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