1 /* xdm-regs.h  -  Common register and related definitions for the XDM
2                   (Xtensa Debug Module) */
3 
4 /* Copyright (c) 2016 Cadence Design Systems Inc.
5 
6    Permission is hereby granted, free of charge, to any person obtaining
7    a copy of this software and associated documentation files (the
8    "Software"), to deal in the Software without restriction, including
9    without limitation the rights to use, copy, modify, merge, publish,
10    distribute, sublicense, and/or sell copies of the Software, and to
11    permit persons to whom the Software is furnished to do so, subject to
12    the following conditions:
13 
14    The above copyright notice and this permission notice shall be included
15    in all copies or substantial portions of the Software.
16 
17    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
24 
25 
26 #ifndef _XDM_REGS_H_
27 #define _XDM_REGS_H_
28 
29 /*  NOTE:  This header file is included by C, assembler, and other sources.
30     So any C-specific or asm-specific content must be appropriately #ifdef'd.  */
31 
32 
33 /*
34  *  XDM registers can be accessed using APB, ERI, or JTAG (via NAR).
35  *  Address offsets for APB and ERI are the same, and for JTAG
36  *  is different (due to the limited 7-bit NAR addressing).
37  *
38  *  Here, we first provide the constants as APB / ERI address offsets.
39  *  This is necessary for assembler code (which accesses XDM via ERI),
40  *  because complex conversion macros between the two address maps
41  *  don't work in the assembler.
42  *  Conversion macros are used to convert these to/from JTAG (NAR),
43  *  addresses, for software using JTAG.
44  */
45 /* FIXME: maybe provide only MISC+CS registers here, and leave specific
46    subsystem registers in separate headers? eg. for TRAX, PERF, OCD */
47 
48 /*       XDM_....     		ERI addr  [NAR addr] Description...... */
49 
50 /*  TRAX  */
51 #define  XDM_TRAX_ID		 0x100000	/*[0x00] ID */
52 #define  XDM_TRAX_CONTROL 	 0x100004	/*[0x01] Control */
53 #define  XDM_TRAX_STATUS	 0x100008	/*[0x02] Status */
54 #define  XDM_TRAX_DATA		 0x10000C	/*[0x03] Data */
55 #define  XDM_TRAX_ADDRESS	 0x100010	/*[0x04] Address */
56 #define  XDM_TRAX_TRIGGER	 0x100014	/*[0x05] Stop PC */
57 #define  XDM_TRAX_MATCH		 0x100018	/*[0x06] Stop PC Range */
58 #define  XDM_TRAX_DELAY		 0x10001C	/*[0x07] Post Stop Trigger Capture Size */
59 #define  XDM_TRAX_STARTADDR	 0x100020	/*[0x08] Trace Memory Start */
60 #define  XDM_TRAX_ENDADDR	 0x100024	/*[0x09] Trace Memory End */
61 #define  XDM_TRAX_DEBUGPC	 0x10003C	/*[0x0F] Debug PC */
62 #define  XDM_TRAX_P4CHANGE	 0x100040	/*[0x10] X */
63 #define  XDM_TRAX_TIME0		 0x100040	/*[0x10] First Time Register */
64 #define  XDM_TRAX_P4REV		 0x100044	/*[0x11] X */
65 #define  XDM_TRAX_TIME1		 0x100044	/*[0x11] Second Time Register */
66 #define  XDM_TRAX_P4DATE	 0x100048	/*[0x12] X */
67 #define  XDM_TRAX_INTTIME_MAX	 0x100048 	/*[0x12] maximal Value of Timestamp IntTime */
68 #define  XDM_TRAX_P4TIME	 0x10004C	/*[0x13] X */
69 #define  XDM_TRAX_PDSTATUS	 0x100050	/*[0x14] Sample of PDebugStatus */
70 #define  XDM_TRAX_PDDATA	 0x100054	/*[0x15] Sample of PDebugData */
71 #define  XDM_TRAX_STOP_PC	 0x100058	/*[0x16] X */
72 #define  XDM_TRAX_STOP_ICNT	 0x10005C	/*[0x16] X */
73 #define  XDM_TRAX_MSG_STATUS	 0x100060	/*[0x17] X */
74 #define  XDM_TRAX_FSM_STATUS	 0x100064	/*[0x18] X */
75 #define  XDM_TRAX_IB_STATUS	 0x100068	/*[0x19] X */
76 #define  XDM_TRAX_STOPCNT	 0x10006C	/*[0x1A] X */
77 
78 /*  Performance Monitoring Counters  */
79 #define  XDM_PERF_PMG		0x101000	/*[0x20] perf. mon. global control register */
80 #define  XDM_PERF_INTPC		0x101010	/*[0x24] perf. mon. interrupt PC */
81 #define  XDM_PERF_PM0		0x101080	/*[0x28] perf. mon. counter 0 value */
82 #define  XDM_PERF_PM1		0x101084	/*[0x29] perf. mon. counter 1 value */
83 #define  XDM_PERF_PM2		0x101088	/*[0x2A] perf. mon. counter 2 value */
84 #define  XDM_PERF_PM3		0x10108C	/*[0x2B] perf. mon. counter 3 value */
85 #define  XDM_PERF_PM4		0x101090	/*[0x2C] perf. mon. counter 4 value */
86 #define  XDM_PERF_PM5		0x101094	/*[0x2D] perf. mon. counter 5 value */
87 #define  XDM_PERF_PM6		0x101098	/*[0x2E] perf. mon. counter 6 value */
88 #define  XDM_PERF_PM7		0x10109C	/*[0x2F] perf. mon. counter 7 value */
89 #define  XDM_PERF_PM(n)		(0x101080+((n)<<2)) /* perfmon cnt n=0..7 value */
90 #define  XDM_PERF_PMCTRL0	0x101100	/*[0x30] perf. mon. counter 0 control */
91 #define  XDM_PERF_PMCTRL1	0x101104	/*[0x31] perf. mon. counter 1 control */
92 #define  XDM_PERF_PMCTRL2	0x101108	/*[0x32] perf. mon. counter 2 control */
93 #define  XDM_PERF_PMCTRL3	0x10110C	/*[0x33] perf. mon. counter 3 control */
94 #define  XDM_PERF_PMCTRL4	0x101110	/*[0x34] perf. mon. counter 4 control */
95 #define  XDM_PERF_PMCTRL5	0x101114	/*[0x35] perf. mon. counter 5 control */
96 #define  XDM_PERF_PMCTRL6	0x101118	/*[0x36] perf. mon. counter 6 control */
97 #define  XDM_PERF_PMCTRL7	0x10111C	/*[0x37] perf. mon. counter 7 control */
98 #define  XDM_PERF_PMCTRL(n)	(0x101100+((n)<<2)) /* perfmon cnt n=0..7 control */
99 #define  XDM_PERF_PMSTAT0	0x101180	/*[0x38] perf. mon. counter 0 status */
100 #define  XDM_PERF_PMSTAT1	0x101184	/*[0x39] perf. mon. counter 1 status */
101 #define  XDM_PERF_PMSTAT2	0x101188	/*[0x3A] perf. mon. counter 2 status */
102 #define  XDM_PERF_PMSTAT3	0x10118C	/*[0x3B] perf. mon. counter 3 status */
103 #define  XDM_PERF_PMSTAT4	0x101190	/*[0x3C] perf. mon. counter 4 status */
104 #define  XDM_PERF_PMSTAT5	0x101194	/*[0x3D] perf. mon. counter 5 status */
105 #define  XDM_PERF_PMSTAT6	0x101198	/*[0x3E] perf. mon. counter 6 status */
106 #define  XDM_PERF_PMSTAT7	0x10119C	/*[0x3F] perf. mon. counter 7 status */
107 #define  XDM_PERF_PMSTAT(n)	(0x101180+((n)<<2)) /* perfmon cnt n=0..7 status */
108 
109 /*  On-Chip-Debug (OCD)  */
110 #define  XDM_OCD_ID		0x102000	/*[0x40] ID register */
111 #define  XDM_OCD_DCR_CLR	0x102008	/*[0x42] Debug Control reg clear */
112 #define  XDM_OCD_DCR_SET	0x10200C	/*[0x43] Debug Control reg set */
113 #define  XDM_OCD_DSR		0x102010	/*[0x44] Debug Status reg */
114 #define  XDM_OCD_DDR		0x102014	/*[0x45] Debug Data reg */
115 #define  XDM_OCD_DDREXEC	0x102018	/*[0x46] Debug Data reg + execute-DIR */
116 #define  XDM_OCD_DIR0EXEC	0x10201C	/*[0x47] Debug Instruction reg, word 0 + execute-DIR */
117 #define  XDM_OCD_DIR0		0x102020	/*[0x48] Debug Instruction reg, word 1 */
118 #define  XDM_OCD_DIR1		0x102024	/*[0x49] Debug Instruction reg, word 2 */
119 #define  XDM_OCD_DIR2		0x102028	/*[0x4A] Debug Instruction reg, word 3 */
120 #define  XDM_OCD_DIR3		0x10202C	/*[0x49] Debug Instruction reg, word 4 */
121 #define  XDM_OCD_DIR4		0x102030	/*[0x4C] Debug Instruction reg, word 5 */
122 #define  XDM_OCD_DIR5		0x102034	/*[0x4D] Debug Instruction reg, word 5 */
123 #define  XDM_OCD_DIR6		0x102038	/*[0x4E] Debug Instruction reg, word 6 */
124 #define  XDM_OCD_DIR7		0x10203C	/*[0x4F] Debug Instruction reg, word 7 */
125 
126 /*  Miscellaneous Registers  */
127 #define  XDM_MISC_PWRCTL	0x103020	/*[0x58] Power and Reset Control */
128 #define  XDM_MISC_PWRSTAT	0x103024	/*[0x59] Power and Reset Status */
129 #define  XDM_MISC_ERISTAT	0x103028	/*[0x5A] ERI Transaction Status */
130 #define  XDM_MISC_DATETIME	0x103034
131 #define  XDM_MISC_CONFIGID1_V0	0x103034	/*[0x5D] [INTERNAL] ConfigID1 in XDM v0/1 */
132 #define  XDM_MISC_CONFIGID1_V2	0x10007c	/*[0x1F] [INTERNAL] ConfigID1 since XDM v2 */
133 #define  XDM_MISC_CONFIGID0_V2	0x100078	/*[0x1E] [INTERNAL] ConfigID0 since XDM v2 */
134 #define  XDM_MISC_UBID		0x103038	/*[0x5E] [INTERNAL] Build Unique ID */
135 #define  XDM_MISC_CID		0x10303C	/*[0x5F] [INTERNAL] Customer ID */
136 
137 /*  CoreSight compatibility  */
138 #define  XDM_CS_ITCTRL		0x103F00	/*[0x60] InTegration Mode control reg */
139 #define  XDM_CS_CLAIMSET	0x103FA0	/*[0x68] Claim Tag Set reg */
140 #define  XDM_CS_CLAIMCLR	0x103FA4	/*[0x69] Claim Tag Clear reg */
141 #define  XDM_CS_LOCK_ACCESS	0x103FB0	/*[0x6B] Lock Access (writing 0xC5ACCE55 unlocks) */
142 #define  XDM_CS_LOCK_STATUS	0x103FB4	/*[0x6D] Lock Status */
143 #define  XDM_CS_AUTH_STATUS	0x103FB8	/*[0x6E] Authentication Status */
144 #define  XDM_CS_DEV_ID		0x103FC8	/*[0x72] Device ID */
145 #define  XDM_CS_DEV_TYPE	0x103FCC	/*[0x73] Device Type */
146 #define  XDM_CS_PER_ID4		0x103FD0	/*[0x74] Peripheral ID reg byte 4 */
147 #define  XDM_CS_PER_ID5		0x103FD4	/*[0x75] Peripheral ID reg byte 5 */
148 #define  XDM_CS_PER_ID6		0x103FD8	/*[0x76] Peripheral ID reg byte 6 */
149 #define  XDM_CS_PER_ID7		0x103FDC	/*[0x77] Peripheral ID reg byte 7 */
150 #define  XDM_CS_PER_ID0		0x103FE0	/*[0x78] Peripheral ID reg byte 0 */
151 #define  XDM_CS_PER_ID1		0x103FE4	/*[0x79] Peripheral ID reg byte 1 */
152 #define  XDM_CS_PER_ID2		0x103FE8	/*[0x7A] Peripheral ID reg byte 2 */
153 #define  XDM_CS_PER_ID3		0x103FEC	/*[0x7B] Peripheral ID reg byte 3 */
154 #define  XDM_CS_COMP_ID0	0x103FF0	/*[0x7C] Component ID reg byte 0 */
155 #define  XDM_CS_COMP_ID1	0x103FF4	/*[0x7D] Component ID reg byte 1 */
156 #define  XDM_CS_COMP_ID2	0x103FF8	/*[0x7E] Component ID reg byte 2 */
157 #define  XDM_CS_COMP_ID3	0x103FFC	/*[0x7F] Component ID reg byte 3 */
158 
159 #define CS_PER_ID0	0x00000003
160 #define CS_PER_ID1	0x00000021
161 #define CS_PER_ID2	0x0000000f
162 #define CS_PER_ID3	0x00000000
163 #define CS_PER_ID4	0x00000024
164 
165 #define CS_COMP_ID0	0x0000000d
166 #define CS_COMP_ID1	0x00000090
167 #define CS_COMP_ID2	0x00000005
168 #define CS_COMP_ID3	0x000000b1
169 
170 #define CS_DEV_TYPE	0x00000015
171 
172 #define XTENSA_IDCODE	0x120034e5    // FIXME (upper bits not spec. out but BE is !)
173 #define XTENSA_MFC_ID	(XTENSA_IDCODE & 0xFFF)
174 #define CS_DEV_ID	XTENSA_IDCODE //FIXME - for XDM v0 only, for v2 is the new ID, that includes vars like PRID but also can be custom
175 #define CS_DEV_ID_v0_MASK	0x00000FFF // can compare only the lower 12 bits
176 #define CS_DEV_ID_v2_MASK	0xF0000000 // can compare only the upper 4 bits
177 
178 #define NXS_OCD_REG(val)  ((val >= 0x40) && (val <= 0x5F))
179 #define NXS_TRAX_REG(val)  val <= 0x3F
180 
181 #define ERI_TRAX_REG(val)  ((val & 0xFFFF) < 0x1000)
182 #define ERI_OCD_REG(val)   ((val & 0xFFFF) >= 0x2000) && ((val & 0xFFFF) < 0x4000))
183 
184 /*  Convert above 14-bit ERI/APB address/offset to 7-bit NAR address:  */
185 #define _XDM_ERI_TO_NAR(a)	( ((a)&0x3F80)==0x0000 ? (((a)>>2) & 0x1F) \
186 				: ((a)&0x3E00)==0x1000 ? (0x20 | (((a)>>2) & 7) | (((a)>>4) & 0x18)) \
187 				: ((a)&0x3FC0)==0x2000 ? (0x40 | (((a)>>2) & 0xF)) \
188 				: ((a)&0x3FE0)==0x3020 ? (0x50 | (((a)>>2) & 0xF)) \
189 				: ((a)&0x3FFC)==0x3F00 ? 0x60 \
190 				: ((a)&0x3F80)==0x3F80 ? (0x60 | (((a)>>2) & 0x1F)) \
191 				: -1 )
192 
193 #define XDM_ERI_TO_NAR(a)	_XDM_ERI_TO_NAR(a & 0xFFFF)
194 
195 /* Convert 7-bit NAR address back to ERI/APB address/offset:  */
196 #define _XDM_NAR_TO_APB(a)	((a) <= 0x1f                ? ((a) << 2)                   \
197 				:(a) >= 0x20 && (a) <= 0x3F ? (0x1000 | (((a)&  7) << 2) | (((a)&0x18)<<4)) \
198 				:(a) >= 0x40 && (a) <= 0x4F ? (0x2000 | (((a)&0xF) << 2))  \
199 				:(a) >= 0x58 && (a) <= 0x5F ? (0x3000 | (((a)&0xF) << 2))  \
200 				:(a) == 0x60                ? (0x3F00)                     \
201 				:(a) >= 0x68 && (a) <= 0x7F ? (0x3F80 | (((a)&0x1F) << 2)) \
202 				: -1)
203 
204 #define XDM_NAR_TO_APB(a)	_XDM_NAR_TO_APB((a & 0xFFFF))
205 #define XDM_NAR_TO_ERI(a)	_XDM_NAR_TO_APB((a & 0xFFFF)) | 0x100000
206 
207 /* Convert APB to ERI address */
208 #define XDM_APB_TO_ERI(a)	((a) | (0x100000))
209 #define XDM_ERI_TO_APB(a)	((a) & (0x0FFFFF))
210 
211 /***********  Bit definitions within some of the above registers  ***********/
212 #define OCD_ID_LSDDRP			0x01000000
213 #define OCD_ID_LSDDRP_SHIFT			24
214 #define OCD_ID_ENDIANESS		0x00000001
215 #define OCD_ID_ENDIANESS_SHIFT			 0
216 #define OCD_ID_PSO			0x0000000C
217 #define OCD_ID_PSO_SHIFT			 2
218 #define OCD_ID_TRACEPORT		0x00000080
219 #define OCD_ID_TRACEPORT_SHIFT			 7
220 
221 #define OCD_ID_LSDDRP_XEA3		0x00000400
222 
223 /*  Power Status register.  NOTE:  different bit positions in JTAG vs. ERI/APB !!  */
224 /*  ERI/APB:  */
225 #define PWRSTAT_CORE_DOMAIN_ON		0x00000001	/* set if core is powered on */
226 #define PWRSTAT_CORE_DOMAIN_ON_SHIFT		0
227 #define PWRSTAT_WAKEUP_RESET		0x00000002	/* [ERI only] 0=cold start, 1=PSO wakeup */
228 #define PWRSTAT_WAKEUP_RESET_SHIFT		1
229 #define PWRSTAT_CACHES_LOST_POWER	0x00000004	/* [ERI only] set if caches (/localmems?) lost power */
230 							/* FIXME: does this include local memories? */
231 #define PWRSTAT_CACHES_LOST_POWER_SHIFT		2
232 #define PWRSTAT_CORE_STILL_NEEDED	0x00000010	/* set if others keeping core awake */
233 #define PWRSTAT_CORE_STILL_NEEDED_SHIFT		4
234 #define PWRSTAT_MEM_DOMAIN_ON		0x00000100	/* set if memory domain is powered on */
235 #define PWRSTAT_MEM_DOMAIN_ON_SHIFT		8
236 #define PWRSTAT_DEBUG_DOMAIN_ON		0x00001000	/* set if debug domain is powered on */
237 #define PWRSTAT_DEBUG_DOMAIN_ON_SHIFT		12
238 #define PWRSTAT_ALL_ON			(PWRSTAT_CORE_DOMAIN_ON | PWRSTAT_MEM_DOMAIN_ON | PWRSTAT_DEBUG_DOMAIN_ON)
239 #define PWRSTAT_CORE_WAS_RESET		0x00010000	/* [APB only] set if core got reset */
240 #define PWRSTAT_CORE_WAS_RESET_SHIFT		16
241 #define PWRSTAT_DEBUG_WAS_RESET		0x10000000	/* set if debug module got reset */
242 #define PWRSTAT_DEBUG_WAS_RESET_SHIFT		28
243 /*  JTAG:  */
244 #define J_PWRSTAT_CORE_DOMAIN_ON	0x01		/* set if core is powered on */
245 #define J_PWRSTAT_MEM_DOMAIN_ON		0x02		/* set if memory domain is powered on */
246 #define J_PWRSTAT_DEBUG_DOMAIN_ON	0x04		/* set if debug domain is powered on */
247 #define J_PWRSTAT_ALL_ON		(J_PWRSTAT_CORE_DOMAIN_ON | J_PWRSTAT_MEM_DOMAIN_ON | J_PWRSTAT_DEBUG_DOMAIN_ON)
248 #define J_PWRSTAT_CORE_STILL_NEEDED	0x08		/* set if others keeping core awake */
249 #define J_PWRSTAT_CORE_WAS_RESET	0x10		/* set if core got reset */
250 #define J_PWRSTAT_DEBUG_WAS_RESET	0x40		/* set if debug module got reset */
251 
252 /*  Power Control register.  NOTE:  different bit positions in JTAG vs. ERI/APB !!  */
253 /*  ERI/APB:  */
254 #define PWRCTL_CORE_SHUTOFF		0x00000001	/* [ERI only] core wants to shut off on WAITI */
255 #define PWRCTL_CORE_SHUTOFF_SHIFT		0
256 #define PWRCTL_CORE_WAKEUP		0x00000001	/* [APB only] set to force core to stay powered on */
257 #define PWRCTL_CORE_WAKEUP_SHIFT		0
258 #define PWRCTL_MEM_WAKEUP		0x00000100	/* set to force memory domain to stay powered on */
259 #define PWRCTL_MEM_WAKEUP_SHIFT			8
260 #define PWRCTL_DEBUG_WAKEUP		0x00001000	/* set to force debug domain to stay powered on */
261 #define PWRCTL_DEBUG_WAKEUP_SHIFT		12
262 #define PWRCTL_ALL_ON			(PWRCTL_CORE_WAKEUP | PWRCTL_MEM_WAKEUP | PWRCTL_DEBUG_WAKEUP)
263 #define PWRCTL_CORE_RESET		0x00010000	/* [APB only] set to assert core reset */
264 #define PWRCTL_CORE_RESET_SHIFT			16
265 #define PWRCTL_DEBUG_RESET		0x10000000	/* set to assert debug module reset */
266 #define PWRCTL_DEBUG_RESET_SHIFT		28
267 /*  JTAG:  */
268 #define J_PWRCTL_CORE_WAKEUP		0x01		/* set to force core to stay powered on */
269 #define J_PWRCTL_MEM_WAKEUP		0x02		/* set to force memory domain to stay powered on */
270 #define J_PWRCTL_DEBUG_WAKEUP		0x04		/* set to force debug domain to stay powered on */
271 #define J_DEBUG_USE			0x80		/*  */
272 #define J_PWRCTL_ALL_ON			(J_DEBUG_USE | J_PWRCTL_CORE_WAKEUP | J_PWRCTL_MEM_WAKEUP | J_PWRCTL_DEBUG_WAKEUP)
273 #define J_PWRCTL_DEBUG_ON		J_DEBUG_USE | J_PWRCTL_DEBUG_WAKEUP
274 #define J_PWRCTL_CORE_RESET		0x10		/* set to assert core reset */
275 #define J_PWRCTL_DEBUG_RESET		0x40		/* set to assert debug module reset */
276 
277 #define J_PWRCTL_WRITE_MASK		0xFF
278 #define J_PWRSTAT_WRITE_MASK		0xFF
279 
280 #define PWRCTL_WRITE_MASK		~0
281 #define PWRSTAT_WRITE_MASK		~0
282 
283 /************  The following are only relevant for JTAG, so perhaps belong in OCD only  **************/
284 
285 /*  XDM 5-bit JTAG Instruction Register (IR) values:  */
286 #define XDM_IR_PWRCTL		0x08	/* select 8-bit Power/Reset Control (PRC) */
287 #define XDM_IR_PWRSTAT		0x09	/* select 8-bit Power/Reset Status (PRS) */
288 #define XDM_IR_NAR_SEL		0x1c	/* select altern. 8-bit NAR / 32-bit NDR (Nexus-style) */
289 #define XDM_IR_NDR_SEL		0x1d	/* select altern. 32-bit NDR / 8-bit NAR
290 					   (FIXME - functionality not yet in HW) */
291 #define XDM_IR_IDCODE		0x1e	/* select 32-bit JTAG IDCODE */
292 #define XDM_IR_BYPASS		0x1f	/* select 1-bit bypass */
293 
294 #define XDM_IR_WIDTH		5	/* width of IR for Xtensa TAP */
295 
296 /*  NAR register bits:  */
297 #define XDM_NAR_WRITE		0x01
298 #define XDM_NAR_ADDR_MASK	0xFE
299 #define XDM_NAR_ADDR_SHIFT	1
300 
301 #define XDM_NAR_BUSY		0x02
302 #define XDM_NAR_ERROR		0x01
303 
304 #define NEXUS_DIR_READ	0x00
305 #define	NEXUS_DIR_WRITE	0x01
306 
307 /************  Define DCR register bits  **************/
308 
309 #define DCR_ENABLEOCD		0x0000001
310 #define DCR_ENABLEOCD_SHIFT		0
311 #define DCR_DEBUG_INT		0x0000002
312 #define DCR_DEBUG_INT_SHIFT		1
313 #define DCR_DEBUG_OVERRIDE	0x0000004
314 #define DCR_DEBUG_OVERRIDE_SHIFT	2
315 #define DCR_DEBUG_SS_REQ	0x0000008
316 #define DCR_DEBUG_SS_REQ_SHIFT	3
317 #define DCR_MASK_NMI		0x0000020
318 #define DCR_MASK_NMI_SHIFT		5
319 #define DCR_STEP_ENABLE		0x0000040
320 #define DCR_STEP_ENABLE_SHIFT		6
321 #define DCR_BREAK_IN_EN		0x0010000
322 #define DCR_BREAK_IN_EN_SHIFT		16
323 #define DCR_BREAK_OUT_EN	0x0020000
324 #define DCR_BREAK_OUT_EN_SHIFT		17
325 #define DCR_DEBUG_INT_EN	0x0040000
326 #define DCR_DEBUG_INT_EN_SHIFT		18
327 #define DCR_DBG_SW_ACTIVE	0x0100000
328 #define DCR_DBG_SW_ACTIVE_SHIFT		20
329 #define DCR_STALL_IN_EN		0x0200000
330 #define DCR_STALL_IN_EN_SHIFT		21
331 #define DCR_DEBUG_OUT_EN	0x0400000
332 #define DCR_DEBUG_OUT_EN_SHIFT		22
333 #define DCR_BREAK_OUT_ITO	0x1000000
334 #define DCR_STALL_OUT_ITO	0x2000000
335 #define DCR_STALL_OUT_ITO_SHIFT		25
336 
337 /************  Define DSR register bits  **************/
338 
339 #define DOSR_STOP_CAUSE_SHIFT	5
340 #define DOSR_STOP_CAUSE_MASK	0xF
341 
342 #define DOSR_EXECDONE_SHIFT	0
343 #define DOSR_EXECDONE_ER	0x01
344 #define DOSR_EXECDONE_SHIFT	0
345 #define DOSR_EXCEPTION_ER	0x02
346 #define DOSR_EXCEPTION_SHIFT	1
347 #define DOSR_BUSY		0x04
348 #define DOSR_BUSY_SHIFT		2
349 #define DOSR_OVERRUN		0x08
350 #define DOSR_OVERRUN_SHIFT	3
351 #define DOSR_INOCDMODE_ER	0x10
352 #define DOSR_INOCDMODE_SHIFT	4
353 #define DOSR_CORE_WROTE_DDR_ER		0x400
354 #define DOSR_CORE_WROTE_DDR_SHIFT	10
355 #define DOSR_CORE_READ_DDR_ER		0x800
356 #define DOSR_CORE_READ_DDR_SHIFT	11
357 #define DOSR_HOST_WROTE_DDR_ER		0x4000
358 #define DOSR_HOST_WROTE_DDR_SHIFT	14
359 #define DOSR_HOST_READ_DDR_ER		0x8000
360 #define DOSR_HOST_READ_DDR_SHIFT	15
361 
362 #define DOSR_DEBUG_PEND_BIN		0x10000
363 #define DOSR_DEBUG_PEND_HOST		0x20000
364 #define DOSR_DEBUG_PEND_TRAX		0x40000
365 #define DOSR_DEBUG_BIN		 	0x100000
366 #define DOSR_DEBUG_HOST			0x200000
367 #define DOSR_DEBUG_TRAX			0x400000
368 #define DOSR_DEBUG_PEND_BIN_SHIFT	16
369 #define DOSR_DEBUG_PEND_HOST_SHIFT	17
370 #define DOSR_DEBUG_PEND_TRAX_SHIFT	18
371 #define DOSR_DEBUG_BREAKIN              0x0100000
372 #define DOSR_DEBUG_BREAKIN_SHIFT        20
373 #define DOSR_DEBUG_HOST_SHIFT		21
374 #define DOSR_DEBUG_TRAX_SHIFT		22
375 
376 #define DOSR_DEBUG_STALL		0x1000000
377 #define DOSR_DEBUG_STALL_SHIFT		24
378 
379 #define DOSR_CORE_ON			0x40000000
380 #define DOSR_CORE_ON_SHIFT		30
381 #define DOSR_DEBUG_ON			0x80000000
382 #define DOSR_DEBUG_ON_SHIFT		31
383 
384 /********** Performance monitor registers bits **********/
385 
386 #define PERF_PMG_ENABLE                 0x00000001 /* global enable bit */
387 #define PERF_PMG_ENABLE_SHIFT           0
388 
389 #define PERF_PMCTRL_INT_ENABLE          0x00000001 /* assert interrupt on overflow */
390 #define PERF_PMCTRL_INT_ENABLE_SHIFT    0
391 #define PERF_PMCTRL_KRNLCNT             0x00000008 /* ignore TRACELEVEL */
392 #define PERF_PMCTRL_KRNLCNT_SHIFT       3
393 #define PERF_PMCTRL_TRACELEVEL          0x000000F0 /* count when CINTLEVEL <= TRACELEVEL */
394 #define PERF_PMCTRL_TRACELEVEL_SHIFT    4
395 #define PERF_PMCTRL_SELECT              0x00001F00 /* events group selector */
396 #define PERF_PMCTRL_SELECT_SHIFT        8
397 #define PERF_PMCTRL_MASK                0xFFFF0000 /* events mask */
398 #define PERF_PMCTRL_MASK_SHIFT          16
399 
400 #define PERF_PMSTAT_OVERFLOW            0x00000001 /* counter overflowed */
401 #define PERF_PMSTAT_OVERFLOW_SHIFT      0
402 #define PERF_PMSTAT_INT                 0x00000010 /* interrupt asserted */
403 #define PERF_PMSTAT_INT_SHIFT           4
404 
405 #if defined (USE_XDM_REGNAME) || defined (USE_DAP_REGNAME)
406 /*  Describes XDM register:  */
407 typedef struct {
408     int    reg;
409     char*  name;
410 } regdef_t;
411 
412 /*
413  *  Returns the name of the specified XDM register number,
414  *  or simply "???" if the register number is not recognized.
415  *  FIXME - requires -1 as the last entry - change to compare the name to ???
416  *  or even better, make the code above to work.
417  */
418 static char*
regname(regdef_t * list,int reg)419 regname(regdef_t* list, int reg)
420 {
421   int i = 0;
422   while (list[i].reg != -1) {
423     if (list[i].reg == reg)
424       break;
425     i++;
426   }
427   return list[i].name;
428 }
429 
430 #if defined (USE_XDM_REGNAME)
431 static regdef_t xdm_reglist[] =
432 {
433   {XDM_OCD_DSR        ,"DOSR"    },
434   {XDM_OCD_DDR        ,"DDR"     },
435   {XDM_OCD_DDREXEC    ,"DDREXEC" },
436   {XDM_OCD_DIR0EXEC   ,"DIR0EXEC"},
437   {XDM_OCD_DCR_CLR    ,"DCR_CLR" },
438   {XDM_OCD_DCR_SET    ,"DCR_SET" },
439   {XDM_TRAX_CONTROL   ,"CONTROL" },
440   {XDM_TRAX_STATUS    ,"STATUS"  },
441   {XDM_TRAX_DATA      ,"DATA"    },
442   {XDM_TRAX_ADDRESS   ,"ADDRESS" },
443 
444   {XDM_TRAX_ID        ,"TRAX_ID"      },
445 
446   {XDM_TRAX_TRIGGER   ,"TRIGGER PC"   },
447   {XDM_TRAX_MATCH     ,"PC MATCH"     },
448   {XDM_TRAX_DELAY     ,"DELAY CNT."   },
449   {XDM_TRAX_STARTADDR ,"START ADDRESS"},
450   {XDM_TRAX_ENDADDR   ,"END ADDRESS"  },
451   {XDM_TRAX_DEBUGPC   ,"DEBUG PC"  },
452   {XDM_TRAX_P4CHANGE  ,"P4 CHANGE"    },
453   {XDM_TRAX_P4REV     ,"P4 REV."      },
454   {XDM_TRAX_P4DATE    ,"P4 DATE"      },
455   {XDM_TRAX_P4TIME    ,"P4 TIME"      },
456   {XDM_TRAX_PDSTATUS  ,"PD STATUS"    },
457   {XDM_TRAX_PDDATA    ,"PD DATA"      },
458   {XDM_TRAX_STOP_PC   ,"STOP PC"      },
459   {XDM_TRAX_STOP_ICNT ,"STOP ICNT"    },
460   {XDM_TRAX_MSG_STATUS,"MSG STAT."    },
461   {XDM_TRAX_FSM_STATUS,"FSM STAT."    },
462   {XDM_TRAX_IB_STATUS ,"IB STAT."     },
463 
464   {XDM_OCD_ID         ,"OCD_ID"  },
465   {XDM_OCD_DIR0       ,"DIR0"    },
466   {XDM_OCD_DIR1       ,"DIR1"    },
467   {XDM_OCD_DIR2       ,"DIR2"    },
468   {XDM_OCD_DIR3       ,"DIR3"    },
469   {XDM_OCD_DIR4       ,"DIR4"    },
470   {XDM_OCD_DIR5       ,"DIR5"    },
471   {XDM_OCD_DIR6       ,"DIR6"    },
472   {XDM_OCD_DIR7       ,"DIR7"    },
473 
474   {XDM_PERF_PMG       ,"PMG"    },
475   {XDM_PERF_INTPC     ,"INTPC"  },
476   {XDM_PERF_PM0       ,"PM0 "   },
477   {XDM_PERF_PM1       ,"PM1 "   },
478   {XDM_PERF_PM2       ,"PM2 "   },
479   {XDM_PERF_PM3       ,"PM3 "   },
480   {XDM_PERF_PM4       ,"PM4 "   },
481   {XDM_PERF_PM5       ,"PM5 "   },
482   {XDM_PERF_PM6       ,"PM6 "   },
483   {XDM_PERF_PM7       ,"PM7 "   },
484   {XDM_PERF_PMCTRL0   ,"PMCTRL0"},
485   {XDM_PERF_PMCTRL1   ,"PMCTRL1"},
486   {XDM_PERF_PMCTRL2   ,"PMCTRL2"},
487   {XDM_PERF_PMCTRL3   ,"PMCTRL3"},
488   {XDM_PERF_PMCTRL4   ,"PMCTRL4"},
489   {XDM_PERF_PMCTRL5   ,"PMCTRL5"},
490   {XDM_PERF_PMCTRL6   ,"PMCTRL6"},
491   {XDM_PERF_PMCTRL7   ,"PMCTRL7"},
492   {XDM_PERF_PMSTAT0   ,"PMSTAT0"},
493   {XDM_PERF_PMSTAT1   ,"PMSTAT1"},
494   {XDM_PERF_PMSTAT2   ,"PMSTAT2"},
495   {XDM_PERF_PMSTAT3   ,"PMSTAT3"},
496   {XDM_PERF_PMSTAT4   ,"PMSTAT4"},
497   {XDM_PERF_PMSTAT5   ,"PMSTAT5"},
498   {XDM_PERF_PMSTAT6   ,"PMSTAT6"},
499   {XDM_PERF_PMSTAT7   ,"PMSTAT7"},
500 
501   {XDM_MISC_PWRCTL    ,"PWRCTL"  },
502   {XDM_MISC_PWRSTAT   ,"PWRSTAT" },
503   {XDM_MISC_ERISTAT   ,"ERISTAT" },
504   {XDM_MISC_DATETIME  ,"DATETIME"},
505   {XDM_MISC_UBID      ,"UBID"    },
506   {XDM_MISC_CID       ,"CID"     },
507 
508   {XDM_CS_ITCTRL      ,"ITCTRL"     },
509   {XDM_CS_CLAIMSET    ,"CLAIMSET"   },
510   {XDM_CS_CLAIMCLR    ,"CLAIMCLR"   },
511   {XDM_CS_LOCK_ACCESS ,"LOCK_ACCESS"},
512   {XDM_CS_LOCK_STATUS ,"LOCK_STATUS"},
513   {XDM_CS_AUTH_STATUS ,"AUTH_STATUS"},
514   {XDM_CS_DEV_ID      ,"DEV_ID"     },
515   {XDM_CS_DEV_TYPE    ,"DEV_TYPE"   },
516   {XDM_CS_PER_ID4     ,"PER_ID4"    },
517   {XDM_CS_PER_ID5     ,"PER_ID5"    },
518   {XDM_CS_PER_ID6     ,"PER_ID6"    },
519   {XDM_CS_PER_ID7     ,"PER_ID7"    },
520   {XDM_CS_PER_ID0     ,"PER_ID0"    },
521   {XDM_CS_PER_ID1     ,"PER_ID1"    },
522   {XDM_CS_PER_ID2     ,"PER_ID2"    },
523   {XDM_CS_PER_ID3     ,"PER_ID3"    },
524   {XDM_CS_COMP_ID0    ,"COMP_ID0"   },
525   {XDM_CS_COMP_ID1    ,"COMP_ID1"   },
526   {XDM_CS_COMP_ID2    ,"COMP_ID2"   },
527   {XDM_CS_COMP_ID3    ,"COMP_ID3"   },
528   {-1                 ,"???"        },
529 };
530 #endif
531 
532 #endif
533 
534 #endif /* _XDM_REGS_H_ */
535