4 ; Initialise a Sapphire application and libraries
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 -------------------------------------------------------------
46 [ :LNOT::DEF:sapphire__dfn
49 ; --- sapphire_init ---
51 ; On entry: R0 == pointer to application name
52 ; R1 == application's workspace size
53 ; R2 == size of stack required
55 ; On exit: R10 == pointer to heap base
56 ; R11 == pointer to ScratchPad
57 ; R12 == pointer to application workspace
58 ; R13 == pointer to full descending stack
59 ; Other registers are corrupted
61 ; Use: Initialises the Sapphire kernel, sets up the memory map,
62 ; and allocates workspace for library and client units. The
63 ; initialisation performed is fairly minimal; in particular,
64 ; the library units are not initialised -- you must call
65 ; sapphire_libInit for this to take place. This allows you
66 ; to check command line arguments etc. before initialising
71 ; --- sapphire_disable ---
73 ; On entry: R0 == pointer to 0-terminated list of initialise routines
77 ; Use: Prevents the given initialisation routines from being called.
78 ; This is mainly useful in the dynamic-linking environment,
79 ; where all Sapphire units are normally active. This routine
80 ; allows you to inactivate units which for example do not
81 ; have the resources they require, or use up unnecesary
84 IMPORT sapphire_disable
86 ; --- sapphire_libInit ---
92 ; Use: Initialises the Sapphire library and client units.
94 IMPORT sapphire_libInit
96 ; --- sapphire_doInit ---
98 ; On entry: R0 == pointer to application name
99 ; R1 == client workspace size
100 ; R2 == requested stack size
101 ; R3 == pointer to initialisation table
103 ; On exit: R10 == base address of Sapphire heap
104 ; R11 == pointer to scratchpad and global data
105 ; R12 == pointer to client global workspace
106 ; R13 == pointer to a full descendion stack
108 ; Use: Performs initialisation of the Sapphire library and the
109 ; client's sections. This is intended for use by the Sapphire
110 ; stub, while initialising the dynamically linked version of
113 IMPORT sapphire_doInit
115 ; --- sapphire_doLibInit ---
117 ; On entry: R0 == address of library initialisation table
121 ; Use: Initialises all currently uninitialised library units.
123 IMPORT sapphire_doLibInit
125 ; --- sapphire_doDisable ---
127 ; On entry: R0 == pointer to list of initialise routines to disable
128 ; R1 == pointer to initialisation table
132 ; Use: Prevents the given initialisation routines from being
133 ; called. This is mainly useful in a dynamically linked
136 IMPORT sapphire_doDisable
138 ; --- sapphire_heapAddr ---
142 ; On exit: R1 == pointer to the heap base (for passing to OS_Heap)
144 ; Use: Returns the address of the Sapphire heap.
146 IMPORT sapphire_heapAddr
148 ; --- sapphire_appName ---
152 ; On exit: R0 == pointer to application name (NULL terminated)
154 ; Use: Returns a pointer to the application's name.
156 IMPORT sapphire_appName
158 ; --- sapphire_resetStack ---
162 ; On exit: R13 == stack pointer
164 ; Use: Resets R13 to point to the top of the stack.
166 IMPORT sapphire_resetStack
168 ; --- sapphire_global ---
170 ; On entry: R0 == magic identifier for global variable
171 ; R1 == size of area required
173 ; On exit: R0 == pointer to area
174 ; CS if the area already exists, CC otherwise
176 ; Use: Locates (and creates if necessary) a `named' global area
177 ; which can be used for inter-section communication without
178 ; the necessity for dependencies.
180 ; There is a limit on the number of global areas allowed, but
181 ; this can be raised fairly easily if necessary.
183 ; If an area can't be created, an error is generated.
185 IMPORT sapphire_global
187 ; --- Data relative to R11 ---
190 sapph__R11 # 0 ;Make a symbol for R11
192 sapph_scratchpad EQU sapph__R11-0 ;Scratchpad data area
193 [ :LNOT::DEF: sapph__specialWorkspace
194 sapph_workspace EQU sapph__R11-4 ;Workspace base address
196 sapph_stackBase EQU sapph__R11-8 ;The top of the system stack
197 sapph_heapBase EQU sapph__R11-12 ;Base address of the heap
198 sapph_appName EQU sapph__R11-16 ;Pointer to application name
199 sapph_clientWS EQU sapph__R11-20 ;Address of client's space
201 ; --- Macro: WSPACE ---
203 ; Arguments: addr == address of a word containing the workspace offset
204 ; reg == (optional) destination register -- default is R12
205 ; off == (optional) offset from R11 -- default is -4
207 ; Use: Locates a unit's workspace. The code generated will corrupt
208 ; R14. Therefore you must save this register.
211 $label WSPACE $addr,$reg
213 IMPORT |__sph_workoff|,WEAK
227 ; LDR R14,sapph_workspace
228 DCD |__sph_workoff| + &E51BE004
236 ;----- That's all, folks ----------------------------------------------------