summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/firmware/pcbios/bios_console.c
diff options
context:
space:
mode:
authorMichael Brown2005-04-08 17:01:17 +0200
committerMichael Brown2005-04-08 17:01:17 +0200
commit0ff80b477dcff0726ebdbed95e8a93971e59e82b (patch)
tree860b7150212a07c24a9529ea072f3fb12700974c /src/arch/i386/firmware/pcbios/bios_console.c
parentMerged this file into HEAD (diff)
downloadipxe-0ff80b477dcff0726ebdbed95e8a93971e59e82b.tar.gz
ipxe-0ff80b477dcff0726ebdbed95e8a93971e59e82b.tar.xz
ipxe-0ff80b477dcff0726ebdbed95e8a93971e59e82b.zip
Merged mcb30-realmode-redesign back to HEAD
Diffstat (limited to 'src/arch/i386/firmware/pcbios/bios_console.c')
-rw-r--r--src/arch/i386/firmware/pcbios/bios_console.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/arch/i386/firmware/pcbios/bios_console.c b/src/arch/i386/firmware/pcbios/bios_console.c
new file mode 100644
index 00000000..b0bee1ab
--- /dev/null
+++ b/src/arch/i386/firmware/pcbios/bios_console.c
@@ -0,0 +1,76 @@
+/* Etherboot routines for PCBIOS firmware.
+ *
+ * Body of routines taken from old pcbios.S
+ */
+
+#include "compiler.h"
+#include "realmode.h"
+#include "console.h"
+
+#define ZF ( 1 << 6 )
+
+/**************************************************************************
+bios_putchar - Print a character on console
+**************************************************************************/
+static void bios_putchar ( int character ) {
+ REAL_EXEC ( rm_console_putc,
+ "sti\n\t"
+ "movb $0x0e, %%ah\n\t"
+ "movl $1, %%ebx\n\t"
+ "int $0x10\n\t"
+ "cli\n\t",
+ 1,
+ OUT_CONSTRAINTS ( "=a" ( character ) ),
+ IN_CONSTRAINTS ( "a" ( character ) ),
+ CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
+
+ /* NOTE: %eax may be clobbered, so must be specified as an output
+ * parameter, even though we don't then do anything with it.
+ */
+}
+
+/**************************************************************************
+bios_getchar - Get a character from console
+**************************************************************************/
+static int bios_getchar ( void ) {
+ uint16_t character;
+
+ REAL_EXEC ( rm_console_getc,
+ "sti\n\t"
+ "xorw %%ax, %%ax\n\t"
+ "int $0x16\n\t"
+ "cli\n\t",
+ 1,
+ OUT_CONSTRAINTS ( "=a" ( character ) ),
+ IN_CONSTRAINTS (),
+ CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
+
+ return ( character & 0xff );
+}
+
+/**************************************************************************
+bios_iskey - Check for keyboard interrupt
+**************************************************************************/
+static int bios_iskey ( void ) {
+ uint16_t flags;
+
+ REAL_EXEC ( rm_console_ischar,
+ "sti\n\t"
+ "movb $1, %%ah\n\t"
+ "int $0x16\n\t"
+ "pushfw\n\t"
+ "popw %%ax\n\t"
+ "cli\n\t",
+ 1,
+ OUT_CONSTRAINTS ( "=a" ( flags ) ),
+ IN_CONSTRAINTS (),
+ CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
+
+ return ( ( flags & ZF ) == 0 );
+}
+
+static struct console_driver bios_console __console_driver = {
+ .putchar = bios_putchar,
+ .getchar = bios_getchar,
+ .iskey = bios_iskey,
+};