aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/memory
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/memory')
-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();
}