Initial revision
[ssr] / StraySrc / Libraries / Steel / h / os
1 /*
2 * os.h
3 *
4 * OS kernel and generic SWI interface
5 *
6 * © 1994-1998 Straylight
7 */
8
9 /*----- Licensing note ----------------------------------------------------*
10 *
11 * This file is part of Straylight's Steel library.
12 *
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)
16 * any later version.
17 *
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.
22 *
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.
26 */
27
28 #ifndef __os_h
29 #define __os_h
30
31 #ifndef __kernel_h
32 #include "kernel.h"
33 #endif
34
35 /*----- Notes -------------------------------------------------------------*
36 *
37 * --- Deviency from the RISC_OSLib version ---
38 *
39 * All the generic SWI interfaces are implemented in this module, rather
40 * than being passed on via the run-time kernel.
41 *
42 * os_error is declared here to be synonymous with _kernel_oserror, to avoid
43 * messy casts between the two (otherwise identical) error structures.
44 *
45 * All the specific SWI interfaces (e.g. os_find etc.) are implemented by
46 * direct calls to the SWI in question, rather than by being passed on
47 * through os_swix and then on to _kernel_swi. This is also true of the
48 * other SWI interfaces found in wimp, bbc etc.
49 *
50 * --- Additions ---
51 *
52 * The collection of register-counted generic SWI veneers (i.e. os_swi0,
53 * os_swi4r etc.) have been filled in with versions for 5 registers. The
54 * non-returning ones (os_swi0-os_swi6) are implemented using only two
55 * separate routines. The returning calls are implemented separately, but
56 * each one uses a single main SWI veneer.
57 *
58 * Also, two more SWI interfaces have been added: os_swiv and os_swivr, each
59 * of which takes a variable number of arguments (the input registers in
60 * order). os_swivr will write the output registers into a register block.
61 */
62
63 /*----- Miscellaneous types -----------------------------------------------*/
64
65 #ifndef BOOL
66 #define BOOL int
67 #define TRUE 1
68 #define FALSE 0
69 #endif
70
71 /*----- Generic SWI veneers -----------------------------------------------*/
72
73 /* --- SWI handling types --- *
74 *
75 * We map directly to the kernel types, because they're identical and it
76 * prevents messy typecasting.
77 */
78
79 typedef _kernel_oserror os_error;
80 typedef _kernel_swi_regs os_regset;
81
82 /* --- The basic SWI veneers --- */
83
84 void os_swi(int swi,os_regset *r);
85 os_error *os_swix(int swi,os_regset *r);
86
87 /* --- Counted, nonreturning SWI veneers --- */
88
89 os_error *os_swi0(int swi);
90
91 os_error *os_swi1(int swi,int r0);
92
93 os_error *os_swi2(int swi,int r0,
94 int r1);
95
96 os_error *os_swi3(int swi,int r0,
97 int r1,
98 int r2);
99
100 os_error *os_swi4(int swi,int r0,
101 int r1,
102 int r2,
103 int r3);
104
105 os_error *os_swi5(int swi,int r0,
106 int r1,
107 int r2,
108 int r3,
109 int r4);
110
111 os_error *os_swi6(int swi,int r0,
112 int r1,
113 int r2,
114 int r3,
115 int r4,
116 int r5);
117
118 /* --- Counted, returning SWI veneers --- */
119
120 os_error *os_swi1r(int swi,int r0,
121 int *r0_out);
122
123 os_error *os_swi2r(int swi,int r0,
124 int r1,
125 int *r0_out,
126 int *r1_out);
127
128 os_error *os_swi3r(int swi,int r0,
129 int r1,
130 int r2,
131 int *r0_out,
132 int *r1_out,
133 int *r2_out);
134
135 os_error *os_swi4r(int swi,int r0,
136 int r1,
137 int r2,
138 int r3,
139 int *r0_out,
140 int *r1_out,
141 int *r2_out,
142 int *r3_out);
143
144 os_error *os_swi5r(int swi,int r0,
145 int r1,
146 int r2,
147 int r3,
148 int r4,
149 int *r0_out,
150 int *r1_out,
151 int *r2_out,
152 int *r3_out,
153 int *r4_out);
154
155 os_error *os_swi6r(int swi,int r0,
156 int r1,
157 int r2,
158 int r3,
159 int r4,
160 int r5,
161 int *r0_out,
162 int *r1_out,
163 int *r2_out,
164 int *r3_out,
165 int *r4_out,
166 int *r5_out);
167
168 /* --- Variable argument SWI veneers --- */
169
170 os_error *os_swiv(int swi,...);
171 os_error *os_swivr(int swi,os_regset *r_out,...);
172
173 /*----- Specific SWI veneers ----------------------------------------------*/
174
175 /* --- Structure types --- *
176 *
177 * These have dummy blocks on the end for compatibility with RISC_OSLib
178 * tried to treat them as os_regsets.
179 */
180
181 typedef struct
182 {
183 int action; /* Which action to perform */
184 char *name; /* Name of the file to do it to */
185 int loadaddr; /* May also be a filetype */
186 int execaddr; /* File execution address */
187 int start; /* May also be object length */
188 int end; /* May also be object attributes */
189 int dummy[4];
190 }
191 os_filestr;
192
193 typedef struct
194 {
195 int action; /* Which action to perform */
196 int file_handle; /* May point to directory name */
197 void *data_addr; /* Point to input or output buffer */
198 int number; /* Bytes to get or put, or number */
199 /* of filenames to read */
200 int seq_point; /* Item number to read in dir or 0 */
201 int buf_len; /* Buffer length for reading names */
202 char *wild_fld; /* Pointer to wildcard leafname */
203 int dummy[3];
204 }
205 os_gbpbstr;
206
207 /* --- SWI veneers --- */
208
209 os_error *os_byte(int action,int *x,int *y);
210 os_error *os_word(int action,int *pblock);
211 os_error *os_file(os_filestr *f);
212 os_error *os_gbpb(os_gbpbstr *g);
213 os_error *os_args(os_regset *r);
214 os_error *os_find(os_regset *r);
215 os_error *os_cli(const char *command);
216
217 /* --- Reading system variables --- *
218 *
219 * We recommend using the standard getenv function for this. The veneer
220 * returns the string null-terminated, which may mess things up.
221 */
222
223 os_error *os_read_var_val(char *name,char *buffer,int bufferSize);
224
225 #endif