home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / gcc263-inclib.lha / gnu / include / library / ixemul.h next >
Encoding:
C/C++ Source or Header  |  1994-12-28  |  6.7 KB  |  261 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *  Portions Copyright (C) 1994 Rafael W. Luebbert
  5.  *
  6.  *  This library is free software; you can redistribute it and/or
  7.  *  modify it under the terms of the GNU Library General Public
  8.  *  License as published by the Free Software Foundation; either
  9.  *  version 2 of the License, or (at your option) any later version.
  10.  *
  11.  *  This library is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  *  Library General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU Library General Public
  17.  *  License along with this library; if not, write to the Free
  18.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  *  $Id: ixemul.h,v 1.6 1994/07/11 22:17:07 rluebbert Exp rluebbert $
  21.  *
  22.  *  $Log: ixemul.h,v $
  23.  *  Revision 1.6  1994/07/11  22:17:07  rluebbert
  24.  *  Removed arp.library from ixemulbase.
  25.  *
  26.  *  Revision 1.5  1994/06/19  15:12:39  rluebbert
  27.  *  *** empty log message ***
  28.  *
  29.  *  Revision 1.3  1992/10/20  16:32:33  mwild
  30.  *  *** empty log message ***
  31.  *
  32.  *  Revision 1.2  1992/07/04  19:25:26  mwild
  33.  *  change __rwport to reflect the current state of the (now global) async port
  34.  *
  35.  * Revision 1.1  1992/05/14  20:36:14  mwild
  36.  * Initial revision
  37.  *
  38.  */
  39.  
  40. #ifdef START
  41. #include "version.h"
  42.  
  43. /* definitions for the assembler startup file */
  44.  
  45. /* when I've REALLY lots of free time, I'll rewrite header files, but now... */
  46.  
  47. /* amazingly works, contains only defines ;-)) */
  48. #include <exec/alerts.h>
  49.  
  50. #define _LVOOpenLibrary        -0x228
  51. #define _LVOCloseLibrary     -0x19e
  52. #define _LVOAlert        -0x6c
  53. #define _LVOFreeMem        -0xd2
  54. #define _LVORemove        -0xfc
  55.  
  56. #define RTC_MATCHWORD    0x4afc
  57. #define RTF_AUTOINIT    (1<<7)
  58.  
  59. #define LIBF_CHANGED    (1<<1)
  60. #define LIBF_SUMUSED    (1<<2)
  61. /* seems there is an assembler bug in expression evaluation here.. */
  62. #define LIBF_CHANGED_SUMUSED 0x6
  63. #define LIBF_DELEXP    (1<<3)
  64. #define LIBB_DELEXP    3
  65.  
  66. #define LN_TYPE        8
  67. #define LN_NAME        10
  68. #define NT_LIBRARY    9
  69. #define MP_FLAGS    14
  70. #define PA_IGNORE    2
  71.  
  72. #define LIST_SIZEOF    14
  73.  
  74. #define THISTASK    276
  75.  
  76. #define INITBYTE(field,val)    .word 0xe000; .word (field); .byte (val); .byte 0
  77. #define INITWORD(field,val)    .word 0xd000; .word (field); .word (val)
  78. #define INITLONG(field,val)    .word 0xc000; .word (field); .long (val)
  79.  
  80. /*
  81.  * our library base.. 
  82.  */
  83.  
  84. /* struct library */
  85. #define    IXBASE_NODE    0
  86. #define IXBASE_FLAGS    14
  87. #define IXBASE_NEGSIZE    16
  88. #define IXBASE_POSSIZE    18
  89. #define IXBASE_VERSION    20
  90. #define IXBASE_REVISION    22
  91. #define IXBASE_IDSTRING    24
  92. #define IXBASE_SUM    28
  93. #define IXBASE_OPENCNT    32
  94. #define IXBASE_LIBRARY    34    /* size of library */
  95.  
  96. /* custom part */
  97. #define IXBASE_MYFLAGS        (IXBASE_LIBRARY + 0)
  98. #define IXBASE_SYSLIB        (IXBASE_MYFLAGS + 2)
  99. #define IXBASE_SEGLIST        (IXBASE_SYSLIB  + 4)
  100. #define IXBASE_C_PRIVATE    (IXBASE_SEGLIST + 4)
  101. /* get size of C_PRIVATE with print_base_size.c */
  102. #define IXBASE_SIZEOF        (IXBASE_C_PRIVATE + 490)
  103.  
  104. #else  /* C-part */
  105.  
  106. #include <exec/types.h>
  107. #include <exec/libraries.h>
  108. #include <exec/execbase.h>
  109. #include <exec/ports.h>
  110. #include <libraries/dosextens.h>
  111. #include <intuition/intuition.h>
  112.  
  113. #include <sys/types.h>
  114. #ifdef KERNEL
  115. #define _INTERNAL_FILE
  116. #endif
  117. #include <sys/file.h>
  118. #include <sys/param.h>
  119. #include <packets.h>
  120. #include <sys/syscall.h>
  121. #include <signal.h>
  122. #ifdef KERNEL
  123. #include <user.h>
  124. #endif
  125. #include <errno.h>
  126.  
  127. /* configure this to the number of hash queues you like, 
  128.  * use a prime number !!
  129.  */
  130. #define IX_NUM_SLEEP_QUEUES    31
  131.  
  132. struct ixemul_base {
  133.   struct Library    ix_lib;
  134.   unsigned char        ix_myflags;
  135.   unsigned char        ix_pad;
  136.   struct ExecBase*    ix_sys_base;
  137.   BPTR            ix_seg_list;
  138.  
  139.   /* needed library bases */
  140.   struct Library    *ix_dos_base;
  141.   struct IntuitionBase    *ix_intui_base;
  142.   struct GfxBase    *ix_gfx_base;
  143.   struct MathIeeeSingBasBase    *ix_ms_base;
  144.   void            *ix_libs;    /* was ix_mst_base */
  145.   struct MathIeeeDoubBasBase    *ix_md_base;
  146.   struct MathIeeeDoubTransBase    *ix_mdt_base;
  147.  
  148.  
  149.   /* the global file table with current size */
  150.   struct file        *ix_file_tab;
  151.   struct file        *ix_fileNFILE;
  152.   struct file        *ix_lastf;
  153.  
  154.   /* size of start of red zone from bottom of stack */
  155.   int            ix_red_zone_size;
  156.  
  157.   struct SignalSemaphore ix_semaph;
  158.   int            ix_membuf_limit;
  159.   
  160.   /* multiplier for id_BytesPerBlock to get to st_blksize, default 64 */
  161.   int            ix_fs_buf_factor;
  162.  
  163.   int            :25,
  164.               ix_ignore_global_env:1,
  165.               ix_disable_fibcache:1,
  166.               ix_translate_dots:1,
  167.               ix_watch_stack:1,
  168.             ix_force_translation:1,
  169.               ix_translate_symlinks:1,
  170.             ix_translate_slash:1;
  171.  
  172.   struct MinList    ix_sleep_queues [IX_NUM_SLEEP_QUEUES];
  173.  
  174.   struct MinList    ix_socket_list;
  175. };
  176.  
  177.  
  178. /* this is the only prototype of library functions, that are really used inside
  179.  * the library. (So a user can patch a function, and the library will use
  180.  * the new entry, and not a hard compiled address */
  181. #if 0
  182. int syscall (enum _syscall_ vector, ...);
  183. #else
  184. /* now that gcc can deal with varargs-macros, this can be inlined! */
  185. #define syscall(vec, args...) \
  186.   ({register int (*_sc)()=(void *)(&((char *)ixemulbase)[-((vec)+4)*6]); _sc(args);})
  187. #endif
  188.  
  189. #ifdef KERNEL
  190. extern struct ixemul_base *ixemulbase;
  191. extern struct user *curproc;
  192. #define ix (*ixemulbase)
  193. #if 0
  194. #define u_save (*(struct user *)((*(struct ExecBase **)4)->ThisTask->tc_TrapData))
  195. #define u (*curproc)
  196. #else
  197. #define u_save (*(struct user *)((*(struct ExecBase **)4)->ThisTask->tc_TrapData))
  198. #define u (*(struct user *)((*(struct ExecBase **)4)->ThisTask->tc_TrapData))
  199. #endif
  200.  
  201. static inline u_int get_usp (void) 
  202.   u_int res;
  203.   asm volatile ("movel    usp,%0" : "=a" (res));
  204.   return res;
  205. }
  206.  
  207. static inline void set_usp (u_int new_usp)
  208. {
  209.   asm volatile ("movel  %0,usp" : /* no output */ : "a" (new_usp));
  210. }
  211.  
  212. static inline u_int get_sp (void) 
  213.   u_int res;
  214.   asm volatile ("movel    sp,%0" : "=a" (res));
  215.   return res;
  216. }
  217.  
  218. static inline void set_sp (u_int new_sp)
  219. {
  220.   asm volatile ("movel  %0,sp" : /* no output */ : "a" (new_sp));
  221. }
  222.  
  223. static inline u_short get_sr (void) 
  224.   u_short res;
  225.   asm volatile ("movew    sr,%0" : "=g" (res));
  226.   return res;
  227. }
  228.  
  229. static inline u_int get_fp (void) 
  230.   u_int res;
  231.   asm volatile ("movel    a5,%0" : "=g" (res));
  232.   return res;
  233. }
  234. #define PRIVATE
  235. #include <inline/exec.h>
  236. #undef PRIVATE
  237.  
  238. #define BASE_EXT_DECL
  239. #define BASE_PAR_DECL    
  240. #define BASE_PAR_DECL0    
  241. #define BASE_NAME    ((struct DosLibrary *) ix.ix_dos_base)
  242. #include <inline/dos.h>
  243.  
  244. #define errno (* u.u_errno)
  245. extern struct MsgPort *ix_async_mp;
  246. #define __rwport (ix_async_mp)
  247. #else
  248. #define ix_errno (*((struct user *)(ixbase->ix_sys_base->ThisTask->tc_TrapData))->u_errno)
  249. #endif
  250.  
  251. /* *BLOODY* commododities.h defines IX_VERSION too, so wait for our defines
  252.    to come last, and undef the sucker now!! */
  253. #undef IX_VERSION
  254. #include "version.h"
  255.  
  256. #endif
  257.