home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntinc25.zoo / osbind.h < prev    next >
C/C++ Source or Header  |  1992-10-18  |  49KB  |  1,469 lines

  1. /*
  2.  * osbind.h    bindings for OS traps
  3.  *
  4.  *        ++jrb bammi@cadence.com
  5.  */
  6.  
  7. /*
  8.  * majorly re-hacked for gcc-1.36 and probably beyond
  9.  * all inlines changed to #defines, beacuse gcc is not
  10.  * handling clobbered reggies correctly when -mshort.
  11.  * We now use the Statement Exprs feature of GnuC
  12.  *
  13.  * 10/12/89
  14.  *    changed all "g" constraints to "r" that will force
  15.  *    all operands to be evaluated (or lea calculated)
  16.  *    before the __asm__. This is necessary because
  17.  *    if we had the (looser) "g" constraint, then sometimes
  18.  *    we are in the situation where stuff is in the stack,
  19.  *    and we are modifying the stack under Gcc (but eventually
  20.  *    restoring it before the end of the __asm__), and it does
  21.  *    not know about it (i believe there is no way to tell it
  22.  *    this either, but you can hardly expect that). by forcing
  23.  *    the stricter "r" constraint, we force the eval before using
  24.  *    the val (or lea as the case may be) and we dont get into
  25.  *    trouble.
  26.  *    (thanks to ers for finding this problem!)
  27.  *    [one side effect of this is that we may(depending on the
  28.  *      situation) actually end up with better code when the
  29.  *    values are already in reggies, or that value is used
  30.  *    later on (note that Gnu's reggie allocation notices the
  31.  *    clobbered reggie, and does'nt put the value/or uses
  32.  *    them from those reggies, nice huh!)
  33.  *
  34.  *  28/2/90
  35.  *    another major re-hack:
  36.  *    -- the basic reason: there was just no reliable
  37.  *    way to get the definitions (inline or not does'nt matter) to
  38.  *    fully evaluate the args before we changed the sp from under it.
  39.  *    (if -fomit-frame-pointer is *not* used, then most of the time
  40.  *     we dont need to do this, as things will just reference off of
  41.  *     a6, but this is not true all of the time).
  42.  *    my solution was to use local vars in the body of the statement
  43.  *    exprs, and initialize them from the args of the statement expr block.
  44.  *    to force the evaluation of the args before we change sp from
  45.  *    under gcc's feet, we make the local vars volatile. we use a
  46.  *    slight code optimization heuristic: if there are more than 4
  47.  *    args, only then we make the local volatile, and relax
  48.  *    the "r" constraint to "g". otherwise, we dont put the volatile
  49.  *    and force the evaluation by putting the "r" constaint. this
  50.  *    produces better code in most sitiations (when !__NO_INLINE__
  51.  *    especially), as either the args are already in a register or
  52.  *    there is good chance they will soon be reused, and in that
  53.  *    case it will already be in a register.
  54.  *      it may (the local vars, especially when no volatile)
  55.  *    look like overhead, but in 99% of the situations gcc will just
  56.  *    optimize that assignment right out. besides, this makes
  57.  *    these defines totally safe (from re-evaluation of the macro args).
  58.  *
  59.  *    -- as suggested by andreas schwab (thanks!)
  60.  *     (schwab@ls5.informatik.uni-dortmund.de) all the retvalues are now
  61.  *     local register vals (see the extentions section in the info file)
  62.  *     this really worked out great as all the silly "movl d0,%0" at
  63.  *     the end of each def can now be removed, and the value of
  64.  *     retvalue ends up in the correct register. it avoids all the
  65.  *     silly "mov d0,[d|a]n" type sequences from being generated. a real win.
  66.  *     (note in the outputs "=r"(retvalue) still has to be specified,
  67.  *     otherwise in certain situations you end up loosing the return
  68.  *     value in d0, as gcc sees no output, and correctly assumes that the
  69.  *     asm returns no value).
  70.  *
  71.  *    -- all the n's (the function #'s for the traps) are now given
  72.  *    the more relaxed "g". This again results in better code, as
  73.  *    it is always a constant, and gcc turns the movw %1,sp@- into
  74.  *    a movw #n,sp@-. we could have given them a "i" constraint too,
  75.  *    but "g" gives gcc more breathing room, and it does the right
  76.  *    thing. note: the n's still need to have "r" constraints in the
  77.  *    non-inline form (function form), as they are no longer constants
  78.  *    in the function, but a normal arg on the stack frame, and hence
  79.  *    we need to force evaluation before we change sp. (see osbind.c)
  80.  *
  81.  *    -- straps.cpp and traps.c are history. we dont need no stinking
  82.  *    non-reentrant bindings (straps) or incorrect ones (traps.c :-)
  83.  *
  84.  * 03/15/92 ++jrb
  85.  *    -- another re-hack needed for gcc-2.0: the optimization that we
  86.  *      used earlier for traps with more than 4 args, making them volatile
  87.  *    and using "g" constraints no longer works, because gcc has become
  88.  *    so smart! we now remove the volatile, and give "r" constraints
  89.  *    (just like traps with <= 4 args). that way the args are evaled
  90.  *    before we change the stack under gcc, and at appropriate times
  91.  *    put into reggies and pushed (or as in most cases, they are evaled
  92.  *    straight into reggies and pushed -- and in even more common cases
  93.  *    they are already in reggies, and they are just pushed). not doing
  94.  *    this with -fomit-frame-pointer was causing the temps (from evaluing
  95.  *    the args) to be created on the stack, but when we changed sp
  96.  *    from under gccs feet, the offsets  to the temps ended up being wrong.
  97.  */
  98.  
  99. #ifndef _OSBIND_H
  100. #define _OSBIND_H
  101.  
  102. #ifndef _COMPILER_H
  103. #include <compiler.h>
  104. #endif
  105.  
  106. #ifdef __cplusplus
  107. extern "C" {
  108. #endif
  109.  
  110. #ifndef _OSTRUCT_H
  111. #include <ostruct.h>
  112. #endif
  113.  
  114. #ifdef __TURBOC__
  115.  
  116. /* we supply a library of bindings for TurboC / PureC */
  117.  
  118. long    gemdos( void, ... );
  119. long    bios( void, ... );
  120. long    xbios( void, ... );
  121.  
  122. /* Gemdos prototypes */
  123.  
  124. void    Pterm0( void );
  125. long    Cconin( void );
  126. void    Cconout( int c );
  127. int     Cauxin( void );
  128. void    Cauxout( int c );
  129. int     Cprnout( int c );
  130. long    Crawio( int w );
  131. long    Crawcin( void );
  132. long    Cnecin( void );
  133. int     Cconws( const char *buf );
  134. void    Cconrs( LINE *buf );
  135. int     Cconis( void );
  136. long    Dsetdrv( int drv );
  137. int     Cconos( void );
  138. int     Cprnos( void );
  139. int     Cauxis( void );
  140. int     Cauxos( void );
  141. int     Dgetdrv( void );
  142. void    Fsetdta( _DTA *buf );
  143. long    Super( void *stack );
  144. unsigned int  Tgetdate( void );
  145. unsigned int  Tsetdate( unsigned int date );
  146. unsigned int  Tgettime( void );
  147. unsigned int  Tsettime( unsigned int time );
  148. _DTA    *Fgetdta( void );
  149. int     Sversion( void );
  150. void    Ptermres( long keepcnt, int retcode );
  151. int     Dfree( _DISKINFO *buf, int driveno );
  152. int     Dcreate( const char *path );
  153. int     Ddelete( const char *path );
  154. int     Dsetpath( const char *path );
  155. long    Fcreate( const char *filename, int attr );
  156. long    Fopen( const char *filename, int mode );
  157. int     Fclose( int handle );
  158. long    Fread( int handle, long count, void *buf );
  159. long    Fwrite( int handle, long count, void *buf );
  160. int     Fdelete( const char *filename );
  161. long    Fseek( long offset, int handle, int seekmode );
  162. int     Fattrib( const char *filename, int wflag, int attrib );
  163. long    Fdup( int handle );
  164. long    Fforce( int stch, int nonstdh );
  165. int     Dgetpath( char *path, int driveno );
  166. void    *Malloc( long number );
  167. int     Mfree( void *block );
  168. int     Mshrink( int zero, void *ptr, long size );
  169. #define Mshrink(ptr, size) Mshrink(0, ptr, size)
  170. long    Pexec( int mode, char *ptr1, void *ptr2, void *ptr3 );
  171. void    Pterm( int retcode );
  172. int     Fsfirst( const char *filename, int attr );
  173. int     Fsnext( void );
  174. int     Frename( int zero, const char *oldname, const char *newname );
  175. int     Fdatime( _DOSTIME *timeptr, int handle, int wflag );
  176.  
  177. /* GEMDOS extensions */
  178.  
  179. void    *Mxalloc( long number, int mode );
  180. long    Maddalt( void *start, long size );
  181.  
  182. /****** Network Gemdos Extension ****************************************/
  183.  
  184. long    Nversion( void );
  185. long    Frlock( int handle, long start, long count );
  186. long    Frunlock( int handle, long start );
  187. long    Flock( int handle, long count );
  188. long    Funlock( int handle );
  189. long    Fflush( int handle );
  190. long    Unlock( const char *path );
  191. long    Lock( const char *path );
  192.  
  193. /* BIOS */
  194.  
  195. void    Getmpb( _MPB *ptr );
  196. int     Bconstat( int dev );
  197. long    Bconin( int dev );
  198. void    Bconout( int dev, int c );
  199. long    Rwabs( int rwflag, void *buf, int cnt, int recnr, int dev );
  200. void    (*Setexc( int number, void (*exchdlr)() )) ();
  201. long    Tickcal( void );
  202. _BPB    *Getbpb( int dev );
  203. long    Bcostat( int dev );
  204. long    Mediach( int dev );
  205. long    Drvmap( void );
  206. long    Kbshift( int mode );
  207. #define Getshift() Kbshift(-1)
  208.  
  209. /* XBios */
  210.  
  211. void    Initmous( int type, _PARAM *par, void (*mousevec)() );
  212. void    *Ssbrk( int count );
  213. void    *Physbase( void );
  214. void    *Logbase( void );
  215. int     Getrez( void );
  216. void    Setscreen( void *laddr, void *paddr, int rez );
  217. void    Setpalette( void *pallptr );
  218. int     Setcolor( int colornum, int color );
  219. int     Floprd( void *buf, long filler, int devno, int sectno,
  220.                int trackno, int sideno, int count );
  221. int     Flopwr( void *buf, long filler, int devno, int sectno,
  222.                int trackno, int sideno, int count );
  223. int     Flopfmt( void *buf, long filler, int devno, int spt, int trackno,
  224.                 int sideno, int interlv, long magic, int virgin );
  225. void    Midiws( int cnt, void *ptr );
  226. void    Mfpint( int erno, void (*vector)() );
  227. _IOREC   *Iorec( int dev );
  228. long    Rsconf( int baud, int ctr, int ucr, int rsr, int tsr, int scr );
  229. _KEYTAB  *Keytbl( void *unshift, void *shift, void *capslock );
  230. long    Random( void );
  231. void    Protobt( void *buf, long serialno, int disktype, int execflag );
  232. int     Flopver( void *buf, long filler, int devno, int sectno,
  233.                 int trackno, int sideno, int count );
  234. void    Scrdmp( void );
  235. int     Cursconf( int func, int rate );
  236. void    Settime( unsigned long time );
  237. unsigned long  Gettime( void );
  238. void    Bioskeys( void );
  239. void    Ikbdws( int count, void *ptr );
  240. void    Jdisint( int number );
  241. void    Jenabint( int number );
  242. char    Giaccess( char data, int regno );
  243. void    Offgibit( int bitno );
  244. void    Ongibit( int bitno );
  245. void    Xbtimer( int timer, int control, int data, void (*vector)() );
  246. void    *Dosound( void *buf );
  247. int     Setprt( int config );
  248. _KBDVECS *Kbdvbase( void );
  249. int     Kbrate( int initial, int repeat );
  250. void    Prtblk( _PBDEF *par );
  251. void    Vsync( void );
  252. long    Supexec( long (*func)() );
  253. #define Supexec(func) Supexec((long (*) ()) func)
  254. void    Puntaes( void );
  255. int     Floprate( int devno, int newrate );
  256. int     Blitmode( int mode );
  257.  
  258. /* TOS030 XBios */
  259. int     DMAread( long sector, int count, void *buffer, int devno );
  260. int     DMAwrite( long sector, int count, void *buffer, int devno );
  261. int     NVMaccess( int opcode, int start, int count, void *buffer );
  262. long    Bconmap( int devno );
  263. int     Esetshift( int shftMode );
  264. #define EsetShift Esetshift
  265. int     Egetshift( void );
  266. #define EgetShift Egetshift
  267. int     EsetBank( int bankNum );
  268. int     EsetColor( int colorNum, int color );
  269. void    EsetPalette( int colorNum, int count, int *palettePtr );
  270. void    EgetPalette( int colorNum, int count, int *palettePtr );
  271. int     EsetGray( int swtch );
  272. int     EsetSmear( int swtch );
  273.  
  274. #else /* !__TURBOC__ */
  275.  
  276. /* want to skip all the gory details of GNU C inlines??
  277.    search for the string "DEFINITIONS" */
  278.  
  279. #ifdef __GNUC_INLINE__
  280. /*
  281.  * GNU C (pseudo inline) Statement Exprs for traps
  282.  *
  283.  */
  284.  
  285. #define trap_1_w(n)                            \
  286. ({                                    \
  287.     register long retvalue __asm__("d0");                \
  288.                                         \
  289.     __asm__ volatile                        \
  290.     ("\
  291.         movw    %1,sp@-; \
  292.         trap    #1;    \
  293.         addqw   #2,sp "                        \
  294.     : "=r"(retvalue)            /* outputs */        \
  295.     : "g"(n)                /* inputs  */        \
  296.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  297.     );                                \
  298.     retvalue;                            \
  299. })
  300.  
  301. #define trap_1_ww(n, a)                            \
  302. ({                                    \
  303.     register long retvalue __asm__("d0");                \
  304.     short _a = (short)(a);                        \
  305.                                         \
  306.     __asm__ volatile                        \
  307.     ("\
  308.         movw    %2,sp@-; \
  309.         movw    %1,sp@-; \
  310.         trap    #1;    \
  311.         addqw   #4,sp "                        \
  312.     : "=r"(retvalue)            /* outputs */        \
  313.     : "g"(n), "r"(_a)            /* inputs  */        \
  314.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  315.     );                                \
  316.     retvalue;                            \
  317. })
  318.  
  319. #define trap_1_wl(n, a)                            \
  320. ({                                    \
  321.     register long retvalue __asm__("d0");                \
  322.     long  _a = (long) (a);                        \
  323.                                         \
  324.     __asm__ volatile                        \
  325.     ("\
  326.         movl    %2,sp@-; \
  327.         movw    %1,sp@-; \
  328.         trap    #1;    \
  329.         addqw   #6,sp "                        \
  330.     : "=r"(retvalue)            /* outputs */        \
  331.     : "g"(n), "r"(_a)            /* inputs  */        \
  332.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  333.     );                                \
  334.     retvalue;                            \
  335. })
  336.  
  337. #define trap_1_wlw(n, a, b)                        \
  338. ({                                    \
  339.     register long retvalue __asm__("d0");                \
  340.     long  _a = (long) (a);                        \
  341.     short _b = (short)(b);                        \
  342.                                         \
  343.     __asm__ volatile                        \
  344.     ("\
  345.         movw    %3,sp@-; \
  346.         movl    %2,sp@-; \
  347.         movw    %1,sp@-; \
  348.         trap    #1;    \
  349.         addqw   #8,sp "                        \
  350.     : "=r"(retvalue)            /* outputs */        \
  351.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  352.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  353.     );                                \
  354.     retvalue;                            \
  355. })
  356.  
  357. #define trap_1_wwll(n, a, b, c)                        \
  358. ({                                    \
  359.     register long retvalue __asm__("d0");                \
  360.     short _a = (short)(a);                        \
  361.     long  _b = (long) (b);                        \
  362.     long  _c = (long) (c);                        \
  363.                                         \
  364.     __asm__ volatile                        \
  365.     ("\
  366.         movl    %4,sp@-; \
  367.         movl    %3,sp@-; \
  368.         movw    %2,sp@-; \
  369.         movw    %1,sp@-; \
  370.         trap    #1;    \
  371.         addw    #12,sp "                    \
  372.     : "=r"(retvalue)            /* outputs */        \
  373.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  374.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  375.     );                                \
  376.     retvalue;                            \
  377. })
  378.  
  379. #define trap_1_wlww(n, a, b, c)                        \
  380. ({                                    \
  381.     register long retvalue __asm__("d0");                \
  382.     long  _a = (long) (a);                        \
  383.     short _b = (short)(b);                        \
  384.     short _c = (short)(c);                        \
  385.                                         \
  386.     __asm__ volatile                        \
  387.     ("\
  388.         movw    %4,sp@-; \
  389.         movw    %3,sp@-; \
  390.         movl    %2,sp@-; \
  391.         movw    %1,sp@-; \
  392.         trap    #1;    \
  393.         addw    #10,sp "                    \
  394.     : "=r"(retvalue)            /* outputs */        \
  395.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  396.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  397.     );                                \
  398.     retvalue;                            \
  399. })
  400.  
  401. #define trap_1_www(n, a, b)                        \
  402. ({                                    \
  403.     register long retvalue __asm__("d0");                \
  404.     short _a = (short)(a);                        \
  405.     short _b = (short)(b);                        \
  406.                                         \
  407.     __asm__ volatile                        \
  408.     ("\
  409.         movw    %3,sp@-; \
  410.         movw    %2,sp@-; \
  411.         movw    %1,sp@-; \
  412.         trap    #1;    \
  413.         addqw   #6,sp "                        \
  414.     : "=r"(retvalue)            /* outputs */        \
  415.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  416.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  417.     );                                \
  418.     retvalue;                            \
  419. })
  420.  
  421. #define trap_1_wll(n, a, b)                        \
  422. ({                                    \
  423.     register long retvalue __asm__("d0");                \
  424.     long  _a = (long) (a);                        \
  425.     long  _b = (long) (b);                        \
  426.                                         \
  427.     __asm__ volatile                        \
  428.     ("\
  429.         movl    %3,sp@-; \
  430.         movl    %2,sp@-; \
  431.         movw    %1,sp@-; \
  432.         trap    #1;    \
  433.         addw    #10,sp "                    \
  434.     : "=r"(retvalue)            /* outputs */        \
  435.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  436.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  437.     );                                \
  438.     retvalue;                            \
  439. })
  440.  
  441. #define trap_1_wwlll(n, a, b, c, d)                    \
  442. ({                                    \
  443.     register long retvalue __asm__("d0");                \
  444.     short _a = (short)(a);            \
  445.     long  _b = (long) (b);            \
  446.     long  _c = (long) (c);            \
  447.     long  _d = (long) (d);            \
  448.                                         \
  449.     __asm__ volatile                        \
  450.     ("\
  451.         movl    %4,sp@-; \
  452.         movl    %3,sp@-; \
  453.         movl    %2,sp@-; \
  454.         movw    %1,sp@-; \
  455.         movw    %0,sp@- "                    \
  456.     :                         /* outputs */    \
  457.     : "g"(n), "r"(_a), "r"(_b), "r"(_c), "r"(_d) /* inputs  */    \
  458.         );                                \
  459.   /* no more than 5 operand allowed in asm() -- therefore the split */  \
  460.                                     \
  461.     __asm__ volatile                        \
  462.     ("\
  463.         trap    #1;    \
  464.         addw    #16,sp "                    \
  465.     : "=r"(retvalue)            /* outputs */        \
  466.     :                    /* inputs  */        \
  467.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  468.     );                                \
  469.     retvalue;                            \
  470. })
  471.  
  472. #define trap_1_wwwll(n, a, b, c, d)                    \
  473. ({                                    \
  474.     register long retvalue __asm__("d0");                \
  475.     short _a = (short)(a);                        \
  476.     short _b = (short)(b);                        \
  477.     long  _c = (long) (c);                        \
  478.     long  _d = (long) (d);                        \
  479.                                         \
  480.     __asm__ volatile                        \
  481.     ("\
  482.         movl    %5,sp@-; \
  483.         movl    %4,sp@-; \
  484.         movw    %3,sp@-; \
  485.         movw    %2,sp@-; \
  486.         movw    %1,sp@-; \
  487.         trap    #1;    \
  488.         addw    #16,sp "                    \
  489.     : "=r"(retvalue)            /* outputs */        \
  490.     : "g"(n), "r"(_a), "r"(_b), "r"(_c), "r"(_d) /* inputs  */    \
  491.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  492.     );                                \
  493.     retvalue;                            \
  494. })
  495.  
  496. #define trap_13_wl(n, a)                        \
  497. ({                                    \
  498.     register long retvalue __asm__("d0");                \
  499.     long  _a = (long) (a);                        \
  500.                                         \
  501.     __asm__ volatile                        \
  502.     ("\
  503.         movl    %2,sp@-; \
  504.         movw    %1,sp@-; \
  505.         trap    #13;    \
  506.         addqw   #6,sp "                        \
  507.     : "=r"(retvalue)            /* outputs */        \
  508.     : "g"(n), "r"(_a)            /* inputs  */        \
  509.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  510.     );                                \
  511.     retvalue;                            \
  512. })
  513.  
  514. #define trap_13_w(n)                            \
  515. ({                                    \
  516.     register long retvalue __asm__("d0");                \
  517.                                         \
  518.     __asm__ volatile                        \
  519.     ("\
  520.         movw    %1,sp@-; \
  521.         trap    #13;    \
  522.         addqw   #2,sp "                        \
  523.     : "=r"(retvalue)            /* outputs */        \
  524.     : "g"(n)                /* inputs  */        \
  525.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  526.     );                                \
  527.     retvalue;                            \
  528. })
  529.  
  530. #define trap_13_ww(n, a)                        \
  531. ({                                    \
  532.     register long retvalue __asm__("d0");                \
  533.     short _a = (short)(a);                        \
  534.                                         \
  535.     __asm__ volatile                        \
  536.     ("\
  537.         movw    %2,sp@-; \
  538.         movw    %1,sp@-; \
  539.         trap    #13;    \
  540.         addqw   #4,sp "                        \
  541.     : "=r"(retvalue)            /* outputs */        \
  542.     : "g"(n), "r"(_a)            /* inputs  */        \
  543.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  544.     );                                \
  545.     retvalue;                            \
  546. })
  547.  
  548. #define trap_13_www(n, a, b)                        \
  549. ({                                    \
  550.     register long retvalue __asm__("d0");                \
  551.     short _a = (short)(a);                        \
  552.     short _b = (short)(b);                        \
  553.                                         \
  554.     __asm__ volatile                        \
  555.     ("\
  556.         movw    %3,sp@-; \
  557.         movw    %2,sp@-; \
  558.         movw    %1,sp@-; \
  559.         trap    #13;    \
  560.         addqw   #6,sp "                        \
  561.     : "=r"(retvalue)            /* outputs */        \
  562.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  563.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  564.     );                                \
  565.     retvalue;                            \
  566. })
  567.  
  568. #define trap_13_wwlwww(n, a, b, c, d, e)                \
  569. ({                                    \
  570.     register long retvalue __asm__("d0");                \
  571.     short _a = (short)(a);            \
  572.     long  _b = (long) (b);            \
  573.     short _c = (short)(c);            \
  574.     short _d = (short)(d);            \
  575.     short _e = (short)(e);            \
  576.                                         \
  577.     __asm__ volatile                        \
  578.     ("\
  579.         movw    %4,sp@-; \
  580.         movw    %3,sp@-; \
  581.         movw    %2,sp@-; \
  582.         movl    %1,sp@-; \
  583.         movw    %0,sp@-    "                    \
  584.     :                          /* outputs */    \
  585.     : "r"(_a), "r"(_b), "r"(_c), "r"(_d), "r"(_e) /* inputs  */    \
  586.     );                                \
  587.                                     \
  588.     __asm__ volatile                        \
  589.     ("\
  590.         movw    %1,sp@-; \
  591.         trap    #13;    \
  592.         addw    #14,sp "                    \
  593.     : "=r"(retvalue)            /* outputs */        \
  594.     : "g"(n)                /* inputs  */        \
  595.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  596.     );                                \
  597.     retvalue;                            \
  598. })
  599.  
  600. #define trap_13_wwl(n, a, b)                        \
  601. ({                                    \
  602.     register long retvalue __asm__("d0");                \
  603.     short _a = (short)(a);                        \
  604.     long  _b = (long) (b);                        \
  605.                                         \
  606.     __asm__ volatile                        \
  607.     ("\
  608.         movl    %3,sp@-; \
  609.         movw    %2,sp@-; \
  610.         movw    %1,sp@-; \
  611.         trap    #13;    \
  612.         addqw   #8,sp "                        \
  613.     : "=r"(retvalue)            /* outputs */        \
  614.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  615.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  616.     );                                \
  617.     retvalue;                            \
  618. })
  619.  
  620. #define trap_14_wwl(n, a, b)                        \
  621. ({                                    \
  622.     register long retvalue __asm__("d0");                \
  623.     short _a = (short)(a);                        \
  624.     long  _b = (long) (b);                        \
  625.                                         \
  626.     __asm__ volatile                        \
  627.     ("\
  628.         movl    %3,sp@-; \
  629.         movw    %2,sp@-; \
  630.         movw    %1,sp@-; \
  631.         trap    #14;    \
  632.         addqw   #8,sp "                        \
  633.     : "=r"(retvalue)            /* outputs */        \
  634.     : "g"(n), "r"(_a), "r"(_b)              /* inputs  */        \
  635.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  636.     );                                \
  637.     retvalue;                            \
  638. })
  639.  
  640. #define trap_14_wwll(n, a, b, c)                    \
  641. ({                                    \
  642.     register long retvalue __asm__("d0");                \
  643.     short _a = (short)(a);                        \
  644.     long  _b = (long) (b);                        \
  645.     long  _c = (long) (c);                        \
  646.                                         \
  647.     __asm__ volatile                        \
  648.     ("\
  649.         movl    %4,sp@-; \
  650.         movl    %3,sp@-; \
  651.         movw    %2,sp@-; \
  652.         movw    %1,sp@-; \
  653.         trap    #14;    \
  654.         addw    #12,sp "                    \
  655.     : "=r"(retvalue)            /* outputs */        \
  656.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  657.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  658.     );                                \
  659.     retvalue;                            \
  660. })
  661.  
  662. #define trap_14_ww(n, a)                        \
  663. ({                                    \
  664.     register long retvalue __asm__("d0");                \
  665.     short _a = (short)(a);                        \
  666.                                         \
  667.     __asm__ volatile                        \
  668.     ("\
  669.         movw    %2,sp@-; \
  670.         movw    %1,sp@-; \
  671.         trap    #14;    \
  672.         addqw   #4,sp "                        \
  673.     : "=r"(retvalue)            /* outputs */        \
  674.     : "g"(n), "r"(_a)            /* inputs  */        \
  675.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  676.     );                                \
  677.     retvalue;                            \
  678. })
  679.  
  680. #define trap_14_w(n)                            \
  681. ({                                    \
  682.     register long retvalue __asm__("d0");                \
  683.                                         \
  684.     __asm__ volatile                        \
  685.     ("\
  686.         movw    %1,sp@-; \
  687.         trap    #14;    \
  688.         addqw   #2,sp "                        \
  689.     : "=r"(retvalue)            /* outputs */        \
  690.     : "g"(n)                /* inputs  */        \
  691.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  692.     );                                \
  693.     retvalue;                            \
  694. })
  695.  
  696. #define trap_14_wllw(n, a, b, c)                    \
  697. ({                                    \
  698.     register long retvalue __asm__("d0");                \
  699.     long  _a = (long) (a);                        \
  700.     long  _b = (long) (b);                        \
  701.     short _c = (short)(c);                        \
  702.                                         \
  703.     __asm__ volatile                        \
  704.     ("\
  705.         movw    %4,sp@-; \
  706.         movl    %3,sp@-; \
  707.         movl    %2,sp@-; \
  708.         movw    %1,sp@-; \
  709.         trap    #14;    \
  710.         addw    #12,sp "                    \
  711.     : "=r"(retvalue)            /* outputs */        \
  712.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)       /* inputs  */        \
  713.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  714.     );                                \
  715.     retvalue;                            \
  716. })
  717.  
  718. #define trap_14_wl(n, a)                        \
  719. ({                                    \
  720.     register long retvalue __asm__("d0");                \
  721.     long  _a = (long) (a);                        \
  722.                                         \
  723.     __asm__ volatile                        \
  724.     ("\
  725.         movl    %2,sp@-; \
  726.         movw    %1,sp@-; \
  727.         trap    #14;    \
  728.         addqw   #6,sp "                        \
  729.     : "=r"(retvalue)            /* outputs */        \
  730.     : "g"(n), "r"(_a)            /* inputs  */        \
  731.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  732.     );                                \
  733.     retvalue;                            \
  734. })
  735.  
  736. #define trap_14_www(n, a, b)                        \
  737. ({                                    \
  738.     register long retvalue __asm__("d0");                \
  739.     short _a = (short)(a);                        \
  740.     short _b = (short)(b);                        \
  741.                                         \
  742.     __asm__ volatile                        \
  743.     ("\
  744.         movw    %3,sp@-; \
  745.         movw    %2,sp@-; \
  746.         movw    %1,sp@-; \
  747.         trap    #14;    \
  748.         addqw   #6,sp "                        \
  749.     : "=r"(retvalue)            /* outputs */        \
  750.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  751.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  752.     );                                \
  753.     retvalue;                            \
  754. })
  755.  
  756. #define trap_14_wllwwwww(n, a, b, c, d, e, f, g)            \
  757. ({                                    \
  758.     register long retvalue __asm__("d0");                \
  759.     long  _a = (long) (a);                        \
  760.     long  _b = (long) (b);                        \
  761.     short _c = (short)(c);                        \
  762.     short _d = (short)(d);                        \
  763.     short _e = (short)(e);                        \
  764.     short _f = (short)(f);                        \
  765.     short _g = (short)(g);                        \
  766.                                         \
  767.     __asm__ volatile                        \
  768.     ("\
  769.         movw    %4,sp@-; \
  770.         movw    %3,sp@-; \
  771.         movw    %2,sp@-; \
  772.         movw    %1,sp@-; \
  773.         movw    %0,sp@-    "                    \
  774.     :                          /* outputs */    \
  775.     : "r"(_c), "r"(_d), "r"(_e), "r"(_f), "r"(_g) /* inputs  */    \
  776.     );                                \
  777.                                     \
  778.     __asm__ volatile                        \
  779.     ("\
  780.         movl    %3,sp@-; \
  781.         movl    %2,sp@-; \
  782.         movw    %1,sp@-; \
  783.         trap    #14;    \
  784.         addw    #20,sp "                    \
  785.     : "=r"(retvalue)            /* outputs */        \
  786.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  787.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  788.     );                                \
  789.     retvalue;                            \
  790. })
  791.  
  792. #define trap_14_wllwwwwlw(n, a, b, c, d, e, f, g, h)            \
  793. ({                                    \
  794.     register long retvalue __asm__("d0");                \
  795.     long  _a = (long) (a);                        \
  796.     long  _b = (long) (b);                        \
  797.     short _c = (short)(c);                        \
  798.     short _d = (short)(d);                        \
  799.     short _e = (short)(e);                        \
  800.     short _f = (short)(f);                        \
  801.     long  _g = (long) (g);                        \
  802.     short _h = (short)(h);                        \
  803.                                         \
  804.     __asm__ volatile                        \
  805.     ("\
  806.         movw    %4,sp@-; \
  807.         movl    %3,sp@-; \
  808.         movw    %2,sp@-; \
  809.         movw    %1,sp@-; \
  810.         movw    %0,sp@- "                    \
  811.     :                          /* outputs */    \
  812.     : "r"(_d), "r"(_e), "r"(_f), "r"(_g), "r"(_h) /* inputs  */    \
  813.     );                                \
  814.                                         \
  815.     __asm__ volatile                        \
  816.     ("\
  817.         movw    %4,sp@-; \
  818.         movl    %3,sp@-; \
  819.         movl    %2,sp@-; \
  820.         movw    %1,sp@-; \
  821.         trap    #14;    \
  822.         addw    #24,sp "                    \
  823.     : "=r"(retvalue)               /* outputs */    \
  824.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)        /* inputs  */    \
  825.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  826.     );                                \
  827.     retvalue;                            \
  828. })
  829.  
  830. #define trap_14_wllwwwwwlw(n, a, b, c, d, e, f, g, h, i)        \
  831. ({                                    \
  832.     register long retvalue __asm__("d0");                \
  833.     long  _a = (long) (a);                        \
  834.     long  _b = (long) (b);                        \
  835.     short _c = (short)(c);                        \
  836.     short _d = (short)(d);                        \
  837.     short _e = (short)(e);                        \
  838.     short _f = (short)(f);                        \
  839.     short _g = (short)(g);                        \
  840.     long  _h = (long) (h);                        \
  841.     short _i = (short)(i);                        \
  842.                                         \
  843.     __asm__ volatile                        \
  844.     ("\
  845.         movw    %4,sp@-; \
  846.         movl    %3,sp@-; \
  847.         movw    %2,sp@-; \
  848.         movw    %1,sp@-; \
  849.         movw    %0,sp@- "                    \
  850.     :                          /* outputs */    \
  851.     : "r"(_e), "r"(_f), "r"(_g), "r"(_h), "r"(_i) /* inputs  */    \
  852.     );                                \
  853.                                     \
  854.     __asm__ volatile                        \
  855.     ("\
  856.         movw    %4,sp@-; \
  857.         movw    %3,sp@-; \
  858.         movl    %2,sp@-; \
  859.         movl    %1,sp@-; \
  860.                 movw    %0,sp@- "                    \
  861.     :                         /* outputs */    \
  862.     : "g"(n), "r"(_a), "r"(_b), "r"(_c), "r"(_d) /* inputs  */    \
  863.     );                                \
  864.                                         \
  865.     __asm__ volatile                        \
  866.     ("\
  867.         trap    #14;    \
  868.         addw    #26,sp "                    \
  869.     : "=r"(retvalue)            /* outputs */        \
  870.     :                     /* inputs  */        \
  871.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  872.     );                                \
  873.     retvalue;                            \
  874. })
  875.  
  876.  
  877. #define trap_14_wwwwwww(n, a, b, c, d, e, f)                \
  878. ({                                    \
  879.     register long retvalue __asm__("d0");                \
  880.     short _a = (short)(a);                        \
  881.     short _b = (short)(b);                        \
  882.     short _c = (short)(c);                        \
  883.     short _d = (short)(d);                        \
  884.     short _e = (short)(e);                        \
  885.     short _f = (short)(f);                        \
  886.                                         \
  887.     __asm__ volatile                        \
  888.     ("\
  889.         movw    %4,sp@-; \
  890.         movw    %3,sp@-; \
  891.         movw    %2,sp@-; \
  892.         movw    %1,sp@-; \
  893.         movw    %0,sp@- "                    \
  894.     :                            /* outputs */    \
  895.     : "r"(_b), "r"(_c), "r"(_d), "r"(_e), "r"(_f)    /* inputs  */    \
  896.     );                                \
  897.                                     \
  898.     __asm__ volatile                        \
  899.     ("\
  900.         movw    %2,sp@-; \
  901.         movw    %1,sp@-; \
  902.         trap    #14;    \
  903.         addw    #14,sp "                    \
  904.     : "=r"(retvalue)            /* outputs */        \
  905.     : "g"(n), "r"(_a)            /* inputs  */        \
  906.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  907.     );                                \
  908.     retvalue;                            \
  909. })
  910.  
  911. #define trap_14_wlll(n, a, b, c)                    \
  912. ({                                    \
  913.     register long retvalue __asm__("d0");                \
  914.     long  _a = (long) (a);                        \
  915.     long  _b = (long) (b);                        \
  916.     long  _c = (long) (c);                        \
  917.                                         \
  918.     __asm__ volatile                        \
  919.     ("\
  920.         movl    %4,sp@-; \
  921.         movl    %3,sp@-; \
  922.         movl    %2,sp@-; \
  923.         movw    %1,sp@-; \
  924.         trap    #14;    \
  925.         addw    #14,sp "                    \
  926.     : "=r"(retvalue)            /* outputs */        \
  927.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  928.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  929.     );                                \
  930.     retvalue;                            \
  931. })
  932.  
  933. #define trap_14_wllww(n, a, b, c, d)                    \
  934. ({                                    \
  935.     register long retvalue __asm__("d0");                \
  936.     long  _a = (long) (a);                        \
  937.     long  _b = (long) (b);                        \
  938.     short _c = (short)(c);                        \
  939.     short _d = (short)(d);                        \
  940.                                         \
  941.     __asm__ volatile                        \
  942.     ("\
  943.         movw    %3,sp@-; \
  944.         movw    %2,sp@-; \
  945.         movl    %1,sp@-; \
  946.         movl    %0,sp@- "                    \
  947.     :                    /* outputs */        \
  948.     : "r"(_a), "r"(_b), "r"(_c), "r"(_d)    /* inputs  */        \
  949.     );                                \
  950.                                     \
  951.     __asm__ volatile                        \
  952.     ("\
  953.         movw    %1,sp@-; \
  954.         trap    #14;    \
  955.         addw    #14,sp "                    \
  956.     : "=r"(retvalue)            /* outputs */        \
  957.     : "g"(n)                /* inputs  */        \
  958.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  959.     );                                \
  960.     retvalue;                            \
  961. })
  962.  
  963. #define trap_14_wwwwl(n, a, b, c, d)                    \
  964. ({                                    \
  965.     register long retvalue __asm__("d0");                \
  966.     short _a = (short)(a);                        \
  967.     short _b = (short)(b);                        \
  968.     short _c = (short)(c);                        \
  969.     long  _d = (long) (d);                        \
  970.                                         \
  971.     __asm__ volatile                        \
  972.     ("\
  973.         movl    %3,sp@-; \
  974.         movw    %2,sp@-; \
  975.         movw    %1,sp@-; \
  976.         movw    %0,sp@- "                    \
  977.     :                        /* outputs */    \
  978.     : "r"(_a), "r"(_b), "r"(_c), "r"(_d)        /* inputs  */    \
  979.     );                                \
  980.                                     \
  981.     __asm__ volatile                        \
  982.     ("\
  983.         movw    %1,sp@-; \
  984.         trap    #14;    \
  985.         addw    #12,sp "                    \
  986.     : "=r"(retvalue)            /* outputs */        \
  987.     : "g"(n)                /* inputs  */        \
  988.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  989.     );                                \
  990.     retvalue;                            \
  991. })
  992.  
  993. #define trap_14_wwwl(n, a, b, c)                    \
  994. ({                                    \
  995.     register long retvalue __asm__("d0");                \
  996.     short _a = (short)(a);                        \
  997.     short _b = (short)(b);                        \
  998.     long  _c = (long)(c);                        \
  999.                                         \
  1000.     __asm__ volatile                        \
  1001.     ("                                \
  1002.         movl    %4,sp@-;                    \
  1003.         movw    %3,sp@-;                    \
  1004.         movw    %2,sp@-;                    \
  1005.         movw    %1,sp@-;                    \
  1006.         trap    #14;                        \
  1007.         addqw   #6,sp "                        \
  1008.     : "=r"(retvalue)            /* outputs */        \
  1009.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)    /* inputs  */        \
  1010.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  1011.     );                                \
  1012.     retvalue;                            \
  1013. })
  1014.  
  1015. #define trap_14_wlwlw(n, a, b, c, d)                    \
  1016. ({                                    \
  1017.     register long retvalue __asm__("d0");                \
  1018.     long  _a = (long) (a);                        \
  1019.     short _b = (short)(b);                        \
  1020.     long  _c = (long) (c);                        \
  1021.     short _d = (short)(d);                        \
  1022.                                         \
  1023.     __asm__ volatile                        \
  1024.     ("\
  1025.         movw    %4,sp@-; \
  1026.         movl    %3,sp@-; \
  1027.         movw    %2,sp@-; \
  1028.         movl    %1,sp@-; \
  1029.         movw    %0,sp@-;" \
  1030.     :                    /* outputs */        \
  1031.     : "g"(n), "r"(_a), "r"(_b), "r"(_c), "r"(_d) /* inputs  */    \
  1032.     );                                \
  1033.                                     \
  1034.     __asm__ volatile                        \
  1035.     ("\
  1036.         trap    #14;    \
  1037.         addw    #14,sp "                    \
  1038.     : "=r"(retvalue)            /* outputs */        \
  1039.     :                    /* inputs  */        \
  1040.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  1041.     );                                \
  1042.     retvalue;                            \
  1043. })
  1044.  
  1045. #else /* __GNUC_INLINE__ */
  1046.  
  1047. # ifndef __MSHORT__
  1048. #  define _TRAP_X_
  1049. # else
  1050. #  ifdef __GNUC__
  1051. #   ifndef __MINT__
  1052. #    define _TRAP_X_
  1053. #   endif
  1054. #  endif
  1055. # endif /* !__MSHORT__ */
  1056.  
  1057. # ifdef _TRAP_X_
  1058. /* if inlines are not allowed, then declare things external */
  1059. __EXTERN long trap_1_w __PROTO((short n));
  1060. __EXTERN long trap_1_ww __PROTO((short n, short a));
  1061. __EXTERN long trap_1_wl __PROTO((short n, long a));
  1062. __EXTERN long trap_1_wlw __PROTO((short n, long a, short b));
  1063. __EXTERN long trap_1_wwll __PROTO((short n, short a, long b, long c));
  1064. __EXTERN long trap_1_wlww __PROTO((short n, long a, short b, short c));
  1065. __EXTERN long trap_1_www __PROTO((short n, short a, short b));
  1066. __EXTERN long trap_1_wll __PROTO((short n, long a, long b));
  1067. __EXTERN long trap_1_wwlll __PROTO((short n, short a, long b, long c, long d));
  1068. __EXTERN long trap_1_wwwll __PROTO((short n, short a, short b, long c, long d));
  1069. __EXTERN long trap_13_wl __PROTO((short n, long a));
  1070. __EXTERN long trap_13_w __PROTO((short n));
  1071. __EXTERN long trap_13_ww __PROTO((short n, short a));
  1072. __EXTERN long trap_13_www __PROTO((short n, short a, short b));
  1073. __EXTERN long trap_13_wwlwww __PROTO((short n, short a, long b, short c, short d, short e));
  1074. __EXTERN long trap_13_wwl __PROTO((short n, short a, long b));
  1075. __EXTERN long trap_14_wwl __PROTO((short n, short a, long b));
  1076. __EXTERN long trap_14_wwll __PROTO((short n, short a, long b, long c));
  1077. __EXTERN long trap_14_ww __PROTO((short n, short a));
  1078. __EXTERN long trap_14_w __PROTO((short n));
  1079. __EXTERN long trap_14_wllw __PROTO((short n, long a, long b, short c));
  1080. __EXTERN long trap_14_wl __PROTO((short n, long a));
  1081. __EXTERN long trap_14_www __PROTO((short n, short a, short b));
  1082. __EXTERN long trap_14_wllwwwww __PROTO((short n, long a, long b, short c, short d, short e, short f, short g));
  1083. __EXTERN long trap_14_wllwwwwlw __PROTO((short n, long a, long b, short c, short d, short e, short f, long g, short h));
  1084. __EXTERN long trap_14_wllwwwwwlw __PROTO((short n, long a, long b, short c, short d, short e, short f, short g, long h, short i));
  1085. __EXTERN long trap_14_wwwwwww __PROTO((short n, short a, short b, short c, short d, short e, short f));
  1086. __EXTERN long trap_14_wlll __PROTO((short n, long a, long b, long c));
  1087. __EXTERN long trap_14_wllww __PROTO((short n, long a, long b, short c, short d));
  1088. __EXTERN long trap_14_wwwwl __PROTO((short n, short a, short b, short c, long d));
  1089. __EXTERN long trap_14_wwwl __PROTO((short n, short a, short b, long c));
  1090. __EXTERN long trap_14_wlwlw __PROTO((short n, long a, short b, long c, short d));
  1091.  
  1092. # else /* __TRAP_X__ */
  1093.  
  1094. __EXTERN long gemdos    __PROTO((short, ...));
  1095. __EXTERN long bios    __PROTO((short, ...));
  1096. __EXTERN long xbios    __PROTO((short, ...));
  1097.  
  1098. #define trap_1_w    gemdos
  1099. #define trap_1_ww    gemdos
  1100. #define trap_1_wl    gemdos
  1101. #define trap_1_wlw    gemdos
  1102. #define trap_1_www    gemdos
  1103. #define trap_1_wll    gemdos
  1104. #define trap_1_wwll    gemdos
  1105. #define trap_1_wlww    gemdos
  1106. #define trap_1_wwlll    gemdos
  1107. #define trap_1_wwwll    gemdos
  1108.  
  1109. #define trap_13_w    bios
  1110. #define trap_13_ww    bios
  1111. #define trap_13_wl    bios
  1112. #define trap_13_www    bios
  1113. #define trap_13_wwl    bios
  1114. #define trap_13_wwlwww    bios
  1115.  
  1116. #define trap_14_w    xbios
  1117. #define trap_14_ww    xbios
  1118. #define trap_14_wl    xbios
  1119. #define trap_14_www    xbios
  1120. #define trap_14_wwl    xbios
  1121. #define trap_14_wwll    xbios
  1122. #define trap_14_wllw    xbios
  1123. #define trap_14_wlll    xbios
  1124. #define trap_14_wwwl    xbios
  1125. #define trap_14_wwwwl    xbios
  1126. #define trap_14_wllww    xbios
  1127. #define trap_14_wwwwwww    xbios
  1128. #define trap_14_wllwwwww    xbios
  1129. #define trap_14_wllwwwwlw    xbios
  1130. #define trap_14_wllwwwwwlw    xbios
  1131. #define trap_14_wlwlw    xbios
  1132.  
  1133. # endif /* _TRAP_X_ */
  1134.  
  1135. #endif /* __GNUC_INLINE__ */
  1136.  
  1137.  
  1138. /* DEFINITIONS FOR OS FUNCTIONS */
  1139.  
  1140. /*
  1141.  *     GEMDOS  (trap1)
  1142.  */
  1143. #define           Pterm0()                                      \
  1144.        (void)trap_1_w((short)(0x00))
  1145. #define           Cconin()                               \
  1146.        (long)trap_1_w((short)(0x01))
  1147. #define           Cconout(c)                           \
  1148.        (void)trap_1_ww((short)(0x02),(short)(c))
  1149. #define           Cauxin()                               \
  1150.        (long)trap_1_w((short)(0x03))
  1151. #define           Cauxout(c)                           \
  1152.        (void)trap_1_ww((short)(0x04),(short)(c))
  1153. #define           Cprnout(c)                           \
  1154.        (void)trap_1_ww((short)(0x05),(short)(c))
  1155. #define           Crawio(data)                           \
  1156.        (long)trap_1_ww((short)(0x06),(short)(data))
  1157. #define           Crawcin()                           \
  1158.        (long)trap_1_w((short)(0x07))
  1159. #define           Cnecin()                               \
  1160.        (long)trap_1_w((short)(0x08))
  1161. #define           Cconws(s)                           \
  1162.        (void)trap_1_wl((short)(0x09),(long)(s))
  1163. #define           Cconrs(buf)                           \
  1164.        (void)trap_1_wl((short)(0x0A),(long)(buf))
  1165. #define           Cconis()                               \
  1166.        (short)trap_1_w((short)(0x0B))
  1167. #define           Dsetdrv(d)                           \
  1168.        (long)trap_1_ww((short)(0x0E),(short)(d))
  1169. #define           Cconos()                               \
  1170.        (short)trap_1_w((short)(0x10))
  1171. #define           Cprnos()                               \
  1172.        (short)trap_1_w((short)(0x11))
  1173. #define           Cauxis()                               \
  1174.        (short)trap_1_w((short)(0x12))
  1175. #define           Cauxos()                               \
  1176.        (short)trap_1_w((short)(0x13))
  1177. #define           Dgetdrv()                           \
  1178.        (short)trap_1_w((short)(0x19))
  1179. #define           Fsetdta(dta)                           \
  1180.        (void)trap_1_wl((short)(0x1A),(long)(dta))
  1181.  
  1182. /*
  1183.  * The next binding is not quite right if used in another than the usual ways:
  1184.  *    1. Super(1L) from either user or supervisor mode
  1185.  *    2. ret = Super(0L) from user mode and after this Super(ret) from
  1186.  *       supervisor mode
  1187.  * We get the following situations (usp, ssp relative to the start of Super):
  1188.  *    Parameter    Userstack    Superstack    Calling Mode    ret
  1189.  *       1L           usp           ssp            user     0L
  1190.  *       1L           usp           ssp         supervisor    -1L
  1191.  *       0L          usp-6           usp            user    ssp
  1192.  *       0L           ssp          ssp-6         supervisor   ssp-6
  1193.  *      ptr          usp-6          ptr+6            user    ssp
  1194.  *      ptr          usp+6           ptr         supervisor     sr
  1195.  * The usual C-bindings are safe only because the "unlk a6" is compensating
  1196.  * the errors when you invoke this function. In this binding the "unlk a6" at
  1197.  * the end of the calling function compensates the error made in sequence 2
  1198.  * above (the usp is 6 to low after the first call which is not corrected by
  1199.  * the second call).
  1200.  */
  1201. #define           Super(ptr)                           \
  1202.        (long)trap_1_wl((short)(0x20),(long)(ptr))
  1203.     /* Tos 1.4: Super(1L) : rets -1L if in super mode, 0L otherwise */
  1204. #define           Tgetdate()                           \
  1205.        (short)trap_1_w((short)(0x2A))
  1206. #define           Tsetdate(date)                           \
  1207.        (long)trap_1_ww((short)(0x2B),(short)(date))
  1208. #define           Tgettime()                           \
  1209.        (short)trap_1_w((short)(0x2C))
  1210. #define           Tsettime(time)                           \
  1211.        (long)trap_1_ww((short)(0x2D),(short)(time))
  1212. #define           Fgetdta()                           \
  1213.        (_DTA *)trap_1_w((short)(0x2F))
  1214. #define           Sversion()                           \
  1215.        (short)trap_1_w((short)(0x30))
  1216. #define           Ptermres(save,rv)                       \
  1217.        (void)trap_1_wlw((short)(0x31),(long)(save),(short)(rv))
  1218. #define           Dfree(buf,d)                           \
  1219.        (long)trap_1_wlw((short)(0x36),(long)(buf),(short)(d))
  1220. #define           Dcreate(path)                           \
  1221.        (short)trap_1_wl((short)(0x39),(long)(path))
  1222. #define           Ddelete(path)                           \
  1223.        (long)trap_1_wl((short)(0x3A),(long)(path))
  1224. #define           Dsetpath(path)                           \
  1225.        (long)trap_1_wl((short)(0x3B),(long)(path))
  1226. #define           Fcreate(fn,mode)                           \
  1227.        (long)trap_1_wlw((short)(0x3C),(long)(fn),(short)(mode))
  1228. #define           Fopen(fn,mode)                           \
  1229.        (long)trap_1_wlw((short)(0x3D),(long)(fn),(short)(mode))
  1230. #define           Fclose(handle)                           \
  1231.        (long)trap_1_ww((short)(0x3E),(short)(handle))
  1232. #define           Fread(handle,cnt,buf)                       \
  1233.        (long)trap_1_wwll((short)(0x3F),(short)(handle),           \
  1234.              (long)(cnt),(long)(buf))
  1235. #define           Fwrite(handle,cnt,buf)                       \
  1236.        (long)trap_1_wwll((short)(0x40),(short)(handle),           \
  1237.              (long)(cnt),(long)(buf))
  1238. #define           Fdelete(fn)                           \
  1239.        (long)trap_1_wl((short)(0x41),(long)(fn))
  1240. #define           Fseek(where,handle,how)                       \
  1241.        (long)trap_1_wlww((short)(0x42),(long)(where),           \
  1242.              (short)(handle),(short)(how))
  1243. #define           Fattrib(fn,rwflag,attr)                       \
  1244.        (short)trap_1_wlww((short)(0x43),(long)(fn),           \
  1245.               (short)(rwflag),(short)(attr))
  1246. #define           Fdup(handle)                           \
  1247.        (long)trap_1_ww((short)(0x45),(short)(handle))
  1248. #define           Fforce(Hstd,Hnew)                       \
  1249.        (long)trap_1_www((short)(0x46),(short)(Hstd),(short)(Hnew))
  1250. #define           Dgetpath(buf,d)                           \
  1251.        (long)trap_1_wlw((short)(0x47),(long)(buf),(short)(d))
  1252. #define           Malloc(size)                           \
  1253.        (long)trap_1_wl((short)(0x48),(long)(size))
  1254. #define           Mfree(ptr)                           \
  1255.        (long)trap_1_wl((short)(0x49),(long)(ptr))
  1256. #define           Mshrink(ptr,size)                       \
  1257.        (long)trap_1_wwll((short)(0x4A),(short)0,(long)(ptr),(long)(size))
  1258. #define           Pexec(mode,prog,tail,env)               \
  1259.        (long)trap_1_wwlll((short)(0x4B),(short)(mode),(long)(prog),   \
  1260.                (long)(tail),(long)(env))
  1261. #define           Pterm(rv)                           \
  1262.        (void)trap_1_ww((short)(0x4C),(short)(rv))
  1263. #define           Fsfirst(filespec,attr)                       \
  1264.        (long)trap_1_wlw((short)(0x4E),(long)(filespec),(short)(attr))
  1265. #define           Fsnext()                               \
  1266.        (long)trap_1_w((short)(0x4F))
  1267. #define           Frename(zero,old,new)                       \
  1268.        (short)trap_1_wwll((short)(0x56),(short)(zero),           \
  1269.               (long)(old),(long)(new))
  1270. #define           Fdatime(timeptr,handle,rwflag)                   \
  1271.        (long)trap_1_wlww((short)(0x57),(long)(timeptr),           \
  1272.              (short)(handle),(short)(rwflag))
  1273. #define           Flock(handle,mode,start,length)                   \
  1274.        (long)trap_1_wwwll((short)(0x5C),(short)(handle),       \
  1275.               (short)(mode),(long)(start),(long)(length))
  1276.  
  1277. /*
  1278.  *     BIOS    (trap13)
  1279.  */
  1280. #define Getmpb(ptr)                           \
  1281.        (void)trap_13_wl((short)(0x00),(long)(ptr))
  1282. #define           Bconstat(dev)                           \
  1283.        (short)trap_13_ww((short)(0x01),(short)(dev))
  1284. #define           Bconin(dev)                           \
  1285.        (long)trap_13_ww((short)(0x02),(short)(dev))
  1286. #define           Bconout(dev,c)                           \
  1287.        (long)trap_13_www((short)(0x03),(short)(dev),(short)((c) & 0xFF))
  1288. /* since AHDI 3.1 there is a new call to Rwabs with one more parameter */
  1289. #define           Rwabs(rwflag,buf,n,sector,d)            \
  1290.        (long)trap_13_wwlwww((short)(0x04),(short)(rwflag),(long)(buf), \
  1291.                  (short)(n),(short)(sector),(short)(d))
  1292. #define           Setexc(vnum,vptr)                       \
  1293.        (void (*) __PROTO((void)))trap_13_wwl((short)(0x05),(short)(vnum),(long)(vptr))
  1294. #define           Tickcal()                           \
  1295.        (long)trap_13_w((short)(0x06))
  1296. #define           Getbpb(d)                           \
  1297.        (void *)trap_13_ww((short)(0x07),(short)(d))
  1298. #define           Bcostat(dev)                           \
  1299.        (short)trap_13_ww((short)(0x08),(short)(dev))
  1300. #define           Mediach(dev)                           \
  1301.        (short)trap_13_ww((short)(0x09),(short)(dev))
  1302. #define           Drvmap()                               \
  1303.        (long)trap_13_w((short)(0x0A))
  1304. #define           Kbshift(data)                           \
  1305.        (long)trap_13_ww((short)(0x0B),(short)(data))
  1306. #define           Getshift()                           \
  1307.     Kbshift(-1)
  1308.  
  1309.  
  1310. /*
  1311.  *     XBIOS   (trap14)
  1312.  */
  1313.  
  1314. #define           Initmous(type,param,vptr)                   \
  1315.        (void)trap_14_wwll((short)(0x00),(short)(type),           \
  1316.               (long)(param),(long)(vptr))
  1317. #define Ssbrk(size)                           \
  1318.        (void *)trap_14_ww((short)(0x01),(short)(size))
  1319. #define           Physbase()                           \
  1320.        (void *)trap_14_w((short)(0x02))
  1321. #define           Logbase()                           \
  1322.        (void *)trap_14_w((short)(0x03))
  1323. #define           Getrez()                               \
  1324.        (short)trap_14_w((short)(0x04))
  1325. #define           Setscreen(lscrn,pscrn,rez)                   \
  1326.        (void)trap_14_wllw((short)(0x05),(long)(lscrn),(long)(pscrn), \
  1327.               (short)(rez))
  1328. #define           Setpalette(palptr)                       \
  1329.        (void)trap_14_wl((short)(0x06),(long)(palptr))
  1330. #define           Setcolor(colornum,mixture)                   \
  1331.        (short)trap_14_www((short)(0x07),(short)(colornum),(short)(mixture))
  1332. #define           Floprd(buf,x,d,sect,trk,side,n)                   \
  1333.        (short)trap_14_wllwwwww((short)(0x08),(long)(buf),(long)(x), \
  1334.      (short)(d),(short)(sect),(short)(trk),(short)(side),(short)(n))
  1335. #define           Flopwr(buf,x,d,sect,trk,side,n)                   \
  1336.        (short)trap_14_wllwwwww((short)(0x09),(long)(buf),(long)(x), \
  1337.            (short)(d),(short)(sect),(short)(trk),(short)(side),(short)(n))
  1338. #define           Flopfmt(buf,x,d,spt,t,sd,i,m,v)               \
  1339.        (short)trap_14_wllwwwwwlw((short)(0x0A),(long)(buf),(long)(x), \
  1340.       (short)(d),(short)(spt),(short)(t),(short)(sd),(short)(i),  \
  1341.       (long)(m),(short)(v))
  1342. #define           Midiws(cnt,ptr)                           \
  1343.        (void)trap_14_wwl((short)(0x0C),(short)(cnt),(long)(ptr))
  1344. #define           Mfpint(vnum,vptr)                       \
  1345.        (void)trap_14_wwl((short)(0x0D),(short)(vnum),(long)(vptr))
  1346. #define           Iorec(ioDEV)                           \
  1347.        (void *)trap_14_ww((short)(0x0E),(short)(ioDEV))
  1348. #define           Rsconf(baud,flow,uc,rs,ts,sc)                   \
  1349.        (long)trap_14_wwwwwww((short)(0x0F),(short)(baud),(short)(flow), \
  1350.               (short)(uc),(short)(rs),(short)(ts),(short)(sc))
  1351.     /* ret old val: MSB -> ucr:8, rsr:8, tsr:8, scr:8 <- LSB */
  1352. #define           Keytbl(nrml,shft,caps)                       \
  1353.        (void *)trap_14_wlll((short)(0x10),(long)(nrml), \
  1354.                 (long)(shft),(long)(caps))
  1355. #define           Random()                               \
  1356.        (long)trap_14_w((short)(0x11))
  1357. #define           Protobt(buf,serial,dsktyp,exec)                   \
  1358.        (void)trap_14_wllww((short)(0x12),(long)(buf),(long)(serial), \
  1359.                (short)(dsktyp),(short)(exec))
  1360. #define           Flopver(buf,x,d,sect,trk,sd,n)                   \
  1361.        (short)trap_14_wllwwwww((short)(0x13),(long)(buf),(long)(x),(short)(d),\
  1362.            (short)(sect),(short)(trk),(short)(sd),(short)(n))
  1363. #define           Scrdmp()                               \
  1364.        (void)trap_14_w((short)(0x14))
  1365. #define           Cursconf(rate,attr)                       \
  1366.        (short)trap_14_www((short)(0x15),(short)(rate),(short)(attr))
  1367. #define           Settime(time)                           \
  1368.        (void)trap_14_wl((short)(0x16),(long)(time))
  1369. #define           Gettime()                           \
  1370.        (long)trap_14_w((short)(0x17))
  1371. #define           Bioskeys()                           \
  1372.        (void)trap_14_w((short)(0x18))
  1373. #define           Ikbdws(len_minus1,ptr)                       \
  1374.        (void)trap_14_wwl((short)(0x19),(short)(len_minus1),(long)(ptr))
  1375. #define           Jdisint(vnum)                           \
  1376.        (void)trap_14_ww((short)(0x1A),(short)(vnum))
  1377. #define           Jenabint(vnum)                           \
  1378.        (void)trap_14_ww((short)(0x1B),(short)(vnum))
  1379. #define           Giaccess(data,reg)                       \
  1380.        (short)trap_14_www((short)(0x1C),(short)(data),(short)(reg))
  1381. #define           Offgibit(ormask)                           \
  1382.        (void)trap_14_ww((short)(0x1D),(short)(ormask))
  1383. #define           Ongibit(andmask)                           \
  1384.        (void)trap_14_ww((short)(0x1E),(short)(andmask))
  1385. #define           Xbtimer(timer,ctrl,data,vptr)                   \
  1386.        (void)trap_14_wwwwl((short)(0x1F),(short)(timer),(short)(ctrl), \
  1387.                (short)(data),(long)(vptr))
  1388. #define           Dosound(ptr)                           \
  1389.        (void)trap_14_wl((short)(0x20),(long)(ptr))
  1390. #define           Setprt(config)                           \
  1391.        (short)trap_14_ww((short)(0x21),(short)(config))
  1392. #define           Kbdvbase()                           \
  1393.        (_KBDVECS*)trap_14_w((short)(0x22))
  1394. #define           Kbrate(delay,reprate)                       \
  1395.        (short)trap_14_www((short)(0x23),(short)(delay),(short)(reprate))
  1396. #define           Prtblk(pblkptr)                           \
  1397.        (void)trap_14_wl((short)(0x24),(long)(pblkptr)) /* obsolete ? */
  1398. #define           Vsync()                               \
  1399.        (void)trap_14_w((short)(0x25))
  1400. #define           Supexec(funcptr)                           \
  1401.        (long)trap_14_wl((short)(0x26),(long)(funcptr))
  1402. #define           Floprate(drive,rate)                       \
  1403.        (short)trap_14_www((short)(0x29),(short)(drive),(short)(rate))
  1404. #define           Blitmode(flag)                           \
  1405.        (short)trap_14_ww((short)(0x40),(short)(flag))
  1406. /*
  1407.  * Flag:
  1408.  *  -1: get config
  1409.  * !-1: set config    previous config returned
  1410.  *    bit
  1411.  *     0    0 blit mode soft    1 blit mode hardware
  1412.  *     1    0 no blitter        1 blitter present
  1413.  *    2..14   reserved
  1414.  *     15    must be zero on set/returned as zero
  1415.  * blitmode (bit 0) forced to soft if no blitter(bit 1 == 0).
  1416.  */
  1417.  
  1418. /*
  1419.  * extensions for TT TOS
  1420.  */
  1421.  
  1422. #define         Mxalloc(amt,flag)                    \
  1423.     (long)trap_1_wlw((short)(0x44),(long)(amt),(short)(flag))
  1424. #define        Maddalt(start,size)                    \
  1425.     (long)trap_1_wll((short)(0x14),(long)(start),(long)(size))
  1426.  
  1427. #define         EsetShift(mode)                        \
  1428.     (void)trap_14_ww((short)(80),(short)mode)
  1429. #define         EgetShift()                        \
  1430.     (short)trap_14_w((short)(81))
  1431. #define         EsetBank(bank)                        \
  1432.     (short)trap_14_ww((short)(82),(short)bank)
  1433. #define         EsetColor(num,val)                    \
  1434.     (short)trap_14_www((short)(83),(short)num,(short)val)
  1435. #define         EsetPalette(start,count,ptr)                \
  1436.     (void)trap_14_wwwl((short)(84),(short)start,(short)count,(long)ptr)
  1437. #define         EgetPalette(start,count,ptr)                \
  1438.     (void)trap_14_wwwl((short)(85),(short)start,(short)count,(long)ptr)
  1439. #define         EsetGray(mode)                        \
  1440.     (short)trap_14_ww((short)(86),(short)mode)
  1441. #define         EsetSmear(mode)                        \
  1442.     (short)trap_14_ww((short)(87),(short)mode)
  1443.  
  1444. #define        DMAread(sector,count,buffer,devno)            \
  1445.     (long)trap_14_wlwlw((short)0x2a,(long)sector,(short)count,(long)buffer, \
  1446.                 (short)devno)
  1447. #define        DMAwrite(sector,count,buffer,devno)            \
  1448.     (long)trap_14_wlwlw((short)0x2b,(long)sector,(short)count,(long)buffer, \
  1449.             (short)devno)
  1450. #define        Bconmap(dev)                        \
  1451.     (long)trap_14_ww((short)0x2c,(short)(dev))
  1452. #define        NVMaccess(op,start,count,buf)                \
  1453.     (short)trap_14_wwwwl((short)0x2e,(short)op,(short)start,(short)count, \
  1454.             (long)buf)
  1455.  
  1456. /*  Wake-up call for ST BOOK -- takes date/time pair in DOS format. */
  1457.  
  1458. #define           Waketime(w_date, w_time)                    \
  1459.        (void)trap_14_www((short)(0x2f),(unsigned short)(w_date),    \
  1460.                        (unsigned short)(w_time))
  1461.  
  1462.  
  1463. #ifdef __cplusplus
  1464. }
  1465. #endif
  1466.  
  1467. #endif /* __TURBOC__ */
  1468. #endif /* _OSBIND_H */
  1469.