home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GCC258_1.LHA / gcc / include / library / ixemul.h
Encoding:
C/C++ Source or Header  |  1985-12-13  |  6.4 KB  |  255 lines

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