qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Hervé Poussineau" <hpoussin@reactos.org>
To: qemu-devel@nongnu.org
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Subject: [Qemu-devel] [PATCH 15/20] [MIPS] qdev: convert dp83932 network card to rc4030 device
Date: Sun,  1 Aug 2010 19:37:17 +0200	[thread overview]
Message-ID: <1280684242-19611-15-git-send-email-hpoussin@reactos.org> (raw)
In-Reply-To: <4C5579DA.8050508@reactos.org>

Use it in Jazz emulation
Remove dp83932_init() function, which is not used anymore

Signed-off-by: Hervé Poussineau <hpoussin@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

  parent reply	other threads:[~2010-08-01 18:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-01 13:42 [Qemu-devel] [PATCH 00/20] MIPS Magnum conversion to qdev Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 01/20] [MIPS] cpu: add a init inplace method Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 02/20] [MIPS] cpu: convert to qdev Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 03/20] [MIPS] Jazz emulation: create a qdev cpu Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 04/20] [MIPS] rc4030: convert to qdev Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 05/20] Add a stub for some rc4030 functions, if rc4030 support is not compiled in Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 06/20] [MIPS] qdev: convert i8042 to rc4030 device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 07/20] [MIPS] qdev: convert parallel port " Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 08/20] [MIPS] qdev: convert serial " Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 09/20] [MIPS] qdev: convert jazz-led to sysbus device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 10/20] [MIPS] Jazz emulation: make video card optional Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 11/20] [MIPS] qdev: convert vga-isa-mm to ISA device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 12/20] [MIPS] qdev: convert g364fb to rc4030 device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 13/20] [MIPS] qdev: add a rtc forwarder device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 14/20] [MIPS] qdev: add an isa bus device Hervé Poussineau
2010-08-01 17:37 ` Hervé Poussineau [this message]
2010-08-01 17:37 ` [Qemu-devel] [PATCH 16/20] [MIPS] qdev: convert floppy disk controller to rc4030 device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 17/20] [MIPS] qdev: convert esp scsi adapter " Hervé Poussineau
2010-08-02 14:51   ` Artyom Tarasenko
2010-08-01 17:37 ` [Qemu-devel] [PATCH 18/20] [MIPS] qdev: convert ds1225y nvram to sysbus device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 19/20] [MIPS] qdev: add a mips board device, which initializes the ram and the rom Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 20/20] [MIPS] qdev: Complete rc4030 conversion, by removing legacy stuff Hervé Poussineau
2010-08-02 16:06 ` [Qemu-devel] [PATCH 00/20] MIPS Magnum conversion to qdev Blue Swirl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1280684242-19611-15-git-send-email-hpoussin@reactos.org \
    --to=hpoussin@reactos.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).