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
This commit is contained in:
Jordan Crouse 2008-04-25 23:09:39 +00:00
parent 24a0404759
commit 63f181f97c
3 changed files with 60 additions and 0 deletions

View File

@ -29,6 +29,11 @@
#include <libpayload.h> #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] = { unsigned char map[2][0x57] = {
{ {
0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
@ -118,3 +123,54 @@ int keyboard_getchar(void)
return ret; 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);
}

View File

@ -67,6 +67,7 @@ u8 nvram_read(u8 addr);
void nvram_write(u8 val, u8 addr); void nvram_write(u8 val, u8 addr);
/* drivers/keyboard.c */ /* drivers/keyboard.c */
void keyboard_init(void);
int keyboard_havechar(void); int keyboard_havechar(void);
unsigned char keyboard_get_scancode(void); unsigned char keyboard_get_scancode(void);
int keyboard_getchar(void); int keyboard_getchar(void);

View File

@ -37,6 +37,9 @@ void console_init(void)
#ifdef CONFIG_SERIAL_CONSOLE #ifdef CONFIG_SERIAL_CONSOLE
serial_init(); serial_init();
#endif #endif
#ifdef CONFIG_PC_KEYBOARD
keyboard_init();
#endif
} }
static void device_putchar(unsigned char c) static void device_putchar(unsigned char c)