diff options
author | Jordan Crouse <jordan.crouse@amd.com> | 2008-04-25 23:09:39 +0000 |
---|---|---|
committer | Jordan Crouse <jordan.crouse@amd.com> | 2008-04-25 23:09:39 +0000 |
commit | 63f181f97c0b89f5fe80f96df7b6288a59f5ad42 (patch) | |
tree | 94b8ac341edc88512413adf32922469156c7b268 /payloads | |
parent | 24a040475918ad2977a52677f59b10f7ce085afc (diff) |
libpayload: Enable keyboard translation so that we can use scancode set 1
The qemu keyboard controller defaults to using scancode set 2, we use set 1.
Turn on the translate mode in the keyboard controller to force the issue.
Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Peter Stuge <peter@stuge.se>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3270 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads')
-rw-r--r-- | payloads/libpayload/drivers/keyboard.c | 56 | ||||
-rw-r--r-- | payloads/libpayload/include/libpayload.h | 1 | ||||
-rw-r--r-- | payloads/libpayload/libc/console.c | 3 |
3 files changed, 60 insertions, 0 deletions
diff --git a/payloads/libpayload/drivers/keyboard.c b/payloads/libpayload/drivers/keyboard.c index 1049b9ccec..540936dae5 100644 --- a/payloads/libpayload/drivers/keyboard.c +++ b/payloads/libpayload/drivers/keyboard.c @@ -29,6 +29,11 @@ #include <libpayload.h> +#define I8042_CMD_READ_MODE 0x20 +#define I8042_CMD_WRITE_MODE 0x60 + +#define I8042_MODE_XLATE 0x40 + unsigned char map[2][0x57] = { { 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, @@ -118,3 +123,54 @@ int keyboard_getchar(void) return ret; } + +static int keyboard_wait_read(void) +{ + int timeout = 10000; + + while(timeout-- && !(inb(0x64) & 0x01)) + udelay(50); + + return (timeout <= 0) ? -1 : 0; +} + +static int keyboard_wait_write(void) +{ + int timeout = 10000; + + while(timeout-- && (inb(0x64) & 0x02)) + udelay(50); + + return (timeout <= 0) ? -1 : 0; +} + +static unsigned char keyboard_get_mode(void) +{ + outb(I8042_CMD_READ_MODE, 0x64); + keyboard_wait_read(); + return inb(0x60); +} + +static void keyboard_set_mode(unsigned char mode) +{ + outb(I8042_CMD_WRITE_MODE, 0x64); + keyboard_wait_write(); + outb(mode, 0x60); +} + +void keyboard_init(void) +{ + u8 mode; + + /* Read the current mode */ + mode = keyboard_get_mode(); + + /* Turn on scancode translate mode so that we can + use the scancode set 1 tables */ + + mode |= I8042_MODE_XLATE; + + /* Write the new mode */ + keyboard_set_mode(mode); +} + diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h index 611f65e432..d557eeff69 100644 --- a/payloads/libpayload/include/libpayload.h +++ b/payloads/libpayload/include/libpayload.h @@ -67,6 +67,7 @@ u8 nvram_read(u8 addr); void nvram_write(u8 val, u8 addr); /* drivers/keyboard.c */ +void keyboard_init(void); int keyboard_havechar(void); unsigned char keyboard_get_scancode(void); int keyboard_getchar(void); diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c index b0bfe241c0..292cac9ca3 100644 --- a/payloads/libpayload/libc/console.c +++ b/payloads/libpayload/libc/console.c @@ -37,6 +37,9 @@ void console_init(void) #ifdef CONFIG_SERIAL_CONSOLE serial_init(); #endif +#ifdef CONFIG_PC_KEYBOARD + keyboard_init(); +#endif } static void device_putchar(unsigned char c) |