4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * Structures & definitions used for dynamically loaded modules file format.
7 * This format is a reformatted version of COFF. It optimizes the layout for
10 * .dof files, when viewed as a sequence of 32-bit integers, look the same
11 * on big-endian and little-endian machines.
13 * Copyright (C) 2005-2006 Texas Instruments, Inc.
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.
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.
28 #define UINT32_C(zzz) ((u32)zzz)
31 #define BYTE_RESHUFFLE_VALUE UINT32_C(0x00010203)
33 /* DOFF file header containing fields categorizing the remainder of the file */
34 struct doff_filehdr_t
{
36 /* string table size, including filename, in bytes */
39 /* entry point if one exists */
42 /* identifies byte ordering of file;
43 * always set to BYTE_RESHUFFLE_VALUE */
44 u32 df_byte_reshuffle
;
46 /* Size of the string table up to and including the last section name */
47 /* Size includes the name of the COFF file also */
51 /* number of symbols */
54 /* length in bytes of the longest string, including terminating NULL */
55 /* excludes the name of the file */
58 /* total number of sections including no-load ones */
61 /* number of sections containing target code allocated or downloaded */
64 /* unique id for dll file format & version */
70 /* useful file flags */
73 /* section reference for entry point, N_UNDEF for none, */
74 /* N_ABS for absolute address */
77 /* length of the longest string, including terminating NULL */
80 /* number of symbols */
83 /* number of sections containing target code allocated or downloaded */
86 /* total number of sections including no-load ones */
92 /* unique id for dll file format & version */
95 /* section reference for entry point, N_UNDEF for none, */
96 /* N_ABS for absolute address */
99 /* useful file flags */
102 /* checksum for file header record */
107 /* flags in the df_flags field */
108 #define DF_LITTLE 0x100
110 #define DF_BYTE_ORDER (DF_LITTLE | DF_BIG)
112 /* Supported processors */
113 #define TMS470_ID 0x97
115 #define TMS32060_ID 0x99
116 #define LEAD3_ID 0x9c
118 /* Primary processor for loading */
120 #define TARGET_ID TMS32060_ID
123 /* Verification record containing values used to test integrity of the bits */
124 struct doff_verify_rec_t
{
126 /* time and date stamp */
129 /* checksum for all section records */
130 u32 dv_scn_rec_checksum
;
132 /* checksum for string table */
133 u32 dv_str_tab_checksum
;
135 /* checksum for symbol table */
136 u32 dv_sym_tab_checksum
;
138 /* checksum for verification record */
139 u32 dv_verify_rec_checksum
;
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
148 /* Section Records including information on the corresponding image packets */
152 * This structure is expected to match in form ldr_section_info in
156 struct doff_scnhdr_t
{
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 */
163 u16 ds_page
; /* memory page id */
164 u16 ds_flags
; /* section flags */
166 u16 ds_flags
; /* section flags */
167 u16 ds_page
; /* memory page id */
169 u32 ds_first_pkt_offset
;
170 /* Absolute byte offset into the file */
171 /* where the first image record resides */
173 s32 ds_nipacks
; /* number of image packets */
177 /* Symbol table entry */
178 struct doff_syment_t
{
180 s32 dn_offset
; /* offset into string table of name */
181 s32 dn_value
; /* value of symbol */
183 s16 dn_scnum
; /* section number */
184 s16 dn_sclass
; /* storage class */
186 s16 dn_sclass
; /* storage class */
187 s16 dn_scnum
; /* section number, 1-based */
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 */
197 #define DN_STATLAB 20
200 /* Default value of image bits in packet */
201 /* Configurable by user on the command line */
202 #define IMAGE_PACKET_SIZE 1024
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
{
208 s32 num_relocs
; /* number of relocations for */
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 */
222 s32 img_chksum
; /* Checksum for image packet */
223 /* and the corresponding */
224 /* relocation records */
226 u8
*img_data
; /* Actual data in section */
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
{
236 /* expressed in target AUs */
241 u8 _offset
; /* bit offset of rel fld */
242 u8 _fieldsz
; /* size of rel fld */
243 u8 _wordsz
; /* # bytes containing rel fld */
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 */
258 u32 _spc
; /* image packet relative PC */
261 u16 _type
; /* relocation type */
263 u16 _type
; /* relocation type */
269 u32 _uval
; /* constant value */
272 u16 _type
; /* relocation type */
274 u16 _type
; /* relocation type */
280 s32 _symndx
; /* 32-bit sym tbl index */
282 u16 _disp
; /* extra addr encode data */
283 u16 _type
; /* relocation type */
285 u16 _type
; /* relocation type */
286 u16 _disp
; /* extra addr encode data */
293 /* abbreviations for convenience */
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
304 /**************************************************************************** */
306 /* Important DOFF macros used for file processing */
308 /**************************************************************************** */
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))
317 /**************************************************************************** */
319 /* The DOFF section header flags field is laid out as follows: */
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 */
326 /**************************************************************************** */
328 /* Enum for DOFF section types (bits 0-3 of flag): See dynamic_loader.h */
330 /* Macros to help processing of sections */
331 #define DLOAD_SECT_TYPE(s_hdr) ((s_hdr)->ds_flags & 0xF)
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)
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)
341 /* Section alignment requirement in AUs */
342 #define DS_ALIGNMENT(ds_flags) (1 << (((ds_flags) >> 8) & 0xF))