Patchwork [20/26] vmstate: port pckbd device

login
register
mail settings
Submitter Juan Quintela
Date Sept. 10, 2009, 1:04 a.m.
Message ID <6ff1ce2455ddd7dd4573ea95a5b11609b71aa6bc.1252543872.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/33258/
State Superseded
Headers show

Comments

Juan Quintela - Sept. 10, 2009, 1:04 a.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/pckbd.c |   41 ++++++++++++++++-------------------------
 1 files changed, 16 insertions(+), 25 deletions(-)

Patch

diff --git a/hw/pckbd.c b/hw/pckbd.c
index 3f83320..f119a33 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -339,28 +339,19 @@  static void kbd_reset(void *opaque)
     s->status = KBD_STAT_CMD | KBD_STAT_UNLOCKED;
 }

-static void kbd_save(QEMUFile* f, void* opaque)
-{
-    KBDState *s = (KBDState*)opaque;
-
-    qemu_put_8s(f, &s->write_cmd);
-    qemu_put_8s(f, &s->status);
-    qemu_put_8s(f, &s->mode);
-    qemu_put_8s(f, &s->pending);
-}
-
-static int kbd_load(QEMUFile* f, void* opaque, int version_id)
-{
-    KBDState *s = (KBDState*)opaque;
-
-    if (version_id != 3)
-        return -EINVAL;
-    qemu_get_8s(f, &s->write_cmd);
-    qemu_get_8s(f, &s->status);
-    qemu_get_8s(f, &s->mode);
-    qemu_get_8s(f, &s->pending);
-    return 0;
-}
+static const VMStateDescription vmstate_kbd = {
+    .name = "pckbd",
+    .version_id = 3,
+    .minimum_version_id = 3,
+    .minimum_version_id_old = 3,
+    .fields      = (VMStateField []) {
+        VMSTATE_UINT8(write_cmd, KBDState),
+        VMSTATE_UINT8(status, KBDState),
+        VMSTATE_UINT8(mode, KBDState),
+        VMSTATE_UINT8(pending, KBDState),
+        VMSTATE_END_OF_LIST()
+    }
+};

 void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base)
 {
@@ -370,7 +361,7 @@  void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base)
     s->irq_mouse = mouse_irq;

     kbd_reset(s);
-    register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s);
+    vmstate_register(0, &vmstate_kbd, s);
     register_ioport_read(io_base, 1, 1, kbd_read_data, s);
     register_ioport_write(io_base, 1, 1, kbd_write_data, s);
     register_ioport_read(io_base + 4, 1, 1, kbd_read_status, s);
@@ -429,7 +420,7 @@  void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
     s->mask = mask;

     kbd_reset(s);
-    register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s);
+    vmstate_register(0, &vmstate_kbd, s);
     s_io_memory = cpu_register_io_memory(kbd_mm_read, kbd_mm_write, s);
     cpu_register_physical_memory(base, size, s_io_memory);

@@ -454,7 +445,7 @@  static int i8042_initfn(ISADevice *dev)
     isa_init_irq(dev, &s->irq_mouse);

     kbd_reset(s);
-    register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s);
+    vmstate_register(0, &vmstate_kbd, s);
     register_ioport_read(dev->iobase[0], 1, 1, kbd_read_data, s);
     register_ioport_write(dev->iobase[0], 1, 1, kbd_write_data, s);
     register_ioport_read(dev->iobase[1], 1, 1, kbd_read_status, s);