[PATCH] libpayload: Bail if the keyboard controller isn't there
authorJordan Crouse <jordan.crouse@amd.com>
Mon, 20 Oct 2008 17:07:26 +0000 (17:07 +0000)
committerJordan Crouse <jordan.crouse@amd.com>
Mon, 20 Oct 2008 17:07:26 +0000 (17:07 +0000)
If the system in question does not have a superIO, then a read of
0x64 will return 0xFF and we will loop forever.

Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Patrick Georgi <patrick.georgi@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3675 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

payloads/libpayload/drivers/keyboard.c

index 0bf7c56161b9430b63a6e41f77f5491f78c12594..95827463ca2b3827fd0ac47c265413857a4175b7 100644 (file)
@@ -175,11 +175,10 @@ static void keyboard_cmd(unsigned char cmd, unsigned char val)
        while (inb(0x64) & 2);
 }
 
-
 int keyboard_havechar(void)
 {
        unsigned char c = inb(0x64);
-       return c & 1;
+       return (c == 0xFF) ? 0 : c & 1;
 }
 
 unsigned char keyboard_get_scancode(void)
@@ -332,6 +331,12 @@ void keyboard_init(void)
        u8 mode;
        map = &keyboard_layouts[0];
 
+       /* If 0x64 returns 0xff, then we have no keyboard
+        * controller */
+
+       if (inb(0x64) == 0xFF)
+               return;
+
        /* Empty keyboard buffer */
        while (keyboard_havechar()) keyboard_getchar();