1 /* 2 * Copyright (c) 2014 Travis Geiselbrecht 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8 #include <kernel/vm.h> 9 10 #include <lk/trace.h> 11 #include <stdint.h> 12 #include <stdlib.h> 13 #include <sys/types.h> 14 15 #include "vm_priv.h" 16 17 #define LOCAL_TRACE 0 18 19 /* cheezy allocator that chews up space just after the end of the kernel mapping */ 20 21 /* track how much memory we've used */ 22 extern int _end; 23 24 uintptr_t boot_alloc_start = (uintptr_t) &_end; 25 uintptr_t boot_alloc_end = (uintptr_t) &_end; 26 boot_alloc_mem(size_t len)27void *boot_alloc_mem(size_t len) { 28 uintptr_t ptr; 29 30 ptr = ALIGN(boot_alloc_end, 8); 31 boot_alloc_end = (ptr + ALIGN(len, 8)); 32 33 LTRACEF("len %zu, ptr %p\n", len, (void *)ptr); 34 35 return (void *)ptr; 36 } 37 38