]> xenbits.xensource.com Git - seabios.git/commitdiff
ps2port: Disable keyboard/mouse prior to resetting ps2 controller
authorKevin O'Connor <kevin@koconnor.net>
Sat, 11 Feb 2017 17:13:03 +0000 (12:13 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 11 Feb 2017 17:13:03 +0000 (12:13 -0500)
If one of the ps2 ports is enabled prior to the ps2 controller reset
then it is possible a device event (eg, key press or mouse move) could
be mistaken for the controller reset response code.  This would result
in a failure and the keyboard would be disabled during the boot.
Always disabling the keyboard and mouse prior to reset ensures that
the controller reset return code can be read properly.

Tested-by: Paul Menzel <paulepanter@users.sourceforge.net>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/ps2port.c

index d9727d265646d3dded4178cc59122a9193fdf33f..88b1059a048cf0bb11fa1d4c8cc71a29a616b027 100644 (file)
@@ -449,11 +449,22 @@ ps2_check_event(void)
 static void
 ps2_keyboard_setup(void *data)
 {
-    /* flush incoming keys */
+    // flush incoming keys (also verifies port is likely present)
     int ret = i8042_flush();
     if (ret)
         return;
 
+    // Disable keyboard / mouse and drain any input they may have sent
+    ret = i8042_command(I8042_CMD_KBD_DISABLE, NULL);
+    if (ret)
+        return;
+    ret = i8042_command(I8042_CMD_AUX_DISABLE, NULL);
+    if (ret)
+        return;
+    ret = i8042_flush();
+    if (ret)
+        return;
+
     // Controller self-test.
     u8 param[2];
     ret = i8042_command(I8042_CMD_CTL_TEST, param);