Commit 26f8db7d authored by Omar Ramirez Luna's avatar Omar Ramirez Luna Committed by Greg Kroah-Hartman

staging: ti dspbridge: add DOFF binaries loader

Add TI's DSP Bridge DOFF binaries dynamic loader driver sources
Signed-off-by: default avatarOmar Ramirez Luna <omar.ramirez@ti.com>
Signed-off-by: default avatarKanigeri, Hari <h-kanigeri2@ti.com>
Signed-off-by: default avatarAmeya Palande <ameya.palande@nokia.com>
Signed-off-by: default avatarGuzman Lugo, Fernando <fernando.lugo@ti.com>
Signed-off-by: default avatarHebbar, Shivananda <x0hebbar@ti.com>
Signed-off-by: default avatarRamos Falcon, Ernesto <ernesto@ti.com>
Signed-off-by: default avatarFelipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: default avatarAnna, Suman <s-anna@ti.com>
Signed-off-by: default avatarGupta, Ramesh <grgupta@ti.com>
Signed-off-by: default avatarGomez Castellanos, Ivan <ivan.gomez@ti.com>
Signed-off-by: default avatarAndy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: default avatarArmando Uribe De Leon <x0095078@ti.com>
Signed-off-by: default avatarDeepak Chitriki <deepak.chitriki@ti.com>
Signed-off-by: default avatarMenon, Nishanth <nm@ti.com>
Signed-off-by: default avatarPhil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: default avatarOhad Ben-Cohen <ohad@wizery.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6a88a4fe
This diff is collapsed.
This diff is collapsed.
/*
* 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
#ifndef UINT32_C
#define UINT32_C(zzz) ((u32)zzz)
#endif
#define BYTE_RESHUFFLE_VALUE UINT32_C(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) & ~UINT32_C(3))
/**************************************************************************** */
/* */
/* 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 */
/* Macros to help processing of sections */
#define DLOAD_SECT_TYPE(s_hdr) ((s_hdr)->ds_flags & 0xF)
/* DS_ALLOCATE indicates whether a section needs space on the target */
#define DS_ALLOCATE_MASK 0x10
#define DS_NEEDS_ALLOCATION(s_hdr) ((s_hdr)->ds_flags & DS_ALLOCATE_MASK)
/* DS_DOWNLOAD indicates that the loader needs to copy bits */
#define DS_DOWNLOAD_MASK 0x20
#define DS_NEEDS_DOWNLOAD(s_hdr) ((s_hdr)->ds_flags & DS_DOWNLOAD_MASK)
/* Section alignment requirement in AUs */
#define DS_ALIGNMENT(ds_flags) (1 << (((ds_flags) >> 8) & 0xF))
#endif /* _DOFF_H */
This diff is collapsed.
/*
* header.h
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* 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.
*/
#define TRUE 1
#define FALSE 0
#ifndef NULL
#define NULL 0
#endif
#include <linux/string.h>
#define DL_STRCMP strcmp
/* maximum parenthesis nesting in relocation stack expressions */
#define STATIC_EXPR_STK_SIZE 10
#include <linux/types.h>
#include "doff.h"
#include <dspbridge/dynamic_loader.h>
#include "params.h"
#include "dload_internal.h"
#include "reloc_table.h"
/*
* Plausibility limits
*
* These limits are imposed upon the input DOFF file as a check for validity.
* They are hard limits, in that the load will fail if they are exceeded.
* The numbers selected are arbitrary, in that the loader implementation does
* not require these limits.
*/
/* maximum number of bytes in string table */
#define MAX_REASONABLE_STRINGTAB (0x100000)
/* maximum number of code,data,etc. sections */
#define MAX_REASONABLE_SECTIONS (200)
/* maximum number of linker symbols */
#define MAX_REASONABLE_SYMBOLS (100000)
/* shift count to align F_BIG with DLOAD_LITTLE */
#define ALIGN_COFF_ENDIANNESS 7
#define ENDIANNESS_MASK (DF_BYTE_ORDER >> ALIGN_COFF_ENDIANNESS)
/*
* dspbridge/mpu_driver/src/dynload/module_list.h
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* Copyright (C) 2008 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.
*/
/*
* This C header file gives the layout of the data structure created by the
* dynamic loader to describe the set of modules loaded into the DSP.
*
* Linked List Structure:
* ----------------------
* The data structure defined here is a singly-linked list. The list
* represents the set of modules which are currently loaded in the DSP memory.
* The first entry in the list is a header record which contains a flag
* representing the state of the list. The rest of the entries in the list
* are module records.
*
* Global symbol _DLModules designates the first record in the list (i.e. the
* header record). This symbol must be defined in any program that wishes to
* use DLLview plug-in.
*
* String Representation:
* ----------------------
* The string names of the module and its sections are stored in a block of
* memory which follows the module record itself. The strings are ordered:
* module name first, followed by section names in order from the first
* section to the last. String names are tightly packed arrays of 8-bit
* characters (two characters per 16-bit word on the C55x). Strings are
* zero-byte-terminated.
*
* Creating and updating the list:
* -------------------------------
* Upon loading a new module into the DSP memory the dynamic loader inserts a
* new module record as the first module record in the list. The fields of
* this module record are initialized to reflect the properties of the module.
* The dynamic loader does NOT increment the flag/counter in the list's header
* record.
*
* Upon unloading a module from the DSP memory the dynamic loader removes the
* module's record from this list. The dynamic loader also increments the
* flag/counter in the list's header record to indicate that the list has been
* changed.
*/
#ifndef _MODULE_LIST_H_
#define _MODULE_LIST_H_
#include <linux/types.h>
/* Global pointer to the modules_header structure */
#define MODULES_HEADER "_DLModules"
#define MODULES_HEADER_NO_UNDERSCORE "DLModules"
/* Initial version number */
#define INIT_VERSION 1
/* Verification number -- to be recorded in each module record */
#define VERIFICATION 0x79
/* forward declarations */
struct dll_module;
struct dll_sect;
/* the first entry in the list is the modules_header record;
* its address is contained in the global _DLModules pointer */
struct modules_header {
/*
* Address of the first dll_module record in the list or NULL.
* Note: for C55x this is a word address (C55x data is
* word-addressable)
*/
u32 first_module;
/* Combined storage size (in target addressable units) of the
* dll_module record which follows this header record, or zero
* if the list is empty. This size includes the module's string table.
* Note: for C55x the unit is a 16-bit word */
u16 first_module_size;
/* Counter is incremented whenever a module record is removed from
* the list */
u16 update_flag;
};
/* for each 32-bits in above structure, a bitmap, LSB first, whose bits are:
* 0 => a 32-bit value, 1 => 2 16-bit values */
/* swapping bitmap for type modules_header */
#define MODULES_HEADER_BITMAP 0x2
/* information recorded about each section in a module */
struct dll_sect {
/* Load-time address of the section.
* Note: for C55x this is a byte address for program sections, and
* a word address for data sections. C55x program memory is
* byte-addressable, while data memory is word-addressable. */
u32 sect_load_adr;
/* Run-time address of the section.
* Note 1: for C55x this is a byte address for program sections, and
* a word address for data sections.
* Note 2: for C55x two most significant bits of this field indicate
* the section type: '00' for a code section, '11' for a data section
* (C55 addresses are really only 24-bits wide). */
u32 sect_run_adr;
};
/* the rest of the entries in the list are module records */
struct dll_module {
/* Address of the next dll_module record in the list, or 0 if this is
* the last record in the list.
* Note: for C55x this is a word address (C55x data is
* word-addressable) */
u32 next_module;
/* Combined storage size (in target addressable units) of the
* dll_module record which follows this one, or zero if this is the
* last record in the list. This size includes the module's string
* table.
* Note: for C55x the unit is a 16-bit word. */
u16 next_module_size;
/* version number of the tooling; set to INIT_VERSION for Phase 1 */
u16 version;
/* the verification word; set to VERIFICATION */
u16 verification;
/* Number of sections in the sects array */
u16 num_sects;
/* Module's "unique" id; copy of the timestamp from the host
* COFF file */
u32 timestamp;
/* Array of num_sects elements of the module's section records */
struct dll_sect sects[1];
};
/* for each 32 bits in above structure, a bitmap, LSB first, whose bits are:
* 0 => a 32-bit value, 1 => 2 16-bit values */
#define DLL_MODULE_BITMAP 0x6 /* swapping bitmap for type dll_module */
#endif /* _MODULE_LIST_H_ */
/*
* params.h
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* This file defines host and target properties for all machines
* supported by the dynamic loader. To be tedious...
*
* host: the machine on which the dynamic loader runs
* target: the machine that the dynamic loader is loading
*
* Host and target may or may not be the same, depending upon the particular
* use.
*
* 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.
*/
/******************************************************************************
*
* Host Properties
*
**************************************************************************** */
#define BITS_PER_BYTE 8 /* bits in the standard PC/SUN byte */
#define LOG_BITS_PER_BYTE 3 /* log base 2 of same */
#define BYTE_MASK ((1U<<BITS_PER_BYTE)-1)
#if defined(__TMS320C55X__) || defined(_TMS320C5XX)
#define BITS_PER_AU 16
#define LOG_BITS_PER_AU 4
/* use this print string in error messages for uint32_t */
#define FMT_UI32 "0x%lx"
#define FMT8_UI32 "%08lx" /* same but no 0x, fixed width field */
#else
/* bits in the smallest addressable data storage unit */
#define BITS_PER_AU 8
/* log base 2 of the same; useful for shift counts */
#define LOG_BITS_PER_AU 3
#define FMT_UI32 "0x%x"
#define FMT8_UI32 "%08x"
#endif
/* generic fastest method for swapping bytes and shorts */
#define SWAP32BY16(zz) (((zz) << 16) | ((zz) >> 16))
#define SWAP16BY8(zz) (((zz) << 8) | ((zz) >> 8))
/* !! don't be tempted to insert type definitions here; use <stdint.h> !! */
/******************************************************************************
*
* Target Properties
*
**************************************************************************** */
/*-------------------------------------------------------------------------- */
/* TMS320C6x Target Specific Parameters (byte-addressable) */
/*-------------------------------------------------------------------------- */
#if TMS32060
#define MEMORG 0x0L /* Size of configured memory */
#define MEMSIZE 0x0L /* (full address space) */
#define CINIT_ALIGN 8 /* alignment of cinit record in TDATA AUs */
#define CINIT_COUNT 4 /* width of count field in TDATA AUs */
#define CINIT_ADDRESS 4 /* width of address field in TDATA AUs */
#define CINIT_PAGE_BITS 0 /* Number of LSBs of address that
* are page number */
#define LENIENT_SIGNED_RELEXPS 0 /* DOES SIGNED ALLOW MAX UNSIGNED */
#undef TARGET_ENDIANNESS /* may be big or little endian */
/* align a target address to a word boundary */
#define TARGET_WORD_ALIGN(zz) (((zz) + 0x3) & -0x4)
#endif
/*--------------------------------------------------------------------------
*
* DEFAULT SETTINGS and DERIVED PROPERTIES
*
* This section establishes defaults for values not specified above
*-------------------------------------------------------------------------- */
#ifndef TARGET_AU_BITS
#define TARGET_AU_BITS 8 /* width of the target addressable unit */
#define LOG_TARGET_AU_BITS 3 /* log2 of same */
#endif
#ifndef CINIT_DEFAULT_PAGE
#define CINIT_DEFAULT_PAGE 0 /* default .cinit page number */
#endif
#ifndef DATA_RUN2LOAD
#define DATA_RUN2LOAD(zz) (zz) /* translate data run address to load address */
#endif
#ifndef DBG_LIST_PAGE
#define DBG_LIST_PAGE 0 /* page number for .dllview section */
#endif
#ifndef TARGET_WORD_ALIGN
/* align a target address to a word boundary */
#define TARGET_WORD_ALIGN(zz) (zz)
#endif
#ifndef TDATA_TO_TADDR
#define TDATA_TO_TADDR(zz) (zz) /* target data address to target AU address */
#define TADDR_TO_TDATA(zz) (zz) /* target AU address to target data address */
#define TDATA_AU_BITS TARGET_AU_BITS /* bits per data AU */
#define LOG_TDATA_AU_BITS LOG_TARGET_AU_BITS
#endif
/*
*
* Useful properties and conversions derived from the above
*
*/
/*
* Conversions between host and target addresses
*/
#if LOG_BITS_PER_AU == LOG_TARGET_AU_BITS
/* translate target addressable unit to host address */
#define TADDR_TO_HOST(x) (x)
/* translate host address to target addressable unit */
#define HOST_TO_TADDR(x) (x)
#elif LOG_BITS_PER_AU > LOG_TARGET_AU_BITS
#define TADDR_TO_HOST(x) ((x) >> (LOG_BITS_PER_AU-LOG_TARGET_AU_BITS))
#define HOST_TO_TADDR(x) ((x) << (LOG_BITS_PER_AU-LOG_TARGET_AU_BITS))
#else
#define TADDR_TO_HOST(x) ((x) << (LOG_TARGET_AU_BITS-LOG_BITS_PER_AU))
#define HOST_TO_TADDR(x) ((x) >> (LOG_TARGET_AU_BITS-LOG_BITS_PER_AU))
#endif
#if LOG_BITS_PER_AU == LOG_TDATA_AU_BITS
/* translate target addressable unit to host address */
#define TDATA_TO_HOST(x) (x)
/* translate host address to target addressable unit */
#define HOST_TO_TDATA(x) (x)
/* translate host address to target addressable unit, round up */
#define HOST_TO_TDATA_ROUND(x) (x)
/* byte offset to host offset, rounded up for TDATA size */
#define BYTE_TO_HOST_TDATA_ROUND(x) BYTE_TO_HOST_ROUND(x)
#elif LOG_BITS_PER_AU > LOG_TDATA_AU_BITS
#define TDATA_TO_HOST(x) ((x) >> (LOG_BITS_PER_AU-LOG_TDATA_AU_BITS))
#define HOST_TO_TDATA(x) ((x) << (LOG_BITS_PER_AU-LOG_TDATA_AU_BITS))
#define HOST_TO_TDATA_ROUND(x) ((x) << (LOG_BITS_PER_AU-LOG_TDATA_AU_BITS))
#define BYTE_TO_HOST_TDATA_ROUND(x) BYTE_TO_HOST_ROUND(x)
#else
#define TDATA_TO_HOST(x) ((x) << (LOG_TDATA_AU_BITS-LOG_BITS_PER_AU))
#define HOST_TO_TDATA(x) ((x) >> (LOG_TDATA_AU_BITS-LOG_BITS_PER_AU))
#define HOST_TO_TDATA_ROUND(x) (((x) +\
(1<<(LOG_TDATA_AU_BITS-LOG_BITS_PER_AU))-1) >>\
(LOG_TDATA_AU_BITS-LOG_BITS_PER_AU))
#define BYTE_TO_HOST_TDATA_ROUND(x) (BYTE_TO_HOST((x) +\
(1<<(LOG_TDATA_AU_BITS-LOG_BITS_PER_BYTE))-1) &\
-(TDATA_AU_BITS/BITS_PER_AU))
#endif
/*
* Input in DOFF format is always expresed in bytes, regardless of loading host
* so we wind up converting from bytes to target and host units even when the
* host is not a byte machine.
*/
#if LOG_BITS_PER_AU == LOG_BITS_PER_BYTE
#define BYTE_TO_HOST(x) (x)
#define BYTE_TO_HOST_ROUND(x) (x)
#define HOST_TO_BYTE(x) (x)
#elif LOG_BITS_PER_AU >= LOG_BITS_PER_BYTE
#define BYTE_TO_HOST(x) ((x) >> (LOG_BITS_PER_AU - LOG_BITS_PER_BYTE))
#define BYTE_TO_HOST_ROUND(x) ((x + (BITS_PER_AU/BITS_PER_BYTE-1)) >>\
(LOG_BITS_PER_AU - LOG_BITS_PER_BYTE))
#define HOST_TO_BYTE(x) ((x) << (LOG_BITS_PER_AU - LOG_BITS_PER_BYTE))
#else
/* lets not try to deal with sub-8-bit byte machines */
#endif
#if LOG_TARGET_AU_BITS == LOG_BITS_PER_BYTE
/* translate target addressable unit to byte address */
#define TADDR_TO_BYTE(x) (x)
/* translate byte address to target addressable unit */
#define BYTE_TO_TADDR(x) (x)
#elif LOG_TARGET_AU_BITS > LOG_BITS_PER_BYTE
#define TADDR_TO_BYTE(x) ((x) << (LOG_TARGET_AU_BITS-LOG_BITS_PER_BYTE))
#define BYTE_TO_TADDR(x) ((x) >> (LOG_TARGET_AU_BITS-LOG_BITS_PER_BYTE))
#else
/* lets not try to deal with sub-8-bit byte machines */
#endif
#ifdef _BIG_ENDIAN
#define HOST_ENDIANNESS 1
#else
#define HOST_ENDIANNESS 0
#endif
#ifdef TARGET_ENDIANNESS
#define TARGET_ENDIANNESS_DIFFERS(rtend) (HOST_ENDIANNESS^TARGET_ENDIANNESS)
#elif HOST_ENDIANNESS
#define TARGET_ENDIANNESS_DIFFERS(rtend) (!(rtend))
#else
#define TARGET_ENDIANNESS_DIFFERS(rtend) (rtend)
#endif
/* the unit in which we process target image data */
#if TARGET_AU_BITS <= 8
typedef u8 tgt_au_t;
#elif TARGET_AU_BITS <= 16
typedef u16 tgt_au_t;
#else
typedef u32 tgt_au_t;
#endif
/* size of that unit */
#if TARGET_AU_BITS < BITS_PER_AU
#define TGTAU_BITS BITS_PER_AU
#define LOG_TGTAU_BITS LOG_BITS_PER_AU
#else
#define TGTAU_BITS TARGET_AU_BITS
#define LOG_TGTAU_BITS LOG_TARGET_AU_BITS
#endif
This diff is collapsed.
/*
* reloc_table.h
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* 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 _RELOC_TABLE_H_
#define _RELOC_TABLE_H_
/*
* Table of relocation operator properties
*/
#include <linux/types.h>
/* How does this relocation operation access the program image? */
#define ROP_N 0 /* does not access image */
#define ROP_R 1 /* read from image */
#define ROP_W 2 /* write to image */
#define ROP_RW 3 /* read from and write to image */
/* For program image access, what are the overflow rules for the bit field? */
/* Beware! Procedure repack depends on this encoding */
#define ROP_ANY 0 /* no overflow ever, just truncate the value */
#define ROP_SGN 1 /* signed field */
#define ROP_UNS 2 /* unsigned field */
#define ROP_MAX 3 /* allow maximum range of either signed or unsigned */
/* How does the relocation operation use the symbol reference */
#define ROP_IGN 0 /* no symbol is referenced */
#define ROP_LIT 0 /* use rp->UVAL literal field */
#define ROP_SYM 1 /* symbol value is used in relocation */
#define ROP_SYMD 2 /* delta value vs last link is used */
/* How does the reloc op use the stack? */
#define RSTK_N 0 /* Does not use */
#define RSTK_POP 1 /* Does a POP */
#define RSTK_UOP 2 /* Unary op, stack position unaffected */
#define RSTK_PSH 3 /* Does a push */
/*
* Computational actions performed by the dynamic loader
*/
enum dload_actions {
/* don't alter the current val (from stack or mem fetch) */
RACT_VAL,
/* set value to reference amount (from symbol reference) */
RACT_ASGN,
RACT_ADD, /* add reference to value */
RACT_PCR, /* add reference minus PC delta to value */
RACT_ADDISP, /* add reference plus R_DISP */
RACT_ASGPC, /* set value to section addr plus reference */
RACT_PLUS, /* stack + */
RACT_SUB, /* stack - */
RACT_NEG, /* stack unary - */
RACT_MPY, /* stack * */
RACT_DIV, /* stack / */
RACT_MOD, /* stack % */
RACT_SR, /* stack unsigned >> */
RACT_ASR, /* stack signed >> */
RACT_SL, /* stack << */
RACT_AND, /* stack & */
RACT_OR, /* stack | */
RACT_XOR, /* stack ^ */
RACT_NOT, /* stack ~ */
RACT_C6SECT, /* for C60 R_SECT op */
RACT_C6BASE, /* for C60 R_BASE op */
RACT_C6DSPL, /* for C60 scaled 15-bit displacement */
RACT_PCR23T /* for ARM Thumb long branch */
};
/*
* macros used to extract values
*/
#define RFV_POSN(aaa) ((aaa) & 0xF)
#define RFV_WIDTH(aaa) (((aaa) >> 4) & 0x3F)
#define RFV_ACTION(aaa) ((aaa) >> 10)
#define RFV_SIGN(iii) (((iii) >> 2) & 0x3)
#define RFV_SYM(iii) (((iii) >> 4) & 0x3)
#define RFV_STK(iii) (((iii) >> 6) & 0x3)
#define RFV_ACCS(iii) ((iii) & 0x3)
#if (TMS32060)
#define RFV_SCALE(iii) ((iii) >> 11)
#define RFV_BIGOFF(iii) (((iii) >> 8) & 0x7)
#else
#define RFV_BIGOFF(iii) ((iii) >> 8)
#endif
#endif /* _RELOC_TABLE_H_ */
/*
* reloc_table_c6000.c
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* 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.
*/
/* Tables generated for c6000 */
#define HASH_FUNC(zz) (((((zz) + 1) * UINT32_C(1845)) >> 11) & 63)
#define HASH_L(zz) ((zz) >> 8)
#define HASH_I(zz) ((zz) & 0xFF)
static const u16 rop_map1[] = {
0,
1,
2,
20,
4,
5,
6,
15,
80,
81,
82,
83,
84,
85,
86,
87,
17,
18,
19,
21,
16,
16394,
16404,
65535,
65535,
65535,
65535,
65535,
65535,
32,
65535,
65535,
65535,
65535,
65535,
65535,
40,
112,
113,
65535,
16384,
16385,
16386,
16387,
16388,
16389,
16390,
16391,
16392,
16393,
16395,
16396,
16397,
16398,
16399,
16400,
16401,
16402,
16403,
16405,
16406,
65535,
65535,
65535
};
static const s16 rop_map2[] = {
-256,
-255,
-254,
-245,
-253,
-252,
-251,
-250,
-241,
-240,
-239,
-238,
-237,
-236,
1813,
5142,
-248,
-247,
778,
-244,
-249,
-221,
-211,
-1,
-1,
-1,
-1,
-1,
-1,
-243,
-1,
-1,
-1,
-1,
-1,
-1,
-242,
-233,
-232,
-1,
-231,
-230,
-229,
-228,
-227,
-226,
-225,
-224,
-223,
5410,
-220,
-219,
-218,
-217,
-216,
-215,
-214,
-213,
5676,
-210,
-209,
-1,
-1,
-1
};
static const u16 rop_action[] = {
2560,
2304,
2304,
2432,
2432,
2560,
2176,
2304,
2560,
3200,
3328,
3584,
3456,
2304,
4208,
20788,
21812,
3415,
3245,
2311,
4359,
19764,
2311,
3191,
3280,
6656,
7680,
8704,
9728,
10752,
11776,
12800,
13824,
14848,
15872,
16896,
17920,
18944,
0,
0,
0,
0,
1536,
1536,
1536,
5632,
512,
0
};
static const u16 rop_info[] = {
0,
35,
35,
35,
35,
35,
35,
35,
35,
39,
39,
39,
39,
35,
34,
283,
299,
4135,
4391,
291,
33059,
283,
295,
4647,
4135,
64,
64,
128,
64,
64,
64,
64,
64,
64,
64,
64,
64,
128,
201,
197,
74,
70,
208,
196,
200,
192,
192,
66
};
This diff is collapsed.
/*
* tramp_table_c6000.c
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* 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.
*/
#include "dload_internal.h"
/* These are defined in coff.h, but may not be available on all platforms
so we'll go ahead and define them here. */
#ifndef R_C60LO16
#define R_C60LO16 0x54 /* C60: MVK Low Half Register */
#define R_C60HI16 0x55 /* C60: MVKH/MVKLH High Half Register */
#endif
#define C6X_TRAMP_WORD_COUNT 8
#define C6X_TRAMP_MAX_RELOS 8
/* THIS HASH FUNCTION MUST MATCH THE ONE IN reloc_table_c6000.c */
#define HASH_FUNC(zz) (((((zz) + 1) * UINT32_C(1845)) >> 11) & 63)
/* THIS MUST MATCH reloc_record_t FOR A SYMBOL BASED RELO */
struct c6000_relo_record {
s32 vaddr;
s32 symndx;
#ifndef _BIG_ENDIAN
u16 disp;
u16 type;
#else
u16 type;
u16 disp;
#endif
};
struct c6000_gen_code {
struct tramp_gen_code_hdr hdr;
u32 tramp_instrs[C6X_TRAMP_WORD_COUNT];
struct c6000_relo_record relos[C6X_TRAMP_MAX_RELOS];
};
/* Hash mapping for relos that can cause trampolines. */
static const u16 tramp_map[] = {
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
0,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535
};
static const struct c6000_gen_code tramp_gen_info[] = {
/* Tramp caused by R_C60PCR21 */
{
/* Header - 8 instructions, 2 relos */
{
sizeof(u32) * C6X_TRAMP_WORD_COUNT,
2,
FIELD_OFFSET(struct c6000_gen_code, relos)
},
/* Trampoline instructions */
{
0x053C54F7, /* STW.D2T2 B10, *sp--[2] */
0x0500002A, /* || MVK.S2 <blank>, B10 */
0x0500006A, /* MVKH.S2 <blank>, B10 */
0x00280362, /* B.S2 B10 */
0x053C52E6, /* LDW.D2T2 *++sp[2], B10 */
0x00006000, /* NOP 4 */
0x00000000, /* NOP */
0x00000000 /* NOP */
},
/* Relocations */
{
{4, 0, 0, R_C60LO16},
{8, 0, 0, R_C60HI16},
{0, 0, 0, 0x0000},
{0, 0, 0, 0x0000},
{0, 0, 0, 0x0000},
{0, 0, 0, 0x0000},
{0, 0, 0, 0x0000},
{0, 0, 0, 0x0000}
}
}
};
/* TARGET SPECIFIC FUNCTIONS THAT MUST BE DEFINED */
static u32 tramp_size_get(void)
{
return sizeof(u32) * C6X_TRAMP_WORD_COUNT;
}
static u32 tramp_img_pkt_size_get(void)
{
return sizeof(struct c6000_gen_code);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment