]> git.proxmox.com Git - mirror_qemu.git/commit
ps2: use a separate keyboard command reply queue
authorVolker Rümelin <vr_qemu@t-online.de>
Tue, 10 Aug 2021 13:32:57 +0000 (15:32 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 10 Sep 2021 05:32:32 +0000 (07:32 +0200)
commit9e24b2dd77da42bbba39ef5c44c757132017910b
tree750710d17938ab0a76e66d1594eec5d9ac0bdd42
parent47db243233cdf9cafc5148e2026aa55b119a59ec
ps2: use a separate keyboard command reply queue

A PS/2 keyboard has a separate command reply queue that is
independent of the key queue. This prevents that command replies
and keyboard input mix. Keyboard command replies take precedence
over queued keystrokes. A new keyboard command removes any
remaining command replies from the command reply queue.

Implement a separate keyboard command reply queue and clear the
command reply queue before command execution. This brings the
PS/2 keyboard emulation much closer to a real PS/2 keyboard.

The command reply queue is located in a few free bytes directly
in front of the scancode queue. Because the scancode queue has
a maximum length of 16 bytes there are 240 bytes available for
the command reply queue. At the moment only a maximum of 3 bytes
are required. For compatibility reasons rptr, wptr and count kept
their function. rptr is the start, wptr is the end and count is
the length of the entire keyboard queue. The new variable cwptr
is the end of the command reply queue or -1 if the queue is
empty. To write to the command reply queue, rptr is moved
backward by the number of required bytes and the command replies
are written to the buffer starting at the new rptr position.
After writing, cwptr is at the old rptr position. Copying cwptr
to rptr clears the command reply queue. The command reply queue
can't overflow because each new keyboard command clears the
command reply queue.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/501
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/502
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20210810133258.8231-2-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/input/ps2.c