aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64')
-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.hpp4
-rw-r--r--arch/x86_64/src/memory/paging/active_page_table.cpp2
3 files changed, 13 insertions, 5 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 84f0471..f06c4e2 100644
--- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
+++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp
@@ -83,9 +83,7 @@ namespace teachos::arch::memory::paging
auto const backup = allocator::physical_frame::containing_address(physical_address.value());
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;