aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-03 11:56:46 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-11-03 11:56:46 +0000
commitbe546b091795e740e9dd4c35fce6453fafe0319c (patch)
tree1d8c7bfc93f91e80534e9f0fb96d32c6fda69194
parent9292814545ab5df5aa69d4f75a6d9230f3e03f5b (diff)
downloadteachos-be546b091795e740e9dd4c35fce6453fafe0319c.tar.xz
teachos-be546b091795e740e9dd4c35fce6453fafe0319c.zip
Make member variables private again.
-rw-r--r--arch/x86_64/include/arch/memory/paging/active_page_table.hpp12
-rw-r--r--arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp3
-rw-r--r--arch/x86_64/src/memory/paging/active_page_table.cpp2
3 files changed, 13 insertions, 4 deletions
diff --git a/arch/x86_64/include/arch/memory/paging/active_page_table.hpp b/arch/x86_64/include/arch/memory/paging/active_page_table.hpp
index 5140c3d..0561420 100644
--- a/arch/x86_64/include/arch/memory/paging/active_page_table.hpp
+++ b/arch/x86_64/include/arch/memory/paging/active_page_table.hpp
@@ -27,6 +27,14 @@ namespace teachos::arch::memory::paging
static auto create_or_get() -> active_page_table &;
/**
+ * @brief Index operator overload to access specific mutable entry directy of the level 4 page table.
+ *
+ * @param index Index of the entry we want to access and only read.
+ * @return Entry at the given table index.
+ */
+ auto operator[](std::size_t index) -> entry &;
+
+ /**
* @brief Translates virtual address into corresponding physical address. Calls translate_page under the hood.
*
* @param address Virtual address we want to translate into physical one.
@@ -160,8 +168,6 @@ namespace teachos::arch::memory::paging
tlb_flush(page.start_address());
}
- page_table_handle active_handle; ///< Underlying active level 4 page table
-
private:
/**
* @brief Private constructor should only be used by create or get method, which ensures to create only ever one
@@ -202,6 +208,8 @@ namespace teachos::arch::memory::paging
entry.set_unused();
allocator.deallocate_frame(frame.value());
}
+
+ page_table_handle active_handle; ///< Underlying active level 4 page table
};
} // namespace teachos::arch::memory::paging
diff --git a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
index d7365a0..ede027c 100644
--- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
+++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
@@ -77,8 +77,7 @@ namespace teachos::arch::memory::paging
auto const backup = allocator::physical_frame::containing_address(PAGE_TABLE_LEVEL_4_ADDRESS);
auto page_table_level4 = temporary_page.map_table_frame(backup, active_table);
- active_table.active_handle[511].set_entry(inactive_table.page_table_level_4_frame,
- entry::PRESENT | entry::WRITABLE);
+ active_table[511].set_entry(inactive_table.page_table_level_4_frame, entry::PRESENT | entry::WRITABLE);
tlb_flush_all();
map_elf_kernel_sections(active_table);
diff --git a/arch/x86_64/src/memory/paging/active_page_table.cpp b/arch/x86_64/src/memory/paging/active_page_table.cpp
index 844ae37..033a363 100644
--- a/arch/x86_64/src/memory/paging/active_page_table.cpp
+++ b/arch/x86_64/src/memory/paging/active_page_table.cpp
@@ -10,6 +10,8 @@ namespace teachos::arch::memory::paging
return active_page;
}
+ auto active_page_table::operator[](std::size_t index) -> entry & { return active_handle[index]; }
+
auto active_page_table::translate_address(virtual_address address) -> std::optional<allocator::physical_address>
{
auto const offset = address % allocator::PAGE_FRAME_SIZE;