Use it in Jazz emulation Remove dp83932_init() function, which is not used anymore
Signed-off-by: Hervé Poussineau <hpous...@reactos.org> --- hw/dp8393x.c | 64 ++++++++++++++++++++++++++++++++++++------------------- hw/mips.h | 5 ---- hw/mips_jazz.c | 6 +++- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/hw/dp8393x.c b/hw/dp8393x.c index e65e4d1..f8fd9f5 100644 --- a/hw/dp8393x.c +++ b/hw/dp8393x.c @@ -21,6 +21,8 @@ #include "qemu-timer.h" #include "net.h" #include "mips.h" +#include "rc4030.h" +#include "qdev-addr.h" //#define DEBUG_SONIC @@ -147,7 +149,7 @@ do { printf("sonic ERROR: %s: " fmt, __func__ , ## __VA_ARGS__); } while (0) typedef struct dp8393xState { /* Hardware */ - int it_shift; + uint32_t it_shift; qemu_irq irq; #ifdef DEBUG_SONIC int irq_level; @@ -869,8 +871,6 @@ static void nic_cleanup(VLANClientState *nc) qemu_del_timer(s->watchdog); qemu_free_timer(s->watchdog); - - qemu_free(s); } static NetClientInfo net_dp83932_info = { @@ -881,33 +881,53 @@ static NetClientInfo net_dp83932_info = { .cleanup = nic_cleanup, }; -void dp83932_init(NICInfo *nd, target_phys_addr_t base, int it_shift, - qemu_irq irq, void* mem_opaque, - void (*memory_rw)(void *opaque, target_phys_addr_t addr, uint8_t *buf, int len, int is_write)) -{ - dp8393xState *s; - - qemu_check_nic_model(nd, "dp83932"); +typedef struct RC4030dp83932State { + RC4030Device dev; + target_phys_addr_t iobase; + uint32_t irq; + dp8393xState state; +} RC4030dp83932State; - s = qemu_mallocz(sizeof(dp8393xState)); +static int dp83932_rc4030_init(RC4030Device *dev) +{ + RC4030dp83932State *rc4030 = DO_UPCAST(RC4030dp83932State, dev, dev); + dp8393xState *s = &rc4030->state; - s->mem_opaque = mem_opaque; - s->memory_rw = memory_rw; - s->it_shift = it_shift; - s->irq = irq; + s->mem_opaque = rc4030_get_opaque(); + s->memory_rw = rc4030_dma_memory_rw; + rc4030_init_irq(dev, &s->irq, rc4030->irq); s->watchdog = qemu_new_timer(vm_clock, dp8393x_watchdog, s); s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux */ - memcpy(s->conf.macaddr.a, nd->macaddr, sizeof(s->conf.macaddr)); - s->conf.vlan = nd->vlan; - s->conf.peer = nd->netdev; - - s->nic = qemu_new_nic(&net_dp83932_info, &s->conf, nd->model, nd->name, s); - + qemu_macaddr_default_if_unset(&s->conf.macaddr); + s->nic = qemu_new_nic(&net_dp83932_info, &s->conf, dev->qdev.info->name, dev->qdev.id, s); qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a); + qemu_register_reset(nic_reset, s); nic_reset(s); s->mmio_index = cpu_register_io_memory(dp8393x_read, dp8393x_write, s); - cpu_register_physical_memory(base, 0x40 << it_shift, s->mmio_index); + cpu_register_physical_memory(rc4030->iobase, 0x40 << s->it_shift, s->mmio_index); + + return 0; } + +static RC4030DeviceInfo dp83932_rc4030_info = { + .qdev.name = "rc4030-dp83932", + .qdev.size = sizeof(RC4030dp83932State), + .init = dp83932_rc4030_init, + .qdev.props = (Property[]) { + DEFINE_PROP_TADDR("iobase", RC4030dp83932State, iobase, 0x80001000), + DEFINE_PROP_UINT32("itshift", RC4030dp83932State, state.it_shift, 2), + DEFINE_PROP_UINT32("irq", RC4030dp83932State, irq, 4), + DEFINE_NIC_PROPERTIES( RC4030dp83932State, state.conf), + DEFINE_PROP_END_OF_LIST(), + }, +}; + +static void dp8393x_register_devices(void) +{ + rc4030_qdev_register(&dp83932_rc4030_info); +} + +device_init(dp8393x_register_devices) diff --git a/hw/mips.h b/hw/mips.h index aa790d8..d8e4954 100644 --- a/hw/mips.h +++ b/hw/mips.h @@ -15,9 +15,4 @@ void ds1225y_set_protection(void *opaque, int protection); /* mipsnet.c */ void mipsnet_init(int base, qemu_irq irq, NICInfo *nd); -/* dp8393x.c */ -void dp83932_init(NICInfo *nd, target_phys_addr_t base, int it_shift, - qemu_irq irq, void* mem_opaque, - void (*memory_rw)(void *opaque, target_phys_addr_t addr, uint8_t *buf, int len, int is_write)); - #endif diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index cf0001e..c0a27b2 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -192,8 +192,10 @@ void mips_jazz_init (ram_addr_t ram_size, if (!nd->model) nd->model = qemu_strdup("dp83932"); if (strcmp(nd->model, "dp83932") == 0) { - dp83932_init(nd, 0x80001000, 2, rc4030[4], - rc4030_opaque, rc4030_dma_memory_rw); + qemu_check_nic_model(nd, nd->model); + dev = qdev_create(NULL, nd->model); + qdev_set_nic_properties(dev, nd); + qdev_init_nofail(dev); break; } else if (strcmp(nd->model, "?") == 0) { fprintf(stderr, "qemu: Supported NICs: dp83932\n"); -- 1.7.1.GIT