Files
banan-os/kernel/include/kernel/Memory/Heap.h
Bananymous e4c6539964 Kernel: Be more clever with physical memory
Initially allocate all physical memory except kernel memory and boot
modules. Before we just skipped all memory before kernel boot modules.
Also release memory used by boot modules after the kernel is up and
running. Once the boot modules are loaded, there is no need to keep them
in memory.
2026-04-06 19:29:34 +03:00

42 lines
706 B
C++

#pragma once
#include <BAN/NoCopyMove.h>
#include <BAN/Vector.h>
#include <kernel/Lock/SpinLock.h>
#include <kernel/Memory/PhysicalRange.h>
namespace Kernel
{
class Heap
{
BAN_NON_COPYABLE(Heap);
BAN_NON_MOVABLE(Heap);
public:
static void initialize();
static Heap& get();
void release_boot_modules();
paddr_t take_free_page();
void release_page(paddr_t);
paddr_t take_free_contiguous_pages(size_t pages);
void release_contiguous_pages(paddr_t paddr, size_t pages);
size_t used_pages() const;
size_t free_pages() const;
private:
Heap() = default;
void initialize_impl();
private:
BAN::Vector<PhysicalRange> m_physical_ranges;
mutable SpinLock m_lock;
};
}