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