--- qemu/roms/seabios/src/kbd.c 2018/04/24 17:36:48 1.1 +++ qemu/roms/seabios/src/kbd.c 2018/04/24 18:27:32 1.1.1.3 @@ -9,7 +9,8 @@ #include "util.h" // debug_enter #include "config.h" // CONFIG_* #include "bregs.h" // struct bregs -#include "ps2port.h" // kbd_command +#include "ps2port.h" // ps2_kbd_command +#include "usb-hid.h" // usb_kbd_command // Bit definitions for BDA kbd_flag[012] #define KF0_RSHIFT (1<<0) @@ -34,7 +35,7 @@ #define KF2_101KBD (1<<4) void -kbd_setup() +kbd_setup(void) { dprintf(3, "init keyboard\n"); u16 x = offsetof(struct bios_data_area_s, kbd_buf); @@ -73,6 +74,7 @@ enqueue_key(u8 scan_code, u8 ascii_code) static void dequeue_key(struct bregs *regs, int incr, int extended) { + yield(); u16 buffer_head; u16 buffer_tail; for (;;) { @@ -108,6 +110,14 @@ dequeue_key(struct bregs *regs, int incr SET_BDA(kbd_buf_head, buffer_head); } +static inline int +kbd_command(int command, u8 *param) +{ + if (usb_kbd_active()) + return usb_kbd_command(command, param); + return ps2_kbd_command(command, param); +} + // read keyboard input static void handle_1600(struct bregs *regs) @@ -126,6 +136,7 @@ handle_1601(struct bregs *regs) static void handle_1602(struct bregs *regs) { + yield(); regs->al = GET_BDA(kbd_flag0); } @@ -184,6 +195,7 @@ handle_1611(struct bregs *regs) static void handle_1612(struct bregs *regs) { + yield(); regs->al = GET_BDA(kbd_flag0); regs->ah = ((GET_BDA(kbd_flag1) & ~(KF2_RCTRL|KF2_RALT)) | (GET_BDA(kbd_flag2) & (KF2_RCTRL|KF2_RALT))); @@ -220,7 +232,7 @@ handle_16XX(struct bregs *regs) } static void -set_leds() +set_leds(void) { u8 shift_flags = (GET_BDA(kbd_flag0) >> 4) & 0x07; u8 kbd_led = GET_BDA(kbd_led);