diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-03-18 15:24:26 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-03-18 15:24:26 +0100 |
| commit | 12c0586ee15cadfa178e6982dc0f76b047cb2df9 (patch) | |
| tree | 7ef0e4dda9960baa93cb572af04f137cd2cebc81 | |
| parent | d25a933ee9df6bc34e806f71b86afb68c391a177 (diff) | |
| download | teachos-12c0586ee15cadfa178e6982dc0f76b047cb2df9.tar.xz teachos-12c0586ee15cadfa178e6982dc0f76b047cb2df9.zip | |
kapi/memory: remove page/frame size macros
| -rw-r--r-- | CMakePresets.json | 7 | ||||
| -rw-r--r-- | arch/x86_64/kapi/memory.cpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/src/memory/kernel_mapper.cpp | 2 | ||||
| -rw-r--r-- | kapi/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | kapi/include/kapi/memory/layout.hpp | 20 |
5 files changed, 21 insertions, 18 deletions
diff --git a/CMakePresets.json b/CMakePresets.json index fd88d3c..15bf4bc 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,12 +15,7 @@ { "name": "x86_64", "inherits": "base", - "toolchainFile": "cmake/Platforms/x86_64.cmake", - "cacheVariables": { - "TEACHOS_PLATFORM_FRAME_SIZE": "4096", - "TEACHOS_PLATFORM_PAGE_SIZE": "4096", - "TEACHOS_PLATFORM_PAGING_LEVELS": "4" - } + "toolchainFile": "cmake/Platforms/x86_64.cmake" } ], "buildPresets": [ diff --git a/arch/x86_64/kapi/memory.cpp b/arch/x86_64/kapi/memory.cpp index 547d359..07e7465 100644 --- a/arch/x86_64/kapi/memory.cpp +++ b/arch/x86_64/kapi/memory.cpp @@ -110,7 +110,7 @@ namespace kapi::memory auto mbi_size = boot::bootstrap_information.mbi->size_bytes(); auto mbi_physical_start = physical_address{mbi_base & ~std::bit_cast<std::uintptr_t>(&arch::boot::TEACHOS_VMA)}; auto mbi_virtual_start = linear_address{mbi_base}; - auto mbi_block_count = (mbi_size + PLATFORM_FRAME_SIZE - 1) / PLATFORM_FRAME_SIZE; + auto mbi_block_count = (mbi_size + frame::size - 1) / frame::size; for (auto i = 0uz; i < mbi_block_count; ++i) { @@ -127,7 +127,7 @@ namespace kapi::memory auto module_virtual_start = linear_address{module.start_address + std::bit_cast<std::uintptr_t>(&arch::boot::TEACHOS_VMA)}; auto module_size = module.end_address - module.start_address; - auto module_block_count = (module_size + PLATFORM_FRAME_SIZE - 1) / PLATFORM_FRAME_SIZE; + auto module_block_count = (module_size + frame::size - 1) / frame::size; for (auto i = 0uz; i < module_block_count; ++i) { diff --git a/arch/x86_64/src/memory/kernel_mapper.cpp b/arch/x86_64/src/memory/kernel_mapper.cpp index 08c32c5..e5bb7f8 100644 --- a/arch/x86_64/src/memory/kernel_mapper.cpp +++ b/arch/x86_64/src/memory/kernel_mapper.cpp @@ -71,7 +71,7 @@ namespace arch::memory auto kernel_mapper::map_section(section_header_type const & section, std::string_view name, kapi::memory::page_mapper & mapper) -> void { - auto number_of_pages = (section.size + (PLATFORM_PAGE_SIZE - 1)) / PLATFORM_PAGE_SIZE; + auto number_of_pages = (section.size + (kapi::memory::page::size - 1)) / kapi::memory::page::size; auto linear_start_address = kapi::memory::linear_address{section.virtual_load_address}; auto physical_start_address = kapi::memory::physical_address{section.virtual_load_address & ~m_kernel_load_base}; diff --git a/kapi/CMakeLists.txt b/kapi/CMakeLists.txt index 028cdbb..b239adb 100644 --- a/kapi/CMakeLists.txt +++ b/kapi/CMakeLists.txt @@ -29,9 +29,3 @@ target_link_libraries("kapi" INTERFACE "gcc" "stdc++" ) - -target_compile_definitions("kapi" INTERFACE - "PLATFORM_PAGE_SIZE=${TEACHOS_PLATFORM_PAGE_SIZE}uz" - "PLATFORM_PAGING_LEVELS=${TEACHOS_PLATFORM_PAGING_LEVELS}uz" - "PLATFORM_FRAME_SIZE=${TEACHOS_PLATFORM_FRAME_SIZE}uz" -) diff --git a/kapi/include/kapi/memory/layout.hpp b/kapi/include/kapi/memory/layout.hpp index f5ba0f9..d4153d8 100644 --- a/kapi/include/kapi/memory/layout.hpp +++ b/kapi/include/kapi/memory/layout.hpp @@ -8,17 +8,31 @@ namespace kapi::memory { - constexpr auto page_size = PLATFORM_PAGE_SIZE; - constexpr auto frame_size = PLATFORM_FRAME_SIZE; - + //! The size of a single page of virtual memory. + //! + //! Platforms that use different sizes of pages are expected to emulate 4 KiB pages towards the kernel. + constexpr auto page_size = 4096uz; + + //! The size of a single frame of physical memory. + //! + //! Platforms that use different sizes of frames are expected to emulate 4 KiB pages towards the kernel. + constexpr auto frame_size = 4096uz; + + //! The linear base address of the higher-half direct map. + //! + //! Platforms are expected to provide a mapping of at least the first 512 GiB of available memory at this address. constexpr auto higher_half_direct_map_base = linear_address{0xffff'8000'0000'0000uz}; + //! The linear base address of the kernel heap. constexpr auto heap_base = linear_address{0xffff'c000'0000'0000uz}; + //! The linear base address of the memory region reserved for the metadata required by the PMM. constexpr auto pmm_metadata_base = linear_address{0xffff'd000'0000'0000uz}; + //! The linear base address of all Memory Mapped I/O mappings. constexpr auto mmio_base = linear_address{0xffff'e000'0000'0000uz}; + //! The linear base address of the loaded kernel image. constexpr auto kernel_base = linear_address{0xffff'ffff'8000'0000uz}; } // namespace kapi::memory |
