aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2009-10-19 18:26:11 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-27 12:28:53 -0500
commit7c131dd59d9c2f0d267841c296b02372c31fadcd (patch)
treedaf909dacd638a6109badbda2d49faf62cfbc192 /hw
parent3d8650597d93b11314bab4ad64b297da85edf179 (diff)
ne2000: port to vmstate
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/ne2000-isa.c2
-rw-r--r--hw/ne2000.c133
-rw-r--r--hw/ne2000.h3
3 files changed, 50 insertions, 88 deletions
diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c
index abb9b97d55..729e8e2253 100644
--- a/hw/ne2000-isa.c
+++ b/hw/ne2000-isa.c
@@ -69,7 +69,7 @@ static int isa_ne2000_initfn(ISADevice *dev)
NULL, isa_ne2000_cleanup, s);
qemu_format_nic_info_str(s->vc, s->c.macaddr.a);
- register_savevm("ne2000", -1, 2, ne2000_save, ne2000_load, s);
+ vmstate_register(-1, &vmstate_ne2000, s);
return 0;
}
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 5489247071..97204e8e82 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -623,94 +623,57 @@ uint32_t ne2000_reset_ioport_read(void *opaque, uint32_t addr)
return 0;
}
-void ne2000_save(QEMUFile* f, void* opaque)
+static int ne2000_post_load(void* opaque, int version_id)
{
- NE2000State* s = opaque;
- uint32_t tmp;
-
- qemu_put_8s(f, &s->rxcr);
-
- qemu_put_8s(f, &s->cmd);
- qemu_put_be32s(f, &s->start);
- qemu_put_be32s(f, &s->stop);
- qemu_put_8s(f, &s->boundary);
- qemu_put_8s(f, &s->tsr);
- qemu_put_8s(f, &s->tpsr);
- qemu_put_be16s(f, &s->tcnt);
- qemu_put_be16s(f, &s->rcnt);
- qemu_put_be32s(f, &s->rsar);
- qemu_put_8s(f, &s->rsr);
- qemu_put_8s(f, &s->isr);
- qemu_put_8s(f, &s->dcfg);
- qemu_put_8s(f, &s->imr);
- qemu_put_buffer(f, s->phys, 6);
- qemu_put_8s(f, &s->curpag);
- qemu_put_buffer(f, s->mult, 8);
- tmp = 0;
- qemu_put_be32s(f, &tmp); /* ignored, was irq */
- qemu_put_buffer(f, s->mem, NE2000_MEM_SIZE);
-}
-
-int ne2000_load(QEMUFile* f, void* opaque, int version_id)
-{
- NE2000State* s = opaque;
- uint32_t tmp;
-
- if (version_id > 3)
- return -EINVAL;
-
- if (version_id >= 2) {
- qemu_get_8s(f, &s->rxcr);
- } else {
- s->rxcr = 0x0c;
- }
-
- qemu_get_8s(f, &s->cmd);
- qemu_get_be32s(f, &s->start);
- qemu_get_be32s(f, &s->stop);
- qemu_get_8s(f, &s->boundary);
- qemu_get_8s(f, &s->tsr);
- qemu_get_8s(f, &s->tpsr);
- qemu_get_be16s(f, &s->tcnt);
- qemu_get_be16s(f, &s->rcnt);
- qemu_get_be32s(f, &s->rsar);
- qemu_get_8s(f, &s->rsr);
- qemu_get_8s(f, &s->isr);
- qemu_get_8s(f, &s->dcfg);
- qemu_get_8s(f, &s->imr);
- qemu_get_buffer(f, s->phys, 6);
- qemu_get_8s(f, &s->curpag);
- qemu_get_buffer(f, s->mult, 8);
- qemu_get_be32s(f, &tmp); /* ignored */
- qemu_get_buffer(f, s->mem, NE2000_MEM_SIZE);
-
- return 0;
-}
-
-static void pci_ne2000_save(QEMUFile* f, void* opaque)
-{
- PCINE2000State* s = opaque;
+ NE2000State* s = opaque;
- pci_device_save(&s->dev, f);
- ne2000_save(f, &s->ne2000);
+ if (version_id < 2) {
+ s->rxcr = 0x0c;
+ }
+ return 0;
}
-static int pci_ne2000_load(QEMUFile* f, void* opaque, int version_id)
-{
- PCINE2000State* s = opaque;
- int ret;
-
- if (version_id > 3)
- return -EINVAL;
-
- if (version_id >= 3) {
- ret = pci_device_load(&s->dev, f);
- if (ret < 0)
- return ret;
- }
+const VMStateDescription vmstate_ne2000 = {
+ .name = "ne2000",
+ .version_id = 2,
+ .minimum_version_id = 0,
+ .minimum_version_id_old = 0,
+ .post_load = ne2000_post_load,
+ .fields = (VMStateField []) {
+ VMSTATE_UINT8_V(rxcr, NE2000State, 2),
+ VMSTATE_UINT8(cmd, NE2000State),
+ VMSTATE_UINT32(start, NE2000State),
+ VMSTATE_UINT32(stop, NE2000State),
+ VMSTATE_UINT8(boundary, NE2000State),
+ VMSTATE_UINT8(tsr, NE2000State),
+ VMSTATE_UINT8(tpsr, NE2000State),
+ VMSTATE_UINT16(tcnt, NE2000State),
+ VMSTATE_UINT16(rcnt, NE2000State),
+ VMSTATE_UINT32(rsar, NE2000State),
+ VMSTATE_UINT8(rsr, NE2000State),
+ VMSTATE_UINT8(isr, NE2000State),
+ VMSTATE_UINT8(dcfg, NE2000State),
+ VMSTATE_UINT8(imr, NE2000State),
+ VMSTATE_BUFFER(phys, NE2000State),
+ VMSTATE_UINT8(curpag, NE2000State),
+ VMSTATE_BUFFER(mult, NE2000State),
+ VMSTATE_UNUSED(4), /* was irq */
+ VMSTATE_BUFFER(mem, NE2000State),
+ VMSTATE_END_OF_LIST()
+ }
+};
- return ne2000_load(f, &s->ne2000, version_id);
-}
+const VMStateDescription vmstate_pci_ne2000 = {
+ .name = "ne2000",
+ .version_id = 3,
+ .minimum_version_id = 3,
+ .minimum_version_id_old = 3,
+ .fields = (VMStateField []) {
+ VMSTATE_PCI_DEVICE(dev, PCINE2000State),
+ VMSTATE_STRUCT(ne2000, PCINE2000State, 0, vmstate_ne2000, NE2000State),
+ VMSTATE_END_OF_LIST()
+ }
+};
/***********************************************************/
/* PCI NE2000 definitions */
@@ -776,7 +739,7 @@ static int pci_ne2000_init(PCIDevice *pci_dev)
}
}
- register_savevm("ne2000", -1, 3, pci_ne2000_save, pci_ne2000_load, d);
+ vmstate_register(-1, &vmstate_pci_ne2000, d);
return 0;
}
@@ -785,7 +748,7 @@ static int pci_ne2000_exit(PCIDevice *pci_dev)
PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
NE2000State *s = &d->ne2000;
- unregister_savevm("ne2000", s);
+ vmstate_unregister(&vmstate_pci_ne2000, s);
qemu_del_vlan_client(s->vc);
return 0;
}
diff --git a/hw/ne2000.h b/hw/ne2000.h
index 78422465c4..2bbce71e6f 100644
--- a/hw/ne2000.h
+++ b/hw/ne2000.h
@@ -33,8 +33,7 @@ void ne2000_asic_ioport_write(void *opaque, uint32_t addr, uint32_t val);
uint32_t ne2000_asic_ioport_read(void *opaque, uint32_t addr);
void ne2000_reset_ioport_write(void *opaque, uint32_t addr, uint32_t val);
uint32_t ne2000_reset_ioport_read(void *opaque, uint32_t addr);
-void ne2000_save(QEMUFile* f, void* opaque);
-int ne2000_load(QEMUFile* f, void* opaque, int version_id);
+extern const VMStateDescription vmstate_ne2000;
void ne2000_reset(NE2000State *s);
int ne2000_can_receive(VLANClientState *vc);
ssize_t ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size_);