aboutsummaryrefslogtreecommitdiff
path: root/lib/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'lib/acpi')
-rw-r--r--lib/acpi/Makefile1
-rw-r--r--lib/acpi/acpi_table.c11
-rw-r--r--lib/acpi/acpi_writer.c22
3 files changed, 19 insertions, 15 deletions
diff --git a/lib/acpi/Makefile b/lib/acpi/Makefile
index f5d58aba908..1318e83dfc4 100644
--- a/lib/acpi/Makefile
+++ b/lib/acpi/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_$(SPL_)ACPIGEN) += acpigen.o
obj-$(CONFIG_$(SPL_)ACPIGEN) += acpi_device.o
obj-$(CONFIG_$(SPL_)ACPIGEN) += acpi_dp.o
obj-$(CONFIG_$(SPL_)ACPIGEN) += acpi_table.o
+obj-y += acpi_writer.o
diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
index 3a72718df89..284b5a9afb8 100644
--- a/lib/acpi/acpi_table.c
+++ b/lib/acpi/acpi_table.c
@@ -253,15 +253,8 @@ static void acpi_write_xsdt(struct acpi_xsdt *xsdt)
sizeof(struct acpi_xsdt));
}
-void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start)
+void acpi_setup_base_tables(struct acpi_ctx *ctx)
{
- ctx->base = start;
- ctx->current = start;
-
- /* Align ACPI tables to 16 byte */
- acpi_align(ctx);
- gd_set_acpi_start(map_to_sysmem(ctx->current));
-
/* We need at least an RSDP and an RSDT Table */
ctx->rsdp = ctx->current;
acpi_inc_align(ctx, sizeof(struct acpi_rsdp));
@@ -271,7 +264,7 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start)
acpi_inc_align(ctx, sizeof(struct acpi_xsdt));
/* clear all table memory */
- memset((void *)start, '\0', ctx->current - start);
+ memset(ctx->base, '\0', ctx->current - ctx->base);
acpi_write_rsdp(ctx->rsdp, ctx->rsdt, ctx->xsdt);
acpi_write_rsdt(ctx->rsdt);
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);
+}