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