aboutsummaryrefslogtreecommitdiff
path: root/test/dm/acpigen.c
diff options
context:
space:
mode:
authorSimon Glass2020-07-07 21:32:10 -0600
committerBin Meng2020-07-17 14:32:24 +0800
commit82659cc91014df7dfcc55474c1657d1c9b6fe957 (patch)
tree6f265db5df0bbbb26f89bf67f383aa95e555ae93 /test/dm/acpigen.c
parentfea9651084e72fe94aefa0b828854ef5ce2835b4 (diff)
acpi: Support generation of a scope
Add a function to write a scope to the generated ACPI code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: Fix build failures on Sandbox] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'test/dm/acpigen.c')
-rw-r--r--test/dm/acpigen.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/dm/acpigen.c b/test/dm/acpigen.c
index f25be938a47..46792d8e89f 100644
--- a/test/dm/acpigen.c
+++ b/test/dm/acpigen.c
@@ -916,3 +916,34 @@ static int dm_test_acpi_write_values(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_acpi_write_values, 0);
+
+/* Test writing a scope */
+static int dm_test_acpi_scope(struct unit_test_state *uts)
+{
+ char buf[ACPI_PATH_MAX];
+ struct acpi_ctx *ctx;
+ struct udevice *dev;
+ u8 *ptr;
+
+ ut_assertok(alloc_context(&ctx));
+ ptr = acpigen_get_current(ctx);
+
+ ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev));
+ ut_assertok(acpi_device_path(dev, buf, sizeof(buf)));
+ acpigen_write_scope(ctx, buf);
+ acpigen_pop_len(ctx);
+
+ ut_asserteq(SCOPE_OP, *ptr++);
+ ut_asserteq(13, acpi_test_get_length(ptr));
+ ptr += 3;
+ ut_asserteq(ROOT_PREFIX, *ptr++);
+ ut_asserteq(DUAL_NAME_PREFIX, *ptr++);
+ ut_asserteq_strn("_SB_" ACPI_TEST_DEV_NAME, (char *)ptr);
+ ptr += 8;
+ ut_asserteq_ptr(ptr, ctx->current);
+
+ free_context(&ctx);
+
+ return 0;
+}
+DM_TEST(dm_test_acpi_scope, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);