summaryrefslogtreecommitdiff
path: root/hw/input/pckbd.c
diff options
context:
space:
mode:
authorPavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>2014-08-28 15:19:14 +0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-09-11 12:20:32 +0200
commita28fe7e3f6dbacfddc70c8fa773466f4a17d92e3 (patch)
tree133f842cf2b3a005302db03f022cb092f5ef188a /hw/input/pckbd.c
parent0b102153e08648391925bd0071226adf0de67270 (diff)
downloadqemu-a28fe7e3f6dbacfddc70c8fa773466f4a17d92e3.tar.gz
qemu-a28fe7e3f6dbacfddc70c8fa773466f4a17d92e3.tar.bz2
qemu-a28fe7e3f6dbacfddc70c8fa773466f4a17d92e3.zip
pckbd: adding new fields to vmstate
This patch adds outport to VMState to allow correct saving and restoring the state of PC keyboard controller. Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/input/pckbd.c')
-rw-r--r--hw/input/pckbd.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index 2ab8c873b6..2b0cd3dbb8 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -131,6 +131,7 @@ typedef struct KBDState {
uint8_t status;
uint8_t mode;
uint8_t outport;
+ bool outport_present;
/* Bitmask of devices with data available. */
uint8_t pending;
void *kbd;
@@ -367,18 +368,68 @@ static void kbd_reset(void *opaque)
s->mode = KBD_MODE_KBD_INT | KBD_MODE_MOUSE_INT;
s->status = KBD_STAT_CMD | KBD_STAT_UNLOCKED;
s->outport = KBD_OUT_RESET | KBD_OUT_A20;
+ s->outport_present = false;
+}
+
+static uint8_t kbd_outport_default(KBDState *s)
+{
+ return KBD_OUT_RESET | KBD_OUT_A20
+ | (s->status & KBD_STAT_OBF ? KBD_OUT_OBF : 0)
+ | (s->status & KBD_STAT_MOUSE_OBF ? KBD_OUT_MOUSE_OBF : 0);
+}
+
+static int kbd_outport_post_load(void *opaque, int version_id)
+{
+ KBDState *s = opaque;
+ s->outport_present = true;
+ return 0;
+}
+
+static const VMStateDescription vmstate_kbd_outport = {
+ .name = "pckbd_outport",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .post_load = kbd_outport_post_load,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT8(outport, KBDState),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static bool kbd_outport_needed(void *opaque)
+{
+ KBDState *s = opaque;
+ return s->outport != kbd_outport_default(s);
+}
+
+static int kbd_post_load(void *opaque, int version_id)
+{
+ KBDState *s = opaque;
+ if (!s->outport_present) {
+ s->outport = kbd_outport_default(s);
+ }
+ s->outport_present = false;
+ return 0;
}
static const VMStateDescription vmstate_kbd = {
.name = "pckbd",
.version_id = 3,
.minimum_version_id = 3,
+ .post_load = kbd_post_load,
.fields = (VMStateField[]) {
VMSTATE_UINT8(write_cmd, KBDState),
VMSTATE_UINT8(status, KBDState),
VMSTATE_UINT8(mode, KBDState),
VMSTATE_UINT8(pending, KBDState),
VMSTATE_END_OF_LIST()
+ },
+ .subsections = (VMStateSubsection[]) {
+ {
+ .vmsd = &vmstate_kbd_outport,
+ .needed = kbd_outport_needed,
+ },
+ VMSTATE_END_OF_LIST()
}
};