4 ; Redirectable memory allocation
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Sapphire library.
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Overview -------------------------------------------------------------
38 [ :LNOT::DEF:alloc__dfn
41 ; --- alloc_register ---
43 ; On entry: R0 == pointer to allocator function
44 ; R1 == pointer to free function
45 ; R2 == workspace pointer to pass to them in R12
49 ; Use: Registers two functions to be used as a heap manager by
52 ; The allocator is entered with R0 as the size of block
53 ; required, and should exit with CC and R0 == pointer to the
54 ; block allocated if successful, CS if there wasn't enough
55 ; memory and generate any other errors that occur. Registers
56 ; other than R0 must be preserved.
58 ; The freer is entered with R0 == pointer to block to free.
59 ; It should exit with all registers preserved. If anything
60 ; goes wrong, it should generate an error.
64 ; --- alloc_useOSHeap ---
66 ; On entry: R1 == pointer to OS_Heap-managed heap to use
70 ; Use: Registers an OS_Heap heap to use to allocate memory when
73 IMPORT alloc_useOSHeap
77 ; On entry: R0 == size of block to allocate from current heap
79 ; On exit: R0 == pointer to block and CC if it all worked
80 ; CS if there wasn't enough memory (R0 corrupted)
82 ; Use: Allocates R0 bytes from a heap manager. This routine will
83 ; attempt to allocate memory from the current heaps in order
84 ; of registration (i.e. the Sapphire OS_Heap first etc.) until
85 ; either one which can service the request is found, or all
86 ; the heaps have been tried.
92 ; On entry: R0 == pointer to block allocated by alloc
96 ; Use: Frees a block allocated by alloc, regardless of which heap
107 ; Use: Initialises the alloc system, and sets it up to use the
108 ; kernel-provided OS_Heap area.
112 ; --- alloc_error ---
116 ; On exit: V set and R0 == pointer to an error about not having enough
119 ; Use: Returns an error suitable for displaying to a user if there
120 ; isn't enough memory left.
126 ;----- That's all, folks ----------------------------------------------------