sp1: acpi: Add ACPI table query function
Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
Reference in New Issue
Block a user