Detect ps2 nak response.
authorKevin O'Connor <kevin@koconnor.net>
Thu, 7 May 2009 03:18:48 +0000 (23:18 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 7 May 2009 03:18:48 +0000 (23:18 -0400)
For now, just ignore the nak.

src/ps2port.c

index 017e3ed67952f132ae0d68da2971cdb4838069c8..01e8b3d607b45f4ef72f0eed21dac5da2c19386f 100644 (file)
@@ -163,14 +163,19 @@ ps2_recvbyte(int aux, int needack, int timeout)
         u8 data = inb(PORT_PS2_DATA);
         dprintf(7, "ps2 read %x\n", data);
 
-        if ((!!(status & I8042_STR_AUXDATA) != aux)
-            || (needack && data != PS2_RET_ACK)) {
-            // This data not for us - XXX - just discard it for now.
-            dprintf(1, "Discarding ps2 data %x (status=%x)\n", data, status);
-            continue;
+        if (!!(status & I8042_STR_AUXDATA) == aux) {
+            if (!needack)
+                return data;
+            if (data == PS2_RET_ACK)
+                return data;
+            if (data == PS2_RET_NAK) {
+                dprintf(1, "Got ps2 nak (status=%x); continuing\n", status);
+                return data;
+            }
         }
 
-        return data;
+        // This data not for us - XXX - just discard it for now.
+        dprintf(1, "Discarding ps2 data %x (status=%x)\n", data, status);
     }
 }