Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /* os9k.h  -  OS-9000 i386 module header definitions
  2.    Copyright 2000 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.    
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC 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
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 51 Franklin Street - Fifth Floor,
  19. Boston, MA 02110-1301, USA.  */
  20. #if !defined(_MODULE_H)
  21. #define _MODULE_H
  22.  
  23. #define _MPF386
  24.  
  25. /* Size of common header less parity field.  */
  26. #define N_M_PARITY  (sizeof(mh_com)-sizeof(unisgned short))
  27. #define OLD_M_PARITY 46
  28. #define M_PARITY N_M_PARITY
  29.  
  30. #ifdef _MPF68K
  31. #define MODSYNC 0x4afc          /* Module header sync code for 680x0 processors.  */
  32. #endif
  33.  
  34. #ifdef _MPF386
  35. #define MODSYNC 0x4afc          /* Module header sync code for 80386 processors.  */
  36. #endif
  37.  
  38. #define MODREV  1               /* Module format revision 1.  */
  39. #define CRCCON  0x800063        /* CRC polynomial constant.  */
  40.  
  41. /* Module access permission values.  */
  42. #define MP_OWNER_READ   0x0001
  43. #define MP_OWNER_WRITE  0x0002
  44. #define MP_OWNER_EXEC   0x0004
  45. #define MP_GROUP_READ   0x0010
  46. #define MP_GROUP_WRITE  0x0020
  47. #define MP_GROUP_EXEC   0x0040
  48. #define MP_WORLD_READ   0x0100
  49. #define MP_WORLD_WRITE  0x0200
  50. #define MP_WORLD_EXEC   0x0400
  51. #define MP_WORLD_ACCESS 0x0777
  52. #define MP_OWNER_MASK   0x000f
  53. #define MP_GROUP_MASK   0x00f0
  54. #define MP_WORLD_MASK   0x0f00
  55. #define MP_SYSTM_MASK   0xf000
  56.  
  57. /* Module Type/Language values.  */
  58. #define MT_ANY          0
  59. #define MT_PROGRAM      0x0001
  60. #define MT_SUBROUT      0x0002
  61. #define MT_MULTI        0x0003
  62. #define MT_DATA         0x0004
  63. #define MT_TRAPLIB      0x000b
  64. #define MT_SYSTEM       0x000c
  65. #define MT_FILEMAN      0x000d
  66. #define MT_DEVDRVR      0x000e
  67. #define MT_DEVDESC      0x000f
  68. #define MT_MASK         0xff00
  69.  
  70. #define ML_ANY          0
  71. #define ML_OBJECT       1
  72. #define ML_ICODE        2
  73. #define ML_PCODE        3
  74. #define ML_CCODE        4
  75. #define ML_CBLCODE      5
  76. #define ML_FRTNCODE     6
  77. #define ML_MASK         0x00ff
  78.  
  79. #define mktypelang(type, lang)  (((type) << 8) | (lang))
  80.  
  81. /* Module Attribute values.  */
  82. #define MA_REENT        0x80
  83. #define MA_GHOST        0x40
  84. #define MA_SUPER        0x20
  85. #define MA_MASK         0xff00
  86. #define MR_MASK         0x00ff
  87.  
  88. #define mkattrevs(attr, revs)   (((attr) << 8) | (revs))
  89.  
  90. #define m_user          m_owner.grp_usr.usr
  91. #define m_group         m_owner.grp_usr.grp
  92. #define m_group_user    m_owner.group_user
  93.  
  94. /* Macro definitions for accessing module header fields.  */
  95. #define MODNAME(mod) ((u_char*)((u_char*)mod + ((Mh_com)mod)->m_name))
  96. #if 0
  97. /* Appears not to be used, and the u_int32 typedef is gone (because it
  98.    conflicted with a Mach header.  */
  99. #define MODSIZE(mod) ((u_int32)((Mh_com)mod)->m_size)
  100. #endif /* 0 */
  101. #define MHCOM_BYTES_SIZE 80
  102. #define N_BADMAG(a) (((a).a_info) != MODSYNC)
  103.  
  104. typedef struct mh_com
  105. {
  106.   /* Sync bytes ($4afc).  */
  107.   unsigned char m_sync[2];
  108.   unsigned char m_sysrev[2];    /* System revision check value.  */
  109.   unsigned char m_size[4];      /* Module size.  */
  110.   unsigned char m_owner[4];     /* Group/user id.  */
  111.   unsigned char m_name[4];      /* Offset to module name.  */
  112.   unsigned char m_access[2];    /* Access permissions.  */
  113.   unsigned char m_tylan[2];     /* Type/lang.  */
  114.   unsigned char m_attrev[2];    /* Rev/attr.  */
  115.   unsigned char m_edit[2];      /* Edition.  */
  116.   unsigned char m_needs[4];     /* Module hardware requirements flags. (reserved).  */
  117.   unsigned char m_usage[4];     /* Comment string offset.  */
  118.   unsigned char m_symbol[4];    /* Symbol table offset.  */
  119.   unsigned char m_exec[4];      /* Offset to execution entry point.  */
  120.   unsigned char m_excpt[4];     /* Offset to exception entry point.  */
  121.   unsigned char m_data[4];      /* Data storage requirement.  */
  122.   unsigned char m_stack[4];     /* Stack size.  */
  123.   unsigned char m_idata[4];     /* Offset to initialized data.  */
  124.   unsigned char m_idref[4];     /* Offset to data reference lists.  */
  125.   unsigned char m_init[4];      /* Initialization routine offset.  */
  126.   unsigned char m_term[4];      /* Termination routine offset.  */
  127.   unsigned char m_ident[2];     /* Ident code for ident program.  */
  128.   char          m_spare[8];     /* Reserved bytes.  */
  129.   unsigned char m_parity[2];    /* Header parity.  */
  130. } mh_com,*Mh_com;
  131.  
  132. /* Executable memory module.  */
  133. typedef mh_com *Mh_exec,mh_exec;
  134.  
  135. /* Data memory module.  */
  136. typedef mh_com *Mh_data,mh_data;
  137.  
  138. /* File manager memory module.  */
  139. typedef mh_com *Mh_fman,mh_fman;
  140.  
  141. /* Device driver module.  */
  142. typedef mh_com *Mh_drvr,mh_drvr;
  143.  
  144. /* Trap handler module.  */
  145. typedef mh_com mh_trap, *Mh_trap;
  146.  
  147. /* Device descriptor module.  */
  148. typedef mh_com *Mh_dev,mh_dev;
  149.  
  150. /* Configuration module.  */
  151. typedef mh_com *Mh_config, mh_config;
  152.  
  153. #if 0
  154.  
  155. #if !defined(_MODDIR_H)
  156. /* Go get _os_fmod (and others).  */
  157. #include <moddir.h>
  158. #endif
  159.  
  160. error_code _os_crc (void *, u_int32, int *);
  161. error_code _os_datmod (char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_data **);
  162. error_code _os_get_moddir (void *, u_int32 *);
  163. error_code _os_initdata (mh_com *, void *);
  164. error_code _os_link (char **, mh_com **, void **, u_int16 *, u_int16 *);
  165. error_code _os_linkm (mh_com *, void **, u_int16 *, u_int16 *);
  166. error_code _os_load (char *, mh_com **, void **, u_int32, u_int16 *, u_int16 *, u_int32);
  167. error_code _os_mkmodule (char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_com **, u_int32);
  168. error_code _os_modaddr (void *, mh_com **);
  169. error_code _os_setcrc (mh_com *);
  170. error_code _os_slink (u_int32, char *, void **, void **, mh_com **);
  171. error_code _os_slinkm (u_int32, mh_com *, void **, void **);
  172. error_code _os_unlink (mh_com *);
  173. error_code _os_unload (char *, u_int32);
  174. error_code _os_tlink (u_int32, char *, void **, mh_trap **, void *, u_int32);
  175. error_code _os_tlinkm (u_int32, mh_com *, void **, void *, u_int32);
  176. error_code _os_iodel (mh_com *);
  177. error_code _os_vmodul (mh_com *, mh_com *, u_int32);
  178. #endif /* 0 */
  179.  
  180. #endif
  181.