2ee739cc |
1 | /* |
2 | * heap.h |
3 | * |
4 | * [Generated from heap, 25 September 1996] |
5 | */ |
6 | |
7 | #if !defined(__CC_NORCROFT) || !defined(__arm) |
8 | #error You must use the Norcroft ARM Compiler for Sapphire programs |
9 | #endif |
10 | |
11 | #pragma include_only_once |
12 | #pragma force_top_level |
13 | |
14 | #ifndef __heap_h |
15 | #define __heap_h |
16 | |
17 | #ifndef __sapphire_h |
18 | #include "sapphire.h" |
19 | #endif |
20 | |
21 | /*----- Overview ----------------------------------------------------------* |
22 | * |
23 | * Functions provided: |
24 | * |
25 | * heap_init |
26 | * heap_useHeap |
27 | * heap_info |
28 | * heap_alloc |
29 | * heap_free |
30 | * heap_reAlloc |
31 | */ |
32 | |
33 | /* --- heap_init --- * |
34 | * |
35 | * On entry: -- |
36 | * |
37 | * On exit: -- |
38 | * |
39 | * Use: Initialises the heap system for use. |
40 | */ |
41 | |
42 | extern routine heap_init; |
43 | |
44 | /* --- heap_useHeap --- * |
45 | * |
46 | * On entry: -- |
47 | * |
48 | * On exit: -- |
49 | * |
50 | * Use: Registers the resizing heap as the current allocator. |
51 | */ |
52 | |
53 | extern routine heap_useHeap; |
54 | |
55 | /* --- heap_info --- * |
56 | * |
57 | * On entry: -- |
58 | * |
59 | * On exit: R0 == current heap size |
60 | * R1 == amount of memory free in the heap |
61 | * R2 == size of the largest block free |
62 | * |
63 | * Use: Describes the heap's current status. |
64 | */ |
65 | |
66 | extern routine heap_info; |
67 | |
68 | /* --- heap_alloc --- * |
69 | * |
70 | * On entry: R0 == size of block wanted |
71 | * |
72 | * On exit: CC if enough memory was found and |
73 | * R0 == pointer to the block allocated |
74 | * else CS and |
75 | * R0 corrupted |
76 | * |
77 | * Use: Allocates a block of at least a given size from a heap. If |
78 | * the heap is not big enough, more is claimed from the |
79 | * operating system. |
80 | */ |
81 | |
82 | extern routine heap_alloc; |
83 | |
84 | /* --- heap_free --- * |
85 | * |
86 | * On entry: R0 == pointer to a block created with heap_alloc |
87 | * |
88 | * On exit: -- |
89 | * |
90 | * Use: Frees a block allocated using heap_alloc. It tries to |
91 | * shrink the heap as much as possible afterwards. |
92 | */ |
93 | |
94 | extern routine heap_free; |
95 | |
96 | /* --- heap_reAlloc --- * |
97 | * |
98 | * On entry: R0 == pointer to block whose size we want to change |
99 | * R1 == the new size of the block |
100 | * |
101 | * On exit: CC if block was resized, and |
102 | * R0 == pointer to the block (which may have moved) |
103 | * else CS and |
104 | * R0 corrupted |
105 | * |
106 | * Use: Changes the size of a heap block. If possible, the block's |
107 | * position is unchanged, but this may not always be the case. |
108 | * |
109 | * Note that changing a block's size to 0 is permitted. |
110 | */ |
111 | |
112 | extern routine heap_reAlloc; |
113 | |
114 | /*----- That's all, folks -------------------------------------------------*/ |
115 | |
116 | #endif |