X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/fef29e9e993e62f025d8cbfeb6b8d51588083b7e..48b4a227035048fdebcd32532deb7a857c6199ac:/lunaix-os/kernel/mm/kalloc.c diff --git a/lunaix-os/kernel/mm/kalloc.c b/lunaix-os/kernel/mm/kalloc.c index e9f0564..91905b4 100644 --- a/lunaix-os/kernel/mm/kalloc.c +++ b/lunaix-os/kernel/mm/kalloc.c @@ -23,8 +23,6 @@ extern uint8_t __kernel_heap_start; -static heap_context_t __kalloc_kheap; - void* lx_malloc_internal(heap_context_t* heap, size_t size); @@ -61,24 +59,25 @@ lx_grow_heap(heap_context_t* heap, size_t sz); int kalloc_init() { - __kalloc_kheap.start = &__kernel_heap_start; - __kalloc_kheap.brk = NULL; - __kalloc_kheap.max_addr = (void*)K_STACK_START; + heap_context_t* kheap = &__current->mm.k_heap; + kheap->start = &__kernel_heap_start; + kheap->brk = NULL; + kheap->max_addr = (void*)KSTACK_START; - if (!dmm_init(&__kalloc_kheap)) { + if (!dmm_init(kheap)) { return 0; } - SW(__kalloc_kheap.start, PACK(4, M_ALLOCATED)); - SW(__kalloc_kheap.start + WSIZE, PACK(0, M_ALLOCATED)); - __kalloc_kheap.brk += WSIZE; + SW(kheap->start, PACK(4, M_ALLOCATED)); + SW(kheap->start + WSIZE, PACK(0, M_ALLOCATED)); + kheap->brk += WSIZE; - return lx_grow_heap(&__kalloc_kheap, HEAP_INIT_SIZE) != NULL; + return lx_grow_heap(kheap, HEAP_INIT_SIZE) != NULL; } void* lxmalloc(size_t size) { - return lx_malloc_internal(&__kalloc_kheap, size); + return lx_malloc_internal(&__current->mm.k_heap, size); } void*