Merge branch 'acpi-rb' into 'master'

ACPI: fix Kernel Panic if available RAM follows XSDT

See merge request nakst/essence!7
This commit is contained in:
phcoder 2023-08-16 19:25:45 +00:00
commit 40b469d166
2 changed files with 11 additions and 4 deletions

View File

@ -150,15 +150,21 @@ void ACPIParseTables() {
bool isXSDT = false;
if (acpi.rsdp) {
uint64_t sdt_address;
if (acpi.rsdp->revision == 2 && acpi.rsdp->xsdtAddress) {
isXSDT = true;
sdt = (ACPIDescriptorTable *) acpi.rsdp->xsdtAddress;
sdt_address = acpi.rsdp->xsdtAddress;
} else {
isXSDT = false;
sdt = (ACPIDescriptorTable *) (uintptr_t) acpi.rsdp->rsdtAddress;
sdt_address = acpi.rsdp->rsdtAddress;
}
sdt = (ACPIDescriptorTable *) MMMapPhysical(kernelMMSpace, (uintptr_t) sdt, 16384, ES_FLAGS_DEFAULT);
ACPIDescriptorTable *tmp_sdt = (ACPIDescriptorTable *) MMMapPhysical(kernelMMSpace, sdt_address, sizeof(ACPIDescriptorTable), ES_FLAGS_DEFAULT);
uint32_t len_sdt = tmp_sdt->length < 16384 ? tmp_sdt->length : 16384;
MMFree(kernelMMSpace, tmp_sdt);
sdt = (ACPIDescriptorTable *) MMMapPhysical(kernelMMSpace, sdt_address, len_sdt, ES_FLAGS_DEFAULT);
} else {
KernelPanic("ACPIInitialise - Could not find supported root system descriptor pointer.\nACPI support is required.\n");
}

View File

@ -1325,7 +1325,8 @@ void *MMMapPhysical(MMSpace *space, uintptr_t offset, size_t bytes, uint64_t cac
uintptr_t offset2 = offset & (K_PAGE_SIZE - 1);
offset -= offset2;
if (offset2) bytes += K_PAGE_SIZE;
bytes += offset2;
bytes = (bytes + K_PAGE_SIZE - 1) & ~(K_PAGE_SIZE - 1);
MMRegion *region;