1 #if !defined(_MODULE_H)
4 /* OS-9000 i386 module header definitions */
7 /* sizeof common header less parity field */
8 #define N_M_PARITY (sizeof(mh_com)-sizeof(unisgned short))
9 #define OLD_M_PARITY 46
10 #define M_PARITY N_M_PARITY
13 #define MODSYNC 0x4afd /* module header sync code for 680x0 processors */
17 #define MODSYNC 0x4afc /* module header sync code for 80386 processors */
20 #define MODREV 1 /* module format revision 1 */
21 #define CRCCON 0x800fe3 /* crc polynomial constant */
23 /* Module access permission values */
24 #define MP_OWNER_READ 0x0001
25 #define MP_OWNER_WRITE 0x0002
26 #define MP_OWNER_EXEC 0x0004
27 #define MP_GROUP_READ 0x0010
28 #define MP_GROUP_WRITE 0x0020
29 #define MP_GROUP_EXEC 0x0040
30 #define MP_WORLD_READ 0x0100
31 #define MP_WORLD_WRITE 0x0200
32 #define MP_WORLD_EXEC 0x0400
33 #define MP_WORLD_ACCESS 0x0777
34 #define MP_OWNER_MASK 0x000f
35 #define MP_GROUP_MASK 0x00f0
36 #define MP_WORLD_MASK 0x0f00
37 #define MP_SYSTM_MASK 0xf000
39 /* Module Type/Language values */
41 #define MT_PROGRAM 0x0001
42 #define MT_SUBROUT 0x0002
43 #define MT_MULTI 0x0003
44 #define MT_DATA 0x0004
45 #define MT_TRAPLIB 0x000b
46 #define MT_SYSTEM 0x000c
47 #define MT_FILEMAN 0x000d
48 #define MT_DEVDRVR 0x000e
49 #define MT_DEVDESC 0x000f
50 #define MT_MASK 0xff00
59 #define ML_MASK 0x00ff
61 #define mktypelang(type,lang) (((type)<<8)|(lang))
63 /* Module Attribute values */
67 #define MA_MASK 0xff00
68 #define MR_MASK 0x00ff
70 #define mkattrevs(attr, revs) (((attr)<<8)|(revs))
72 #define m_user m_owner.grp_usr.usr
73 #define m_group m_owner.grp_usr.grp
74 #define m_group_user m_owner.group_user
76 /* macro definitions for accessing module header fields */
77 #define MODNAME(mod) ((u_char*)((u_char*)mod + ((Mh_com)mod)->m_name))
79 /* Appears not to be used, and the u_int32 typedef is gone (because it
80 conflicted with a Mach header. */
81 #define MODSIZE(mod) ((u_int32)((Mh_com)mod)->m_size)
83 #define MHCOM_BYTES_SIZE 80
84 #define N_BADMAG(a) (((a).a_info) != MODSYNC)
86 typedef struct mh_com {
87 /* sync bytes ($4afc). */
88 unsigned char m_sync[2];
89 unsigned char m_sysrev[2]; /* system revision check value */
91 m_size[4]; /* module size */
93 m_owner[4]; /* group/user id */
95 m_name[4]; /* offset to module name */
97 m_access[2], /* access permissions */
98 m_tylan[2], /* type/lang */
99 m_attrev[2], /* rev/attr */
100 m_edit[2]; /* edition */
102 m_needs[4], /* module hardware requirements flags. (reserved) */
103 m_usage[4], /* comment string offset */
104 m_symbol[4], /* symbol table offset */
105 m_exec[4], /* offset to execution entry point */
106 m_excpt[4], /* offset to exception entry point */
107 m_data[4], /* data storage requirement */
108 m_stack[4], /* stack size */
109 m_idata[4], /* offset to initialized data */
110 m_idref[4], /* offset to data reference lists */
111 m_init[4], /* initialization routine offset */
112 m_term[4]; /* termination routine offset */
114 m_ident[2]; /* ident code for ident program */
116 m_spare[8]; /* reserved bytes */
118 m_parity[2]; /* header parity */
121 /* Executable memory module */
122 typedef mh_com *Mh_exec,mh_exec;
124 /* Data memory module */
125 typedef mh_com *Mh_data,mh_data;
127 /* File manager memory module */
128 typedef mh_com *Mh_fman,mh_fman;
130 /* device driver module */
131 typedef mh_com *Mh_drvr,mh_drvr;
133 /* trap handler module */
134 typedef mh_com mh_trap, *Mh_trap;
136 /* Device descriptor module */
137 typedef mh_com *Mh_dev,mh_dev;
139 /* Configuration module */
140 typedef mh_com *Mh_config, mh_config;
144 #if !defined(_MODDIR_H)
145 /* go get _os_fmod (and others) */
149 error_code _os_crc(void *, u_int32, int *);
150 error_code _os_datmod(char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_data **);
151 error_code _os_get_moddir(void *, u_int32 *);
152 error_code _os_initdata(mh_com *, void *);
153 error_code _os_link(char **, mh_com **, void **, u_int16 *, u_int16 *);
154 error_code _os_linkm(mh_com *, void **, u_int16 *, u_int16 *);
155 error_code _os_load(char *, mh_com **, void **, u_int32, u_int16 *, u_int16 *, u_int32);
156 error_code _os_mkmodule(char *, u_int32, u_int16 *, u_int16 *, u_int32, void **, mh_com **, u_int32);
157 error_code _os_modaddr(void *, mh_com **);
158 error_code _os_setcrc(mh_com *);
159 error_code _os_slink(u_int32, char *, void **, void **, mh_com **);
160 error_code _os_slinkm(u_int32, mh_com *, void **, void **);
161 error_code _os_unlink(mh_com *);
162 error_code _os_unload(char *, u_int32);
163 error_code _os_tlink(u_int32, char *, void **, mh_trap **, void *, u_int32);
164 error_code _os_tlinkm(u_int32, mh_com *, void **, void *, u_int32);
165 error_code _os_iodel(mh_com *);
166 error_code _os_vmodul(mh_com *, mh_com *, u_int32);