os9k.h 5.9 KB

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