qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [6286] Check NIC model in some NIC init functions (Mark McLoughlin)
@ 2009-01-13 19:39 Anthony Liguori
  0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2009-01-13 19:39 UTC (permalink / raw)
  To: qemu-devel

Revision: 6286
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6286
Author:   aliguori
Date:     2009-01-13 19:39:36 +0000 (Tue, 13 Jan 2009)

Log Message:
-----------
Check NIC model in some NIC init functions (Mark McLoughlin)

Some NIC init functions are only called when that model is
the only valid model. In that case, it makes sense to use
qemu_check_nic_model() from the NIC init function itself.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Modified Paths:
--------------
    trunk/hw/axis_dev88.c
    trunk/hw/etraxfs.c
    trunk/hw/etraxfs_eth.c
    trunk/hw/integratorcp.c
    trunk/hw/mcf5208.c
    trunk/hw/mcf_fec.c
    trunk/hw/mips_mipssim.c
    trunk/hw/mips_r4k.c
    trunk/hw/mipsnet.c
    trunk/hw/musicpal.c
    trunk/hw/ne2000.c
    trunk/hw/pcnet.c
    trunk/hw/realview.c
    trunk/hw/smc91c111.c
    trunk/hw/stellaris.c
    trunk/hw/stellaris_enet.c
    trunk/hw/sun4m.c
    trunk/hw/versatilepb.c

Modified: trunk/hw/axis_dev88.c
===================================================================
--- trunk/hw/axis_dev88.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/axis_dev88.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -303,13 +303,10 @@
     }
 
     /* Add the two ethernet blocks.  */
-    nd_table[0].model = nd_table[0].model ? nd_table[0].model : "fseth";
     eth[0] = etraxfs_eth_init(&nd_table[0], env, pic->irq + 25, 0x30034000, 1);
-    if (nb_nics > 1) {
-        nd_table[1].model = nd_table[1].model ? nd_table[1].model : "fseth";
+    if (nb_nics > 1)
         eth[1] = etraxfs_eth_init(&nd_table[1], env,
                                   pic->irq + 26, 0x30036000, 2);
-    }
 
     /* The DMA Connector block is missing, hardwire things for now.  */
     etraxfs_dmac_connect_client(etraxfs_dmac, 0, eth[0]);

Modified: trunk/hw/etraxfs.c
===================================================================
--- trunk/hw/etraxfs.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/etraxfs.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -94,13 +94,10 @@
     }
 
     /* Add the two ethernet blocks.  */
-    nd_table[0].model = nd_table[0].model ? nd_table[0].model : "fseth";
     eth[0] = etraxfs_eth_init(&nd_table[0], env, pic->irq + 25, 0x30034000, 1);
-    if (nb_nics > 1) {
-        nd_table[1].model = nd_table[1].model ? nd_table[1].model : "fseth";
+    if (nb_nics > 1)
         eth[1] = etraxfs_eth_init(&nd_table[1], env,
                                   pic->irq + 26, 0x30036000, 2);
-    }
 
     /* The DMA Connector block is missing, hardwire things for now.  */
     etraxfs_dmac_connect_client(etraxfs_dmac, 0, eth[0]);

Modified: trunk/hw/etraxfs_eth.c
===================================================================
--- trunk/hw/etraxfs_eth.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/etraxfs_eth.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -561,6 +561,8 @@
 	struct etraxfs_dma_client *dma = NULL;	
 	struct fs_eth *eth = NULL;
 
+	qemu_check_nic_model(nd, "fseth");
+
 	dma = qemu_mallocz(sizeof *dma * 2);
 	if (!dma)
 		return NULL;

Modified: trunk/hw/integratorcp.c
===================================================================
--- trunk/hw/integratorcp.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/integratorcp.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -497,18 +497,8 @@
         exit(1);
     }
     pl181_init(0x1c000000, drives_table[sd].bdrv, pic[23], pic[24]);
-    if (nd_table[0].vlan) {
-        if (nd_table[0].model == NULL
-            || strcmp(nd_table[0].model, "smc91c111") == 0) {
-            smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
-        } else if (strcmp(nd_table[0].model, "?") == 0) {
-            fprintf(stderr, "qemu: Supported NICs: smc91c111\n");
-            exit (1);
-        } else {
-            fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
-            exit (1);
-        }
-    }
+    if (nd_table[0].vlan)
+        smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
     pl110_init(ds, 0xc0000000, pic[22], 0);
 
     integrator_binfo.ram_size = ram_size;

Modified: trunk/hw/mcf5208.c
===================================================================
--- trunk/hw/mcf5208.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/mcf5208.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -241,18 +241,8 @@
         fprintf(stderr, "Too many NICs\n");
         exit(1);
     }
-    if (nd_table[0].vlan) {
-        if (nd_table[0].model == NULL
-            || strcmp(nd_table[0].model, "mcf_fec") == 0) {
-            mcf_fec_init(&nd_table[0], 0xfc030000, pic + 36);
-        } else if (strcmp(nd_table[0].model, "?") == 0) {
-            fprintf(stderr, "qemu: Supported NICs: mcf_fec\n");
-            exit (1);
-        } else {
-            fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
-            exit (1);
-        }
-    }
+    if (nd_table[0].vlan)
+        mcf_fec_init(&nd_table[0], 0xfc030000, pic + 36);
 
     /*  0xfc000000 SCM.  */
     /*  0xfc004000 XBS.  */

Modified: trunk/hw/mcf_fec.c
===================================================================
--- trunk/hw/mcf_fec.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/mcf_fec.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -446,6 +446,8 @@
     mcf_fec_state *s;
     int iomemtype;
 
+    qemu_check_nic_model(nd, "mcf_fec");
+
     s = (mcf_fec_state *)qemu_mallocz(sizeof(mcf_fec_state));
     s->irq = irq;
     iomemtype = cpu_register_io_memory(0, mcf_fec_readfn,

Modified: trunk/hw/mips_mipssim.c
===================================================================
--- trunk/hw/mips_mipssim.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/mips_mipssim.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -175,19 +175,9 @@
     if (serial_hds[0])
         serial_init(0x3f8, env->irq[4], 115200, serial_hds[0]);
 
-    if (nd_table[0].vlan) {
-        if (nd_table[0].model == NULL
-            || strcmp(nd_table[0].model, "mipsnet") == 0) {
-            /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
-            mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
-        } else if (strcmp(nd_table[0].model, "?") == 0) {
-            fprintf(stderr, "qemu: Supported NICs: mipsnet\n");
-            exit (1);
-        } else {
-            fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
-            exit (1);
-        }
-    }
+    if (nd_table[0].vlan)
+        /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
+        mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
 }
 
 QEMUMachine mips_mipssim_machine = {

Modified: trunk/hw/mips_r4k.c
===================================================================
--- trunk/hw/mips_r4k.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/mips_r4k.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -247,20 +247,8 @@
     isa_vga_init(ds, phys_ram_base + ram_size, ram_size,
                  vga_ram_size);
 
-    if (nd_table[0].vlan) {
-        if (nd_table[i].model == NULL) {
-	    nd_table[i].model = "ne2k_isa";
-        }
-        if (strcmp(nd_table[0].model, "ne2k_isa") == 0) {
-            isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
-        } else if (strcmp(nd_table[0].model, "?") == 0) {
-            fprintf(stderr, "qemu: Supported NICs: ne2k_isa\n");
-            exit (1);
-        } else {
-            fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
-            exit (1);
-        }
-    }
+    if (nd_table[0].vlan)
+        isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
 
     if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
         fprintf(stderr, "qemu: too many IDE bus\n");

Modified: trunk/hw/mipsnet.c
===================================================================
--- trunk/hw/mipsnet.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/mipsnet.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -236,6 +236,8 @@
 {
     MIPSnetState *s;
 
+    qemu_check_nic_model(nd, "mipsnet");
+
     s = qemu_mallocz(sizeof(MIPSnetState));
     if (!s)
         return;

Modified: trunk/hw/musicpal.c
===================================================================
--- trunk/hw/musicpal.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/musicpal.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -714,6 +714,8 @@
     mv88w8618_eth_state *s;
     int iomemtype;
 
+    qemu_check_nic_model(nd, "mv88w8618");
+
     s = qemu_mallocz(sizeof(mv88w8618_eth_state));
     if (!s)
         return;

Modified: trunk/hw/ne2000.c
===================================================================
--- trunk/hw/ne2000.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/ne2000.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -722,6 +722,8 @@
 {
     NE2000State *s;
 
+    qemu_check_nic_model(nd, "ne2k_isa");
+
     s = qemu_mallocz(sizeof(NE2000State));
     if (!s)
         return;

Modified: trunk/hw/pcnet.c
===================================================================
--- trunk/hw/pcnet.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/pcnet.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -2087,6 +2087,8 @@
     PCNetState *d;
     int lance_io_memory;
 
+    qemu_check_nic_model(nd, "lance");
+
     d = qemu_mallocz(sizeof(PCNetState));
     if (!d)
         return;

Modified: trunk/hw/realview.c
===================================================================
--- trunk/hw/realview.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/realview.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -121,11 +121,13 @@
     }
     for(n = 0; n < nb_nics; n++) {
         nd = &nd_table[n];
-        if (!nd->model)
-            nd->model = done_smc ? "rtl8139" : "smc91c111";
-        if (strcmp(nd->model, "smc91c111") == 0) {
+
+        if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
             smc91c111_init(nd, 0x4e000000, pic[28]);
+            done_smc = 1;
         } else {
+            if (!nd->model)
+                nd->model = "rtl8139";
             pci_nic_init(pci_bus, nd, -1);
         }
     }

Modified: trunk/hw/smc91c111.c
===================================================================
--- trunk/hw/smc91c111.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/smc91c111.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -695,6 +695,8 @@
     smc91c111_state *s;
     int iomemtype;
 
+    qemu_check_nic_model(nd, "smc91c111");
+
     s = (smc91c111_state *)qemu_mallocz(sizeof(smc91c111_state));
     iomemtype = cpu_register_io_memory(0, smc91c111_readfn,
                                        smc91c111_writefn, s);

Modified: trunk/hw/stellaris.c
===================================================================
--- trunk/hw/stellaris.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/stellaris.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -1361,10 +1361,8 @@
             pl022_init(0x40008000, pic[7], NULL, NULL);
         }
     }
-    if (board->dc4 & (1 << 28)) {
-        /* FIXME: Obey network model.  */
+    if (board->dc4 & (1 << 28))
         stellaris_enet_init(&nd_table[0], 0x40048000, pic[42]);
-    }
     if (board->peripherals & BP_GAMEPAD) {
         qemu_irq gpad_irq[5];
         static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d };

Modified: trunk/hw/stellaris_enet.c
===================================================================
--- trunk/hw/stellaris_enet.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/stellaris_enet.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -389,6 +389,8 @@
     stellaris_enet_state *s;
     int iomemtype;
 
+    qemu_check_nic_model(nd, "stellaris");
+
     s = (stellaris_enet_state *)qemu_mallocz(sizeof(stellaris_enet_state));
     iomemtype = cpu_register_io_memory(0, stellaris_enet_readfn,
                                        stellaris_enet_writefn, s);

Modified: trunk/hw/sun4m.c
===================================================================
--- trunk/hw/sun4m.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/sun4m.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -536,17 +536,7 @@
     tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
              hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
 
-    if (nd_table[0].model == NULL)
-        nd_table[0].model = "lance";
-    if (strcmp(nd_table[0].model, "lance") == 0) {
-        lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
-    } else if (strcmp(nd_table[0].model, "?") == 0) {
-        fprintf(stderr, "qemu: Supported NICs: lance\n");
-        exit (1);
-    } else {
-        fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
-        exit (1);
-    }
+    lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
 
     nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
                         hwdef->nvram_size, 8);
@@ -1329,17 +1319,7 @@
     tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
              hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
 
-    if (nd_table[0].model == NULL)
-        nd_table[0].model = "lance";
-    if (strcmp(nd_table[0].model, "lance") == 0) {
-        lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
-    } else if (strcmp(nd_table[0].model, "?") == 0) {
-        fprintf(stderr, "qemu: Supported NICs: lance\n");
-        exit (1);
-    } else {
-        fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
-        exit (1);
-    }
+    lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
 
     nvram = m48t59_init(sbi_irq[0], hwdef->nvram_base, 0,
                         hwdef->nvram_size, 8);
@@ -1545,17 +1525,7 @@
     tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
              hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
 
-    if (nd_table[0].model == NULL)
-        nd_table[0].model = "lance";
-    if (strcmp(nd_table[0].model, "lance") == 0) {
-        lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
-    } else if (strcmp(nd_table[0].model, "?") == 0) {
-        fprintf(stderr, "qemu: Supported NICs: lance\n");
-        exit (1);
-    } else {
-        fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
-        exit (1);
-    }
+    lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
 
     nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
                         hwdef->nvram_size, 2);

Modified: trunk/hw/versatilepb.c
===================================================================
--- trunk/hw/versatilepb.c	2009-01-13 19:15:55 UTC (rev 6285)
+++ trunk/hw/versatilepb.c	2009-01-13 19:39:36 UTC (rev 6286)
@@ -194,11 +194,13 @@
        so many of the qemu PCI devices are not useable.  */
     for(n = 0; n < nb_nics; n++) {
         nd = &nd_table[n];
-        if (!nd->model)
-            nd->model = done_smc ? "rtl8139" : "smc91c111";
-        if (strcmp(nd->model, "smc91c111") == 0) {
+
+        if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
             smc91c111_init(nd, 0x10010000, sic[25]);
+            done_smc = 1;
         } else {
+            if (!nd->model)
+                nd->model = "rtl8139";
             pci_nic_init(pci_bus, nd, -1);
         }
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-01-13 19:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-13 19:39 [Qemu-devel] [6286] Check NIC model in some NIC init functions (Mark McLoughlin) Anthony Liguori

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).