diff options
Diffstat (limited to 'drivers/staging/tidspbridge/dynload/doff.h')
-rw-r--r-- | drivers/staging/tidspbridge/dynload/doff.h | 344 |
1 files changed, 344 insertions, 0 deletions
diff --git a/drivers/staging/tidspbridge/dynload/doff.h b/drivers/staging/tidspbridge/dynload/doff.h new file mode 100644 index 00000000000..5bf99240f9f --- /dev/null +++ b/drivers/staging/tidspbridge/dynload/doff.h | |||
@@ -0,0 +1,344 @@ | |||
1 | /* | ||
2 | * doff.h | ||
3 | * | ||
4 | * DSP-BIOS Bridge driver support functions for TI OMAP processors. | ||
5 | * | ||
6 | * Structures & definitions used for dynamically loaded modules file format. | ||
7 | * This format is a reformatted version of COFF. It optimizes the layout for | ||
8 | * the dynamic loader. | ||
9 | * | ||
10 | * .dof files, when viewed as a sequence of 32-bit integers, look the same | ||
11 | * on big-endian and little-endian machines. | ||
12 | * | ||
13 | * Copyright (C) 2005-2006 Texas Instruments, Inc. | ||
14 | * | ||
15 | * This package is free software; you can redistribute it and/or modify | ||
16 | * it under the terms of the GNU General Public License version 2 as | ||
17 | * published by the Free Software Foundation. | ||
18 | * | ||
19 | * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | ||
20 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | ||
21 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
22 | */ | ||
23 | |||
24 | #ifndef _DOFF_H | ||
25 | #define _DOFF_H | ||
26 | |||
27 | #ifndef UINT32_C | ||
28 | #define UINT32_C(zzz) ((u32)zzz) | ||
29 | #endif | ||
30 | |||
31 | #define BYTE_RESHUFFLE_VALUE UINT32_C(0x00010203) | ||
32 | |||
33 | /* DOFF file header containing fields categorizing the remainder of the file */ | ||
34 | struct doff_filehdr_t { | ||
35 | |||
36 | /* string table size, including filename, in bytes */ | ||
37 | u32 df_strtab_size; | ||
38 | |||
39 | /* entry point if one exists */ | ||
40 | u32 df_entrypt; | ||
41 | |||
42 | /* identifies byte ordering of file; | ||
43 | * always set to BYTE_RESHUFFLE_VALUE */ | ||
44 | u32 df_byte_reshuffle; | ||
45 | |||
46 | /* Size of the string table up to and including the last section name */ | ||
47 | /* Size includes the name of the COFF file also */ | ||
48 | u32 df_scn_name_size; | ||
49 | |||
50 | #ifndef _BIG_ENDIAN | ||
51 | /* number of symbols */ | ||
52 | u16 df_no_syms; | ||
53 | |||
54 | /* length in bytes of the longest string, including terminating NULL */ | ||
55 | /* excludes the name of the file */ | ||
56 | u16 df_max_str_len; | ||
57 | |||
58 | /* total number of sections including no-load ones */ | ||
59 | u16 df_no_scns; | ||
60 | |||
61 | /* number of sections containing target code allocated or downloaded */ | ||
62 | u16 df_target_scns; | ||
63 | |||
64 | /* unique id for dll file format & version */ | ||
65 | u16 df_doff_version; | ||
66 | |||
67 | /* identifies ISA */ | ||
68 | u16 df_target_id; | ||
69 | |||
70 | /* useful file flags */ | ||
71 | u16 df_flags; | ||
72 | |||
73 | /* section reference for entry point, N_UNDEF for none, */ | ||
74 | /* N_ABS for absolute address */ | ||
75 | s16 df_entry_secn; | ||
76 | #else | ||
77 | /* length of the longest string, including terminating NULL */ | ||
78 | u16 df_max_str_len; | ||
79 | |||
80 | /* number of symbols */ | ||
81 | u16 df_no_syms; | ||
82 | |||
83 | /* number of sections containing target code allocated or downloaded */ | ||
84 | u16 df_target_scns; | ||
85 | |||
86 | /* total number of sections including no-load ones */ | ||
87 | u16 df_no_scns; | ||
88 | |||
89 | /* identifies ISA */ | ||
90 | u16 df_target_id; | ||
91 | |||
92 | /* unique id for dll file format & version */ | ||
93 | u16 df_doff_version; | ||
94 | |||
95 | /* section reference for entry point, N_UNDEF for none, */ | ||
96 | /* N_ABS for absolute address */ | ||
97 | s16 df_entry_secn; | ||
98 | |||
99 | /* useful file flags */ | ||
100 | u16 df_flags; | ||
101 | #endif | ||
102 | /* checksum for file header record */ | ||
103 | u32 df_checksum; | ||
104 | |||
105 | }; | ||
106 | |||
107 | /* flags in the df_flags field */ | ||
108 | #define DF_LITTLE 0x100 | ||
109 | #define DF_BIG 0x200 | ||
110 | #define DF_BYTE_ORDER (DF_LITTLE | DF_BIG) | ||
111 | |||
112 | /* Supported processors */ | ||
113 | #define TMS470_ID 0x97 | ||
114 | #define LEAD_ID 0x98 | ||
115 | #define TMS32060_ID 0x99 | ||
116 | #define LEAD3_ID 0x9c | ||
117 | |||
118 | /* Primary processor for loading */ | ||
119 | #if TMS32060 | ||
120 | #define TARGET_ID TMS32060_ID | ||
121 | #endif | ||
122 | |||
123 | /* Verification record containing values used to test integrity of the bits */ | ||
124 | struct doff_verify_rec_t { | ||
125 | |||
126 | /* time and date stamp */ | ||
127 | u32 dv_timdat; | ||
128 | |||
129 | /* checksum for all section records */ | ||
130 | u32 dv_scn_rec_checksum; | ||
131 | |||
132 | /* checksum for string table */ | ||
133 | u32 dv_str_tab_checksum; | ||
134 | |||
135 | /* checksum for symbol table */ | ||
136 | u32 dv_sym_tab_checksum; | ||
137 | |||
138 | /* checksum for verification record */ | ||
139 | u32 dv_verify_rec_checksum; | ||
140 | |||
141 | }; | ||
142 | |||
143 | /* String table is an array of null-terminated strings. The first entry is | ||
144 | * the filename, which is added by DLLcreate. No new structure definitions | ||
145 | * are required. | ||
146 | */ | ||
147 | |||
148 | /* Section Records including information on the corresponding image packets */ | ||
149 | /* | ||
150 | * !!WARNING!! | ||
151 | * | ||
152 | * This structure is expected to match in form ldr_section_info in | ||
153 | * dynamic_loader.h | ||
154 | */ | ||
155 | |||
156 | struct doff_scnhdr_t { | ||
157 | |||
158 | s32 ds_offset; /* offset into string table of name */ | ||
159 | s32 ds_paddr; /* RUN address, in target AU */ | ||
160 | s32 ds_vaddr; /* LOAD address, in target AU */ | ||
161 | s32 ds_size; /* section size, in target AU */ | ||
162 | #ifndef _BIG_ENDIAN | ||
163 | u16 ds_page; /* memory page id */ | ||
164 | u16 ds_flags; /* section flags */ | ||
165 | #else | ||
166 | u16 ds_flags; /* section flags */ | ||
167 | u16 ds_page; /* memory page id */ | ||
168 | #endif | ||
169 | u32 ds_first_pkt_offset; | ||
170 | /* Absolute byte offset into the file */ | ||
171 | /* where the first image record resides */ | ||
172 | |||
173 | s32 ds_nipacks; /* number of image packets */ | ||
174 | |||
175 | }; | ||
176 | |||
177 | /* Symbol table entry */ | ||
178 | struct doff_syment_t { | ||
179 | |||
180 | s32 dn_offset; /* offset into string table of name */ | ||
181 | s32 dn_value; /* value of symbol */ | ||
182 | #ifndef _BIG_ENDIAN | ||
183 | s16 dn_scnum; /* section number */ | ||
184 | s16 dn_sclass; /* storage class */ | ||
185 | #else | ||
186 | s16 dn_sclass; /* storage class */ | ||
187 | s16 dn_scnum; /* section number, 1-based */ | ||
188 | #endif | ||
189 | |||
190 | }; | ||
191 | |||
192 | /* special values for dn_scnum */ | ||
193 | #define DN_UNDEF 0 /* undefined symbol */ | ||
194 | #define DN_ABS (-1) /* value of symbol is absolute */ | ||
195 | /* special values for dn_sclass */ | ||
196 | #define DN_EXT 2 | ||
197 | #define DN_STATLAB 20 | ||
198 | #define DN_EXTLAB 21 | ||
199 | |||
200 | /* Default value of image bits in packet */ | ||
201 | /* Configurable by user on the command line */ | ||
202 | #define IMAGE_PACKET_SIZE 1024 | ||
203 | |||
204 | /* An image packet contains a chunk of data from a section along with */ | ||
205 | /* information necessary for its processing. */ | ||
206 | struct image_packet_t { | ||
207 | |||
208 | s32 num_relocs; /* number of relocations for */ | ||
209 | /* this packet */ | ||
210 | |||
211 | s32 packet_size; /* number of bytes in array */ | ||
212 | /* "bits" occupied by */ | ||
213 | /* valid data. Could be */ | ||
214 | /* < IMAGE_PACKET_SIZE to */ | ||
215 | /* prevent splitting a */ | ||
216 | /* relocation across packets. */ | ||
217 | /* Last packet of a section */ | ||
218 | /* will most likely contain */ | ||
219 | /* < IMAGE_PACKET_SIZE bytes */ | ||
220 | /* of valid data */ | ||
221 | |||
222 | s32 img_chksum; /* Checksum for image packet */ | ||
223 | /* and the corresponding */ | ||
224 | /* relocation records */ | ||
225 | |||
226 | u8 *img_data; /* Actual data in section */ | ||
227 | |||
228 | }; | ||
229 | |||
230 | /* The relocation structure definition matches the COFF version. Offsets */ | ||
231 | /* however are relative to the image packet base not the section base. */ | ||
232 | struct reloc_record_t { | ||
233 | |||
234 | s32 vaddr; | ||
235 | |||
236 | /* expressed in target AUs */ | ||
237 | |||
238 | union { | ||
239 | struct { | ||
240 | #ifndef _BIG_ENDIAN | ||
241 | u8 _offset; /* bit offset of rel fld */ | ||
242 | u8 _fieldsz; /* size of rel fld */ | ||
243 | u8 _wordsz; /* # bytes containing rel fld */ | ||
244 | u8 _dum1; | ||
245 | u16 _dum2; | ||
246 | u16 _type; | ||
247 | #else | ||
248 | unsigned _dum1:8; | ||
249 | unsigned _wordsz:8; /* # bytes containing rel fld */ | ||
250 | unsigned _fieldsz:8; /* size of rel fld */ | ||
251 | unsigned _offset:8; /* bit offset of rel fld */ | ||
252 | u16 _type; | ||
253 | u16 _dum2; | ||
254 | #endif | ||
255 | } _r_field; | ||
256 | |||
257 | struct { | ||
258 | u32 _spc; /* image packet relative PC */ | ||
259 | #ifndef _BIG_ENDIAN | ||
260 | u16 _dum; | ||
261 | u16 _type; /* relocation type */ | ||
262 | #else | ||
263 | u16 _type; /* relocation type */ | ||
264 | u16 _dum; | ||
265 | #endif | ||
266 | } _r_spc; | ||
267 | |||
268 | struct { | ||
269 | u32 _uval; /* constant value */ | ||
270 | #ifndef _BIG_ENDIAN | ||
271 | u16 _dum; | ||
272 | u16 _type; /* relocation type */ | ||
273 | #else | ||
274 | u16 _type; /* relocation type */ | ||
275 | u16 _dum; | ||
276 | #endif | ||
277 | } _r_uval; | ||
278 | |||
279 | struct { | ||
280 | s32 _symndx; /* 32-bit sym tbl index */ | ||
281 | #ifndef _BIG_ENDIAN | ||
282 | u16 _disp; /* extra addr encode data */ | ||
283 | u16 _type; /* relocation type */ | ||
284 | #else | ||
285 | u16 _type; /* relocation type */ | ||
286 | u16 _disp; /* extra addr encode data */ | ||
287 | #endif | ||
288 | } _r_sym; | ||
289 | } _u_reloc; | ||
290 | |||
291 | }; | ||
292 | |||
293 | /* abbreviations for convenience */ | ||
294 | #ifndef TYPE | ||
295 | #define TYPE _u_reloc._r_sym._type | ||
296 | #define UVAL _u_reloc._r_uval._uval | ||
297 | #define SYMNDX _u_reloc._r_sym._symndx | ||
298 | #define OFFSET _u_reloc._r_field._offset | ||
299 | #define FIELDSZ _u_reloc._r_field._fieldsz | ||
300 | #define WORDSZ _u_reloc._r_field._wordsz | ||
301 | #define R_DISP _u_reloc._r_sym._disp | ||
302 | #endif | ||
303 | |||
304 | /**************************************************************************** */ | ||
305 | /* */ | ||
306 | /* Important DOFF macros used for file processing */ | ||
307 | /* */ | ||
308 | /**************************************************************************** */ | ||
309 | |||
310 | /* DOFF Versions */ | ||
311 | #define DOFF0 0 | ||
312 | |||
313 | /* Return the address/size >= to addr that is at a 32-bit boundary */ | ||
314 | /* This assumes that a byte is 8 bits */ | ||
315 | #define DOFF_ALIGN(addr) (((addr) + 3) & ~UINT32_C(3)) | ||
316 | |||
317 | /**************************************************************************** */ | ||
318 | /* */ | ||
319 | /* The DOFF section header flags field is laid out as follows: */ | ||
320 | /* */ | ||
321 | /* Bits 0-3 : Section Type */ | ||
322 | /* Bit 4 : Set when section requires target memory to be allocated by DL */ | ||
323 | /* Bit 5 : Set when section requires downloading */ | ||
324 | /* Bits 8-11: Alignment, same as COFF */ | ||
325 | /* */ | ||
326 | /**************************************************************************** */ | ||
327 | |||
328 | /* Enum for DOFF section types (bits 0-3 of flag): See dynamic_loader.h */ | ||
329 | |||
330 | /* Macros to help processing of sections */ | ||
331 | #define DLOAD_SECT_TYPE(s_hdr) ((s_hdr)->ds_flags & 0xF) | ||
332 | |||
333 | /* DS_ALLOCATE indicates whether a section needs space on the target */ | ||
334 | #define DS_ALLOCATE_MASK 0x10 | ||
335 | #define DS_NEEDS_ALLOCATION(s_hdr) ((s_hdr)->ds_flags & DS_ALLOCATE_MASK) | ||
336 | |||
337 | /* DS_DOWNLOAD indicates that the loader needs to copy bits */ | ||
338 | #define DS_DOWNLOAD_MASK 0x20 | ||
339 | #define DS_NEEDS_DOWNLOAD(s_hdr) ((s_hdr)->ds_flags & DS_DOWNLOAD_MASK) | ||
340 | |||
341 | /* Section alignment requirement in AUs */ | ||
342 | #define DS_ALIGNMENT(ds_flags) (1 << (((ds_flags) >> 8) & 0xF)) | ||
343 | |||
344 | #endif /* _DOFF_H */ | ||