[PATCH 4/6] riscv: qemu: copy ACPI tables from QEMU

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Wed Nov 15 15:23:53 CET 2023


If CONFIG_GENERATE_ACPI_TABLES=y, read the ACPI tables provided by QEMU
and make them available to U-Boot.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 board/emulation/qemu-riscv/qemu-riscv.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c
index 181abbbf97..2cebce2128 100644
--- a/board/emulation/qemu-riscv/qemu-riscv.c
+++ b/board/emulation/qemu-riscv/qemu-riscv.c
@@ -4,17 +4,20 @@
  */
 
 #include <common.h>
+#include <acpi/acpi_table.h>
 #include <dm.h>
 #include <dm/ofnode.h>
 #include <env.h>
 #include <fdtdec.h>
 #include <image.h>
 #include <log.h>
+#include <malloc.h>
 #include <spl.h>
 #include <init.h>
 #include <usb.h>
 #include <virtio_types.h>
 #include <virtio.h>
+#include <linux/sizes.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -46,6 +49,20 @@ int board_late_init(void)
 	if (CONFIG_IS_ENABLED(USB_KEYBOARD))
 		usb_init();
 
+	if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
+		uintptr_t addr;
+		void *ptr;
+
+		/* Reserve 64K for ACPI tables, aligned to a 4K boundary */
+		ptr = memalign(SZ_4K, SZ_64K);
+		addr = (uintptr_t)ptr;
+
+		/* Generate ACPI tables */
+		write_acpi_tables(addr);
+		gd->arch.table_start = addr;
+		gd->arch.table_end = addr;
+	}
+
 	return 0;
 }
 
-- 
2.40.1



More information about the U-Boot mailing list