diff options
author | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:07 +0100 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:07 +0100 |
commit | 418dcf5b7da0efefea33ad4e96434feff57524d5 (patch) | |
tree | e4992b63c6a9dd0f2da07dff338bc57142c359e9 /hw | |
parent | 6a824ec3d2e3d9b061c31aa14535eb7e08a6846c (diff) |
smc91c111 qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/smc91c111.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/hw/smc91c111.c b/hw/smc91c111.c index e294f51cd9..38cbd016e9 100644 --- a/hw/smc91c111.c +++ b/hw/smc91c111.c @@ -7,7 +7,7 @@ * This code is licenced under the GPL */ -#include "hw.h" +#include "sysbus.h" #include "net.h" #include "devices.h" /* For crc32 */ @@ -17,6 +17,7 @@ #define NUM_PACKETS 4 typedef struct { + SysBusDevice busdev; VLANClientState *vc; uint16_t tcr; uint16_t rcr; @@ -697,24 +698,44 @@ static void smc91c111_cleanup(VLANClientState *vc) qemu_free(s); } -void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq) +static void smc91c111_init1(SysBusDevice *dev) { - smc91c111_state *s; - - qemu_check_nic_model(nd, "smc91c111"); + smc91c111_state *s = FROM_SYSBUS(smc91c111_state, dev); - s = (smc91c111_state *)qemu_mallocz(sizeof(smc91c111_state)); s->mmio_index = cpu_register_io_memory(0, smc91c111_readfn, smc91c111_writefn, s); - cpu_register_physical_memory(base, 16, s->mmio_index); - s->irq = irq; - memcpy(s->macaddr, nd->macaddr, 6); + sysbus_init_mmio(dev, 16, s->mmio_index); + sysbus_init_irq(dev, &s->irq); + qdev_get_macaddr(&dev->qdev, s->macaddr); smc91c111_reset(s); - s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, + s->vc = qdev_get_vlan_client(&dev->qdev, smc91c111_receive, smc91c111_can_receive, smc91c111_cleanup, s); qemu_format_nic_info_str(s->vc, s->macaddr); /* ??? Save/restore. */ } + +static void smc91c111_register_devices(void) +{ + sysbus_register_dev("smc91c111", sizeof(smc91c111_state), smc91c111_init1); +} + +/* Legacy helper function. Should go away when machine config files are + implemented. */ +void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq) +{ + DeviceState *dev; + SysBusDevice *s; + + qemu_check_nic_model(nd, "smc91c111"); + dev = qdev_create(NULL, "smc91c111"); + qdev_set_netdev(dev, nd); + qdev_init(dev); + s = sysbus_from_qdev(dev); + sysbus_mmio_map(s, 0, base); + sysbus_connect_irq(s, 0, irq); +} + +device_init(smc91c111_register_devices) |