mirror of
https://github.com/ipxe/ipxe
synced 2025-12-24 15:23:42 +03:00
Merged mcb30-realmode-redesign back to HEAD
This commit is contained in:
76
src/arch/i386/firmware/pcbios/bios_console.c
Normal file
76
src/arch/i386/firmware/pcbios/bios_console.c
Normal file
@@ -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,
|
||||
};
|
||||
Reference in New Issue
Block a user