[6287] Make pci_nic_init() use qemu_setup_nic_model() (Mark McLoughlin)
Revision: 6287
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6287 Author: aliguori Date: 2009-01-13 19:47:10 +0000 (Tue, 13 Jan 2009)
Log Message:
-----------
Make pci_nic_init() use qemu_setup_nic_model() (Mark McLoughlin)
Add a table of PCI NIC models to pass to qemu_setup_nic_model().
While we're at it, also add a corresponding table of NIC init functions.
Modified Paths:
--------------
trunk/hw/mips_malta.c
trunk/hw/pc.c
trunk/hw/pci.c
trunk/hw/pci.h
trunk/hw/ppc440_bamboo.c
trunk/hw/ppc_chrp.c
trunk/hw/ppc_oldworld.c
trunk/hw/ppc_prep.c
trunk/hw/r2d.c
trunk/hw/realview.c
trunk/hw/sun4u.c
trunk/hw/versatilepb.cModified: trunk/hw/mips_malta.c
===================================================================
hw/mips_malta.c +7 -10
@@ -487,19 +487,16 @@static void network_init (PCIBus *pci_bus) {int i; -NICInfo *nd;for (i =0 ; i < nb_nics; i++) { - nd = &nd_table[i]; -if (!nd->model) { - nd->model ="pcnet" ; - } -if (i ==0 &&strcmp (nd->model,"pcnet" ) ==0 ) { +NICInfo *nd = &nd_table[i]; +int devfn =-1 ; + +if (i ==0 && (!nd->model ||strcmp (nd->model,"pcnet" ) ==0 ))/* The malta board has a PCNet card using PCI SLOT 11 */ -pci_nic_init (pci_bus, nd,88 ); - }else { -pci_nic_init (pci_bus, nd,-1 ); - } + devfn =88 ; + +pci_nic_init (pci_bus, nd, devfn,"pcnet" ); } }
Modified: trunk/hw/pc.c
===================================================================
hw/pc.c +5 -21
@@ -764,7 +764,6 @@PCIBus *pci_bus;int piix3_devfn =-1 ;CPUState *env; -NICInfo *nd;qemu_irq *cpu_irq;qemu_irq *i8259;int index;
@@ -1000,27 +999,12 @@ }for (i =0 ; i < nb_nics; i++) { - nd = &nd_table[i]; -if (!nd->model) { -if (pci_enabled) { - nd->model ="ne2k_pci" ; - }else { - nd->model ="ne2k_isa" ; - } - } -if (strcmp (nd->model,"ne2k_isa" ) ==0 ) { +NICInfo *nd = &nd_table[i]; + +if (!pci_enabled || (nd->model &&strcmp (nd->model,"ne2k_isa" ) ==0 ))pc_init_ne2k_isa (nd, i8259); - }else if (pci_enabled) { -if (strcmp (nd->model,"?" ) ==0 ) -fprintf (stderr,"qemu: Supported ISA NICs: ne2k_isa\n" ); -pci_nic_init (pci_bus, nd,-1 ); - }else if (strcmp (nd->model,"?" ) ==0 ) { -fprintf (stderr,"qemu: Supported ISA NICs: ne2k_isa\n" ); -exit (1 ); - }else { -fprintf (stderr,"qemu: Unsupported NIC: %s\n" , nd->model); -exit (1 ); - } +else +pci_nic_init (pci_bus, nd,-1 ,"ne2k_pci" ); }if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) {
Modified: trunk/hw/pci.c
===================================================================
hw/pci.c +35 -25
68 lines not on this page · raw message
Modified: trunk/hw/pci.h
===================================================================
hw/pci.h +2 -1
@@ -118,7 +118,8 @@PCIBus *pci_register_bus (pci_set_irq_fn set_irq,pci_map_irq_fn map_irq,qemu_irq *pic,int devfn_min,int nirq); -void pci_nic_init (PCIBus *bus,NICInfo *nd,int devfn); +void pci_nic_init (PCIBus *bus,NICInfo *nd,int devfn, +const char *default_model);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);
Modified: trunk/hw/ppc440_bamboo.c
===================================================================
hw/ppc440_bamboo.c +3 -8
@@ -90,7 +90,6 @@ const char *cpu_model) {unsigned int pci_irq_nrs[4 ] = {28 ,27 ,26 ,25 }; -NICInfo *nd;PCIBus *pcibus;CPUState *env;uint64_t elf_entry;
@@ -118,13 +117,9 @@/* Register network interfaces. */ for (i =0 ; i < nb_nics; i++) { - nd = &nd_table[i]; -if (!nd->model) { -/* There are no PCI NICs on the Bamboo board, but there are -* PCI slots, so we can pick model whatever we want. */ - nd->model ="e1000" ; - } -pci_nic_init (pcibus, nd,-1 ); +/* There are no PCI NICs on the Bamboo board, but there are +* PCI slots, so we can pick whatever default model we want. */ +pci_nic_init (pcibus, &nd_table[i],-1 ,"e1000" ); } }
Modified: trunk/hw/ppc_chrp.c
===================================================================
hw/ppc_chrp.c +4 -5
@@ -265,11 +265,10 @@ escc_mem_index =escc_init (0x80013000 , dummy_irq[4 ], serial_hds[0 ], serial_hds[1 ],ESCC_CLOCK ,4 ); -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],-1 ); - } + +for (i =0 ; i < nb_nics; i++) +pci_nic_init (pci_bus, &nd_table[i],-1 ,"ne2k_pci" ); +if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) {fprintf (stderr,"qemu: too many IDE bus\n" );exit (1 );
Modified: trunk/hw/ppc_oldworld.c
===================================================================
hw/ppc_oldworld.c +2 -5
@@ -307,11 +307,8 @@ escc_mem_index =escc_init (0x80013000 , pic[0x10 ], serial_hds[0 ], serial_hds[1 ],ESCC_CLOCK ,4 ); -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],-1 ); - } +for (i =0 ; i < nb_nics; i++) +pci_nic_init (pci_bus, &nd_table[i],-1 ,"ne2k_pci" );/* First IDE channel is a CMD646 on the PCI bus */
Modified: trunk/hw/ppc_prep.c
===================================================================
hw/ppc_prep.c +1 -1
@@ -677,7 +677,7 @@if (strcmp (nd_table[i].model,"ne2k_isa" ) ==0 ) {isa_ne2000_init (ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]); }else { -pci_nic_init (pci_bus, &nd_table[i],-1 ); +pci_nic_init (pci_bus, &nd_table[i],-1 ,"ne2k_pci" ); } }
Modified: trunk/hw/r2d.c
===================================================================
hw/r2d.c +2 -2
@@ -230,9 +230,9 @@ drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL);/* NIC: rtl8139 on-board, and 2 slots. */ -pci_rtl8139_init (pci, &nd_table[0 ],2 <<3 ); +pci_nic_init (pci, &nd_table[0 ],2 <<3 ,"rtl8139" );for (i =1 ; i < nb_nics; i++) -pci_nic_init (pci, &nd_table[i],-1 ); +pci_nic_init (pci, &nd_table[i],-1 ,"ne2k_pci" );/* Todo: register on board registers */ {
Modified: trunk/hw/realview.c
===================================================================
hw/realview.c +1 -3
@@ -126,9 +126,7 @@smc91c111_init (nd,0x4e000000 , pic[28 ]); done_smc =1 ; }else { -if (!nd->model) - nd->model ="rtl8139" ; -pci_nic_init (pci_bus, nd,-1 ); +pci_nic_init (pci_bus, nd,-1 ,"rtl8139" ); } }
Modified: trunk/hw/sun4u.c
===================================================================
hw/sun4u.c +2 -5
@@ -535,11 +535,8 @@ } } -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],-1 ); - } +for (i =0 ; i < nb_nics; i++) +pci_nic_init (pci_bus, &nd_table[i],-1 ,"ne2k_pci" ); irq =qemu_allocate_irqs (cpu_set_irq, env,MAX_PILS );if (drive_get_max_bus (IF_IDE ) >=MAX_IDE_BUS ) {
Modified: trunk/hw/versatilepb.c
===================================================================
hw/versatilepb.c +1 -3
@@ -199,9 +199,7 @@smc91c111_init (nd,0x10010000 , sic[25 ]); done_smc =1 ; }else { -if (!nd->model) - nd->model ="rtl8139" ; -pci_nic_init (pci_bus, nd,-1 ); +pci_nic_init (pci_bus, nd,-1 ,"rtl8139" ); } }if (usb_enabled) {