1 /* $NetBSD: ibcs2_exec.h,v 1.16 2008/11/19 18:36:03 ad Exp $ */ 2 3 /* 4 * Copyright (c) 1994, 1995, 1998 Scott Bartram 5 * All rights reserved. 6 * 7 * adapted from sys/sys/exec_ecoff.h 8 * based on Intel iBCS2 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef _IBCS2_EXEC_H_ 34 #define _IBCS2_EXEC_H_ 35 36 /* 37 * COFF file header 38 */ 39 40 /* f_magic flags */ 41 /* defined in <machine/ibcs2_machdep.h> */ 42 43 /* magic */ 44 #define COFF_OMAGIC 0407 /* text not write-protected; data seg 45 is contiguous with text */ 46 #define COFF_NMAGIC 0410 /* text is write-protected; data starts 47 at next seg following text */ 48 #define COFF_ZMAGIC 0413 /* text and data segs are aligned for 49 direct paging */ 50 #define COFF_SMAGIC 0443 /* shared lib */ 51 52 #define COFF_SEGMENT_ALIGNMENT(fp, ap) 4 53 54 #define IBCS2_HIGH_SYSCALL(n) (((n) & 0x7f) == 0x28 && ((n) >> 8) > 0) 55 #define IBCS2_CVT_HIGH_SYSCALL(n) (((n) >> 8) + 200) 56 57 struct exec_package; 58 int exec_ibcs2_coff_makecmds(struct lwp *, struct exec_package *); 59 60 /* 61 * x.out (XENIX) 62 */ 63 64 struct xexec { 65 u_short x_magic; /* magic number */ 66 u_short x_ext; /* size of extended header */ 67 long x_text; /* ignored */ 68 long x_data; /* ignored */ 69 long x_bss; /* ignored */ 70 long x_syms; /* ignored */ 71 long x_reloc; /* ignored */ 72 long x_entry; /* executable entry point */ 73 char x_cpu; /* processor type */ 74 char x_relsym; /* ignored */ 75 u_short x_renv; /* flags */ 76 }; 77 78 /* x_magic flags */ 79 #define XOUT_MAGIC 0x0206 80 81 /* x_cpu flags */ 82 #define XC_386 0x004a /* 386, word-swapped */ 83 84 /* x_renv flags */ 85 #define XE_V5 0xc000 86 #define XE_SEG 0x0800 87 #define XE_ABS 0x0400 88 #define XE_ITER 0x0200 89 #define XE_VMOD 0x0100 90 #define XE_FPH 0x0080 91 #define XE_LTEXT 0x0040 92 #define XE_LDATA 0x0020 93 #define XE_OVER 0x0010 94 #define XE_FS 0x0008 95 #define XE_PURE 0x0004 96 #define XE_SEP 0x0002 97 #define XE_EXEC 0x0001 98 99 /* 100 * x.out extended header 101 */ 102 103 struct xext { 104 long xe_trsize; /* ignored */ 105 long xe_drsize; /* ignored */ 106 long xe_tbase; /* ignored */ 107 long xe_dbase; /* ignored */ 108 long xe_stksize; /* stack size if XE_FS set in x_renv */ 109 long xe_segpos; /* offset of segment table */ 110 long xe_segsize; /* segment table size */ 111 long xe_mdtpos; /* ignored */ 112 long xe_mdtsize; /* ignored */ 113 char xe_mdttype; /* ignored */ 114 char xe_pagesize; /* ignored */ 115 char xe_ostype; /* ignored */ 116 char xe_osvers; /* ignored */ 117 u_short xe_eseg; /* ignored */ 118 u_short xe_sres; /* ignored */ 119 }; 120 121 /* 122 * x.out segment table 123 */ 124 125 struct xseg { 126 u_short xs_type; /* segment type */ 127 u_short xs_attr; /* attribute flags */ 128 u_short xs_seg; /* segment selector number */ 129 char xs_align; /* ignored */ 130 char xs_cres; /* ignored */ 131 long xs_filpos; /* offset of this segment */ 132 long xs_psize; /* physical segment size */ 133 long xs_vsize; /* virtual segment size */ 134 long xs_rbase; /* relocation base address */ 135 u_short xs_noff; /* ignored */ 136 u_short xs_sres; /* ignored */ 137 long xs_lres; /* ignored */ 138 }; 139 140 /* xs_type flags */ 141 #define XS_TNULL 0 /* unused */ 142 #define XS_TTEXT 1 /* text (read-only) */ 143 #define XS_TDATA 2 /* data (read-write) */ 144 #define XS_TSYMS 3 /* symbol table (noload) */ 145 #define XS_TREL 4 /* relocation segment (noload) */ 146 #define XS_TSESTR 5 /* string table (noload) */ 147 #define XS_TGRPS 6 /* group segment (noload) */ 148 149 #define XS_TIDATA 64 150 #define XS_TTSS 65 151 #define XS_TLFIX 66 152 #define XS_TDNAME 67 153 #define XS_TDTEXT 68 154 #define XS_TDFIX 69 155 #define XS_TOVTAB 70 156 #define XS_T71 71 157 #define XS_TSYSTR 72 158 159 /* xs_attr flags */ 160 #define XS_AMEM 0x8000 /* memory image */ 161 #define XS_AITER 0x0001 /* iteration records */ 162 #define XS_AHUGE 0x0002 /* unused */ 163 #define XS_ABSS 0x0004 /* uninitialized data */ 164 #define XS_APURE 0x0008 /* read-only (sharable) segment */ 165 #define XS_AEDOWN 0x0010 /* expand down memory segment */ 166 #define XS_APRIV 0x0020 /* unused */ 167 #define XS_A32BIT 0x0040 /* 32-bit text/data */ 168 169 /* 170 * x.out iteration record 171 */ 172 173 struct xiter { 174 long xi_size; /* text/data size */ 175 long xi_rep; /* number of replications */ 176 long xi_offset; /* offset within segment to replicated data */ 177 }; 178 179 extern struct emul emul_ibcs2; 180 181 #define XOUT_HDR_SIZE (sizeof(struct xexec) + sizeof(struct xext)) 182 183 int exec_ibcs2_xout_makecmds(struct lwp *, struct exec_package *); 184 int ibcs2_exec_setup_stack(struct lwp *, struct exec_package *); 185 186 #ifdef EXEC_ELF32 187 int ibcs2_elf32_probe(struct lwp *, struct exec_package *, 188 void *, char *, vaddr_t *); 189 #endif 190 191 /* following two are used for indication of executable type */ 192 #define IBCS2_EXEC_XENIX ((void *)0x01) /* XENIX x.out executable */ 193 #define IBCS2_EXEC_OTHER ((void *)0x02) /* something else */ 194 195 #endif /* !_IBCS2_EXEC_H_ */ 196