aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-07 21:32:14 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-07-17 14:32:24 +0800
commit91c2f9c32ed76269b9786a6c506233e9b91bdfce (patch)
tree14de5d060315332b66350acf58885c6aa14d608b /test
parent70303d24809599e14f97f8ef08364ac6589410f4 (diff)
downloadu-boot-91c2f9c32ed76269b9786a6c506233e9b91bdfce.zip
u-boot-91c2f9c32ed76269b9786a6c506233e9b91bdfce.tar.gz
u-boot-91c2f9c32ed76269b9786a6c506233e9b91bdfce.tar.bz2
acpi: Support generation of a device
Allow writing an ACPI device to the generated ACPI code. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> [bmeng: Fix build failures on Sandbox] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/dm/acpigen.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/dm/acpigen.c b/test/dm/acpigen.c
index 822641a..cea1a62 100644
--- a/test/dm/acpigen.c
+++ b/test/dm/acpigen.c
@@ -993,3 +993,30 @@ static int dm_test_acpi_resource_template(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_acpi_resource_template, 0);
+
+/* Test writing a device */
+static int dm_test_acpi_device(struct unit_test_state *uts)
+{
+ struct acpi_ctx *ctx;
+ u8 *ptr;
+
+ ut_assertok(alloc_context(&ctx));
+ ptr = acpigen_get_current(ctx);
+
+ acpigen_write_device(ctx, "\\_SB." ACPI_TEST_DEV_NAME);
+ acpigen_pop_len(ctx);
+
+ ut_asserteq(EXT_OP_PREFIX, *ptr++);
+ ut_asserteq(DEVICE_OP, *ptr++);
+ ut_asserteq(0xd, acpi_test_get_length(ptr));
+ ptr += 3;
+ ut_asserteq(ROOT_PREFIX, *ptr++);
+ ut_asserteq(DUAL_NAME_PREFIX, *ptr++);
+ ptr += 8;
+ ut_asserteq_ptr(ptr, ctx->current);
+
+ free_context(&ctx);
+
+ return 0;
+}
+DM_TEST(dm_test_acpi_device, 0);