[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 04/23] hw: acpi: Implement XSDT support for RSDP
From: |
Samuel Ortiz |
Subject: |
[Qemu-devel] [PATCH v4 04/23] hw: acpi: Implement XSDT support for RSDP |
Date: |
Thu, 1 Nov 2018 11:22:44 +0100 |
XSDT is the 64-bit version of the legacy ACPI RSDT (Root System
Description Table). RSDT only allow for 32-bit addressses and have thus
been deprecated. Since ACPI version 2.0, RSDPs should point at XSDTs and
no longer RSDTs, although RSDTs are still supported for backward
compatibility.
Since version 2.0, RSDPs should add an extended checksum, a complete table
length and a version field to the table.
Here we provide a legacy API (RSDP points at RSDTs) for backward
compatibility purpose and a default, XSDT pointing API.
Signed-off-by: Samuel Ortiz <address@hidden>
---
hw/acpi/aml-build.c | 41 ++++++++++++++++++++++++++++++++++++-
hw/i386/acpi-build.c | 2 +-
include/hw/acpi/aml-build.h | 5 ++++-
3 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 2d6f538f9d..77eb17b113 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1651,8 +1651,10 @@ build_xsdt(GArray *table_data, BIOSLinker *linker,
GArray *table_offsets,
(void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id);
}
+/* Legacy RSDP pointing at an RSDT. This is deprecated */
void
-build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offset)
+build_rsdp_rsdt(GArray *rsdp_table,
+ BIOSLinker *linker, unsigned rsdt_tbl_offset)
{
AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
unsigned rsdt_pa_size = sizeof(rsdp->rsdt_physical_address);
@@ -1675,6 +1677,43 @@ build_rsdp(GArray *rsdp_table, BIOSLinker *linker,
unsigned rsdt_tbl_offset)
(char *)&rsdp->checksum - rsdp_table->data);
}
+/* RSDP pointing at an XSDT */
+void
+build_rsdp(GArray *rsdp_table,
+ BIOSLinker *linker, unsigned xsdt_tbl_offset)
+{
+ AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp);
+ unsigned xsdt_pa_size = sizeof(rsdp->xsdt_physical_address);
+ unsigned xsdt_pa_offset =
+ (char *)&rsdp->xsdt_physical_address - rsdp_table->data;
+ unsigned xsdt_offset =
+ (char *)&rsdp->length - rsdp_table->data;
+
+ bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, rsdp_table, 16,
+ true /* fseg memory */);
+
+ memcpy(&rsdp->signature, "RSD PTR ", 8);
+ memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, 6);
+ rsdp->length = cpu_to_le32(sizeof(*rsdp));
+ /* version 2, we will use the XSDT pointer */
+ rsdp->revision = 0x02;
+
+ /* Address to be filled by Guest linker */
+ bios_linker_loader_add_pointer(linker,
+ ACPI_BUILD_RSDP_FILE, xsdt_pa_offset, xsdt_pa_size,
+ ACPI_BUILD_TABLE_FILE, xsdt_tbl_offset);
+
+ /* Legacy checksum to be filled by Guest linker */
+ bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE,
+ (char *)rsdp - rsdp_table->data, xsdt_offset,
+ (char *)&rsdp->checksum - rsdp_table->data);
+
+ /* Extended checksum to be filled by Guest linker */
+ bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE,
+ (char *)rsdp - rsdp_table->data, sizeof *rsdp,
+ (char *)&rsdp->extended_checksum - rsdp_table->data);
+}
+
void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
uint64_t len, int node, MemoryAffinityFlags flags)
{
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index d7b47e05b5..cfc2444d0d 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2657,7 +2657,7 @@ void acpi_build(AcpiBuildTables *tables,
slic_oem.id, slic_oem.table_id);
/* RSDP is in FSEG memory, so allocate it separately */
- build_rsdp(tables->rsdp, tables->linker, rsdt);
+ build_rsdp_rsdt(tables->rsdp, tables->linker, rsdt);
/* We'll expose it all to Guest so we want to reduce
* chance of size changes.
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index c9bcb32d81..a2ef8b6f31 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -390,8 +390,11 @@ void acpi_add_table(GArray *table_offsets, GArray
*table_data);
void acpi_build_tables_init(AcpiBuildTables *tables);
void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre);
void
+build_rsdp_rsdt(GArray *table_data,
+ BIOSLinker *linker, unsigned rsdt_tbl_offset);
+void
build_rsdp(GArray *table_data,
- BIOSLinker *linker, unsigned rsdt_tbl_offset);
+ BIOSLinker *linker, unsigned xsdt_tbl_offset);
void
build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
const char *oem_id, const char *oem_table_id);
--
2.19.1
- [Qemu-devel] [PATCH v4 00/23] ACPI reorganization for hardware-reduced support, Samuel Ortiz, 2018/11/01
- [Qemu-devel] [PATCH v4 01/23] hw: i386: Decouple the ACPI build from the PC machine type, Samuel Ortiz, 2018/11/01
- [Qemu-devel] [PATCH v4 04/23] hw: acpi: Implement XSDT support for RSDP,
Samuel Ortiz <=
- [Qemu-devel] [PATCH v4 05/23] hw: arm: Switch to the AML build RSDP building routine, Samuel Ortiz, 2018/11/01
- [Qemu-devel] [PATCH v4 11/23] hw: acpi: Export the MCFG getter, Samuel Ortiz, 2018/11/01
- [Qemu-devel] [PATCH v4 08/23] hw: i386: Move PCI host definitions to pci_host.h, Samuel Ortiz, 2018/11/01
- [Qemu-devel] [PATCH v4 12/23] hw: acpi: Do not create hotplug method when handler is not defined, Samuel Ortiz, 2018/11/01
- [Qemu-devel] [PATCH v4 13/23] hw: i386: Make the hotpluggable memory size property more generic, Samuel Ortiz, 2018/11/01
- [Qemu-devel] [PATCH v4 09/23] hw: acpi: Export the PCI host and holes getters, Samuel Ortiz, 2018/11/01
- [Qemu-devel] [PATCH v4 10/23] hw: acpi: Export and generalize the PCI host AML API, Samuel Ortiz, 2018/11/01