From 74c958b18075e0e4e7c02f1356b45756f3381e08 Mon Sep 17 00:00:00 2001 From: robertmh Date: Thu, 24 Sep 2009 13:15:51 +0000 Subject: [PATCH] 2009-09-24 Robert Millan * include/grub/i386/at_keyboard.h (KEYBOARD_ISREADY): Negate return value. * term/i386/pc/at_keyboard.c (grub_keyboard_getkey): Negate KEYBOARD_ISREADY check. (grub_at_keyboard_checkkey): Rename to ... (grub_at_keyboard_getkey_noblock): ... this. Update all users. Remove gratuitous cast. --- ChangeLog | 10 ++++++++++ include/grub/i386/at_keyboard.h | 2 +- term/i386/pc/at_keyboard.c | 13 +++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc343d1d9..b5315fa70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-09-24 Robert Millan + + * include/grub/i386/at_keyboard.h (KEYBOARD_ISREADY): Negate + return value. + * term/i386/pc/at_keyboard.c (grub_keyboard_getkey): Negate + KEYBOARD_ISREADY check. + (grub_at_keyboard_checkkey): Rename to ... + (grub_at_keyboard_getkey_noblock): ... this. Update all users. + Remove gratuitous cast. + 2009-09-23 Colin Watson * configure.ac: Call AC_PROG_MKDIR_P. diff --git a/include/grub/i386/at_keyboard.h b/include/grub/i386/at_keyboard.h index 5c15ef344..96b21627f 100644 --- a/include/grub/i386/at_keyboard.h +++ b/include/grub/i386/at_keyboard.h @@ -39,7 +39,7 @@ #define KEYBOARD_SCANCODE_SET1 0x40 #define KEYBOARD_ISMAKE(x) !((x) & 0x80) -#define KEYBOARD_ISREADY(x) (((x) & 0x01) == 0) +#define KEYBOARD_ISREADY(x) ((x) & 0x01) #define KEYBOARD_SCANCODE(x) ((x) & 0x7f) #ifdef GRUB_MACHINE_IEEE1275 diff --git a/term/i386/pc/at_keyboard.c b/term/i386/pc/at_keyboard.c index 0b2a06d46..1ab41d8fd 100644 --- a/term/i386/pc/at_keyboard.c +++ b/term/i386/pc/at_keyboard.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -135,7 +135,7 @@ static int grub_keyboard_getkey (void) { grub_uint8_t key; - if (KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) + if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) return -1; key = grub_inb (KEYBOARD_REG_DATA); /* FIXME */ grub_keyboard_isr (key); @@ -146,7 +146,7 @@ grub_keyboard_getkey (void) /* If there is a character pending, return it; otherwise return -1. */ static int -grub_at_keyboard_checkkey (void) +grub_at_keyboard_getkey_noblock (void) { int code, key; code = grub_keyboard_getkey (); @@ -186,7 +186,7 @@ grub_at_keyboard_checkkey (void) key += 'a' - 'A'; } } - return (int) key; + return key; } static int @@ -195,7 +195,7 @@ grub_at_keyboard_getkey (void) int key; do { - key = grub_at_keyboard_checkkey (); + key = grub_at_keyboard_getkey_noblock (); } while (key == -1); return key; } @@ -220,7 +220,8 @@ static struct grub_term_input grub_at_keyboard_term = .name = "at_keyboard", .init = grub_keyboard_controller_init, .fini = grub_keyboard_controller_fini, - .checkkey = grub_at_keyboard_checkkey, + /* FIXME: This routine flushes input buffer, and it shouldn't. */ + .checkkey = grub_at_keyboard_getkey_noblock, .getkey = grub_at_keyboard_getkey, };