diff options
author | Juan Quintela <quintela@redhat.com> | 2010-12-02 02:48:43 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-04-22 14:41:41 -0500 |
commit | ff269cd041d33cded58bc734f88456720dcc1864 (patch) | |
tree | 2964d228ac70ebd06a3a34c294b06162ab7b1e57 | |
parent | 0797226c56ea51a72ebbf7dcecfd2c1e44147cf0 (diff) | |
download | qemu-ff269cd041d33cded58bc734f88456720dcc1864.zip qemu-ff269cd041d33cded58bc734f88456720dcc1864.tar.gz qemu-ff269cd041d33cded58bc734f88456720dcc1864.tar.bz2 |
vmstate: port stellaris i2c
Signed-off-by: Juan Quintela <quintela@redhat.com>
-rw-r--r-- | hw/stellaris.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/hw/stellaris.c b/hw/stellaris.c index 7932c24..d0b1588 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -843,36 +843,22 @@ static CPUWriteMemoryFunc * const stellaris_i2c_writefn[] = { stellaris_i2c_write }; -static void stellaris_i2c_save(QEMUFile *f, void *opaque) -{ - stellaris_i2c_state *s = (stellaris_i2c_state *)opaque; - - qemu_put_be32(f, s->msa); - qemu_put_be32(f, s->mcs); - qemu_put_be32(f, s->mdr); - qemu_put_be32(f, s->mtpr); - qemu_put_be32(f, s->mimr); - qemu_put_be32(f, s->mris); - qemu_put_be32(f, s->mcr); -} - -static int stellaris_i2c_load(QEMUFile *f, void *opaque, int version_id) -{ - stellaris_i2c_state *s = (stellaris_i2c_state *)opaque; - - if (version_id != 1) - return -EINVAL; - - s->msa = qemu_get_be32(f); - s->mcs = qemu_get_be32(f); - s->mdr = qemu_get_be32(f); - s->mtpr = qemu_get_be32(f); - s->mimr = qemu_get_be32(f); - s->mris = qemu_get_be32(f); - s->mcr = qemu_get_be32(f); - - return 0; -} +static const VMStateDescription vmstate_stellaris_i2c = { + .name = "stellaris_i2c", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32(msa, stellaris_i2c_state), + VMSTATE_UINT32(mcs, stellaris_i2c_state), + VMSTATE_UINT32(mdr, stellaris_i2c_state), + VMSTATE_UINT32(mtpr, stellaris_i2c_state), + VMSTATE_UINT32(mimr, stellaris_i2c_state), + VMSTATE_UINT32(mris, stellaris_i2c_state), + VMSTATE_UINT32(mcr, stellaris_i2c_state), + VMSTATE_END_OF_LIST() + } +}; static int stellaris_i2c_init(SysBusDevice * dev) { @@ -890,8 +876,7 @@ static int stellaris_i2c_init(SysBusDevice * dev) sysbus_init_mmio(dev, 0x1000, iomemtype); /* ??? For now we only implement the master interface. */ stellaris_i2c_reset(s); - register_savevm(&dev->qdev, "stellaris_i2c", -1, 1, - stellaris_i2c_save, stellaris_i2c_load, s); + vmstate_register(&dev->qdev, -1, &vmstate_stellaris_i2c, s); return 0; } |