diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-26 11:30:05 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-26 11:30:05 +0000 |
| commit | ccd3c37c281261d35c5f11352ef78160057c41a6 (patch) | |
| tree | b8dbeb1d0b43213f00d8bf62b5a826e99651d2d6 /arch | |
| parent | 454dcb6f2033ee80a43f99d23323b02e8fd0a115 (diff) | |
| parent | bc993ccf7c5a80a8f4b1cd05437701efb81beec9 (diff) | |
| download | teachos-ccd3c37c281261d35c5f11352ef78160057c41a6.tar.xz teachos-ccd3c37c281261d35c5f11352ef78160057c41a6.zip | |
Merge branch 'feat_memory_manager' of ssh://gitlab.ost.ch:45022/teachos/kernel into feat_memory_manager
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/x86_64/src/memory/paging/page_table.cpp | 15 |
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(); } |
