/* * os.h * * OS kernel and generic SWI interface * * © 1994-1998 Straylight */ /*----- Licensing note ----------------------------------------------------* * * This file is part of Straylight's Steel library. * * Steel is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Steel is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Steel. If not, write to the Free Software Foundation, * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __os_h #define __os_h #ifndef __kernel_h #include "kernel.h" #endif /*----- Notes -------------------------------------------------------------* * * --- Deviency from the RISC_OSLib version --- * * All the generic SWI interfaces are implemented in this module, rather * than being passed on via the run-time kernel. * * os_error is declared here to be synonymous with _kernel_oserror, to avoid * messy casts between the two (otherwise identical) error structures. * * All the specific SWI interfaces (e.g. os_find etc.) are implemented by * direct calls to the SWI in question, rather than by being passed on * through os_swix and then on to _kernel_swi. This is also true of the * other SWI interfaces found in wimp, bbc etc. * * --- Additions --- * * The collection of register-counted generic SWI veneers (i.e. os_swi0, * os_swi4r etc.) have been filled in with versions for 5 registers. The * non-returning ones (os_swi0-os_swi6) are implemented using only two * separate routines. The returning calls are implemented separately, but * each one uses a single main SWI veneer. * * Also, two more SWI interfaces have been added: os_swiv and os_swivr, each * of which takes a variable number of arguments (the input registers in * order). os_swivr will write the output registers into a register block. */ /*----- Miscellaneous types -----------------------------------------------*/ #ifndef BOOL #define BOOL int #define TRUE 1 #define FALSE 0 #endif /*----- Generic SWI veneers -----------------------------------------------*/ /* --- SWI handling types --- * * * We map directly to the kernel types, because they're identical and it * prevents messy typecasting. */ typedef _kernel_oserror os_error; typedef _kernel_swi_regs os_regset; /* --- The basic SWI veneers --- */ void os_swi(int swi,os_regset *r); os_error *os_swix(int swi,os_regset *r); /* --- Counted, nonreturning SWI veneers --- */ os_error *os_swi0(int swi); os_error *os_swi1(int swi,int r0); os_error *os_swi2(int swi,int r0, int r1); os_error *os_swi3(int swi,int r0, int r1, int r2); os_error *os_swi4(int swi,int r0, int r1, int r2, int r3); os_error *os_swi5(int swi,int r0, int r1, int r2, int r3, int r4); os_error *os_swi6(int swi,int r0, int r1, int r2, int r3, int r4, int r5); /* --- Counted, returning SWI veneers --- */ os_error *os_swi1r(int swi,int r0, int *r0_out); os_error *os_swi2r(int swi,int r0, int r1, int *r0_out, int *r1_out); os_error *os_swi3r(int swi,int r0, int r1, int r2, int *r0_out, int *r1_out, int *r2_out); os_error *os_swi4r(int swi,int r0, int r1, int r2, int r3, int *r0_out, int *r1_out, int *r2_out, int *r3_out); os_error *os_swi5r(int swi,int r0, int r1, int r2, int r3, int r4, int *r0_out, int *r1_out, int *r2_out, int *r3_out, int *r4_out); os_error *os_swi6r(int swi,int r0, int r1, int r2, int r3, int r4, int r5, int *r0_out, int *r1_out, int *r2_out, int *r3_out, int *r4_out, int *r5_out); /* --- Variable argument SWI veneers --- */ os_error *os_swiv(int swi,...); os_error *os_swivr(int swi,os_regset *r_out,...); /*----- Specific SWI veneers ----------------------------------------------*/ /* --- Structure types --- * * * These have dummy blocks on the end for compatibility with RISC_OSLib * tried to treat them as os_regsets. */ typedef struct { int action; /* Which action to perform */ char *name; /* Name of the file to do it to */ int loadaddr; /* May also be a filetype */ int execaddr; /* File execution address */ int start; /* May also be object length */ int end; /* May also be object attributes */ int dummy[4]; } os_filestr; typedef struct { int action; /* Which action to perform */ int file_handle; /* May point to directory name */ void *data_addr; /* Point to input or output buffer */ int number; /* Bytes to get or put, or number */ /* of filenames to read */ int seq_point; /* Item number to read in dir or 0 */ int buf_len; /* Buffer length for reading names */ char *wild_fld; /* Pointer to wildcard leafname */ int dummy[3]; } os_gbpbstr; /* --- SWI veneers --- */ os_error *os_byte(int action,int *x,int *y); os_error *os_word(int action,int *pblock); os_error *os_file(os_filestr *f); os_error *os_gbpb(os_gbpbstr *g); os_error *os_args(os_regset *r); os_error *os_find(os_regset *r); os_error *os_cli(const char *command); /* --- Reading system variables --- * * * We recommend using the standard getenv function for this. The veneer * returns the string null-terminated, which may mess things up. */ os_error *os_read_var_val(char *name,char *buffer,int bufferSize); #endif