// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
// Copyright (C) 2002 MandrakeSoft S.A.
//
-// This file may be distributed under the terms of the GNU GPLv3 license.
+// This file may be distributed under the terms of the GNU LGPLv3 license.
#include "biosvar.h" // GET_BDA
#include "util.h" // debug_enter
static void
keyboard_init()
{
- if (CONFIG_COREBOOT)
- // Coreboot already does low-level keyboard init.
- goto end;
-
/* flush incoming keys */
int ret = i8042_flush();
if (ret)
/* ------------------- keyboard side ------------------------*/
/* reset keyboard and self test (keyboard side) */
ret = kbd_command(ATKBD_CMD_RESET_BAT, param);
- if (ret != 0 && ret != 2)
+ if (ret)
return;
if (param[0] != 0xaa) {
dprintf(1, "keyboard self test failed (got %x not 0xaa)\n", param[0]);
if (ret)
return;
-end:
+ // Set scancode command (mode 2)
+ param[0] = 0x02;
+ ret = kbd_command(ATKBD_CMD_SSCANSET, param);
+ if (ret)
+ return;
+
// Keyboard Mode: scan code convert, disable mouse, enable IRQ 1
SET_EBDA(ps2ctr, I8042_CTR_AUXDIS | I8042_CTR_XLATE | I8042_CTR_KBDINT);
kbd_setup()
{
dprintf(3, "init keyboard\n");
- u16 x = offsetof(struct bios_data_area_s, kbd_buf) - 0x400;
+ u16 x = offsetof(struct bios_data_area_s, kbd_buf);
SET_BDA(kbd_mode, 0x10);
SET_BDA(kbd_buf_head, x);
SET_BDA(kbd_buf_tail, x);
if (buffer_tail == buffer_head)
return 0;
- SET_FARVAR(SEG_BDA, *(u8*)(temp_tail+0x400+0), ascii_code);
- SET_FARVAR(SEG_BDA, *(u8*)(temp_tail+0x400+1), scan_code);
+ SET_FARVAR(SEG_BDA, *(u8*)(temp_tail+0), ascii_code);
+ SET_FARVAR(SEG_BDA, *(u8*)(temp_tail+1), scan_code);
SET_BDA(kbd_buf_tail, buffer_tail);
return 1;
}
cpu_relax();
}
- u8 ascii_code = GET_FARVAR(SEG_BDA, *(u8*)(buffer_head+0x400+0));
- u8 scan_code = GET_FARVAR(SEG_BDA, *(u8*)(buffer_head+0x400+1));
+ u8 ascii_code = GET_FARVAR(SEG_BDA, *(u8*)(buffer_head+0));
+ u8 scan_code = GET_FARVAR(SEG_BDA, *(u8*)(buffer_head+1));
if ((ascii_code == 0xF0 && scan_code != 0)
|| (ascii_code == 0xE0 && !extended))
ascii_code = 0;
if (scancode & 0x80)
// toss key releases
break;
- if (scancode == 0x53 && (shift_flags & 0x0c) == 0x0c)
+ if (scancode == 0x53 && (shift_flags & 0x0c) == 0x0c) {
// Ctrl+alt+del - reset machine.
+ SET_BDA(soft_reset_flag, 0x1234);
reset_vector();
+ }
if (scancode > MAX_SCAN_CODE) {
dprintf(1, "KBD: int09h_handler(): unknown scancode read: 0x%02x!\n"
, scancode);
// read key from keyboard controller
u8 v = inb(PORT_PS2_STATUS);
- if ((v & 0x21) != 0x01) {
- dprintf(1, "int09 but no keyboard data.\n");
+ if ((v & (I8042_STR_OBF|I8042_STR_AUXDATA)) != I8042_STR_OBF) {
+ dprintf(1, "keyboard irq but no keyboard data.\n");
goto done;
}
u8 key = inb(PORT_PS2_DATA);