aboutsummaryrefslogtreecommitdiff
path: root/hw/mcf_fec.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/mcf_fec.c')
-rw-r--r--hw/mcf_fec.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c
index 413c5694db..1ca847b22b 100644
--- a/hw/mcf_fec.c
+++ b/hw/mcf_fec.c
@@ -24,6 +24,7 @@ do { printf("mcf_fec: " fmt , ##args); } while (0)
typedef struct {
qemu_irq *irq;
+ int mmio_index;
VLANClientState *vc;
uint32_t irq_state;
uint32_t eir;
@@ -441,21 +442,30 @@ static CPUWriteMemoryFunc *mcf_fec_writefn[] = {
mcf_fec_write
};
+static void mcf_fec_cleanup(VLANClientState *vc)
+{
+ mcf_fec_state *s = vc->opaque;
+
+ cpu_unregister_io_memory(s->mmio_index);
+
+ qemu_free(s);
+}
+
void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq)
{
mcf_fec_state *s;
- int iomemtype;
qemu_check_nic_model(nd, "mcf_fec");
s = (mcf_fec_state *)qemu_mallocz(sizeof(mcf_fec_state));
s->irq = irq;
- iomemtype = cpu_register_io_memory(0, mcf_fec_readfn,
- mcf_fec_writefn, s);
- cpu_register_physical_memory(base, 0x400, iomemtype);
+ s->mmio_index = cpu_register_io_memory(0, mcf_fec_readfn,
+ mcf_fec_writefn, s);
+ cpu_register_physical_memory(base, 0x400, s->mmio_index);
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
- mcf_fec_receive, mcf_fec_can_receive, s);
+ mcf_fec_receive, mcf_fec_can_receive,
+ mcf_fec_cleanup, s);
memcpy(s->macaddr, nd->macaddr, 6);
qemu_format_nic_info_str(s->vc, s->macaddr);
}