home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / useful / include / ixemul.h.clues < prev    next >
Text File  |  1993-09-05  |  7KB  |  258 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.  *  $Id: ixemul.h,v 1.1 1992/05/14 20:36:14 mwild Exp $
  20.  *
  21.  *  $Log: ixemul.h,v $
  22.  * Revision 1.1  1992/05/14  20:36:14  mwild
  23.  * Initial revision
  24.  *
  25.  */
  26. /* #include "version.h" */
  27.  
  28. #ifdef START
  29. /* definitions for the assembler startup file */
  30.  
  31. /* when I've REALLY lots of free time, I'll rewrite header files, but now... */
  32.  
  33. /* amazingly works, contains only defines ;-)) */
  34. #include <exec/alerts.h>
  35.  
  36. #define _LVOOpenLibrary        -0x228
  37. #define _LVOCloseLibrary     -0x19e
  38. #define _LVOAlert        -0x6c
  39. #define _LVOFreeMem        -0xd2
  40. #define _LVORemove        -0xfc
  41.  
  42. #define RTC_MATCHWORD    0x4afc
  43. #define RTF_AUTOINIT    (1<<7)
  44.  
  45. #define LIBF_CHANGED    (1<<1)
  46. #define LIBF_SUMUSED    (1<<2)
  47. /* seems there is an assembler bug in expression evaluation here.. */
  48. #define LIBF_CHANGED_SUMUSED 0x6
  49. #define LIBF_DELEXP    (1<<3)
  50. #define LIBB_DELEXP    3
  51.  
  52. #define LN_TYPE        8
  53. #define LN_NAME        10
  54. #define NT_LIBRARY    9
  55. #define MP_FLAGS    14
  56. #define PA_IGNORE    2
  57.  
  58. #define LIST_SIZEOF    14
  59.  
  60. #define THISTASK    276
  61.  
  62. #define INITBYTE(field,val)    .word 0xe000; .word (field); .byte (val); .byte 0
  63. #define INITWORD(field,val)    .word 0xd000; .word (field); .word (val)
  64. #define INITLONG(field,val)    .word 0xc000; .word (field); .long (val)
  65.  
  66. /*
  67.  * our library base.. 
  68.  */
  69.  
  70. /* struct library */
  71. #define    IXBASE_NODE    0
  72. #define IXBASE_FLAGS    14
  73. #define IXBASE_NEGSIZE    16
  74. #define IXBASE_POSSIZE    18
  75. #define IXBASE_VERSION    20
  76. #define IXBASE_REVISION    22
  77. #define IXBASE_IDSTRING    24
  78. #define IXBASE_SUM    28
  79. #define IXBASE_OPENCNT    32
  80. #define IXBASE_LIBRARY    34    /* size of library */
  81.  
  82. /* custom part */
  83. #define IXBASE_MYFLAGS        (IXBASE_LIBRARY + 0)
  84. #define IXBASE_SYSLIB        (IXBASE_MYFLAGS + 2)
  85. #define IXBASE_SEGLIST        (IXBASE_SYSLIB  + 4)
  86. #define IXBASE_C_PRIVATE    (IXBASE_SEGLIST + 4)
  87. /* get size of C_PRIVATE with print_base_size.c */
  88. #define IXBASE_SIZEOF        (IXBASE_C_PRIVATE + 490)
  89.  
  90. #else  /* C-part */
  91.  
  92. #include <exec/types.h>
  93. #include <exec/libraries.h>
  94. #include <exec/execbase.h>
  95. #include <exec/semaphores.h>
  96. /* #include <exec/ports.h> */
  97. /* #include <libraries/dosextens.h> */
  98. /* #include <intuition/intuition.h> */
  99.  
  100. /* #include <sys/types.h> */
  101. #ifdef KERNEL
  102. #define _INTERNAL_FILE
  103. #endif
  104. #include <sys/file.h>
  105. #include <sys/param.h>
  106. #include <packets.h>
  107. #include <sys/syscall.h>
  108. #include <signal.h>
  109. #ifdef KERNEL
  110. #include <user.h>
  111. #endif
  112. #include <errno.h>
  113.  
  114. /* configure this to the number of hash queues you like, 
  115.  * use a prime number !!
  116.  */
  117. #define IX_NUM_SLEEP_QUEUES    31
  118.  
  119. struct ixemul_base {
  120.   struct Library    ix_lib;
  121.   unsigned char        ix_myflags;
  122.   unsigned char        ix_pad;
  123.   struct ExecBase*    ix_sys_base;
  124.   BPTR            ix_seg_list;
  125.  
  126.   /* needed library bases */
  127.   struct DOSBase    *ix_dos_base;
  128.   struct ArpBase    *ix_arp_base;
  129.   struct IntuitionBase    *ix_intui_base;
  130.   struct GfxBase    *ix_gfx_base;
  131.   struct MathIeeeSingBasBase    *ix_ms_base;
  132.   struct MathIeeeSingTransBase    *ix_mst_base;
  133.   struct MathIeeeDoubBasBase    *ix_md_base;
  134.   struct MathIeeeDoubTransBase    *ix_mdt_base;
  135.  
  136.  
  137.   /* the global file table with current size */
  138.   struct file        *ix_file_tab;
  139.   struct file        *ix_fileNFILE;
  140.   struct file        *ix_lastf;
  141.  
  142.   /* size of start of red zone from bottom of stack */
  143.   int            ix_red_zone_size;  D7     $58
  144.  
  145.   struct SignalSemaphore ix_semaph;
  146.   int            ix_membuf_limit;   *D4     $8A
  147.   
  148.   /* multiplier for id_BytesPerBlock to get to st_blksize, default 64 */
  149.   int            ix_fs_buf_factor;     *A2   $8E
  150.  
  151.  
  152.   /* enable Unix meaning of slash a dir-separator.
  153.    * Thus a///b is the same as a/b. Later, this flag enables /sys -> sys:
  154.    * translation as well.
  155.    */
  156.   int            :27,                            $95
  157.               ix_translate_dots:1,      *D6
  158.               ix_watch_stack:1,           *D2
  159.             ix_force_translation:1,    *A3
  160.               ix_translate_symlinks:1,   *A5
  161.             ix_translate_slash:1;      *D5
  162.  
  163.  
  164.  
  165.     D6    D2    A3      A5      D5       D3
  166.     1    3    0      4       2        6
  167.         $FD     $F7     $FE       $EF     $FB      $BF
  168.  
  169.      11111101 11110111 11111110 11101111 11111011  10111111
  170.  
  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. int syscall (enum _syscall_ vector, ...);
  182.  
  183. #ifdef KERNEL
  184. extern struct ixemul_base *ixemulbase;
  185. #define ix (*ixemulbase)
  186. #define u (*(struct user *)((*(struct ExecBase **)4)->ThisTask->tc_TrapData))
  187.  
  188. static inline u_int get_usp (void) 
  189.   u_int res;
  190.   asm volatile ("movel    usp,%0" : "=a" (res));
  191.   return res;
  192. }
  193.  
  194. static inline void set_usp (u_int new_usp)
  195. {
  196.   asm volatile ("movel  %0,usp" : /* no output */ : "a" (new_usp));
  197. }
  198.  
  199. static inline u_int get_sp (void) 
  200.   u_int res;
  201.   asm volatile ("movel    sp,%0" : "=a" (res));
  202.   return res;
  203. }
  204.  
  205. static inline void set_sp (u_int new_sp)
  206. {
  207.   asm volatile ("movel  %0,sp" : /* no output */ : "a" (new_sp));
  208. }
  209.  
  210. static inline u_short get_sr (void) 
  211.   u_short res;
  212.   asm volatile ("movew    sr,%0" : "=g" (res));
  213.   return res;
  214. }
  215.  
  216. static inline u_int get_fp (void) 
  217.   u_int res;
  218.   asm volatile ("movel    a5,%0" : "=g" (res));
  219.   return res;
  220. }
  221.  
  222. #define PRIVATE
  223. #include <inline/exec.h>
  224. #undef PRIVATE
  225.  
  226. #define BASE_EXT_DECL
  227. #define BASE_PAR_DECL    
  228. #define BASE_PAR_DECL0    
  229. #define BASE_NAME    ix.ix_dos_base
  230. #include <inline/dos.h>
  231.  
  232. #ifdef notyetneeded
  233. #define BASE_EXT_DECL
  234. #define BASE_PAR_DECL    
  235. #define BASE_PAR_DECL0    
  236. #define BASE_NAME    ix.ix_arp_base
  237. #include <inline/arp.h>
  238.  
  239. #define BASE_EXT_DECL
  240. #define BASE_PAR_DECL    
  241. #define BASE_PAR_DECL0    
  242. #define BASE_NAME    ix.ix_intui_base
  243. #include <inline/intuition.h>
  244. #endif
  245.  
  246. #define errno (* u.u_errno)
  247. extern struct MsgPort *ix_async_mp;
  248. #define __rwport (ix_async_mp)
  249. #else
  250. #define ix_errno (*((struct user *)(ixbase->ix_sys_base->ThisTask->tc_TrapData))->u_errno)
  251. #endif
  252.  
  253. #endif
  254.