diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-15 08:23:39 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-15 08:23:39 +0000 |
| commit | 205934ca45d591924b4be6e7ae5a8849958e0cf6 (patch) | |
| tree | 5f0b193fa9620a253690f494405e5d407d97ca56 /arch/x86_64/include | |
| parent | 38e0b13ab9a4997fdf9f311fd125825919d2e6c7 (diff) | |
| download | teachos-205934ca45d591924b4be6e7ae5a8849958e0cf6.tar.xz teachos-205934ca45d591924b4be6e7ae5a8849958e0cf6.zip | |
continue implementing paging
Diffstat (limited to 'arch/x86_64/include')
| -rw-r--r-- | arch/x86_64/include/arch/exception_handling/assert.hpp | 11 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/frame_allocator.hpp | 7 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging.hpp | 99 |
3 files changed, 43 insertions, 74 deletions
diff --git a/arch/x86_64/include/arch/exception_handling/assert.hpp b/arch/x86_64/include/arch/exception_handling/assert.hpp new file mode 100644 index 0000000..eba43ac --- /dev/null +++ b/arch/x86_64/include/arch/exception_handling/assert.hpp @@ -0,0 +1,11 @@ +namespace teachos::arch::exception_handling +{ + /** + * @brief assert a condition to be true, if not do not continue + * execution of the code and print message to screen + * + * @param condition + * @param message + */ + auto assert(bool condition, char const * message) -> void; +} // namespace teachos::arch::exception_handling
\ No newline at end of file diff --git a/arch/x86_64/include/arch/memory/frame_allocator.hpp b/arch/x86_64/include/arch/memory/frame_allocator.hpp index ab93231..69c108c 100644 --- a/arch/x86_64/include/arch/memory/frame_allocator.hpp +++ b/arch/x86_64/include/arch/memory/frame_allocator.hpp @@ -32,6 +32,13 @@ namespace teachos::arch::memory static auto containing_address(std::size_t address) -> physical_frame; /** + * @brief TODO + * + * @return uint64_t + */ + auto start_address() const -> uint64_t; + + /** * @brief Defaulted equals operator. */ constexpr auto operator==(const physical_frame & other) const -> bool = default; diff --git a/arch/x86_64/include/arch/memory/paging.hpp b/arch/x86_64/include/arch/memory/paging.hpp index a5408e1..1870c28 100644 --- a/arch/x86_64/include/arch/memory/paging.hpp +++ b/arch/x86_64/include/arch/memory/paging.hpp @@ -43,72 +43,6 @@ namespace teachos::arch::memory auto set_unused() -> void; /** - * @brief Whether the current page is in memory and therefore present or not. Read from bit index 0. - * - * @return Current page is in memory. - */ - auto present() const -> bool; - - /** - * @brief Whether it is possible to write to the current page or not. Read from bit index 1. - * - * @return Current page can be written too. - */ - auto writable() const -> bool; - - /** - * @brief Whether the current page can be accessed in user mode, or only in kernel mode code. Read from bit index 2. - * - * @return Current page can be accessed in user mode. - */ - auto user_accessible() const -> bool; - - /** - * @brief Whether any write to the current page go directly to memory instead of the cache or not. Read from bit - * index 3. - * - * @return Writes to the current page go directly to memory. - */ - auto write_through_caching() const -> bool; - - /** - * @brief Whether the current page uses caching or not. Read from bit index 4. - * - * @return Current page does not use caching. - */ - auto disabled_caching() const -> bool; - - /** - * @brief Whether the current page is currently being used or not. Read from bit index 5. - * - * @return Current page is currently being used. - */ - auto is_accessing() const -> bool; - - /** - * @brief Whether the current page has been writen too or not. Read from bit index 6. - * - * @return Current page has been writen too. - */ - auto is_diry() const -> bool; - - /** - * @brief Whether the current page is huge or not (2 MiB page size in P2 page table and 1 GiB in P3 page table, - * instead of 4 KiB). Has to be false for P1 and P4 page tables. Read from bit index 7. - * - * @return Current page is huge - */ - auto is_huge_page() const -> bool; - - /** - * @brief Whether the current page is not flushed from caches on address space switches or not (PGE bit of CR4 - * register has to be set). Read from bit index 8. - * - * @return Current page is not flushed from caches on address space switches. - */ - auto is_global() const -> bool; - - /** * @brief Whether the current page is forbidden from executing code or not (NXE bit in the EFER register has to be * set). Read from bit index 63. * @@ -124,6 +58,22 @@ namespace teachos::arch::memory */ auto calculate_pointed_to_frame() const -> std::optional<physical_frame>; + /** + * @brief TODO + * + * @param frame + */ + auto set(physical_frame frame) -> void; + + /** + * @brief TODO + * + * @param b + * @return true + * @return false + */ + auto contains_flags(std::bitset<64U> b) const -> bool; + private: /** * @brief Extracts the physical address from the underlying bitset read from bit index 12 - 51. Is a 52 bit page @@ -134,17 +84,18 @@ namespace teachos::arch::memory */ auto calculate_physical_address() const -> std::size_t; - /** - * @brief Checks the underlying std::bitset if the bit at the specific index is set, meaning a value of 1 - * - * @param index Specific index we want to check at - * @return Bit value 1 is set and will return true - */ - auto is_bit_set(uint8_t index) const -> bool; - std::bitset<64U> flags; ///< Underlying bitset used to read the flags from. Bits 9 - 11 and 52 - 62 can be freely ///< used for additional flagsby the operating system. }; + + /** + * @brief TODO + * + */ + struct page_table + { + entry entries[PAGE_TABLE_ENTRY_COUNT]; + }; } // namespace teachos::arch::memory #endif // TEACHOS_ARCH_X86_64_MEMORY_PAGING_HPP |
