aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/memory/paging
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-26 11:23:58 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-10-26 11:23:58 +0000
commitffb6507d565585bb2a817ff01317b7643bd6d981 (patch)
tree3534317a37e5d1b1aec7f8a91ddbaa4dd9454cf5 /arch/x86_64/src/memory/paging
parent9954cff61ce56f9e68eefa24a5d838f935515f6c (diff)
downloadteachos-ffb6507d565585bb2a817ff01317b7643bd6d981.tar.xz
teachos-ffb6507d565585bb2a817ff01317b7643bd6d981.zip
Create for loops to construct base level 3 page table
Diffstat (limited to 'arch/x86_64/src/memory/paging')
-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 059ada2..935dd8c 100644
--- a/arch/x86_64/src/memory/paging/page_table.cpp
+++ b/arch/x86_64/src/memory/paging/page_table.cpp
@@ -70,8 +70,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;
}
@@ -109,7 +108,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 = 0; 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(); }