![]() |
Max OS 0.3
|
Handles memory allocation and deallocation. More...
#include <memorymanagement.h>
Public Member Functions | |
| MemoryManager (VirtualMemoryManager *virtual_memory_manager=nullptr) | |
| Construct a new Memory Manager object. Will switch the pml4 to use the calling process's page tables. | |
| ~MemoryManager () | |
| Destroy the Memory Manager object, frees the VMM if not the kernel memory manager. | |
Public Member Functions inherited from MaxOS::memory::BumpMemoryManager | |
| BumpMemoryManager (VirtualMemoryManager *virtual_memory_manager=nullptr) | |
| Constructs a new BumpMemoryManager. | |
| ~BumpMemoryManager () | |
| VirtualMemoryManager * | vmm () |
Public Member Functions inherited from MaxOS::memory::allocator::BumpAllocator | |
| BumpAllocator () | |
| Creates a new bump memory allocator. | |
| virtual | ~BumpAllocator () |
| Destructs a Bump memory allocator. | |
| 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. | |
| void * | allocate (size_t size) final |
| Allocates a block of memory. | |
| void | unallocate (void *pointer) final |
| Frees a block of memory. | |
| size_t | amount_used () final |
| Returns the amount of memory used. | |
| size_t | align (size_t size) final |
| Aligns the size to the chunk alignment. | |
Public Member Functions inherited from MaxOS::memory::allocator::MemoryAllocator | |
| MemoryAllocator () | |
| virtual | ~MemoryAllocator () |
Static Public Member Functions | |
| static void * | malloc (size_t size) |
| Allocates a block of memory in the current USERSPACE heap. | |
| static void | free (void *pointer) |
| Frees a block of memory using the current memory manager. | |
| 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. | |
Static Public Member Functions inherited from MaxOS::memory::BumpMemoryManager | |
| static void | switch_active_memory_manager (BumpMemoryManager *manager) |
| Switches the active memory manager. | |
Static Public Attributes | |
| static MemoryManager * | s_kernel_memory_manager = nullptr |
| The memory manager for any kernel processes and all kernel allocations. | |
Handles memory allocation and deallocation.
Definition at line 51 of file memorymanagement.h.
|
explicit |
Construct a new Memory Manager object. Will switch the pml4 to use the calling process's page tables.
| vmm | The virtual memory manager to use, if nullptr a new one will be created |
Definition at line 99 of file memorymanagement.cpp.
References s_kernel_memory_manager.
| MemoryManager::~MemoryManager | ( | ) |
Destroy the Memory Manager object, frees the VMM if not the kernel memory manager.
Definition at line 112 of file memorymanagement.cpp.
References s_kernel_memory_manager.
|
static |
Frees a block of memory using the current memory manager.
| pointer | The pointer to the block |
Definition at line 150 of file memorymanagement.cpp.
References MaxOS::processes::GlobalScheduler::current_process(), MaxOS::processes::Process::memory_manager, and MaxOS::memory::allocator::BumpAllocator::unallocate().
Referenced by MaxOS::system::SyscallManager::syscall_free_memory().
|
static |
Frees a block of memory using the kernel memory manager.
| pointer | The pointer to the block |
Definition at line 160 of file memorymanagement.cpp.
References s_kernel_memory_manager, and MaxOS::memory::allocator::BumpAllocator::unallocate().
|
static |
Allocates a block of memory in the KERNEL space.
| size | The size of the block |
Definition at line 136 of file memorymanagement.cpp.
References MaxOS::memory::allocator::BumpAllocator::allocate(), and s_kernel_memory_manager.
Referenced by MaxOS::system::Core::Core(), MaxOS::processes::resources::ProcessResourceRegistry::create_resource(), MaxOS::console::FramebufferConsole::FramebufferConsole(), and MaxOS::processes::Thread::Thread().
|
static |
Allocates a block of memory in the current USERSPACE heap.
| size | size of the block |
Definition at line 125 of file memorymanagement.cpp.
References MaxOS::memory::allocator::BumpAllocator::allocate(), MaxOS::processes::GlobalScheduler::current_process(), and MaxOS::processes::Process::memory_manager.
Referenced by MaxOS::processes::resources::ProcessResource::read(), and MaxOS::system::SyscallManager::syscall_allocate_memory().
|
inlinestatic |
The memory manager for any kernel processes and all kernel allocations.
Definition at line 55 of file memorymanagement.h.
Referenced by MaxOS::processes::resources::BridgeHandler::BridgeHandler(), kfree(), kmalloc(), MemoryManager(), MaxOS::processes::GlobalScheduler::prepare_initrd(), MaxOS::processes::Process::Process(), MaxOS::processes::Scheduler::Scheduler(), MaxOS::memory::VirtualMemoryManager::VirtualMemoryManager(), and ~MemoryManager().