Add new and delete operator implementations to the kernel heap.
For now delete does nothing.
This commit is contained in:
parent
2d719d0443
commit
4380590af2
2 changed files with 22 additions and 2 deletions
|
|
@ -3,8 +3,22 @@
|
|||
#include "debug/debug.h"
|
||||
#include "memory/paging_util.h"
|
||||
|
||||
namespace {
|
||||
|
||||
static KernelHeap* gKernelHeap = nullptr;
|
||||
|
||||
KernelHeap& GetKernelHeap() {
|
||||
if (!gKernelHeap) {
|
||||
panic("Kernel Heap not initialized.");
|
||||
}
|
||||
return *gKernelHeap;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
KernelHeap::KernelHeap(uint64_t lower_bound, uint64_t upper_bound)
|
||||
: next_addr_(lower_bound), upper_bound_(upper_bound) {}
|
||||
: next_addr_(lower_bound), upper_bound_(upper_bound) {
|
||||
gKernelHeap = this;
|
||||
}
|
||||
|
||||
void* KernelHeap::Allocate(uint64_t size) {
|
||||
if (next_addr_ + size >= upper_bound_) {
|
||||
|
|
@ -15,3 +29,7 @@ void* KernelHeap::Allocate(uint64_t size) {
|
|||
next_addr_ += size;
|
||||
return reinterpret_cast<void*>(address);
|
||||
}
|
||||
|
||||
void* operator new(uint64_t size) { return GetKernelHeap().Allocate(size); }
|
||||
|
||||
void operator delete(void*, uint64_t) {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue