diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-07-03 09:32:30 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-07-03 09:32:30 +0200 |
| commit | 3012fa5dfe5dfed5e83baf9b40934ed8e8317627 (patch) | |
| tree | 00d1c60a3d5d1cdfa55e0ff1691cd3362b6064ee /kernel/src/memory.cpp | |
| parent | 5d8a58d538515ffc57ddf82ba40ba763990a8696 (diff) | |
| download | kernel-3012fa5dfe5dfed5e83baf9b40934ed8e8317627.tar.xz kernel-3012fa5dfe5dfed5e83baf9b40934ed8e8317627.zip | |
kernel: rearrange sources according to p1204
Diffstat (limited to 'kernel/src/memory.cpp')
| -rw-r--r-- | kernel/src/memory.cpp | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/kernel/src/memory.cpp b/kernel/src/memory.cpp deleted file mode 100644 index 6a85c0e7..00000000 --- a/kernel/src/memory.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include <kernel/memory.hpp> - -#include <kernel/memory/block_list_allocator.hpp> -#include <kernel/memory/heap_allocator.hpp> - -#include <kapi/memory.hpp> -#include <kapi/system.hpp> - -#include <kstd/print> -#include <kstd/units> - -#include <atomic> -#include <optional> - -namespace kernel::memory -{ - - namespace - { - struct null_allocator : heap_allocator - { - null_allocator static instance; - - [[nodiscard]] auto allocate(kstd::units::bytes, kstd::units::bytes) noexcept -> void * override - { - kstd::print(kstd::print_sink::stderr, "Tried to allocate memory without an active heap!"); - return nullptr; - } - - auto deallocate(void *) noexcept -> void override - { - kstd::print(kstd::print_sink::stderr, "Tried to deallocate memory without an active heap!"); - } - }; - - constinit null_allocator null_allocator::instance{}; - - auto constinit active_heap_allocator = std::optional<heap_allocator *>{&null_allocator::instance}; - auto constinit basic_allocator = std::optional<block_list_allocator>{}; - } // namespace - - auto get_heap_allocator() -> heap_allocator & - { - return *active_heap_allocator.value(); - } - - auto init_heap(kapi::memory::linear_address base) -> void - { - auto static constinit is_initialized = std::atomic_flag{}; - - if (is_initialized.test_and_set()) - { - kapi::system::panic("[OS:MEM] The heap has already been initialized."); - } - - auto & instance = basic_allocator.emplace(base); - active_heap_allocator = &instance; - kstd::println("[OS:MEM] Heap initialized. Dynamic memory available."); - } - -} // namespace kernel::memory
\ No newline at end of file |
