2022-09-05 16:13:51 +02:00
|
|
|
#include "acpi/RSDT.h"
|
|
|
|
#include "bootboot.h"
|
|
|
|
#include "std/stdio.h"
|
|
|
|
#include "std/string.h"
|
|
|
|
|
|
|
|
extern BOOTBOOT bootboot;
|
|
|
|
|
|
|
|
ACPI::SDTHeader* ACPI::GetRSDTOrXSDT()
|
|
|
|
{
|
|
|
|
return (SDTHeader*)bootboot.arch.x86_64.acpi_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* ACPI::FindTable(ACPI::SDTHeader* rootSDT, const char* signature)
|
|
|
|
{
|
2022-09-06 11:46:47 +02:00
|
|
|
bool isXSDT = (strncmp(rootSDT->Signature, "XSDT", 4) == 0);
|
|
|
|
int entries = (rootSDT->Length - sizeof(SDTHeader)) / (isXSDT ? 8 : 4);
|
2022-09-05 16:13:51 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < entries; i++)
|
|
|
|
{
|
|
|
|
SDTHeader* h;
|
|
|
|
if (isXSDT) h = (SDTHeader*)((XSDT*)rootSDT)->PointerToOtherSDT[i];
|
|
|
|
else
|
2022-09-06 11:46:47 +02:00
|
|
|
{
|
|
|
|
uint32_t entry = ((RSDT*)rootSDT)->PointerToOtherSDT[i];
|
|
|
|
h = (SDTHeader*)(uint64_t)entry;
|
|
|
|
}
|
2022-09-05 16:13:51 +02:00
|
|
|
if (strncmp(h->Signature, signature, 4) == 0) return (void*)h;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|