aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-03-16 08:34:13 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-03-16 08:34:13 +0100
commit64bf7fcf58ced023be1701ed4508e38f746d40b8 (patch)
tree023637c060d169e5a72576f62c9bd616b8b5b937 /arch/x86_64/src
parent1e23bfc850f0ca126bff3c56c86419ab1570c96e (diff)
downloadteachos-64bf7fcf58ced023be1701ed4508e38f746d40b8.tar.xz
teachos-64bf7fcf58ced023be1701ed4508e38f746d40b8.zip
kernel/memory: implement basic free-list heap
Diffstat (limited to 'arch/x86_64/src')
-rw-r--r--arch/x86_64/src/memory/recursive_page_mapper.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/arch/x86_64/src/memory/recursive_page_mapper.cpp b/arch/x86_64/src/memory/recursive_page_mapper.cpp
index d8273e1..c7c5341 100644
--- a/arch/x86_64/src/memory/recursive_page_mapper.cpp
+++ b/arch/x86_64/src/memory/recursive_page_mapper.cpp
@@ -56,18 +56,17 @@ namespace arch::memory
} // namespace
- recursive_page_mapper::recursive_page_mapper(kapi::memory::frame_allocator & allocator)
- : m_allocator{&allocator}
- {}
+ recursive_page_mapper::recursive_page_mapper() {}
auto recursive_page_mapper::map(kapi::memory::page page, kapi::memory::frame frame, flags flags) -> std::byte *
{
auto pml4 = static_cast<recursive_page_table<4> *>((paging_root::get()));
+ auto & allocator = kapi::memory::get_frame_allocator();
return std::optional{pml4}
- .and_then([&](auto pml) -> auto { return do_map(pml, page, *m_allocator, flags); })
- .and_then([&](auto pml) -> auto { return do_map(pml, page, *m_allocator, flags); })
- .and_then([&](auto pml) -> auto { return do_map(pml, page, *m_allocator, flags); })
+ .and_then([&](auto pml) -> auto { return do_map(pml, page, allocator, flags); })
+ .and_then([&](auto pml) -> auto { return do_map(pml, page, allocator, flags); })
+ .and_then([&](auto pml) -> auto { return do_map(pml, page, allocator, flags); })
.and_then([&](auto pml) -> auto { return do_map(pml, page, frame, flags); })
.value_or(nullptr);
}
@@ -91,27 +90,28 @@ namespace arch::memory
auto pml3 = pml4->next(pml_index<4>(page)).value();
auto pml2 = pml3->next(pml_index<3>(page)).value();
auto pml1 = pml2->next(pml_index<2>(page)).value();
+ auto & allocator = kapi::memory::get_frame_allocator();
(*pml1)[pml_index<1>(page)].clear();
if (pml1->empty())
{
auto pml1_frame = (*pml2)[pml_index<2>(page)].frame().value();
- m_allocator->release(pml1_frame);
+ allocator.release(pml1_frame);
(*pml2)[pml_index<2>(page)].clear();
}
if (pml2->empty())
{
auto pml2_frame = (*pml3)[pml_index<3>(page)].frame().value();
- m_allocator->release(pml2_frame);
+ allocator.release(pml2_frame);
(*pml3)[pml_index<3>(page)].clear();
}
if (pml3->empty())
{
auto pml3_frame = (*pml4)[pml_index<4>(page)].frame().value();
- m_allocator->release(pml3_frame);
+ allocator.release(pml3_frame);
(*pml4)[pml_index<4>(page)].clear();
}