Fix FindTable method to work properly with RSDT instead of XSDT

This commit is contained in:
apio 2022-09-06 11:46:47 +02:00
parent f7f8c1068a
commit 5b132e3197

View File

@ -12,18 +12,18 @@ ACPI::SDTHeader* ACPI::GetRSDTOrXSDT()
void* ACPI::FindTable(ACPI::SDTHeader* rootSDT, const char* signature)
{
bool isXSDT = strncmp(rootSDT->Signature, "XSDT", 4);
int entries = (rootSDT->Length - sizeof(SDTHeader)) / isXSDT ? 8 : 4;
printf("%d entries in root SDT\n", entries);
bool isXSDT = (strncmp(rootSDT->Signature, "XSDT", 4) == 0);
int entries = (rootSDT->Length - sizeof(SDTHeader)) / (isXSDT ? 8 : 4);
for (int i = 0; i < entries; i++)
{
printf("Trying this entry\n");
SDTHeader* h;
if (isXSDT) h = (SDTHeader*)((XSDT*)rootSDT)->PointerToOtherSDT[i];
else
h = (SDTHeader*)(uint64_t)((RSDT*)rootSDT)->PointerToOtherSDT[i];
{
uint32_t entry = ((RSDT*)rootSDT)->PointerToOtherSDT[i];
h = (SDTHeader*)(uint64_t)entry;
}
if (strncmp(h->Signature, signature, 4) == 0) return (void*)h;
}