[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 41/47] pc: acpi-build: create PCI0._CRS dynamical
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH v2 41/47] pc: acpi-build: create PCI0._CRS dynamically |
Date: |
Thu, 22 Jan 2015 14:50:25 +0000 |
Replace template patching and runtime
calculation in _CRS() method with static _CRS
defined in SSDT.
It also drops manual hole patching for reserved
PCI/MEM/CPU hoptlug MMIO resources and utilizes
the fact that MMIO resources are reserved by
respective child /i.e. PHPR, MHPD, PRES/ containers.
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/i386/acpi-build.c | 71 ++++++++++++++++-----------------
hw/i386/acpi-dsdt-pci-crs.dsl | 92 -------------------------------------------
hw/i386/acpi-dsdt.dsl | 45 ---------------------
hw/i386/q35-acpi-dsdt.dsl | 18 ---------
hw/i386/ssdt-misc.dsl | 19 ---------
5 files changed, 34 insertions(+), 211 deletions(-)
delete mode 100644 hw/i386/acpi-dsdt-pci-crs.dsl
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a09bf28..4572c21 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -319,24 +319,6 @@ static void acpi_align_size(GArray *blob, unsigned align)
g_array_set_size(blob, ROUND_UP(acpi_data_len(blob), align));
}
-/* Set a value within table in a safe manner */
-#define ACPI_BUILD_SET_LE(table, size, off, bits, val) \
- do { \
- uint64_t ACPI_BUILD_SET_LE_val = cpu_to_le64(val); \
- memcpy(acpi_data_get_ptr(table, size, off, \
- (bits) / BITS_PER_BYTE), \
- &ACPI_BUILD_SET_LE_val, \
- (bits) / BITS_PER_BYTE); \
- } while (0)
-
-static inline void *acpi_data_get_ptr(uint8_t *table_data, unsigned table_size,
- unsigned off, unsigned size)
-{
- assert(off + size > off);
- assert(off + size <= table_size);
- return table_data + off;
-}
-
static inline void acpi_add_table(GArray *table_offsets, GArray *table_data)
{
uint32_t offset = cpu_to_le32(table_data->len);
@@ -665,22 +647,6 @@ static void build_append_pci_bus_devices(AcpiAml
*parent_scope, PCIBus *bus,
aml_append(parent_scope, method);
}
-static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size)
-{
- ACPI_BUILD_SET_LE(start, size, acpi_pci32_start[0], 32, pci->w32.begin);
-
- ACPI_BUILD_SET_LE(start, size, acpi_pci32_end[0], 32, pci->w32.end - 1);
-
- if (pci->w64.end || pci->w64.begin) {
- ACPI_BUILD_SET_LE(start, size, acpi_pci64_valid[0], 8, 1);
- ACPI_BUILD_SET_LE(start, size, acpi_pci64_start[0], 64,
pci->w64.begin);
- ACPI_BUILD_SET_LE(start, size, acpi_pci64_end[0], 64, pci->w64.end -
1);
- ACPI_BUILD_SET_LE(start, size, acpi_pci64_length[0], 64, pci->w64.end
- pci->w64.begin);
- } else {
- ACPI_BUILD_SET_LE(start, size, acpi_pci64_valid[0], 8, 0);
- }
-}
-
static void
build_ssdt(GArray *table_data, GArray *linker,
AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -700,13 +666,44 @@ build_ssdt(GArray *table_data, GArray *linker,
QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256);
g_assert(acpi_cpus <= ACPI_CPU_HOTPLUG_ID_LIMIT);
- /* Copy header and ssdt template and patch values */
+ /* Copy SSDT header */
ssdt_ptr = acpi_data_push(table_data, sizeof(ssdp_misc_aml));
memcpy(ssdt_ptr, ssdp_misc_aml, sizeof(ssdp_misc_aml));
- patch_pci_windows(pci, ssdt_ptr, sizeof(ssdp_misc_aml));
-
scope = acpi_scope("\\_SB.PCI0");
+ /* build PCI0._CRS */
+ crs = acpi_resource_template();
+ aml_append(&crs,
+ acpi_word_bus_number(acpi_min_fixed, acpi_max_fixed, acpi_pos_decode,
+ 0x0000, 0x0000, 0x00FF, 0x0000, 0x0100));
+ aml_append(&crs, acpi_io(acpi_decode16, 0x0CF8, 0x0CF8, 0x01, 0x08));
+
+ aml_append(&crs,
+ acpi_word_io(acpi_min_fixed, acpi_max_fixed,
+ acpi_pos_decode, acpi_entire_range,
+ 0x0000, 0x0000, 0x0CF7, 0x0000, 0x0CF8));
+ aml_append(&crs,
+ acpi_word_io(acpi_min_fixed, acpi_max_fixed,
+ acpi_pos_decode, acpi_entire_range,
+ 0x0000, 0x0D00, 0xFFFF, 0x0000, 0xF300));
+ aml_append(&crs,
+ acpi_dword_memory(acpi_pos_decode, acpi_min_fixed, acpi_max_fixed,
+ acpi_cacheable, acpi_ReadWrite,
+ 0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
+ aml_append(&crs,
+ acpi_dword_memory(acpi_pos_decode, acpi_min_fixed, acpi_max_fixed,
+ acpi_non_cacheable, acpi_ReadWrite,
+ 0, pci->w32.begin, pci->w32.end - 1, 0,
+ pci->w32.end - pci->w32.begin));
+ if (pci->w64.begin) {
+ aml_append(&crs,
+ acpi_qword_memory(acpi_pos_decode, acpi_min_fixed, acpi_max_fixed,
+ acpi_cacheable, acpi_ReadWrite,
+ 0, pci->w64.begin, pci->w64.end - 1, 0,
+ pci->w64.end - pci->w64.begin));
+ }
+ aml_append(&scope, acpi_name_decl("_CRS", crs));
+
/* reserve PCIHP resources */
if (pm->pcihp_io_len) {
dev = acpi_device("PHPR");
diff --git a/hw/i386/acpi-dsdt-pci-crs.dsl b/hw/i386/acpi-dsdt-pci-crs.dsl
deleted file mode 100644
index 4648e90..0000000
--- a/hw/i386/acpi-dsdt-pci-crs.dsl
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-/* PCI CRS (current resources) definition. */
-Scope(\_SB.PCI0) {
-
- Name(CRES, ResourceTemplate() {
- WordBusNumber(ResourceProducer, MinFixed, MaxFixed, PosDecode,
- 0x0000, // Address Space Granularity
- 0x0000, // Address Range Minimum
- 0x00FF, // Address Range Maximum
- 0x0000, // Address Translation Offset
- 0x0100, // Address Length
- ,, )
- IO(Decode16,
- 0x0CF8, // Address Range Minimum
- 0x0CF8, // Address Range Maximum
- 0x01, // Address Alignment
- 0x08, // Address Length
- )
- BOARD_SPECIFIC_PCI_RESOURSES
- DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
Cacheable, ReadWrite,
- 0x00000000, // Address Space Granularity
- 0x000A0000, // Address Range Minimum
- 0x000BFFFF, // Address Range Maximum
- 0x00000000, // Address Translation Offset
- 0x00020000, // Address Length
- ,, , AddressRangeMemory, TypeStatic)
- DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
NonCacheable, ReadWrite,
- 0x00000000, // Address Space Granularity
- 0xE0000000, // Address Range Minimum
- 0xFEBFFFFF, // Address Range Maximum
- 0x00000000, // Address Translation Offset
- 0x1EC00000, // Address Length
- ,, PW32, AddressRangeMemory, TypeStatic)
- })
-
- Name(CR64, ResourceTemplate() {
- QWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
Cacheable, ReadWrite,
- 0x00000000, // Address Space Granularity
- 0x8000000000, // Address Range Minimum
- 0xFFFFFFFFFF, // Address Range Maximum
- 0x00000000, // Address Translation Offset
- 0x8000000000, // Address Length
- ,, PW64, AddressRangeMemory, TypeStatic)
- })
-
- Method(_CRS, 0) {
- /* Fields provided by dynamically created ssdt */
- External(P0S, IntObj)
- External(P0E, IntObj)
- External(P1V, IntObj)
- External(P1S, BuffObj)
- External(P1E, BuffObj)
- External(P1L, BuffObj)
-
- /* fixup 32bit pci io window */
- CreateDWordField(CRES, \_SB.PCI0.PW32._MIN, PS32)
- CreateDWordField(CRES, \_SB.PCI0.PW32._MAX, PE32)
- CreateDWordField(CRES, \_SB.PCI0.PW32._LEN, PL32)
- Store(P0S, PS32)
- Store(P0E, PE32)
- Store(Add(Subtract(P0E, P0S), 1), PL32)
-
- If (LEqual(P1V, Zero)) {
- Return (CRES)
- }
-
- /* fixup 64bit pci io window */
- CreateQWordField(CR64, \_SB.PCI0.PW64._MIN, PS64)
- CreateQWordField(CR64, \_SB.PCI0.PW64._MAX, PE64)
- CreateQWordField(CR64, \_SB.PCI0.PW64._LEN, PL64)
- Store(P1S, PS64)
- Store(P1E, PE64)
- Store(P1L, PL64)
- /* add window and return result */
- ConcatenateResTemplate(CRES, CR64, Local0)
- Return (Local0)
- }
-}
diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
index a611e07..09b68f0 100644
--- a/hw/i386/acpi-dsdt.dsl
+++ b/hw/i386/acpi-dsdt.dsl
@@ -31,50 +31,6 @@ DefinitionBlock (
#include "acpi-dsdt-dbug.dsl"
-
-/****************************************************************
- * PCI Bus definition
- ****************************************************************/
-#define BOARD_SPECIFIC_PCI_RESOURSES \
- WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
- 0x0000, \
- 0x0000, \
- 0x0CF7, \
- 0x0000, \
- 0x0CF8, \
- ,, , TypeStatic) \
- WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
- 0x0000, \
- 0x0D00, \
- 0xADFF, \
- 0x0000, \
- 0xA100, \
- ,, , TypeStatic) \
- /* 0xae00-0xae0e hole for PCI hotplug, hw/acpi/piix4.c:PCI_HOTPLUG_ADDR
*/ \
- WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
- 0x0000, \
- 0xAE0F, \
- 0xAEFF, \
- 0x0000, \
- 0x00F1, \
- ,, , TypeStatic) \
- /* 0xaf00-0xaf1f hole for CPU hotplug, hw/acpi/piix4.c:PIIX4_PROC_BASE */
\
- WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
- 0x0000, \
- 0xAF20, \
- 0xAFDF, \
- 0x0000, \
- 0x00C0, \
- ,, , TypeStatic) \
- /* 0xafe0-0xafe3 hole for ACPI.GPE0, hw/acpi/piix4.c:GPE_BASE */ \
- WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
- 0x0000, \
- 0xAFE4, \
- 0xFFFF, \
- 0x0000, \
- 0x501C, \
- ,, , TypeStatic)
-
Scope(\_SB) {
Device(PCI0) {
Name(_HID, EisaId("PNP0A03"))
@@ -85,7 +41,6 @@ DefinitionBlock (
}
}
-#include "acpi-dsdt-pci-crs.dsl"
#include "acpi-dsdt-hpet.dsl"
diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
index e1cee5d..3fb4b2f 100644
--- a/hw/i386/q35-acpi-dsdt.dsl
+++ b/hw/i386/q35-acpi-dsdt.dsl
@@ -48,23 +48,6 @@ DefinitionBlock (
/****************************************************************
* PCI Bus definition
****************************************************************/
-#define BOARD_SPECIFIC_PCI_RESOURSES \
- WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
- 0x0000, \
- 0x0000, \
- 0x0CD7, \
- 0x0000, \
- 0x0CD8, \
- ,, , TypeStatic) \
- /* 0xcd8-0xcf7 hole for CPU hotplug, hw/acpi/ich9.c:ICH9_PROC_BASE */ \
- WordIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, \
- 0x0000, \
- 0x0D00, \
- 0xFFFF, \
- 0x0000, \
- 0xF300, \
- ,, , TypeStatic)
-
Scope(\_SB) {
Device(PCI0) {
Name(_HID, EisaId("PNP0A08"))
@@ -131,7 +114,6 @@ DefinitionBlock (
}
}
-#include "acpi-dsdt-pci-crs.dsl"
#include "acpi-dsdt-hpet.dsl"
diff --git a/hw/i386/ssdt-misc.dsl b/hw/i386/ssdt-misc.dsl
index 2588e30..8d61f21 100644
--- a/hw/i386/ssdt-misc.dsl
+++ b/hw/i386/ssdt-misc.dsl
@@ -18,23 +18,4 @@ ACPI_EXTRACT_ALL_CODE ssdp_misc_aml
DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1)
{
-
-/****************************************************************
- * PCI memory ranges
- ****************************************************************/
-
- Scope(\) {
- ACPI_EXTRACT_NAME_DWORD_CONST acpi_pci32_start
- Name(P0S, 0x12345678)
- ACPI_EXTRACT_NAME_DWORD_CONST acpi_pci32_end
- Name(P0E, 0x12345678)
- ACPI_EXTRACT_NAME_BYTE_CONST acpi_pci64_valid
- Name(P1V, 0x12)
- ACPI_EXTRACT_NAME_BUFFER8 acpi_pci64_start
- Name(P1S, Buffer() { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 })
- ACPI_EXTRACT_NAME_BUFFER8 acpi_pci64_end
- Name(P1E, Buffer() { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 })
- ACPI_EXTRACT_NAME_BUFFER8 acpi_pci64_length
- Name(P1L, Buffer() { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 })
- }
}
--
1.8.3.1
- [Qemu-devel] [PATCH v2 33/47] pc: acpi-build: drop template patching and CPU hotplug objects dynamically, (continued)
- [Qemu-devel] [PATCH v2 33/47] pc: acpi-build: drop template patching and CPU hotplug objects dynamically, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 36/47] pc: acpi-build: drop template patching and memory hotplug objects dynamically, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 32/47] acpi: add acpi_eisaid() term, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 34/47] pc: acpi-build: create CPU hotplug IO region dynamically, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 37/47] pc: acpi-build: create memory hotplug IO region dynamically, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 30/47] acpi: add acpi_equal() term, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 38/47] acpi: add acpi_word_bus_number(), acpi_word_io(), acpi_dword_memory(), acpi_qword_memory() terms, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 39/47] pc: pcihp: expose MMIO base and len as properties, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 42/47] acpi: add acpi_def_block() term, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 40/47] pc: acpi-build: reserve PCIHP MMIO resources, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 41/47] pc: acpi-build: create PCI0._CRS dynamically,
Igor Mammedov <=
- [Qemu-devel] [PATCH v2 44/47] pc: acpi-build: drop remaining ssdt_misc template and use acpi_def_block(), Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 45/47] acpi: add acpi_iqr_no_flags() term, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 46/47] pc: export applesmc IO port/len, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 43/47] pc: acpi-build: prepare to make ACPI tables blob opaque for table building functions, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 47/47] pc: acpi-build: drop template patching and create Device(SMC) dynamically, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 17/47] acpi: add acpi_package() term, Igor Mammedov, 2015/01/22
- [Qemu-devel] [PATCH v2 06/47] acpi: add acpi_name() & acpi_name_decl() term, Igor Mammedov, 2015/01/22