X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/61bcf0c65dac58d2f29ab40e016489c89ec8eec0..e8e64a4f1d76aaeac3defa13243505cccd25c078:/lunaix-os/kernel/mm/kalloc.c diff --git a/lunaix-os/kernel/mm/kalloc.c b/lunaix-os/kernel/mm/kalloc.c index 3aba61e..6b5b878 100644 --- a/lunaix-os/kernel/mm/kalloc.c +++ b/lunaix-os/kernel/mm/kalloc.c @@ -13,6 +13,7 @@ */ #include #include +#include #include #include @@ -58,15 +59,23 @@ lx_grow_heap(heap_context_t* heap, size_t sz); Note: the brk always point to the beginning of epilogue. */ -// FIXME: This should be per-process but not global! static heap_context_t kheap; int kalloc_init() { - kheap.start = &__kernel_heap_start; + kheap.start = KHEAP_START; kheap.brk = NULL; - kheap.max_addr = (void*)KSTACK_START; + kheap.max_addr = + (void*)PROC_START; // 在新的布局中,堆结束的地方即为进程表开始的地方 + + for (size_t i = 0; i < KHEAP_SIZE_MB >> 2; i++) { + vmm_set_mapping(PD_REFERENCED, + (uintptr_t)kheap.start + (i << 22), + 0, + PG_PREM_RW, + VMAP_NOMAP); + } if (!dmm_init(&kheap)) { return 0;