chiark / gitweb /
Initial revision
[ssr] / StraySrc / SDLS / DLLManager / s / dheader
1 ;
2 ; dheader.s
3 ;
4 ; Module header for DLL manager
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Dynamic Linking System (SDLS)
12 ;
13 ; SDLS 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)
16 ; any later version.
17 ;
18 ; SDLS 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.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with SDLS.  If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Standard stuff -------------------------------------------------------
28
29                 GET     libs:header
30                 GET     libs:swis
31
32 ;----- External dependencies ------------------------------------------------
33
34                 GET     sh.wSpace
35
36                 GET     sh.misc
37                 GET     sh.dll
38                 GET     sh.app
39                 GET     sh.suballoc
40                 GET     sh.messages
41
42                 IMPORT  hdr_help
43
44 ;----- Magic numbers --------------------------------------------------------
45
46 hdr_swiChunk    EQU     &4A300                  ;SWI chunk number
47
48 ;----- Yer actual module header ---------------------------------------------
49
50                 AREA    |!!!Module$$Header|,CODE,READONLY
51
52                 DCD     hdr_enter               ;Module application code
53                 DCD     hdr_init                ;Module initialisation code
54                 DCD     hdr_final               ;Module finalisation code
55                 DCD     hdr_service             ;Module service call code
56                 DCD     hdr_title               ;Module title
57                 DCD     hdr_help                ;Module version string
58                 DCD     hdr_commands            ;Module *command table
59                 DCD     hdr_swiChunk            ;Module SWI chunk number
60                 DCD     hdr_swiHandler          ;Module SWI handler code
61                 DCD     hdr_swiTable            ;Module SWI name table
62                 DCD     hdr_swiCode             ;Module SWI name code
63
64 ;----- Some text strings ----------------------------------------------------
65
66 hdr_title       DCB     "DLLManager",0
67
68 ;----- Initialisation and finalisation --------------------------------------
69
70 hdr_init        ROUT
71
72                 STMFD   R13!,{R14}              ;Stack anything relevant
73
74                 ; --- Now we allocate some memory ---
75
76                 MOV     R0,#6                   ;Better allocate some memory
77                 LDR     R3,=dm__wSize           ;Get the length of the data
78                 SWI     XOS_Module              ;Try to allocate the memory
79                 LDMVSFD R13!,{PC}               ;If no memory, quit now
80
81                 ; --- Store workspace address in private word ---
82
83                 STR     R2,[R12]                ;Store in private word
84                 MOV     R12,R2                  ;Keep relocation in R12 now
85
86                 ; --- Initialise the workspace ---
87                 ;
88                 ; Just zero-init the whole lot.
89
90                 MOV     R0,R2                   ;Point to base of area
91                 ADD     R1,R2,R3                ;Find add length to get limit
92                 BL      misc_zinit              ;Zero-init the whole lot
93
94                 ; --- Set up application section ---
95
96                 BL      app_init                ;Allow app to store PW
97
98                 ; --- Tha's it ---
99
100                 LDMFD   R13!,{PC}               ;We are initialised
101
102                 LTORG
103
104 hdr_final       ROUT
105
106                 STMFD   R13!,{R12,R14}          ;Keep hold of the link
107                 LDR     R12,[R12]               ;Get relocation offset
108                 BL      app_checkQuit           ;Make sure we can quit
109                 LDMVSFD R13!,{R12,PC}           ;If not, return the error
110                 BL      dll_freeAll             ;Remove DLLs in memory
111                 BL      app_killAll             ;Remove application blocks
112                 BL      sub_die                 ;Remove link blocks
113                 MOV     R2,R12                  ;Point to workspace
114                 MOV     R0,#7                   ;Free the workspace
115                 SWI     XOS_Module              ;Do it!
116                 LDMFD   R13!,{R12}              ;Get back private word ptr
117                 MOV     R0,#0                   ;Now zero out private word
118                 STR     R0,[R12]                ;Right, now that's done
119                 LDMFD   R13!,{PC}               ;Return to OS
120
121                 LTORG
122
123 ;----- Application entry ----------------------------------------------------
124
125 hdr_enter       EQU     0                       ;No module application code
126
127 ;----- *commands and things -------------------------------------------------
128
129 ; --- The commands table ---
130
131 hdr_commands
132
133                 DCB     "DLLs",0
134                 ALIGN
135                 DCD     hdr_dlls_c
136                 DCB     0,0,1,0
137                 DCD     synt_DLLs
138                 DCD     help_DLLs
139
140                 DCB     "DLLApps",0
141                 ALIGN
142                 DCD     hdr_dll_apps_c
143                 DCB     0,0,1,0
144                 DCD     synt_DLLApps
145                 DCD     help_DLLApps
146
147                 DCB     "DLLInfo",0
148                 ALIGN
149                 DCD     hdr_dll_info_c
150                 DCB     1,0,2,0
151                 DCD     synt_DLLInfo
152                 DCD     help_DLLInfo
153
154                 DCB     "DLLKillApp",0
155                 ALIGN
156                 DCD     hdr_dll_killapp_c
157                 DCB     1,0,1,0
158                 DCD     synt_DLLKillApp
159                 DCD     help_DLLKillApp
160
161                 DCB     "DLLReset",0
162                 ALIGN
163                 DCD     hdr_dll_reset_c
164                 DCB     0,0,0,0
165                 DCD     synt_DLLReset
166                 DCD     help_DLLReset
167
168                 DCB     "DLLEnsure",0
169                 ALIGN
170                 DCD     hdr_dll_ensure_c
171                 DCB     2,0,2,0
172                 DCD     synt_DLLEnsure
173                 DCD     help_DLLEnsure
174
175                 DCD     0
176
177 ; --- *DLLs ---
178
179 hdr_dlls_c      LDR     R12,[R12]               ;Find relocation offset
180                 CMP     R1,#0                   ;Did he give arguments?
181                 BEQ     dll_list                ;Display a list of DLLs
182                 B       app_listDLLs
183
184 ; --- *DLLApps ---
185
186 hdr_dll_apps_c  LDR     R12,[R12]               ;Load data relocation
187                 CMP     R1,#0                   ;Did he give arguments?
188                 BEQ     app_list                ;Display the list
189                 B       app_listUsing
190
191 ; --- *DLLInfo ---
192
193 hdr_dll_info_c  LDR     R12,[R12]               ;Find relocation to data
194                 B       dll_showInfo            ;Go to a routine that can
195
196 ; --- *DLLKillApp ---
197
198 hdr_dll_killapp_c
199                 LDR     R12,[R12]               ;Find relocation to data
200                 STMFD   R13!,{R14}              ;Keep return address safe
201                 BL      app_findNamed           ;Find the application named
202                 LDMFD   R13!,{R14}              ;Get return address back
203                 BVC     app_kill                ;If no error, kill the app
204                 ORRS    PC,R14,#V_flag          ;Return to caller with error
205
206 ; --- *DLLReset ---
207
208 hdr_dll_reset_c LDR     R12,[R12]
209                 STMFD   R13!,{R14}
210                 BL      sub_die
211                 BL      dll_freeAll
212                 LDMFD   R13!,{R14}
213                 B       app_killAll
214
215 ; --- *DLLEnsure ---
216
217 hdr_dll_ensure_c
218                 LDR     R12,[R12]
219                 B       dll_check
220
221 ;----- SWI stuff ------------------------------------------------------------
222
223 ; --- SWI name-number translation table ---
224
225 hdr_swiTable    DCB     "DLL",0                 ;SWI name prefix
226
227                 DCB     "Find",0
228                 DCB     "FindFromTable",0
229                 DCB     "Load",0
230                 DCB     "Lose",0
231                 DCB     "AppDying",0
232                 DCB     "GiveCLibData",0
233                 DCB     "FindCLibData",0
234                 DCB     "InstanceVars",0
235                 DCB     "SetInstanceVars",0
236                 DCB     "AppData",0
237                 DCB     "Prologue",0
238                 DCB     "ReadStackPtr",0
239                 DCB     "SetStackPtr",0
240                 DCB     "NameApp",0
241                 DCB     "Info",0
242                 DCB     "FindEntry",0
243                 DCB     "SaveHandle",0
244                 DCB     "RestoreHandle",0
245                 DCB     "FindInstanceVars",0
246                 DCB     "RegisterAppEntryTable",0
247                 DCB     "FindAppEntry",0
248                 DCB     "SetExtensionTable",0
249
250                 DCB     0                       ;End of list
251                 ALIGN
252
253 ; --- Main SWI entry point ---
254
255 hdr_swiHandler  ROUT
256
257                 LDR     R12,[R12]               ;Get workspace relocation
258                 CMP     R11,#(%01hdr_swiHandler-%00hdr_swiHandler)/4
259                 ADDCC   PC,PC,R11,LSL #2        ;Branch to correct handler
260                 B       %01hdr_swiHandler       ;If SWI out of range, error
261
262 00hdr_swiHandler
263                 B       app_findDLL             ;DLL_Find
264                 B       app_fromtable           ;DLL_FindFromTable
265                 B       dll_load                ;DLL_Load
266                 B       app_loseDLL             ;DLL_Lose
267                 B       app_dying               ;DLL_AppDying
268                 B       app_giveclib            ;DLL_GiveCLibData
269                 B       app_findclib            ;DLL_FindCLibData
270                 B       app_instvars            ;DLL_InstanceVars
271                 B       dll_instvars            ;DLL_SetInstanceVars
272                 B       app_appdata             ;DLL_AppData
273                 B       app_prologue            ;DLL_Prologue
274                 B       app_readstkptr          ;DLL_ReadStackPtr
275                 B       app_setstkptr           ;DLL_SetStackPtr
276                 B       app_setname             ;DLL_NameApp
277                 B       dll_info                ;DLL_Info
278                 B       dll_findEntry           ;DLL_FindEntry
279                 B       app_getHandle           ;DLL_SaveHandle
280                 B       app_restoreHandle       ;DLL_RestoreHandle
281                 B       dll_findWorkspace       ;DLL_FindInstanceVars
282                 B       app_setBtable           ;DLL_RegisterAppEntryTable
283                 B       app_appEntry            ;DLL_FindAppEntry
284                 B       app_fixExtension        ;DLL_SetExtensionTable
285
286 01hdr_swiHandler
287                 ADRL    R0,msg_errBadSWI        ;Point to an error message
288                 ORRS    PC,R14,#V_flag          ;Return an error to OS
289
290                 LTORG
291
292 ; --- Name-number translation code ---
293
294 hdr_swiCode     EQU     0                       ;No name-number code
295
296 ;----- Service call handling ------------------------------------------------
297
298 hdr_service     EQU     0                       ;Not interested in these
299
300 ;----- That's all folks -----------------------------------------------------
301
302                 END