diff options
Diffstat (limited to 'sys/vm/vm_init.c')
-rw-r--r-- | sys/vm/vm_init.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/vm/vm_init.c b/sys/vm/vm_init.c index 3e9718d..703942b 100644 --- a/sys/vm/vm_init.c +++ b/sys/vm/vm_init.c @@ -28,16 +28,40 @@ */ #include <sys/limine.h> +#include <sys/panic.h> #include <vm/vm.h> #include <vm/physmem.h> +#include <assert.h> +#define DYNALLOC_POOL_SZ 0x400000 /* 4 MiB */ +#define DYNALLOC_POOL_PAGES (DYNALLOC_POOL_SZ / DEFAULT_PAGESIZE) + +static struct vm_ctx vm_ctx; volatile struct limine_hhdm_request g_hhdm_request = { .id = LIMINE_HHDM_REQUEST, .revision = 0 }; +struct vm_ctx * +vm_get_ctx(void) +{ + return &vm_ctx; +} + void vm_init(void) { + void *pool; + vm_physmem_init(); + + vm_ctx.dynalloc_pool_sz = DYNALLOC_POOL_SZ; + vm_ctx.dynalloc_pool_pa = vm_alloc_frame(DYNALLOC_POOL_PAGES); + if (vm_ctx.dynalloc_pool_pa == 0) { + panic("Failed to allocate dynamic pool\n"); + } + + pool = PHYS_TO_VIRT(vm_ctx.dynalloc_pool_pa); + vm_ctx.tlsf_ctx = tlsf_create_with_pool(pool, DYNALLOC_POOL_SZ); + __assert(vm_ctx.tlsf_ctx != 0); } |