1 /* TRAX register definitions 2 3 Copyright (c) 2006-2012 Tensilica Inc. 4 5 Permission is hereby granted, free of charge, to any person obtaining 6 a copy of this software and associated documentation files (the 7 "Software"), to deal in the Software without restriction, including 8 without limitation the rights to use, copy, modify, merge, publish, 9 distribute, sublicense, and/or sell copies of the Software, and to 10 permit persons to whom the Software is furnished to do so, subject to 11 the following conditions: 12 13 The above copyright notice and this permission notice shall be included 14 in all copies or substantial portions of the Software. 15 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 23 24 #ifndef _TRAX_REGISTERS_H_ 25 #define _TRAX_REGISTERS_H_ 26 27 #define SHOW 1 28 #define HIDE 0 29 30 #define RO 0 31 #define RW 1 32 33 /* TRAX Register Numbers (from possible range of 0..127) */ 34 #if 0 35 #define TRAXREG_ID 0 36 #define TRAXREG_CONTROL 1 37 #define TRAXREG_STATUS 2 38 #define TRAXREG_DATA 3 39 #define TRAXREG_ADDRESS 4 40 #define TRAXREG_TRIGGER 5 41 #define TRAXREG_MATCH 6 42 #define TRAXREG_DELAY 7 43 #define TRAXREG_STARTADDR 8 44 #define TRAXREG_ENDADDR 9 45 /* Internal use only (unpublished): */ 46 #define TRAXREG_P4CHANGE 16 47 #define TRAXREG_P4REV 17 48 #define TRAXREG_P4DATE 18 49 #define TRAXREG_P4TIME 19 50 #define TRAXREG_PDSTATUS 20 51 #define TRAXREG_PDDATA 21 52 #define TRAXREG_STOP_PC 22 53 #define TRAXREG_STOP_ICNT 23 54 #define TRAXREG_MSG_STATUS 24 55 #define TRAXREG_FSM_STATUS 25 56 #define TRAXREG_IB_STATUS 26 57 #define TRAXREG_MAX 27 58 #define TRAXREG_ITCTRL 96 59 #endif 60 /* The registers above match the NAR addresses. So, their values are used for NAR access */ 61 62 /* TRAX Register Fields */ 63 64 /* TRAX ID register fields: */ 65 #define TRAX_ID_PRODNO 0xf0000000 /* product number (0=TRAX) */ 66 #define TRAX_ID_PRODOPT 0x0f000000 /* product options */ 67 #define TRAX_ID_MIW64 0x08000000 /* opt: instruction width */ 68 #define TRAX_ID_AMTRAX 0x04000000 /* opt: collection of options, internal (VER_2_0 or later)*/ 69 #define TRAX_ID_MAJVER(id) (((id) >> 20) & 0x0f) 70 #define TRAX_ID_MINVER(id) (((id) >> 17) & 0x07) 71 #define TRAX_ID_VER(id) ((TRAX_ID_MAJVER(id)<<4)|TRAX_ID_MINVER(id)) 72 #define TRAX_ID_STDCFG 0x00010000 /* standard config */ 73 #define TRAX_ID_CFGID 0x0000ffff /* TRAX configuration ID */ 74 #define TRAX_ID_MEMSHARED 0x00001000 /* Memshared option in TRAX */ 75 #define TRAX_ID_FROM_VER(ver) ((((ver) & 0xf0) << 16) | (((ver) & 0x7) << 17)) 76 /* Other TRAX ID register macros: */ 77 /* TRAX versions of interest (TRAX_ID_VER(), ie. MAJVER*16 + MINVER): */ 78 #define TRAX_VER_1_0 0x10 /* RA */ 79 #define TRAX_VER_1_1 0x11 /* RB thru RC-2010.1 */ 80 #define TRAX_VER_2_0 0x20 /* RC-2010.2, RD-2010.0, RD-2011.1 */ 81 #define TRAX_VER_2_1 0x21 /* RC-2011.3 / RD-2011.2 and later */ 82 #define TRAX_VER_3_0 0x30 /* RE-2012.0 */ 83 #define TRAX_VER_3_1 0x31 /* RE-2012.1 */ 84 #define TRAX_VER_HUAWEI_3 TRAX_VER_3_0 /* For Huawei, PRs: 25223, 25224, 24880 */ 85 86 87 /* TRAX version 1.0 requires a couple software workarounds: */ 88 #define TRAX_ID_1_0_ERRATUM(id) (TRAX_ID_VER(id) == TRAX_VER_1_0) 89 /* TRAX version 2.0 requires software workaround for PR 22161: */ 90 #define TRAX_ID_MEMSZ_ERRATUM(id) (TRAX_ID_VER(id) == TRAX_VER_2_0) 91 92 /* TRAX Control register fields: */ 93 #define TRAX_CONTROL_TREN 0x00000001 94 #define TRAX_CONTROL_TRSTP 0x00000002 95 #define TRAX_CONTROL_PCMEN 0x00000004 96 #define TRAX_CONTROL_PTIEN 0x00000010 97 #define TRAX_CONTROL_CTIEN 0x00000020 98 #define TRAX_CONTROL_TMEN 0x00000080 /* 2.0+ */ 99 #define TRAX_CONTROL_CNTU 0x00000200 100 #define TRAX_CONTROL_BIEN 0x00000400 101 #define TRAX_CONTROL_BOEN 0x00000800 102 #define TRAX_CONTROL_TSEN 0x00000800 103 #define TRAX_CONTROL_SMPER 0x00007000 104 #define TRAX_CONTROL_SMPER_SHIFT 12 105 #define TRAX_CONTROL_PTOWT 0x00010000 106 #define TRAX_CONTROL_CTOWT 0x00020000 107 #define TRAX_CONTROL_PTOWS 0x00100000 108 #define TRAX_CONTROL_CTOWS 0x00200000 109 #define TRAX_CONTROL_ATID 0x7F000000 /* 2.0+, amtrax */ 110 #define TRAX_CONTROL_ATID_SHIFT 24 111 #define TRAX_CONTROL_ATEN 0x80000000 /* 2.0+, amtrax */ 112 113 #define TRAX_CONTROL_PTOWS_ER 0x00020000 /* For 3.0 */ 114 #define TRAX_CONTROL_CTOWT_ER 0x00100000 /* For 3.0 */ 115 116 #define TRAX_CONTROL_ITCTO 0x00400000 /* For 3.0 */ 117 #define TRAX_CONTROL_ITCTIA 0x00800000 /* For 3.0 */ 118 #define TRAX_CONTROL_ITATV 0x01000000 /* For 3.0 */ 119 120 121 /* TRAX Status register fields: */ 122 #define TRAX_STATUS_TRACT 0x00000001 123 #define TRAX_STATUS_TRIG 0x00000002 124 #define TRAX_STATUS_PCMTG 0x00000004 125 #define TRAX_STATUS_BUSY 0x00000008 /* ER ??? */ 126 #define TRAX_STATUS_PTITG 0x00000010 127 #define TRAX_STATUS_CTITG 0x00000020 128 #define TRAX_STATUS_MEMSZ 0x00001F00 129 #define TRAX_STATUS_MEMSZ_SHIFT 8 130 #define TRAX_STATUS_PTO 0x00010000 131 #define TRAX_STATUS_CTO 0x00020000 132 133 #define TRAX_STATUS_ITCTOA 0x00400000 /* For 3.0 */ 134 #define TRAX_STATUS_ITCTI 0x00800000 /* For 3.0 */ 135 #define TRAX_STATUS_ITATR 0x01000000 /* For 3.0 */ 136 137 138 /* TRAX Address register fields: */ 139 #define TRAX_ADDRESS_TWSAT 0x80000000 140 #define TRAX_ADDRESS_TWSAT_SHIFT 31 141 #define TRAX_ADDRESS_TOTALMASK 0x00FFFFFF 142 // !!! VUakiVU. added for new TRAX: 143 #define TRAX_ADDRESS_WRAPCNT 0x7FE00000 /* version ???... */ 144 #define TRAX_ADDRESS_WRAP_SHIFT 21 145 146 /* TRAX PCMatch register fields: */ 147 #define TRAX_PCMATCH_PCML 0x0000001F 148 #define TRAX_PCMATCH_PCML_SHIFT 0 149 #define TRAX_PCMATCH_PCMS 0x80000000 150 151 /* Compute trace ram buffer size (in bytes) from status register: */ 152 #define TRAX_MEM_SIZE(status) (1L << (((status) & TRAX_STATUS_MEMSZ) >> TRAX_STATUS_MEMSZ_SHIFT)) 153 154 #if 0 155 /* Describes a field within a register: */ 156 typedef struct { 157 const char* name; 158 // unsigned width; 159 // unsigned shift; 160 char width; 161 char shift; 162 char visible; /* 0 = internal use only, 1 = shown */ 163 char reserved; 164 } trax_regfield_t; 165 #endif 166 167 /* Describes a TRAX register: */ 168 typedef struct { 169 const char* name; 170 unsigned id; 171 char width; 172 char visible; 173 char writable; 174 char reserved; 175 //const trax_regfield_t * fieldset; 176 } trax_regdef_t; 177 178 179 extern const trax_regdef_t trax_reglist[]; 180 extern const signed int trax_readable_regs[]; 181 extern const signed int trax_unamed_header_regs[]; 182 183 #ifdef __cplusplus 184 extern "C" { 185 #endif 186 187 /* Prototypes: */ 188 extern int trax_find_reg(char * regname, char **errmsg); 189 extern const char * trax_regname(int regno); 190 191 #ifdef __cplusplus 192 } 193 #endif 194 195 #endif /* _TRAX_REGISTERS_H_ */ 196