home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mnthlb30.zoo / osbind.h < prev    next >
C/C++ Source or Header  |  1993-06-02  |  48KB  |  1,471 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, int mode, long start, long length );
  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. long    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. #define Setexc(number, exchdlr)    Setexc(number, (void(*)())(exchdlr))
  202. long    Tickcal( void );
  203. _BPB    *Getbpb( int dev );
  204. long    Bcostat( int dev );
  205. long    Mediach( int dev );
  206. long    Drvmap( void );
  207. long    Kbshift( int mode );
  208. #define Getshift() Kbshift(-1)
  209.  
  210. /* XBios */
  211.  
  212. void    Initmous( int type, _PARAM *par, void (*mousevec)() );
  213. #define Initmous(type, par, mousevec) Initmous(type, par, (void(*)()) mousevec)
  214. void    *Ssbrk( int count );
  215. void    *Physbase( void );
  216. void    *Logbase( void );
  217. int     Getrez( void );
  218. void    Setscreen( void *laddr, void *paddr, int rez );
  219. void    Setpalette( void *pallptr );
  220. int     Setcolor( int colornum, int color );
  221. int     Floprd( void *buf, long filler, int devno, int sectno,
  222.                int trackno, int sideno, int count );
  223. int     Flopwr( void *buf, long filler, int devno, int sectno,
  224.                int trackno, int sideno, int count );
  225. int     Flopfmt( void *buf, long filler, int devno, int spt, int trackno,
  226.                 int sideno, int interlv, long magic, int virgin );
  227. void    Midiws( int cnt, void *ptr );
  228. void    Mfpint( int erno, void (*vector)() );
  229. _IOREC   *Iorec( int dev );
  230. long    Rsconf( int baud, int ctr, int ucr, int rsr, int tsr, int scr );
  231. _KEYTAB  *Keytbl( void *unshift, void *shift, void *capslock );
  232. long    Random( void );
  233. void    Protobt( void *buf, long serialno, int disktype, int execflag );
  234. int     Flopver( void *buf, long filler, int devno, int sectno,
  235.                 int trackno, int sideno, int count );
  236. void    Scrdmp( void );
  237. int     Cursconf( int func, int rate );
  238. void    Settime( unsigned long time );
  239. unsigned long  Gettime( void );
  240. void    Bioskeys( void );
  241. void    Ikbdws( int count, void *ptr );
  242. void    Jdisint( int number );
  243. void    Jenabint( int number );
  244. char    Giaccess( char data, int regno );
  245. void    Offgibit( int bitno );
  246. void    Ongibit( int bitno );
  247. void    Xbtimer( int timer, int control, int data, void (*vector)() );
  248. void    *Dosound( void *buf );
  249. int     Setprt( int config );
  250. _KBDVECS *Kbdvbase( void );
  251. int     Kbrate( int initial, int repeat );
  252. void    Prtblk( _PBDEF *par );
  253. void    Vsync( void );
  254. long    Supexec( long (*func)() );
  255. #define Supexec(func) Supexec((long (*) ()) func)
  256. void    Puntaes( void );
  257. int     Floprate( int devno, int newrate );
  258. int     Blitmode( int mode );
  259.  
  260. /* TOS030 XBios */
  261. int     DMAread( long sector, int count, void *buffer, int devno );
  262. int     DMAwrite( long sector, int count, void *buffer, int devno );
  263. int     NVMaccess( int opcode, int start, int count, void *buffer );
  264. long    Bconmap( int devno );
  265. int     Esetshift( int shftMode );
  266. #define EsetShift Esetshift
  267. int     Egetshift( void );
  268. #define EgetShift Egetshift
  269. int     EsetBank( int bankNum );
  270. int     EsetColor( int colorNum, int color );
  271. void    EsetPalette( int colorNum, int count, int *palettePtr );
  272. void    EgetPalette( int colorNum, int count, int *palettePtr );
  273. int     EsetGray( int swtch );
  274. int     EsetSmear( int swtch );
  275.  
  276. #else /* !__TURBOC__ */
  277.  
  278. /* want to skip all the gory details of GNU C inlines??
  279.    search for the string "DEFINITIONS" */
  280.  
  281. #ifdef __GNUC_INLINE__
  282. /*
  283.  * GNU C (pseudo inline) Statement Exprs for traps
  284.  *
  285.  */
  286.  
  287. #define trap_1_w(n)                            \
  288. ({                                    \
  289.     register long retvalue __asm__("d0");                \
  290.                                         \
  291.     __asm__ volatile                        \
  292.     ("\
  293.         movw    %1,sp@-; \
  294.         trap    #1;    \
  295.         addqw   #2,sp "                        \
  296.     : "=r"(retvalue)            /* outputs */        \
  297.     : "g"(n)                /* inputs  */        \
  298.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  299.     );                                \
  300.     retvalue;                            \
  301. })
  302.  
  303. #define trap_1_ww(n, a)                            \
  304. ({                                    \
  305.     register long retvalue __asm__("d0");                \
  306.     short _a = (short)(a);                        \
  307.                                         \
  308.     __asm__ volatile                        \
  309.     ("\
  310.         movw    %2,sp@-; \
  311.         movw    %1,sp@-; \
  312.         trap    #1;    \
  313.         addqw   #4,sp "                        \
  314.     : "=r"(retvalue)            /* outputs */        \
  315.     : "g"(n), "r"(_a)            /* inputs  */        \
  316.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  317.     );                                \
  318.     retvalue;                            \
  319. })
  320.  
  321. #define trap_1_wl(n, a)                            \
  322. ({                                    \
  323.     register long retvalue __asm__("d0");                \
  324.     long  _a = (long) (a);                        \
  325.                                         \
  326.     __asm__ volatile                        \
  327.     ("\
  328.         movl    %2,sp@-; \
  329.         movw    %1,sp@-; \
  330.         trap    #1;    \
  331.         addqw   #6,sp "                        \
  332.     : "=r"(retvalue)            /* outputs */        \
  333.     : "g"(n), "r"(_a)            /* inputs  */        \
  334.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  335.     );                                \
  336.     retvalue;                            \
  337. })
  338.  
  339. #define trap_1_wlw(n, a, b)                        \
  340. ({                                    \
  341.     register long retvalue __asm__("d0");                \
  342.     long  _a = (long) (a);                        \
  343.     short _b = (short)(b);                        \
  344.                                         \
  345.     __asm__ volatile                        \
  346.     ("\
  347.         movw    %3,sp@-; \
  348.         movl    %2,sp@-; \
  349.         movw    %1,sp@-; \
  350.         trap    #1;    \
  351.         addqw   #8,sp "                        \
  352.     : "=r"(retvalue)            /* outputs */        \
  353.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  354.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  355.     );                                \
  356.     retvalue;                            \
  357. })
  358.  
  359. #define trap_1_wwll(n, a, b, c)                        \
  360. ({                                    \
  361.     register long retvalue __asm__("d0");                \
  362.     short _a = (short)(a);                        \
  363.     long  _b = (long) (b);                        \
  364.     long  _c = (long) (c);                        \
  365.                                         \
  366.     __asm__ volatile                        \
  367.     ("\
  368.         movl    %4,sp@-; \
  369.         movl    %3,sp@-; \
  370.         movw    %2,sp@-; \
  371.         movw    %1,sp@-; \
  372.         trap    #1;    \
  373.         addw    #12,sp "                    \
  374.     : "=r"(retvalue)            /* outputs */        \
  375.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  376.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  377.     );                                \
  378.     retvalue;                            \
  379. })
  380.  
  381. #define trap_1_wlww(n, a, b, c)                        \
  382. ({                                    \
  383.     register long retvalue __asm__("d0");                \
  384.     long  _a = (long) (a);                        \
  385.     short _b = (short)(b);                        \
  386.     short _c = (short)(c);                        \
  387.                                         \
  388.     __asm__ volatile                        \
  389.     ("\
  390.         movw    %4,sp@-; \
  391.         movw    %3,sp@-; \
  392.         movl    %2,sp@-; \
  393.         movw    %1,sp@-; \
  394.         trap    #1;    \
  395.         addw    #10,sp "                    \
  396.     : "=r"(retvalue)            /* outputs */        \
  397.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  398.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  399.     );                                \
  400.     retvalue;                            \
  401. })
  402.  
  403. #define trap_1_www(n, a, b)                        \
  404. ({                                    \
  405.     register long retvalue __asm__("d0");                \
  406.     short _a = (short)(a);                        \
  407.     short _b = (short)(b);                        \
  408.                                         \
  409.     __asm__ volatile                        \
  410.     ("\
  411.         movw    %3,sp@-; \
  412.         movw    %2,sp@-; \
  413.         movw    %1,sp@-; \
  414.         trap    #1;    \
  415.         addqw   #6,sp "                        \
  416.     : "=r"(retvalue)            /* outputs */        \
  417.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  418.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  419.     );                                \
  420.     retvalue;                            \
  421. })
  422.  
  423. #define trap_1_wll(n, a, b)                        \
  424. ({                                    \
  425.     register long retvalue __asm__("d0");                \
  426.     long  _a = (long) (a);                        \
  427.     long  _b = (long) (b);                        \
  428.                                         \
  429.     __asm__ volatile                        \
  430.     ("\
  431.         movl    %3,sp@-; \
  432.         movl    %2,sp@-; \
  433.         movw    %1,sp@-; \
  434.         trap    #1;    \
  435.         addw    #10,sp "                    \
  436.     : "=r"(retvalue)            /* outputs */        \
  437.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  438.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  439.     );                                \
  440.     retvalue;                            \
  441. })
  442.  
  443. #define trap_1_wwlll(n, a, b, c, d)                    \
  444. ({                                    \
  445.     register long retvalue __asm__("d0");                \
  446.     short _a = (short)(a);            \
  447.     long  _b = (long) (b);            \
  448.     long  _c = (long) (c);            \
  449.     long  _d = (long) (d);            \
  450.                                         \
  451.     __asm__ volatile                        \
  452.     ("\
  453.         movl    %4,sp@-; \
  454.         movl    %3,sp@-; \
  455.         movl    %2,sp@-; \
  456.         movw    %1,sp@-; \
  457.         movw    %0,sp@- "                    \
  458.     :                         /* outputs */    \
  459.     : "g"(n), "r"(_a), "r"(_b), "r"(_c), "r"(_d) /* inputs  */    \
  460.         );                                \
  461.   /* no more than 5 operand allowed in asm() -- therefore the split */  \
  462.                                     \
  463.     __asm__ volatile                        \
  464.     ("\
  465.         trap    #1;    \
  466.         addw    #16,sp "                    \
  467.     : "=r"(retvalue)            /* outputs */        \
  468.     :                    /* inputs  */        \
  469.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  470.     );                                \
  471.     retvalue;                            \
  472. })
  473.  
  474. #define trap_1_wwwll(n, a, b, c, d)                    \
  475. ({                                    \
  476.     register long retvalue __asm__("d0");                \
  477.     short _a = (short)(a);                        \
  478.     short _b = (short)(b);                        \
  479.     long  _c = (long) (c);                        \
  480.     long  _d = (long) (d);                        \
  481.                                         \
  482.     __asm__ volatile                        \
  483.     ("\
  484.         movl    %5,sp@-; \
  485.         movl    %4,sp@-; \
  486.         movw    %3,sp@-; \
  487.         movw    %2,sp@-; \
  488.         movw    %1,sp@-; \
  489.         trap    #1;    \
  490.         addw    #16,sp "                    \
  491.     : "=r"(retvalue)            /* outputs */        \
  492.     : "g"(n), "r"(_a), "r"(_b), "r"(_c), "r"(_d) /* inputs  */    \
  493.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  494.     );                                \
  495.     retvalue;                            \
  496. })
  497.  
  498. #define trap_13_wl(n, a)                        \
  499. ({                                    \
  500.     register long retvalue __asm__("d0");                \
  501.     long  _a = (long) (a);                        \
  502.                                         \
  503.     __asm__ volatile                        \
  504.     ("\
  505.         movl    %2,sp@-; \
  506.         movw    %1,sp@-; \
  507.         trap    #13;    \
  508.         addqw   #6,sp "                        \
  509.     : "=r"(retvalue)            /* outputs */        \
  510.     : "g"(n), "r"(_a)            /* inputs  */        \
  511.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  512.     );                                \
  513.     retvalue;                            \
  514. })
  515.  
  516. #define trap_13_w(n)                            \
  517. ({                                    \
  518.     register long retvalue __asm__("d0");                \
  519.                                         \
  520.     __asm__ volatile                        \
  521.     ("\
  522.         movw    %1,sp@-; \
  523.         trap    #13;    \
  524.         addqw   #2,sp "                        \
  525.     : "=r"(retvalue)            /* outputs */        \
  526.     : "g"(n)                /* inputs  */        \
  527.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  528.     );                                \
  529.     retvalue;                            \
  530. })
  531.  
  532. #define trap_13_ww(n, a)                        \
  533. ({                                    \
  534.     register long retvalue __asm__("d0");                \
  535.     short _a = (short)(a);                        \
  536.                                         \
  537.     __asm__ volatile                        \
  538.     ("\
  539.         movw    %2,sp@-; \
  540.         movw    %1,sp@-; \
  541.         trap    #13;    \
  542.         addqw   #4,sp "                        \
  543.     : "=r"(retvalue)            /* outputs */        \
  544.     : "g"(n), "r"(_a)            /* inputs  */        \
  545.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  546.     );                                \
  547.     retvalue;                            \
  548. })
  549.  
  550. #define trap_13_www(n, a, b)                        \
  551. ({                                    \
  552.     register long retvalue __asm__("d0");                \
  553.     short _a = (short)(a);                        \
  554.     short _b = (short)(b);                        \
  555.                                         \
  556.     __asm__ volatile                        \
  557.     ("\
  558.         movw    %3,sp@-; \
  559.         movw    %2,sp@-; \
  560.         movw    %1,sp@-; \
  561.         trap    #13;    \
  562.         addqw   #6,sp "                        \
  563.     : "=r"(retvalue)            /* outputs */        \
  564.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  565.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  566.     );                                \
  567.     retvalue;                            \
  568. })
  569.  
  570. #define trap_13_wwlwww(n, a, b, c, d, e)                \
  571. ({                                    \
  572.     register long retvalue __asm__("d0");                \
  573.     short _a = (short)(a);            \
  574.     long  _b = (long) (b);            \
  575.     short _c = (short)(c);            \
  576.     short _d = (short)(d);            \
  577.     short _e = (short)(e);            \
  578.                                         \
  579.     __asm__ volatile                        \
  580.     ("\
  581.         movw    %4,sp@-; \
  582.         movw    %3,sp@-; \
  583.         movw    %2,sp@-; \
  584.         movl    %1,sp@-; \
  585.         movw    %0,sp@-    "                    \
  586.     :                          /* outputs */    \
  587.     : "r"(_a), "r"(_b), "r"(_c), "r"(_d), "r"(_e) /* inputs  */    \
  588.     );                                \
  589.                                     \
  590.     __asm__ volatile                        \
  591.     ("\
  592.         movw    %1,sp@-; \
  593.         trap    #13;    \
  594.         addw    #14,sp "                    \
  595.     : "=r"(retvalue)            /* outputs */        \
  596.     : "g"(n)                /* inputs  */        \
  597.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  598.     );                                \
  599.     retvalue;                            \
  600. })
  601.  
  602. #define trap_13_wwl(n, a, b)                        \
  603. ({                                    \
  604.     register long retvalue __asm__("d0");                \
  605.     short _a = (short)(a);                        \
  606.     long  _b = (long) (b);                        \
  607.                                         \
  608.     __asm__ volatile                        \
  609.     ("\
  610.         movl    %3,sp@-; \
  611.         movw    %2,sp@-; \
  612.         movw    %1,sp@-; \
  613.         trap    #13;    \
  614.         addqw   #8,sp "                        \
  615.     : "=r"(retvalue)            /* outputs */        \
  616.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  617.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  618.     );                                \
  619.     retvalue;                            \
  620. })
  621.  
  622. #define trap_14_wwl(n, a, b)                        \
  623. ({                                    \
  624.     register long retvalue __asm__("d0");                \
  625.     short _a = (short)(a);                        \
  626.     long  _b = (long) (b);                        \
  627.                                         \
  628.     __asm__ volatile                        \
  629.     ("\
  630.         movl    %3,sp@-; \
  631.         movw    %2,sp@-; \
  632.         movw    %1,sp@-; \
  633.         trap    #14;    \
  634.         addqw   #8,sp "                        \
  635.     : "=r"(retvalue)            /* outputs */        \
  636.     : "g"(n), "r"(_a), "r"(_b)              /* inputs  */        \
  637.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  638.     );                                \
  639.     retvalue;                            \
  640. })
  641.  
  642. #define trap_14_wwll(n, a, b, c)                    \
  643. ({                                    \
  644.     register long retvalue __asm__("d0");                \
  645.     short _a = (short)(a);                        \
  646.     long  _b = (long) (b);                        \
  647.     long  _c = (long) (c);                        \
  648.                                         \
  649.     __asm__ volatile                        \
  650.     ("\
  651.         movl    %4,sp@-; \
  652.         movl    %3,sp@-; \
  653.         movw    %2,sp@-; \
  654.         movw    %1,sp@-; \
  655.         trap    #14;    \
  656.         addw    #12,sp "                    \
  657.     : "=r"(retvalue)            /* outputs */        \
  658.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  659.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  660.     );                                \
  661.     retvalue;                            \
  662. })
  663.  
  664. #define trap_14_ww(n, a)                        \
  665. ({                                    \
  666.     register long retvalue __asm__("d0");                \
  667.     short _a = (short)(a);                        \
  668.                                         \
  669.     __asm__ volatile                        \
  670.     ("\
  671.         movw    %2,sp@-; \
  672.         movw    %1,sp@-; \
  673.         trap    #14;    \
  674.         addqw   #4,sp "                        \
  675.     : "=r"(retvalue)            /* outputs */        \
  676.     : "g"(n), "r"(_a)            /* inputs  */        \
  677.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  678.     );                                \
  679.     retvalue;                            \
  680. })
  681.  
  682. #define trap_14_w(n)                            \
  683. ({                                    \
  684.     register long retvalue __asm__("d0");                \
  685.                                         \
  686.     __asm__ volatile                        \
  687.     ("\
  688.         movw    %1,sp@-; \
  689.         trap    #14;    \
  690.         addqw   #2,sp "                        \
  691.     : "=r"(retvalue)            /* outputs */        \
  692.     : "g"(n)                /* inputs  */        \
  693.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  694.     );                                \
  695.     retvalue;                            \
  696. })
  697.  
  698. #define trap_14_wllw(n, a, b, c)                    \
  699. ({                                    \
  700.     register long retvalue __asm__("d0");                \
  701.     long  _a = (long) (a);                        \
  702.     long  _b = (long) (b);                        \
  703.     short _c = (short)(c);                        \
  704.                                         \
  705.     __asm__ volatile                        \
  706.     ("\
  707.         movw    %4,sp@-; \
  708.         movl    %3,sp@-; \
  709.         movl    %2,sp@-; \
  710.         movw    %1,sp@-; \
  711.         trap    #14;    \
  712.         addw    #12,sp "                    \
  713.     : "=r"(retvalue)            /* outputs */        \
  714.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)       /* inputs  */        \
  715.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  716.     );                                \
  717.     retvalue;                            \
  718. })
  719.  
  720. #define trap_14_wl(n, a)                        \
  721. ({                                    \
  722.     register long retvalue __asm__("d0");                \
  723.     long  _a = (long) (a);                        \
  724.                                         \
  725.     __asm__ volatile                        \
  726.     ("\
  727.         movl    %2,sp@-; \
  728.         movw    %1,sp@-; \
  729.         trap    #14;    \
  730.         addqw   #6,sp "                        \
  731.     : "=r"(retvalue)            /* outputs */        \
  732.     : "g"(n), "r"(_a)            /* inputs  */        \
  733.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  734.     );                                \
  735.     retvalue;                            \
  736. })
  737.  
  738. #define trap_14_www(n, a, b)                        \
  739. ({                                    \
  740.     register long retvalue __asm__("d0");                \
  741.     short _a = (short)(a);                        \
  742.     short _b = (short)(b);                        \
  743.                                         \
  744.     __asm__ volatile                        \
  745.     ("\
  746.         movw    %3,sp@-; \
  747.         movw    %2,sp@-; \
  748.         movw    %1,sp@-; \
  749.         trap    #14;    \
  750.         addqw   #6,sp "                        \
  751.     : "=r"(retvalue)            /* outputs */        \
  752.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  753.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  754.     );                                \
  755.     retvalue;                            \
  756. })
  757.  
  758. #define trap_14_wllwwwww(n, a, b, c, d, e, f, g)            \
  759. ({                                    \
  760.     register long retvalue __asm__("d0");                \
  761.     long  _a = (long) (a);                        \
  762.     long  _b = (long) (b);                        \
  763.     short _c = (short)(c);                        \
  764.     short _d = (short)(d);                        \
  765.     short _e = (short)(e);                        \
  766.     short _f = (short)(f);                        \
  767.     short _g = (short)(g);                        \
  768.                                         \
  769.     __asm__ volatile                        \
  770.     ("\
  771.         movw    %4,sp@-; \
  772.         movw    %3,sp@-; \
  773.         movw    %2,sp@-; \
  774.         movw    %1,sp@-; \
  775.         movw    %0,sp@-    "                    \
  776.     :                          /* outputs */    \
  777.     : "r"(_c), "r"(_d), "r"(_e), "r"(_f), "r"(_g) /* inputs  */    \
  778.     );                                \
  779.                                     \
  780.     __asm__ volatile                        \
  781.     ("\
  782.         movl    %3,sp@-; \
  783.         movl    %2,sp@-; \
  784.         movw    %1,sp@-; \
  785.         trap    #14;    \
  786.         addw    #20,sp "                    \
  787.     : "=r"(retvalue)            /* outputs */        \
  788.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  789.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  790.     );                                \
  791.     retvalue;                            \
  792. })
  793.  
  794. #define trap_14_wllwwwwlw(n, a, b, c, d, e, f, g, h)            \
  795. ({                                    \
  796.     register long retvalue __asm__("d0");                \
  797.     long  _a = (long) (a);                        \
  798.     long  _b = (long) (b);                        \
  799.     short _c = (short)(c);                        \
  800.     short _d = (short)(d);                        \
  801.     short _e = (short)(e);                        \
  802.     short _f = (short)(f);                        \
  803.     long  _g = (long) (g);                        \
  804.     short _h = (short)(h);                        \
  805.                                         \
  806.     __asm__ volatile                        \
  807.     ("\
  808.         movw    %4,sp@-; \
  809.         movl    %3,sp@-; \
  810.         movw    %2,sp@-; \
  811.         movw    %1,sp@-; \
  812.         movw    %0,sp@- "                    \
  813.     :                          /* outputs */    \
  814.     : "r"(_d), "r"(_e), "r"(_f), "r"(_g), "r"(_h) /* inputs  */    \
  815.     );                                \
  816.                                         \
  817.     __asm__ volatile                        \
  818.     ("\
  819.         movw    %4,sp@-; \
  820.         movl    %3,sp@-; \
  821.         movl    %2,sp@-; \
  822.         movw    %1,sp@-; \
  823.         trap    #14;    \
  824.         addw    #24,sp "                    \
  825.     : "=r"(retvalue)               /* outputs */    \
  826.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)        /* inputs  */    \
  827.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  828.     );                                \
  829.     retvalue;                            \
  830. })
  831.  
  832. #define trap_14_wllwwwwwlw(n, a, b, c, d, e, f, g, h, i)\
  833. ({\
  834. register long retvalue __asm__("d0");\
  835. long  _a = (long) (a);\
  836. long  _b = (long) (b);\
  837. short _c = (short)(c);\
  838. short _d = (short)(d);\
  839. short _e = (short)(e);\
  840. short _f = (short)(f);\
  841. short _g = (short)(g);\
  842. long  _h = (long) (h);\
  843. short _i = (short)(i);\
  844. \
  845. __asm__ volatile\
  846. ("\
  847. movw    %4,sp@-; \
  848. movl    %3,sp@-; \
  849. movw    %2,sp@-; \
  850. movw    %1,sp@-; \
  851. movw    %0,sp@- "\
  852. :/* outputs */\
  853. : "r"(_e), "r"(_f), "r"(_g), "r"(_h), "r"(_i) /* inputs  */\
  854. );\
  855. \
  856. __asm__ volatile\
  857. ("\
  858. movw    %4,sp@-; \
  859. movw    %3,sp@-; \
  860. movl    %2,sp@-; \
  861. movl    %1,sp@-; \
  862. movw    %0,sp@- "\
  863. :/* outputs */\
  864. : "g"(n), "r"(_a), "r"(_b), "r"(_c), "r"(_d) /* inputs  */\
  865. );\
  866. \
  867. __asm__ volatile\
  868. ("\
  869. trap    #14;\
  870. addw    #26,sp "\
  871. : "=r"(retvalue)/* outputs */\
  872. : /* inputs  */\
  873. : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */\
  874. );\
  875. retvalue;\
  876. })
  877.  
  878.  
  879. #define trap_14_wwwwwww(n, a, b, c, d, e, f)                \
  880. ({                                    \
  881.     register long retvalue __asm__("d0");                \
  882.     short _a = (short)(a);                        \
  883.     short _b = (short)(b);                        \
  884.     short _c = (short)(c);                        \
  885.     short _d = (short)(d);                        \
  886.     short _e = (short)(e);                        \
  887.     short _f = (short)(f);                        \
  888.                                         \
  889.     __asm__ volatile                        \
  890.     ("\
  891.         movw    %4,sp@-; \
  892.         movw    %3,sp@-; \
  893.         movw    %2,sp@-; \
  894.         movw    %1,sp@-; \
  895.         movw    %0,sp@- "                    \
  896.     :                            /* outputs */    \
  897.     : "r"(_b), "r"(_c), "r"(_d), "r"(_e), "r"(_f)    /* inputs  */    \
  898.     );                                \
  899.                                     \
  900.     __asm__ volatile                        \
  901.     ("\
  902.         movw    %2,sp@-; \
  903.         movw    %1,sp@-; \
  904.         trap    #14;    \
  905.         addw    #14,sp "                    \
  906.     : "=r"(retvalue)            /* outputs */        \
  907.     : "g"(n), "r"(_a)            /* inputs  */        \
  908.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  909.     );                                \
  910.     retvalue;                            \
  911. })
  912.  
  913. #define trap_14_wlll(n, a, b, c)                    \
  914. ({                                    \
  915.     register long retvalue __asm__("d0");                \
  916.     long  _a = (long) (a);                        \
  917.     long  _b = (long) (b);                        \
  918.     long  _c = (long) (c);                        \
  919.                                         \
  920.     __asm__ volatile                        \
  921.     ("\
  922.         movl    %4,sp@-; \
  923.         movl    %3,sp@-; \
  924.         movl    %2,sp@-; \
  925.         movw    %1,sp@-; \
  926.         trap    #14;    \
  927.         addw    #14,sp "                    \
  928.     : "=r"(retvalue)            /* outputs */        \
  929.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  930.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  931.     );                                \
  932.     retvalue;                            \
  933. })
  934.  
  935. #define trap_14_wllww(n, a, b, c, d)                    \
  936. ({                                    \
  937.     register long retvalue __asm__("d0");                \
  938.     long  _a = (long) (a);                        \
  939.     long  _b = (long) (b);                        \
  940.     short _c = (short)(c);                        \
  941.     short _d = (short)(d);                        \
  942.                                         \
  943.     __asm__ volatile                        \
  944.     ("\
  945.         movw    %3,sp@-; \
  946.         movw    %2,sp@-; \
  947.         movl    %1,sp@-; \
  948.         movl    %0,sp@- "                    \
  949.     :                    /* outputs */        \
  950.     : "r"(_a), "r"(_b), "r"(_c), "r"(_d)    /* inputs  */        \
  951.     );                                \
  952.                                     \
  953.     __asm__ volatile                        \
  954.     ("\
  955.         movw    %1,sp@-; \
  956.         trap    #14;    \
  957.         addw    #14,sp "                    \
  958.     : "=r"(retvalue)            /* outputs */        \
  959.     : "g"(n)                /* inputs  */        \
  960.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  961.     );                                \
  962.     retvalue;                            \
  963. })
  964.  
  965. #define trap_14_wwwwl(n, a, b, c, d)                    \
  966. ({                                    \
  967.     register long retvalue __asm__("d0");                \
  968.     short _a = (short)(a);                        \
  969.     short _b = (short)(b);                        \
  970.     short _c = (short)(c);                        \
  971.     long  _d = (long) (d);                        \
  972.                                         \
  973.     __asm__ volatile                        \
  974.     ("\
  975.         movl    %3,sp@-; \
  976.         movw    %2,sp@-; \
  977.         movw    %1,sp@-; \
  978.         movw    %0,sp@- "                    \
  979.     :                        /* outputs */    \
  980.     : "r"(_a), "r"(_b), "r"(_c), "r"(_d)        /* inputs  */    \
  981.     );                                \
  982.                                     \
  983.     __asm__ volatile                        \
  984.     ("\
  985.         movw    %1,sp@-; \
  986.         trap    #14;    \
  987.         addw    #12,sp "                    \
  988.     : "=r"(retvalue)            /* outputs */        \
  989.     : "g"(n)                /* inputs  */        \
  990.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  991.     );                                \
  992.     retvalue;                            \
  993. })
  994.  
  995. #define trap_14_wwwl(n, a, b, c)                    \
  996. ({                                    \
  997.     register long retvalue __asm__("d0");                \
  998.     short _a = (short)(a);                        \
  999.     short _b = (short)(b);                        \
  1000.     long  _c = (long)(c);                        \
  1001.                                         \
  1002.     __asm__ volatile                        \
  1003.     ("                                \
  1004.         movl    %4,sp@-;                    \
  1005.         movw    %3,sp@-;                    \
  1006.         movw    %2,sp@-;                    \
  1007.         movw    %1,sp@-;                    \
  1008.         trap    #14;                        \
  1009.         addqw   #6,sp "                        \
  1010.     : "=r"(retvalue)            /* outputs */        \
  1011.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)    /* inputs  */        \
  1012.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  1013.     );                                \
  1014.     retvalue;                            \
  1015. })
  1016.  
  1017. #define trap_14_wlwlw(n, a, b, c, d)                    \
  1018. ({                                    \
  1019.     register long retvalue __asm__("d0");                \
  1020.     long  _a = (long) (a);                        \
  1021.     short _b = (short)(b);                        \
  1022.     long  _c = (long) (c);                        \
  1023.     short _d = (short)(d);                        \
  1024.                                         \
  1025.     __asm__ volatile                        \
  1026.     ("\
  1027.         movw    %4,sp@-; \
  1028.         movl    %3,sp@-; \
  1029.         movw    %2,sp@-; \
  1030.         movl    %1,sp@-; \
  1031.         movw    %0,sp@-;" \
  1032.     :                    /* outputs */        \
  1033.     : "g"(n), "r"(_a), "r"(_b), "r"(_c), "r"(_d) /* inputs  */    \
  1034.     );                                \
  1035.                                     \
  1036.     __asm__ volatile                        \
  1037.     ("\
  1038.         trap    #14;    \
  1039.         addw    #14,sp "                    \
  1040.     : "=r"(retvalue)            /* outputs */        \
  1041.     :                    /* inputs  */        \
  1042.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  1043.     );                                \
  1044.     retvalue;                            \
  1045. })
  1046.  
  1047. #else /* __GNUC_INLINE__ */
  1048.  
  1049. # ifndef __MSHORT__
  1050. #  define _TRAP_X_
  1051. # else
  1052. #  ifdef __GNUC__
  1053. #   ifndef __MINT__
  1054. #    define _TRAP_X_
  1055. #   endif
  1056. #  endif
  1057. # endif /* !__MSHORT__ */
  1058.  
  1059. # ifdef _TRAP_X_
  1060. /* if inlines are not allowed, then declare things external */
  1061. __EXTERN long trap_1_w __PROTO((short n));
  1062. __EXTERN long trap_1_ww __PROTO((short n, short a));
  1063. __EXTERN long trap_1_wl __PROTO((short n, long a));
  1064. __EXTERN long trap_1_wlw __PROTO((short n, long a, short b));
  1065. __EXTERN long trap_1_wwll __PROTO((short n, short a, long b, long c));
  1066. __EXTERN long trap_1_wlww __PROTO((short n, long a, short b, short c));
  1067. __EXTERN long trap_1_www __PROTO((short n, short a, short b));
  1068. __EXTERN long trap_1_wll __PROTO((short n, long a, long b));
  1069. __EXTERN long trap_1_wwlll __PROTO((short n, short a, long b, long c, long d));
  1070. __EXTERN long trap_1_wwwll __PROTO((short n, short a, short b, long c, long d));
  1071. __EXTERN long trap_13_wl __PROTO((short n, long a));
  1072. __EXTERN long trap_13_w __PROTO((short n));
  1073. __EXTERN long trap_13_ww __PROTO((short n, short a));
  1074. __EXTERN long trap_13_www __PROTO((short n, short a, short b));
  1075. __EXTERN long trap_13_wwlwww __PROTO((short n, short a, long b, short c, short d, short e));
  1076. __EXTERN long trap_13_wwl __PROTO((short n, short a, long b));
  1077. __EXTERN long trap_14_wwl __PROTO((short n, short a, long b));
  1078. __EXTERN long trap_14_wwll __PROTO((short n, short a, long b, long c));
  1079. __EXTERN long trap_14_ww __PROTO((short n, short a));
  1080. __EXTERN long trap_14_w __PROTO((short n));
  1081. __EXTERN long trap_14_wllw __PROTO((short n, long a, long b, short c));
  1082. __EXTERN long trap_14_wl __PROTO((short n, long a));
  1083. __EXTERN long trap_14_www __PROTO((short n, short a, short b));
  1084. __EXTERN long trap_14_wllwwwww __PROTO((short n, long a, long b, short c, short d, short e, short f, short g));
  1085. __EXTERN long trap_14_wllwwwwlw __PROTO((short n, long a, long b, short c, short d, short e, short f, long g, short h));
  1086. __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));
  1087. __EXTERN long trap_14_wwwwwww __PROTO((short n, short a, short b, short c, short d, short e, short f));
  1088. __EXTERN long trap_14_wlll __PROTO((short n, long a, long b, long c));
  1089. __EXTERN long trap_14_wllww __PROTO((short n, long a, long b, short c, short d));
  1090. __EXTERN long trap_14_wwwwl __PROTO((short n, short a, short b, short c, long d));
  1091. __EXTERN long trap_14_wwwl __PROTO((short n, short a, short b, long c));
  1092. __EXTERN long trap_14_wlwlw __PROTO((short n, long a, short b, long c, short d));
  1093.  
  1094. # else /* __TRAP_X__ */
  1095.  
  1096. __EXTERN long gemdos    __PROTO((short, ...));
  1097. __EXTERN long bios    __PROTO((short, ...));
  1098. __EXTERN long xbios    __PROTO((short, ...));
  1099.  
  1100. #define trap_1_w    gemdos
  1101. #define trap_1_ww    gemdos
  1102. #define trap_1_wl    gemdos
  1103. #define trap_1_wlw    gemdos
  1104. #define trap_1_www    gemdos
  1105. #define trap_1_wll    gemdos
  1106. #define trap_1_wwll    gemdos
  1107. #define trap_1_wlww    gemdos
  1108. #define trap_1_wwlll    gemdos
  1109. #define trap_1_wwwll    gemdos
  1110.  
  1111. #define trap_13_w    bios
  1112. #define trap_13_ww    bios
  1113. #define trap_13_wl    bios
  1114. #define trap_13_www    bios
  1115. #define trap_13_wwl    bios
  1116. #define trap_13_wwlwww    bios
  1117.  
  1118. #define trap_14_w    xbios
  1119. #define trap_14_ww    xbios
  1120. #define trap_14_wl    xbios
  1121. #define trap_14_www    xbios
  1122. #define trap_14_wwl    xbios
  1123. #define trap_14_wwll    xbios
  1124. #define trap_14_wllw    xbios
  1125. #define trap_14_wlll    xbios
  1126. #define trap_14_wwwl    xbios
  1127. #define trap_14_wwwwl    xbios
  1128. #define trap_14_wllww    xbios
  1129. #define trap_14_wwwwwww    xbios
  1130. #define trap_14_wllwwwww    xbios
  1131. #define trap_14_wllwwwwlw    xbios
  1132. #define trap_14_wllwwwwwlw    xbios
  1133. #define trap_14_wlwlw    xbios
  1134.  
  1135. # endif /* _TRAP_X_ */
  1136.  
  1137. #endif /* __GNUC_INLINE__ */
  1138.  
  1139.  
  1140. /* DEFINITIONS FOR OS FUNCTIONS */
  1141.  
  1142. /*
  1143.  *     GEMDOS  (trap1)
  1144.  */
  1145. #define           Pterm0()                                      \
  1146.        (void)trap_1_w((short)(0x00))
  1147. #define           Cconin()                               \
  1148.        (long)trap_1_w((short)(0x01))
  1149. #define           Cconout(c)                           \
  1150.        (void)trap_1_ww((short)(0x02),(short)(c))
  1151. #define           Cauxin()                               \
  1152.        (long)trap_1_w((short)(0x03))
  1153. #define           Cauxout(c)                           \
  1154.        (void)trap_1_ww((short)(0x04),(short)(c))
  1155. #define           Cprnout(c)                           \
  1156.        (void)trap_1_ww((short)(0x05),(short)(c))
  1157. #define           Crawio(data)                           \
  1158.        (long)trap_1_ww((short)(0x06),(short)(data))
  1159. #define           Crawcin()                           \
  1160.        (long)trap_1_w((short)(0x07))
  1161. #define           Cnecin()                               \
  1162.        (long)trap_1_w((short)(0x08))
  1163. #define           Cconws(s)                           \
  1164.        (void)trap_1_wl((short)(0x09),(long)(s))
  1165. #define           Cconrs(buf)                           \
  1166.        (void)trap_1_wl((short)(0x0A),(long)(buf))
  1167. #define           Cconis()                               \
  1168.        (short)trap_1_w((short)(0x0B))
  1169. #define           Dsetdrv(d)                           \
  1170.        (long)trap_1_ww((short)(0x0E),(short)(d))
  1171. #define           Cconos()                               \
  1172.        (short)trap_1_w((short)(0x10))
  1173. #define           Cprnos()                               \
  1174.        (short)trap_1_w((short)(0x11))
  1175. #define           Cauxis()                               \
  1176.        (short)trap_1_w((short)(0x12))
  1177. #define           Cauxos()                               \
  1178.        (short)trap_1_w((short)(0x13))
  1179. #define           Dgetdrv()                           \
  1180.        (short)trap_1_w((short)(0x19))
  1181. #define           Fsetdta(dta)                           \
  1182.        (void)trap_1_wl((short)(0x1A),(long)(dta))
  1183.  
  1184. /*
  1185.  * The next binding is not quite right if used in another than the usual ways:
  1186.  *    1. Super(1L) from either user or supervisor mode
  1187.  *    2. ret = Super(0L) from user mode and after this Super(ret) from
  1188.  *       supervisor mode
  1189.  * We get the following situations (usp, ssp relative to the start of Super):
  1190.  *    Parameter    Userstack    Superstack    Calling Mode    ret
  1191.  *       1L           usp           ssp            user     0L
  1192.  *       1L           usp           ssp         supervisor    -1L
  1193.  *       0L          usp-6           usp            user    ssp
  1194.  *       0L           ssp          ssp-6         supervisor   ssp-6
  1195.  *      ptr          usp-6          ptr+6            user    ssp
  1196.  *      ptr          usp+6           ptr         supervisor     sr
  1197.  * The usual C-bindings are safe only because the "unlk a6" is compensating
  1198.  * the errors when you invoke this function. In this binding the "unlk a6" at
  1199.  * the end of the calling function compensates the error made in sequence 2
  1200.  * above (the usp is 6 to low after the first call which is not corrected by
  1201.  * the second call).
  1202.  */
  1203. #define           Super(ptr)                           \
  1204.        (long)trap_1_wl((short)(0x20),(long)(ptr))
  1205.     /* Tos 1.4: Super(1L) : rets -1L if in super mode, 0L otherwise */
  1206. #define           Tgetdate()                           \
  1207.        (short)trap_1_w((short)(0x2A))
  1208. #define           Tsetdate(date)                           \
  1209.        (long)trap_1_ww((short)(0x2B),(short)(date))
  1210. #define           Tgettime()                           \
  1211.        (short)trap_1_w((short)(0x2C))
  1212. #define           Tsettime(time)                           \
  1213.        (long)trap_1_ww((short)(0x2D),(short)(time))
  1214. #define           Fgetdta()                           \
  1215.        (_DTA *)trap_1_w((short)(0x2F))
  1216. #define           Sversion()                           \
  1217.        (short)trap_1_w((short)(0x30))
  1218. #define           Ptermres(save,rv)                       \
  1219.        (void)trap_1_wlw((short)(0x31),(long)(save),(short)(rv))
  1220. #define           Dfree(buf,d)                           \
  1221.        (long)trap_1_wlw((short)(0x36),(long)(buf),(short)(d))
  1222. #define           Dcreate(path)                           \
  1223.        (short)trap_1_wl((short)(0x39),(long)(path))
  1224. #define           Ddelete(path)                           \
  1225.        (long)trap_1_wl((short)(0x3A),(long)(path))
  1226. #define           Dsetpath(path)                           \
  1227.        (long)trap_1_wl((short)(0x3B),(long)(path))
  1228. #define           Fcreate(fn,mode)                           \
  1229.        (long)trap_1_wlw((short)(0x3C),(long)(fn),(short)(mode))
  1230. #define           Fopen(fn,mode)                           \
  1231.        (long)trap_1_wlw((short)(0x3D),(long)(fn),(short)(mode))
  1232. #define           Fclose(handle)                           \
  1233.        (long)trap_1_ww((short)(0x3E),(short)(handle))
  1234. #define           Fread(handle,cnt,buf)                       \
  1235.        (long)trap_1_wwll((short)(0x3F),(short)(handle),           \
  1236.              (long)(cnt),(long)(buf))
  1237. #define           Fwrite(handle,cnt,buf)                       \
  1238.        (long)trap_1_wwll((short)(0x40),(short)(handle),           \
  1239.              (long)(cnt),(long)(buf))
  1240. #define           Fdelete(fn)                           \
  1241.        (long)trap_1_wl((short)(0x41),(long)(fn))
  1242. #define           Fseek(where,handle,how)                       \
  1243.        (long)trap_1_wlww((short)(0x42),(long)(where),           \
  1244.              (short)(handle),(short)(how))
  1245. #define           Fattrib(fn,rwflag,attr)                       \
  1246.        (short)trap_1_wlww((short)(0x43),(long)(fn),           \
  1247.               (short)(rwflag),(short)(attr))
  1248. #define           Fdup(handle)                           \
  1249.        (long)trap_1_ww((short)(0x45),(short)(handle))
  1250. #define           Fforce(Hstd,Hnew)                       \
  1251.        (long)trap_1_www((short)(0x46),(short)(Hstd),(short)(Hnew))
  1252. #define           Dgetpath(buf,d)                           \
  1253.        (long)trap_1_wlw((short)(0x47),(long)(buf),(short)(d))
  1254. #define           Malloc(size)                           \
  1255.        (long)trap_1_wl((short)(0x48),(long)(size))
  1256. #define           Mfree(ptr)                           \
  1257.        (long)trap_1_wl((short)(0x49),(long)(ptr))
  1258. #define           Mshrink(ptr,size)                       \
  1259.        (long)trap_1_wwll((short)(0x4A),(short)0,(long)(ptr),(long)(size))
  1260. #define           Pexec(mode,prog,tail,env)               \
  1261.        (long)trap_1_wwlll((short)(0x4B),(short)(mode),(long)(prog),   \
  1262.                (long)(tail),(long)(env))
  1263. #define           Pterm(rv)                           \
  1264.        (void)trap_1_ww((short)(0x4C),(short)(rv))
  1265. #define           Fsfirst(filespec,attr)                       \
  1266.        (long)trap_1_wlw((short)(0x4E),(long)(filespec),(short)(attr))
  1267. #define           Fsnext()                               \
  1268.        (long)trap_1_w((short)(0x4F))
  1269. #define           Frename(zero,old,new)                       \
  1270.        (short)trap_1_wwll((short)(0x56),(short)(zero),           \
  1271.               (long)(old),(long)(new))
  1272. #define           Fdatime(timeptr,handle,rwflag)                   \
  1273.        (long)trap_1_wlww((short)(0x57),(long)(timeptr),           \
  1274.              (short)(handle),(short)(rwflag))
  1275. #define           Flock(handle,mode,start,length)                   \
  1276.        (long)trap_1_wwwll((short)(0x5C),(short)(handle),       \
  1277.               (short)(mode),(long)(start),(long)(length))
  1278.  
  1279. /*
  1280.  *     BIOS    (trap13)
  1281.  */
  1282. #define Getmpb(ptr)                           \
  1283.        (void)trap_13_wl((short)(0x00),(long)(ptr))
  1284. #define           Bconstat(dev)                           \
  1285.        (short)trap_13_ww((short)(0x01),(short)(dev))
  1286. #define           Bconin(dev)                           \
  1287.        (long)trap_13_ww((short)(0x02),(short)(dev))
  1288. #define           Bconout(dev,c)                           \
  1289.        (long)trap_13_www((short)(0x03),(short)(dev),(short)((c) & 0xFF))
  1290. /* since AHDI 3.1 there is a new call to Rwabs with one more parameter */
  1291. #define           Rwabs(rwflag,buf,n,sector,d)            \
  1292.        (long)trap_13_wwlwww((short)(0x04),(short)(rwflag),(long)(buf), \
  1293.                  (short)(n),(short)(sector),(short)(d))
  1294. #define           Setexc(vnum,vptr)                       \
  1295.        (void (*) __PROTO((void)))trap_13_wwl((short)(0x05),(short)(vnum),(long)(vptr))
  1296. #define           Tickcal()                           \
  1297.        (long)trap_13_w((short)(0x06))
  1298. #define           Getbpb(d)                           \
  1299.        (void *)trap_13_ww((short)(0x07),(short)(d))
  1300. #define           Bcostat(dev)                           \
  1301.        (short)trap_13_ww((short)(0x08),(short)(dev))
  1302. #define           Mediach(dev)                           \
  1303.        (short)trap_13_ww((short)(0x09),(short)(dev))
  1304. #define           Drvmap()                               \
  1305.        (long)trap_13_w((short)(0x0A))
  1306. #define           Kbshift(data)                           \
  1307.        (long)trap_13_ww((short)(0x0B),(short)(data))
  1308. #define           Getshift()                           \
  1309.     Kbshift(-1)
  1310.  
  1311.  
  1312. /*
  1313.  *     XBIOS   (trap14)
  1314.  */
  1315.  
  1316. #define           Initmous(type,param,vptr)                   \
  1317.        (void)trap_14_wwll((short)(0x00),(short)(type),           \
  1318.               (long)(param),(long)(vptr))
  1319. #define Ssbrk(size)                           \
  1320.        (void *)trap_14_ww((short)(0x01),(short)(size))
  1321. #define           Physbase()                           \
  1322.        (void *)trap_14_w((short)(0x02))
  1323. #define           Logbase()                           \
  1324.        (void *)trap_14_w((short)(0x03))
  1325. #define           Getrez()                               \
  1326.        (short)trap_14_w((short)(0x04))
  1327. #define           Setscreen(lscrn,pscrn,rez)                   \
  1328.        (void)trap_14_wllw((short)(0x05),(long)(lscrn),(long)(pscrn), \
  1329.               (short)(rez))
  1330. #define           Setpalette(palptr)                       \
  1331.        (void)trap_14_wl((short)(0x06),(long)(palptr))
  1332. #define           Setcolor(colornum,mixture)                   \
  1333.        (short)trap_14_www((short)(0x07),(short)(colornum),(short)(mixture))
  1334. #define           Floprd(buf,x,d,sect,trk,side,n)                   \
  1335.        (short)trap_14_wllwwwww((short)(0x08),(long)(buf),(long)(x), \
  1336.      (short)(d),(short)(sect),(short)(trk),(short)(side),(short)(n))
  1337. #define           Flopwr(buf,x,d,sect,trk,side,n)                   \
  1338.        (short)trap_14_wllwwwww((short)(0x09),(long)(buf),(long)(x), \
  1339.            (short)(d),(short)(sect),(short)(trk),(short)(side),(short)(n))
  1340. #define           Flopfmt(buf,x,d,spt,t,sd,i,m,v)               \
  1341.        (short)trap_14_wllwwwwwlw((short)(0x0A),(long)(buf),(long)(x), \
  1342.       (short)(d),(short)(spt),(short)(t),(short)(sd),(short)(i),  \
  1343.       (long)(m),(short)(v))
  1344. #define           Midiws(cnt,ptr)                           \
  1345.        (void)trap_14_wwl((short)(0x0C),(short)(cnt),(long)(ptr))
  1346. #define           Mfpint(vnum,vptr)                       \
  1347.        (void)trap_14_wwl((short)(0x0D),(short)(vnum),(long)(vptr))
  1348. #define           Iorec(ioDEV)                           \
  1349.        (void *)trap_14_ww((short)(0x0E),(short)(ioDEV))
  1350. #define           Rsconf(baud,flow,uc,rs,ts,sc)                   \
  1351.        (long)trap_14_wwwwwww((short)(0x0F),(short)(baud),(short)(flow), \
  1352.               (short)(uc),(short)(rs),(short)(ts),(short)(sc))
  1353.     /* ret old val: MSB -> ucr:8, rsr:8, tsr:8, scr:8 <- LSB */
  1354. #define           Keytbl(nrml,shft,caps)                       \
  1355.        (void *)trap_14_wlll((short)(0x10),(long)(nrml), \
  1356.                 (long)(shft),(long)(caps))
  1357. #define           Random()                               \
  1358.        (long)trap_14_w((short)(0x11))
  1359. #define           Protobt(buf,serial,dsktyp,exec)                   \
  1360.        (void)trap_14_wllww((short)(0x12),(long)(buf),(long)(serial), \
  1361.                (short)(dsktyp),(short)(exec))
  1362. #define           Flopver(buf,x,d,sect,trk,sd,n)                   \
  1363.        (short)trap_14_wllwwwww((short)(0x13),(long)(buf),(long)(x),(short)(d),\
  1364.            (short)(sect),(short)(trk),(short)(sd),(short)(n))
  1365. #define           Scrdmp()                               \
  1366.        (void)trap_14_w((short)(0x14))
  1367. #define           Cursconf(rate,attr)                       \
  1368.        (short)trap_14_www((short)(0x15),(short)(rate),(short)(attr))
  1369. #define           Settime(time)                           \
  1370.        (void)trap_14_wl((short)(0x16),(long)(time))
  1371. #define           Gettime()                           \
  1372.        (long)trap_14_w((short)(0x17))
  1373. #define           Bioskeys()                           \
  1374.        (void)trap_14_w((short)(0x18))
  1375. #define           Ikbdws(len_minus1,ptr)                       \
  1376.        (void)trap_14_wwl((short)(0x19),(short)(len_minus1),(long)(ptr))
  1377. #define           Jdisint(vnum)                           \
  1378.        (void)trap_14_ww((short)(0x1A),(short)(vnum))
  1379. #define           Jenabint(vnum)                           \
  1380.        (void)trap_14_ww((short)(0x1B),(short)(vnum))
  1381. #define           Giaccess(data,reg)                       \
  1382.        (short)trap_14_www((short)(0x1C),(short)(data),(short)(reg))
  1383. #define           Offgibit(ormask)                           \
  1384.        (void)trap_14_ww((short)(0x1D),(short)(ormask))
  1385. #define           Ongibit(andmask)                           \
  1386.        (void)trap_14_ww((short)(0x1E),(short)(andmask))
  1387. #define           Xbtimer(timer,ctrl,data,vptr)                   \
  1388.        (void)trap_14_wwwwl((short)(0x1F),(short)(timer),(short)(ctrl), \
  1389.                (short)(data),(long)(vptr))
  1390. #define           Dosound(ptr)                           \
  1391.        (void)trap_14_wl((short)(0x20),(long)(ptr))
  1392. #define           Setprt(config)                           \
  1393.        (short)trap_14_ww((short)(0x21),(short)(config))
  1394. #define           Kbdvbase()                           \
  1395.        (_KBDVECS*)trap_14_w((short)(0x22))
  1396. #define           Kbrate(delay,reprate)                       \
  1397.        (short)trap_14_www((short)(0x23),(short)(delay),(short)(reprate))
  1398. #define           Prtblk(pblkptr)                           \
  1399.        (void)trap_14_wl((short)(0x24),(long)(pblkptr)) /* obsolete ? */
  1400. #define           Vsync()                               \
  1401.        (void)trap_14_w((short)(0x25))
  1402. #define           Supexec(funcptr)                           \
  1403.        (long)trap_14_wl((short)(0x26),(long)(funcptr))
  1404. #define           Floprate(drive,rate)                       \
  1405.        (short)trap_14_www((short)(0x29),(short)(drive),(short)(rate))
  1406. #define           Blitmode(flag)                           \
  1407.        (short)trap_14_ww((short)(0x40),(short)(flag))
  1408. /*
  1409.  * Flag:
  1410.  *  -1: get config
  1411.  * !-1: set config    previous config returned
  1412.  *    bit
  1413.  *     0    0 blit mode soft    1 blit mode hardware
  1414.  *     1    0 no blitter        1 blitter present
  1415.  *    2..14   reserved
  1416.  *     15    must be zero on set/returned as zero
  1417.  * blitmode (bit 0) forced to soft if no blitter(bit 1 == 0).
  1418.  */
  1419.  
  1420. /*
  1421.  * extensions for TT TOS
  1422.  */
  1423.  
  1424. #define         Mxalloc(amt,flag)                    \
  1425.     (long)trap_1_wlw((short)(0x44),(long)(amt),(short)(flag))
  1426. #define        Maddalt(start,size)                    \
  1427.     (long)trap_1_wll((short)(0x14),(long)(start),(long)(size))
  1428.  
  1429. #define         EsetShift(mode)                        \
  1430.     (void)trap_14_ww((short)(80),(short)mode)
  1431. #define         EgetShift()                        \
  1432.     (short)trap_14_w((short)(81))
  1433. #define         EsetBank(bank)                        \
  1434.     (short)trap_14_ww((short)(82),(short)bank)
  1435. #define         EsetColor(num,val)                    \
  1436.     (short)trap_14_www((short)(83),(short)num,(short)val)
  1437. #define         EsetPalette(start,count,ptr)                \
  1438.     (void)trap_14_wwwl((short)(84),(short)start,(short)count,(long)ptr)
  1439. #define         EgetPalette(start,count,ptr)                \
  1440.     (void)trap_14_wwwl((short)(85),(short)start,(short)count,(long)ptr)
  1441. #define         EsetGray(mode)                        \
  1442.     (short)trap_14_ww((short)(86),(short)mode)
  1443. #define         EsetSmear(mode)                        \
  1444.     (short)trap_14_ww((short)(87),(short)mode)
  1445.  
  1446. #define        DMAread(sector,count,buffer,devno)            \
  1447.     (long)trap_14_wlwlw((short)0x2a,(long)sector,(short)count,(long)buffer, \
  1448.                 (short)devno)
  1449. #define        DMAwrite(sector,count,buffer,devno)            \
  1450.     (long)trap_14_wlwlw((short)0x2b,(long)sector,(short)count,(long)buffer, \
  1451.             (short)devno)
  1452. #define        Bconmap(dev)                        \
  1453.     (long)trap_14_ww((short)0x2c,(short)(dev))
  1454. #define        NVMaccess(op,start,count,buf)                \
  1455.     (short)trap_14_wwwwl((short)0x2e,(short)op,(short)start,(short)count, \
  1456.             (long)buf)
  1457.  
  1458. /*  Wake-up call for ST BOOK -- takes date/time pair in DOS format. */
  1459.  
  1460. #define           Waketime(w_date, w_time)                    \
  1461.        (void)trap_14_www((short)(0x2f),(unsigned short)(w_date),    \
  1462.                        (unsigned short)(w_time))
  1463.  
  1464.  
  1465. #ifdef __cplusplus
  1466. }
  1467. #endif
  1468.  
  1469. #endif /* __TURBOC__ */
  1470. #endif /* _OSBIND_H */
  1471.