4 * OS kernel and generic SWI 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.
35 /*----- Notes -------------------------------------------------------------*
37 * --- Deviency from the RISC_OSLib version ---
39 * All the generic SWI interfaces are implemented in this module, rather
40 * than being passed on via the run-time kernel.
42 * os_error is declared here to be synonymous with _kernel_oserror, to avoid
43 * messy casts between the two (otherwise identical) error structures.
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.
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.
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.
63 /*----- Miscellaneous types -----------------------------------------------*/
71 /*----- Generic SWI veneers -----------------------------------------------*/
73 /* --- SWI handling types --- *
75 * We map directly to the kernel types, because they're identical and it
76 * prevents messy typecasting.
79 typedef _kernel_oserror os_error;
80 typedef _kernel_swi_regs os_regset;
82 /* --- The basic SWI veneers --- */
84 void os_swi(int swi,os_regset *r);
85 os_error *os_swix(int swi,os_regset *r);
87 /* --- Counted, nonreturning SWI veneers --- */
89 os_error *os_swi0(int swi);
91 os_error *os_swi1(int swi,int r0);
93 os_error *os_swi2(int swi,int r0,
96 os_error *os_swi3(int swi,int r0,
100 os_error *os_swi4(int swi,int r0,
105 os_error *os_swi5(int swi,int r0,
111 os_error *os_swi6(int swi,int r0,
118 /* --- Counted, returning SWI veneers --- */
120 os_error *os_swi1r(int swi,int r0,
123 os_error *os_swi2r(int swi,int r0,
128 os_error *os_swi3r(int swi,int r0,
135 os_error *os_swi4r(int swi,int r0,
144 os_error *os_swi5r(int swi,int r0,
155 os_error *os_swi6r(int swi,int r0,
168 /* --- Variable argument SWI veneers --- */
170 os_error *os_swiv(int swi,...);
171 os_error *os_swivr(int swi,os_regset *r_out,...);
173 /*----- Specific SWI veneers ----------------------------------------------*/
175 /* --- Structure types --- *
177 * These have dummy blocks on the end for compatibility with RISC_OSLib
178 * tried to treat them as os_regsets.
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 */
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 */
207 /* --- SWI veneers --- */
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);
217 /* --- Reading system variables --- *
219 * We recommend using the standard getenv function for this. The veneer
220 * returns the string null-terminated, which may mess things up.
223 os_error *os_read_var_val(char *name,char *buffer,int bufferSize);