aboutsummaryrefslogtreecommitdiff
path: root/test/dm
diff options
context:
space:
mode:
authorSimon Glass2020-04-26 09:19:50 -0600
committerBin Meng2020-04-30 17:16:12 +0800
commit29b351122ed23124f70473a411c65074d5a61146 (patch)
tree3291b96b1660fcc0fad1db917def8f2f14768370 /test/dm
parent288edc78213433526e42cbc7c3dabca4fdf8e671 (diff)
acpi: Move acpi_add_table() to generic code
Move this code to a generic location so that we can test it with sandbox. This requires adding a few new fields to acpi_ctx, so drop the local variables used in the original code. Also use mapmem to avoid pointer-to-address casts which don't work on sandbox. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Diffstat (limited to 'test/dm')
-rw-r--r--test/dm/acpi.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index 59aee1f6146..99ae321e0a2 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <dm.h>
+#include <mapmem.h>
#include <version.h>
#include <acpi/acpi_table.h>
#include <dm/acpi.h>
@@ -21,10 +22,14 @@ static int testacpi_write_tables(const struct udevice *dev,
struct acpi_ctx *ctx)
{
struct acpi_dmar *dmar;
+ int ret;
dmar = (struct acpi_dmar *)ctx->current;
acpi_create_dmar(dmar, DMAR_INTR_REMAP);
ctx->current += sizeof(struct acpi_dmar);
+ ret = acpi_add_table(ctx, dmar);
+ if (ret)
+ return log_msg_ret("add", ret);
return 0;
}
@@ -127,6 +132,7 @@ DM_TEST(dm_test_acpi_fill_header, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
static int dm_test_acpi_write_tables(struct unit_test_state *uts)
{
struct acpi_dmar *dmar;
+ struct acpi_xsdt *xsdt;
struct acpi_ctx ctx;
void *buf;
@@ -134,8 +140,16 @@ static int dm_test_acpi_write_tables(struct unit_test_state *uts)
ut_assertnonnull(buf);
ctx.current = buf;
+ ctx.rsdp = ctx.current;
+ acpi_inc_align(&ctx, sizeof(struct acpi_rsdp));
+ ctx.rsdt = ctx.current;
+ acpi_inc_align(&ctx, sizeof(struct acpi_rsdt));
+ xsdt = ctx.current;
+ acpi_inc_align(&ctx, sizeof(struct acpi_xsdt));
+ ctx.rsdp->xsdt_address = map_to_sysmem(xsdt);
+ dmar = ctx.current;
+
ut_assertok(acpi_write_dev_tables(&ctx));
- dmar = buf;
/*
* We should have two dmar tables, one for each "denx,u-boot-acpi-test"