From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <ehabkost@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Volker Rümelin" <vr_qemu@t-online.de>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PULL 09/14] pckbd: add controller response queue
Date: Wed, 26 May 2021 16:06:22 +0200 [thread overview]
Message-ID: <20210526140627.381857-10-kraxel@redhat.com> (raw)
In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com>
From: Volker Rümelin <vr_qemu@t-online.de>
Add a separate queue for PS/2 controller responses. The
responses no longer get queued in the keyboard or mouse queues.
The advantage of this can be seen after the next two patches,
where the guest can disable the PS/2 communication with keyboard
and mouse and still talk to the PS/2 controller.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20210525181441.27768-8-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/input/pckbd.c | 42 +++++++++++++++++++++++++++++++++++-------
1 file changed, 35 insertions(+), 7 deletions(-)
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index 62a3b29074b8..294b31590196 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -133,11 +133,14 @@
#define KBD_PENDING_KBD 1
#define KBD_PENDING_AUX 2
+#define KBD_PENDING_CTRL_KBD 0x04
+#define KBD_PENDING_CTRL_AUX 0x08
#define KBD_MIGR_TIMER_PENDING 0x1
#define KBD_OBSRC_KBD 0x01
#define KBD_OBSRC_MOUSE 0x02
+#define KBD_OBSRC_CTRL 0x04
typedef struct KBDState {
uint8_t write_cmd; /* if non zero, write data to port 60 is expected */
@@ -152,6 +155,7 @@ typedef struct KBDState {
/* Bitmask of devices with data available. */
uint8_t pending;
uint8_t obdata;
+ uint8_t cbdata;
void *kbd;
void *mouse;
QEMUTimer *throttle_timer;
@@ -202,12 +206,18 @@ static void kbd_update_irq(KBDState *s)
if (s->pending) {
s->status |= KBD_STAT_OBF;
s->outport |= KBD_OUT_OBF;
- if (s->pending == KBD_PENDING_AUX) {
+ if (s->pending & KBD_PENDING_CTRL_KBD) {
+ s->obsrc = KBD_OBSRC_CTRL;
+ } else if (s->pending & KBD_PENDING_CTRL_AUX) {
s->status |= KBD_STAT_MOUSE_OBF;
s->outport |= KBD_OUT_MOUSE_OBF;
- s->obsrc = KBD_OBSRC_MOUSE;
- } else {
+ s->obsrc = KBD_OBSRC_CTRL;
+ } else if (s->pending & KBD_PENDING_KBD) {
s->obsrc = KBD_OBSRC_KBD;
+ } else {
+ s->status |= KBD_STAT_MOUSE_OBF;
+ s->outport |= KBD_OUT_MOUSE_OBF;
+ s->obsrc = KBD_OBSRC_MOUSE;
}
}
kbd_update_irq_lines(s);
@@ -276,10 +286,25 @@ static uint64_t kbd_read_status(void *opaque, hwaddr addr,
static void kbd_queue(KBDState *s, int b, int aux)
{
- if (aux)
- ps2_queue(s->mouse, b);
- else
- ps2_queue(s->kbd, b);
+ if (s->extended_state) {
+ s->cbdata = b;
+ s->pending &= ~KBD_PENDING_CTRL_KBD & ~KBD_PENDING_CTRL_AUX;
+ s->pending |= aux ? KBD_PENDING_CTRL_AUX : KBD_PENDING_CTRL_KBD;
+ kbd_safe_update_irq(s);
+ } else {
+ ps2_queue(aux ? s->mouse : s->kbd, b);
+ }
+}
+
+static uint8_t kbd_dequeue(KBDState *s)
+{
+ uint8_t b = s->cbdata;
+
+ s->pending &= ~KBD_PENDING_CTRL_KBD & ~KBD_PENDING_CTRL_AUX;
+ if (s->pending) {
+ kbd_update_irq(s);
+ }
+ return b;
}
static void outport_write(KBDState *s, uint32_t val)
@@ -389,6 +414,8 @@ static uint64_t kbd_read_data(void *opaque, hwaddr addr,
s->obdata = ps2_read_data(s->kbd);
} else if (s->obsrc & KBD_OBSRC_MOUSE) {
s->obdata = ps2_read_data(s->mouse);
+ } else if (s->obsrc & KBD_OBSRC_CTRL) {
+ s->obdata = kbd_dequeue(s);
}
}
@@ -526,6 +553,7 @@ static const VMStateDescription vmstate_kbd_extended_state = {
VMSTATE_UINT32(migration_flags, KBDState),
VMSTATE_UINT32(obsrc, KBDState),
VMSTATE_UINT8(obdata, KBDState),
+ VMSTATE_UINT8(cbdata, KBDState),
VMSTATE_END_OF_LIST()
}
};
--
2.31.1
next prev parent reply other threads:[~2021-05-26 14:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-26 14:06 [PULL 00/14] Input 20210526 patches Gerd Hoffmann
2021-05-26 14:06 ` [PULL 01/14] hw/input: expand trace info reported for ps2 device Gerd Hoffmann
2021-05-26 14:06 ` [PULL 02/14] ps2: fix mouse stream corruption Gerd Hoffmann
2021-05-26 14:06 ` [PULL 03/14] ps2: don't raise an interrupt if queue is full Gerd Hoffmann
2021-05-26 14:06 ` [PULL 04/14] ps2: don't deassert irq twice if queue is empty Gerd Hoffmann
2021-05-26 14:06 ` [PULL 05/14] pckbd: split out interrupt line changing code Gerd Hoffmann
2021-05-26 14:06 ` [PULL 06/14] pckbd: don't update OBF flags if KBD_STAT_OBF is set Gerd Hoffmann
2021-05-26 14:06 ` [PULL 07/14] pckbd: PS/2 keyboard throttle Gerd Hoffmann
2021-05-26 14:06 ` [PULL 08/14] pckbd: add state variable for interrupt source Gerd Hoffmann
2021-05-26 14:06 ` Gerd Hoffmann [this message]
2021-05-26 14:06 ` [PULL 10/14] pckbd: add function kbd_pending() Gerd Hoffmann
2021-05-26 14:06 ` [PULL 11/14] pckbd: correctly disable PS/2 communication Gerd Hoffmann
2021-05-26 14:06 ` [PULL 12/14] pckbd: remove duplicated keyboard and mouse defines Gerd Hoffmann
2021-05-26 14:06 ` [PULL 13/14] pckbd: clear outport_present in outer pre_load() Gerd Hoffmann
2021-05-26 14:06 ` [PULL 14/14] hw/input/ps2: Use ps2_raise_irq() instead of open coding it Gerd Hoffmann
2021-05-26 20:04 ` [PULL 00/14] Input 20210526 patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210526140627.381857-10-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=ehabkost@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vr_qemu@t-online.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).