Interface 8.81 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
; Copyright 1998 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; **************************************************
;
; !Lanman.s.interface
;
; All those horrible little assembler bits
;
; Original based on FSinC
; 20-10-94  IH  Add suicide callback bit
;               Add 'free' veneer
; 26-01-96      Add CollectCallbacks
; **************************************************

Stewart Brodie's avatar
Stewart Brodie committed
27 28 29 30 31 32
        GET   Hdr:ListOpts
        GET   Hdr:Macros
        GET   Hdr:System
        GET   Hdr:Machine.<Machine>
        GET   Hdr:APCS.<APCS>
        GET   Hdr:ResourceFS
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

        ; ---------------------------

SWIClass        SETS    "LanMan"

        ^       &49240
        AddSWI  OmniOp  ; &49240
        AddSWI  FreeOp  ; &49241

        ; -----------------------------

        IMPORT  |Image$$RO$$Base|
        IMPORT  |_Lib$Reloc$Off$DP|
        IMPORT  fsentry_open
        IMPORT  fsentry_getbytes
        IMPORT  fsentry_putbytes
        IMPORT  fsentry_args
        IMPORT  fsentry_close
        IMPORT  fsentry_file
        IMPORT  fsentry_func
        IMPORT  fsentry_gbpb

        EXPORT  veneer_fsentry_open
        EXPORT  veneer_fsentry_getbytes
        EXPORT  veneer_fsentry_putbytes
        EXPORT  veneer_fsentry_args
        EXPORT  veneer_fsentry_close
        EXPORT  veneer_fsentry_file
        EXPORT  veneer_fsentry_func
        EXPORT  veneer_fsentry_gbpb

        AREA    FSEntry_Interfaces,REL,CODE,READONLY

        LTORG

veneer_fsentry_open
        STMFD   SP!, {R8}
        MOV     R8, #fsentry_branchtable - %F10 + 4*0
        B       fsentry_common
veneer_fsentry_getbytes
        STMFD   SP!, {R8}
        MOV     R8, #fsentry_branchtable - %F10 + 4*1
        B       fsentry_common
veneer_fsentry_putbytes
        STMFD   SP!, {R8}
        MOV     R8, #fsentry_branchtable - %F10 + 4*2
        B       fsentry_common
veneer_fsentry_args
        STMFD   SP!, {R8}
        MOV     R8, #fsentry_branchtable - %F10 + 4*3
        B       fsentry_common
veneer_fsentry_close
        STMFD   SP!, {R8}
        MOV     R8, #fsentry_branchtable - %F10 + 4*4
        B       fsentry_common
veneer_fsentry_file
        STMFD   SP!, {R8}
        MOV     R8, #fsentry_branchtable - %F10 + 4*5
        B       fsentry_common
veneer_fsentry_func
        STMFD   SP!, {R8}
        MOV     R8, #fsentry_branchtable - %F10 + 4*6
        B       fsentry_common
veneer_fsentry_gbpb
        STMFD   SP!, {R8}
        MOV     R8, #fsentry_branchtable - %F10 + 4*7
        B       fsentry_common


fsentry_common  ; os_error *fsentry_common( Parameter_Block * )

        ; Store the input registers onto the stack
        STMFD   SP!,{R0-R7, SL, FP, IP, LR}

        MOV     sl, SP, LSR #20
        MOV     sl, sl, LSL #20         ; SP_LWM
        LDMIA   sl, {v1, v2}            ; save old reloc modifiers over fn call
        LDR     r12, [r12]              ; private word pointer
        LDMIB   r12, {fp, r12}          ; new relocation modifiers
        STMIA   sl,  {fp, r12}          ; set by module init
        MOV     fp, #0                  ; halt C backtrace here!

        ; This is equivalent of 'ADD r10, r10, #0' + |_Lib$Reloc$Off$DP|
        DCD     |_Lib$Reloc$Off$DP| + &E28AA000

        ; Pass a pointer to the structure on the stack
        MOV     a1, SP

        ; BL    fsentry_branchtable[R8]
        MOV     lr, pc
        ADD     pc, pc, R8

        ; This is equivalent of 'SUB r10, r10, #0' + |_Lib$Reloc$Off$DP|
        DCD     |_Lib$Reloc$Off$DP| + &E24AA000

128
10      ; This label must be the 2nd instruction past the above ADD pc, pc, R8
129 130 131 132 133 134 135 136 137 138 139

        STMIA   sl, {v1, v2}            ; restore old reloc modifiers

        ; Save the returned value in R8
        MOVS    R8, r0
        ; Get the stuff off the stack
        LDMFD   SP!, {r0-r7, sl, fp, ip, lr}
        ; If returned value indicates an error, then set the overflow and put it back in r0
        MOVNE   r0, R8

        ; Mess about with the flag bits in R8
Stewart Brodie's avatar
Stewart Brodie committed
140 141 142 143
        [ :LNOT: No32bitCode
        ; If we're allowed to use 32-bit code, it all falls out really nicely
        MOVNE   R8, #V_bit              ; R8 == 0 if Z, V set if !Z
        |
144 145 146
        MOV     R8, pc
        BIC     R8, R8, #C_bit + V_bit
        ORRNE   R8, R8, #V_bit          ; V = err != 0
Stewart Brodie's avatar
Stewart Brodie committed
147
        ]
148 149 150 151
        TST     r1, r1                  ; C = r1 == 0
        ORREQ   R8, R8, #C_bit

        ; Move the flag bits into psr
Stewart Brodie's avatar
Stewart Brodie committed
152 153 154
        [ :LNOT: No32bitCode
        MSR     CPSR_f, r8
        |
155
        TEQP    R8, #0
Stewart Brodie's avatar
Stewart Brodie committed
156 157
        NOP
        ]
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184

        LDMFD   SP!, {R8}

        MOV     pc, lr

fsentry_branchtable
        B       fsentry_open
        B       fsentry_getbytes
        B       fsentry_putbytes
        B       fsentry_args
        B       fsentry_close
        B       fsentry_file
        B       fsentry_func
        B       fsentry_gbpb

; Suicide callback --------------------------------------------------

        AREA    |C$$code|, CODE, READONLY


; This is used when we get a service call to terminate the module.
; For some reason, we can't terminate there and then, so it has to
; be done on a callback.

        EXPORT   OmniS_Suicide

OmniS_Suicide ; (char *modulename)
Stewart Brodie's avatar
Stewart Brodie committed
185
        FunctionEntry
186 187 188
        MOV     r1, r0                  ; save module_title address (called as r12)
        ADR     r0, suicide_cb
        SWI     XOS_AddCallBack
Stewart Brodie's avatar
Stewart Brodie committed
189
        Return
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206

suicide_cb
        STMFD   SP!, {r0-r1, r14}
        MOV     r0, #4                  ; kill named module
        MOV     r1, r12
        SWI     XOS_Module
        LDMFD   SP!, {r0-r1, r14}
        MOV     pc, r14

; Free routine -------------------------------------------

; This is the routine which is passed to Free_Register. It has
; a number of particularly poor characteristics like being called
; in user mode with little or no stack, and returning a value
; in the Z bit. For this reason the routine calls our 'FreeOp'
; SWI.

Stewart Brodie's avatar
Stewart Brodie committed
207 208 209 210 211
; Free module only worried about V and Z, doesn't mind C and N being
; corrupted.  Removed all the unnecessary flag todging and non-32-bit
; friendly code: V is already set correctly, the TEQ sets the Z as
; required.  Yes, the return value is already stacked. (sbrodie: 19/11/99)

212 213 214 215 216
        EXPORT   Free_ServiceRoutine

Free_ServiceRoutine ; On entry R0 = reason code 0-3
        STMFD  SP!, {R1, R4}
        SWI    XLanMan_FreeOp
Stewart Brodie's avatar
Stewart Brodie committed
217 218
        TEQ    R1,#0                    ; set Z if R1 was 0 on exit, preserve V
        LDMFD  SP!, {R1, R4, PC}        ; As it says in book
219

220 221
        DCB "Nothing libellous or obscene", 0 ; Contractual obligation
        ALIGN
222 223 224

; Collect callbacks routine ------------------------------

Stewart Brodie's avatar
Stewart Brodie committed
225 226 227
; Long multiplier ----------------------------------------
; Taken from Acorn Assembler manual.
; extern void OmniS_FastMultiply64(fspc_64 *, unsigned, unsigned);
228
        EXPORT OmniS_FastMultiply64
Stewart Brodie's avatar
Stewart Brodie committed
229 230

OmniS_FastMultiply64
Stewart Brodie's avatar
Stewart Brodie committed
231
        FunctionEntry
232 233 234 235 236 237 238 239 240 241 242 243 244 245
        MOVS    lr, a2, LSR #16
        BIC     a2, a2, lr, LSL #16
        MOV     ip, a3, LSR #16
        BIC     a3, a3, ip, LSL #16
        MUL     a4, a2, a3
        MUL     a3, lr, a3
        MUL     a2, ip, a2
        MULNE   lr, ip, lr
        ADDS    a2, a2, a3
        ADDCS   lr, lr, #&10000
        ADDS    a4, a4, a2, LSL #16
        ADC     lr, lr, a2, LSR #16
        STMIA   a1, {a4, lr}
        Return
Stewart Brodie's avatar
Stewart Brodie committed
246 247 248



249 250 251 252 253 254 255 256 257 258 259
; Resources ----------------------------------------------

; This is Acorn's sorry excuse for the lack of a resource compiler.

        EXPORT  OmniS_ResourceInit
        EXPORT  OmniS_ResourceShutdown
        EXPORT  OmniS_ResFSStarting

; Register & Deregister routines for our ResourceFS block

OmniS_ResourceInit ; (void)
Stewart Brodie's avatar
Stewart Brodie committed
260
        FunctionEntry
261 262 263
        ADR     r0, Resource_Base
        SWI     XResourceFS_RegisterFiles
        MOVVC   r0, #0
Stewart Brodie's avatar
Stewart Brodie committed
264
        Return
265 266

OmniS_ResourceShutdown ; (void)
Stewart Brodie's avatar
Stewart Brodie committed
267
        FunctionEntry
268 269 270
        ADR     r0, Resource_Base
        SWI     XResourceFS_DeregisterFiles
        MOVVC   r0, #0
Stewart Brodie's avatar
Stewart Brodie committed
271
        Return
272 273 274

OmniS_ResFSStarting ; (int R2, int R3 )
        ; Dunno what this does!!
Stewart Brodie's avatar
Stewart Brodie committed
275
        FunctionEntry
276 277 278 279 280
        MOV     r2, r0
        MOV     r3, r1
        ADR     r0, Resource_Base
        MOV     r14, pc
        MOV     pc, r2
Stewart Brodie's avatar
Stewart Brodie committed
281
        Return
282 283 284 285


; Data block
Resource_Base
286 287 288 289 290
      [ ROMSPRITES
        ; Slim or low res sprites in ROM to save space
        ResourceFile "LocalRes:ROM.Sprites", "ThirdParty.OmniClient.LanMan.Sprites"
      |
        ; Deep colour high res sprites for RAM modules
291
        ResourceFile "LocalRes:Sprites", "ThirdParty.OmniClient.LanMan.Sprites"
292
      ]
293 294 295 296
        DCD     0


        END