diff options
author | Juan Quintela <quintela@redhat.com> | 2009-10-07 18:52:10 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-27 12:28:45 -0500 |
commit | 5f637ce06f4edc17963401d87d4fa37a63466d40 (patch) | |
tree | 9f15a03892a29758fef76aa41a8e04b3e548968a | |
parent | b38436e3a9cb4ce15dcce874fb3854a4e41422ac (diff) |
ide: port microdrive to vmstate
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | hw/ide/microdrive.c | 61 |
1 files changed, 18 insertions, 43 deletions
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c index 49a9b93642..9f7789d611 100644 --- a/hw/ide/microdrive.c +++ b/hw/ide/microdrive.c @@ -300,48 +300,23 @@ static void md_common_write(void *opaque, uint32_t at, uint16_t value) } } -static void md_save(QEMUFile *f, void *opaque) -{ - MicroDriveState *s = opaque; - int i; - - qemu_put_8s(f, &s->opt); - qemu_put_8s(f, &s->stat); - qemu_put_8s(f, &s->pins); - - qemu_put_8s(f, &s->ctrl); - qemu_put_be16s(f, &s->io); - qemu_put_byte(f, s->cycle); - - idebus_save(f, &s->bus); - - for (i = 0; i < 2; i ++) - ide_save(f, &s->bus.ifs[i]); -} - -static int md_load(QEMUFile *f, void *opaque, int version_id) -{ - MicroDriveState *s = opaque; - int i; - - if (version_id != 0 && version_id != 3) - return -EINVAL; - - qemu_get_8s(f, &s->opt); - qemu_get_8s(f, &s->stat); - qemu_get_8s(f, &s->pins); - - qemu_get_8s(f, &s->ctrl); - qemu_get_be16s(f, &s->io); - s->cycle = qemu_get_byte(f); - - idebus_load(f, &s->bus, version_id); - - for (i = 0; i < 2; i ++) - ide_load(f, &s->bus.ifs[i], version_id); - - return 0; -} +const VMStateDescription vmstate_microdrive = { + .name = "microdrive", + .version_id = 3, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .fields = (VMStateField []) { + VMSTATE_UINT8(opt, MicroDriveState), + VMSTATE_UINT8(stat, MicroDriveState), + VMSTATE_UINT8(pins, MicroDriveState), + VMSTATE_UINT8(ctrl, MicroDriveState), + VMSTATE_UINT16(io, MicroDriveState), + VMSTATE_UINT8(cycle, MicroDriveState), + VMSTATE_IDE_BUS(bus, MicroDriveState), + VMSTATE_IDE_DRIVES(bus.ifs, MicroDriveState), + VMSTATE_END_OF_LIST() + } +}; static const uint8_t dscm1xxxx_cis[0x14a] = { [0x000] = CISTPL_DEVICE, /* 5V Device Information */ @@ -569,7 +544,7 @@ PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv) md->bus.ifs[0].mdata_size = METADATA_SIZE; md->bus.ifs[0].mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE); - register_savevm("microdrive", -1, 3, md_save, md_load, md); + vmstate_register(-1, &vmstate_microdrive, md); return &md->card; } |