--- qemu/roms/seabios/src/mouse.c 2018/04/24 17:36:47 1.1 +++ qemu/roms/seabios/src/mouse.c 2018/04/24 19:23:53 1.1.1.4 @@ -9,10 +9,11 @@ #include "util.h" // debug_isr #include "pic.h" // eoi_pic2 #include "bregs.h" // struct bregs -#include "ps2port.h" // aux_command +#include "ps2port.h" // ps2_mouse_command +#include "usb-hid.h" // usb_mouse_command void -mouse_setup() +mouse_setup(void) { if (! CONFIG_MOUSE) return; @@ -21,6 +22,14 @@ mouse_setup() SETBITS_BDA(equipment_list_flags, 0x04); } +static inline int +mouse_command(int command, u8 *param) +{ + if (usb_mouse_active()) + return usb_mouse_command(command, param); + return ps2_mouse_command(command, param); +} + #define RET_SUCCESS 0x00 #define RET_EINVFUNCTION 0x01 #define RET_EINVINPUT 0x02 @@ -28,23 +37,11 @@ mouse_setup() #define RET_ENEEDRESEND 0x04 #define RET_ENOHANDLER 0x05 -static int -disable_mouse(u16 ebda_seg) -{ - u8 ps2ctr = GET_EBDA2(ebda_seg, ps2ctr); - ps2ctr |= I8042_CTR_AUXDIS; - ps2ctr &= ~I8042_CTR_AUXINT; - SET_EBDA2(ebda_seg, ps2ctr, ps2ctr); - - return aux_command(PSMOUSE_CMD_DISABLE, NULL); -} - // Disable Mouse static void mouse_15c20000(struct bregs *regs) { - u16 ebda_seg = get_ebda_seg(); - int ret = disable_mouse(ebda_seg); + int ret = mouse_command(PSMOUSE_CMD_DISABLE, NULL); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else @@ -55,19 +52,13 @@ mouse_15c20000(struct bregs *regs) static void mouse_15c20001(struct bregs *regs) { - u16 ebda_seg = get_ebda_seg(); - u8 mouse_flags_2 = GET_EBDA2(ebda_seg, mouse_flag2); + u8 mouse_flags_2 = GET_EBDA(mouse_flag2); if ((mouse_flags_2 & 0x80) == 0) { set_code_invalid(regs, RET_ENOHANDLER); return; } - u8 ps2ctr = GET_EBDA2(ebda_seg, ps2ctr); - ps2ctr &= ~I8042_CTR_AUXDIS; - ps2ctr |= I8042_CTR_AUXINT; - SET_EBDA2(ebda_seg, ps2ctr, ps2ctr); - - int ret = aux_command(PSMOUSE_CMD_ENABLE, NULL); + int ret = mouse_command(PSMOUSE_CMD_ENABLE, NULL); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else @@ -96,7 +87,7 @@ static void mouse_15c201(struct bregs *regs) { u8 param[2]; - int ret = aux_command(PSMOUSE_CMD_RESET_BAT, param); + int ret = mouse_command(PSMOUSE_CMD_RESET_BAT, param); if (ret) { set_code_invalid(regs, RET_ENEEDRESEND); return; @@ -116,7 +107,7 @@ mouse_15c202(struct bregs *regs) return; } u8 mouse_data1 = GET_GLOBAL(sample_rates[regs->bh]); - int ret = aux_command(PSMOUSE_CMD_SETRATE, &mouse_data1); + int ret = mouse_command(PSMOUSE_CMD_SETRATE, &mouse_data1); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else @@ -137,7 +128,7 @@ mouse_15c203(struct bregs *regs) return; } u8 param = regs->bh; - int ret = aux_command(PSMOUSE_CMD_SETRES, ¶m); + int ret = mouse_command(PSMOUSE_CMD_SETRES, ¶m); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else @@ -149,7 +140,7 @@ static void mouse_15c204(struct bregs *regs) { u8 param[2]; - int ret = aux_command(PSMOUSE_CMD_GETID, param); + int ret = mouse_command(PSMOUSE_CMD_GETID, param); if (ret) { set_code_invalid(regs, RET_ENEEDRESEND); return; @@ -179,7 +170,7 @@ static void mouse_15c20600(struct bregs *regs) { u8 param[3]; - int ret = aux_command(PSMOUSE_CMD_GETINFO, param); + int ret = mouse_command(PSMOUSE_CMD_GETINFO, param); if (ret) { set_code_invalid(regs, RET_ENEEDRESEND); return; @@ -194,7 +185,7 @@ mouse_15c20600(struct bregs *regs) static void mouse_15c20601(struct bregs *regs) { - int ret = aux_command(PSMOUSE_CMD_SETSCALE11, NULL); + int ret = mouse_command(PSMOUSE_CMD_SETSCALE11, NULL); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else @@ -205,7 +196,7 @@ mouse_15c20601(struct bregs *regs) static void mouse_15c20602(struct bregs *regs) { - int ret = aux_command(PSMOUSE_CMD_SETSCALE21, NULL); + int ret = mouse_command(PSMOUSE_CMD_SETSCALE21, NULL); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else @@ -241,7 +232,7 @@ mouse_15c207(struct bregs *regs) /* remove handler */ if ((mouse_flags_2 & 0x80) != 0) { mouse_flags_2 &= ~0x80; - disable_mouse(ebda_seg); + mouse_command(PSMOUSE_CMD_DISABLE, NULL); } } else { /* install handler */ @@ -281,7 +272,7 @@ handle_15c2(struct bregs *regs) } } -void +void noinline process_mouse(u8 data) { if (!CONFIG_MOUSE) @@ -305,15 +296,17 @@ process_mouse(u8 data) return; } - //BX_DEBUG_INT74("int74_function: make_farcall=1\n"); u16 status = GET_EBDA2(ebda_seg, mouse_data[0]); u16 X = GET_EBDA2(ebda_seg, mouse_data[1]); u16 Y = GET_EBDA2(ebda_seg, mouse_data[2]); SET_EBDA2(ebda_seg, mouse_flag1, 0); struct segoff_s func = GET_EBDA2(ebda_seg, far_call_pointer); + dprintf(16, "mouse farcall s=%04x x=%04x y=%04x func=%04x:%04x\n" + , status, X, Y, func.seg, func.offset); asm volatile( + "pushl %%ebp\n" "sti\n" "pushl %0\n" @@ -326,8 +319,8 @@ process_mouse(u8 data) "cli\n" "cld\n" + "popl %%ebp" + : "+a"(func.segoff), "+c"(status), "+d"(X), "+b"(Y) : - : "r"(func.segoff), "r"(status), "r"(X), "r"(Y) - : "cc" - ); + : "edi", "esi", "cc", "memory"); }