Devfn number for network PCI cards, by Aurelien Jarno.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2314 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 94700c1..a045a20 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -781,7 +781,7 @@
     register_ioport_read(addr + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
 }
 
-void pci_ne2000_init(PCIBus *bus, NICInfo *nd)
+void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
     PCINE2000State *d;
     NE2000State *s;
@@ -789,7 +789,7 @@
     
     d = (PCINE2000State *)pci_register_device(bus,
                                               "NE2000", sizeof(PCINE2000State),
-                                              -1, 
+                                              devfn, 
                                               NULL, NULL);
     pci_conf = d->dev.config;
     pci_conf[0x00] = 0xec; // Realtek 8029
diff --git a/hw/pc.c b/hw/pc.c
index 1c141ae..408a9fb 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -668,7 +668,7 @@
         if (strcmp(nd->model, "ne2k_isa") == 0) {
             pc_init_ne2k_isa(nd);
         } else if (pci_enabled) {
-            pci_nic_init(pci_bus, nd);
+            pci_nic_init(pci_bus, nd, -1);
         } else {
             fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
             exit(1);
diff --git a/hw/pci.c b/hw/pci.c
index d8fcd7b..b895f98 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -544,14 +544,14 @@
 }
 
 /* Initialize a PCI NIC.  */
-void pci_nic_init(PCIBus *bus, NICInfo *nd)
+void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
     if (strcmp(nd->model, "ne2k_pci") == 0) {
-        pci_ne2000_init(bus, nd);
+        pci_ne2000_init(bus, nd, devfn);
     } else if (strcmp(nd->model, "rtl8139") == 0) {
-        pci_rtl8139_init(bus, nd);
+        pci_rtl8139_init(bus, nd, devfn);
     } else if (strcmp(nd->model, "pcnet") == 0) {
-        pci_pcnet_init(bus, nd);
+        pci_pcnet_init(bus, nd, devfn);
     } else {
         fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
         exit (1);
diff --git a/hw/pcnet.c b/hw/pcnet.c
index f242cd1..3bdddeb 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -1889,7 +1889,7 @@
     cpu_physical_memory_read(addr, buf, len);
 }
 
-void pci_pcnet_init(PCIBus *bus, NICInfo *nd)
+void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
     PCNetState *d;
     uint8_t *pci_conf;
@@ -1900,7 +1900,7 @@
 #endif
 
     d = (PCNetState *)pci_register_device(bus, "PCNet", sizeof(PCNetState),
-                                          -1, NULL, NULL);
+                                          devfn, NULL, NULL);
                                           
     pci_conf = d->dev.config;
     
diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c
index 7599eab..1e0fd2e 100644
--- a/hw/ppc_chrp.c
+++ b/hw/ppc_chrp.c
@@ -436,7 +436,7 @@
         for(i = 0; i < nb_nics; i++) {
             if (!nd_table[i].model)
                 nd_table[i].model = "ne2k_pci";
-            pci_nic_init(pci_bus, &nd_table[i]);
+            pci_nic_init(pci_bus, &nd_table[i], -1);
         }
         
         pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
@@ -483,7 +483,7 @@
         serial_init(&pic_set_irq_new, isa_pic, 0x3f8, 4, serial_hds[0]);
         
         for(i = 0; i < nb_nics; i++) {
-            pci_ne2000_init(pci_bus, &nd_table[i]);
+            pci_ne2000_init(pci_bus, &nd_table[i], -1);
         }
         
 #if 1
diff --git a/hw/realview.c b/hw/realview.c
index 11b0916..6d057ce 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -71,7 +71,7 @@
         if (strcmp(nd->model, "smc91c111") == 0) {
             smc91c111_init(nd, 0x4e000000, pic, 28);
         } else {
-            pci_nic_init(pci_bus, nd);
+            pci_nic_init(pci_bus, nd, -1);
         }
     }
 
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index db6353a..94fc2fc 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -3409,7 +3409,7 @@
 }
 #endif /* RTL8139_ONBOARD_TIMER */
 
-void pci_rtl8139_init(PCIBus *bus, NICInfo *nd)
+void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
     PCIRTL8139State *d;
     RTL8139State *s;
@@ -3417,7 +3417,7 @@
     
     d = (PCIRTL8139State *)pci_register_device(bus,
                                               "RTL8139", sizeof(PCIRTL8139State),
-                                              -1, 
+                                              devfn, 
                                               NULL, NULL);
     pci_conf = d->dev.config;
     pci_conf[0x00] = 0xec; /* Realtek 8139 */
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 6d41369..61069a6 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -344,7 +344,7 @@
     for(i = 0; i < nb_nics; i++) {
         if (!nd_table[i].model)
             nd_table[i].model = "ne2k_pci";
-	pci_nic_init(pci_bus, &nd_table[i]);
+	pci_nic_init(pci_bus, &nd_table[i], -1);
     }
 
     pci_cmd646_ide_init(pci_bus, bs_table, 1);
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 475cb48..12b7303 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -188,7 +188,7 @@
         if (strcmp(nd->model, "smc91c111") == 0) {
             smc91c111_init(nd, 0x10010000, sic, 25);
         } else {
-            pci_nic_init(pci_bus, nd);
+            pci_nic_init(pci_bus, nd, -1);
         }
     }
     if (usb_enabled) {
diff --git a/vl.h b/vl.h
index ef1205c..8667ba8 100644
--- a/vl.h
+++ b/vl.h
@@ -793,7 +793,7 @@
 PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
                          void *pic, int devfn_min, int nirq);
 
-void pci_nic_init(PCIBus *bus, NICInfo *nd);
+void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn);
 void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
 uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
 int pci_bus_num(PCIBus *s);
@@ -956,15 +956,15 @@
 /* ne2000.c */
 
 void isa_ne2000_init(int base, int irq, NICInfo *nd);
-void pci_ne2000_init(PCIBus *bus, NICInfo *nd);
+void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn);
 
 /* rtl8139.c */
 
-void pci_rtl8139_init(PCIBus *bus, NICInfo *nd);
+void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
 
 /* pcnet.c */
 
-void pci_pcnet_init(PCIBus *bus, NICInfo *nd);
+void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn);
 void pcnet_h_reset(void *opaque);
 void *lance_init(NICInfo *nd, uint32_t leaddr, void *dma_opaque);