Implement kernel brk

This commit is contained in:
2022-01-10 00:06:31 +01:00
parent 4a2dc7e083
commit 8eaa8e6c8f
6 changed files with 68 additions and 4 deletions

18
src/kernel/memory/kbrk.c Normal file
View File

@@ -0,0 +1,18 @@
#include <memory.h>
#include <debug.h>
static long _brk = KERNEL_BRK0;
long kbrk(long brk, long, long, long, long, long)
{
if(brk)
{
while(_brk < brk) {
vmm_set_page(kernel_P4, _brk, pmm_alloc(), PAGE_WRITE | PAGE_PRESENT);
_brk += PAGE_SIZE;
}
return _brk;
} else {
return _brk;
}
}

View File

@@ -2,6 +2,7 @@
#include <memory.h>
#include <debug.h>
#include <multiboot.h>
#include <musl-glue.h>
uint64_t kernel_P4;
@@ -37,4 +38,6 @@ void memory_init()
pmm_free(p);
}
}
set_syscall_handler(SYSCALL_BRK, &kbrk);
}