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