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