1 /* 2 * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include <OS.h> 7 8 #include <boot/platform.h> 9 #include <boot/heap.h> 10 #include <boot/stdio.h> 11 #include <platform/openfirmware/openfirmware.h> 12 13 14 #define TRACE_HEAP 1 15 #if TRACE_HEAP 16 # define TRACE(x) printf x 17 #else 18 # define TRACE(x) ; 19 #endif 20 21 22 status_t 23 platform_init_heap(stage2_args *args, void **_base, void **_top) 24 { 25 TRACE(("platform_init_heap()\n")); 26 27 *_base = NULL; 28 status_t error = platform_allocate_region(_base, args->heap_size, 29 B_READ_AREA | B_WRITE_AREA, false); 30 if (error != B_OK) 31 return error; 32 33 printf("heap base = %p\n", *_base); 34 *_top = (void *)((int8 *)*_base + args->heap_size); 35 printf("heap top = %p\n", *_top); 36 37 return B_OK; 38 } 39 40 41 void 42 platform_release_heap(stage2_args *args, void *base) 43 { 44 if (base != NULL) 45 platform_free_region(base, args->heap_size); 46 } 47 48