Luna/kernel/src/acpi/RSDT.cpp

31 lines
818 B
C++
Raw Normal View History

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)
{
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
{
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;
}