From 29b351122ed23124f70473a411c65074d5a61146 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 26 Apr 2020 09:19:50 -0600 Subject: 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 Reviewed-by: Wolfgang Wallner --- test/dm/acpi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 59aee1f614..99ae321e0a 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -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" -- cgit v1.2.3