14using namespace MaxOS::memory;
15using namespace MaxOS::memory::allocator;
16using namespace MaxOS::common;
17using namespace MaxOS::processes;
18using namespace MaxOS::system;
26 : m_virtual_memory_manager(virtual_memory_manager)
30 if(m_virtual_memory_manager ==
nullptr)
45 if(m_virtual_memory_manager !=
nullptr)
46 delete m_virtual_memory_manager;
56void* BumpMemoryManager::allocate_extra_space(
size_t requested_size,
size_t& actual_size) {
59 auto* chunk = m_virtual_memory_manager->
allocate(requested_size, actual_size, PRESENT | WRITE | NO_EXECUTE);
60 ASSERT(chunk !=
nullptr,
"Out of memory - kernel cannot allocate any more memory");
74 return m_virtual_memory_manager;
86 if(manager ==
nullptr)
Basic doubly linked list bump memory manager.
BumpMemoryManager(VirtualMemoryManager *virtual_memory_manager=nullptr)
Constructs a new BumpMemoryManager.
static void switch_active_memory_manager(BumpMemoryManager *manager)
Switches the active memory manager.
VirtualMemoryManager * vmm()
static void free(void *pointer)
Frees a block of memory using the current memory manager.
static MemoryManager * s_kernel_memory_manager
The memory manager for any kernel processes and all kernel allocations.
static void * malloc(size_t size)
Allocates a block of memory in the current USERSPACE heap.
static void * kmalloc(size_t size)
Allocates a block of memory in the KERNEL space.
static void kfree(void *pointer)
Frees a block of memory using the kernel memory manager.
~MemoryManager()
Destroy the Memory Manager object, frees the VMM if not the kernel memory manager.
MemoryManager(VirtualMemoryManager *virtual_memory_manager=nullptr)
Construct a new Memory Manager object. Will switch the pml4 to use the calling process's page tables.
Manages the virtual memory of the system and provides functions to allocate and free memory in the vi...
void * allocate(size_t size, size_t flags)
Allocate a new chunk of virtual memory.
uint64_t * pml4_root_address_physical()
Get the physical address of the PML4 root.
void unallocate(void *pointer) final
Frees a block of memory.
void * allocate(size_t size) final
Allocates a block of memory.
void setup_region(uintptr_t address, size_t length) final
Setup a region to be bump memory managed, creates a free chunk represent the whole region.
static Process * current_process()
Gets the process on the currently executing core.
memory::MemoryManager * memory_manager
The manager for memory used by this process.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
Defines a MemoryManager class for handling memory allocation and deallocation.
constexpr uint64_t PAGE_SIZE
The size of a page (4KB)
Defines a GlobalScheduler and Scheduler for managing processes and threads.