diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-11-03 12:20:21 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-11-03 12:20:21 +0000 |
| commit | 380bc85d1a4fdbef102132c726ef2ac7ac6355da (patch) | |
| tree | d06c9d786fc461af0920e768104be4f583c06fac /arch | |
| parent | 756ef3a6d6aa61656dddbfea97482c8698807e39 (diff) | |
| download | teachos-380bc85d1a4fdbef102132c726ef2ac7ac6355da.tar.xz teachos-380bc85d1a4fdbef102132c726ef2ac7ac6355da.zip | |
Make constructor constexpr for basic page and frame types
Diffstat (limited to 'arch')
5 files changed, 13 insertions, 18 deletions
diff --git a/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp b/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp index b95687c..89e3cf8 100644 --- a/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp +++ b/arch/x86_64/include/arch/memory/allocator/physical_frame.hpp @@ -20,14 +20,18 @@ namespace teachos::arch::memory::allocator /** * @brief Defaulted constructor. */ - physical_frame() = default; + constexpr physical_frame() = default; /** * @brief Constructor. * * @param frame_number Index number that should be assigned to this physical frame. */ - explicit physical_frame(std::size_t frame_number); + explicit constexpr physical_frame(std::size_t frame_number) + : frame_number(frame_number) + { + // Nothing to do + } /** * @brief Returns the physical frame the given address is contained in. diff --git a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp index 3931db3..c62a02e 100644 --- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp +++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp @@ -9,7 +9,7 @@ namespace teachos::arch::memory::paging { namespace { - std::size_t constexpr UNUSED_VIRTUAL_ADDRESS = 0xCAFEBABE; + virtual_page constexpr UNUSED_VIRTUAL_PAGE{0xCAFEBABE}; } // namespace typedef shared::container<allocator::physical_frame_iterator> frame_container; @@ -45,8 +45,7 @@ namespace teachos::arch::memory::paging */ auto remap_kernel() -> void { - virtual_page temporary_address{UNUSED_VIRTUAL_ADDRESS}; - temporary_page temporary_page{temporary_address, allocator}; + temporary_page temporary_page{UNUSED_VIRTUAL_PAGE, allocator}; auto & active_table = active_page_table::create_or_get(); auto const frame = allocator.allocate_frame(); exception_handling::assert(frame.has_value(), diff --git a/arch/x86_64/include/arch/memory/paging/virtual_page.hpp b/arch/x86_64/include/arch/memory/paging/virtual_page.hpp index 8c5613d..c319af2 100644 --- a/arch/x86_64/include/arch/memory/paging/virtual_page.hpp +++ b/arch/x86_64/include/arch/memory/paging/virtual_page.hpp @@ -22,7 +22,11 @@ namespace teachos::arch::memory::paging * * @param page_number Index number of the current virtual page, used to distinguish it from other pages. */ - explicit virtual_page(std::size_t page_number); + explicit constexpr virtual_page(std::size_t page_number) + : page_number(page_number) + { + // Nothing to do + } /** * @brief Returns the virtual page the given address is contained in. diff --git a/arch/x86_64/src/memory/allocator/physical_frame.cpp b/arch/x86_64/src/memory/allocator/physical_frame.cpp index 9307602..227745a 100644 --- a/arch/x86_64/src/memory/allocator/physical_frame.cpp +++ b/arch/x86_64/src/memory/allocator/physical_frame.cpp @@ -2,12 +2,6 @@ namespace teachos::arch::memory::allocator { - physical_frame::physical_frame(std::size_t frame_number) - : frame_number(frame_number) - { - // Nothing to do - } - auto physical_frame::containing_address(physical_address address) -> physical_frame { return physical_frame{address / PAGE_FRAME_SIZE}; diff --git a/arch/x86_64/src/memory/paging/virtual_page.cpp b/arch/x86_64/src/memory/paging/virtual_page.cpp index c0ec88d..f798709 100644 --- a/arch/x86_64/src/memory/paging/virtual_page.cpp +++ b/arch/x86_64/src/memory/paging/virtual_page.cpp @@ -4,12 +4,6 @@ namespace teachos::arch::memory::paging { - virtual_page::virtual_page(std::size_t page_number) - : page_number(page_number) - { - // Nothing to do - } - auto virtual_page::containing_address(virtual_address address) -> virtual_page { exception_handling::assert(address < 0x00008000'00000000 || address >= 0xffff8000'00000000, |
