4 ; RISC OS kernel interface
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Steel library.
13 ; Steel 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 ; Steel 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 Steel. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Standard stuff -------------------------------------------------------
32 ;----- Generic SWI interface ------------------------------------------------
34 AREA |C$$Code|,CODE,READONLY
39 ; On entry: a1 == SWI number
40 ; a2 == pointer to register set
44 os_swi STMFD R13!,{R1,R4-R10,R14} ;Save registers
45 BIC R10,R0,#&20000 ;Strip the X bit
46 LDMIA R1,{R0-R9} ;Load lots of registers
47 MOV R14,PC ;Set return address
48 LDR PC,_swihack ;And call the hacky routine
49 LDR R10,[R13],#4 ;Reload regset pointer
50 STMIA R10,{R0-R9} ;Save output registers
51 LDMFD R13!,{R4-R10,PC}^ ;And return to caller
57 ; On entry: a1 == SWI number
58 ; a2 == pointer to register set
62 os_swix STMFD R13!,{R1,R4-R10,R14} ;Save registers
63 ORR R10,R0,#&20000 ;Set the X bit
64 LDMIA R1,{R0-R9} ;Load lots of registers
65 MOV R14,PC ;Set return address
66 LDR PC,_swihack ;And call the hacky routine
67 LDR R10,[R13],#4 ;Reload regset pointer
68 STMIA R10,{R0-R9} ;Save output registers
69 MOVVC R0,#0 ;Return zero on no error
70 LDMFD R13!,{R4-R10,PC}^ ;And return to caller
74 ;----- Fixed-parameter non-returning SWI interfaces -------------------------
76 ; --- os_swi0, os_swi1, os_swi2, os_swi3 ---
78 ; On entry: a1 == SWI number
79 ; a2,a3,a4 == R0,R1,R2 on entry to SWI
80 ; On exit: a1 == pointer to possible error
89 os_swi3 STMFD R13!,{R4-R10,R14} ;Save registers
90 ORR R10,R0,#&20000 ;Set the X bit
94 MOV R14,PC ;Set return address
95 LDR PC,_swihack ;And call the hacky routine
96 MOVVC R0,#0 ;Return zero on no error
97 LDMFD R13!,{R4-R10,PC}^ ;And return to caller
101 ; --- os_swi4, os_swi5, os_swi6 ---
103 ; On entry: a1 == SWI number
104 ; a2,a3,a4 == R0,R1,R2 on entry to SWI
105 ; [sp,#0],[sp,#4],[sp,#8] == R3,R4,R5 on entry to SWI
106 ; On exit: a1 == pointer to possible error
113 os_swi6 MOV R12,R12 ;Remember stack position
114 STMFD R13!,{R1,R4-R10,R14} ;Save registers
115 ORR R10,R0,#&20000 ;Set the X bit
120 MOV R14,PC ;Set return address
121 LDR PC,_swihack ;And call the hacky routine
122 MOVVC R0,#0 ;Return zero on no error
123 LDMFD R13!,{R4-R10,PC}^ ;And return to caller
127 ;----- Fixed-parameter, returning SWI interfaces ----------------------------
131 ; CAUTION: NOTHING LIKE APCS
133 ; On entry: R0-R5 == SWI registers
134 ; R6-R11 == where to output registers
136 ; sp points to saved R4-R11 and R14 on stack
137 ; On exit: R0 == pointer to possible error
141 STMFD sp!,{R6-R11} ;Save the pointers away
142 ORR R10,R14,#&20000 ;Put in the X bit anyway
145 ADDVS sp,sp,#24 ;Point back at saved regs
146 LDMVSFD sp!,{R4-R11,pc}^ ;If it failed, return now
148 ; --- Refind the the pointers and store ---
150 LDMFD sp!,{R6-R11} ;Get the output pointers
164 ; --- Now return to the caller ---
166 MOV R0,#0 ;There was no error
167 LDMFD sp!,{R4-R11,pc}^ ;Return to caller
175 STMFD sp!,{R4-R11,lr} ;We corrupt lots of registers
194 STMFD sp!,{R4-R11,lr} ;We corrupt lots of registers
214 STMFD sp!,{R4-R11,lr} ;We corrupt lots of registers
233 STMFD sp!,{R4-R11,lr} ;We corrupt lots of registers
252 STMFD sp!,{R4-R11,lr} ;We corrupt lots of registers
270 STMFD sp!,{R4-R11,lr} ;We corrupt lots of registers
283 ;----- Variable number of registers -----------------------------------------
287 ; On entry: a1 == SWI number
289 ; On exit: a1 == pointer to possible to area
294 STMFD R13!,{R4-R10,R14} ;Save registers
295 ORR R10,R0,#&20000 ;Set the X bit
300 MOV R14,PC ;Set return address
301 LDR PC,_swihack ;And call the hacky routine
302 MOVVC R0,#0 ;Return zero on no error
303 LDMFD R13!,{R4-R10,PC}^ ;And return to caller
309 ; On entry: a1 == SWI number
310 ; a2 == pointer to os_regset
311 ; a3... == registers to pass
312 ; On exit: a1 == pointer to possible error
317 STMFD R13!,{R1,R4-R10,R14} ;Save registers
318 ORR R10,R0,#&20000 ;Set the X bit
322 MOV R14,PC ;Set return address
323 LDR PC,_swihack ;And call the hacky routine
324 LDR R12,[R13],#4 ;Load regset pointer
325 LDMVCIA R12,{R0-R9} ;Save all of them away
326 MOVVC R0,#0 ;Return zero on no error
327 LDMFD R13!,{R4-R10,PC}^ ;And return to caller
331 ;----- Veneers to specific routines -----------------------------------------
335 ; On entry: a1 == reason code for OS_Byte
336 ; a2 == pointer to x value
337 ; a3 == pointer to y value
340 os_byte STMFD sp!,{v1,v2,lr} ;Save registers away
349 LDMFD sp!,{v1,v2,pc}^
353 ; On entry: a1 == reason code for OS_Word
354 ; a2 == pointer to parameter block
363 ; On entry: a1 == pointer to `reg block'
366 os_gbpb STMFD sp!,{a1,v1-v6,lr}
367 LDMIA a1,{a1-a4,v1-v6}
370 STMVCIA lr,{a1-a4,v1-v6}
372 LDMFD sp!,{v1-v6,pc}^
378 ; On entry: a1 == pointer to `reg block'
381 os_file STMFD sp!,{a1,v1-v6,lr}
382 LDMIA a1,{a1-a4,v1-v6}
385 STMVCIA lr,{a1-a4,v1-v6}
387 LDMFD sp!,{v1-v6,pc}^
393 ; On entry: a1 == pointer to a real reg block
396 os_args STMFD sp!,{a1,v1-v6,lr}
397 LDMIA a1,{a1-a4,v1-v6}
400 STMVCIA lr,{a1-a4,v1-v6}
402 LDMFD sp!,{v1-v6,pc}^
408 ; On entry: a1 == pointer to a real reg block
411 os_find STMFD sp!,{a1,v1-v6,lr}
412 LDMIA a1,{a1-a4,v1-v6}
415 STMVCIA lr,{a1-a4,v1-v6}
417 LDMFD sp!,{v1-v6,pc}^
423 ; On entry: a1 == pointer to command string
430 ; --- os_read_var_val ---
432 ; On entry: a1 == pointer to variable name
433 ; a2 == pointer to buffer to store the value
434 ; a3 == size of the buffer
436 EXPORT os_read_var_val
437 os_read_var_val STMFD sp!,{v1,lr}
447 ;----- That's all, folks ----------------------------------------------------