From ffb6507d565585bb2a817ff01317b7643bd6d981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Sat, 26 Oct 2024 11:23:58 +0000 Subject: Create for loops to construct base level 3 page table --- arch/x86_64/src/memory/paging/page_table.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'arch/x86_64/src/memory') 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(address.value())); + return reinterpret_cast(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(_end_of_image)); + auto level3_page_table = std::construct_at(reinterpret_cast(&_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(&_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(&_end_of_image + offset)); + } + } } auto page_table_handle::zero_entries() -> void { handle->zero_entries(); } -- cgit v1.2.3 From bc993ccf7c5a80a8f4b1cd05437701efb81beec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Sat, 26 Oct 2024 11:24:13 +0000 Subject: Fix typo --- arch/x86_64/src/memory/paging/page_table.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/x86_64/src/memory') diff --git a/arch/x86_64/src/memory/paging/page_table.cpp b/arch/x86_64/src/memory/paging/page_table.cpp index 935dd8c..38d5025 100644 --- a/arch/x86_64/src/memory/paging/page_table.cpp +++ b/arch/x86_64/src/memory/paging/page_table.cpp @@ -113,7 +113,7 @@ namespace teachos::arch::memory::paging { size_t offset = sizeof(page_table) * n; std::construct_at(reinterpret_cast(&_end_of_image + offset)); - for (size_t m = 0; m < PAGE_TABLE_ENTRY_COUNT; ++m) + for (size_t m = 1; m <= PAGE_TABLE_ENTRY_COUNT; ++m) { size_t offset = sizeof(page_table) * (n + m); std::construct_at(reinterpret_cast(&_end_of_image + offset)); -- cgit v1.2.3