From: "Volker Rümelin" <vr_qemu@t-online.de>
To: "Michael S. Tsirkin" <mst@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [PATCH v3 07/11] pckbd: add state variable for interrupt source
Date: Sat, 15 May 2021 13:32:50 +0200 [thread overview]
Message-ID: <20210515113254.6245-7-vr_qemu@t-online.de> (raw)
In-Reply-To: <d00ea6b1-43c7-78a2-8c0a-35e19efb5e46@t-online.de>
Currently there is only one flag to distinguish between two
interrupt sources and there are no available flags for more
sources. Add an internal state variable to store the interrupt
source. The next patch will introduce an additional interrupt
source. There is no functional change.
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
hw/input/pckbd.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index ebf08c7cb8..adce525b88 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -135,12 +135,16 @@
#define KBD_MIGR_TIMER_PENDING 0x1
+#define KBD_OBSRC_KBD 0x01
+#define KBD_OBSRC_MOUSE 0x02
+
typedef struct KBDState {
uint8_t write_cmd; /* if non zero, write data to port 60 is expected */
uint8_t status;
uint8_t mode;
uint8_t outport;
uint32_t migration_flags;
+ uint32_t obsrc;
bool outport_present;
/* Bitmask of devices with data available. */
uint8_t pending;
@@ -198,6 +202,9 @@ static void kbd_update_irq(KBDState *s)
if (s->pending == KBD_PENDING_AUX) {
s->status |= KBD_STAT_MOUSE_OBF;
s->outport |= KBD_OUT_MOUSE_OBF;
+ s->obsrc = KBD_OBSRC_MOUSE;
+ } else {
+ s->obsrc = KBD_OBSRC_KBD;
}
}
kbd_update_irq_lines(s);
@@ -368,18 +375,17 @@ static uint64_t kbd_read_data(void *opaque, hwaddr addr,
unsigned size)
{
KBDState *s = opaque;
- uint8_t status = s->status;
- if (status & KBD_STAT_OBF) {
+ if (s->status & KBD_STAT_OBF) {
kbd_deassert_irq(s);
- if (status & KBD_STAT_MOUSE_OBF) {
- s->obdata = ps2_read_data(s->mouse);
- } else {
+ if (s->obsrc & KBD_OBSRC_KBD) {
if (s->throttle_timer) {
timer_mod(s->throttle_timer,
qemu_clock_get_us(QEMU_CLOCK_VIRTUAL) + 1000);
}
s->obdata = ps2_read_data(s->kbd);
+ } else if (s->obsrc & KBD_OBSRC_MOUSE) {
+ s->obdata = ps2_read_data(s->mouse);
}
}
@@ -496,6 +502,11 @@ static int kbd_post_load(void *opaque, int version_id)
s->outport = kbd_outport_default(s);
}
s->outport_present = false;
+ if (version_id < 4) {
+ s->obsrc = s->status & KBD_STAT_OBF ?
+ (s->status & KBD_STAT_MOUSE_OBF ? KBD_OBSRC_MOUSE : KBD_OBSRC_KBD) :
+ 0;
+ }
if (s->migration_flags & KBD_MIGR_TIMER_PENDING) {
kbd_throttle_timeout(s);
}
@@ -514,6 +525,7 @@ static const VMStateDescription vmstate_kbd = {
VMSTATE_UINT8(mode, KBDState),
VMSTATE_UINT8(pending, KBDState),
VMSTATE_UINT32_V(migration_flags, KBDState, 4),
+ VMSTATE_UINT32_V(obsrc, KBDState, 4),
VMSTATE_UINT8_V(obdata, KBDState, 4),
VMSTATE_END_OF_LIST()
},
--
2.26.2
next prev parent reply other threads:[~2021-05-15 11:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-15 11:31 [PATCH v3 00/11] PS/2 controller related fixes Volker Rümelin
2021-05-15 11:32 ` [PATCH v3 01/11] ps2: fix mouse stream corruption Volker Rümelin
2021-05-15 11:32 ` [PATCH v3 02/11] ps2: don't raise an interrupt if queue is full Volker Rümelin
2021-05-15 11:32 ` [PATCH v3 03/11] ps2: don't deassert irq twice if queue is empty Volker Rümelin
2021-05-15 11:32 ` [PATCH v3 04/11] pckbd: split out interrupt line changing code Volker Rümelin
2021-05-15 11:32 ` [PATCH v3 05/11] pckbd: don't update OBF flags if KBD_STAT_OBF is set Volker Rümelin
2021-05-18 10:49 ` Gerd Hoffmann
2021-05-18 19:37 ` Volker Rümelin
2021-05-15 11:32 ` [PATCH v3 06/11] pckbd: PS/2 keyboard throttle Volker Rümelin
2021-05-15 11:32 ` Volker Rümelin [this message]
2021-05-15 11:32 ` [PATCH v3 08/11] pckbd: add controller response queue Volker Rümelin
2021-05-15 11:32 ` [PATCH v3 09/11] pckbd: add function kbd_pending() Volker Rümelin
2021-05-15 11:32 ` [PATCH v3 10/11] pckbd: correctly disable PS/2 communication Volker Rümelin
2021-05-15 11:32 ` [PATCH v3 11/11] pckbd: remove duplicated keyboard and mouse defines Volker Rümelin
2021-05-15 12:05 ` [PATCH v3 00/11] PS/2 controller related fixes Philippe Mathieu-Daudé
2021-05-15 14:35 ` BALATON Zoltan
2021-05-15 16:33 ` Philippe Mathieu-Daudé
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=20210515113254.6245-7-vr_qemu@t-online.de \
--to=vr_qemu@t-online.de \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).