Initial revision
[ssr] / StraySrc / Dynamite / dynamite / sh / dynHeap
1 ;
2 ; dynHeap.sh
3 ;
4 ; New heap management for Dynamite
5 ;
6 ; © 1994 Straylight
7 ;
8
9 ;----- Overview -------------------------------------------------------------
10 ;
11 ; Functions provided:
12 ;
13 ; dh_alloc
14 ; dh_free
15 ; dh_freeWithID
16 ; dh_blockInfo
17 ; dh_changeID
18 ; dh_reduce
19 ; dh_compact
20 ; dh_lock
21 ; dh_unlock
22 ; dh_save
23 ; dh_load
24 ; dh_extend
25 ; dh_midExtend
26 ; dh_checkHeap
27 ; dh_changeAnchor
28 ; dh_dump
29
30 [ :LNOT::DEF:dynHeap__dfn
31 GBLL dynHeap__dfn
32
33 ; --- dh_alloc ---
34 ;
35 ; On entry: R0 == pointer to anchor
36 ; R1 == size to allocate in bytes
37 ; R2 == ID value to store
38 ;
39 ; On exit: R0 and R1 preserved
40 ; R2 == address of block allocated
41 ;
42 ; Use: Allocates a block from the Dynamite heap.
43
44 IMPORT dh_alloc
45
46 ; --- dh_free ---
47 ;
48 ; On entry: R0 == pointer to anchor of block to free
49 ;
50 ; On exit: --
51 ;
52 ; Use: Frees a Dynamite block.
53
54 IMPORT dh_free
55
56 ; --- dh_freeWithID ---
57 ;
58 ; On entry: R0 == ID of all blocks to free
59 ;
60 ; On exit: --
61 ;
62 ; Use: Frees all allocated blocks with a given ID number.
63
64 IMPORT dh_freeWithID
65
66 ; --- dh_blockInfo ---
67 ;
68 ; On entry: R0 == address of block anchor
69 ;
70 ; On exit: R0 preserved
71 ; R1 == address of block
72 ; R2 == size of block
73 ; R3 == block ID
74 ;
75 ; Use: Returns information about a Dynamite block
76
77 IMPORT dh_blockInfo
78
79 ; --- dh_changeID ---
80 ;
81 ; On entry: R0 == address of anchor block, or 0 for all
82 ; R1 == new ID
83 ; R2 == old ID (if R0 == 0)
84 ;
85 ; On exit: --
86 ;
87 ; Use: This call is use to change the ID of either an individual
88 ; block (R0 == address of anchor), or the ID of all the
89 ; blocks with the ID passed in R2 (if R0 == 0).
90
91 IMPORT dh_changeID
92
93 ; --- dh_reduce ---
94 ;
95 ; On entry: --
96 ;
97 ; On exit: CS if there was nothing we could do
98 ;
99 ; Use: Tries to shunt the free space in the heap off the end and
100 ; back into the operating system's free pool. It does it a
101 ; little bit and then stops, rather like those workmen on the
102 ; M40.
103
104 IMPORT dh_reduce
105
106 ; --- dh_compact ---
107 ;
108 ; On entry: --
109 ;
110 ; On exit: --
111 ;
112 ; Use: Does a full compaction of the heap.
113
114 IMPORT dh_compact
115
116 ; --- dh_lock ---
117 ;
118 ; On entry: --
119 ;
120 ; On exit: R10 corrupted (SWIs don't care about this)
121 ;
122 ; Use: Locks the heap, so that compaction entirely fails to happen.
123
124 IMPORT dh_lock
125
126 ; --- dh_unlock ---
127 ;
128 ; On entry: --
129 ;
130 ; On exit: R10 corrupted (SWIs don't care about this)
131 ;
132 ; Use: Unlocks the heap, so that compaction can happen again, maybe.
133
134 IMPORT dh_unlock
135
136 ; --- dh_save ---
137 ;
138 ; On entry: R0 == mask of registers to save
139 ;
140 ; On exit: R10, R11 corrupted
141 ;
142 ; Use: Saves a load of registers on the Dynamite relocation stack.
143 ; The mask in R0 contains a bit set for each register to save:
144 ; bit 3 set means save R3 etc. Since this is a SWI, only
145 ; R1-R9 can be saved on the stack.
146
147 IMPORT dh_save
148
149 ; --- dh_load ---
150 ;
151 ; On entry: R0 == mask of registers to load
152 ;
153 ; On exit: R10, R11 corrupted
154 ;
155 ; Use: Loads a load of registers on the Dynamite relocation stack.
156 ; The mask in R0 contains a bit set for each register to load:
157 ; bit 3 set means load R3 etc. Since this is a SWI, only
158 ; R1-R9 can be read from the stack.
159
160 IMPORT dh_load
161
162 ; --- dh_extend ---
163 ;
164 ; On entry: R0 == address of block anchor
165 ; R1 == new size for block
166 ;
167 ; On exit: R0 preserved
168 ; R1 == address of block, may have moved
169 ;
170 ; Use: Changes the size of a block.
171
172 IMPORT dh_extend
173
174 ; --- dh_midExtend ---
175 ;
176 ; On entry: R0 == address of block anchor
177 ; R1 == byte offset from block start
178 ; R2 == number of bytes to insert
179 ;
180 ; On exit: R0 preserved
181 ; R1 == address of block, may have moved
182 ;
183 ; Use: Inserts or removes bytes at a given offset into a Dynamite
184 ; heap block.
185
186 IMPORT dh_midExtend
187
188 ; --- dh_checkHeap ---
189 ;
190 ; On entry: --
191 ;
192 ; On exit: May return an error
193 ;
194 ; Use: Checks the current internal format of the heap to make
195 ; sure that it hasn't been corrupted in any way.
196 ; If the integrity check fails then an error is returned.
197
198 IMPORT dh_checkHeap
199
200 ; --- dh_changeAnchor ---
201 ;
202 ; On entry: R0 == pointer to anchor for block
203 ; R1 == address of new anchor
204 ;
205 ; On exit: --
206 ;
207 ; Use: Adjusts a block's anchor, in case it moves.
208
209 IMPORT dh_changeAnchor
210
211 ; --- dh_dump ---
212 ;
213 ; On entry: --
214 ;
215 ; On exit: --
216 ;
217 ; Use: Outputs a textual description of the dynamite heap, giving
218 ; details of each block within it.
219
220 IMPORT dh_dump
221
222 ]
223
224 ;----- That's all, folks ----------------------------------------------------
225
226 END