aboutsummaryrefslogtreecommitdiff
path: root/hw/usb-uhci.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2009-10-14 12:49:30 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-27 12:28:43 -0500
commit817afc614c779596fb95a5c3ff50dee2b8f6df7b (patch)
tree5f3eed8d7ecb21a9a6a91347e9349a2ab9b22d6b /hw/usb-uhci.c
parent64e58fe5c157c46bd9ddb02b9ebbeec006feccaf (diff)
usb-uhci: port to vmstate
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/usb-uhci.c')
-rw-r--r--hw/usb-uhci.c79
1 files changed, 34 insertions, 45 deletions
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 99aa7d1dd0..67a9a233c6 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -351,57 +351,46 @@ static void uhci_reset(void *opaque)
uhci_async_cancel_all(s);
}
-static void uhci_save(QEMUFile *f, void *opaque)
+static void uhci_pre_save(void *opaque)
{
UHCIState *s = opaque;
- int i;
uhci_async_cancel_all(s);
-
- pci_device_save(&s->dev, f);
-
- qemu_put_8s(f, &s->num_ports_vmstate);
- for (i = 0; i < s->num_ports_vmstate; ++i)
- qemu_put_be16s(f, &s->ports[i].ctrl);
- qemu_put_be16s(f, &s->cmd);
- qemu_put_be16s(f, &s->status);
- qemu_put_be16s(f, &s->intr);
- qemu_put_be16s(f, &s->frnum);
- qemu_put_be32s(f, &s->fl_base_addr);
- qemu_put_8s(f, &s->sof_timing);
- qemu_put_8s(f, &s->status2);
- qemu_put_timer(f, s->frame_timer);
}
-static int uhci_load(QEMUFile *f, void *opaque, int version_id)
-{
- UHCIState *s = opaque;
- int i, ret;
-
- if (version_id > 1)
- return -EINVAL;
-
- ret = pci_device_load(&s->dev, f);
- if (ret < 0)
- return ret;
-
- qemu_get_8s(f, &s->num_ports_vmstate);
- if (s->num_ports_vmstate != NB_PORTS)
- return -EINVAL;
-
- for (i = 0; i < s->num_ports_vmstate; ++i)
- qemu_get_be16s(f, &s->ports[i].ctrl);
- qemu_get_be16s(f, &s->cmd);
- qemu_get_be16s(f, &s->status);
- qemu_get_be16s(f, &s->intr);
- qemu_get_be16s(f, &s->frnum);
- qemu_get_be32s(f, &s->fl_base_addr);
- qemu_get_8s(f, &s->sof_timing);
- qemu_get_8s(f, &s->status2);
- qemu_get_timer(f, s->frame_timer);
+static const VMStateDescription vmstate_uhci_port = {
+ .name = "uhci port",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .fields = (VMStateField []) {
+ VMSTATE_UINT16(ctrl, UHCIPort),
+ VMSTATE_END_OF_LIST()
+ }
+};
- return 0;
-}
+static const VMStateDescription vmstate_uhci = {
+ .name = "uhci",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .pre_save = uhci_pre_save,
+ .fields = (VMStateField []) {
+ VMSTATE_PCI_DEVICE(dev, UHCIState),
+ VMSTATE_UINT8_EQUAL(num_ports_vmstate, UHCIState),
+ VMSTATE_STRUCT_ARRAY(ports, UHCIState, NB_PORTS, 1,
+ vmstate_uhci_port, UHCIPort),
+ VMSTATE_UINT16(cmd, UHCIState),
+ VMSTATE_UINT16(status, UHCIState),
+ VMSTATE_UINT16(intr, UHCIState),
+ VMSTATE_UINT16(frnum, UHCIState),
+ VMSTATE_UINT32(fl_base_addr, UHCIState),
+ VMSTATE_UINT8(sof_timing, UHCIState),
+ VMSTATE_UINT8(status2, UHCIState),
+ VMSTATE_TIMER(frame_timer, UHCIState),
+ VMSTATE_END_OF_LIST()
+ }
+};
static void uhci_ioport_writeb(void *opaque, uint32_t addr, uint32_t val)
{
@@ -1097,7 +1086,7 @@ static int usb_uhci_common_initfn(UHCIState *s)
pci_register_bar(&s->dev, 4, 0x20,
PCI_ADDRESS_SPACE_IO, uhci_map);
- register_savevm("uhci", 0, 1, uhci_save, uhci_load, s);
+ vmstate_register(0, &vmstate_uhci, s);
return 0;
}