1/* 2 * params.h 3 * 4 * DSP-BIOS Bridge driver support functions for TI OMAP processors. 5 * 6 * This file defines host and target properties for all machines 7 * supported by the dynamic loader. To be tedious... 8 * 9 * host: the machine on which the dynamic loader runs 10 * target: the machine that the dynamic loader is loading 11 * 12 * Host and target may or may not be the same, depending upon the particular 13 * use. 14 * 15 * Copyright (C) 2005-2006 Texas Instruments, Inc. 16 * 17 * This package is free software; you can redistribute it and/or modify 18 * it under the terms of the GNU General Public License version 2 as 19 * published by the Free Software Foundation. 20 * 21 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 23 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24 */ 25 26/****************************************************************************** 27 * 28 * Host Properties 29 * 30 **************************************************************************** */ 31 32#define BITS_PER_BYTE 8 /* bits in the standard PC/SUN byte */ 33#define LOG_BITS_PER_BYTE 3 /* log base 2 of same */ 34#define BYTE_MASK ((1U<<BITS_PER_BYTE)-1) 35 36#if defined(__TMS320C55X__) || defined(_TMS320C5XX) 37#define BITS_PER_AU 16 38#define LOG_BITS_PER_AU 4 39 /* use this print string in error messages for uint32_t */ 40#define FMT_UI32 "0x%lx" 41#define FMT8_UI32 "%08lx" /* same but no 0x, fixed width field */ 42#else 43/* bits in the smallest addressable data storage unit */ 44#define BITS_PER_AU 8 45/* log base 2 of the same; useful for shift counts */ 46#define LOG_BITS_PER_AU 3 47#define FMT_UI32 "0x%x" 48#define FMT8_UI32 "%08x" 49#endif 50 51/* generic fastest method for swapping bytes and shorts */ 52#define SWAP32BY16(zz) (((zz) << 16) | ((zz) >> 16)) 53#define SWAP16BY8(zz) (((zz) << 8) | ((zz) >> 8)) 54 55/* !! don't be tempted to insert type definitions here; use <stdint.h> !! */ 56 57/****************************************************************************** 58 * 59 * Target Properties 60 * 61 **************************************************************************** */ 62 63/*-------------------------------------------------------------------------- */ 64/* TMS320C6x Target Specific Parameters (byte-addressable) */ 65/*-------------------------------------------------------------------------- */ 66#if TMS32060 67#define MEMORG 0x0L /* Size of configured memory */ 68#define MEMSIZE 0x0L /* (full address space) */ 69 70#define CINIT_ALIGN 8 /* alignment of cinit record in TDATA AUs */ 71#define CINIT_COUNT 4 /* width of count field in TDATA AUs */ 72#define CINIT_ADDRESS 4 /* width of address field in TDATA AUs */ 73#define CINIT_PAGE_BITS 0 /* Number of LSBs of address that 74 * are page number */ 75 76#define LENIENT_SIGNED_RELEXPS 0 /* DOES SIGNED ALLOW MAX UNSIGNED */ 77 78#undef TARGET_ENDIANNESS /* may be big or little endian */ 79 80/* align a target address to a word boundary */ 81#define TARGET_WORD_ALIGN(zz) (((zz) + 0x3) & -0x4) 82#endif 83 84/*-------------------------------------------------------------------------- 85 * 86 * DEFAULT SETTINGS and DERIVED PROPERTIES 87 * 88 * This section establishes defaults for values not specified above 89 *-------------------------------------------------------------------------- */ 90#ifndef TARGET_AU_BITS 91#define TARGET_AU_BITS 8 /* width of the target addressable unit */ 92#define LOG_TARGET_AU_BITS 3 /* log2 of same */ 93#endif 94 95#ifndef CINIT_DEFAULT_PAGE 96#define CINIT_DEFAULT_PAGE 0 /* default .cinit page number */ 97#endif 98 99#ifndef DATA_RUN2LOAD 100#define DATA_RUN2LOAD(zz) (zz) /* translate data run address to load address */ 101#endif 102 103#ifndef DBG_LIST_PAGE 104#define DBG_LIST_PAGE 0 /* page number for .dllview section */ 105#endif 106 107#ifndef TARGET_WORD_ALIGN 108/* align a target address to a word boundary */ 109#define TARGET_WORD_ALIGN(zz) (zz) 110#endif 111 112#ifndef TDATA_TO_TADDR 113#define TDATA_TO_TADDR(zz) (zz) /* target data address to target AU address */ 114#define TADDR_TO_TDATA(zz) (zz) /* target AU address to target data address */ 115#define TDATA_AU_BITS TARGET_AU_BITS /* bits per data AU */ 116#define LOG_TDATA_AU_BITS LOG_TARGET_AU_BITS 117#endif 118 119/* 120 * 121 * Useful properties and conversions derived from the above 122 * 123 */ 124 125/* 126 * Conversions between host and target addresses 127 */ 128#if LOG_BITS_PER_AU == LOG_TARGET_AU_BITS 129/* translate target addressable unit to host address */ 130#define TADDR_TO_HOST(x) (x) 131/* translate host address to target addressable unit */ 132#define HOST_TO_TADDR(x) (x) 133#elif LOG_BITS_PER_AU > LOG_TARGET_AU_BITS 134#define TADDR_TO_HOST(x) ((x) >> (LOG_BITS_PER_AU-LOG_TARGET_AU_BITS)) 135#define HOST_TO_TADDR(x) ((x) << (LOG_BITS_PER_AU-LOG_TARGET_AU_BITS)) 136#else 137#define TADDR_TO_HOST(x) ((x) << (LOG_TARGET_AU_BITS-LOG_BITS_PER_AU)) 138#define HOST_TO_TADDR(x) ((x) >> (LOG_TARGET_AU_BITS-LOG_BITS_PER_AU)) 139#endif 140 141#if LOG_BITS_PER_AU == LOG_TDATA_AU_BITS 142/* translate target addressable unit to host address */ 143#define TDATA_TO_HOST(x) (x) 144/* translate host address to target addressable unit */ 145#define HOST_TO_TDATA(x) (x) 146/* translate host address to target addressable unit, round up */ 147#define HOST_TO_TDATA_ROUND(x) (x) 148/* byte offset to host offset, rounded up for TDATA size */ 149#define BYTE_TO_HOST_TDATA_ROUND(x) BYTE_TO_HOST_ROUND(x) 150#elif LOG_BITS_PER_AU > LOG_TDATA_AU_BITS 151#define TDATA_TO_HOST(x) ((x) >> (LOG_BITS_PER_AU-LOG_TDATA_AU_BITS)) 152#define HOST_TO_TDATA(x) ((x) << (LOG_BITS_PER_AU-LOG_TDATA_AU_BITS)) 153#define HOST_TO_TDATA_ROUND(x) ((x) << (LOG_BITS_PER_AU-LOG_TDATA_AU_BITS)) 154#define BYTE_TO_HOST_TDATA_ROUND(x) BYTE_TO_HOST_ROUND(x) 155#else 156#define TDATA_TO_HOST(x) ((x) << (LOG_TDATA_AU_BITS-LOG_BITS_PER_AU)) 157#define HOST_TO_TDATA(x) ((x) >> (LOG_TDATA_AU_BITS-LOG_BITS_PER_AU)) 158#define HOST_TO_TDATA_ROUND(x) (((x) +\ 159 (1<<(LOG_TDATA_AU_BITS-LOG_BITS_PER_AU))-1) >>\ 160 (LOG_TDATA_AU_BITS-LOG_BITS_PER_AU)) 161#define BYTE_TO_HOST_TDATA_ROUND(x) (BYTE_TO_HOST((x) +\ 162 (1<<(LOG_TDATA_AU_BITS-LOG_BITS_PER_BYTE))-1) &\ 163 -(TDATA_AU_BITS/BITS_PER_AU)) 164#endif 165 166/* 167 * Input in DOFF format is always expresed in bytes, regardless of loading host 168 * so we wind up converting from bytes to target and host units even when the 169 * host is not a byte machine. 170 */ 171#if LOG_BITS_PER_AU == LOG_BITS_PER_BYTE 172#define BYTE_TO_HOST(x) (x) 173#define BYTE_TO_HOST_ROUND(x) (x) 174#define HOST_TO_BYTE(x) (x) 175#elif LOG_BITS_PER_AU >= LOG_BITS_PER_BYTE 176#define BYTE_TO_HOST(x) ((x) >> (LOG_BITS_PER_AU - LOG_BITS_PER_BYTE)) 177#define BYTE_TO_HOST_ROUND(x) ((x + (BITS_PER_AU/BITS_PER_BYTE-1)) >>\ 178 (LOG_BITS_PER_AU - LOG_BITS_PER_BYTE)) 179#define HOST_TO_BYTE(x) ((x) << (LOG_BITS_PER_AU - LOG_BITS_PER_BYTE)) 180#else 181/* lets not try to deal with sub-8-bit byte machines */ 182#endif 183 184#if LOG_TARGET_AU_BITS == LOG_BITS_PER_BYTE 185/* translate target addressable unit to byte address */ 186#define TADDR_TO_BYTE(x) (x) 187/* translate byte address to target addressable unit */ 188#define BYTE_TO_TADDR(x) (x) 189#elif LOG_TARGET_AU_BITS > LOG_BITS_PER_BYTE 190#define TADDR_TO_BYTE(x) ((x) << (LOG_TARGET_AU_BITS-LOG_BITS_PER_BYTE)) 191#define BYTE_TO_TADDR(x) ((x) >> (LOG_TARGET_AU_BITS-LOG_BITS_PER_BYTE)) 192#else 193/* lets not try to deal with sub-8-bit byte machines */ 194#endif 195 196#ifdef _BIG_ENDIAN 197#define HOST_ENDIANNESS 1 198#else 199#define HOST_ENDIANNESS 0 200#endif 201 202#ifdef TARGET_ENDIANNESS 203#define TARGET_ENDIANNESS_DIFFERS(rtend) (HOST_ENDIANNESS^TARGET_ENDIANNESS) 204#elif HOST_ENDIANNESS 205#define TARGET_ENDIANNESS_DIFFERS(rtend) (!(rtend)) 206#else 207#define TARGET_ENDIANNESS_DIFFERS(rtend) (rtend) 208#endif 209 210/* the unit in which we process target image data */ 211#if TARGET_AU_BITS <= 8 212typedef u8 tgt_au_t; 213#elif TARGET_AU_BITS <= 16 214typedef u16 tgt_au_t; 215#else 216typedef u32 tgt_au_t; 217#endif 218 219/* size of that unit */ 220#if TARGET_AU_BITS < BITS_PER_AU 221#define TGTAU_BITS BITS_PER_AU 222#define LOG_TGTAU_BITS LOG_BITS_PER_AU 223#else 224#define TGTAU_BITS TARGET_AU_BITS 225#define LOG_TGTAU_BITS LOG_TARGET_AU_BITS 226#endif 227