1130812Smarcel/* os9k.h  -  OS-9000 i386 module header definitions
2130812Smarcel   Copyright 2000 Free Software Foundation, Inc.
3130812Smarcel
4130812SmarcelThis file is part of GNU CC.
5130812Smarcel
6130812SmarcelGNU CC is free software; you can redistribute it and/or modify
7130812Smarcelit under the terms of the GNU General Public License as published by
8130812Smarcelthe Free Software Foundation; either version 2, or (at your option)
9130812Smarcelany later version.
10130812Smarcel
11130812SmarcelGNU CC is distributed in the hope that it will be useful,
12130812Smarcelbut WITHOUT ANY WARRANTY; without even the implied warranty of
13130812SmarcelMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14130812SmarcelGNU General Public License for more details.
15130812Smarcel
16130812SmarcelYou should have received a copy of the GNU General Public License
17130812Smarcelalong with GNU CC; see the file COPYING.  If not, write to
18130812Smarcelthe Free Software Foundation, 59 Temple Place - Suite 330,
19130812SmarcelBoston, MA 02111-1307, USA.  */
20130812Smarcel
21130812Smarcel#if !defined(_MODULE_H)
22130812Smarcel#define _MODULE_H
23130812Smarcel
24130812Smarcel#define _MPF386
25130812Smarcel
26130812Smarcel/* Size of common header less parity field.  */
27130812Smarcel#define N_M_PARITY  (sizeof(mh_com)-sizeof(unisgned short))
28130812Smarcel#define OLD_M_PARITY 46
29130812Smarcel#define M_PARITY N_M_PARITY
30130812Smarcel
31130812Smarcel#ifdef _MPF68K
32130812Smarcel#define MODSYNC 0x4afc		/* Module header sync code for 680x0 processors.  */
33130812Smarcel#endif
34130812Smarcel
35130812Smarcel#ifdef _MPF386
36130812Smarcel#define MODSYNC 0x4afc		/* Module header sync code for 80386 processors.  */
37130812Smarcel#endif
38130812Smarcel
39130812Smarcel#define MODREV	1		/* Module format revision 1.  */
40130812Smarcel#define CRCCON	0x800063	/* CRC polynomial constant.  */
41130812Smarcel
42130812Smarcel/* Module access permission values.  */
43130812Smarcel#define MP_OWNER_READ	0x0001
44130812Smarcel#define MP_OWNER_WRITE	0x0002
45130812Smarcel#define MP_OWNER_EXEC	0x0004
46130812Smarcel#define MP_GROUP_READ	0x0010
47130812Smarcel#define MP_GROUP_WRITE	0x0020
48130812Smarcel#define MP_GROUP_EXEC	0x0040
49130812Smarcel#define MP_WORLD_READ	0x0100
50130812Smarcel#define MP_WORLD_WRITE	0x0200
51130812Smarcel#define MP_WORLD_EXEC	0x0400
52130812Smarcel#define MP_WORLD_ACCESS	0x0777
53130812Smarcel#define MP_OWNER_MASK	0x000f
54130812Smarcel#define MP_GROUP_MASK	0x00f0
55130812Smarcel#define MP_WORLD_MASK	0x0f00
56130812Smarcel#define MP_SYSTM_MASK	0xf000
57130812Smarcel
58130812Smarcel/* Module Type/Language values.  */
59130812Smarcel#define MT_ANY		0
60130812Smarcel#define MT_PROGRAM	0x0001
61130812Smarcel#define MT_SUBROUT	0x0002
62130812Smarcel#define MT_MULTI	0x0003
63130812Smarcel#define MT_DATA		0x0004
64130812Smarcel#define MT_TRAPLIB	0x000b
65130812Smarcel#define MT_SYSTEM	0x000c
66130812Smarcel#define MT_FILEMAN	0x000d
67130812Smarcel#define MT_DEVDRVR	0x000e
68130812Smarcel#define MT_DEVDESC	0x000f
69130812Smarcel#define MT_MASK		0xff00
70130812Smarcel
71130812Smarcel#define ML_ANY		0
72130812Smarcel#define ML_OBJECT	1
73130812Smarcel#define ML_ICODE	2
74130812Smarcel#define ML_PCODE	3
75130812Smarcel#define ML_CCODE	4
76130812Smarcel#define ML_CBLCODE	5
77130812Smarcel#define ML_FRTNCODE	6
78130812Smarcel#define ML_MASK		0x00ff
79130812Smarcel
80130812Smarcel#define mktypelang(type, lang)	(((type) << 8) | (lang))
81130812Smarcel
82130812Smarcel/* Module Attribute values.  */
83130812Smarcel#define MA_REENT	0x80
84130812Smarcel#define MA_GHOST	0x40
85130812Smarcel#define MA_SUPER	0x20
86130812Smarcel#define MA_MASK		0xff00
87130812Smarcel#define MR_MASK		0x00ff
88130812Smarcel
89130812Smarcel#define mkattrevs(attr, revs)	(((attr) << 8) | (revs))
90130812Smarcel
91130812Smarcel#define m_user 		m_owner.grp_usr.usr
92130812Smarcel#define m_group 	m_owner.grp_usr.grp
93130812Smarcel#define m_group_user	m_owner.group_user
94130812Smarcel
95130812Smarcel/* Macro definitions for accessing module header fields.  */
96130812Smarcel#define MODNAME(mod) ((u_char*)((u_char*)mod + ((Mh_com)mod)->m_name))
97130812Smarcel#if 0
98130812Smarcel/* Appears not to be used, and the u_int32 typedef is gone (because it
99130812Smarcel   conflicted with a Mach header.  */
100130812Smarcel#define MODSIZE(mod) ((u_int32)((Mh_com)mod)->m_size)
101130812Smarcel#endif /* 0 */
102130812Smarcel#define MHCOM_BYTES_SIZE 80
103130812Smarcel#define N_BADMAG(a) (((a).a_info) != MODSYNC)
104130812Smarcel
105130812Smarceltypedef struct mh_com
106130812Smarcel{
107130812Smarcel  /* Sync bytes ($4afc).  */
108130812Smarcel  unsigned char m_sync[2];
109130812Smarcel  unsigned char m_sysrev[2];	/* System revision check value.  */
110130812Smarcel  unsigned char m_size[4];	/* Module size.  */
111130812Smarcel  unsigned char m_owner[4];	/* Group/user id.  */
112130812Smarcel  unsigned char m_name[4];	/* Offset to module name.  */
113130812Smarcel  unsigned char m_access[2];	/* Access permissions.  */
114130812Smarcel  unsigned char m_tylan[2];	/* Type/lang.  */
115130812Smarcel  unsigned char m_attrev[2];	/* Rev/attr.  */
116130812Smarcel  unsigned char m_edit[2];	/* Edition.  */
117130812Smarcel  unsigned char m_needs[4];	/* Module hardware requirements flags. (reserved).  */
118130812Smarcel  unsigned char m_usage[4];	/* Comment string offset.  */
119130812Smarcel  unsigned char m_symbol[4];	/* Symbol table offset.  */
120130812Smarcel  unsigned char m_exec[4];	/* Offset to execution entry point.  */
121130812Smarcel  unsigned char m_excpt[4];	/* Offset to exception entry point.  */
122130812Smarcel  unsigned char m_data[4];	/* Data storage requirement.  */
123130812Smarcel  unsigned char m_stack[4];	/* Stack size.  */
124130812Smarcel  unsigned char m_idata[4];	/* Offset to initialized data.  */
125130812Smarcel  unsigned char m_idref[4];	/* Offset to data reference lists.  */
126130812Smarcel  unsigned char m_init[4];	/* Initialization routine offset.  */
127130812Smarcel  unsigned char m_term[4];	/* Termination routine offset.  */
128130812Smarcel  unsigned char m_ident[2];	/* Ident code for ident program.  */
129130812Smarcel  char          m_spare[8];	/* Reserved bytes.  */
130130812Smarcel  unsigned char m_parity[2]; 	/* Header parity.  */
131130812Smarcel} mh_com,*Mh_com;
132130812Smarcel
133130812Smarcel/* Executable memory module.  */
134130812Smarceltypedef mh_com *Mh_exec,mh_exec;
135130812Smarcel
136130812Smarcel/* Data memory module.  */
137130812Smarceltypedef mh_com *Mh_data,mh_data;
138130812Smarcel
139130812Smarcel/* File manager memory module.  */
140130812Smarceltypedef mh_com *Mh_fman,mh_fman;
141130812Smarcel
142130812Smarcel/* Device driver module.  */
143130812Smarceltypedef mh_com *Mh_drvr,mh_drvr;
144130812Smarcel
145130812Smarcel/* Trap handler module.  */
146130812Smarceltypedef	mh_com mh_trap, *Mh_trap;
147130812Smarcel
148130812Smarcel/* Device descriptor module.  */
149130812Smarceltypedef	mh_com *Mh_dev,mh_dev;
150130812Smarcel
151130812Smarcel/* Configuration module.  */
152130812Smarceltypedef mh_com *Mh_config, mh_config;
153130812Smarcel
154130812Smarcel#if 0
155130812Smarcel
156130812Smarcel#if !defined(_MODDIR_H)
157130812Smarcel/* Go get _os_fmod (and others).  */
158130812Smarcel#include <moddir.h>
159130812Smarcel#endif
160130812Smarcel
161130812Smarcelerror_code _os_crc (void *, u_int32, int *);
162130812Smarcelerror_code _os_datmod (char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_data **);
163130812Smarcelerror_code _os_get_moddir (void *, u_int32 *);
164130812Smarcelerror_code _os_initdata (mh_com *, void *);
165130812Smarcelerror_code _os_link (char **, mh_com **, void **, u_int16 *, u_int16 *);
166130812Smarcelerror_code _os_linkm (mh_com *, void **, u_int16 *, u_int16 *);
167130812Smarcelerror_code _os_load (char *, mh_com **, void **, u_int32, u_int16 *, u_int16 *, u_int32);
168130812Smarcelerror_code _os_mkmodule (char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_com **, u_int32);
169130812Smarcelerror_code _os_modaddr (void *, mh_com **);
170130812Smarcelerror_code _os_setcrc (mh_com *);
171130812Smarcelerror_code _os_slink (u_int32, char *, void **, void **, mh_com **);
172130812Smarcelerror_code _os_slinkm (u_int32, mh_com *, void **, void **);
173130812Smarcelerror_code _os_unlink (mh_com *);
174130812Smarcelerror_code _os_unload (char *, u_int32);
175130812Smarcelerror_code _os_tlink (u_int32, char *, void **, mh_trap **, void *, u_int32);
176130812Smarcelerror_code _os_tlinkm (u_int32, mh_com *, void **, void *, u_int32);
177130812Smarcelerror_code _os_iodel (mh_com *);
178130812Smarcelerror_code _os_vmodul (mh_com *, mh_com *, u_int32);
179130812Smarcel#endif /* 0 */
180130812Smarcel
181130812Smarcel#endif
182