
From: Simon Glass <sjg@chromium.org> At present acpi_find_table() support locating most of the tables, but not these two, since they are the pointers to the rest. When adding new tables, these tables need to be located and updated, so update acpi_find_table() to allow searching for them. Signed-off-by: Simon Glass <sjg@chromium.org> --- lib/acpi/acpi.c | 10 ++++++++++ test/dm/acpi.c | 3 +++ 2 files changed, 13 insertions(+) diff --git a/lib/acpi/acpi.c b/lib/acpi/acpi.c index dc327dc08c7..44ea5136de4 100644 --- a/lib/acpi/acpi.c +++ b/lib/acpi/acpi.c @@ -121,6 +121,11 @@ struct acpi_table_header *acpi_find_table(const char *sig) return NULL; count = ret; + if (!strcmp("RSDT", sig)) + return &rsdt->header; + if (!strcmp("XSDT", sig)) + return &xsdt->header; + for (i = 0; i < count; i++) { struct acpi_table_header *hdr; @@ -204,6 +209,11 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) struct acpi_rsdt *rsdt; struct acpi_xsdt *xsdt; + if (!ctx->rsdt && !ctx->xsdt) { + log_err("ACPI: Error: no RSDT / XSDT\n"); + return -EINVAL; + } + /* On legacy x86 platforms the RSDT is mandatory while the XSDT is not. * On other platforms there might be no memory below 4GiB, thus RSDT is NULL. */ diff --git a/test/dm/acpi.c b/test/dm/acpi.c index d38a13e7f84..bb37e7da88f 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -809,6 +809,9 @@ static int dm_test_acpi_find_table(struct unit_test_state *uts) ut_asserteq_ptr(table3, table); ut_asserteq_strn("TST3", table->signature); + table = acpi_find_table("RSDT"); + ut_asserteq_ptr(nomap_sysmem(rsdt, 0), table); + /* Find with XSDT only */ rsdp->rsdt_address = 0; acpi_udpate_rsdp_checksum(rsdp); -- 2.43.0