KernOS
memoryallocator.h
Go to the documentation of this file.
1 //
2 // Created on 5/26/20.
3 //
4 
5 #ifndef KERNOS_MEMORYALLOCATOR_H
6 #define KERNOS_MEMORYALLOCATOR_H
7 
8 #include <common.h>
9 
10 namespace INIT
11 {
12  void pagetables();
13 }
14 
17 namespace KM // kernel memory
18 {
19  class MemoryAllocator; // forward declare
20 
21  extern MemoryAllocator mem_alloc; // singleton
22 
27  void* kmalloc(size_t Size);
28 
32  void free(void* Ptr);
33 
45  struct [[gnu::aligned(sizeof(uint32_t))]] Header
46  {
47 
48  Header *m_Next;
49  uint32_t m_Size;
50  };
51 
60  {
61  public:
62 
63  uint32_t m_StartAdd = 0;
64  uint32_t m_EndAdd = 0;
65 
66  Header m_Base {nullptr, 0};
67 
72  void Initialize(const uint32_t StartAdd, const uint32_t EndAdd);
73  };
74 
75 
76 } // namespace KM, kernel memory
77 
78 namespace INIT
79 {
80  void KMALLOC();
81 }
82 
83 #endif //KERNOS_MEMORYALLOCATOR_H
MemoryAllocator mem_alloc
void * kmalloc(size_t Size)
kernel malloc
void KMALLOC()
Provides memory allocator with range of reserved memory address to manage.
Manages kernel heap memory.
contains all kernel initialization routines
Definition: cpu.h:10
void free(void *Ptr)
kernel free
Kernel memory namespace.
void pagetables()