Patchwork [52/61] pci: add a hook to replace default pci bus instead of 0 bus.

login
register
mail settings
Submitter Isaku Yamahata
Date Sept. 30, 2009, 10:18 a.m.
Message ID <1254305917-14784-53-git-send-email-yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/34597/
State Superseded
Headers show

Comments

Isaku Yamahata - Sept. 30, 2009, 10:18 a.m.
add a register function to replace default pci bus of 0.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/pci.c |   10 ++++++++++
 hw/pci.h |    1 +
 2 files changed, 11 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 7aed737..05cd2cb 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -343,6 +343,14 @@  int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
     return 0;
 }
 
+static PCIBus *pci_default_bus;
+
+void pci_set_default_bus(PCIBus *bus)
+{
+    assert(pci_default_bus == NULL);
+    pci_default_bus = bus;
+}
+
 static PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
 {
     int dom, bus;
@@ -350,6 +358,8 @@  static PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
 
     if (!devaddr) {
         *devfnp = -1;
+        if (pci_default_bus)
+            return pci_default_bus;
         return pci_find_bus(0);
     }
 
diff --git a/hw/pci.h b/hw/pci.h
index aed4a44..27a5d33 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -352,6 +352,7 @@  void pci_default_write_config(PCIDevice *d,
                               uint32_t address, uint32_t val, int len);
 void pci_device_save(PCIDevice *s, QEMUFile *f);
 int pci_device_load(PCIDevice *s, QEMUFile *f);
+void pci_set_default_bus(PCIBus *bus);
 
 typedef void (*pci_set_irq_fn)(void *opaque, int irq_num, int level);
 typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);