qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [patch 2/2] qemu: switch pci device init functions to accep


From: Marcelo Tosatti
Subject: [Qemu-devel] [patch 2/2] qemu: switch pci device init functions to accept devfn
Date: Mon, 13 Apr 2009 00:53:13 -0300
User-agent: quilt/0.47-1

Some pci device initialization functions do not accept a devfn parameter,
but instead use "-1", which caused pci_register_device to find the first
free slot on the given bus.

Have them accept a "devfn" parameter, and use the newly introduced
pci_bus_assign_dev_addr function on platform init code to perform
the "first free" enumeration.

Some pci init functions still hardcode devfn (usually the host bridge of the bus
with devfn 0), those will have be to changed later.

 
Index: trunk/hw/cirrus_vga.c
===================================================================
--- trunk.orig/hw/cirrus_vga.c
+++ trunk/hw/cirrus_vga.c
@@ -3358,7 +3358,7 @@ static void pci_cirrus_write_config(PCID
     vga_dirty_log_start((VGAState *)s);
 }
 
-void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_cirrus_vga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
                          ram_addr_t vga_ram_offset, int vga_ram_size)
 {
     PCICirrusVGAState *d;
@@ -3371,7 +3371,8 @@ void pci_cirrus_vga_init(PCIBus *bus, ui
     /* setup PCI configuration registers */
     d = (PCICirrusVGAState *)pci_register_device(bus, "Cirrus VGA",
                                                  sizeof(PCICirrusVGAState),
-                                                 -1, NULL, 
pci_cirrus_write_config);
+                                                 devfn, NULL,
+                                                 pci_cirrus_write_config);
     pci_conf = d->dev.config;
     pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CIRRUS);
     pci_config_set_device_id(pci_conf, device_id);
Index: trunk/hw/pc.c
===================================================================
--- trunk.orig/hw/pc.c
+++ trunk/hw/pc.c
@@ -946,7 +946,7 @@ vga_bios_error:
 
     if (pci_enabled) {
         pci_bus = i440fx_init(&i440fx_state, i8259);
-        piix3_devfn = piix3_init(pci_bus, -1);
+        piix3_devfn = piix3_init(pci_bus, pci_bus_assign_dev_addr(pci_bus));
     } else {
         pci_bus = NULL;
     }
@@ -959,6 +959,7 @@ vga_bios_error:
     if (cirrus_vga_enabled) {
         if (pci_enabled) {
             pci_cirrus_vga_init(pci_bus,
+                                pci_bus_assign_dev_addr(pci_bus),
                                 phys_ram_base + vga_ram_addr,
                                 vga_ram_addr, vga_ram_size);
         } else {
@@ -967,13 +968,15 @@ vga_bios_error:
         }
     } else if (vmsvga_enabled) {
         if (pci_enabled)
-            pci_vmsvga_init(pci_bus, phys_ram_base + vga_ram_addr,
+            pci_vmsvga_init(pci_bus, pci_bus_assign_dev_addr(pci_bus),
+                            phys_ram_base + vga_ram_addr,
                             vga_ram_addr, vga_ram_size);
         else
             fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
     } else if (std_vga_enabled) {
         if (pci_enabled) {
-            pci_vga_init(pci_bus, phys_ram_base + vga_ram_addr,
+            pci_vga_init(pci_bus, pci_bus_assign_dev_addr(pci_bus),
+                         phys_ram_base + vga_ram_addr,
                          vga_ram_addr, vga_ram_size, 0, 0);
         } else {
             isa_vga_init(phys_ram_base + vga_ram_addr,
@@ -1020,7 +1023,8 @@ vga_bios_error:
         if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
             pc_init_ne2k_isa(nd, i8259);
         else
-            pci_nic_init(pci_bus, nd, -1, "ne2k_pci");
+            pci_nic_init(pci_bus, nd, pci_bus_assign_dev_addr(pci_bus),
+                         "ne2k_pci");
     }
 
     qemu_system_hot_add_init();
@@ -1091,7 +1095,7 @@ vga_bios_error:
         max_bus = drive_get_max_bus(IF_SCSI);
 
        for (bus = 0; bus <= max_bus; bus++) {
-            scsi = lsi_scsi_init(pci_bus, -1);
+            scsi = lsi_scsi_init(pci_bus, pci_bus_assign_dev_addr(pci_bus));
             for (unit = 0; unit < LSI_MAX_DEVS; unit++) {
                index = drive_get_index(IF_SCSI, bus, unit);
                if (index == -1)
Index: trunk/hw/pc.h
===================================================================
--- trunk.orig/hw/pc.h
+++ trunk/hw/pc.h
@@ -146,7 +146,7 @@ extern enum vga_retrace_method vga_retra
 
 int isa_vga_init(uint8_t *vga_ram_base,
                  unsigned long vga_ram_offset, int vga_ram_size);
-int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+int pci_vga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
                  unsigned long vga_ram_offset, int vga_ram_size,
                  unsigned long vga_bios_offset, int vga_bios_size);
 int isa_vga_mm_init(uint8_t *vga_ram_base,
@@ -155,7 +155,7 @@ int isa_vga_mm_init(uint8_t *vga_ram_bas
                     int it_shift);
 
 /* cirrus_vga.c */
-void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_cirrus_vga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
                          ram_addr_t vga_ram_offset, int vga_ram_size);
 void isa_cirrus_vga_init(uint8_t *vga_ram_base,
                          ram_addr_t vga_ram_offset, int vga_ram_size);
Index: trunk/hw/pci.h
===================================================================
--- trunk.orig/hw/pci.h
+++ trunk/hw/pci.h
@@ -220,7 +220,7 @@ void lsi_scsi_attach(void *opaque, Block
 void *lsi_scsi_init(PCIBus *bus, int devfn);
 
 /* vmware_vga.c */
-void pci_vmsvga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_vmsvga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
                      unsigned long vga_ram_offset, int vga_ram_size);
 
 /* usb-uhci.c */
Index: trunk/hw/vga.c
===================================================================
--- trunk.orig/hw/vga.c
+++ trunk/hw/vga.c
@@ -2500,7 +2500,7 @@ static void pci_vga_write_config(PCIDevi
     vga_dirty_log_start(s);
 }
 
-int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
+int pci_vga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
                  unsigned long vga_ram_offset, int vga_ram_size,
                  unsigned long vga_bios_offset, int vga_bios_size)
 {
@@ -2510,7 +2510,7 @@ int pci_vga_init(PCIBus *bus, uint8_t *v
 
     d = (PCIVGAState *)pci_register_device(bus, "VGA",
                                            sizeof(PCIVGAState),
-                                           -1, NULL, pci_vga_write_config);
+                                           devfn, NULL, pci_vga_write_config);
     if (!d)
         return -1;
     s = &d->vga_state;
Index: trunk/hw/vmware_vga.c
===================================================================
--- trunk.orig/hw/vmware_vga.c
+++ trunk/hw/vmware_vga.c
@@ -1215,7 +1215,7 @@ static void pci_vmsvga_map_mem(PCIDevice
 
 #define PCI_CLASS_HEADERTYPE_00h       0x00
 
-void pci_vmsvga_init(PCIBus *bus, uint8_t *vga_ram_base,
+void pci_vmsvga_init(PCIBus *bus, int devfn, uint8_t *vga_ram_base,
                      unsigned long vga_ram_offset, int vga_ram_size)
 {
     struct pci_vmsvga_state_s *s;
@@ -1223,7 +1223,7 @@ void pci_vmsvga_init(PCIBus *bus, uint8_
     /* Setup PCI configuration */
     s = (struct pci_vmsvga_state_s *)
         pci_register_device(bus, "QEMUware SVGA",
-                sizeof(struct pci_vmsvga_state_s), -1, 0, 0);
+                sizeof(struct pci_vmsvga_state_s), devfn, 0, 0);
     pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
     pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
     s->card.config[PCI_COMMAND]                = 0x07;         /* I/O + Memory 
*/






reply via email to

[Prev in Thread] Current Thread [Next in Thread]