sp1: acpi: Add ACPI table query function

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-04-20 17:21:50 -04:00
parent 21816ed9be
commit 98a2dd01d3
2 changed files with 32 additions and 0 deletions
+22
View File
@@ -15,6 +15,7 @@
#include <os/knot.h>
#include <os/bpt.h>
#include <mm/vm.h>
#include <string.h>
#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)
{
+10
View File
@@ -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_ */