summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-12-01 19:03:00 +0300
committerSimon Glass <sjg@chromium.org>2022-01-25 21:44:36 +0300
commit85b8161b141070e5c7515edb38424ea48f023d04 (patch)
tree0b8fa73e06dc3a3b6e2de7d39b16784a841363fe /lib
parentef55f48788100212db7cd19eb9c8a347e630ffe8 (diff)
downloadu-boot-85b8161b141070e5c7515edb38424ea48f023d04.tar.xz
x86: Move CSRT table to a writer function
Move this table over to use a writer function, moving the code from the x86 implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/acpi/Makefile1
-rw-r--r--lib/acpi/csrt.c50
2 files changed, 51 insertions, 0 deletions
diff --git a/lib/acpi/Makefile b/lib/acpi/Makefile
index 552d499fde..f9b504988f 100644
--- a/lib/acpi/Makefile
+++ b/lib/acpi/Makefile
@@ -10,6 +10,7 @@ obj-y += acpi_writer.o
# With QEMU the ACPI tables come from there, not from U-Boot
ifndef CONFIG_QEMU
obj-y += base.o
+obj-y += csrt.o
# Sandbox does not build a .asl file
ifndef CONFIG_SANDBOX
diff --git a/lib/acpi/csrt.c b/lib/acpi/csrt.c
new file mode 100644
index 0000000000..7606931841
--- /dev/null
+++ b/lib/acpi/csrt.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Write an ACPI Core System Resource Table (CSRT)
+ *
+ * Copyright 2021 Google LLC
+ */
+
+#define LOG_CATEGORY LOGC_ACPI
+
+#include <common.h>
+#include <mapmem.h>
+#include <tables_csum.h>
+#include <acpi/acpi_table.h>
+#include <dm/acpi.h>
+
+__weak u32 acpi_fill_csrt(u32 current)
+{
+ return 0;
+}
+
+int acpi_write_csrt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
+{
+ struct acpi_table_header *header;
+ struct acpi_csrt *csrt;
+ uint ptr;
+
+ csrt = ctx->current;
+ header = &csrt->header;
+
+ memset(csrt, '\0', sizeof(struct acpi_csrt));
+
+ /* Fill out header fields */
+ acpi_fill_header(header, "CSRT");
+ header->length = sizeof(struct acpi_csrt);
+ header->revision = 0;
+
+ ptr = acpi_fill_csrt(map_to_sysmem(csrt));
+ if (!ptr)
+ return log_msg_ret("fill", -ENOENT);
+
+ /* (Re)calculate length and checksum */
+ header->length = (ulong)ctx->current - (ulong)csrt;
+ header->checksum = table_compute_checksum(csrt, header->length);
+
+ acpi_add_table(ctx, csrt);
+ acpi_inc(ctx, csrt->header.length);
+
+ return 0;
+}
+ACPI_WRITER(5csrt, "CSRT", acpi_write_csrt, 0);