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