aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/src/memory/paging/page_table.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/arch/x86_64/src/memory/paging/page_table.cpp b/arch/x86_64/src/memory/paging/page_table.cpp
index 14ead9e..c0f199a 100644
--- a/arch/x86_64/src/memory/paging/page_table.cpp
+++ b/arch/x86_64/src/memory/paging/page_table.cpp
@@ -74,8 +74,7 @@ namespace teachos::arch::memory::paging
auto address = next_table_address(table_index);
if (address)
{
- // TODO: Probably erases the data even if the page table already existed previously and had values.
- return std::construct_at(reinterpret_cast<page_table *>(address.value()));
+ return reinterpret_cast<page_table *>(address.value());
}
return std::nullopt;
}
@@ -113,7 +112,17 @@ namespace teachos::arch::memory::paging
{
exception_handling::assert(handle_level == page_table_handle::LEVEL4,
"[Page Table] Attempted to initialize a page table of level 3 or lower");
- auto level3_page_table = std::construct_at(reinterpret_cast<page_table *>(_end_of_image));
+ auto level3_page_table = std::construct_at(reinterpret_cast<page_table *>(&_end_of_image));
+ for (size_t n = 1; n <= PAGE_TABLE_ENTRY_COUNT; ++n)
+ {
+ size_t offset = sizeof(page_table) * n;
+ std::construct_at(reinterpret_cast<page_table *>(&_end_of_image + offset));
+ for (size_t m = 1; m <= PAGE_TABLE_ENTRY_COUNT; ++m)
+ {
+ size_t offset = sizeof(page_table) * (n + m);
+ std::construct_at(reinterpret_cast<page_table *>(&_end_of_image + offset));
+ }
+ }
}
auto page_table_handle::zero_entries() -> void { handle->zero_entries(); }