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