diff options
Diffstat (limited to 'hw/stellaris_enet.c')
-rw-r--r-- | hw/stellaris_enet.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c index 88c56204e3..a4c2011113 100644 --- a/hw/stellaris_enet.c +++ b/hw/stellaris_enet.c @@ -69,6 +69,7 @@ typedef struct { VLANClientState *vc; qemu_irq irq; uint8_t macaddr[6]; + int mmio_index; } stellaris_enet_state; static void stellaris_enet_update(stellaris_enet_state *s) @@ -384,23 +385,35 @@ static int stellaris_enet_load(QEMUFile *f, void *opaque, int version_id) return 0; } +static void stellaris_enet_cleanup(VLANClientState *vc) +{ + stellaris_enet_state *s = vc->opaque; + + unregister_savevm("stellaris_enet", s); + + cpu_unregister_io_memory(s->mmio_index); + + qemu_free(s); +} + void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq) { stellaris_enet_state *s; - int iomemtype; qemu_check_nic_model(nd, "stellaris"); s = (stellaris_enet_state *)qemu_mallocz(sizeof(stellaris_enet_state)); - iomemtype = cpu_register_io_memory(0, stellaris_enet_readfn, - stellaris_enet_writefn, s); - cpu_register_physical_memory(base, 0x00001000, iomemtype); + s->mmio_index = cpu_register_io_memory(0, stellaris_enet_readfn, + stellaris_enet_writefn, s); + cpu_register_physical_memory(base, 0x00001000, s->mmio_index); s->irq = irq; memcpy(s->macaddr, nd->macaddr, 6); if (nd->vlan) { s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, - stellaris_enet_receive, stellaris_enet_can_receive, s); + stellaris_enet_receive, + stellaris_enet_can_receive, + stellaris_enet_cleanup, s); qemu_format_nic_info_str(s->vc, s->macaddr); } |