Kernel: Cleanup RSDP parsing code

This commit is contained in:
Bananymous 2023-03-07 00:41:13 +02:00
parent 06db890d49
commit 8a52c0f9d7
1 changed files with 6 additions and 4 deletions

View File

@ -157,7 +157,6 @@ static bool is_valid_std_header(const SDTHeader* header)
uintptr_t locate_madt(uintptr_t rsdp_addr)
{
uintptr_t entry_address_base = 0;
uintptr_t entry_address_mask = 0;
ptrdiff_t entry_pointer_size = 0;
uint32_t entry_count = 0;
@ -167,7 +166,6 @@ uintptr_t locate_madt(uintptr_t rsdp_addr)
uintptr_t xsdt_addr = rsdp->v2_xsdt_address;
MMU::get().allocate_page(xsdt_addr, MMU::Flags::ReadWrite | MMU::Flags::Present);
entry_address_base = xsdt_addr + sizeof(SDTHeader);
entry_address_mask = (uintptr_t)0xFFFFFFFFFFFFFFFF;
entry_count = (((const SDTHeader*)xsdt_addr)->length - sizeof(SDTHeader)) / 8;
entry_pointer_size = 8;
MMU::get().unallocate_page(xsdt_addr);
@ -177,7 +175,6 @@ uintptr_t locate_madt(uintptr_t rsdp_addr)
uintptr_t rsdt_addr = rsdp->rsdt_address;
MMU::get().allocate_page(rsdt_addr, MMU::Flags::ReadWrite | MMU::Flags::Present);
entry_address_base = rsdt_addr + sizeof(SDTHeader);
entry_address_mask = 0xFFFFFFFF;
entry_count = (((const SDTHeader*)rsdt_addr)->length - sizeof(SDTHeader)) / 4;
entry_pointer_size = 4;
MMU::get().unallocate_page(rsdt_addr);
@ -188,7 +185,12 @@ uintptr_t locate_madt(uintptr_t rsdp_addr)
uintptr_t entry_addr_ptr = entry_address_base + i * entry_pointer_size;
MMU::get().allocate_page(entry_addr_ptr, MMU::Flags::ReadWrite | MMU::Flags::Present);
uintptr_t entry_addr = *(uintptr_t*)entry_addr_ptr & entry_address_mask;
uintptr_t entry_addr;
if (entry_pointer_size == 4)
entry_addr = *(uint32_t*)entry_addr_ptr;
else
entry_addr = *(uint64_t*)entry_addr_ptr;
MMU::get().allocate_page(entry_addr, MMU::Flags::ReadWrite | MMU::Flags::Present);
BAN::ScopeGuard _([&]() {