From 7d1d7c5f63791506049cc188740cc4956fc8d14c Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Tue, 22 Oct 2024 05:37:28 +0000 Subject: update comments --- .../include/arch/memory/paging/page_table.hpp | 30 ++++++++++++---------- arch/x86_64/src/memory/paging/page_table.cpp | 21 ++++++++------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/arch/x86_64/include/arch/memory/paging/page_table.hpp b/arch/x86_64/include/arch/memory/paging/page_table.hpp index 3a31dc5..9aaaafb 100644 --- a/arch/x86_64/include/arch/memory/paging/page_table.hpp +++ b/arch/x86_64/include/arch/memory/paging/page_table.hpp @@ -21,7 +21,9 @@ namespace teachos::arch::memory::paging struct page_table_handle { /** - * @brief Level of the page table, level 1 will not be able to call next_table anymore, because it would result in + * @brief Level of the page table. + * + * Level 1 will not be able to call next_table anymore, because it would result in * attempting to access memory that it should not. */ enum level : uint8_t @@ -46,10 +48,11 @@ namespace teachos::arch::memory::paging auto zero_entries() -> void; /** - * @brief Returns the next page table level from the given page table index. Meaning we - * use an index into a Level 4 page table to get the according Level 3 page table. If this method is called with a - * Level 1 page table it will instead assert and halt execution, because there is no furthere page table and - * mangeling up and returning the physical address would cause hard to debug issues. + * @brief Returns the next page table level from the given page table index. + * + * Meaning we use an index into a Level 4 page table to get the according Level 3 page table. If this method is + * called with a Level 1 page table it will instead assert and halt execution, because there is no furthere page + * table and mangeling up and returning the physical address would cause hard to debug issues. * * @param table_index Index of this page table in the page table one level lower. */ @@ -64,14 +67,15 @@ namespace teachos::arch::memory::paging auto operator[](std::size_t index) const -> entry; /** - * @brief Decrements the page table handle level enum by one, is defined so we can use it as a replacement for an - * int index in a range based for loop. Will halt execution if called with page_table_handle::LEVEL1, because there - * is no level below. Has to be defined as either a friend function or inline header method, because we define an - * operator of another type. In this instance friend function was choosen, because the struct itself also requires - * the operator, but declaring before the struct is not possible, because the enum is in the struct. This is - * inpossible because the struct requires the operator declared before itself to work, and the operator requires the - * struct declared before itself to work. Furthermore this allows the defintion of the method to be done in the cpp, - * avoiding includes in the header file. + * @brief Decrements the page table handle level enum by one. + * + * Is defined so we can use it as a replacement for an int index in a range based for loop. Will halt execution if + * called with page_table_handle::LEVEL1, because there is no level below. Has to be defined as either a friend + * function or inline header method, because we define an operator of another type. In this instance friend function + * was choosen, because the struct itself also requires the operator, but declaring before the struct is not + * possible, because the enum is in the struct. This is inpossible because the struct requires the operator declared + * before itself to work, and the operator requires the struct declared before itself to work. Furthermore this + * allows the defintion of the method to be done in the cpp, avoiding includes in the header file. * * @param value Value we want to decrement on * @return level New level value decrement by one, meaning the level is also decrement by one Level4 --> Level3, ... diff --git a/arch/x86_64/src/memory/paging/page_table.cpp b/arch/x86_64/src/memory/paging/page_table.cpp index 9c9ca76..939f3b1 100644 --- a/arch/x86_64/src/memory/paging/page_table.cpp +++ b/arch/x86_64/src/memory/paging/page_table.cpp @@ -15,10 +15,11 @@ namespace teachos::arch::memory::paging auto zero_entries() -> void; /** - * @brief Returns the next page table level from the given page table index. Meaning we - * use an index into a Level 4 page table to get the according Level 3 page table. This method should not be called - * on a Level 1 page table, because there is no furthere page table and mangeling up and returning the physical - * address would cause hard to debug issues. + * @brief Returns the next page table level from the given page table index. + * + * Meaning we use an index into a Level 4 page table to get the according Level 3 page table. This method should not + * be called on a Level 1 page table, because there is no furthere page table and mangeling up and returning the + * physical address would cause hard to debug issues. * * @param table_index Index of this page table in the page table one level lower. */ @@ -34,7 +35,9 @@ namespace teachos::arch::memory::paging private: /** - * @brief Calculates the address of the next page table level for the given table index. The next page table address + * @brief Calculates the address of the next page table level for the given table index. + * + * The next page table address * is only valid if the corresponding entry is present and not a huge page. Meaning we use an index into a * Level 4 page table to get the according Level 3 page table address. * @@ -43,8 +46,8 @@ namespace teachos::arch::memory::paging */ auto next_table_address(std::size_t table_index) const -> std::optional; - entry entries[PAGE_TABLE_ENTRY_COUNT]; ///< Entries containing addresses to page tables of a level below or actual - ///< virtual addresses for the level 1 page table. + entry entries[PAGE_TABLE_ENTRY_COUNT]; ///< Entries containing addresses to page tables of a level below or + ///< actual virtual addresses for the level 1 page table. }; auto page_table::zero_entries() -> void @@ -91,7 +94,7 @@ namespace teachos::arch::memory::paging : handle(handle) , handle_level(handle_level) { - exception_handling::assert(handle, "[Page table] Attemptd to pass nullptr as handle to page table handle method"); + exception_handling::assert(handle, "[Page table] Attempted to pass nullptr as handle to page table handle method"); } auto page_table_handle::zero_entries() -> void { handle->zero_entries(); } @@ -113,7 +116,7 @@ namespace teachos::arch::memory::paging auto operator--(page_table_handle::level value, int) -> page_table_handle::level { exception_handling::assert(value != page_table_handle::LEVEL1, - "[Page table] Attemptd to decrement enum to value outside of range"); + "[Page table] Attempted to decrement enum to value outside of range"); auto new_value = static_cast::type>(value); return static_cast(--new_value); } -- cgit v1.2.3