xref: /haiku/src/system/boot/platform/openfirmware/heap.cpp (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
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 status_t
24 platform_init_heap(stage2_args *args, void **_base, void **_top)
25 {
26 	TRACE(("platform_init_heap()\n"));
27 
28 	*_base = NULL;
29 	status_t error = platform_allocate_region(_base, args->heap_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 	*_top = (void *)((int8 *)*_base + args->heap_size);
36 	printf("heap top = %p\n", *_top);
37 
38 	return B_OK;
39 }
40 
41 
42 void
43 platform_release_heap(stage2_args *args, void *base)
44 {
45 	if (base != NULL)
46 		platform_free_region(base, args->heap_size);
47 }
48 
49