Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/boot.c | 44 +++++++++++++++++++++++++++++++++++++++++++- src/util.c | 41 ----------------------------------------- src/util.h | 1 - 3 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/src/boot.c b/src/boot.c index bbe9155..3542283 100644 --- a/src/boot.c +++ b/src/boot.c @@ -1,6 +1,6 @@ // Code to load disk image and start system boot. // -// Copyright (C) 2008-2010 Kevin O'Connor kevin@koconnor.net +// Copyright (C) 2008-2013 Kevin O'Connor kevin@koconnor.net // Copyright (C) 2002 MandrakeSoft S.A. // // This file may be distributed under the terms of the GNU LGPLv3 license. @@ -396,6 +396,48 @@ boot_add_cbfs(void *data, const char *desc, int prio)
/**************************************************************** + * Keyboard calls + ****************************************************************/ + +// See if a keystroke is pending in the keyboard buffer. +static int +check_for_keystroke(void) +{ + struct bregs br; + memset(&br, 0, sizeof(br)); + br.flags = F_IF|F_ZF; + br.ah = 1; + call16_int(0x16, &br); + return !(br.flags & F_ZF); +} + +// Return a keystroke - waiting forever if necessary. +static int +get_raw_keystroke(void) +{ + struct bregs br; + memset(&br, 0, sizeof(br)); + br.flags = F_IF; + call16_int(0x16, &br); + return br.ah; +} + +// Read a keystroke - waiting up to 'msec' milliseconds. +static int +get_keystroke(int msec) +{ + u32 end = irqtimer_calc(msec); + for (;;) { + if (check_for_keystroke()) + return get_raw_keystroke(); + if (irqtimer_check(end)) + return -1; + yield_toirq(); + } +} + + +/**************************************************************** * Boot menu and BCV execution ****************************************************************/
diff --git a/src/util.c b/src/util.c index dd7afdf..ee59b13 100644 --- a/src/util.c +++ b/src/util.c @@ -233,44 +233,3 @@ nullTrailingSpace(char *buf) while (end >= buf && *end <= ' ') *(end--) = '\0'; } - -/**************************************************************** - * Keyboard calls - ****************************************************************/ - -// See if a keystroke is pending in the keyboard buffer. -static int -check_for_keystroke(void) -{ - struct bregs br; - memset(&br, 0, sizeof(br)); - br.flags = F_IF|F_ZF; - br.ah = 1; - call16_int(0x16, &br); - return !(br.flags & F_ZF); -} - -// Return a keystroke - waiting forever if necessary. -static int -get_raw_keystroke(void) -{ - struct bregs br; - memset(&br, 0, sizeof(br)); - br.flags = F_IF; - call16_int(0x16, &br); - return br.ah; -} - -// Read a keystroke - waiting up to 'msec' milliseconds. -int -get_keystroke(int msec) -{ - u32 end = irqtimer_calc(msec); - for (;;) { - if (check_for_keystroke()) - return get_raw_keystroke(); - if (irqtimer_check(end)) - return -1; - yield_toirq(); - } -} diff --git a/src/util.h b/src/util.h index 70114a6..4fa0939 100644 --- a/src/util.h +++ b/src/util.h @@ -30,7 +30,6 @@ void *memmove(void *d, const void *s, size_t len); char *strtcpy(char *dest, const char *src, size_t len); char *strchr(const char *s, int c); void nullTrailingSpace(char *buf); -int get_keystroke(int msec);
// stacks.c extern u8 ExtraStack[], *StackPos;