xref: /openbsd-src/gnu/usr.bin/binutils/include/os9k.h (revision 5f210c2af8ad7a823d98e333e3a6e3d7999783f5)
1*5f210c2aSfgsch /* os9k.h  -  OS-9000 i386 module header definitions
2*5f210c2aSfgsch    Copyright 2000 Free Software Foundation, Inc.
3*5f210c2aSfgsch 
4*5f210c2aSfgsch This file is part of GNU CC.
5*5f210c2aSfgsch 
6*5f210c2aSfgsch GNU CC is free software; you can redistribute it and/or modify
7*5f210c2aSfgsch it under the terms of the GNU General Public License as published by
8*5f210c2aSfgsch the Free Software Foundation; either version 2, or (at your option)
9*5f210c2aSfgsch any later version.
10*5f210c2aSfgsch 
11*5f210c2aSfgsch GNU CC is distributed in the hope that it will be useful,
12*5f210c2aSfgsch but WITHOUT ANY WARRANTY; without even the implied warranty of
13*5f210c2aSfgsch MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*5f210c2aSfgsch GNU General Public License for more details.
15*5f210c2aSfgsch 
16*5f210c2aSfgsch You should have received a copy of the GNU General Public License
17*5f210c2aSfgsch along with GNU CC; see the file COPYING.  If not, write to
18*5f210c2aSfgsch the Free Software Foundation, 59 Temple Place - Suite 330,
19*5f210c2aSfgsch Boston, MA 02111-1307, USA.  */
20*5f210c2aSfgsch 
212159047fSniklas #if !defined(_MODULE_H)
222159047fSniklas #define _MODULE_H
232159047fSniklas 
242159047fSniklas #define _MPF386
252159047fSniklas 
26*5f210c2aSfgsch /* Size of common header less parity field.  */
272159047fSniklas #define N_M_PARITY  (sizeof(mh_com)-sizeof(unisgned short))
282159047fSniklas #define OLD_M_PARITY 46
292159047fSniklas #define M_PARITY N_M_PARITY
302159047fSniklas 
312159047fSniklas #ifdef _MPF68K
32*5f210c2aSfgsch #define MODSYNC 0x4afc		/* Module header sync code for 680x0 processors.  */
332159047fSniklas #endif
342159047fSniklas 
352159047fSniklas #ifdef _MPF386
36*5f210c2aSfgsch #define MODSYNC 0x4afc		/* Module header sync code for 80386 processors.  */
372159047fSniklas #endif
382159047fSniklas 
39*5f210c2aSfgsch #define MODREV	1		/* Module format revision 1.  */
40*5f210c2aSfgsch #define CRCCON	0x800063	/* CRC polynomial constant.  */
412159047fSniklas 
42*5f210c2aSfgsch /* Module access permission values.  */
432159047fSniklas #define MP_OWNER_READ	0x0001
442159047fSniklas #define MP_OWNER_WRITE	0x0002
452159047fSniklas #define MP_OWNER_EXEC	0x0004
462159047fSniklas #define MP_GROUP_READ	0x0010
472159047fSniklas #define MP_GROUP_WRITE	0x0020
482159047fSniklas #define MP_GROUP_EXEC	0x0040
492159047fSniklas #define MP_WORLD_READ	0x0100
502159047fSniklas #define MP_WORLD_WRITE	0x0200
512159047fSniklas #define MP_WORLD_EXEC	0x0400
522159047fSniklas #define MP_WORLD_ACCESS	0x0777
532159047fSniklas #define MP_OWNER_MASK	0x000f
542159047fSniklas #define MP_GROUP_MASK	0x00f0
552159047fSniklas #define MP_WORLD_MASK	0x0f00
562159047fSniklas #define MP_SYSTM_MASK	0xf000
572159047fSniklas 
58*5f210c2aSfgsch /* Module Type/Language values.  */
592159047fSniklas #define MT_ANY		0
602159047fSniklas #define MT_PROGRAM	0x0001
612159047fSniklas #define MT_SUBROUT	0x0002
622159047fSniklas #define MT_MULTI	0x0003
632159047fSniklas #define MT_DATA		0x0004
642159047fSniklas #define MT_TRAPLIB	0x000b
652159047fSniklas #define MT_SYSTEM	0x000c
662159047fSniklas #define MT_FILEMAN	0x000d
672159047fSniklas #define MT_DEVDRVR	0x000e
682159047fSniklas #define MT_DEVDESC	0x000f
692159047fSniklas #define MT_MASK		0xff00
702159047fSniklas 
712159047fSniklas #define ML_ANY		0
722159047fSniklas #define ML_OBJECT	1
732159047fSniklas #define ML_ICODE	2
742159047fSniklas #define ML_PCODE	3
752159047fSniklas #define ML_CCODE	4
762159047fSniklas #define ML_CBLCODE	5
772159047fSniklas #define ML_FRTNCODE	6
782159047fSniklas #define ML_MASK		0x00ff
792159047fSniklas 
802159047fSniklas #define mktypelang(type, lang)	(((type) << 8) | (lang))
812159047fSniklas 
82*5f210c2aSfgsch /* Module Attribute values.  */
832159047fSniklas #define MA_REENT	0x80
842159047fSniklas #define MA_GHOST	0x40
852159047fSniklas #define MA_SUPER	0x20
862159047fSniklas #define MA_MASK		0xff00
872159047fSniklas #define MR_MASK		0x00ff
882159047fSniklas 
892159047fSniklas #define mkattrevs(attr, revs)	(((attr) << 8) | (revs))
902159047fSniklas 
912159047fSniklas #define m_user 		m_owner.grp_usr.usr
922159047fSniklas #define m_group 	m_owner.grp_usr.grp
932159047fSniklas #define m_group_user	m_owner.group_user
942159047fSniklas 
95*5f210c2aSfgsch /* Macro definitions for accessing module header fields.  */
962159047fSniklas #define MODNAME(mod) ((u_char*)((u_char*)mod + ((Mh_com)mod)->m_name))
972159047fSniklas #if 0
982159047fSniklas /* Appears not to be used, and the u_int32 typedef is gone (because it
992159047fSniklas    conflicted with a Mach header.  */
1002159047fSniklas #define MODSIZE(mod) ((u_int32)((Mh_com)mod)->m_size)
1012159047fSniklas #endif /* 0 */
1022159047fSniklas #define MHCOM_BYTES_SIZE 80
1032159047fSniklas #define N_BADMAG(a) (((a).a_info) != MODSYNC)
1042159047fSniklas 
105*5f210c2aSfgsch typedef struct mh_com
106*5f210c2aSfgsch {
107*5f210c2aSfgsch   /* Sync bytes ($4afc).  */
1082159047fSniklas   unsigned char m_sync[2];
109*5f210c2aSfgsch   unsigned char m_sysrev[2];	/* System revision check value.  */
110*5f210c2aSfgsch   unsigned char m_size[4];	/* Module size.  */
111*5f210c2aSfgsch   unsigned char m_owner[4];	/* Group/user id.  */
112*5f210c2aSfgsch   unsigned char m_name[4];	/* Offset to module name.  */
113*5f210c2aSfgsch   unsigned char m_access[2];	/* Access permissions.  */
114*5f210c2aSfgsch   unsigned char m_tylan[2];	/* Type/lang.  */
115*5f210c2aSfgsch   unsigned char m_attrev[2];	/* Rev/attr.  */
116*5f210c2aSfgsch   unsigned char m_edit[2];	/* Edition.  */
117*5f210c2aSfgsch   unsigned char m_needs[4];	/* Module hardware requirements flags. (reserved).  */
118*5f210c2aSfgsch   unsigned char m_usage[4];	/* Comment string offset.  */
119*5f210c2aSfgsch   unsigned char m_symbol[4];	/* Symbol table offset.  */
120*5f210c2aSfgsch   unsigned char m_exec[4];	/* Offset to execution entry point.  */
121*5f210c2aSfgsch   unsigned char m_excpt[4];	/* Offset to exception entry point.  */
122*5f210c2aSfgsch   unsigned char m_data[4];	/* Data storage requirement.  */
123*5f210c2aSfgsch   unsigned char m_stack[4];	/* Stack size.  */
124*5f210c2aSfgsch   unsigned char m_idata[4];	/* Offset to initialized data.  */
125*5f210c2aSfgsch   unsigned char m_idref[4];	/* Offset to data reference lists.  */
126*5f210c2aSfgsch   unsigned char m_init[4];	/* Initialization routine offset.  */
127*5f210c2aSfgsch   unsigned char m_term[4];	/* Termination routine offset.  */
128*5f210c2aSfgsch   unsigned char m_ident[2];	/* Ident code for ident program.  */
129*5f210c2aSfgsch   char          m_spare[8];	/* Reserved bytes.  */
130*5f210c2aSfgsch   unsigned char m_parity[2]; 	/* Header parity.  */
1312159047fSniklas } mh_com,*Mh_com;
1322159047fSniklas 
133*5f210c2aSfgsch /* Executable memory module.  */
1342159047fSniklas typedef mh_com *Mh_exec,mh_exec;
1352159047fSniklas 
136*5f210c2aSfgsch /* Data memory module.  */
1372159047fSniklas typedef mh_com *Mh_data,mh_data;
1382159047fSniklas 
139*5f210c2aSfgsch /* File manager memory module.  */
1402159047fSniklas typedef mh_com *Mh_fman,mh_fman;
1412159047fSniklas 
142*5f210c2aSfgsch /* Device driver module.  */
1432159047fSniklas typedef mh_com *Mh_drvr,mh_drvr;
1442159047fSniklas 
145*5f210c2aSfgsch /* Trap handler module.  */
1462159047fSniklas typedef	mh_com mh_trap, *Mh_trap;
1472159047fSniklas 
148*5f210c2aSfgsch /* Device descriptor module.  */
1492159047fSniklas typedef	mh_com *Mh_dev,mh_dev;
1502159047fSniklas 
151*5f210c2aSfgsch /* Configuration module.  */
1522159047fSniklas typedef mh_com *Mh_config, mh_config;
1532159047fSniklas 
1542159047fSniklas #if 0
1552159047fSniklas 
1562159047fSniklas #if !defined(_MODDIR_H)
157*5f210c2aSfgsch /* Go get _os_fmod (and others).  */
1582159047fSniklas #include <moddir.h>
1592159047fSniklas #endif
1602159047fSniklas 
1612159047fSniklas error_code _os_crc (void *, u_int32, int *);
1622159047fSniklas error_code _os_datmod (char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_data **);
1632159047fSniklas error_code _os_get_moddir (void *, u_int32 *);
1642159047fSniklas error_code _os_initdata (mh_com *, void *);
1652159047fSniklas error_code _os_link (char **, mh_com **, void **, u_int16 *, u_int16 *);
1662159047fSniklas error_code _os_linkm (mh_com *, void **, u_int16 *, u_int16 *);
1672159047fSniklas error_code _os_load (char *, mh_com **, void **, u_int32, u_int16 *, u_int16 *, u_int32);
1682159047fSniklas error_code _os_mkmodule (char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_com **, u_int32);
1692159047fSniklas error_code _os_modaddr (void *, mh_com **);
1702159047fSniklas error_code _os_setcrc (mh_com *);
1712159047fSniklas error_code _os_slink (u_int32, char *, void **, void **, mh_com **);
1722159047fSniklas error_code _os_slinkm (u_int32, mh_com *, void **, void **);
1732159047fSniklas error_code _os_unlink (mh_com *);
1742159047fSniklas error_code _os_unload (char *, u_int32);
1752159047fSniklas error_code _os_tlink (u_int32, char *, void **, mh_trap **, void *, u_int32);
1762159047fSniklas error_code _os_tlinkm (u_int32, mh_com *, void **, void *, u_int32);
1772159047fSniklas error_code _os_iodel (mh_com *);
1782159047fSniklas error_code _os_vmodul (mh_com *, mh_com *, u_int32);
1792159047fSniklas #endif /* 0 */
1802159047fSniklas 
1812159047fSniklas #endif
182