X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fps2port.c;h=1f042999047ed818e7a5b458c0c03716b9b4cc0d;hb=091dd17e8dc2ca242ae6839a6699dbc0ed52a3ed;hp=ccbd2f698b59210057b3be59f16d413129e8b6f3;hpb=cc9e1bf4336696340330010d59028e3b8fb9aa7d;p=seabios.git diff --git a/src/ps2port.c b/src/ps2port.c index ccbd2f6..1f04299 100644 --- a/src/ps2port.c +++ b/src/ps2port.c @@ -7,6 +7,7 @@ #include "ioport.h" // inb #include "util.h" // dprintf +#include "paravirt.h" // romfile_loadint #include "biosvar.h" // GET_EBDA #include "ps2port.h" // ps2_kbd_command #include "pic.h" // eoi_pic1 @@ -51,7 +52,7 @@ i8042_wait_write(void) return -1; } -int +static int i8042_flush(void) { dprintf(7, "i8042_flush\n"); @@ -102,7 +103,7 @@ __i8042_command(int command, u8 *param) return 0; } -int +static int i8042_command(int command, u8 *param) { dprintf(7, "i8042_command cmd=%x\n", command); @@ -128,6 +129,20 @@ i8042_aux_write(u8 c) return i8042_command(I8042_CMD_AUX_SEND, &c); } +void +i8042_reboot(void) +{ + if (! CONFIG_PS2PORT) + return; + int i; + for (i=0; i<10; i++) { + i8042_wait_write(); + udelay(50); + outb(0xfe, PORT_PS2_STATUS); /* pulse reset low */ + udelay(50); + } +} + /**************************************************************** * Device commands. @@ -309,12 +324,28 @@ ps2_command(int aux, int command, u8 *param) int ps2_kbd_command(int command, u8 *param) { + if (! CONFIG_PS2PORT) + return -1; return ps2_command(0, command, param); } int ps2_mouse_command(int command, u8 *param) { + if (! CONFIG_PS2PORT) + return -1; + + // Update ps2ctr for mouse enable/disable. + if (command == PSMOUSE_CMD_ENABLE || command == PSMOUSE_CMD_DISABLE) { + u16 ebda_seg = get_ebda_seg(); + u8 ps2ctr = GET_EBDA2(ebda_seg, ps2ctr); + if (command == PSMOUSE_CMD_ENABLE) + ps2ctr = (ps2ctr | I8042_CTR_AUXINT) & ~I8042_CTR_AUXDIS; + else + ps2ctr = (ps2ctr | I8042_CTR_AUXDIS) & ~I8042_CTR_AUXINT; + SET_EBDA2(ebda_seg, ps2ctr, ps2ctr); + } + return ps2_command(1, command, param); } @@ -415,9 +446,19 @@ keyboard_init(void *data) /* ------------------- keyboard side ------------------------*/ /* reset keyboard and self test (keyboard side) */ - ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param); - if (ret) - return; + int spinupdelay = romfile_loadint("etc/ps2-keyboard-spinup", 0); + u64 end = calc_future_tsc(spinupdelay); + for (;;) { + ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param); + if (!ret) + break; + if (check_tsc(end)) { + if (spinupdelay) + warn_timeout(); + return; + } + yield(); + } if (param[0] != 0xaa) { dprintf(1, "keyboard self test failed (got %x not 0xaa)\n", param[0]); return;