diff --git a/hw/acpi.c b/hw/acpi.c index 37a5d9823bcd3c532b07a5a5e179b6dac5ef1844..6eddd0ec5d68bfdf6aad2ce82a96df55c8213d72 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -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;