aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-03 11:03:34 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-03 11:03:34 +0000
commit9292814545ab5df5aa69d4f75a6d9230f3e03f5b (patch)
tree4d3cd879c21e3f14867fce0cb78c7aa73fc812c6 /arch/x86_64
parentd4b1b8a85212f07df47217fe13d86956c7eb064f (diff)
downloadteachos-9292814545ab5df5aa69d4f75a6d9230f3e03f5b.tar.xz
teachos-9292814545ab5df5aa69d4f75a6d9230f3e03f5b.zip
Move possible implementation into cpp
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp13
-rw-r--r--arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp16
-rw-r--r--arch/x86_64/src/memory/paging/temporary_page.cpp16
3 files changed, 25 insertions, 20 deletions
diff --git a/arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp b/arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp
index b8ed506..a96b743 100644
--- a/arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp
+++ b/arch/x86_64/include/arch/memory/allocator/tiny_frame_allocator.hpp
@@ -27,18 +27,7 @@ namespace teachos::arch::memory::allocator
* @param allocator Reference to an allocator following the FrameAllocator concept, which is used to allocate
* entries *when a new page table is required.
*/
- tiny_frame_allocator(area_frame_allocator & allocator)
- : frames{}
- {
- for (auto & frame : frames)
- {
- auto allocated = allocator.allocate_frame();
- if (allocated.has_value())
- {
- frame.emplace(allocated.value());
- }
- }
- }
+ tiny_frame_allocator(area_frame_allocator & allocator);
/**
* @brief Allocate memory by finding and returning one of the three free physical frames.
diff --git a/arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp b/arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp
index b9fd2c8..d37864e 100644
--- a/arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp
+++ b/arch/x86_64/src/memory/allocator/tiny_frame_allocator.cpp
@@ -4,6 +4,22 @@
namespace teachos::arch::memory::allocator
{
+ tiny_frame_allocator::tiny_frame_allocator(area_frame_allocator & allocator)
+ : frames{}
+ {
+ // Has to be done this way, because constructing the constructor with the data from allocator.allocate_frames(),
+ // does not work because it would set the value correctly but because we pass it as an std::optional it would not
+ // set the engaged flag. Meaning the has_value() method would still return false.
+ for (auto & frame : frames)
+ {
+ auto allocated = allocator.allocate_frame();
+ if (allocated.has_value())
+ {
+ frame.emplace(allocated.value());
+ }
+ }
+ }
+
auto tiny_frame_allocator::allocate_frame() -> std::optional<physical_frame>
{
for (auto & frame_option : frames)
diff --git a/arch/x86_64/src/memory/paging/temporary_page.cpp b/arch/x86_64/src/memory/paging/temporary_page.cpp
index 7b065ab..5f760a5 100644
--- a/arch/x86_64/src/memory/paging/temporary_page.cpp
+++ b/arch/x86_64/src/memory/paging/temporary_page.cpp
@@ -4,6 +4,14 @@
namespace teachos::arch::memory::paging
{
+ auto temporary_page::map_table_frame(allocator::physical_frame frame,
+ active_page_table & active_table) -> page_table_handle
+ {
+ page_table_handle handle{reinterpret_cast<page_table *>(map_to_frame(frame, active_table)),
+ page_table_handle::LEVEL1};
+ return handle;
+ }
+
auto temporary_page::map_to_frame(allocator::physical_frame frame,
active_page_table & active_table) -> virtual_address
{
@@ -19,14 +27,6 @@ namespace teachos::arch::memory::paging
active_table.unmap_page(allocator, page);
}
- auto temporary_page::map_table_frame(allocator::physical_frame frame,
- active_page_table & active_table) -> page_table_handle
- {
- page_table_handle handle{reinterpret_cast<page_table *>(map_to_frame(frame, active_table)),
- page_table_handle::LEVEL1};
- return handle;
- }
-
auto temporary_page::zero_entries(active_page_table & active_table) -> void
{
auto frame = allocator.allocate_frame();