summaryrefslogtreecommitdiff
path: root/lib/acpi/acpi_writer.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-12-01 09:02:48 -0700
committerSimon Glass <sjg@chromium.org>2022-01-25 11:44:36 -0700
commitcc1f8c39882c5100ec07dfa46e32ff395d792b94 (patch)
tree2f5a32f096aec41a5082f8727269fae8688eaaa0 /lib/acpi/acpi_writer.c
parent6afa63a5a63662fa7e517b29da613f51e9e68429 (diff)
x86: acpi: Split out context creation from base tables
At present acpi_setup_base_tables() both sets up the ACPI context and writes out the base tables. We want to use an ACPI writer to write the base tables, so split this function into two, with acpi_setup_ctx() doing the context set, and acpi_setup_base_tables() just doing the base tables. Disable the writer's write_acpi_tables() function for now, to avoid build errors. It is enabled in a following patch. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/acpi/acpi_writer.c')
-rw-r--r--lib/acpi/acpi_writer.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/acpi/acpi_writer.c b/lib/acpi/acpi_writer.c
index 5ddffc87343..7779bf38aab 100644
--- a/lib/acpi/acpi_writer.c
+++ b/lib/acpi/acpi_writer.c
@@ -60,23 +60,20 @@ static int acpi_write_all(struct acpi_ctx *ctx)
/*
* QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
*/
-ulong write_acpi_tables(ulong start_addr)
+ulong new_write_acpi_tables(ulong start_addr)
{
struct acpi_ctx *ctx;
ulong addr;
- void *start;
int ret;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = malloc(sizeof(*ctx));
if (!ctx)
return log_msg_ret("mem", -ENOMEM);
- gd->acpi_ctx = ctx;
-
- start = map_sysmem(start_addr, 0);
log_debug("ACPI: Writing ACPI tables at %lx\n", start_addr);
acpi_reset_items();
+ acpi_setup_ctx(ctx, start_addr);
ret = acpi_write_all(ctx);
if (ret) {
@@ -89,3 +86,16 @@ ulong write_acpi_tables(ulong start_addr)
return addr;
}
+
+void acpi_setup_ctx(struct acpi_ctx *ctx, ulong start)
+{
+ gd->acpi_ctx = ctx;
+ memset(ctx, '\0', sizeof(*ctx));
+
+ /* Align ACPI tables to 16-byte boundary */
+ start = ALIGN(start, 16);
+ ctx->base = map_sysmem(start, 0);
+ ctx->current = ctx->base;
+
+ gd_set_acpi_start(start);
+}