Revert "Rework disabling of ps2 port irqs."
[seabios.git] / src / mouse.c
index 3004d7864aef5da7e016c3142e7a9a29764096dc..8389d2a093d1c847286b2bbd00726f3296ee761f 100644 (file)
@@ -29,8 +29,13 @@ mouse_setup(void)
 #define RET_ENOHANDLER   0x05
 
 static int
-disable_mouse(void)
+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);
 }
 
@@ -38,7 +43,8 @@ disable_mouse(void)
 static void
 mouse_15c20000(struct bregs *regs)
 {
-    int ret = disable_mouse();
+    u16 ebda_seg = get_ebda_seg();
+    int ret = disable_mouse(ebda_seg);
     if (ret)
         set_code_invalid(regs, RET_ENEEDRESEND);
     else
@@ -49,12 +55,18 @@ mouse_15c20000(struct bregs *regs)
 static void
 mouse_15c20001(struct bregs *regs)
 {
-    u8 mouse_flags_2 = GET_EBDA(mouse_flag2);
+    u16 ebda_seg = get_ebda_seg();
+    u8 mouse_flags_2 = GET_EBDA2(ebda_seg, 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);
     if (ret)
         set_code_invalid(regs, RET_ENEEDRESEND);
@@ -229,7 +241,7 @@ mouse_15c207(struct bregs *regs)
         /* remove handler */
         if ((mouse_flags_2 & 0x80) != 0) {
             mouse_flags_2 &= ~0x80;
-            disable_mouse();
+            disable_mouse(ebda_seg);
         }
     } else {
         /* install handler */