diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-15 08:40:56 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-15 08:40:56 +0000 |
| commit | 03d3dec4807d6adcfc5e21bd13992014900b4eac (patch) | |
| tree | a5c083c33ce4eea3e538ac1a62e58ed2d7cfee7c /arch/x86_64 | |
| parent | 205934ca45d591924b4be6e7ae5a8849958e0cf6 (diff) | |
| download | teachos-03d3dec4807d6adcfc5e21bd13992014900b4eac.tar.xz teachos-03d3dec4807d6adcfc5e21bd13992014900b4eac.zip | |
implement page table members
Diffstat (limited to 'arch/x86_64')
| -rw-r--r-- | arch/x86_64/include/arch/memory/frame_allocator.hpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging.hpp | 21 | ||||
| -rw-r--r-- | arch/x86_64/src/memory/paging.cpp | 11 |
3 files changed, 32 insertions, 4 deletions
diff --git a/arch/x86_64/include/arch/memory/frame_allocator.hpp b/arch/x86_64/include/arch/memory/frame_allocator.hpp index 69c108c..3d1f826 100644 --- a/arch/x86_64/include/arch/memory/frame_allocator.hpp +++ b/arch/x86_64/include/arch/memory/frame_allocator.hpp @@ -32,9 +32,9 @@ namespace teachos::arch::memory static auto containing_address(std::size_t address) -> physical_frame; /** - * @brief TODO + * @brief Evaluates the start address of the physical frame * - * @return uint64_t + * @return start address of the physical frame */ auto start_address() const -> uint64_t; diff --git a/arch/x86_64/include/arch/memory/paging.hpp b/arch/x86_64/include/arch/memory/paging.hpp index 1870c28..43f13e0 100644 --- a/arch/x86_64/include/arch/memory/paging.hpp +++ b/arch/x86_64/include/arch/memory/paging.hpp @@ -89,11 +89,28 @@ namespace teachos::arch::memory }; /** - * @brief TODO - * + * @brief A Page table containing 512 entries */ struct page_table { + /** + * @brief Set every entry of the page to unused + */ + auto zero_entries() -> void; + + /** + * @brief Index operator overload to access specific entries directy + * + * @param index + * @return The address of the accessed entry + */ + entry & operator[](size_t index) + { + arch::exception_handling::assert(index < PAGE_TABLE_ENTRY_COUNT, "[Page Table] index out of bounds"); + return entries[index]; + } + + private: entry entries[PAGE_TABLE_ENTRY_COUNT]; }; } // namespace teachos::arch::memory diff --git a/arch/x86_64/src/memory/paging.cpp b/arch/x86_64/src/memory/paging.cpp index 90c4199..58a2b99 100644 --- a/arch/x86_64/src/memory/paging.cpp +++ b/arch/x86_64/src/memory/paging.cpp @@ -40,4 +40,15 @@ namespace teachos::arch::memory auto entry::contains_flags(std::bitset<64U> b) const -> bool { return (flags & b) == b; } + auto page_table::zero_entries() -> void + { + auto begin = &entries[0]; + auto end = &entries[PAGE_TABLE_ENTRY_COUNT]; + + for (auto entry = begin; entry < end; ++entry) + { + entry->set_unused(); + } + } + } // namespace teachos::arch::memory |
