提交 76dec49f 编写于 作者: J Juan Quintela 提交者: Anthony Liguori

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: NJuan Quintela <quintela@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 cff09e92
...@@ -440,46 +440,33 @@ static void pm_write_config(PCIDevice *d, ...@@ -440,46 +440,33 @@ static void pm_write_config(PCIDevice *d,
pm_io_space_update((PIIX4PMState *)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; 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); pm_io_space_update(s);
return 0; 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) static void piix4_reset(void *opaque)
{ {
PIIX4PMState *s = opaque; PIIX4PMState *s = opaque;
...@@ -561,7 +548,7 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, ...@@ -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); 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->smbus = i2c_init_bus(NULL, "i2c");
s->irq = sci_irq; s->irq = sci_irq;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册