ACPI::get_rsdt_or_xsdt(): Use a temporary variable to do mappings, then set cache to it.

This commit is contained in:
apio 2022-10-08 15:05:59 +02:00
parent a5daa24fbf
commit 159d025d9f

View File

@ -19,19 +19,20 @@ ACPI::SDTHeader* ACPI::get_rsdt_or_xsdt()
void* physical = (void*)bootboot.arch.x86_64.acpi_ptr;
kdbgln("RSDT/XSDT physical address: %lx", (uint64_t)physical);
cache = (SDTHeader*)MemoryManager::get_unaligned_mapping(physical);
SDTHeader* rsdt = (SDTHeader*)MemoryManager::get_unaligned_mapping(physical);
uint64_t offset = (uint64_t)physical % PAGE_SIZE;
uint64_t rsdt_pages = Utilities::get_blocks_from_size(PAGE_SIZE, (offset + cache->Length));
uint64_t rsdt_pages = Utilities::get_blocks_from_size(PAGE_SIZE, (offset + rsdt->Length));
if (rsdt_pages > 1)
{
MemoryManager::release_unaligned_mapping(cache);
cache = (SDTHeader*)MemoryManager::get_unaligned_mappings(cache, rsdt_pages);
MemoryManager::release_unaligned_mapping(rsdt);
rsdt = (SDTHeader*)MemoryManager::get_unaligned_mappings(cache, rsdt_pages);
}
kdbgln("Mapped RSDT/XSDT to virtual address %lx, uses %ld pages", (uint64_t)cache, rsdt_pages);
return cache;
kdbgln("Mapped RSDT/XSDT to virtual address %lx, uses %ld pages", (uint64_t)rsdt, rsdt_pages);
cache = rsdt;
return rsdt;
}
bool ACPI::validate_rsdt_or_xsdt(ACPI::SDTHeader* root_sdt)