Hi Simon, -----"Simon Glass" <s...@chromium.org> schrieb: -----
>Betreff: [PATCH v5 27/29] acpi: Put table-setup code in its own >function > >We always write three basic tables to ACPI at the start. Move this >into >its own function, along with acpi_fill_header(), so we can write a >test >for this code. > >Signed-off-by: Simon Glass <s...@chromium.org> >--- > >Changes in v5: None >Changes in v4: >- Put back cast on table_compute_checksum() > >Changes in v3: >- Fix 'XDST' typo >- Move acpi_align_large() out of dm_test_acpi_setup_base_tables() >- Beef up the comment explaining how the unaligned address is used > >Changes in v2: None > > arch/x86/lib/acpi_table.c | 72 +----------------------------------- > include/acpi/acpi_table.h | 10 +++++ > lib/acpi/acpi_table.c | 77 >+++++++++++++++++++++++++++++++++++++++ > test/dm/acpi.c | 58 ++++++++++++++++++++++++++++- > 4 files changed, 144 insertions(+), 73 deletions(-) [snip] >diff --git a/test/dm/acpi.c b/test/dm/acpi.c >index ffc611efb82..beb1b6da737 100644 >--- a/test/dm/acpi.c >+++ b/test/dm/acpi.c [snip] >+/* Test acpi_setup_base_tables */ >+static int dm_test_acpi_setup_base_tables(struct unit_test_state >*uts) >+{ >+ struct acpi_rsdp *rsdp; >+ struct acpi_rsdt *rsdt; >+ struct acpi_xsdt *xsdt; >+ struct acpi_ctx ctx; >+ void *buf, *end; >+ >+ /* >+ * Use an unaligned address deliberately, by allocating an aligned >+ * address and then adding 4 to it >+ */ >+ buf = memalign(64, BUF_SIZE); >+ ut_assertnonnull(buf); >+ acpi_setup_base_tables(&ctx, buf + 4); >+ >+ rsdp = buf + 16; >+ ut_asserteq_ptr(rsdp, ctx.rsdp); >+ ut_assertok(memcmp(RSDP_SIG, rsdp->signature, >sizeof(rsdp->signature))); Nit: could we also use ut_assertmem_eq() here? Similar to patch 22. >+ ut_asserteq(sizeof(*rsdp), rsdp->length); >+ ut_assertok(table_compute_checksum(rsdp, 20)); >+ ut_assertok(table_compute_checksum(rsdp, sizeof(*rsdp))); >+ >+ rsdt = PTR_ALIGN((void *)rsdp + sizeof(*rsdp), 16); >+ ut_asserteq_ptr(rsdt, ctx.rsdt); >+ ut_assertok(memcmp("RSDT", rsdt->header.signature, ACPI_NAME_LEN)); same here >+ ut_asserteq(sizeof(*rsdt), rsdt->header.length); >+ ut_assertok(table_compute_checksum(rsdt, sizeof(*rsdt))); >+ >+ xsdt = PTR_ALIGN((void *)rsdt + sizeof(*rsdt), 16); >+ ut_assertok(memcmp("XSDT", xsdt->header.signature, ACPI_NAME_LEN)); and here >+ ut_asserteq(sizeof(*xsdt), xsdt->header.length); >+ ut_assertok(table_compute_checksum(xsdt, sizeof(*xsdt))); >+ >+ end = PTR_ALIGN((void *)xsdt + sizeof(*xsdt), 64); >+ ut_asserteq_ptr(end, ctx.current); >+ >+ ut_asserteq(map_to_sysmem(rsdt), rsdp->rsdt_address); >+ ut_asserteq(map_to_sysmem(xsdt), rsdp->xsdt_address); >+ >+ return 0; >+} >+DM_TEST(dm_test_acpi_setup_base_tables, >+ DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); >-- >2.26.0.292.g33ef6b2f38-goog > Reviewed-by: Wolfgang Wallner <wolfgang.wall...@br-automation.com>