[SeaBIOS] [PATCH] i8042_flush change
john.baboval at virtualcomputer.com
Thu Oct 27 22:55:15 CEST 2011
When using seabios with Xen and qemu, I frequently get the following
WARNING - Timeout at i8042_flush:69!
I do have a slightly unusual configuration compared to the typical Xen
configuration. We are running with no hvmloader. However I don't think
that's related to this issue....
The flush routine attempts to read the queue depth's worth of data from
the port and then checks to see if the queue is empty. There are two
issues with this. First is that qemu and seabios disagree about the
queue depth. Qemu's ps2 buffer has 256 entries, and I8042_BUFFER_SIZE is
16 for seabios. The second is that a command may arrive between the
start of the flush loop and the completion.
I believe a more robust way to do this would be to first issue a RESET
command, and then flush. That resolves the issue that I am seeing.
Signed-off By: John Baboval <john.baboval at virtualcomputer.com>
diff --git a/src/ps2port.c b/src/ps2port.c
index 58335af..4ed25bf 100644
@@ -20,7 +20,7 @@
// Timeout value.
#define I8042_CTL_TIMEOUT 10000
-#define I8042_BUFFER_SIZE 16
+#define I8042_BUFFER_SIZE 256
@@ -391,7 +391,7 @@ handle_09(void)
v = inb(PORT_PS2_DATA);
- if (!(GET_EBDA(ps2ctr) & I8042_CTR_KBDINT))
+ if (!(GET_EBDA(ps2ctr) & I8042_CTR_KBDINT))
// Interrupts not enabled.
@@ -409,13 +409,17 @@ done:
+ int ret;
+ u8 param;
/* flush incoming keys */
- int ret = i8042_flush();
+ ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param);
+ if (ret)
+ ret = i8042_flush();
// Controller self-test.
- u8 param;
ret = i8042_command(I8042_CMD_CTL_TEST, param);
More information about the SeaBIOS