Skip to contentSkip to conversation

hw/arm/virt-acpi: Generate FACS and FADT, update ACPI headers

RFC PATCH In review Alexander Spyridakis 1 participant 1 message Oct 31, 2014

lore
Share & tools
lore
#0 lore raw

RFC PATCH 4/7 hw/arm/virt-acpi: Generate FACS and FADT, update ACPI headers

FADT points to FACS and DSDT and additionally, in the case of mach virt, it is also used to set the Hardware Reduced bit and enable PSCI SMP booting through HVC. For FACS the table is created as a mockup, as with the Hardware Reduced bit set it will not be used.

Update the header definitions for FADT and FACS taking into account the new additions of ACPI v5.1 in include/hw/acpi/acpi-defs.h

---
 hw/arm/virt-acpi.c          |  41 +++++++++++--
 include/hw/acpi/acpi-defs.h | 141 ++++++++++++++++++++++++++++++--------------
 2 files changed, 134 insertions(+), 48 deletions(-)
hw/arm/virt-acpi.c +37 -4
index 0d7bb99..aca0434 100644
@@ -133,14 +133,47 @@ static void acpi_create_gtdt(const struct acpi_gtdt_info *irqs)
 
 static void acpi_create_fadt(void)
 {
-    acpi_table[FADT] = NULL;
-    acpi_size[FADT] = 0;
+    AcpiFacpDescriptorRev5_1 *fadt;
+    hwaddr facs_offset;
+    int i;
+
+    fadt = g_malloc0(sizeof(*fadt));
+    acpi_fill_common_header_data(fadt, "FACP", 5, sizeof(*fadt));
+
+    /* Hardware Reduced = 1 and use PSCI 0.2+ and with HVC */
+    fadt->flags = cpu_to_le32(1 << ACPI_FADT_F_HW_REDUCED_ACPI);
+    fadt->arm_boot_flags = cpu_to_le16((1 << ACPI_FADT_ARM_USE_PSCI_G_0_2) |
+                                       (1 << ACPI_FADT_ARM_PSCI_USE_HVC));
+
+    /* ACPI v5.1 (fadt->revision.fadt->minor_revision) */
+    fadt->minor_revision = 0x1;
+
+    acpi_size[FADT] = fadt->length;
+
+    /* Calculate FACS and DSDT table offsets */
+    for (i = RSDP, facs_offset = 0; i < FACS; ++i) {
+        facs_offset += acpi_size[i];
+    }
+    fadt->Xfacs = cpu_to_le64(ACPI_BASE_ADDRESS + facs_offset);
+    fadt->Xdsdt = cpu_to_le64(fadt->Xfacs + acpi_size[FACS]);
+
+    acpi_do_checksum(fadt, fadt->length, &fadt->checksum);
+
+    acpi_table[FADT] = (void *)fadt;
 }
 
 static void acpi_create_facs(void)
 {
-    acpi_table[FACS] = NULL;
-    acpi_size[FACS] = 0;
+    AcpiFacsDescriptorRev5_1 *facs;
+
+    facs = g_malloc0(sizeof(*facs));
+
+    memcpy(&facs->signature, "FACS", sizeof(facs->signature));
+    facs->length = cpu_to_le32(sizeof(*facs));
+    facs->version = 0x02;
+
+    acpi_table[FACS] = (void *)facs;
+    acpi_size[FACS] = facs->length;
 }
 
 static void acpi_create_dsdt(int smp_cpus, const struct acpi_dsdt_info *info)
include/hw/acpi/acpi-defs.h +97 -44

169 lines not on this page · raw message

Signature · 1 line
1.9.1