aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kapi/include/kapi/memory.hpp1
-rw-r--r--kapi/include/kapi/memory/frame.hpp3
-rw-r--r--kapi/include/kapi/memory/layout.hpp26
-rw-r--r--kapi/include/kapi/memory/page.hpp3
-rw-r--r--kernel/kapi/memory.cpp2
5 files changed, 32 insertions, 3 deletions
diff --git a/kapi/include/kapi/memory.hpp b/kapi/include/kapi/memory.hpp
index 3a8f42d..b234cde 100644
--- a/kapi/include/kapi/memory.hpp
+++ b/kapi/include/kapi/memory.hpp
@@ -5,6 +5,7 @@
#include "kapi/memory/chunk.hpp" // IWYU pragma: export
#include "kapi/memory/frame.hpp" // IWYU pragma: export
#include "kapi/memory/frame_allocator.hpp" // IWYU pragma: export
+#include "kapi/memory/layout.hpp" // IWYU pragma: export
#include "kapi/memory/page.hpp" // IWYU pragma: export
#include "kapi/memory/page_mapper.hpp" // IWYU pragma: export
diff --git a/kapi/include/kapi/memory/frame.hpp b/kapi/include/kapi/memory/frame.hpp
index deab300..a55b6ff 100644
--- a/kapi/include/kapi/memory/frame.hpp
+++ b/kapi/include/kapi/memory/frame.hpp
@@ -5,6 +5,7 @@
#include "kapi/memory/address.hpp"
#include "kapi/memory/chunk.hpp"
+#include "kapi/memory/layout.hpp"
#include <cstddef>
@@ -15,7 +16,7 @@ namespace kapi::memory
//! A handle to a frame of physical memory.
//!
//! @note Contrary to the address types, this type is modeled using inheritance to support future extensions.
- struct frame : chunk<frame, physical_address, PLATFORM_FRAME_SIZE>
+ struct frame : chunk<frame, physical_address, frame_size>
{
frame() = default;
diff --git a/kapi/include/kapi/memory/layout.hpp b/kapi/include/kapi/memory/layout.hpp
new file mode 100644
index 0000000..f5ba0f9
--- /dev/null
+++ b/kapi/include/kapi/memory/layout.hpp
@@ -0,0 +1,26 @@
+#ifndef TEACHOS_KAPI_MEMORY_LAYOUT_HPP
+#define TEACHOS_KAPI_MEMORY_LAYOUT_HPP
+
+// IWYU pragma: private, include "kapi/memory.hpp"
+
+#include "kapi/memory/address.hpp"
+
+namespace kapi::memory
+{
+
+ constexpr auto page_size = PLATFORM_PAGE_SIZE;
+ constexpr auto frame_size = PLATFORM_FRAME_SIZE;
+
+ constexpr auto higher_half_direct_map_base = linear_address{0xffff'8000'0000'0000uz};
+
+ constexpr auto heap_base = linear_address{0xffff'c000'0000'0000uz};
+
+ constexpr auto pmm_metadata_base = linear_address{0xffff'd000'0000'0000uz};
+
+ constexpr auto mmio_base = linear_address{0xffff'e000'0000'0000uz};
+
+ constexpr auto kernel_base = linear_address{0xffff'ffff'8000'0000uz};
+
+} // namespace kapi::memory
+
+#endif \ No newline at end of file
diff --git a/kapi/include/kapi/memory/page.hpp b/kapi/include/kapi/memory/page.hpp
index f209278..3846bd8 100644
--- a/kapi/include/kapi/memory/page.hpp
+++ b/kapi/include/kapi/memory/page.hpp
@@ -5,6 +5,7 @@
#include "kapi/memory/address.hpp"
#include "kapi/memory/chunk.hpp"
+#include "kapi/memory/layout.hpp"
#include <cstddef>
@@ -15,7 +16,7 @@ namespace kapi::memory
//! A handle to a page of virtual memory.
//!
//! @note Contrary to the address types, this type is modeled using inheritance to support future extensions.
- struct page : chunk<page, linear_address, PLATFORM_PAGE_SIZE>
+ struct page : chunk<page, linear_address, page_size>
{
page() = default;
diff --git a/kernel/kapi/memory.cpp b/kernel/kapi/memory.cpp
index 1699cd3..d657527 100644
--- a/kernel/kapi/memory.cpp
+++ b/kernel/kapi/memory.cpp
@@ -122,7 +122,7 @@ namespace kapi::memory
system::panic("[OS:MEM] Not enough memory for bitmap allocator!");
}
- auto const base_address = 0xffff'c000'0000'0000uz;
+ auto const base_address = pmm_metadata_base.raw();
auto const flags = page_mapper::flags::writable | page_mapper::flags::supervisor_only;
std::ranges::for_each(std::views::iota(0uz, bitmap_pages), [&](auto index) {