diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-03-16 08:34:13 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-03-16 08:34:13 +0100 |
| commit | 64bf7fcf58ced023be1701ed4508e38f746d40b8 (patch) | |
| tree | 023637c060d169e5a72576f62c9bd616b8b5b937 /arch/x86_64/kapi | |
| parent | 1e23bfc850f0ca126bff3c56c86419ab1570c96e (diff) | |
| download | teachos-64bf7fcf58ced023be1701ed4508e38f746d40b8.tar.xz teachos-64bf7fcf58ced023be1701ed4508e38f746d40b8.zip | |
kernel/memory: implement basic free-list heap
Diffstat (limited to 'arch/x86_64/kapi')
| -rw-r--r-- | arch/x86_64/kapi/memory.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/x86_64/kapi/memory.cpp b/arch/x86_64/kapi/memory.cpp index 48aab9f..e704408 100644 --- a/arch/x86_64/kapi/memory.cpp +++ b/arch/x86_64/kapi/memory.cpp @@ -189,7 +189,7 @@ namespace kapi::memory auto mbi_size = boot::bootstrap_information.mbi->size_bytes(); auto mbi_address = physical_address{mbi_base & ~std::bit_cast<std::uintptr_t>(&arch::boot::TEACHOS_VMA)}; auto mbi_start = frame::containing(mbi_address); - auto mbi_end = frame::containing(physical_address{mbi_address.raw() + mbi_size}) + 1; + auto mbi_end = frame::containing(mbi_address + mbi_size) + 1; std::ranges::for_each(std::views::iota(mbi_start, mbi_end), [&](auto frame) { new_allocator.mark_used(frame); }); } @@ -211,7 +211,10 @@ namespace kapi::memory region_based_allocator.emplace(collect_memory_information()); allocation_buffer.emplace(&*region_based_allocator); - recursive_page_mapper.emplace(*allocation_buffer); + set_frame_allocator(*allocation_buffer); + + recursive_page_mapper.emplace(); + set_page_mapper(*recursive_page_mapper); kstd::println("[x86_64:MEM] Preparing new paging hierarchy."); @@ -227,9 +230,6 @@ namespace kapi::memory cr3.frame(new_pml4_frame); arch::cpu::cr3::write(cr3); - set_frame_allocator(*allocation_buffer); - set_page_mapper(*recursive_page_mapper); - auto memory_map = boot::bootstrap_information.mbi->memory_map(); auto highest_byte = std::ranges::max(std::views::transform( std::views::filter(memory_map.regions(), |
