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/page_mapper.hpp5
-rw-r--r--arch/x86_64/src/memory/paging/page_mapper.cpp15
2 files changed, 6 insertions, 14 deletions
diff --git a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
index a8cca4c..24d8cde 100644
--- a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
+++ b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp
@@ -73,12 +73,11 @@ namespace teachos::arch::memory::paging
if (!next_handle)
{
auto allocated_frame = allocator.allocate_frame();
- exception_handling::assert(!allocated_frame.has_value(), "[Page mapper] Unable to allocate frame");
+ exception_handling::assert(allocated_frame.has_value(), "[Page mapper] Unable to allocate frame");
current_handle[level_index].set_entry(allocated_frame.value(), entry::PRESENT | entry::WRITABLE);
// There should now be an entry at the previously not existent index, therefore we can simply access it again.
next_handle = current_handle.next_table(page.get_level_index(level));
- exception_handling::assert(!next_handle.has_value(),
- "[Page mapper] Unable to create new entry into page table");
+ exception_handling::assert(next_handle.has_value(), "[Page mapper] Unable to create new entry into page table");
next_handle.value().zero_entries();
}
current_handle = next_handle.value();
diff --git a/arch/x86_64/src/memory/paging/page_mapper.cpp b/arch/x86_64/src/memory/paging/page_mapper.cpp
index 75b17ff..1371868 100644
--- a/arch/x86_64/src/memory/paging/page_mapper.cpp
+++ b/arch/x86_64/src/memory/paging/page_mapper.cpp
@@ -4,8 +4,9 @@ namespace teachos::arch::memory::paging
{
namespace
{
- constexpr size_t PAGE_TABLE_LEVEL_4_ADDRESS = 0xfffffffffffff000;
- }
+ // TODO: Set the address to a sensible location, this is merely a placeholder
+ constexpr size_t PAGE_TABLE_LEVEL_4_ADDRESS = 0x27AC40;
+ } // namespace
auto create_or_get() -> page_table_handle
{
@@ -14,19 +15,11 @@ namespace teachos::arch::memory::paging
return page_table_handle{active_page, page_table_handle::LEVEL4};
}
- auto subtract_level(page_table_handle::level level) -> page_table_handle::level
- {
- exception_handling::assert(level != page_table_handle::LEVEL1,
- "[Page table] Attemptd to decrement enum to value outside of range");
- auto value = static_cast<std::underlying_type<page_table_handle::level>::type>(level);
- return static_cast<page_table_handle::level>(--value);
- }
-
auto translate_page(virtual_page page) -> std::optional<allocator::physical_frame>
{
auto current_handle = create_or_get();
- for (auto level = page_table_handle::LEVEL4; level != page_table_handle::LEVEL1; level = subtract_level(level))
+ for (auto level = page_table_handle::LEVEL4; level != page_table_handle::LEVEL1; level--)
{
auto next_handle = current_handle.next_table(page.get_level_index(level));
// If the next table method failed then it is highly likely that it was a huge page and we therefore have to