[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT tab
From: |
Shannon Zhao |
Subject: |
[Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT table and add a build_header function |
Date: |
Sat, 24 Jan 2015 17:21:13 +0800 |
XDST points to other tables except FACS & DSDT.
Implement a common header helper functions for generating ACPI tables.
Signed-off-by: Shannon Zhao <address@hidden>
---
hw/arm/virt-acpi-build.c | 34 ++++++++++++++++++++++++++++++++++
include/hw/acpi/acpi-defs.h | 9 +++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 9c3971a..446947a 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -61,6 +61,22 @@
#define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
#define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
+static void
+build_header(GArray *linker, GArray *table_data,
+ AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
+{
+ memcpy(&h->signature, sig, sizeof(h->signature));
+ h->length = cpu_to_le32(len);
+ h->revision = rev;
+ memcpy(h->oem_id, ACPI_VIRT_QEMU_STR_6, sizeof(h->oem_id));
+ memcpy(h->oem_table_id, ACPI_VIRT_MACH_STR_8, sizeof(h->oem_table_id));
+ h->oem_revision = cpu_to_le32(1);
+ h->checksum = 0;
+ /* Checksum to be filled in by Guest linker */
+ bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
+ table_data->data, h, len, &h->checksum);
+}
+
static inline void *acpi_data_push(GArray *table_data, uint64_t size)
{
unsigned off = table_data->len;
@@ -115,6 +131,24 @@ build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t
xsdt)
static void
build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
{
+ AcpiXsdtDescriptor *xsdt;
+ size_t xsdt_len;
+ int i;
+
+ xsdt_len = sizeof(*xsdt) + sizeof(uint64_t) * table_offsets->len;
+ xsdt = acpi_data_push(table_data, xsdt_len);
+ memcpy(xsdt->table_offset_entry, table_offsets->data,
+ sizeof(uint64_t) * table_offsets->len);
+ for (i = 0; i < table_offsets->len; ++i) {
+ /* rsdt->table_offset_entry to be filled by Guest linker */
+ bios_linker_loader_add_pointer(linker,
+ ACPI_BUILD_TABLE_FILE,
+ ACPI_BUILD_TABLE_FILE,
+ table_data,
&xsdt->table_offset_entry[i],
+ sizeof(uint64_t));
+ }
+ build_header(linker, table_data,
+ (void *)xsdt, "XSDT", xsdt_len, 1);
}
/* MADT */
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index c4468f8..779f872 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -88,6 +88,15 @@ struct AcpiTableHeader /* ACPI common table header */
typedef struct AcpiTableHeader AcpiTableHeader;
/*
+ * Extended System Description Table (XSDT)
+ */
+struct AcpiXsdtDescriptor {
+ ACPI_TABLE_HEADER_DEF
+ uint64_t table_offset_entry[1]; /* Array of pointers to ACPI tables */
+} QEMU_PACKED;
+typedef struct AcpiXsdtDescriptor AcpiXsdtDescriptor;
+
+/*
* ACPI 1.0 Fixed ACPI Description Table (FADT)
*/
struct AcpiFadtDescriptorRev1
--
1.7.1
- [Qemu-devel] [RFC PATCH 00/11] Generate ACPI v5.1 tables and expose it to guest over fw_cfg on ARM, Shannon Zhao, 2015/01/24
- [Qemu-devel] [RFC PATCH 06/11] hw/arm/virt-acpi-build: Generate GTDT table, Shannon Zhao, 2015/01/24
- [Qemu-devel] [RFC PATCH 09/11] hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and acpi_extended_irq(), Shannon Zhao, 2015/01/24
- [Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT table and add a build_header function,
Shannon Zhao <=
- [Qemu-devel] [RFC PATCH 10/11] hw/arm/virt-acpi-build: Generation of DSDT table for virt devices, Shannon Zhao, 2015/01/24
- [Qemu-devel] [RFC PATCH 08/11] hw/arm/virt-acpi-build: Generate FACS table and update ACPI headers, Shannon Zhao, 2015/01/24
- [Qemu-devel] [RFC PATCH 11/11] hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables, Shannon Zhao, 2015/01/24
- [Qemu-devel] [RFC PATCH 03/11] hw/arm/virt-acpi-build: Generate RSDP table, Shannon Zhao, 2015/01/24