diff options
author | Juan Quintela <quintela@redhat.com> | 2009-08-20 19:42:41 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-08-27 20:30:22 -0500 |
commit | 76dec49f1befded9828bc448fc6bf4de1d1faf00 (patch) | |
tree | 150cb16347a59d13ceadebcc474e3e5d5efc4558 | |
parent | cff09e923999e3848cdf3b2dc4e6c595523cddc6 (diff) | |
download | qemu-76dec49f1befded9828bc448fc6bf4de1d1faf00.tar.gz qemu-76dec49f1befded9828bc448fc6bf4de1d1faf00.tar.bz2 qemu-76dec49f1befded9828bc448fc6bf4de1d1faf00.zip |
Port ACPI to VMState
This uses a run_after_load() function, and VMSTATE_PCI_DEVICE()
It could be made smaller changing the type of pm_io_space_update()
to return an int.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | hw/acpi.c | 55 |
1 files changed, 21 insertions, 34 deletions
@@ -440,46 +440,33 @@ static void pm_write_config(PCIDevice *d, pm_io_space_update((PIIX4PMState *)d); } -static void pm_save(QEMUFile* f,void *opaque) +static int vmstate_acpi_after_load(void *opaque) { PIIX4PMState *s = opaque; - pci_device_save(&s->dev, f); - - qemu_put_be16s(f, &s->pmsts); - qemu_put_be16s(f, &s->pmen); - qemu_put_be16s(f, &s->pmcntrl); - qemu_put_8s(f, &s->apmc); - qemu_put_8s(f, &s->apms); - qemu_put_timer(f, s->tmr_timer); - qemu_put_be64(f, s->tmr_overflow_time); -} - -static int pm_load(QEMUFile* f,void* opaque,int version_id) -{ - PIIX4PMState *s = opaque; - int ret; - - if (version_id > 1) - return -EINVAL; - - ret = pci_device_load(&s->dev, f); - if (ret < 0) - return ret; - - qemu_get_be16s(f, &s->pmsts); - qemu_get_be16s(f, &s->pmen); - qemu_get_be16s(f, &s->pmcntrl); - qemu_get_8s(f, &s->apmc); - qemu_get_8s(f, &s->apms); - qemu_get_timer(f, s->tmr_timer); - s->tmr_overflow_time=qemu_get_be64(f); - pm_io_space_update(s); - return 0; } +static const VMStateDescription vmstate_acpi = { + .name = "piix4_pm", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .run_after_load = vmstate_acpi_after_load, + .fields = (VMStateField []) { + VMSTATE_PCI_DEVICE(dev, PIIX4PMState), + VMSTATE_UINT16(pmsts, PIIX4PMState), + VMSTATE_UINT16(pmen, PIIX4PMState), + VMSTATE_UINT16(pmcntrl, PIIX4PMState), + VMSTATE_UINT8(apmc, PIIX4PMState), + VMSTATE_UINT8(apms, PIIX4PMState), + VMSTATE_TIMER(tmr_timer, PIIX4PMState), + VMSTATE_INT64(tmr_overflow_time, PIIX4PMState), + VMSTATE_END_OF_LIST() + } +}; + static void piix4_reset(void *opaque) { PIIX4PMState *s = opaque; @@ -561,7 +548,7 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_system_powerdown = *qemu_allocate_irqs(piix4_powerdown, s, 1); - register_savevm("piix4_pm", 0, 1, pm_save, pm_load, s); + vmstate_register(0, &vmstate_acpi, s); s->smbus = i2c_init_bus(NULL, "i2c"); s->irq = sci_irq; |