]> xenbits.xensource.com Git - seabios.git/commitdiff
ps2: Don't wait 100ms to discard possible extra reset receive byte
authorKevin O'Connor <kevin@koconnor.net>
Wed, 22 Jul 2015 18:32:28 +0000 (14:32 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 22 Jul 2015 18:32:28 +0000 (14:32 -0400)
The existing PS2 port code waits 100ms to see if the device attached
to the keyboard port responds to a reset command with two bytes
(instead of the normal one byte).  If an extra byte is received, it is
discarded.

Receiving two bytes would be unusual and waiting to check for that
event is unnecessary because the next command in the keyboard init
sequence already seamlessly discards any extra bytes in the command
queue.

This patch eliminates the 100ms wait, which notably reduces the
SeaBIOS boot time on QEMU.  This patch also forces PS2 mice to always
respond with two bytes during a reset sequence (instead of just one
byte), which is a good sanity check.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/ps2port.c
src/hw/ps2port.h

index 4558a6e6ed921b590492e47e22c818c27266594f..c368afc082cd3887787d3d6e514b0fb1003ba1a9 100644 (file)
@@ -242,8 +242,8 @@ __ps2_command(int aux, int command, u8 *param)
     if (ret)
         goto fail;
 
-    if (command == ATKBD_CMD_RESET_BAT) {
-        // Reset is special wrt timeouts and bytes received.
+    if ((u8)command == (u8)ATKBD_CMD_RESET_BAT) {
+        // Reset is special wrt timeouts.
 
         // Send command.
         ret = ps2_sendbyte(aux, command, 1000);
@@ -255,11 +255,12 @@ __ps2_command(int aux, int command, u8 *param)
         if (ret < 0)
             goto fail;
         param[0] = ret;
-        ret = ps2_recvbyte(aux, 0, 100);
-        if (ret < 0)
-            // Some devices only respond with one byte on reset.
-            ret = 0;
-        param[1] = ret;
+        if (receive > 1) {
+            ret = ps2_recvbyte(aux, 0, 500);
+            if (ret < 0)
+                goto fail;
+            param[1] = ret;
+        }
     } else if (command == ATKBD_CMD_GETID) {
         // Getid is special wrt bytes received.
 
index dc0e4303bd254077ad3d7fc715347c51173c75f7..1338406ac0cb16a00e380a0d3672bcf68c2012f2 100644 (file)
@@ -26,7 +26,7 @@
 #define ATKBD_CMD_GETID         0x02f2
 #define ATKBD_CMD_ENABLE        0x00f4
 #define ATKBD_CMD_RESET_DIS     0x00f5
-#define ATKBD_CMD_RESET_BAT     0x02ff
+#define ATKBD_CMD_RESET_BAT     0x01ff
 
 // Mouse commands
 #define PSMOUSE_CMD_SETSCALE11  0x00e6