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 | a5580466257337e74e48124c185e4db9d29325ec (patch) | |
tree | b45bc816375cd1201390883478d9207342ae0023 /hw | |
parent | cf21e106cd9b34a12a533191932a8a08a1f5ebe4 (diff) |
Stellaris ethernet qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/arm-misc.h | 3 | ||||
-rw-r--r-- | hw/stellaris.c | 13 | ||||
-rw-r--r-- | hw/stellaris_enet.c | 39 |
3 files changed, 32 insertions, 23 deletions
diff --git a/hw/arm-misc.h b/hw/arm-misc.h index 5daac4fabf..32a5e9f664 100644 --- a/hw/arm-misc.h +++ b/hw/arm-misc.h @@ -41,7 +41,4 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info); extern int system_clock_scale; qemu_irq *armv7m_nvic_init(CPUState *env); -/* stellaris_enent.c */ -void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq); - #endif /* !ARM_MISC_H */ diff --git a/hw/stellaris.c b/hw/stellaris.c index 31206c34f2..8d0995a99b 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -1356,8 +1356,17 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model, pl022_init(0x40008000, pic[7], NULL, NULL); } } - if (board->dc4 & (1 << 28)) - stellaris_enet_init(&nd_table[0], 0x40048000, pic[42]); + if (board->dc4 & (1 << 28)) { + DeviceState *enet; + + qemu_check_nic_model(&nd_table[0], "stellaris"); + + enet = qdev_create(NULL, "stellaris_enet"); + qdev_set_netdev(enet, &nd_table[0]); + qdev_init(enet); + sysbus_mmio_map(sysbus_from_qdev(enet), 0, 0x40048000); + sysbus_connect_irq(sysbus_from_qdev(enet), 0, pic[42]); + } if (board->peripherals & BP_GAMEPAD) { qemu_irq gpad_irq[5]; static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d }; diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c index d1ec61a5ce..36fabd3260 100644 --- a/hw/stellaris_enet.c +++ b/hw/stellaris_enet.c @@ -6,8 +6,7 @@ * * This code is licenced under the GPL. */ -#include "hw.h" -#include "arm-misc.h" +#include "sysbus.h" #include "net.h" #include <zlib.h> @@ -44,6 +43,7 @@ do { fprintf(stderr, "stellaris_enet: error: " fmt , ## __VA_ARGS__);} while (0) #define SE_TCTL_DUPLEX 0x08 typedef struct { + SysBusDevice busdev; uint32_t ris; uint32_t im; uint32_t rctl; @@ -394,28 +394,31 @@ static void stellaris_enet_cleanup(VLANClientState *vc) qemu_free(s); } -void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq) +static void stellaris_enet_init(SysBusDevice *dev) { - stellaris_enet_state *s; + stellaris_enet_state *s = FROM_SYSBUS(stellaris_enet_state, dev); - qemu_check_nic_model(nd, "stellaris"); - - s = (stellaris_enet_state *)qemu_mallocz(sizeof(stellaris_enet_state)); 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, - stellaris_enet_cleanup, s); - qemu_format_nic_info_str(s->vc, s->macaddr); - } + sysbus_init_mmio(dev, 0x1000, s->mmio_index); + sysbus_init_irq(dev, &s->irq); + qdev_get_macaddr(&dev->qdev, s->macaddr); + + s->vc = qdev_get_vlan_client(&dev->qdev, + stellaris_enet_receive, + stellaris_enet_can_receive, + stellaris_enet_cleanup, s); + qemu_format_nic_info_str(s->vc, s->macaddr); stellaris_enet_reset(s); register_savevm("stellaris_enet", -1, 1, stellaris_enet_save, stellaris_enet_load, s); } + +static void stellaris_enet_register_devices(void) +{ + sysbus_register_dev("stellaris_enet", sizeof(stellaris_enet_state), + stellaris_enet_init); +} + +device_init(stellaris_enet_register_devices) |