bond/x64/src/kernel/k_alloc.c
secXsQuared 8da028f518 Eventually went with not using in-place linked list for PMM (Don't really want to mix up PMM and VMM).
So yeah, now keep trace of those physical pages on kernel heap, Windows does that, linux does that, I have to do that since there are more attributes(paged/non-paged) that the kernel requires.
Hmm finished PMM alpha and redefined all those PMM/VMM interfaces.
The code is still broken right now.
2016-06-25 00:25:54 -07:00

30 lines
561 B
C

#include "g_abi.h"
#include "k_alloc.h"
#include "salloc.h"
#define K_KERNEL_HEAP_SIZE 8192
static _Bool _k_alloc_initialized;
static uint8_t _k_alloc_heap[K_KERNEL_HEAP_SIZE];
void KAPI k_alloc_init()
{
if(!_k_alloc_initialized)
{
salloc_init(_k_alloc_heap, K_KERNEL_HEAP_SIZE);
_k_alloc_initialized = true;
}
}
void* KAPI k_alloc(uint32_t size)
{
return _k_alloc_initialized ? salloc(_k_alloc_heap, size) : NULL;
}
void KAPI k_free(void* ptr)
{
if(_k_alloc_initialized)
{
sfree(_k_alloc_heap, ptr);
}
}