[SeaBIOS] [PATCH v4 4/5] acpi: load and link tables through romfile loader

Michael S. Tsirkin mst at redhat.com
Mon Sep 23 20:20:34 CEST 2013


Load files through romfile loader and use for acpi tables.
We need the RSDP pointer to hang the rest of the tables off it,
to detect that we simply scan all memory in FSEG.

Add an option to disable this feature (useful for old QEMU versions).
This saves about 1Kbytes.

enabled:
Total size: 134932  Fixed: 61571  Free: 127212 (used 51.5% of 256KiB rom)

disabled:
Total size: 133836  Fixed: 61563  Free: 128308 (used 51.1% of 256KiB rom)

Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
---
 src/fw/acpi.c | 27 +++++++++++++++++++++++++++
 src/Kconfig   | 10 ++++++++++
 2 files changed, 37 insertions(+)

diff --git a/src/fw/acpi.c b/src/fw/acpi.c
index 0497d9b..0fb8007 100644
--- a/src/fw/acpi.c
+++ b/src/fw/acpi.c
@@ -32,6 +32,7 @@
 #include "string.h" // memset
 #include "util.h" // MaxCountCPUs
 #include "x86.h" // readl
+#include "romfile_loader.h" // romfile_loader_execute
 
 #include "src/fw/acpi-dsdt.hex"
 
@@ -606,6 +607,14 @@ static const struct pci_device_id acpi_find_tbl[] = {
 
 struct rsdp_descriptor *RsdpAddr;
 
+/* Look for RSDP signature in FSEG memory */
+struct rsdp_descriptor *
+acpi_find_rsdp_rom(void)
+{
+    u64 rsdp = cpu_to_le64(RSDP_SIGNATURE);
+    return malloc_find_fseg_pattern(&rsdp, sizeof(rsdp));
+}
+
 #define MAX_ACPI_TABLES 20
 void
 acpi_setup(void)
@@ -615,6 +624,24 @@ acpi_setup(void)
 
     dprintf(3, "init ACPI tables\n");
 
+    if (CONFIG_ACPI_ROMFILE_LOAD) {
+        int loader_err = romfile_loader_execute("etc/table-loader");
+
+        RsdpAddr = acpi_find_rsdp_rom();
+
+        if (RsdpAddr)
+            return;
+
+        /* If present, loader should have installed an RSDP.
+         * Not installed? We might still be able to continue
+         * using the builtin RSDP.
+         */
+        if (!loader_err)
+            warn_internalerror();
+    }
+
+    dprintf(3, "generate ACPI tables\n");
+
     // This code is hardcoded for PIIX4 Power Management device.
     struct pci_device *pci = pci_find_init_device(acpi_find_tbl, NULL);
     if (!pci)
diff --git a/src/Kconfig b/src/Kconfig
index c40cc61..b5f0d39 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -414,6 +414,16 @@ menu "BIOS Tables"
         default y
         help
             Support generation of ACPI tables.
+    config ACPI_ROMFILE_LOAD
+        bool "Load ACPI tables from ROM files"
+        default y
+        depends on ACPI
+        help
+            Support loading ACPI tables from ROM files.
+            Required for QEMU 1.7 and newer.
+            This option can be disabled for QEMU 1.6 and older
+            to save some space in the ROM file.
+            If unsure, say Y.
     config ACPI_DSDT
         bool "Include default ACPI DSDT"
         default y
-- 
MST




More information about the SeaBIOS mailing list