xref: /netbsd-src/external/gpl3/binutils.old/dist/include/os9k.h (revision e992f068c547fd6e84b3f104dc2340adcc955732)
175fd0b74Schristos /* os9k.h  -  OS-9000 i386 module header definitions
2*e992f068Schristos    Copyright (C) 2000-2022 Free Software Foundation, Inc.
375fd0b74Schristos 
475fd0b74Schristos This file is part of GNU CC.
575fd0b74Schristos 
675fd0b74Schristos GNU CC is free software; you can redistribute it and/or modify
775fd0b74Schristos it under the terms of the GNU General Public License as published by
875fd0b74Schristos the Free Software Foundation; either version 2, or (at your option)
975fd0b74Schristos any later version.
1075fd0b74Schristos 
1175fd0b74Schristos GNU CC is distributed in the hope that it will be useful,
1275fd0b74Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
1375fd0b74Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1475fd0b74Schristos GNU General Public License for more details.
1575fd0b74Schristos 
1675fd0b74Schristos You should have received a copy of the GNU General Public License
1775fd0b74Schristos along with GNU CC; see the file COPYING.  If not, write to
1875fd0b74Schristos the Free Software Foundation, 51 Franklin Street - Fifth Floor,
1975fd0b74Schristos Boston, MA 02110-1301, USA.  */
2075fd0b74Schristos 
2175fd0b74Schristos #if !defined(_MODULE_H)
2275fd0b74Schristos #define _MODULE_H
2375fd0b74Schristos 
2475fd0b74Schristos #define _MPF386
2575fd0b74Schristos 
2675fd0b74Schristos /* Size of common header less parity field.  */
2775fd0b74Schristos #define N_M_PARITY  (sizeof(mh_com)-sizeof(unisgned short))
2875fd0b74Schristos #define OLD_M_PARITY 46
2975fd0b74Schristos #define M_PARITY N_M_PARITY
3075fd0b74Schristos 
3175fd0b74Schristos #ifdef _MPF68K
3275fd0b74Schristos #define MODSYNC 0x4afc		/* Module header sync code for 680x0 processors.  */
3375fd0b74Schristos #endif
3475fd0b74Schristos 
3575fd0b74Schristos #ifdef _MPF386
3675fd0b74Schristos #define MODSYNC 0x4afc		/* Module header sync code for 80386 processors.  */
3775fd0b74Schristos #endif
3875fd0b74Schristos 
3975fd0b74Schristos #define MODREV	1		/* Module format revision 1.  */
4075fd0b74Schristos #define CRCCON	0x800063	/* CRC polynomial constant.  */
4175fd0b74Schristos 
4275fd0b74Schristos /* Module access permission values.  */
4375fd0b74Schristos #define MP_OWNER_READ	0x0001
4475fd0b74Schristos #define MP_OWNER_WRITE	0x0002
4575fd0b74Schristos #define MP_OWNER_EXEC	0x0004
4675fd0b74Schristos #define MP_GROUP_READ	0x0010
4775fd0b74Schristos #define MP_GROUP_WRITE	0x0020
4875fd0b74Schristos #define MP_GROUP_EXEC	0x0040
4975fd0b74Schristos #define MP_WORLD_READ	0x0100
5075fd0b74Schristos #define MP_WORLD_WRITE	0x0200
5175fd0b74Schristos #define MP_WORLD_EXEC	0x0400
5275fd0b74Schristos #define MP_WORLD_ACCESS	0x0777
5375fd0b74Schristos #define MP_OWNER_MASK	0x000f
5475fd0b74Schristos #define MP_GROUP_MASK	0x00f0
5575fd0b74Schristos #define MP_WORLD_MASK	0x0f00
5675fd0b74Schristos #define MP_SYSTM_MASK	0xf000
5775fd0b74Schristos 
5875fd0b74Schristos /* Module Type/Language values.  */
5975fd0b74Schristos #define MT_ANY		0
6075fd0b74Schristos #define MT_PROGRAM	0x0001
6175fd0b74Schristos #define MT_SUBROUT	0x0002
6275fd0b74Schristos #define MT_MULTI	0x0003
6375fd0b74Schristos #define MT_DATA		0x0004
6475fd0b74Schristos #define MT_TRAPLIB	0x000b
6575fd0b74Schristos #define MT_SYSTEM	0x000c
6675fd0b74Schristos #define MT_FILEMAN	0x000d
6775fd0b74Schristos #define MT_DEVDRVR	0x000e
6875fd0b74Schristos #define MT_DEVDESC	0x000f
6975fd0b74Schristos #define MT_MASK		0xff00
7075fd0b74Schristos 
7175fd0b74Schristos #define ML_ANY		0
7275fd0b74Schristos #define ML_OBJECT	1
7375fd0b74Schristos #define ML_ICODE	2
7475fd0b74Schristos #define ML_PCODE	3
7575fd0b74Schristos #define ML_CCODE	4
7675fd0b74Schristos #define ML_CBLCODE	5
7775fd0b74Schristos #define ML_FRTNCODE	6
7875fd0b74Schristos #define ML_MASK		0x00ff
7975fd0b74Schristos 
8075fd0b74Schristos #define mktypelang(type, lang)	(((type) << 8) | (lang))
8175fd0b74Schristos 
8275fd0b74Schristos /* Module Attribute values.  */
8375fd0b74Schristos #define MA_REENT	0x80
8475fd0b74Schristos #define MA_GHOST	0x40
8575fd0b74Schristos #define MA_SUPER	0x20
8675fd0b74Schristos #define MA_MASK		0xff00
8775fd0b74Schristos #define MR_MASK		0x00ff
8875fd0b74Schristos 
8975fd0b74Schristos #define mkattrevs(attr, revs)	(((attr) << 8) | (revs))
9075fd0b74Schristos 
9175fd0b74Schristos #define m_user 		m_owner.grp_usr.usr
9275fd0b74Schristos #define m_group 	m_owner.grp_usr.grp
9375fd0b74Schristos #define m_group_user	m_owner.group_user
9475fd0b74Schristos 
9575fd0b74Schristos /* Macro definitions for accessing module header fields.  */
9675fd0b74Schristos #define MODNAME(mod) ((u_char*)((u_char*)mod + ((Mh_com)mod)->m_name))
9775fd0b74Schristos #if 0
9875fd0b74Schristos /* Appears not to be used, and the u_int32 typedef is gone (because it
9975fd0b74Schristos    conflicted with a Mach header.  */
10075fd0b74Schristos #define MODSIZE(mod) ((u_int32)((Mh_com)mod)->m_size)
10175fd0b74Schristos #endif /* 0 */
10275fd0b74Schristos #define MHCOM_BYTES_SIZE 80
10375fd0b74Schristos #define N_BADMAG(a) (((a)->a_info) != MODSYNC)
10475fd0b74Schristos 
10575fd0b74Schristos typedef struct mh_com
10675fd0b74Schristos {
10775fd0b74Schristos   /* Sync bytes ($4afc).  */
10875fd0b74Schristos   unsigned char m_sync[2];
10975fd0b74Schristos   unsigned char m_sysrev[2];	/* System revision check value.  */
11075fd0b74Schristos   unsigned char m_size[4];	/* Module size.  */
11175fd0b74Schristos   unsigned char m_owner[4];	/* Group/user id.  */
11275fd0b74Schristos   unsigned char m_name[4];	/* Offset to module name.  */
11375fd0b74Schristos   unsigned char m_access[2];	/* Access permissions.  */
11475fd0b74Schristos   unsigned char m_tylan[2];	/* Type/lang.  */
11575fd0b74Schristos   unsigned char m_attrev[2];	/* Rev/attr.  */
11675fd0b74Schristos   unsigned char m_edit[2];	/* Edition.  */
11775fd0b74Schristos   unsigned char m_needs[4];	/* Module hardware requirements flags. (reserved).  */
11875fd0b74Schristos   unsigned char m_usage[4];	/* Comment string offset.  */
11975fd0b74Schristos   unsigned char m_symbol[4];	/* Symbol table offset.  */
12075fd0b74Schristos   unsigned char m_exec[4];	/* Offset to execution entry point.  */
12175fd0b74Schristos   unsigned char m_excpt[4];	/* Offset to exception entry point.  */
12275fd0b74Schristos   unsigned char m_data[4];	/* Data storage requirement.  */
12375fd0b74Schristos   unsigned char m_stack[4];	/* Stack size.  */
12475fd0b74Schristos   unsigned char m_idata[4];	/* Offset to initialized data.  */
12575fd0b74Schristos   unsigned char m_idref[4];	/* Offset to data reference lists.  */
12675fd0b74Schristos   unsigned char m_init[4];	/* Initialization routine offset.  */
12775fd0b74Schristos   unsigned char m_term[4];	/* Termination routine offset.  */
12875fd0b74Schristos   unsigned char m_ident[2];	/* Ident code for ident program.  */
12975fd0b74Schristos   char          m_spare[8];	/* Reserved bytes.  */
13075fd0b74Schristos   unsigned char m_parity[2]; 	/* Header parity.  */
13175fd0b74Schristos } mh_com,*Mh_com;
13275fd0b74Schristos 
13375fd0b74Schristos /* Executable memory module.  */
13475fd0b74Schristos typedef mh_com *Mh_exec,mh_exec;
13575fd0b74Schristos 
13675fd0b74Schristos /* Data memory module.  */
13775fd0b74Schristos typedef mh_com *Mh_data,mh_data;
13875fd0b74Schristos 
13975fd0b74Schristos /* File manager memory module.  */
14075fd0b74Schristos typedef mh_com *Mh_fman,mh_fman;
14175fd0b74Schristos 
14275fd0b74Schristos /* Device driver module.  */
14375fd0b74Schristos typedef mh_com *Mh_drvr,mh_drvr;
14475fd0b74Schristos 
14575fd0b74Schristos /* Trap handler module.  */
14675fd0b74Schristos typedef	mh_com mh_trap, *Mh_trap;
14775fd0b74Schristos 
14875fd0b74Schristos /* Device descriptor module.  */
14975fd0b74Schristos typedef	mh_com *Mh_dev,mh_dev;
15075fd0b74Schristos 
15175fd0b74Schristos /* Configuration module.  */
15275fd0b74Schristos typedef mh_com *Mh_config, mh_config;
15375fd0b74Schristos 
15475fd0b74Schristos #if 0
15575fd0b74Schristos 
15675fd0b74Schristos #if !defined(_MODDIR_H)
15775fd0b74Schristos /* Go get _os_fmod (and others).  */
15875fd0b74Schristos #include <moddir.h>
15975fd0b74Schristos #endif
16075fd0b74Schristos 
16175fd0b74Schristos error_code _os_crc (void *, u_int32, int *);
16275fd0b74Schristos error_code _os_datmod (char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_data **);
16375fd0b74Schristos error_code _os_get_moddir (void *, u_int32 *);
16475fd0b74Schristos error_code _os_initdata (mh_com *, void *);
16575fd0b74Schristos error_code _os_link (char **, mh_com **, void **, u_int16 *, u_int16 *);
16675fd0b74Schristos error_code _os_linkm (mh_com *, void **, u_int16 *, u_int16 *);
16775fd0b74Schristos error_code _os_load (char *, mh_com **, void **, u_int32, u_int16 *, u_int16 *, u_int32);
16875fd0b74Schristos error_code _os_mkmodule (char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_com **, u_int32);
16975fd0b74Schristos error_code _os_modaddr (void *, mh_com **);
17075fd0b74Schristos error_code _os_setcrc (mh_com *);
17175fd0b74Schristos error_code _os_slink (u_int32, char *, void **, void **, mh_com **);
17275fd0b74Schristos error_code _os_slinkm (u_int32, mh_com *, void **, void **);
17375fd0b74Schristos error_code _os_unlink (mh_com *);
17475fd0b74Schristos error_code _os_unload (char *, u_int32);
17575fd0b74Schristos error_code _os_tlink (u_int32, char *, void **, mh_trap **, void *, u_int32);
17675fd0b74Schristos error_code _os_tlinkm (u_int32, mh_com *, void **, void *, u_int32);
17775fd0b74Schristos error_code _os_iodel (mh_com *);
17875fd0b74Schristos error_code _os_vmodul (mh_com *, mh_com *, u_int32);
17975fd0b74Schristos #endif /* 0 */
18075fd0b74Schristos 
18175fd0b74Schristos #endif
182