Skip to contentSkip to conversation

m68k: QOMify the MCF Fast Ethernet Controller device

PATCH In review Thomas Huth 2 participants 2 messages Jan 6, 2017 – Jan 8, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: QOMify the MCF Fast Ethernet Controller device

When running qemu-system-m68k with the "-net" parameter (for example simply "-net nic -net user"), there is currently a confusing warning message saying:

Warning: requested NIC (anonymous, model mcf_fec) was not created (not supported by this machine?)

This seems to happen because the MCF NIC has never been adapted to the currently expected QEMU device behavior. Thus let's QOMify the NIC now to get rid of the warning message.

---
 hw/m68k/mcf5208.c     | 20 ++++++++++++++
 hw/net/mcf_fec.c      | 75 ++++++++++++++++++++++++++++++++++++++-------------
 include/hw/m68k/mcf.h |  4 ---
 3 files changed, 77 insertions(+), 22 deletions(-)
hw/m68k/mcf5208.c +20 -0
index 3438314..f9e1adb 100644
@@ -18,6 +18,7 @@
 #include "net/net.h"
 #include "hw/boards.h"
 #include "hw/loader.h"
+#include "hw/sysbus.h"
 #include "elf.h"
 #include "exec/address-spaces.h"
 
@@ -192,6 +193,25 @@ static void mcf5208_sys_init(MemoryRegion *address_space, qemu_irq *pic)
     }
 }
 
+static void mcf_fec_init(MemoryRegion *sysmem, NICInfo *nd, hwaddr base,
+                         qemu_irq *irqs)
+{
+    DeviceState *dev;
+    SysBusDevice *s;
+    int i;
+
+    dev = qdev_create(NULL, "mcf-fec");
+    qdev_set_nic_properties(dev, nd);
+    qdev_init_nofail(dev);
+
+    s = SYS_BUS_DEVICE(dev);
+    for (i = 0; i < 13; i++) {
+        sysbus_connect_irq(s, i, irqs[i]);
+    }
+
+    memory_region_add_subregion(sysmem, base, sysbus_mmio_get_region(s, 0));
+}
+
 static void mcf5208evb_init(MachineState *machine)
 {
     ram_addr_t ram_size = machine->ram_size;
hw/net/mcf_fec.c +57 -18

122 lines not on this page · raw message

include/hw/m68k/mcf.h +0 -4
index fdae229..bf43998 100644
@@ -21,10 +21,6 @@ qemu_irq *mcf_intc_init(struct MemoryRegion *sysmem,
                         hwaddr base,
                         M68kCPU *cpu);
 
-/* mcf_fec.c */
-void mcf_fec_init(struct MemoryRegion *sysmem, NICInfo *nd,
-                  hwaddr base, qemu_irq *irq);
-
 /* mcf5206.c */
 qemu_irq *mcf5206_init(struct MemoryRegion *sysmem,
                        uint32_t base, M68kCPU *cpu);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 32 lines · Thomas Huth

When running qemu-system-m68k with the "-net" parameter (for example simply "-net nic -net user"), there is currently a confusing warning message saying:

Warning: requested NIC (anonymous, model mcf_fec) was not created (not supported by this machine?)

This seems to happen because the MCF NIC has never been adapted to the currently expected QEMU device behavior. Thus let's QOMify the NIC now to get rid of the warning message.

---
 hw/m68k/mcf5208.c     | 20 ++++++++++++++
 hw/net/mcf_fec.c      | 75 ++++++++++++++++++++++++++++++++++++++-------------
 include/hw/m68k/mcf.h |  4 ---
 3 files changed, 77 insertions(+), 22 deletions(-)
hw/m68k/mcf5208.c +1 -0
index 3438314..f9e1adb 100644
@@ -18,6 +18,7 @@
 #include "net/net.h"
 #include "hw/boards.h"
 #include "hw/loader.h"
+#include "hw/sysbus.h"
 #include "elf.h"
 #include "exec/address-spaces.h"
 
@@ -192,6 +193,25 @@ static void mcf5208_sys_init(MemoryRegion *address_space, qemu_irq *pic)
     }

hw/m68k/mcf5208.c static void mcf5208_sys_init(MemoryRegion *address_space, qemu_irq *pic) · line 203

Quoted 10 lines
hw/m68k/mcf5208.c +8 -0
 }
 
+static void mcf_fec_init(MemoryRegion *sysmem, NICInfo *nd, hwaddr base,
+                         qemu_irq *irqs)
+{
+    DeviceState *dev;
+    SysBusDevice *s;
+    int i;
+
+    dev = qdev_create(NULL, "mcf-fec");

I just read on http://wiki.qemu.org/Documentation/QOMConventions:

"DO use TYPE_FOO constants, defined in a header if used in other parts
of code"

... so I guess I should rather declare the TYPE_MCF_FEC_NET in a header file instead. I'll send a v2 of this patch...

Thomas