xref: /titanic_50/usr/src/grub/grub-0.97/netboot/elf.h (revision 1b8adde7ba7d5e04395c141c5400dc2cffd7d809)
1*1b8adde7SWilliam Kucharski #ifndef ELF_H
2*1b8adde7SWilliam Kucharski #define ELF_H
3*1b8adde7SWilliam Kucharski 
4*1b8adde7SWilliam Kucharski #define EI_NIDENT	16	/* Size of e_ident array. */
5*1b8adde7SWilliam Kucharski 
6*1b8adde7SWilliam Kucharski /* Values for e_type. */
7*1b8adde7SWilliam Kucharski #define ET_NONE		0	/* No file type */
8*1b8adde7SWilliam Kucharski #define ET_REL		1	/* Relocatable file */
9*1b8adde7SWilliam Kucharski #define ET_EXEC		2	/* Executable file */
10*1b8adde7SWilliam Kucharski #define ET_DYN		3	/* Shared object file */
11*1b8adde7SWilliam Kucharski #define ET_CORE		4	/* Core file */
12*1b8adde7SWilliam Kucharski 
13*1b8adde7SWilliam Kucharski /* Values for e_machine (architecute). */
14*1b8adde7SWilliam Kucharski #define EM_NONE		 0		/* No machine */
15*1b8adde7SWilliam Kucharski #define EM_M32		 1		/* AT&T WE 32100 */
16*1b8adde7SWilliam Kucharski #define EM_SPARC	 2		/* SUN SPARC */
17*1b8adde7SWilliam Kucharski #define EM_386		 3		/* Intel 80386+ */
18*1b8adde7SWilliam Kucharski #define EM_68K		 4		/* Motorola m68k family */
19*1b8adde7SWilliam Kucharski #define EM_88K		 5		/* Motorola m88k family */
20*1b8adde7SWilliam Kucharski #define EM_486		 6		/* Perhaps disused */
21*1b8adde7SWilliam Kucharski #define EM_860		 7		/* Intel 80860 */
22*1b8adde7SWilliam Kucharski #define EM_MIPS		 8		/* MIPS R3000 big-endian */
23*1b8adde7SWilliam Kucharski #define EM_S370		 9		/* IBM System/370 */
24*1b8adde7SWilliam Kucharski #define EM_MIPS_RS3_LE	10		/* MIPS R3000 little-endian */
25*1b8adde7SWilliam Kucharski 
26*1b8adde7SWilliam Kucharski #define EM_PARISC	15		/* HPPA */
27*1b8adde7SWilliam Kucharski #define EM_VPP500	17		/* Fujitsu VPP500 */
28*1b8adde7SWilliam Kucharski #define EM_SPARC32PLUS	18		/* Sun's "v8plus" */
29*1b8adde7SWilliam Kucharski #define EM_960		19		/* Intel 80960 */
30*1b8adde7SWilliam Kucharski #define EM_PPC		20		/* PowerPC */
31*1b8adde7SWilliam Kucharski #define EM_PPC64	21		/* PowerPC 64-bit */
32*1b8adde7SWilliam Kucharski #define EM_S390		22		/* IBM S390 */
33*1b8adde7SWilliam Kucharski 
34*1b8adde7SWilliam Kucharski #define EM_V800		36		/* NEC V800 series */
35*1b8adde7SWilliam Kucharski #define EM_FR20		37		/* Fujitsu FR20 */
36*1b8adde7SWilliam Kucharski #define EM_RH32		38		/* TRW RH-32 */
37*1b8adde7SWilliam Kucharski #define EM_RCE		39		/* Motorola RCE */
38*1b8adde7SWilliam Kucharski #define EM_ARM		40		/* ARM */
39*1b8adde7SWilliam Kucharski #define EM_FAKE_ALPHA	41		/* Digital Alpha */
40*1b8adde7SWilliam Kucharski #define EM_SH		42		/* Hitachi SH */
41*1b8adde7SWilliam Kucharski #define EM_SPARCV9	43		/* SPARC v9 64-bit */
42*1b8adde7SWilliam Kucharski #define EM_TRICORE	44		/* Siemens Tricore */
43*1b8adde7SWilliam Kucharski #define EM_ARC		45		/* Argonaut RISC Core */
44*1b8adde7SWilliam Kucharski #define EM_H8_300	46		/* Hitachi H8/300 */
45*1b8adde7SWilliam Kucharski #define EM_H8_300H	47		/* Hitachi H8/300H */
46*1b8adde7SWilliam Kucharski #define EM_H8S		48		/* Hitachi H8S */
47*1b8adde7SWilliam Kucharski #define EM_H8_500	49		/* Hitachi H8/500 */
48*1b8adde7SWilliam Kucharski #define EM_IA_64	50		/* Intel Merced */
49*1b8adde7SWilliam Kucharski #define EM_MIPS_X	51		/* Stanford MIPS-X */
50*1b8adde7SWilliam Kucharski #define EM_COLDFIRE	52		/* Motorola Coldfire */
51*1b8adde7SWilliam Kucharski #define EM_68HC12	53		/* Motorola M68HC12 */
52*1b8adde7SWilliam Kucharski #define EM_MMA		54		/* Fujitsu MMA Multimedia Accelerator*/
53*1b8adde7SWilliam Kucharski #define EM_PCP		55		/* Siemens PCP */
54*1b8adde7SWilliam Kucharski #define EM_NCPU		56		/* Sony nCPU embeeded RISC */
55*1b8adde7SWilliam Kucharski #define EM_NDR1		57		/* Denso NDR1 microprocessor */
56*1b8adde7SWilliam Kucharski #define EM_STARCORE	58		/* Motorola Start*Core processor */
57*1b8adde7SWilliam Kucharski #define EM_ME16		59		/* Toyota ME16 processor */
58*1b8adde7SWilliam Kucharski #define EM_ST100	60		/* STMicroelectronic ST100 processor */
59*1b8adde7SWilliam Kucharski #define EM_TINYJ	61		/* Advanced Logic Corp. Tinyj emb.fam*/
60*1b8adde7SWilliam Kucharski #define EM_X86_64	62		/* AMD x86-64 architecture */
61*1b8adde7SWilliam Kucharski #define EM_PDSP		63		/* Sony DSP Processor */
62*1b8adde7SWilliam Kucharski 
63*1b8adde7SWilliam Kucharski #define EM_FX66		66		/* Siemens FX66 microcontroller */
64*1b8adde7SWilliam Kucharski #define EM_ST9PLUS	67		/* STMicroelectronics ST9+ 8/16 mc */
65*1b8adde7SWilliam Kucharski #define EM_ST7		68		/* STmicroelectronics ST7 8 bit mc */
66*1b8adde7SWilliam Kucharski #define EM_68HC16	69		/* Motorola MC68HC16 microcontroller */
67*1b8adde7SWilliam Kucharski #define EM_68HC11	70		/* Motorola MC68HC11 microcontroller */
68*1b8adde7SWilliam Kucharski #define EM_68HC08	71		/* Motorola MC68HC08 microcontroller */
69*1b8adde7SWilliam Kucharski #define EM_68HC05	72		/* Motorola MC68HC05 microcontroller */
70*1b8adde7SWilliam Kucharski #define EM_SVX		73		/* Silicon Graphics SVx */
71*1b8adde7SWilliam Kucharski #define EM_AT19		74		/* STMicroelectronics ST19 8 bit mc */
72*1b8adde7SWilliam Kucharski #define EM_VAX		75		/* Digital VAX */
73*1b8adde7SWilliam Kucharski #define EM_CRIS		76		/* Axis Communications 32-bit embedded processor */
74*1b8adde7SWilliam Kucharski #define EM_JAVELIN	77		/* Infineon Technologies 32-bit embedded processor */
75*1b8adde7SWilliam Kucharski #define EM_FIREPATH	78		/* Element 14 64-bit DSP Processor */
76*1b8adde7SWilliam Kucharski #define EM_ZSP		79		/* LSI Logic 16-bit DSP Processor */
77*1b8adde7SWilliam Kucharski #define EM_MMIX		80		/* Donald Knuth's educational 64-bit processor */
78*1b8adde7SWilliam Kucharski #define EM_HUANY	81		/* Harvard University machine-independent object files */
79*1b8adde7SWilliam Kucharski #define EM_PRISM	82		/* SiTera Prism */
80*1b8adde7SWilliam Kucharski #define EM_AVR		83		/* Atmel AVR 8-bit microcontroller */
81*1b8adde7SWilliam Kucharski #define EM_FR30		84		/* Fujitsu FR30 */
82*1b8adde7SWilliam Kucharski #define EM_D10V		85		/* Mitsubishi D10V */
83*1b8adde7SWilliam Kucharski #define EM_D30V		86		/* Mitsubishi D30V */
84*1b8adde7SWilliam Kucharski #define EM_V850		87		/* NEC v850 */
85*1b8adde7SWilliam Kucharski #define EM_M32R		88		/* Mitsubishi M32R */
86*1b8adde7SWilliam Kucharski #define EM_MN10300	89		/* Matsushita MN10300 */
87*1b8adde7SWilliam Kucharski #define EM_MN10200	90		/* Matsushita MN10200 */
88*1b8adde7SWilliam Kucharski #define EM_PJ		91		/* picoJava */
89*1b8adde7SWilliam Kucharski #define EM_OPENRISC	92		/* OpenRISC 32-bit embedded processor */
90*1b8adde7SWilliam Kucharski #define EM_ARC_A5	93		/* ARC Cores Tangent-A5 */
91*1b8adde7SWilliam Kucharski #define EM_XTENSA	94		/* Tensilica Xtensa Architecture */
92*1b8adde7SWilliam Kucharski #define EM_NUM		95
93*1b8adde7SWilliam Kucharski 
94*1b8adde7SWilliam Kucharski /* Values for p_type. */
95*1b8adde7SWilliam Kucharski #define PT_NULL		0	/* Unused entry. */
96*1b8adde7SWilliam Kucharski #define PT_LOAD		1	/* Loadable segment. */
97*1b8adde7SWilliam Kucharski #define PT_DYNAMIC	2	/* Dynamic linking information segment. */
98*1b8adde7SWilliam Kucharski #define PT_INTERP	3	/* Pathname of interpreter. */
99*1b8adde7SWilliam Kucharski #define PT_NOTE		4	/* Auxiliary information. */
100*1b8adde7SWilliam Kucharski #define PT_SHLIB	5	/* Reserved (not used). */
101*1b8adde7SWilliam Kucharski #define PT_PHDR		6	/* Location of program header itself. */
102*1b8adde7SWilliam Kucharski 
103*1b8adde7SWilliam Kucharski /* Values for p_flags. */
104*1b8adde7SWilliam Kucharski #define PF_X		0x1	/* Executable. */
105*1b8adde7SWilliam Kucharski #define PF_W		0x2	/* Writable. */
106*1b8adde7SWilliam Kucharski #define PF_R		0x4	/* Readable. */
107*1b8adde7SWilliam Kucharski 
108*1b8adde7SWilliam Kucharski 
109*1b8adde7SWilliam Kucharski #define	ELF_PROGRAM_RETURNS_BIT	0x8000000	/* e_flags bit 31 */
110*1b8adde7SWilliam Kucharski 
111*1b8adde7SWilliam Kucharski #define EI_MAG0		0
112*1b8adde7SWilliam Kucharski #define ELFMAG0		0x7f
113*1b8adde7SWilliam Kucharski 
114*1b8adde7SWilliam Kucharski #define EI_MAG1		1
115*1b8adde7SWilliam Kucharski #define ELFMAG1		'E'
116*1b8adde7SWilliam Kucharski 
117*1b8adde7SWilliam Kucharski #define EI_MAG2		2
118*1b8adde7SWilliam Kucharski #define ELFMAG2		'L'
119*1b8adde7SWilliam Kucharski 
120*1b8adde7SWilliam Kucharski #define EI_MAG3		3
121*1b8adde7SWilliam Kucharski #define ELFMAG3		'F'
122*1b8adde7SWilliam Kucharski 
123*1b8adde7SWilliam Kucharski #define ELFMAG		"\177ELF"
124*1b8adde7SWilliam Kucharski 
125*1b8adde7SWilliam Kucharski #define EI_CLASS	4	/* File class byte index */
126*1b8adde7SWilliam Kucharski #define ELFCLASSNONE	0	/* Invalid class */
127*1b8adde7SWilliam Kucharski #define ELFCLASS32	1	/* 32-bit objects */
128*1b8adde7SWilliam Kucharski #define ELFCLASS64	2	/* 64-bit objects */
129*1b8adde7SWilliam Kucharski 
130*1b8adde7SWilliam Kucharski #define EI_DATA		5	/* Data encodeing byte index */
131*1b8adde7SWilliam Kucharski #define ELFDATANONE	0	/* Invalid data encoding */
132*1b8adde7SWilliam Kucharski #define ELFDATA2LSB	1	/* 2's complement little endian */
133*1b8adde7SWilliam Kucharski #define ELFDATA2MSB	2	/* 2's complement big endian */
134*1b8adde7SWilliam Kucharski 
135*1b8adde7SWilliam Kucharski #define EI_VERSION	6	/* File version byte index */
136*1b8adde7SWilliam Kucharski 				/* Value must be EV_CURRENT */
137*1b8adde7SWilliam Kucharski 
138*1b8adde7SWilliam Kucharski #define EV_NONE		0	/* Invalid ELF Version */
139*1b8adde7SWilliam Kucharski #define EV_CURRENT	1	/* Current version */
140*1b8adde7SWilliam Kucharski 
141*1b8adde7SWilliam Kucharski #define ELF32_PHDR_SIZE (8*4)	/* Size of an elf program header */
142*1b8adde7SWilliam Kucharski 
143*1b8adde7SWilliam Kucharski #ifndef ASSEMBLY
144*1b8adde7SWilliam Kucharski /*
145*1b8adde7SWilliam Kucharski  * ELF definitions common to all 32-bit architectures.
146*1b8adde7SWilliam Kucharski  */
147*1b8adde7SWilliam Kucharski 
148*1b8adde7SWilliam Kucharski typedef uint32_t	Elf32_Addr;
149*1b8adde7SWilliam Kucharski typedef uint16_t	Elf32_Half;
150*1b8adde7SWilliam Kucharski typedef uint32_t	Elf32_Off;
151*1b8adde7SWilliam Kucharski typedef int32_t		Elf32_Sword;
152*1b8adde7SWilliam Kucharski typedef uint32_t	Elf32_Word;
153*1b8adde7SWilliam Kucharski typedef uint32_t	Elf32_Size;
154*1b8adde7SWilliam Kucharski 
155*1b8adde7SWilliam Kucharski typedef uint64_t	Elf64_Addr;
156*1b8adde7SWilliam Kucharski typedef uint16_t	Elf64_Half;
157*1b8adde7SWilliam Kucharski typedef uint64_t	Elf64_Off;
158*1b8adde7SWilliam Kucharski typedef int32_t		Elf64_Sword;
159*1b8adde7SWilliam Kucharski typedef uint32_t	Elf64_Word;
160*1b8adde7SWilliam Kucharski typedef uint64_t	Elf64_Size;
161*1b8adde7SWilliam Kucharski 
162*1b8adde7SWilliam Kucharski /*
163*1b8adde7SWilliam Kucharski  * ELF header.
164*1b8adde7SWilliam Kucharski  */
165*1b8adde7SWilliam Kucharski typedef struct {
166*1b8adde7SWilliam Kucharski 	unsigned char	e_ident[EI_NIDENT];	/* File identification. */
167*1b8adde7SWilliam Kucharski 	Elf32_Half	e_type;		/* File type. */
168*1b8adde7SWilliam Kucharski 	Elf32_Half	e_machine;	/* Machine architecture. */
169*1b8adde7SWilliam Kucharski 	Elf32_Word	e_version;	/* ELF format version. */
170*1b8adde7SWilliam Kucharski 	Elf32_Addr	e_entry;	/* Entry point. */
171*1b8adde7SWilliam Kucharski 	Elf32_Off	e_phoff;	/* Program header file offset. */
172*1b8adde7SWilliam Kucharski 	Elf32_Off	e_shoff;	/* Section header file offset. */
173*1b8adde7SWilliam Kucharski 	Elf32_Word	e_flags;	/* Architecture-specific flags. */
174*1b8adde7SWilliam Kucharski 	Elf32_Half	e_ehsize;	/* Size of ELF header in bytes. */
175*1b8adde7SWilliam Kucharski 	Elf32_Half	e_phentsize;	/* Size of program header entry. */
176*1b8adde7SWilliam Kucharski 	Elf32_Half	e_phnum;	/* Number of program header entries. */
177*1b8adde7SWilliam Kucharski 	Elf32_Half	e_shentsize;	/* Size of section header entry. */
178*1b8adde7SWilliam Kucharski 	Elf32_Half	e_shnum;	/* Number of section header entries. */
179*1b8adde7SWilliam Kucharski 	Elf32_Half	e_shstrndx;	/* Section name strings section. */
180*1b8adde7SWilliam Kucharski } Elf32_Ehdr;
181*1b8adde7SWilliam Kucharski 
182*1b8adde7SWilliam Kucharski typedef struct {
183*1b8adde7SWilliam Kucharski 	unsigned char	e_ident[EI_NIDENT];	/* File identification. */
184*1b8adde7SWilliam Kucharski 	Elf64_Half	e_type;		/* File type. */
185*1b8adde7SWilliam Kucharski 	Elf64_Half	e_machine;	/* Machine architecture. */
186*1b8adde7SWilliam Kucharski 	Elf64_Word	e_version;	/* ELF format version. */
187*1b8adde7SWilliam Kucharski 	Elf64_Addr	e_entry;	/* Entry point. */
188*1b8adde7SWilliam Kucharski 	Elf64_Off	e_phoff;	/* Program header file offset. */
189*1b8adde7SWilliam Kucharski 	Elf64_Off	e_shoff;	/* Section header file offset. */
190*1b8adde7SWilliam Kucharski 	Elf64_Word	e_flags;	/* Architecture-specific flags. */
191*1b8adde7SWilliam Kucharski 	Elf64_Half	e_ehsize;	/* Size of ELF header in bytes. */
192*1b8adde7SWilliam Kucharski 	Elf64_Half	e_phentsize;	/* Size of program header entry. */
193*1b8adde7SWilliam Kucharski 	Elf64_Half	e_phnum;	/* Number of program header entries. */
194*1b8adde7SWilliam Kucharski 	Elf64_Half	e_shentsize;	/* Size of section header entry. */
195*1b8adde7SWilliam Kucharski 	Elf64_Half	e_shnum;	/* Number of section header entries. */
196*1b8adde7SWilliam Kucharski 	Elf64_Half	e_shstrndx;	/* Section name strings section. */
197*1b8adde7SWilliam Kucharski } Elf64_Ehdr;
198*1b8adde7SWilliam Kucharski 
199*1b8adde7SWilliam Kucharski /*
200*1b8adde7SWilliam Kucharski  * Program header.
201*1b8adde7SWilliam Kucharski  */
202*1b8adde7SWilliam Kucharski typedef struct {
203*1b8adde7SWilliam Kucharski 	Elf32_Word	p_type;		/* Entry type. */
204*1b8adde7SWilliam Kucharski 	Elf32_Off	p_offset;	/* File offset of contents. */
205*1b8adde7SWilliam Kucharski 	Elf32_Addr	p_vaddr;	/* Virtual address (not used). */
206*1b8adde7SWilliam Kucharski 	Elf32_Addr	p_paddr;	/* Physical address. */
207*1b8adde7SWilliam Kucharski 	Elf32_Size	p_filesz;	/* Size of contents in file. */
208*1b8adde7SWilliam Kucharski 	Elf32_Size	p_memsz;	/* Size of contents in memory. */
209*1b8adde7SWilliam Kucharski 	Elf32_Word	p_flags;	/* Access permission flags. */
210*1b8adde7SWilliam Kucharski 	Elf32_Size	p_align;	/* Alignment in memory and file. */
211*1b8adde7SWilliam Kucharski } Elf32_Phdr;
212*1b8adde7SWilliam Kucharski 
213*1b8adde7SWilliam Kucharski typedef struct {
214*1b8adde7SWilliam Kucharski 	Elf64_Word	p_type;		/* Entry type. */
215*1b8adde7SWilliam Kucharski 	Elf64_Word	p_flags;	/* Access permission flags. */
216*1b8adde7SWilliam Kucharski 	Elf64_Off	p_offset;	/* File offset of contents. */
217*1b8adde7SWilliam Kucharski 	Elf64_Addr	p_vaddr;	/* Virtual address (not used). */
218*1b8adde7SWilliam Kucharski 	Elf64_Addr	p_paddr;	/* Physical address. */
219*1b8adde7SWilliam Kucharski 	Elf64_Size	p_filesz;	/* Size of contents in file. */
220*1b8adde7SWilliam Kucharski 	Elf64_Size	p_memsz;	/* Size of contents in memory. */
221*1b8adde7SWilliam Kucharski 	Elf64_Size	p_align;	/* Alignment in memory and file. */
222*1b8adde7SWilliam Kucharski } Elf64_Phdr;
223*1b8adde7SWilliam Kucharski 
224*1b8adde7SWilliam Kucharski /* Standardized Elf image notes for booting... The name for all of these is ELFBoot */
225*1b8adde7SWilliam Kucharski 
226*1b8adde7SWilliam Kucharski 
227*1b8adde7SWilliam Kucharski /* ELF Defines for the current architecture */
228*1b8adde7SWilliam Kucharski #include "i386_elf.h"
229*1b8adde7SWilliam Kucharski 
230*1b8adde7SWilliam Kucharski #endif /* ASSEMBLY */
231*1b8adde7SWilliam Kucharski 
232*1b8adde7SWilliam Kucharski //#include "elf_boot.h"
233*1b8adde7SWilliam Kucharski 
234*1b8adde7SWilliam Kucharski #endif /* ELF_H */
235