From 98a2dd01d33a5e3b5d8b399e9818431f7a68d0ed Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 20 Apr 2026 17:21:50 -0400 Subject: [PATCH] sp1: acpi: Add ACPI table query function Signed-off-by: Ian Moffett --- usr/src/sp1/common/io/acpi/acpi_init.c | 22 ++++++++++++++++++++++ usr/src/sp1/head/io/acpi/acpi.h | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/usr/src/sp1/common/io/acpi/acpi_init.c b/usr/src/sp1/common/io/acpi/acpi_init.c index 90fc15b..f1b1ff1 100644 --- a/usr/src/sp1/common/io/acpi/acpi_init.c +++ b/usr/src/sp1/common/io/acpi/acpi_init.c @@ -15,6 +15,7 @@ #include #include #include +#include #define pr_trace(fmt, ...) \ printf("acpi: " fmt, ##__VA_ARGS__) @@ -53,6 +54,27 @@ rsdp_verify(void) } } +void * +acpi_query(const char *signature) +{ + struct acpi_header *hdr; + uintptr_t pma; + + if (signature == NULL) { + return NULL; + } + + for (size_t i = 0; i < root_sdt_entries; ++i) { + pma = (uintptr_t)root_sdt->tables[i]; + hdr = (struct acpi_header *)pma_to_vma(pma); + if (memcmp(hdr->signature, signature, sizeof(hdr->signature)) == 0) { + return (void *)hdr; + } + } + + return NULL; +} + void acpi_init(void) { diff --git a/usr/src/sp1/head/io/acpi/acpi.h b/usr/src/sp1/head/io/acpi/acpi.h index 03fecc0..c84a4c7 100644 --- a/usr/src/sp1/head/io/acpi/acpi.h +++ b/usr/src/sp1/head/io/acpi/acpi.h @@ -17,4 +17,14 @@ */ void acpi_init(void); +/* + * Query an ACPI table through its signature + * + * @signature: Signature to lookup + * + * Returns the virtual table base on success, otherwise + * NULL on failure. + */ +void *acpi_query(const char *signature); + #endif /* !_ACPI_ACPI_H_ */