From patchwork Sun Aug 1 17:37:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Herv=C3=A9_Poussineau?= X-Patchwork-Id: 60487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B0FBC1007D1 for ; Mon, 2 Aug 2010 04:41:36 +1000 (EST) Received: from localhost ([127.0.0.1]:54739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OfdTX-0000y8-OI for incoming@patchwork.ozlabs.org; Sun, 01 Aug 2010 14:41:31 -0400 Received: from [140.186.70.92] (port=41998 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ofd0Z-0007FT-3G for qemu-devel@nongnu.org; Sun, 01 Aug 2010 14:11:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ofd0X-00063E-QB for qemu-devel@nongnu.org; Sun, 01 Aug 2010 14:11:34 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:43934) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ofd0X-00062f-2k for qemu-devel@nongnu.org; Sun, 01 Aug 2010 14:11:33 -0400 Received: from localhost.localdomain (unknown [88.171.126.33]) by smtp5-g21.free.fr (Postfix) with ESMTP id DB561D4803C; Sun, 1 Aug 2010 20:11:27 +0200 (CEST) From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= To: qemu-devel@nongnu.org Date: Sun, 1 Aug 2010 19:37:17 +0200 Message-Id: <1280684242-19611-15-git-send-email-hpoussin@reactos.org> X-Mailer: git-send-email 1.7.1.GIT In-Reply-To: <4C5579DA.8050508@reactos.org> References: <4C5579DA.8050508@reactos.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [Qemu-devel] [PATCH 15/20] [MIPS] qdev: convert dp83932 network card to rc4030 device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use it in Jazz emulation Remove dp83932_init() function, which is not used anymore Signed-off-by: Hervé Poussineau --- 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");