aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/memory/heap/allocator.hpp32
-rw-r--r--arch/x86_64/include/arch/memory/heap/concept.hpp15
-rw-r--r--arch/x86_64/include/arch/memory/main.hpp13
-rw-r--r--arch/x86_64/include/arch/memory/paging/active_page_table.hpp2
4 files changed, 61 insertions, 1 deletions
diff --git a/arch/x86_64/include/arch/memory/heap/allocator.hpp b/arch/x86_64/include/arch/memory/heap/allocator.hpp
new file mode 100644
index 0000000..c486a4c
--- /dev/null
+++ b/arch/x86_64/include/arch/memory/heap/allocator.hpp
@@ -0,0 +1,32 @@
+#ifndef TEACHOS_ARCH_X86_64_MEMORY_HEAP_ALLOCATOR_HPP
+#define TEACHOS_ARCH_X86_64_MEMORY_HEAP_ALLOCATOR_HPP
+
+#include <cstdint>
+
+namespace teachos::arch::memory::heap
+{
+ std::size_t constexpr HEAP_START = 0x4000'0000;
+ std::size_t constexpr HEAP_SIZE = 100 * 1024;
+
+ struct bump_allocator
+ {
+ bump_allocator(std::size_t heap_start, std::size_t heap_end)
+ : heap_start{heap_start}
+ , heap_end{heap_end}
+ , next{heap_start}
+ {
+ }
+
+ auto allocate(std::size_t size) -> void *;
+
+ auto deallocate(uint8_t * pointer, std::size_t size) -> void;
+
+ private:
+ std::size_t heap_start;
+ std::size_t heap_end;
+ std::size_t next;
+ };
+
+} // namespace teachos::arch::memory::heap
+
+#endif \ No newline at end of file
diff --git a/arch/x86_64/include/arch/memory/heap/concept.hpp b/arch/x86_64/include/arch/memory/heap/concept.hpp
new file mode 100644
index 0000000..a525b0b
--- /dev/null
+++ b/arch/x86_64/include/arch/memory/heap/concept.hpp
@@ -0,0 +1,15 @@
+#ifndef TEACHOS_ARCH_X86_64_MEMORY_HEAP_CONCEPT_HPP
+#define TEACHOS_ARCH_X86_64_MEMORY_HEAP_CONCEPT_HPP
+
+#include <cstdint>
+
+namespace teachos::arch::memory::heap
+{
+ template<typename T>
+ concept HeapAllocator = requires(T t, uint8_t * pointer, std::size_t size) {
+ { t.allocate(size) } -> std::same_as<uint8_t *>;
+ { t.deallocate(pointer, size) } -> std::same_as<void>;
+ };
+} // namespace teachos::arch::memory::heap
+
+#endif // TEACHOS_ARCH_X86_64_MEMORY_HEAP_CONCEPT_HPP \ No newline at end of file
diff --git a/arch/x86_64/include/arch/memory/main.hpp b/arch/x86_64/include/arch/memory/main.hpp
new file mode 100644
index 0000000..e166285
--- /dev/null
+++ b/arch/x86_64/include/arch/memory/main.hpp
@@ -0,0 +1,13 @@
+#ifndef TEACHOS_ARCH_X86_64_MEMORY_MAIN_HPP
+#define TEACHOS_ARCH_X86_64_MEMORY_MAIN_HPP
+
+namespace teachos::arch::memory
+{
+ /**
+ * @brief
+ *
+ */
+ auto initialize_memory_management() -> void;
+} // namespace teachos::arch::memory
+
+#endif
diff --git a/arch/x86_64/include/arch/memory/paging/active_page_table.hpp b/arch/x86_64/include/arch/memory/paging/active_page_table.hpp
index 4687209..1b2aaed 100644
--- a/arch/x86_64/include/arch/memory/paging/active_page_table.hpp
+++ b/arch/x86_64/include/arch/memory/paging/active_page_table.hpp
@@ -98,7 +98,7 @@ namespace teachos::arch::memory::paging
* @see map_page_to_frame
*/
template<allocator::FrameAllocator T>
- auto map_next_free_page_to_frame(T & allocator, virtual_page page, std::bitset<64U> flags) -> void
+ auto map_page_to_next_free_frame(T & allocator, virtual_page page, std::bitset<64U> flags) -> void
{
auto const frame = allocator.allocate_frame();
exception_handling::assert(frame.has_value(), "[Page mapper] Out of memory exception");