Initial revision
[ssr] / StraySrc / Libraries / DLLLib / h / swiv
1 /*
2 * swiv.h
3 *
4 * Interface to SWI veneer
5 *
6 * © 1997 Straylight
7 */
8
9 #ifndef ___swis_h
10 #define ___swis_h
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 #ifndef __kernel_h
17 #include "kernel.h"
18 #endif
19
20 /* --- SWI veneer functions --- *
21 *
22 * Arguments: int swi == the SWI to call
23 * unsigned flags == a definition of the SWIs registers
24 *
25 * Returns: _swi returns the value of the `return' register in the flags
26 * _swix returns 0, or a pointer to an error block
27 *
28 * Use: Calls a SWI, passing it a collection of registers, and
29 * filling in the registers as given in the function call.
30 *
31 * Order of arguments is as follows:
32 *
33 * Input registers: One word for each input register
34 * Output registers: Address to store each reg value
35 * Flags address: Address to store PC+flags value
36 * Block contents: Build contents of local block at end
37 */
38
39 extern int _swi(int /*swi*/, unsigned /*flags*/,...);
40 extern _kernel_oserror *_swix(int /*swi*/, unsigned /*flags*/,...);
41
42 /* --- Various flags settings --- *
43 *
44 * _in(n) -- declare Rn as an input register
45 * _inr(m, n) -- declare Rm--Rn as input registers
46 * _out(n) -- declare Rn as an output register
47 * _outr(m, n) -- declare Rm--Rn as output registers
48 * _return(n) -- return Rn from _swi
49 * _block(n) -- point Rn at block containing remaining arguments
50 */
51
52 #ifndef _FLAGS
53
54 /* --- _flags -- return or output processor flags --- */
55
56 #define _flags (0x10)
57
58 /* --- _in and _inr -- input a register, or a range of registers --- */
59
60 #define _in(r) (1u << (r))
61 #define _inr(ra,rb) (((~0) << (ra)) ^ ((~0) << ((rb)+1)))
62
63 /* --- _out and _outr -- output a register, or a range of registers --- */
64
65 #define _out(r) (1u << (31-((r) == _flags ? 10 : (r))))
66 #define _outr(ra,rb) (((~0) << (31-(rb))) ^ ((~0) << (32-(ra))))
67
68 /* --- _block -- point a register at block built from arguments --- */
69
70 #define _block(r) (((r) << 12) | 0x800)
71
72 /* --- _return -- return register from _swi (not _swix) --- */
73
74 #define _return(r) ((r) == _flags ? 0xF0000 : (r) << 16)
75
76 /* --- Constants for ARM processor flags --- */
77
78 #define _n (0x80000000u)
79 #define _z (0x40000000u)
80 #define _c (0x20000000u)
81 #define _v (0x10000000u)
82
83 /* --- Acorn style capital-letter macros --- */
84
85 #define _FLAGS _flags
86 #define _IN(x) _in(x)
87 #define _INR(x,y) _inr(x,y)
88 #define _OUT(x) _out(x)
89 #define _OUTR(x,y) _outr(x,y)
90 #define _BLOCK(x) _block(x)
91 #define _RETURN(x) _return(x)
92 #define _N _n
93 #define _Z _z
94 #define _C _c
95 #define _V _v
96
97 #endif
98
99 #ifdef __cplusplus
100 }
101 #endif
102
103 #endif