[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/28] hw/acpi: add _CRS method for extra root busses
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 14/28] hw/acpi: add _CRS method for extra root busses |
Date: |
Thu, 4 Jun 2015 13:10:54 +0200 |
From: Marcel Apfelbaum <address@hidden>
Save the IO/mem/bus numbers ranges assigned to the extra root busses
to be removed from the root bus 0 range.
Signed-off-by: Marcel Apfelbaum <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Acked-by: Laszlo Ersek <address@hidden>
---
hw/i386/acpi-build.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 139 insertions(+)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 451566f..8b1e6b1 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -697,6 +697,137 @@ static Aml *build_prt(void)
return method;
}
+typedef struct CrsRangeEntry {
+ uint64_t base;
+ uint64_t limit;
+} CrsRangeEntry;
+
+static void crs_range_insert(GPtrArray *ranges, uint64_t base, uint64_t limit)
+{
+ CrsRangeEntry *entry;
+
+ entry = g_malloc(sizeof(*entry));
+ entry->base = base;
+ entry->limit = limit;
+
+ g_ptr_array_add(ranges, entry);
+}
+
+static void crs_range_free(gpointer data)
+{
+ CrsRangeEntry *entry = (CrsRangeEntry *)data;
+ g_free(entry);
+}
+
+static Aml *build_crs(PCIHostState *host,
+ GPtrArray *io_ranges, GPtrArray *mem_ranges)
+{
+ Aml *crs = aml_resource_template();
+ uint8_t max_bus = pci_bus_num(host->bus);
+ uint8_t type;
+ int devfn;
+
+ for (devfn = 0; devfn < ARRAY_SIZE(host->bus->devices); devfn++) {
+ int i;
+ uint64_t range_base, range_limit;
+ PCIDevice *dev = host->bus->devices[devfn];
+
+ if (!dev) {
+ continue;
+ }
+
+ for (i = 0; i < PCI_NUM_REGIONS; i++) {
+ PCIIORegion *r = &dev->io_regions[i];
+
+ range_base = r->addr;
+ range_limit = r->addr + r->size - 1;
+
+ if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
+ aml_append(crs,
+ aml_word_io(aml_min_fixed, aml_max_fixed,
+ aml_pos_decode, aml_entire_range,
+ 0,
+ range_base,
+ range_limit,
+ 0,
+ range_limit - range_base + 1));
+ crs_range_insert(io_ranges, range_base, range_limit);
+ } else { /* "memory" */
+ aml_append(crs,
+ aml_dword_memory(aml_pos_decode, aml_min_fixed,
+ aml_max_fixed, aml_non_cacheable,
+ aml_ReadWrite,
+ 0,
+ range_base,
+ range_limit,
+ 0,
+ range_limit - range_base + 1));
+ crs_range_insert(mem_ranges, range_base, range_limit);
+ }
+ }
+
+ type = dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
+ if (type == PCI_HEADER_TYPE_BRIDGE) {
+ uint8_t subordinate = dev->config[PCI_SUBORDINATE_BUS];
+ if (subordinate > max_bus) {
+ max_bus = subordinate;
+ }
+
+ range_base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_IO);
+ range_limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_IO);
+ aml_append(crs,
+ aml_word_io(aml_min_fixed, aml_max_fixed,
+ aml_pos_decode, aml_entire_range,
+ 0,
+ range_base,
+ range_limit,
+ 0,
+ range_limit - range_base + 1));
+ crs_range_insert(io_ranges, range_base, range_limit);
+
+ range_base =
+ pci_bridge_get_base(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
+ range_limit =
+ pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY);
+ aml_append(crs,
+ aml_dword_memory(aml_pos_decode, aml_min_fixed,
+ aml_max_fixed, aml_non_cacheable,
+ aml_ReadWrite,
+ 0,
+ range_base,
+ range_limit,
+ 0,
+ range_limit - range_base + 1));
+ crs_range_insert(mem_ranges, range_base, range_limit);
+
+ range_base =
+ pci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
+ range_limit =
+ pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_MEM_PREFETCH);
+ aml_append(crs,
+ aml_dword_memory(aml_pos_decode, aml_min_fixed,
+ aml_max_fixed, aml_non_cacheable,
+ aml_ReadWrite,
+ 0,
+ range_base,
+ range_limit,
+ 0,
+ range_limit - range_base + 1));
+ crs_range_insert(mem_ranges, range_base, range_limit);
+ }
+ }
+
+ aml_append(crs,
+ aml_word_bus_number(aml_min_fixed, aml_max_fixed, aml_pos_decode,
+ 0,
+ pci_bus_num(host->bus),
+ max_bus,
+ 0,
+ max_bus - pci_bus_num(host->bus) + 1));
+
+ return crs;
+}
+
static void
build_ssdt(GArray *table_data, GArray *linker,
AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -707,6 +838,8 @@ build_ssdt(GArray *table_data, GArray *linker,
unsigned acpi_cpus = guest_info->apic_id_limit;
Aml *ssdt, *sb_scope, *scope, *pkg, *dev, *method, *crs, *field, *ifctx;
PCIBus *bus = NULL;
+ GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+ GPtrArray *mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
int i;
ssdt = init_aml_allocator();
@@ -736,9 +869,15 @@ build_ssdt(GArray *table_data, GArray *linker,
aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A03")));
aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num)));
aml_append(dev, build_prt());
+ crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent),
+ io_ranges, mem_ranges);
+ aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
aml_append(ssdt, scope);
}
+
+ g_ptr_array_free(io_ranges, true);
+ g_ptr_array_free(mem_ranges, true);
}
scope = aml_scope("\\_SB.PCI0");
--
MST
- [Qemu-devel] [PULL 04/28] TPM: fix build with tpm disabled, (continued)
- [Qemu-devel] [PULL 04/28] TPM: fix build with tpm disabled, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 05/28] virtio: 64bit features fixups., Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 06/28] acpi: add acpi_send_gpe_event() to rise sci for hotplug, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 07/28] acpi: add implementation of aml_while() term, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 08/28] hw/pci: made pci_bus_is_root a PCIBusClass method, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 09/28] hw/pci: made pci_bus_num a PCIBusClass method, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 10/28] hw/i386: query only for q35/pc when looking for pci host bridge, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 11/28] hw/pci: extend PCI config access to support devices behind PXB, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 12/28] hw/acpi: add support for i440fx 'snooping' root busses, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 13/28] hw/apci: add _PRT method for extra PCI root busses, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 14/28] hw/acpi: add _CRS method for extra root busses,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 15/28] hw/acpi: remove from root bus 0 the crs resources used by other buses., Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 16/28] hw/pci: removed 'rootbus nr is 0' assumption from qmp_pci_query, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 17/28] hw/pci: introduce PCI Expander Bridge (PXB), Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 18/28] hw/pci: inform bios if the system has extra pci root buses, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 19/28] hw/pxb: add map_irq func, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 20/28] hw/pci: add support for NUMA nodes, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 21/28] hw/pxb: add numa_node parameter, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 22/28] apci: fix PXB behaviour if used with unsupported BIOS, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 24/28] pc-dimm: don't assert if pc-dimm alignment != hotpluggable mem range size, Michael S. Tsirkin, 2015/06/04
- [Qemu-devel] [PULL 23/28] docs: Add PXB documentation, Michael S. Tsirkin, 2015/06/04