4 ; Module header for DLL manager
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Dynamic Linking System (SDLS)
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)
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.
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.
27 ;----- Standard stuff -------------------------------------------------------
32 ;----- External dependencies ------------------------------------------------
44 ;----- Magic numbers --------------------------------------------------------
46 hdr_swiChunk EQU &4A300 ;SWI chunk number
48 ;----- Yer actual module header ---------------------------------------------
50 AREA |!!!Module$$Header|,CODE,READONLY
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
64 ;----- Some text strings ----------------------------------------------------
66 hdr_title DCB "DLLManager",0
68 ;----- Initialisation and finalisation --------------------------------------
72 STMFD R13!,{R14} ;Stack anything relevant
74 ; --- Now we allocate some memory ---
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
81 ; --- Store workspace address in private word ---
83 STR R2,[R12] ;Store in private word
84 MOV R12,R2 ;Keep relocation in R12 now
86 ; --- Initialise the workspace ---
88 ; Just zero-init the whole lot.
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
94 ; --- Set up application section ---
96 BL app_init ;Allow app to store PW
100 LDMFD R13!,{PC} ;We are initialised
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
123 ;----- Application entry ----------------------------------------------------
125 hdr_enter EQU 0 ;No module application code
127 ;----- *commands and things -------------------------------------------------
129 ; --- The commands table ---
156 DCD hdr_dll_killapp_c
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
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
193 hdr_dll_info_c LDR R12,[R12] ;Find relocation to data
194 B dll_showInfo ;Go to a routine that can
196 ; --- *DLLKillApp ---
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
208 hdr_dll_reset_c LDR R12,[R12]
221 ;----- SWI stuff ------------------------------------------------------------
223 ; --- SWI name-number translation table ---
225 hdr_swiTable DCB "DLL",0 ;SWI name prefix
228 DCB "FindFromTable",0
235 DCB "SetInstanceVars",0
244 DCB "RestoreHandle",0
245 DCB "FindInstanceVars",0
246 DCB "RegisterAppEntryTable",0
248 DCB "SetExtensionTable",0
253 ; --- Main SWI entry point ---
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
263 B app_findDLL ;DLL_Find
264 B app_fromtable ;DLL_FindFromTable
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
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
287 ADRL R0,msg_errBadSWI ;Point to an error message
288 ORRS PC,R14,#V_flag ;Return an error to OS
292 ; --- Name-number translation code ---
294 hdr_swiCode EQU 0 ;No name-number code
296 ;----- Service call handling ------------------------------------------------
298 hdr_service EQU 0 ;Not interested in these
300 ;----- That's all folks -----------------------------------------------------