/[pcsx2_0.9.7]/trunk/fps2bios/kernel/iopload/include/iopelf.h
ViewVC logotype

Contents of /trunk/fps2bios/kernel/iopload/include/iopelf.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations) (download)
Mon Sep 6 11:40:06 2010 UTC (9 years, 5 months ago) by william
File MIME type: text/plain
File size: 6345 byte(s)
exported r3113 from ./upstream/trunk
1 #ifndef __IOPELF_H__
2 #define __IOPELF_H__
3
4 #include "romdir.h"
5
6 #define MOD_TYPE_REL 1
7 #define MOD_TYPE_2 2
8 #define MOD_TYPE_DYN 3
9 #define MOD_TYPE_CORE 4
10
11 typedef struct {
12 char *name;
13 short version;
14 } moduleInfo;
15
16 // info about a module file
17 typedef struct module_info {
18 int type; // module type (MOD_TYPE_*)
19 int (*entry)(void*);// module entry point address
20 int gpValue; // module gp value
21 int progVAddr; // programs virtual address
22 int textSize; // size of text section
23 int dataSize; // size of data section
24 int bssSize; // size of bss section
25 int progMemSize; // size of program memory
26 int moduleInfo; // info about module ?
27 } MODULE_INFO;
28
29 typedef struct {
30 u32 ei_magic;
31 u8 ei_class;
32 u8 ei_data;
33 u8 ei_version;
34 u8 ei_pad[9];
35 } E_IDENT;
36
37 typedef struct {
38 u8 e_ident[16]; //+00 0x7f,"ELF" (ELF file identifier), E_IDENT*
39 u16 e_type; //+10 ELF type: 0=NONE, 1=REL, 2=EXEC, 3=SHARED, 4=CORE
40 u16 e_machine; //+12 Processor: 8=MIPS R3000
41 u32 e_version; //+14 Version: 1=current
42 u32 e_entry; //+18 Entry point address
43 u32 e_phoff; //+1C Start of program headers (offset from file start)
44 u32 e_shoff; //+20 Start of section headers (offset from file start)
45 u32 e_flags; //+24 Processor specific flags = 0x20924001 noreorder, mips
46 u16 e_ehsize; //+28 ELF header size (0x34 = 52 bytes)
47 u16 e_phentsize; //+2A Program headers entry size
48 u16 e_phnum; //+2C Number of program headers
49 u16 e_shentsize; //+2E Section headers entry size
50 u16 e_shnum; //+30 Number of section headers
51 u16 e_shstrndx; //+32 Section header stringtable index
52 } ELF_HEADER; //+34=sizeof
53 #define ET_SCE_IOPRELEXEC 0xFF80
54 #define PT_SCE_IOPMOD 0x70000080
55 #define SHT_REL 9
56 #define EM_MIPS 8
57
58 typedef struct tag_COFF_AOUTHDR {
59 short magic; //+00
60 short vstamp; //+02
61 int tsize; //+04
62 int dsize; //+08
63 int bsize; //+0C
64 int entry; //+10
65 int text_start; //+14
66 int data_start; //+18
67 int bss_start; //+1C
68 int field_20; //+20
69 int field_24; //+24
70 int field_28; //+28
71 int field_2C; //+2C
72 int moduleinfo; //+30
73 int gp_value; //+34
74 } COFF_AOUTHDR, COHDR; //=38
75
76 typedef struct tag_CHDR{
77 short f_magic; //+00
78 short f_nscns; //+02
79 int f_timdat; //+04
80 int f_symptr; //+08
81 int f_nsyms; //+0C
82 short f_opthdr; //+10
83 short f_flags; //+12
84 } CHDR; //=14
85
86 typedef struct tag_COFF_HEADER{ //same header as above
87 short f_magic; //+00
88 short f_nscns; //+02
89 int f_timdat; //+04
90 int f_symptr; //+08
91 int f_nsyms; //+0C
92 short f_opthdr; //+10
93 short f_flags; //+12
94 COFF_AOUTHDR opthdr; //+14
95 } COFF_HEADER; //=4C
96
97 typedef struct tag_COFF_scnhdr
98 {
99 char s_name[8]; //+00
100 int s_paddr; //+08
101 int s_vaddr; //+0C
102 int s_size; //+10
103 int s_scnptr; //+14
104 int s_relptr; //+18
105 int s_lnnoptr; //+1C
106 short s_nreloc; //+20
107 short s_nlnno; //+22
108 int s_flags; //+24
109 } COFF_scnhdr, SHDR; //=28
110
111 typedef struct _fileInfo
112 {
113 u32 type, //+00
114 entry, //+04
115 gp_value, //+08
116 p1_vaddr, //+0C
117 text_size, //+10
118 data_size, //+14
119 bss_size, //+18
120 p1_memsz; //+1C
121 moduleInfo *moduleinfo; //+20
122 } fileInfo;
123
124 typedef struct {
125 u32 p_type; //+00 see notes1
126 u32 p_offset; //+04 Offset from file start to program segment.
127 u32 p_vaddr; //+08 Virtual address of the segment
128 u32 p_paddr; //+0C Physical address of the segment
129 u32 p_filesz; //+10 Number of bytes in the file image of the segment
130 u32 p_memsz; //+14 Number of bytes in the memory image of the segment
131 u32 p_flags; //+18 Flags for segment
132 u32 p_align; //+1C Alignment. The address of 0x08 and 0x0C must fit this alignment. 0=no alignment
133 } ELF_PHR;
134
135 //notes1
136 //------
137 //0=Inactive
138 //1=Load the segment into memory, no. of bytes specified by 0x10 and 0x14
139 //2=Dynamic linking
140 //3=Interpreter. The array element must specify a path name
141 //4=Note. The array element must specify the location and size of aux. info
142 //5=reserved
143 //6=The array element must specify location and size of the program header table.
144
145 typedef struct {
146 u32 r_offset;
147 u32 r_info;
148 } ELF_REL;
149
150 typedef struct {
151 char* moduleinfo;
152 u32 entry; //+04
153 u32 gp_value; //+08
154 u32 text_size; //+0C
155 u32 data_size; //+10
156 u32 bss_size;//+14
157 short moduleversion;//+18
158 char* modulename; //+1A
159 } ELF_IOPMOD;
160
161 typedef struct {
162 u32 sh_name; //+00 No. to the index of the Section header stringtable index
163 u32 sh_type; //+04 See notes2
164 u32 sh_flags; //+08 see notes3
165 u32 sh_addr; //+0C Section start address
166 u32 sh_offset; //+10 Offset from start of file to section
167 u32 sh_size; //+14 Size of section
168 u32 sh_link; //+18 Section header table index link
169 u32 sh_info; //+1C Info
170 u32 sh_addralign; //+20 Alignment. The adress of 0x0C must fit this alignment. 0=no alignment.
171 u32 sh_entsize; //+24 Fixed size entries.
172 } ELF_SHR;
173
174 //notes 2
175 //-------
176 //Type:
177 //0=Inactive
178 //1=PROGBITS
179 //2=SYMTAB symbol table
180 //3=STRTAB string table
181 //4=RELA relocation entries
182 //5=HASH hash table
183 //6=DYNAMIC dynamic linking information
184 //7=NOTE
185 //8=NOBITS
186 //9=REL relocation entries
187 //10=SHLIB
188 //0x70000000=LOPROC processor specifc
189 //0x7fffffff=HIPROC
190 //0x80000000=LOUSER lower bound
191 //0xffffffff=HIUSER upper bound
192 //
193 //notes 3
194 //-------
195 //Section Flags: (1 bit, you may combine them like 3 = alloc & write permission)
196 //1=Write section contains data the is be writeable during execution.
197 //2=Alloc section occupies memory during execution
198 //4=Exec section contains executable instructions
199 //0xf0000000=Mask bits processor-specific
200
201
202 #define ELF32_ST_TYPE(i) ((i)&0xf)
203
204 // special header for every iop module?
205 typedef struct {
206 u32 next; //+00
207 char *name; //+04
208 short version, //+08
209 flags, //+0A
210 modid, //+0C
211 HE; //+0E
212 u32 entry, //+10
213 gp_value, //+14
214 p1_vaddr, //+18
215 text_size, //+1C
216 data_size, //+20
217 bss_size, //+24
218 H28, //+28
219 H2C; //+2C
220 } imageInfo;
221
222 // pass in the memory to load the elf file from
223 // elfoffset - offset to load elf file to
224 void* loadElfFile(ROMFILE_INFO* ri, u32 elfoffset);
225
226 #endif

  ViewVC Help
Powered by ViewVC 1.1.22