home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / library / rcs / ixemul.h,v < prev    next >
Encoding:
Text File  |  1992-07-04  |  6.6 KB  |  296 lines

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