aboutsummaryrefslogtreecommitdiff
path: root/hw/pci/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/pci/pci.c')
-rw-r--r--hw/pci/pci.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index b386777..7e5f8d0 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -120,6 +120,27 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
vmstate_register(NULL, -1, &vmstate_pcibus, bus);
}
+static void pcie_bus_realize(BusState *qbus, Error **errp)
+{
+ PCIBus *bus = PCI_BUS(qbus);
+
+ pci_bus_realize(qbus, errp);
+
+ /*
+ * A PCI-E bus can support extended config space if it's the root
+ * bus, or if the bus/bridge above it does as well
+ */
+ if (pci_bus_is_root(bus)) {
+ bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
+ } else {
+ PCIBus *parent_bus = pci_get_bus(bus->parent_dev);
+
+ if (pci_bus_allows_extended_config_space(parent_bus)) {
+ bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;
+ }
+ }
+}
+
static void pci_bus_unrealize(BusState *qbus, Error **errp)
{
PCIBus *bus = PCI_BUS(qbus);
@@ -142,11 +163,6 @@ static uint16_t pcibus_numa_node(PCIBus *bus)
return NUMA_NODE_UNASSIGNED;
}
-static bool pcibus_allows_extended_config_space(PCIBus *bus)
-{
- return false;
-}
-
static void pci_bus_class_init(ObjectClass *klass, void *data)
{
BusClass *k = BUS_CLASS(klass);
@@ -161,7 +177,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
pbc->bus_num = pcibus_num;
pbc->numa_node = pcibus_numa_node;
- pbc->allows_extended_config_space = pcibus_allows_extended_config_space;
}
static const TypeInfo pci_bus_info = {
@@ -182,16 +197,11 @@ static const TypeInfo conventional_pci_interface_info = {
.parent = TYPE_INTERFACE,
};
-static bool pciebus_allows_extended_config_space(PCIBus *bus)
-{
- return true;
-}
-
static void pcie_bus_class_init(ObjectClass *klass, void *data)
{
- PCIBusClass *pbc = PCI_BUS_CLASS(klass);
+ BusClass *k = BUS_CLASS(klass);
- pbc->allows_extended_config_space = pciebus_allows_extended_config_space;
+ k->realize = pcie_bus_realize;
}
static const TypeInfo pcie_bus_info = {
@@ -410,11 +420,6 @@ bool pci_bus_is_express(PCIBus *bus)
return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS);
}
-bool pci_bus_allows_extended_config_space(PCIBus *bus)
-{
- return PCI_BUS_GET_CLASS(bus)->allows_extended_config_space(bus);
-}
-
void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
const char *name,
MemoryRegion *address_space_mem,