* Copyright 2004-2011, Axel DΓΆrfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
#include "keyboard.h"
#include "bios.h"
#include <boot/platform.h>
mode, at least in Bochs.
*/
static uint16
check_for_key(void)
{
bios_regs regs;
regs.eax = 0x0100;
call_bios(0x16, ®s);
if (regs.flags & ZERO_FLAG)
return 0;
regs.eax = 0;
call_bios(0x16, ®s);
return regs.eax & 0xffff;
}
extern "C" void
clear_key_buffer(void)
{
while (check_for_key() != 0)
;
}
extern "C" union key
wait_for_key(void)
{
union key key;
do {
key.ax = check_for_key();
} while (key.ax == 0);
return key;
}
extern "C" uint32
check_for_boot_keys(void)
{
bios_regs regs;
uint32 options = 0;
uint32 keycode = 0;
regs.eax = 0x0200;
call_bios(0x16, ®s);
if ((regs.eax & 0x03) != 0) {
options |= BOOT_OPTION_MENU;
} else {
keycode = boot_key_in_keyboard_buffer();
if (keycode == 0x3920) {
options |= BOOT_OPTION_MENU;
} else if (keycode == 0x011B) {
options |= BOOT_OPTION_DEBUG_OUTPUT;
}
}
dprintf("options = %d\n", options);
return options;
}