diff options
Diffstat (limited to 'arch/x86_64/include')
4 files changed, 11 insertions, 28 deletions
diff --git a/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp b/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp index 209f8b3..d5f4561 100644 --- a/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp +++ b/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp @@ -34,7 +34,7 @@ namespace teachos::arch::memory::heap * @param size Amount of memory to allocate. * @return Address of the first byte to the allocated area */ - auto allocate(std::size_t size) -> void *; + auto allocate(std::size_t size) -> void * override; /** * @brief Deallocates heap memory at the specified location. @@ -44,7 +44,7 @@ namespace teachos::arch::memory::heap * @param pointer Pointer to the location which should be deallocated. * @param size Size of the underlying memory area we want to deallocate. */ - auto deallocate(void * pointer, std::size_t size) -> void; + auto deallocate(void * pointer, std::size_t size) -> void override; private: std::size_t heap_start; ///< Start of the allocatable heap area diff --git a/arch/x86_64/include/arch/memory/heap/concept.hpp b/arch/x86_64/include/arch/memory/heap/concept.hpp deleted file mode 100644 index e22e35f..0000000 --- a/arch/x86_64/include/arch/memory/heap/concept.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef TEACHOS_ARCH_X86_64_MEMORY_HEAP_CONCEPT_HPP -#define TEACHOS_ARCH_X86_64_MEMORY_HEAP_CONCEPT_HPP - -#include <concepts> - -namespace teachos::arch::memory::heap -{ - std::size_t constexpr HEAP_START = 0x100000000; - std::size_t constexpr HEAP_SIZE = 100 * 1024; - - /** - * @brief Heap allocator concept required for allocating and managing free space on the 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 diff --git a/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp b/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp index e8555df..1b1d964 100644 --- a/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp +++ b/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp @@ -1,7 +1,7 @@ #ifndef TEACHOS_ARCH_X86_64_MEMORY_HEAP_GLOBAL_HEAP_ALLOCATOR_HPP #define TEACHOS_ARCH_X86_64_MEMORY_HEAP_GLOBAL_HEAP_ALLOCATOR_HPP -#include "arch/memory/heap/linked_list_allocator.hpp" +#include "arch/memory/heap/heap_allocator.hpp" namespace teachos::arch::memory::heap { @@ -14,16 +14,16 @@ namespace teachos::arch::memory::heap struct global_heap_allocator { - static auto register_heap_allocator_type(heap_allocator_type new_type) -> void; + static auto register_heap_allocator(heap_allocator_type new_type) -> void; static auto allocate(std::size_t size) -> void *; static auto deallocate(void * pointer, std::size_t size) -> void; private: - static heap_allocator_type allocator_type; + static heap_allocator * allocator_instance; - static auto create_or_get() -> heap_allocator &; + static auto get() -> heap_allocator &; }; } // namespace teachos::arch::memory::heap diff --git a/arch/x86_64/include/arch/memory/heap/heap_allocator.hpp b/arch/x86_64/include/arch/memory/heap/heap_allocator.hpp index 9e37bd4..62ba963 100644 --- a/arch/x86_64/include/arch/memory/heap/heap_allocator.hpp +++ b/arch/x86_64/include/arch/memory/heap/heap_allocator.hpp @@ -5,8 +5,13 @@ namespace teachos::arch::memory::heap { + std::size_t constexpr HEAP_START = 0x100000000; + std::size_t constexpr HEAP_SIZE = 100 * 1024; + struct heap_allocator { + virtual ~heap_allocator() {} + virtual auto allocate(std::size_t size) -> void * = 0; virtual auto deallocate(void * pointer, std::size_t size) -> void = 0; |
