chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Core / s / xapp
1 ;
2 ; xapp.s
3 ;
4 ; SDLS stubs for applications
5 ;
6 ; © 1993-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's C library stubs (xstubs).
12 ;
13 ; xstubs 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 ; xstubs 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 xstubs.  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                 IMPORT  |_kernel_init|
35                 IMPORT  |Image$$RO$$Base|
36                 IMPORT  |Image$$RW$$Limit|
37                 IMPORT  |RTSK$$Data$$Base|
38                 IMPORT  |RTSK$$Data$$Limit|
39                 IMPORT  |__root_stack_size|,WEAK
40
41                 IMPORT  xstub__ktable
42                 IMPORT  xstub__ektable
43                 IMPORT  xstub__ctable
44                 IMPORT  xstub__ectable
45                 IMPORT  xstub__kdata
46                 IMPORT  xstub__ekdata
47                 IMPORT  xstub__cdata
48                 IMPORT  xstub__ecdata
49
50 ;----- Exports --------------------------------------------------------------
51
52                 EXPORT  |__main|
53
54 ;----- Initialise the library -----------------------------------------------
55
56                 AREA    |Stub$$Code|,CODE,READONLY
57
58 xstub__stack    EQU     4096                    ;Standard stack size thing
59 xstub__error    EQU     &800E90                 ;Error number base
60 xstub__version  EQU     5                       ;Version number of stubs
61
62                 ENTRY                           ;Start here :-)
63
64 |__main|        SWI     OS_GetEnv               ;Get information about me
65                 MOV     R2,R1                   ;Keep memory limit thing
66                 LDR     R1,=|Image$$RW$$Limit|  ;Point to end of program
67                 MOV     R3,#-1                  ;As required
68                 MOV     R4,#0                   ;As required
69                 MOV     R5,#-1                  ;As required
70                 ADR     R0,xstub__stubs         ;Point to stub descriptions
71                 LDR     R6,=|__root_stack_size| ;Load root stack size
72                 CMP     R6,#0                   ;Has it been specified?
73                 MOVEQ   R6,#xstub__stack        ;No -- substitute a default
74                 LDRNE   R6,[R6]                 ;Otherwise, read the size
75                 MOV     R6,R6,ASR #10           ;Convert to kilobytes
76                 MOV     R6,R6,LSL #16           ;And shift to top halfword
77                 SWI     XSharedCLibrary_LibInitAPCS_R ;Init C library
78                 ADRVS   R0,xstub__noCLib        ;If failed, claim CLib gone
79                 SWIVS   OS_GenerateError        ;And generate the error
80                 CMP     R6,#xstub__version      ;Check returned version
81                 MOVGE   R4,R0                   ;Point to workspae limit
82                 ADRGE   R0,xstub__kernel        ;Point to _kernel_init block
83                 MOVGE   R3,#0                   ;Say we're an application
84                 BGE     |_kernel_init|          ;Start up the kernel!
85                 ADR     R0,xstub__oldCLib       ;Point to error message
86                 SWI     OS_GenerateError        ;Complain about old CLib
87
88 xstub__noCLib   DCD     xstub__error+&00        ;Error number (official)
89                 DCB     "Couldn't find Shared C Library",0
90                 ALIGN
91
92 xstub__oldCLib  DCD     xstub__error+&01        ;Error number (also official)
93                 DCB     "Shared C Library is out of date",0
94                 ALIGN
95
96 ;----- Stub description block -----------------------------------------------
97
98 xstub__stubs
99
100                 ; --- Magic numbers ---
101
102 xstub__krnlID   EQU     1                       ;Kernel's chunk ID
103 xstub__clibID   EQU     2                       ;C library's chunk ID
104
105                 ; --- Kernel section ---
106
107                 DCD     xstub__krnlID
108                 DCD     xstub__ktable
109                 DCD     xstub__ektable
110                 DCD     xstub__kdata
111                 DCD     xstub__ekdata
112
113                 ; --- C library section ---
114
115                 DCD     xstub__clibID
116                 DCD     xstub__ctable
117                 DCD     xstub__ectable
118                 DCD     xstub__cdata
119                 DCD     xstub__ecdata
120
121                 DCD     -1                      ;Terminate the table
122
123 ;----- Kernel description block ---------------------------------------------
124
125 xstub__kernel
126
127                 DCD     |Image$$RO$$Base|
128                 DCD     |RTSK$$Data$$Base|
129                 DCD     |RTSK$$Data$$Limit|
130
131 ;----- That's all folks -----------------------------------------------------
132
133                 END