summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHervé Poussineau <hpoussin@reactos.org>2016-09-15 22:06:24 +0200
committerGerd Hoffmann <kraxel@redhat.com>2016-09-28 14:03:18 +0200
commit4df23b64c51cc830d19eb29801070d31aa1e81cd (patch)
tree5763aa77d003492b1aead8c03a36c47f68d34194
parent06b3611fc2a3001d3940fa3bfa404c679b7d2b13 (diff)
downloadqemu-4df23b64c51cc830d19eb29801070d31aa1e81cd.tar.gz
qemu-4df23b64c51cc830d19eb29801070d31aa1e81cd.tar.bz2
qemu-4df23b64c51cc830d19eb29801070d31aa1e81cd.zip
ps2: correctly handle 'get/set scancode' command
When getting scancode, current scancode must be preceded from reply ack. When setting scancode, we must reject invalid scancodes. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Message-id: 1473969987-5890-3-git-send-email-hpoussin@reactos.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r--hw/input/ps2.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 00a1792228..2105e51f0b 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -296,16 +296,18 @@ void ps2_write_keyboard(void *opaque, int val)
break;
case KBD_CMD_SCANCODE:
if (val == 0) {
+ ps2_queue(&s->common, KBD_REPLY_ACK);
if (s->scancode_set == 1)
ps2_put_keycode(s, 0x43);
else if (s->scancode_set == 2)
ps2_put_keycode(s, 0x41);
else if (s->scancode_set == 3)
ps2_put_keycode(s, 0x3f);
- } else {
- if (val >= 1 && val <= 3)
- s->scancode_set = val;
+ } else if (val >= 1 && val <= 3) {
+ s->scancode_set = val;
ps2_queue(&s->common, KBD_REPLY_ACK);
+ } else {
+ ps2_queue(&s->common, KBD_REPLY_RESEND);
}
s->common.write_cmd = -1;
break;