home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / program / code / sdls / DLLLib / h / swiv < prev   
Encoding:
Text File  |  1994-12-08  |  2.1 KB  |  88 lines

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