OpenOCD
debug_defines.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-2-Clause OR CC-BY-4.0 */
2 /* This file was auto-generated by running 'make debug_defines' in https://github.com/riscv/riscv-debug-spec/ (22a7576) */
3 
4 #ifndef DEBUG_DEFINES_H
5 #define DEBUG_DEFINES_H
6 #define DTM_IDCODE 0x01
7 /*
8  * Identifies the release version of this part.
9  */
10 #define DTM_IDCODE_VERSION_OFFSET 0x1cULL
11 #define DTM_IDCODE_VERSION_LENGTH 4ULL
12 #define DTM_IDCODE_VERSION 0xf0000000ULL
13 /*
14  * Identifies the designer's part number of this part.
15  */
16 #define DTM_IDCODE_PARTNUMBER_OFFSET 0xcULL
17 #define DTM_IDCODE_PARTNUMBER_LENGTH 0x10ULL
18 #define DTM_IDCODE_PARTNUMBER 0xffff000ULL
19 /*
20  * Identifies the designer/manufacturer of this part. Bits 6:0 must be
21  * bits 6:0 of the designer/manufacturer's Identification Code as
22  * assigned by JEDEC Standard JEP106. Bits 10:7 contain the modulo-16
23  * count of the number of continuation characters (0x7f) in that same
24  * Identification Code.
25  */
26 #define DTM_IDCODE_MANUFID_OFFSET 1ULL
27 #define DTM_IDCODE_MANUFID_LENGTH 0xbULL
28 #define DTM_IDCODE_MANUFID 0xffeULL
29 #define DTM_IDCODE_1_OFFSET 0ULL
30 #define DTM_IDCODE_1_LENGTH 1ULL
31 #define DTM_IDCODE_1 1ULL
32 #define DTM_DTMCS 0x10
33 /*
34  * This optional field may provide additional detail about an error
35  * that occurred when communicating with a DM. It is updated whenever
36  * {dmi-op} is updated by the hardware or when 1 is written to
37  * {dtmcs-dmireset}.
38  */
39 #define DTM_DTMCS_ERRINFO_OFFSET 0x12ULL
40 #define DTM_DTMCS_ERRINFO_LENGTH 3ULL
41 #define DTM_DTMCS_ERRINFO 0x1c0000ULL
42 /*
43  * not implemented: This field is not implemented.
44  */
45 #define DTM_DTMCS_ERRINFO_NOT_IMPLEMENTED 0
46 /*
47  * dmi error: There was an error between the DTM and DMI.
48  */
49 #define DTM_DTMCS_ERRINFO_DMI_ERROR 1
50 /*
51  * communication error: There was an error between the DMI and a DMI subordinate.
52  */
53 #define DTM_DTMCS_ERRINFO_COMMUNICATION_ERROR 2
54 /*
55  * device error: The DMI subordinate reported an error.
56  */
57 #define DTM_DTMCS_ERRINFO_DEVICE_ERROR 3
58 /*
59  * unknown: There is no error to report, or no further information available
60  * about the error. This is the reset value if the field is implemented.
61  */
62 #define DTM_DTMCS_ERRINFO_UNKNOWN 4
63 /*
64  * Other values are reserved for future use by this specification.
65  */
66 /*
67  * Writing 1 to this bit does a hard reset of the DTM,
68  * causing the DTM to forget about any outstanding DMI transactions, and
69  * returning all registers and internal state to their reset value.
70  * In general this should only be used when the Debugger has
71  * reason to expect that the outstanding DMI transaction will never
72  * complete (e.g. a reset condition caused an inflight DMI transaction to
73  * be cancelled).
74  */
75 #define DTM_DTMCS_DTMHARDRESET_OFFSET 0x11ULL
76 #define DTM_DTMCS_DTMHARDRESET_LENGTH 1ULL
77 #define DTM_DTMCS_DTMHARDRESET 0x20000ULL
78 /*
79  * Writing 1 to this bit clears the sticky error state and resets
80  * {dtmcs-errinfo}, but does not affect outstanding DMI transactions.
81  */
82 #define DTM_DTMCS_DMIRESET_OFFSET 0x10ULL
83 #define DTM_DTMCS_DMIRESET_LENGTH 1ULL
84 #define DTM_DTMCS_DMIRESET 0x10000ULL
85 /*
86  * This is a hint to the debugger of the minimum number of
87  * cycles a debugger should spend in
88  * Run-Test/Idle after every DMI scan to avoid a `busy'
89  * return code ({dtmcs-dmistat} of 3). A debugger must still
90  * check {dtmcs-dmistat} when necessary.
91  *
92  * 0: It is not necessary to enter Run-Test/Idle at all.
93  *
94  * 1: Enter Run-Test/Idle and leave it immediately.
95  *
96  * 2: Enter Run-Test/Idle and stay there for 1 cycle before leaving.
97  *
98  * And so on.
99  */
100 #define DTM_DTMCS_IDLE_OFFSET 0xcULL
101 #define DTM_DTMCS_IDLE_LENGTH 3ULL
102 #define DTM_DTMCS_IDLE 0x7000ULL
103 /*
104  * Read-only alias of {dmi-op}.
105  */
106 #define DTM_DTMCS_DMISTAT_OFFSET 0xaULL
107 #define DTM_DTMCS_DMISTAT_LENGTH 2ULL
108 #define DTM_DTMCS_DMISTAT 0xc00ULL
109 /*
110  * The size of {dmi-address} in {dtm-dmi}.
111  */
112 #define DTM_DTMCS_ABITS_OFFSET 4ULL
113 #define DTM_DTMCS_ABITS_LENGTH 6ULL
114 #define DTM_DTMCS_ABITS 0x3f0ULL
115 #define DTM_DTMCS_VERSION_OFFSET 0ULL
116 #define DTM_DTMCS_VERSION_LENGTH 4ULL
117 #define DTM_DTMCS_VERSION 0xfULL
118 /*
119  * 0.11: Version described in spec version 0.11.
120  */
121 #define DTM_DTMCS_VERSION_0_11 0
122 /*
123  * 1.0: Version described in spec versions 0.13 and 1.0.
124  */
125 #define DTM_DTMCS_VERSION_1_0 1
126 /*
127  * custom: Version not described in any available version of this spec.
128  */
129 #define DTM_DTMCS_VERSION_CUSTOM 15
130 #define DTM_DMI 0x11
131 /*
132  * Address used for DMI access. In Update-DR this value is used
133  * to access the DM over the DMI.
134  * {dmi-op} defines what this register contains after every possible
135  * operation.
136  */
137 #define DTM_DMI_ADDRESS_OFFSET 0x22ULL
138 #define DTM_DMI_ADDRESS_LENGTH(abits) (abits)
139 #define DTM_DMI_ADDRESS(abits) ((0x400000000ULL * (1ULL << (abits))) + -0x400000000ULL)
140 /*
141  * The data to send to the DM over the DMI during Update-DR, and
142  * the data returned from the DM as a result of the previous operation.
143  */
144 #define DTM_DMI_DATA_OFFSET 2ULL
145 #define DTM_DMI_DATA_LENGTH 0x20ULL
146 #define DTM_DMI_DATA 0x3fffffffcULL
147 /*
148  * When the debugger writes this field, it has the following meaning:
149  */
150 #define DTM_DMI_OP_OFFSET 0ULL
151 #define DTM_DMI_OP_LENGTH 2ULL
152 #define DTM_DMI_OP 3ULL
153 /*
154  * nop: Ignore {sbdata0-data} and {sbaddress0-address}.
155  *
156  * Don't send anything over the DMI during Update-DR.
157  * This operation should never affect DMI busy or error status.
158  * The address and data reported in the following Capture-DR
159  * are undefined.
160  *
161  * This operation leaves the values in {dmi-address} and {dmi-data}
162  * UNSPECIFIED.
163  */
164 #define DTM_DMI_OP_NOP 0
165 /*
166  * read: Read from {dmi-address}.
167  *
168  * When this operation succeeds, {dmi-address} contains the address
169  * that was read from, and {dmi-data} contains the value that was
170  * read.
171  */
172 #define DTM_DMI_OP_READ 1
173 /*
174  * write: Write {dmi-data} to {dmi-address}.
175  *
176  * This operation leaves the values in {dmi-address} and {dmi-data}
177  * UNSPECIFIED.
178  */
179 #define DTM_DMI_OP_WRITE 2
180 /*
181  * reserved: Reserved.
182  */
183 /*
184  * When the debugger reads this field, it means the following:
185  */
186 /*
187  * success: The previous operation completed successfully.
188  */
189 #define DTM_DMI_OP_SUCCESS 0
190 /*
191  * reserved: Reserved.
192  */
193 /*
194  * failed: A previous operation failed. The data scanned into {dtm-dmi} in
195  * this access will be ignored. This status is sticky and can be
196  * cleared by writing {dtmcs-dmireset} in {dtm-dtmcs}.
197  *
198  * This indicates that the DM itself or the DMI responded with an error.
199  * There are no specified cases in which the DM would
200  * respond with an error, and DMI is not required to support
201  * returning errors.
202  *
203  * If a debugger sees this status, there might be additional
204  * information in {dtmcs-errinfo}.
205  */
206 #define DTM_DMI_OP_FAILED 2
207 /*
208  * busy: A DMI operation was attempted while a prior DMI operation was still in
209  * progress. The data scanned into {dtm-dmi} in this access will be
210  * ignored. This status is sticky and can be cleared by writing
211  * {dtmcs-dmireset} in {dtm-dtmcs}. If a debugger sees this status, it
212  * needs to give the target more TCK edges between Update-DR and
213  * Capture-DR. The simplest way to do that is to add extra transitions
214  * in Run-Test/Idle.
215  */
216 #define DTM_DMI_OP_BUSY 3
217 #define CSR_DCSR 0x7b0
218 #define CSR_DCSR_DEBUGVER_OFFSET 0x1cULL
219 #define CSR_DCSR_DEBUGVER_LENGTH 4ULL
220 #define CSR_DCSR_DEBUGVER 0xf0000000ULL
221 /*
222  * none: There is no debug support.
223  */
224 #define CSR_DCSR_DEBUGVER_NONE 0
225 /*
226  * 1.0: Debug support exists as it is described in this document.
227  */
228 #define CSR_DCSR_DEBUGVER_1_0 4
229 /*
230  * custom: There is debug support, but it does not conform to any
231  * available version of this spec.
232  */
233 #define CSR_DCSR_DEBUGVER_CUSTOM 15
234 /*
235  * When {dcsr-cause} is 7, this optional field contains the value of a
236  * more specific halt reason than "other." Otherwise it contains 0.
237  */
238 #define CSR_DCSR_EXTCAUSE_OFFSET 0x18ULL
239 #define CSR_DCSR_EXTCAUSE_LENGTH 3ULL
240 #define CSR_DCSR_EXTCAUSE 0x7000000ULL
241 /*
242  * critical error: The hart entered a critical error state, as defined in the
243  * ((Smdbltrp)) extension.
244  */
245 #define CSR_DCSR_EXTCAUSE_CRITICAL_ERROR 0
246 /*
247  * All other values are reserved for future versions of this spec, or
248  * for use by other RISC-V extensions.
249  */
250 /*
251  * This bit is part of ((Smdbltrp)) and only exists when that extension
252  * is implemented.
253  */
254 #define CSR_DCSR_CETRIG_OFFSET 0x13ULL
255 #define CSR_DCSR_CETRIG_LENGTH 1ULL
256 #define CSR_DCSR_CETRIG 0x80000ULL
257 /*
258  * disabled: A hart in a critical error state does not enter Debug Mode but
259  * instead asserts the critical-error signal to the platform.
260  */
261 #define CSR_DCSR_CETRIG_DISABLED 0
262 /*
263  * enabled: A hart in a critical error state enters Debug Mode instead of
264  * asserting the critical-error signal to the platform. Upon such
265  * entry into Debug Mode, the cause field is set to 7, and the
266  * extcause field is set to 0, indicating a critical error
267  * triggered the Debug Mode entry. This cause has the highest
268  * priority among all reasons for entering Debug Mode. Resuming
269  * from Debug Mode following an entry from the critical error state
270  * returns the hart to the critical error state.
271  */
272 #define CSR_DCSR_CETRIG_ENABLED 1
273 /*
274  * [NOTE]
275  * ====
276  * When {dcsr-cetrig} is 1, resuming from Debug Mode
277  * following an entry due to a critical error will result in an
278  * immediate re-entry into Debug Mode due to the critical error.
279  * The debugger may resume with {dcsr-cetrig} set to 0 to allow the
280  * platform defined actions on critical-error signal to occur.
281  * Other possible actions include initiating a hart or platform
282  * reset using the Debug Module reset control.
283  * ====
284  */
285 /*
286  * This bit is part of ((Zicfilp)) and only exists when that extension
287  * is implemented.
288  */
289 #define CSR_DCSR_PELP_OFFSET 0x12ULL
290 #define CSR_DCSR_PELP_LENGTH 1ULL
291 #define CSR_DCSR_PELP 0x40000ULL
292 /*
293  * NO_LP_EXPECTED: No landing pad instruction expected.
294  */
295 #define CSR_DCSR_PELP_NO_LP_EXPECTED 0
296 /*
297  * LP_EXPECTED: A landing pad instruction is expected.
298  */
299 #define CSR_DCSR_PELP_LP_EXPECTED 1
300 #define CSR_DCSR_EBREAKVS_OFFSET 0x11ULL
301 #define CSR_DCSR_EBREAKVS_LENGTH 1ULL
302 #define CSR_DCSR_EBREAKVS 0x20000ULL
303 /*
304  * exception: `ebreak` instructions in VS-mode behave as described in the
305  * Privileged Spec.
306  */
307 #define CSR_DCSR_EBREAKVS_EXCEPTION 0
308 /*
309  * debug mode: `ebreak` instructions in VS-mode enter Debug Mode.
310  */
311 #define CSR_DCSR_EBREAKVS_DEBUG_MODE 1
312 /*
313  * This bit is hardwired to 0 if the hart does not support virtualization mode.
314  */
315 #define CSR_DCSR_EBREAKVU_OFFSET 0x10ULL
316 #define CSR_DCSR_EBREAKVU_LENGTH 1ULL
317 #define CSR_DCSR_EBREAKVU 0x10000ULL
318 /*
319  * exception: `ebreak` instructions in VU-mode behave as described in the
320  * Privileged Spec.
321  */
322 #define CSR_DCSR_EBREAKVU_EXCEPTION 0
323 /*
324  * debug mode: `ebreak` instructions in VU-mode enter Debug Mode.
325  */
326 #define CSR_DCSR_EBREAKVU_DEBUG_MODE 1
327 /*
328  * This bit is hardwired to 0 if the hart does not support virtualization mode.
329  */
330 #define CSR_DCSR_EBREAKM_OFFSET 0xfULL
331 #define CSR_DCSR_EBREAKM_LENGTH 1ULL
332 #define CSR_DCSR_EBREAKM 0x8000ULL
333 /*
334  * exception: `ebreak` instructions in M-mode behave as described in the
335  * Privileged Spec.
336  */
337 #define CSR_DCSR_EBREAKM_EXCEPTION 0
338 /*
339  * debug mode: `ebreak` instructions in M-mode enter Debug Mode.
340  */
341 #define CSR_DCSR_EBREAKM_DEBUG_MODE 1
342 #define CSR_DCSR_EBREAKS_OFFSET 0xdULL
343 #define CSR_DCSR_EBREAKS_LENGTH 1ULL
344 #define CSR_DCSR_EBREAKS 0x2000ULL
345 /*
346  * exception: `ebreak` instructions in S-mode behave as described in the
347  * Privileged Spec.
348  */
349 #define CSR_DCSR_EBREAKS_EXCEPTION 0
350 /*
351  * debug mode: `ebreak` instructions in S-mode enter Debug Mode.
352  */
353 #define CSR_DCSR_EBREAKS_DEBUG_MODE 1
354 /*
355  * This bit is hardwired to 0 if the hart does not support S-mode.
356  */
357 #define CSR_DCSR_EBREAKU_OFFSET 0xcULL
358 #define CSR_DCSR_EBREAKU_LENGTH 1ULL
359 #define CSR_DCSR_EBREAKU 0x1000ULL
360 /*
361  * exception: `ebreak` instructions in U-mode behave as described in the
362  * Privileged Spec.
363  */
364 #define CSR_DCSR_EBREAKU_EXCEPTION 0
365 /*
366  * debug mode: `ebreak` instructions in U-mode enter Debug Mode.
367  */
368 #define CSR_DCSR_EBREAKU_DEBUG_MODE 1
369 /*
370  * This bit is hardwired to 0 if the hart does not support U-mode.
371  */
372 #define CSR_DCSR_STEPIE_OFFSET 0xbULL
373 #define CSR_DCSR_STEPIE_LENGTH 1ULL
374 #define CSR_DCSR_STEPIE 0x800ULL
375 /*
376  * interrupts disabled: Interrupts (including NMI) are disabled during single stepping
377  * with {dcsr-step} set.
378  * This value should be supported.
379  */
380 #define CSR_DCSR_STEPIE_INTERRUPTS_DISABLED 0
381 /*
382  * interrupts enabled: Interrupts (including NMI) are enabled during single stepping
383  * with {dcsr-step} set.
384  */
385 #define CSR_DCSR_STEPIE_INTERRUPTS_ENABLED 1
386 /*
387  * Implementations may hard wire this bit to 0.
388  * In that case interrupt behavior can be emulated by the debugger.
389  *
390  * The debugger must not change the value of this bit while the hart
391  * is running.
392  */
393 #define CSR_DCSR_STOPCOUNT_OFFSET 0xaULL
394 #define CSR_DCSR_STOPCOUNT_LENGTH 1ULL
395 #define CSR_DCSR_STOPCOUNT 0x400ULL
396 /*
397  * normal: Increment counters as usual.
398  */
399 #define CSR_DCSR_STOPCOUNT_NORMAL 0
400 /*
401  * freeze: Don't increment any hart-local counters while in Debug Mode or
402  * on `ebreak` instructions that cause entry into Debug Mode.
403  * These counters include the `instret` CSR. On single-hart cores
404  * `cycle` should be stopped, but on multi-hart cores it must keep
405  * incrementing.
406  */
407 #define CSR_DCSR_STOPCOUNT_FREEZE 1
408 /*
409  * An implementation may hardwire this bit to 0 or 1.
410  */
411 #define CSR_DCSR_STOPTIME_OFFSET 9ULL
412 #define CSR_DCSR_STOPTIME_LENGTH 1ULL
413 #define CSR_DCSR_STOPTIME 0x200ULL
414 /*
415  * normal: `time` continues to reflect `mtime`.
416  */
417 #define CSR_DCSR_STOPTIME_NORMAL 0
418 /*
419  * freeze: `time` is frozen at the time that Debug Mode was entered. When
420  * leaving Debug Mode, `time` will reflect the latest
421  * value of `mtime` again.
422  *
423  * While all harts have {dcsr-stoptime}=1 and are in Debug Mode,
424  * `mtime` is allowed to stop incrementing.
425  */
426 #define CSR_DCSR_STOPTIME_FREEZE 1
427 /*
428  * An implementation may hardwire this bit to 0 or 1.
429  */
430 /*
431  * Explains why Debug Mode was entered.
432  *
433  * When there are multiple reasons to enter Debug Mode in a single
434  * cycle, hardware should set {dcsr-cause} to the cause with the highest
435  * priority. See <<tab:dcsrcausepriority>> for priorities.
436  */
437 #define CSR_DCSR_CAUSE_OFFSET 6ULL
438 #define CSR_DCSR_CAUSE_LENGTH 3ULL
439 #define CSR_DCSR_CAUSE 0x1c0ULL
440 /*
441  * ebreak: An `ebreak` instruction was executed.
442  */
443 #define CSR_DCSR_CAUSE_EBREAK 1
444 /*
445  * trigger: A Trigger Module trigger fired with action=1.
446  */
447 #define CSR_DCSR_CAUSE_TRIGGER 2
448 /*
449  * haltreq: The debugger requested entry to Debug Mode using {dmcontrol-haltreq}.
450  */
451 #define CSR_DCSR_CAUSE_HALTREQ 3
452 /*
453  * step: The hart single stepped because {dcsr-step} was set.
454  */
455 #define CSR_DCSR_CAUSE_STEP 4
456 /*
457  * resethaltreq: The hart halted directly out of reset due to {resethaltreq} It
458  * is also acceptable to report 3 when this happens.
459  */
460 #define CSR_DCSR_CAUSE_RESETHALTREQ 5
461 /*
462  * group: The hart halted because it's part of a halt group.
463  * Harts may report 3 for this cause instead.
464  */
465 #define CSR_DCSR_CAUSE_GROUP 6
466 /*
467  * other: The hart halted for a reason other than the ones mentioned above.
468  * {dcsr-extcause} may contain a more specific reason.
469  */
470 #define CSR_DCSR_CAUSE_OTHER 7
471 /*
472  * Extends the prv field with the virtualization mode the hart was operating
473  * in when Debug Mode was entered. The encoding is described in <<tab:privmode>>.
474  * A debugger can change this value to change the hart's virtualization mode
475  * when exiting Debug Mode.
476  * This bit is hardwired to 0 on harts that do not support virtualization mode.
477  */
478 #define CSR_DCSR_V_OFFSET 5ULL
479 #define CSR_DCSR_V_LENGTH 1ULL
480 #define CSR_DCSR_V 0x20ULL
481 #define CSR_DCSR_MPRVEN_OFFSET 4ULL
482 #define CSR_DCSR_MPRVEN_LENGTH 1ULL
483 #define CSR_DCSR_MPRVEN 0x10ULL
484 /*
485  * disabled: `mprv` in `mstatus` is ignored in Debug Mode.
486  */
487 #define CSR_DCSR_MPRVEN_DISABLED 0
488 /*
489  * enabled: `mprv` in `mstatus` takes effect in Debug Mode.
490  */
491 #define CSR_DCSR_MPRVEN_ENABLED 1
492 /*
493  * Implementing this bit is optional. It may be tied to either 0 or 1.
494  */
495 /*
496  * When set, there is a Non-Maskable-Interrupt (NMI) pending for the hart.
497  *
498  * Since an NMI can indicate a hardware error condition,
499  * reliable debugging may no longer be possible once this bit becomes set.
500  * This is implementation-dependent.
501  */
502 #define CSR_DCSR_NMIP_OFFSET 3ULL
503 #define CSR_DCSR_NMIP_LENGTH 1ULL
504 #define CSR_DCSR_NMIP 8ULL
505 /*
506  * When set and not in Debug Mode, the hart will only execute a single
507  * instruction and then enter Debug Mode. See xref:stepbit[]
508  * for details.
509  *
510  * The debugger must not change the value of this bit while the hart
511  * is running.
512  */
513 #define CSR_DCSR_STEP_OFFSET 2ULL
514 #define CSR_DCSR_STEP_LENGTH 1ULL
515 #define CSR_DCSR_STEP 4ULL
516 /*
517  * Contains the privilege mode the hart was operating in when Debug
518  * Mode was entered. The encoding is described in <<tab:privmode>>. A debugger can change this value to change
519  * the hart's privilege mode when exiting Debug Mode.
520  *
521  * Not all privilege modes are supported on all harts. If the
522  * encoding written is not supported or the debugger is not allowed to
523  * change to it, the hart may change to any supported privilege mode.
524  */
525 #define CSR_DCSR_PRV_OFFSET 0ULL
526 #define CSR_DCSR_PRV_LENGTH 2ULL
527 #define CSR_DCSR_PRV 3ULL
528 #define CSR_DPC 0x7b1
529 #define CSR_DPC_DPC_OFFSET 0ULL
530 #define CSR_DPC_DPC_LENGTH(DXLEN) (DXLEN)
531 #define CSR_DPC_DPC(DXLEN) ((1ULL << (DXLEN)) + -1ULL)
532 #define CSR_DSCRATCH0 0x7b2
533 #define CSR_DSCRATCH0_DSCRATCH0_OFFSET 0ULL
534 #define CSR_DSCRATCH0_DSCRATCH0_LENGTH(DXLEN) (DXLEN)
535 #define CSR_DSCRATCH0_DSCRATCH0(DXLEN) ((1ULL << (DXLEN)) + -1ULL)
536 #define CSR_DSCRATCH1 0x7b3
537 #define CSR_DSCRATCH1_DSCRATCH1_OFFSET 0ULL
538 #define CSR_DSCRATCH1_DSCRATCH1_LENGTH(DXLEN) (DXLEN)
539 #define CSR_DSCRATCH1_DSCRATCH1(DXLEN) ((1ULL << (DXLEN)) + -1ULL)
540 #define CSR_TSELECT 0x7a0
541 #define CSR_TSELECT_INDEX_OFFSET 0ULL
542 #define CSR_TSELECT_INDEX_LENGTH(XLEN) (XLEN)
543 #define CSR_TSELECT_INDEX(XLEN) ((1ULL << (XLEN)) + -1ULL)
544 #define CSR_TDATA1 0x7a1
545 #define CSR_TDATA1_TYPE_OFFSET(XLEN) ((XLEN) + -4ULL)
546 #define CSR_TDATA1_TYPE_LENGTH 4ULL
547 #define CSR_TDATA1_TYPE(XLEN) (0xfULL * (1ULL << ((XLEN) + -4ULL)))
548 /*
549  * none: There is no trigger at this {csr-tselect}.
550  */
551 #define CSR_TDATA1_TYPE_NONE 0
552 /*
553  * legacy: The trigger is a legacy SiFive address match trigger. These
554  * should not be implemented and aren't further documented here.
555  */
556 #define CSR_TDATA1_TYPE_LEGACY 1
557 /*
558  * mcontrol: The trigger is an address/data match trigger. The remaining bits
559  * in this register act as described in {csr-mcontrol}.
560  */
561 #define CSR_TDATA1_TYPE_MCONTROL 2
562 /*
563  * icount: The trigger is an instruction count trigger. The remaining bits
564  * in this register act as described in {csr-icount}.
565  */
566 #define CSR_TDATA1_TYPE_ICOUNT 3
567 /*
568  * itrigger: The trigger is an interrupt trigger. The remaining bits
569  * in this register act as described in {csr-itrigger}.
570  */
571 #define CSR_TDATA1_TYPE_ITRIGGER 4
572 /*
573  * etrigger: The trigger is an exception trigger. The remaining bits
574  * in this register act as described in {csr-etrigger}.
575  */
576 #define CSR_TDATA1_TYPE_ETRIGGER 5
577 /*
578  * mcontrol6: The trigger is an address/data match trigger. The remaining bits
579  * in this register act as described in {csr-mcontrol6}. This is similar
580  * to a type 2 trigger, but provides additional functionality and
581  * should be used instead of type 2 in newer implementations.
582  */
583 #define CSR_TDATA1_TYPE_MCONTROL6 6
584 /*
585  * tmexttrigger: The trigger is a trigger source external to the TM. The
586  * remaining bits in this register act as described in {csr-tmexttrigger}.
587  */
588 #define CSR_TDATA1_TYPE_TMEXTTRIGGER 7
589 /*
590  * custom: These trigger types are available for non-standard use.
591  */
592 #define CSR_TDATA1_TYPE_CUSTOM_LOW 12
593 #define CSR_TDATA1_TYPE_CUSTOM_HIGH 14
594 /*
595  * disabled: This trigger is disabled. In this state, {csr-tdata2} and
596  * {csr-tdata3} can be written with any value that is supported for
597  * any of the types this trigger implements.
598  * The remaining bits in this register, except for {tdata1-dmode},
599  * are ignored.
600  */
601 #define CSR_TDATA1_TYPE_DISABLED 15
602 /*
603  * Other values are reserved for future use.
604  */
605 /*
606  * If {tdata1-type} is 0, then this bit is hard-wired to 0.
607  */
608 #define CSR_TDATA1_DMODE_OFFSET(XLEN) ((XLEN) + -5ULL)
609 #define CSR_TDATA1_DMODE_LENGTH 1ULL
610 #define CSR_TDATA1_DMODE(XLEN) (1ULL << ((XLEN) + -5ULL))
611 /*
612  * both: Both Debug and M-mode can write the `tdata` registers at the
613  * selected {csr-tselect}.
614  */
615 #define CSR_TDATA1_DMODE_BOTH 0
616 /*
617  * dmode: Only Debug Mode can write the `tdata` registers at the
618  * selected {csr-tselect}. Writes from other modes are ignored.
619  */
620 #define CSR_TDATA1_DMODE_DMODE 1
621 /*
622  * This bit is only writable from Debug Mode.
623  * In ordinary use, external debuggers will always set this bit when
624  * configuring a trigger.
625  * When clearing this bit, debuggers should also set the action field
626  * (whose location depends on {tdata1-type}) to something other
627  * than 1.
628  */
629 /*
630  * If {tdata1-type} is 0, then this field is hard-wired to 0.
631  *
632  * Trigger-specific data.
633  */
634 #define CSR_TDATA1_DATA_OFFSET 0ULL
635 #define CSR_TDATA1_DATA_LENGTH(XLEN) ((XLEN) + -5ULL)
636 #define CSR_TDATA1_DATA(XLEN) ((1ULL << ((XLEN) + -5ULL)) + -1ULL)
637 #define CSR_TDATA2 0x7a2
638 #define CSR_TDATA2_DATA_OFFSET 0ULL
639 #define CSR_TDATA2_DATA_LENGTH(XLEN) (XLEN)
640 #define CSR_TDATA2_DATA(XLEN) ((1ULL << (XLEN)) + -1ULL)
641 #define CSR_TDATA3 0x7a3
642 #define CSR_TDATA3_DATA_OFFSET 0ULL
643 #define CSR_TDATA3_DATA_LENGTH(XLEN) (XLEN)
644 #define CSR_TDATA3_DATA(XLEN) ((1ULL << (XLEN)) + -1ULL)
645 #define CSR_TINFO 0x7a4
646 /*
647  * Contains the version of the Sdtrig extension implemented.
648  */
649 #define CSR_TINFO_VERSION_OFFSET 0x18ULL
650 #define CSR_TINFO_VERSION_LENGTH 8ULL
651 #define CSR_TINFO_VERSION 0xff000000ULL
652 /*
653  * 0: Supports triggers as described in this spec at commit 5a5c078,
654  * made on February 2, 2023.
655  *
656  * In these older versions:
657  *
658  * . {csr-mcontrol6} has a timing bit identical to {mcontrol-timing}
659  * . {mcontrol6-hit0} behaves just as {mcontrol-hit}.
660  * . {mcontrol6-hit1} is read-only 0.
661  * . Encodings for {mcontrol6-size} for access sizes larger than 64 bits are different.
662  */
663 #define CSR_TINFO_VERSION_0 0
664 /*
665  * 1: Supports triggers as described in the ratified version 1.0 of
666  * this document.
667  */
668 #define CSR_TINFO_VERSION_1 1
669 /*
670  * One bit for each possible {tdata1-type} enumerated in {csr-tdata1}. Bit N
671  * corresponds to type N. If the bit is set, then that type is
672  * supported by the currently selected trigger.
673  *
674  * If the currently selected trigger doesn't exist, this field
675  * contains 1.
676  */
677 #define CSR_TINFO_INFO_OFFSET 0ULL
678 #define CSR_TINFO_INFO_LENGTH 0x10ULL
679 #define CSR_TINFO_INFO 0xffffULL
680 #define CSR_TCONTROL 0x7a5
681 /*
682  * M-mode previous trigger enable field.
683  *
684  * {tcontrol-mpte} and {tcontrol-mte} provide one solution to a problem
685  * regarding triggers with action=0 firing in M-mode trap handlers. See
686  * xref:nativetrigger[] for more details.
687  *
688  * When any trap into M-mode is taken, {tcontrol-mpte} is set to the value of
689  * {tcontrol-mte}.
690  */
691 #define CSR_TCONTROL_MPTE_OFFSET 7ULL
692 #define CSR_TCONTROL_MPTE_LENGTH 1ULL
693 #define CSR_TCONTROL_MPTE 0x80ULL
694 /*
695  * M-mode trigger enable field.
696  */
697 #define CSR_TCONTROL_MTE_OFFSET 3ULL
698 #define CSR_TCONTROL_MTE_LENGTH 1ULL
699 #define CSR_TCONTROL_MTE 8ULL
700 /*
701  * disabled: Triggers with action=0 do not match/fire while the hart is in M-mode.
702  */
703 #define CSR_TCONTROL_MTE_DISABLED 0
704 /*
705  * enabled: Triggers do match/fire while the hart is in M-mode.
706  */
707 #define CSR_TCONTROL_MTE_ENABLED 1
708 /*
709  * When any trap into M-mode is taken, {tcontrol-mte} is set to 0. When `mret` is executed, {tcontrol-mte} is set to the value of {tcontrol-mpte}.
710  */
711 #define CSR_HCONTEXT 0x6a8
712 #define CSR_SCONTEXT 0x5a8
713 /*
714  * Supervisor mode software can write a context number to this
715  * register, which can be used to set triggers that only fire in that
716  * specific context.
717  *
718  * An implementation may tie any number of high bits in this field to
719  * 0. It's recommended to implement 16 bits on RV32 and 32 bits on
720  * RV64.
721  */
722 #define CSR_SCONTEXT_DATA_OFFSET 0ULL
723 #define CSR_SCONTEXT_DATA_LENGTH 0x20ULL
724 #define CSR_SCONTEXT_DATA 0xffffffffULL
725 #define CSR_MCONTEXT 0x7a8
726 /*
727  * M-Mode or HS-Mode (using {csr-hcontext}) software can write a context
728  * number to this register, which can be used to set triggers that only
729  * fire in that specific context.
730  *
731  * An implementation may tie any number of upper bits in this field to
732  * 0. If the H extension is not implemented, it's recommended to implement
733  * 6 bits on RV32 and 13 bits on RV64 (as visible through the
734  * {csr-mcontext} register). If the H extension is implemented,
735  * it's recommended to implement 7 bits on RV32
736  * and 14 bits on RV64.
737  */
738 #define CSR_MCONTEXT_HCONTEXT_OFFSET 0ULL
739 #define CSR_MCONTEXT_HCONTEXT_LENGTH 0xeULL
740 #define CSR_MCONTEXT_HCONTEXT 0x3fffULL
741 #define CSR_MSCONTEXT 0x7aa
742 #define CSR_MCONTROL 0x7a1
743 #define CSR_MCONTROL_TYPE_OFFSET(XLEN) ((XLEN) + -4ULL)
744 #define CSR_MCONTROL_TYPE_LENGTH 4ULL
745 #define CSR_MCONTROL_TYPE(XLEN) (0xfULL * (1ULL << ((XLEN) + -4ULL)))
746 #define CSR_MCONTROL_DMODE_OFFSET(XLEN) ((XLEN) + -5ULL)
747 #define CSR_MCONTROL_DMODE_LENGTH 1ULL
748 #define CSR_MCONTROL_DMODE(XLEN) (1ULL << ((XLEN) + -5ULL))
749 /*
750  * Specifies the largest naturally aligned powers-of-two (NAPOT) range
751  * supported by the hardware when {mcontrol-match} is 1. The value is the
752  * logarithm base 2 of the number of bytes in that range.
753  * A value of 0 indicates {mcontrol-match} 1 is not supported.
754  * A value of 63 corresponds to the maximum NAPOT range, which is
755  * 2^63^ bytes in size.
756  */
757 #define CSR_MCONTROL_MASKMAX_OFFSET(XLEN) ((XLEN) + -0xbULL)
758 #define CSR_MCONTROL_MASKMAX_LENGTH 6ULL
759 #define CSR_MCONTROL_MASKMAX(XLEN) (0x3fULL * (1ULL << ((XLEN) + -0xbULL)))
760 /*
761  * This field only exists when XLEN is at least 64.
762  * It contains the 2 high bits of the access size. The low bits
763  * come from {mcontrol-sizelo}. See {mcontrol-sizelo} for how this
764  * is used.
765  */
766 #define CSR_MCONTROL_SIZEHI_OFFSET 0x15ULL
767 #define CSR_MCONTROL_SIZEHI_LENGTH 2ULL
768 #define CSR_MCONTROL_SIZEHI 0x600000ULL
769 /*
770  * If this bit is implemented then it must become set when this
771  * trigger fires and may become set when this trigger matches.
772  * The trigger's user can set or clear it at any
773  * time. It is used to determine which
774  * trigger(s) matched. If the bit is not implemented, it is always 0
775  * and writing it has no effect.
776  */
777 #define CSR_MCONTROL_HIT_OFFSET 0x14ULL
778 #define CSR_MCONTROL_HIT_LENGTH 1ULL
779 #define CSR_MCONTROL_HIT 0x100000ULL
780 /*
781  * This bit determines the contents of the XLEN-bit compare values.
782  */
783 #define CSR_MCONTROL_SELECT_OFFSET 0x13ULL
784 #define CSR_MCONTROL_SELECT_LENGTH 1ULL
785 #define CSR_MCONTROL_SELECT 0x80000ULL
786 /*
787  * address: There is at least one compare value and it contains the lowest
788  * virtual address of the access.
789  * It is recommended that there are additional compare values for
790  * the other accessed virtual addresses.
791  * (E.g. on a 32-bit read from 0x4000, the lowest address is 0x4000
792  * and the other addresses are 0x4001, 0x4002, and 0x4003.)
793  */
794 #define CSR_MCONTROL_SELECT_ADDRESS 0
795 /*
796  * data: There is exactly one compare value and it contains the data
797  * value loaded or stored, or the instruction executed.
798  * Any bits beyond the size of the data access will contain 0.
799  */
800 #define CSR_MCONTROL_SELECT_DATA 1
801 #define CSR_MCONTROL_TIMING_OFFSET 0x12ULL
802 #define CSR_MCONTROL_TIMING_LENGTH 1ULL
803 #define CSR_MCONTROL_TIMING 0x40000ULL
804 /*
805  * before: The action for this trigger will be taken just before the
806  * instruction that triggered it is retired, but after all preceding
807  * instructions are retired. `xepc` or {csr-dpc} (depending
808  * on {mcontrol-action}) must be set to the virtual address of the
809  * instruction that matched.
810  *
811  * If this is combined with {mcontrol-load} and
812  * {mcontrol-select}=1 then a memory access will be
813  * performed (including any side effects of performing such an access) even
814  * though the load will not update its destination register. Debuggers
815  * should consider this when setting such breakpoints on, for example,
816  * memory-mapped I/O addresses.
817  *
818  * If an instruction matches this trigger and the instruction performs
819  * multiple memory accesses, it is UNSPECIFIED which memory accesses
820  * have completed before the trigger fires.
821  */
822 #define CSR_MCONTROL_TIMING_BEFORE 0
823 /*
824  * after: The action for this trigger will be taken after the instruction
825  * that triggered it is retired. It should be taken before the next
826  * instruction is retired, but it is better to implement triggers imprecisely
827  * than to not implement them at all. `xepc` or
828  * {csr-dpc} (depending on {mcontrol-action}) must be set to
829  * the virtual address of the next instruction that must be executed to
830  * preserve the program flow.
831  */
832 #define CSR_MCONTROL_TIMING_AFTER 1
833 /*
834  * Most hardware will only implement one timing or the other, possibly
835  * dependent on {mcontrol-select}, {mcontrol-execute},
836  * {mcontrol-load}, and {mcontrol-store}. This bit
837  * primarily exists for the hardware to communicate to the debugger
838  * what will happen. Hardware may implement the bit fully writable, in
839  * which case the debugger has a little more control.
840  *
841  * Data load triggers with {mcontrol-timing} of 0 will result in the same load
842  * happening again when the debugger lets the hart run. For data load
843  * triggers, debuggers must first attempt to set the breakpoint with
844  * {mcontrol-timing} of 1.
845  *
846  * If a trigger with {mcontrol-timing} of 0 matches, it is
847  * implementation-dependent whether that prevents a trigger with
848  * {mcontrol-timing} of 1 matching as well.
849  */
850 /*
851  * This field contains the 2 low bits of the access size. The high bits come
852  * from {mcontrol-sizehi}. The combined value is interpreted as follows:
853  */
854 #define CSR_MCONTROL_SIZELO_OFFSET 0x10ULL
855 #define CSR_MCONTROL_SIZELO_LENGTH 2ULL
856 #define CSR_MCONTROL_SIZELO 0x30000ULL
857 /*
858  * any: The trigger will attempt to match against an access of any size.
859  * The behavior is only well-defined if {mcontrol-select}=0, or if the access
860  * size is XLEN.
861  */
862 #define CSR_MCONTROL_SIZELO_ANY 0
863 /*
864  * 8bit: The trigger will only match against 8-bit memory accesses.
865  */
866 #define CSR_MCONTROL_SIZELO_8BIT 1
867 /*
868  * 16bit: The trigger will only match against 16-bit memory accesses or
869  * execution of 16-bit instructions.
870  */
871 #define CSR_MCONTROL_SIZELO_16BIT 2
872 /*
873  * 32bit: The trigger will only match against 32-bit memory accesses or
874  * execution of 32-bit instructions.
875  */
876 #define CSR_MCONTROL_SIZELO_32BIT 3
877 /*
878  * 48bit: The trigger will only match against execution of 48-bit instructions.
879  */
880 #define CSR_MCONTROL_SIZELO_48BIT 4
881 /*
882  * 64bit: The trigger will only match against 64-bit memory accesses or
883  * execution of 64-bit instructions.
884  */
885 #define CSR_MCONTROL_SIZELO_64BIT 5
886 /*
887  * 80bit: The trigger will only match against execution of 80-bit instructions.
888  */
889 #define CSR_MCONTROL_SIZELO_80BIT 6
890 /*
891  * 96bit: The trigger will only match against execution of 96-bit instructions.
892  */
893 #define CSR_MCONTROL_SIZELO_96BIT 7
894 /*
895  * 112bit: The trigger will only match against execution of 112-bit instructions.
896  */
897 #define CSR_MCONTROL_SIZELO_112BIT 8
898 /*
899  * 128bit: The trigger will only match against 128-bit memory accesses or
900  * execution of 128-bit instructions.
901  */
902 #define CSR_MCONTROL_SIZELO_128BIT 9
903 /*
904  * An implementation must support the value of 0, but all other values
905  * are optional. When an implementation supports address triggers
906  * ({mcontrol-select}=0), it is recommended that those triggers
907  * support every access size that the hart supports, as well as for
908  * every instruction size that the hart supports.
909  *
910  * Implementations such as RV32D or RV64V are able to perform loads
911  * and stores that are wider than XLEN. Custom extensions may also
912  * support instructions that are wider than XLEN. Because
913  * {csr-tdata2} is of size XLEN, there is a known limitation that
914  * data value triggers ({mcontrol-select}=1) can only be supported
915  * for access sizes up to XLEN bits. When an implementation supports
916  * data value triggers ({mcontrol-select}=1), it is recommended
917  * that those triggers support every access size up to XLEN that the
918  * hart supports, as well as for every instruction length up to XLEN
919  * that the hart supports.
920  */
921 /*
922  * The action to take when the trigger fires. The values are explained
923  * in xref:tab:action[].
924  */
925 #define CSR_MCONTROL_ACTION_OFFSET 0xcULL
926 #define CSR_MCONTROL_ACTION_LENGTH 4ULL
927 #define CSR_MCONTROL_ACTION 0xf000ULL
928 /*
929  * breakpoint:
930  */
931 #define CSR_MCONTROL_ACTION_BREAKPOINT 0
932 /*
933  * debug mode:
934  */
935 #define CSR_MCONTROL_ACTION_DEBUG_MODE 1
936 /*
937  * trace on:
938  */
939 #define CSR_MCONTROL_ACTION_TRACE_ON 2
940 /*
941  * trace off:
942  */
943 #define CSR_MCONTROL_ACTION_TRACE_OFF 3
944 /*
945  * trace notify:
946  */
947 #define CSR_MCONTROL_ACTION_TRACE_NOTIFY 4
948 /*
949  * external0:
950  */
951 #define CSR_MCONTROL_ACTION_EXTERNAL0 8
952 /*
953  * external1:
954  */
955 #define CSR_MCONTROL_ACTION_EXTERNAL1 9
956 #define CSR_MCONTROL_CHAIN_OFFSET 0xbULL
957 #define CSR_MCONTROL_CHAIN_LENGTH 1ULL
958 #define CSR_MCONTROL_CHAIN 0x800ULL
959 /*
960  * disabled: When this trigger matches, the configured action is taken.
961  */
962 #define CSR_MCONTROL_CHAIN_DISABLED 0
963 /*
964  * enabled: While this trigger does not match, it prevents the trigger with
965  * the next index from matching.
966  */
967 #define CSR_MCONTROL_CHAIN_ENABLED 1
968 /*
969  * A trigger chain starts on the first trigger with `chain`=1 after
970  * a trigger with `chain`=0, or simply on the first trigger if that
971  * has `chain`=1. It ends on the first trigger after that which has
972  * `chain`=0. This final trigger is part of the chain. The action
973  * on all but the final trigger is ignored. The action on that final
974  * trigger will be taken if and only if all the triggers in the chain
975  * match at the same time.
976  *
977  * Debuggers should not terminate a chain with a trigger with a
978  * different type. It is undefined when exactly such a chain fires.
979  *
980  * Because {mcontrol-chain} affects the next trigger, hardware must zero it in
981  * writes to {csr-mcontrol} that set {tdata1-dmode} to 0 if the next trigger has
982  * {tdata1-dmode} of 1.
983  * In addition hardware should ignore writes to {csr-mcontrol} that set
984  * {tdata1-dmode} to 1 if the previous trigger has both {tdata1-dmode} of 0 and
985  * {mcontrol-chain} of 1. Debuggers must avoid the latter case by checking
986  * {mcontrol-chain} on the previous trigger if they're writing {csr-mcontrol}.
987  *
988  * Implementations that wish to limit the maximum length of a trigger
989  * chain (eg. to meet timing requirements) may do so by zeroing
990  * {mcontrol-chain} in writes to {csr-mcontrol} that would make the chain too long.
991  */
992 #define CSR_MCONTROL_MATCH_OFFSET 7ULL
993 #define CSR_MCONTROL_MATCH_LENGTH 4ULL
994 #define CSR_MCONTROL_MATCH 0x780ULL
995 /*
996  * equal: Matches when any compare value equals {csr-tdata2}.
997  */
998 #define CSR_MCONTROL_MATCH_EQUAL 0
999 /*
1000  * napot: Matches when the top `M` bits of any compare value match the top
1001  * `M` bits of {csr-tdata2}.
1002  * `M` is `XLEN-1` minus the index of the least-significant
1003  * bit containing 0 in {csr-tdata2}. Debuggers should only write values
1004  * to {csr-tdata2} such that `M` + {mcontrol-maskmax} ≥ `XLEN`
1005  * and `M` > 0, otherwise it's undefined on what conditions the
1006  * trigger will match.
1007  */
1008 #define CSR_MCONTROL_MATCH_NAPOT 1
1009 /*
1010  * ge: Matches when any compare value is greater than (unsigned) or
1011  * equal to {csr-tdata2}.
1012  */
1013 #define CSR_MCONTROL_MATCH_GE 2
1014 /*
1015  * lt: Matches when any compare value is less than (unsigned)
1016  * {csr-tdata2}.
1017  */
1018 #define CSR_MCONTROL_MATCH_LT 3
1019 /*
1020  * mask low: Matches when latexmath:[$\frac{XLEN}{2}-{1:0}] of any compare value
1021  * equals latexmath:[$\frac{XLEN}{2}-{1:0}] of {csr-tdata2} after
1022  * latexmath:[$\frac{XLEN}{2}-{1:0}] of the compare value is ANDed with
1023  * `XLEN-1`:latexmath:[$\frac{XLEN}{2}$] of {csr-tdata2}.
1024  */
1025 #define CSR_MCONTROL_MATCH_MASK_LOW 4
1026 /*
1027  * mask high: Matches when `XLEN-1`:latexmath:[$\frac{XLEN}{2}$] of any compare
1028  * value equals latexmath:[$\frac{XLEN}{2}-{1:0}] of {csr-tdata2} after
1029  * `XLEN-1`:latexmath:[$\frac{XLEN}{2}$] of the compare value is ANDed with
1030  * `XLEN-1`:latexmath:[$\frac{XLEN}{2}$] of {csr-tdata2}.
1031  */
1032 #define CSR_MCONTROL_MATCH_MASK_HIGH 5
1033 /*
1034  * not equal: Matches when {mcontrol-match}=0 would not match.
1035  */
1036 #define CSR_MCONTROL_MATCH_NOT_EQUAL 8
1037 /*
1038  * not napot: Matches when {mcontrol-match}=1 would not match.
1039  */
1040 #define CSR_MCONTROL_MATCH_NOT_NAPOT 9
1041 /*
1042  * not mask low: Matches when {mcontrol-match}=4 would not match.
1043  */
1044 #define CSR_MCONTROL_MATCH_NOT_MASK_LOW 12
1045 /*
1046  * not mask high: Matches when {mcontrol-match}=5 would not match.
1047  */
1048 #define CSR_MCONTROL_MATCH_NOT_MASK_HIGH 13
1049 /*
1050  * Other values are reserved for future use.
1051  *
1052  * All comparisons only look at the lower XLEN (in the current mode)
1053  * bits of the compare values and of {csr-tdata2}.
1054  * When {mcontrol-select}=1 and access size is N, this is further
1055  * reduced, and comparisons only look at the lower N bits of the
1056  * compare values and of {csr-tdata2}.
1057  */
1058 /*
1059  * When set, enable this trigger in M-mode.
1060  */
1061 #define CSR_MCONTROL_M_OFFSET 6ULL
1062 #define CSR_MCONTROL_M_LENGTH 1ULL
1063 #define CSR_MCONTROL_M 0x40ULL
1064 /*
1065  * When set, enable this trigger in S/HS-mode.
1066  * This bit is hard-wired to 0 if the hart does not support
1067  * S-mode.
1068  */
1069 #define CSR_MCONTROL_S_OFFSET 4ULL
1070 #define CSR_MCONTROL_S_LENGTH 1ULL
1071 #define CSR_MCONTROL_S 0x10ULL
1072 /*
1073  * When set, enable this trigger in U-mode.
1074  * This bit is hard-wired to 0 if the hart does not support
1075  * U-mode.
1076  */
1077 #define CSR_MCONTROL_U_OFFSET 3ULL
1078 #define CSR_MCONTROL_U_LENGTH 1ULL
1079 #define CSR_MCONTROL_U 8ULL
1080 /*
1081  * When set, the trigger fires on the virtual address or opcode of an
1082  * instruction that is executed.
1083  */
1084 #define CSR_MCONTROL_EXECUTE_OFFSET 2ULL
1085 #define CSR_MCONTROL_EXECUTE_LENGTH 1ULL
1086 #define CSR_MCONTROL_EXECUTE 4ULL
1087 /*
1088  * When set, the trigger fires on the virtual address or data of any
1089  * store.
1090  */
1091 #define CSR_MCONTROL_STORE_OFFSET 1ULL
1092 #define CSR_MCONTROL_STORE_LENGTH 1ULL
1093 #define CSR_MCONTROL_STORE 2ULL
1094 /*
1095  * When set, the trigger fires on the virtual address or data of any
1096  * load.
1097  */
1098 #define CSR_MCONTROL_LOAD_OFFSET 0ULL
1099 #define CSR_MCONTROL_LOAD_LENGTH 1ULL
1100 #define CSR_MCONTROL_LOAD 1ULL
1101 #define CSR_MCONTROL6 0x7a1
1102 #define CSR_MCONTROL6_TYPE_OFFSET(XLEN) ((XLEN) + -4ULL)
1103 #define CSR_MCONTROL6_TYPE_LENGTH 4ULL
1104 #define CSR_MCONTROL6_TYPE(XLEN) (0xfULL * (1ULL << ((XLEN) + -4ULL)))
1105 #define CSR_MCONTROL6_DMODE_OFFSET(XLEN) ((XLEN) + -5ULL)
1106 #define CSR_MCONTROL6_DMODE_LENGTH 1ULL
1107 #define CSR_MCONTROL6_DMODE(XLEN) (1ULL << ((XLEN) + -5ULL))
1108 /*
1109  * If implemented, the TM updates this field every time the trigger
1110  * fires.
1111  */
1112 #define CSR_MCONTROL6_UNCERTAIN_OFFSET 0x1aULL
1113 #define CSR_MCONTROL6_UNCERTAIN_LENGTH 1ULL
1114 #define CSR_MCONTROL6_UNCERTAIN 0x4000000ULL
1115 /*
1116  * certain: The trigger that fired satisfied the configured conditions, or
1117  * this bit is not implemented.
1118  */
1119 #define CSR_MCONTROL6_UNCERTAIN_CERTAIN 0
1120 /*
1121  * uncertain: The trigger that fired might not have perfectly satisfied the
1122  * configured conditions. Due to the implementation the hardware
1123  * cannot be certain.
1124  */
1125 #define CSR_MCONTROL6_UNCERTAIN_UNCERTAIN 1
1126 #define CSR_MCONTROL6_HIT1_OFFSET 0x19ULL
1127 #define CSR_MCONTROL6_HIT1_LENGTH 1ULL
1128 #define CSR_MCONTROL6_HIT1 0x2000000ULL
1129 /*
1130  * When set, enable this trigger in VS-mode.
1131  * This bit is hard-wired to 0 if the hart does not support
1132  * virtualization mode.
1133  */
1134 #define CSR_MCONTROL6_VS_OFFSET 0x18ULL
1135 #define CSR_MCONTROL6_VS_LENGTH 1ULL
1136 #define CSR_MCONTROL6_VS 0x1000000ULL
1137 /*
1138  * When set, enable this trigger in VU-mode.
1139  * This bit is hard-wired to 0 if the hart does not support
1140  * virtualization mode.
1141  */
1142 #define CSR_MCONTROL6_VU_OFFSET 0x17ULL
1143 #define CSR_MCONTROL6_VU_LENGTH 1ULL
1144 #define CSR_MCONTROL6_VU 0x800000ULL
1145 /*
1146  * If they are implemented, {mcontrol6-hit1} (MSB) and
1147  * {mcontrol6-hit0} (LSB) combine into a single 2-bit field.
1148  * The TM updates this field when the trigger fires. After the debugger
1149  * has seen the update, it will normally write 0 to this field to so it
1150  * can see future changes.
1151  *
1152  * If either of the bits is not implemented, the unimplemented bits
1153  * will be read-only 0.
1154  */
1155 #define CSR_MCONTROL6_HIT0_OFFSET 0x16ULL
1156 #define CSR_MCONTROL6_HIT0_LENGTH 1ULL
1157 #define CSR_MCONTROL6_HIT0 0x400000ULL
1158 /*
1159  * false: The trigger did not fire.
1160  */
1161 #define CSR_MCONTROL6_HIT0_FALSE 0
1162 /*
1163  * before: The trigger fired before the instruction that matched it was
1164  * retired, but after all preceding instructions are retired. This
1165  * explicitly allows for instructions to be partially executed, as
1166  * described in xref:multistate[].
1167  *
1168  * `xepc` or {csr-dpc} (depending on {mcontrol6-action}) must be set
1169  * to the virtual address of the instruction that matched.
1170  */
1171 #define CSR_MCONTROL6_HIT0_BEFORE 1
1172 /*
1173  * after: The trigger fired after the instruction that triggered and at least
1174  * one additional instruction were retired.
1175  * `xepc` or {csr-dpc} (depending on {mcontrol6-action}) must be set
1176  * to the virtual address of the next instruction that must be executed
1177  * to preserve the program flow.
1178  */
1179 #define CSR_MCONTROL6_HIT0_AFTER 2
1180 /*
1181  * immediately after: The trigger fired just after the instruction that triggered it was
1182  * retired, but before any subsequent instructions were executed.
1183  * `xepc` or {csr-dpc} (depending on {mcontrol6-action}) must be set
1184  * to the virtual address of the next instruction that must be executed
1185  * to preserve the program flow.
1186  *
1187  * If the instruction performed multiple memory accesses, all of them
1188  * have been completed.
1189  */
1190 #define CSR_MCONTROL6_HIT0_IMMEDIATELY_AFTER 3
1191 /*
1192  * This bit determines the contents of the XLEN-bit compare values.
1193  */
1194 #define CSR_MCONTROL6_SELECT_OFFSET 0x15ULL
1195 #define CSR_MCONTROL6_SELECT_LENGTH 1ULL
1196 #define CSR_MCONTROL6_SELECT 0x200000ULL
1197 /*
1198  * address: There is at least one compare value and it contains the lowest
1199  * virtual address of the access.
1200  * In addition, it is recommended that there are additional compare
1201  * values for the other accessed virtual addresses match.
1202  * (E.g. on a 32-bit read from 0x4000, the lowest address is 0x4000
1203  * and the other addresses are 0x4001, 0x4002, and 0x4003.)
1204  */
1205 #define CSR_MCONTROL6_SELECT_ADDRESS 0
1206 /*
1207  * data: There is exactly one compare value and it contains the data
1208  * value loaded or stored, or the instruction executed.
1209  * Any bits beyond the size of the data access will contain 0.
1210  */
1211 #define CSR_MCONTROL6_SELECT_DATA 1
1212 #define CSR_MCONTROL6_SIZE_OFFSET 0x10ULL
1213 #define CSR_MCONTROL6_SIZE_LENGTH 3ULL
1214 #define CSR_MCONTROL6_SIZE 0x70000ULL
1215 /*
1216  * any: The trigger will attempt to match against an access of any size.
1217  * The behavior is only well-defined if {mcontrol6-select}=0, or if the
1218  * access size is XLEN.
1219  */
1220 #define CSR_MCONTROL6_SIZE_ANY 0
1221 /*
1222  * 8bit: The trigger will only match against 8-bit memory accesses.
1223  */
1224 #define CSR_MCONTROL6_SIZE_8BIT 1
1225 /*
1226  * 16bit: The trigger will only match against 16-bit memory accesses or
1227  * execution of 16-bit instructions.
1228  */
1229 #define CSR_MCONTROL6_SIZE_16BIT 2
1230 /*
1231  * 32bit: The trigger will only match against 32-bit memory accesses or
1232  * execution of 32-bit instructions.
1233  */
1234 #define CSR_MCONTROL6_SIZE_32BIT 3
1235 /*
1236  * 48bit: The trigger will only match against execution of 48-bit instructions.
1237  */
1238 #define CSR_MCONTROL6_SIZE_48BIT 4
1239 /*
1240  * 64bit: The trigger will only match against 64-bit memory accesses or
1241  * execution of 64-bit instructions.
1242  */
1243 #define CSR_MCONTROL6_SIZE_64BIT 5
1244 /*
1245  * 128bit: The trigger will only match against 128-bit memory accesses or
1246  * execution of 128-bit instructions.
1247  */
1248 #define CSR_MCONTROL6_SIZE_128BIT 6
1249 /*
1250  * An implementation must support the value of 0, but all other values
1251  * are optional. When an implementation supports address triggers
1252  * ({mcontrol6-select}=0), it is recommended that those triggers
1253  * support every access size that the hart supports, as well as for
1254  * every instruction size that the hart supports.
1255  *
1256  * Implementations such as RV32D or RV64V are able to perform loads
1257  * and stores that are wider than XLEN. Custom extensions may also
1258  * support instructions that are wider than XLEN. Because
1259  * {csr-tdata2} is of size XLEN, there is a known limitation that
1260  * data value triggers ({mcontrol6-select}=1) can only be supported
1261  * for access sizes up to XLEN bits. When an implementation supports
1262  * data value triggers ({mcontrol6-select}=1), it is recommended
1263  * that those triggers support every access size up to XLEN that the
1264  * hart supports, as well as for every instruction length up to XLEN
1265  * that the hart supports.
1266  */
1267 /*
1268  * The action to take when the trigger fires. The values are explained
1269  * in xref:tab:action[].
1270  */
1271 #define CSR_MCONTROL6_ACTION_OFFSET 0xcULL
1272 #define CSR_MCONTROL6_ACTION_LENGTH 4ULL
1273 #define CSR_MCONTROL6_ACTION 0xf000ULL
1274 /*
1275  * breakpoint:
1276  */
1277 #define CSR_MCONTROL6_ACTION_BREAKPOINT 0
1278 /*
1279  * debug mode:
1280  */
1281 #define CSR_MCONTROL6_ACTION_DEBUG_MODE 1
1282 /*
1283  * trace on:
1284  */
1285 #define CSR_MCONTROL6_ACTION_TRACE_ON 2
1286 /*
1287  * trace off:
1288  */
1289 #define CSR_MCONTROL6_ACTION_TRACE_OFF 3
1290 /*
1291  * trace notify:
1292  */
1293 #define CSR_MCONTROL6_ACTION_TRACE_NOTIFY 4
1294 /*
1295  * external0:
1296  */
1297 #define CSR_MCONTROL6_ACTION_EXTERNAL0 8
1298 /*
1299  * external1:
1300  */
1301 #define CSR_MCONTROL6_ACTION_EXTERNAL1 9
1302 #define CSR_MCONTROL6_CHAIN_OFFSET 0xbULL
1303 #define CSR_MCONTROL6_CHAIN_LENGTH 1ULL
1304 #define CSR_MCONTROL6_CHAIN 0x800ULL
1305 /*
1306  * disabled: When this trigger matches, the configured action is taken.
1307  */
1308 #define CSR_MCONTROL6_CHAIN_DISABLED 0
1309 /*
1310  * enabled: While this trigger does not match, it prevents the trigger with
1311  * the next index from matching.
1312  */
1313 #define CSR_MCONTROL6_CHAIN_ENABLED 1
1314 /*
1315  * A trigger chain starts on the first trigger with `chain`=1 after
1316  * a trigger with `chain`=0, or simply on the first trigger if that
1317  * has `chain`=1. It ends on the first trigger after that which has
1318  * `chain`=0. This final trigger is part of the chain. The action
1319  * on all but the final trigger is ignored. The action on that final
1320  * trigger will be taken if and only if all the triggers in the chain
1321  * match at the same time.
1322  *
1323  * Debuggers should not terminate a chain with a trigger with a
1324  * different type. It is undefined when exactly such a chain fires.
1325  *
1326  * Because {mcontrol6-chain} affects the next trigger, hardware must zero it in
1327  * writes to {csr-mcontrol6} that set {tdata1-dmode} to 0 if the next trigger has
1328  * {tdata1-dmode} of 1.
1329  * In addition hardware should ignore writes to {csr-mcontrol6} that set
1330  * {tdata1-dmode} to 1 if the previous trigger has both {tdata1-dmode} of 0 and
1331  * {mcontrol6-chain} of 1. Debuggers must avoid the latter case by checking
1332  * {mcontrol6-chain} on the previous trigger if they're writing {csr-mcontrol6}.
1333  *
1334  * Implementations that wish to limit the maximum length of a trigger
1335  * chain (eg. to meet timing requirements) may do so by zeroing
1336  * {mcontrol6-chain} in writes to {csr-mcontrol6} that would make the chain too long.
1337  */
1338 #define CSR_MCONTROL6_MATCH_OFFSET 7ULL
1339 #define CSR_MCONTROL6_MATCH_LENGTH 4ULL
1340 #define CSR_MCONTROL6_MATCH 0x780ULL
1341 /*
1342  * equal: Matches when any compare value equals {csr-tdata2}.
1343  */
1344 #define CSR_MCONTROL6_MATCH_EQUAL 0
1345 /*
1346  * napot: Matches when the top `M` bits of any compare value match the top
1347  * `M` bits of {csr-tdata2}.
1348  * `M` is `XLEN-1` minus the index of the least-significant bit
1349  * containing 0 in {csr-tdata2}.
1350  * {csr-tdata2} is *WARL* and if bits `maskmax6-1:0` are written with all
1351  * ones then bit `maskmax6-1` will be set to 0 while the values of bits `maskmax6-2:0`
1352  * are UNSPECIFIED.
1353  * Legal values for {csr-tdata2} require M + `maskmax6` ≥ `XLEN` and `M` > 0.
1354  * See above for how to determine maskmax6.
1355  */
1356 #define CSR_MCONTROL6_MATCH_NAPOT 1
1357 /*
1358  * ge: Matches when any compare value is greater than (unsigned) or
1359  * equal to {csr-tdata2}.
1360  */
1361 #define CSR_MCONTROL6_MATCH_GE 2
1362 /*
1363  * lt: Matches when any compare value is less than (unsigned)
1364  * {csr-tdata2}.
1365  */
1366 #define CSR_MCONTROL6_MATCH_LT 3
1367 /*
1368  * mask low: Matches when latexmath:[$\frac{XLEN}{2}-{1:0}] of any compare value
1369  * equals latexmath:[$\frac{XLEN}{2}-{1:0}] of {csr-tdata2} after
1370  * latexmath:[$\frac{XLEN}{2}-{1:0}] of the compare value is ANDed with
1371  * `XLEN-1`:latexmath:[$\frac{XLEN}{2}$] of {csr-tdata2}.
1372  */
1373 #define CSR_MCONTROL6_MATCH_MASK_LOW 4
1374 /*
1375  * mask high: Matches when `XLEN-1`:latexmath:[$\frac{XLEN}{2}$] of any compare
1376  * value equals latexmath:[$\frac{XLEN}{2}-{1:0}] of {csr-tdata2} after
1377  * `XLEN-1`:latexmath:[$\frac{XLEN}{2}$] of the compare value is ANDed with
1378  * `XLEN-1`:latexmath:[$\frac{XLEN}{2}$] of {csr-tdata2}.
1379  */
1380 #define CSR_MCONTROL6_MATCH_MASK_HIGH 5
1381 /*
1382  * not equal: Matches when {mcontrol6-match} `=0` would not match.
1383  */
1384 #define CSR_MCONTROL6_MATCH_NOT_EQUAL 8
1385 /*
1386  * not napot: Matches when {mcontrol6-match} `=1` would not match.
1387  */
1388 #define CSR_MCONTROL6_MATCH_NOT_NAPOT 9
1389 /*
1390  * not mask low: Matches when {mcontrol6-match} `=4` would not match.
1391  */
1392 #define CSR_MCONTROL6_MATCH_NOT_MASK_LOW 12
1393 /*
1394  * not mask high: Matches when {mcontrol6-match} `=5` would not match.
1395  */
1396 #define CSR_MCONTROL6_MATCH_NOT_MASK_HIGH 13
1397 /*
1398  * Other values are reserved for future use.
1399  *
1400  * All comparisons only look at the lower XLEN (in the current mode)
1401  * bits of the compare values and of {csr-tdata2}.
1402  * When {mcontrol-select}=1 and access size is N, this is further
1403  * reduced, and comparisons only look at the lower N bits of the
1404  * compare values and of {csr-tdata2}.
1405  */
1406 /*
1407  * When set, enable this trigger in M-mode.
1408  */
1409 #define CSR_MCONTROL6_M_OFFSET 6ULL
1410 #define CSR_MCONTROL6_M_LENGTH 1ULL
1411 #define CSR_MCONTROL6_M 0x40ULL
1412 #define CSR_MCONTROL6_UNCERTAINEN_OFFSET 5ULL
1413 #define CSR_MCONTROL6_UNCERTAINEN_LENGTH 1ULL
1414 #define CSR_MCONTROL6_UNCERTAINEN 0x20ULL
1415 /*
1416  * disabled: This trigger will only match if the hardware can perfectly
1417  * evaluate it.
1418  */
1419 #define CSR_MCONTROL6_UNCERTAINEN_DISABLED 0
1420 /*
1421  * enabled: This trigger will match if it's possible that it would match if
1422  * the Trigger Module had perfect information about the operations
1423  * being performed.
1424  */
1425 #define CSR_MCONTROL6_UNCERTAINEN_ENABLED 1
1426 /*
1427  * When set, enable this trigger in S/HS-mode.
1428  * This bit is hard-wired to 0 if the hart does not support
1429  * S-mode.
1430  */
1431 #define CSR_MCONTROL6_S_OFFSET 4ULL
1432 #define CSR_MCONTROL6_S_LENGTH 1ULL
1433 #define CSR_MCONTROL6_S 0x10ULL
1434 /*
1435  * When set, enable this trigger in U-mode.
1436  * This bit is hard-wired to 0 if the hart does not support
1437  * U-mode.
1438  */
1439 #define CSR_MCONTROL6_U_OFFSET 3ULL
1440 #define CSR_MCONTROL6_U_LENGTH 1ULL
1441 #define CSR_MCONTROL6_U 8ULL
1442 /*
1443  * When set, the trigger fires on the virtual address or opcode of an
1444  * instruction that is executed.
1445  */
1446 #define CSR_MCONTROL6_EXECUTE_OFFSET 2ULL
1447 #define CSR_MCONTROL6_EXECUTE_LENGTH 1ULL
1448 #define CSR_MCONTROL6_EXECUTE 4ULL
1449 /*
1450  * When set, the trigger fires on the virtual address or data of any
1451  * store.
1452  */
1453 #define CSR_MCONTROL6_STORE_OFFSET 1ULL
1454 #define CSR_MCONTROL6_STORE_LENGTH 1ULL
1455 #define CSR_MCONTROL6_STORE 2ULL
1456 /*
1457  * When set, the trigger fires on the virtual address or data of any
1458  * load.
1459  */
1460 #define CSR_MCONTROL6_LOAD_OFFSET 0ULL
1461 #define CSR_MCONTROL6_LOAD_LENGTH 1ULL
1462 #define CSR_MCONTROL6_LOAD 1ULL
1463 #define CSR_ICOUNT 0x7a1
1464 #define CSR_ICOUNT_TYPE_OFFSET(XLEN) ((XLEN) + -4ULL)
1465 #define CSR_ICOUNT_TYPE_LENGTH 4ULL
1466 #define CSR_ICOUNT_TYPE(XLEN) (0xfULL * (1ULL << ((XLEN) + -4ULL)))
1467 #define CSR_ICOUNT_DMODE_OFFSET(XLEN) ((XLEN) + -5ULL)
1468 #define CSR_ICOUNT_DMODE_LENGTH 1ULL
1469 #define CSR_ICOUNT_DMODE(XLEN) (1ULL << ((XLEN) + -5ULL))
1470 /*
1471  * When set, enable this trigger in VS-mode.
1472  * This bit is hard-wired to 0 if the hart does not support
1473  * virtualization mode.
1474  */
1475 #define CSR_ICOUNT_VS_OFFSET 0x1aULL
1476 #define CSR_ICOUNT_VS_LENGTH 1ULL
1477 #define CSR_ICOUNT_VS 0x4000000ULL
1478 /*
1479  * When set, enable this trigger in VU-mode.
1480  * This bit is hard-wired to 0 if the hart does not support
1481  * virtualization mode.
1482  */
1483 #define CSR_ICOUNT_VU_OFFSET 0x19ULL
1484 #define CSR_ICOUNT_VU_LENGTH 1ULL
1485 #define CSR_ICOUNT_VU 0x2000000ULL
1486 /*
1487  * If this bit is implemented, the hardware sets it when this
1488  * trigger fires. The trigger's user can set or clear it at any
1489  * time. It is used to determine which
1490  * trigger(s) fires. If the bit is not implemented, it is always 0
1491  * and writing it has no effect.
1492  */
1493 #define CSR_ICOUNT_HIT_OFFSET 0x18ULL
1494 #define CSR_ICOUNT_HIT_LENGTH 1ULL
1495 #define CSR_ICOUNT_HIT 0x1000000ULL
1496 /*
1497  * The trigger will generally fire after {icount-count} instructions
1498  * in enabled modes have been executed. See above for the precise behavior.
1499  */
1500 #define CSR_ICOUNT_COUNT_OFFSET 0xaULL
1501 #define CSR_ICOUNT_COUNT_LENGTH 0xeULL
1502 #define CSR_ICOUNT_COUNT 0xfffc00ULL
1503 /*
1504  * When set, enable this trigger in M-mode.
1505  */
1506 #define CSR_ICOUNT_M_OFFSET 9ULL
1507 #define CSR_ICOUNT_M_LENGTH 1ULL
1508 #define CSR_ICOUNT_M 0x200ULL
1509 /*
1510  * This bit becomes set when {icount-count} is decremented from 1
1511  * to 0. It is cleared when the trigger fires, which will happen just
1512  * before executing the next instruction in one of the enabled modes.
1513  */
1514 #define CSR_ICOUNT_PENDING_OFFSET 8ULL
1515 #define CSR_ICOUNT_PENDING_LENGTH 1ULL
1516 #define CSR_ICOUNT_PENDING 0x100ULL
1517 /*
1518  * When set, enable this trigger in S/HS-mode.
1519  * This bit is hard-wired to 0 if the hart does not support
1520  * S-mode.
1521  */
1522 #define CSR_ICOUNT_S_OFFSET 7ULL
1523 #define CSR_ICOUNT_S_LENGTH 1ULL
1524 #define CSR_ICOUNT_S 0x80ULL
1525 /*
1526  * When set, enable this trigger in U-mode.
1527  * This bit is hard-wired to 0 if the hart does not support
1528  * U-mode.
1529  */
1530 #define CSR_ICOUNT_U_OFFSET 6ULL
1531 #define CSR_ICOUNT_U_LENGTH 1ULL
1532 #define CSR_ICOUNT_U 0x40ULL
1533 /*
1534  * The action to take when the trigger fires. The values are explained
1535  * in xref:tab:action[].
1536  */
1537 #define CSR_ICOUNT_ACTION_OFFSET 0ULL
1538 #define CSR_ICOUNT_ACTION_LENGTH 6ULL
1539 #define CSR_ICOUNT_ACTION 0x3fULL
1540 /*
1541  * breakpoint:
1542  */
1543 #define CSR_ICOUNT_ACTION_BREAKPOINT 0
1544 /*
1545  * debug mode:
1546  */
1547 #define CSR_ICOUNT_ACTION_DEBUG_MODE 1
1548 /*
1549  * trace on:
1550  */
1551 #define CSR_ICOUNT_ACTION_TRACE_ON 2
1552 /*
1553  * trace off:
1554  */
1555 #define CSR_ICOUNT_ACTION_TRACE_OFF 3
1556 /*
1557  * trace notify:
1558  */
1559 #define CSR_ICOUNT_ACTION_TRACE_NOTIFY 4
1560 /*
1561  * external0:
1562  */
1563 #define CSR_ICOUNT_ACTION_EXTERNAL0 8
1564 /*
1565  * external1:
1566  */
1567 #define CSR_ICOUNT_ACTION_EXTERNAL1 9
1568 #define CSR_ITRIGGER 0x7a1
1569 #define CSR_ITRIGGER_TYPE_OFFSET(XLEN) ((XLEN) + -4ULL)
1570 #define CSR_ITRIGGER_TYPE_LENGTH 4ULL
1571 #define CSR_ITRIGGER_TYPE(XLEN) (0xfULL * (1ULL << ((XLEN) + -4ULL)))
1572 #define CSR_ITRIGGER_DMODE_OFFSET(XLEN) ((XLEN) + -5ULL)
1573 #define CSR_ITRIGGER_DMODE_LENGTH 1ULL
1574 #define CSR_ITRIGGER_DMODE(XLEN) (1ULL << ((XLEN) + -5ULL))
1575 /*
1576  * If this bit is implemented, the hardware sets it when this
1577  * trigger matches. The trigger's user can set or clear it at any
1578  * time. It is used to determine which
1579  * trigger(s) matched. If the bit is not implemented, it is always 0
1580  * and writing it has no effect.
1581  */
1582 #define CSR_ITRIGGER_HIT_OFFSET(XLEN) ((XLEN) + -6ULL)
1583 #define CSR_ITRIGGER_HIT_LENGTH 1ULL
1584 #define CSR_ITRIGGER_HIT(XLEN) (1ULL << ((XLEN) + -6ULL))
1585 /*
1586  * When set, enable this trigger for interrupts that are taken from VS
1587  * mode.
1588  * This bit is hard-wired to 0 if the hart does not support
1589  * virtualization mode.
1590  */
1591 #define CSR_ITRIGGER_VS_OFFSET 0xcULL
1592 #define CSR_ITRIGGER_VS_LENGTH 1ULL
1593 #define CSR_ITRIGGER_VS 0x1000ULL
1594 /*
1595  * When set, enable this trigger for interrupts that are taken from VU
1596  * mode.
1597  * This bit is hard-wired to 0 if the hart does not support
1598  * virtualization mode.
1599  */
1600 #define CSR_ITRIGGER_VU_OFFSET 0xbULL
1601 #define CSR_ITRIGGER_VU_LENGTH 1ULL
1602 #define CSR_ITRIGGER_VU 0x800ULL
1603 /*
1604  * When set, non-maskable interrupts cause this
1605  * trigger to fire if the trigger is enabled for the current mode.
1606  */
1607 #define CSR_ITRIGGER_NMI_OFFSET 0xaULL
1608 #define CSR_ITRIGGER_NMI_LENGTH 1ULL
1609 #define CSR_ITRIGGER_NMI 0x400ULL
1610 /*
1611  * When set, enable this trigger for interrupts that are taken from M
1612  * mode.
1613  */
1614 #define CSR_ITRIGGER_M_OFFSET 9ULL
1615 #define CSR_ITRIGGER_M_LENGTH 1ULL
1616 #define CSR_ITRIGGER_M 0x200ULL
1617 /*
1618  * When set, enable this trigger for interrupts that are taken from S/HS
1619  * mode.
1620  * This bit is hard-wired to 0 if the hart does not support
1621  * S-mode.
1622  */
1623 #define CSR_ITRIGGER_S_OFFSET 7ULL
1624 #define CSR_ITRIGGER_S_LENGTH 1ULL
1625 #define CSR_ITRIGGER_S 0x80ULL
1626 /*
1627  * When set, enable this trigger for interrupts that are taken from U
1628  * mode.
1629  * This bit is hard-wired to 0 if the hart does not support
1630  * U-mode.
1631  */
1632 #define CSR_ITRIGGER_U_OFFSET 6ULL
1633 #define CSR_ITRIGGER_U_LENGTH 1ULL
1634 #define CSR_ITRIGGER_U 0x40ULL
1635 /*
1636  * The action to take when the trigger fires. The values are explained
1637  * in xref:tab:action[].
1638  */
1639 #define CSR_ITRIGGER_ACTION_OFFSET 0ULL
1640 #define CSR_ITRIGGER_ACTION_LENGTH 6ULL
1641 #define CSR_ITRIGGER_ACTION 0x3fULL
1642 /*
1643  * breakpoint:
1644  */
1645 #define CSR_ITRIGGER_ACTION_BREAKPOINT 0
1646 /*
1647  * debug mode:
1648  */
1649 #define CSR_ITRIGGER_ACTION_DEBUG_MODE 1
1650 /*
1651  * trace on:
1652  */
1653 #define CSR_ITRIGGER_ACTION_TRACE_ON 2
1654 /*
1655  * trace off:
1656  */
1657 #define CSR_ITRIGGER_ACTION_TRACE_OFF 3
1658 /*
1659  * trace notify:
1660  */
1661 #define CSR_ITRIGGER_ACTION_TRACE_NOTIFY 4
1662 /*
1663  * external0:
1664  */
1665 #define CSR_ITRIGGER_ACTION_EXTERNAL0 8
1666 /*
1667  * external1:
1668  */
1669 #define CSR_ITRIGGER_ACTION_EXTERNAL1 9
1670 #define CSR_ETRIGGER 0x7a1
1671 #define CSR_ETRIGGER_TYPE_OFFSET(XLEN) ((XLEN) + -4ULL)
1672 #define CSR_ETRIGGER_TYPE_LENGTH 4ULL
1673 #define CSR_ETRIGGER_TYPE(XLEN) (0xfULL * (1ULL << ((XLEN) + -4ULL)))
1674 #define CSR_ETRIGGER_DMODE_OFFSET(XLEN) ((XLEN) + -5ULL)
1675 #define CSR_ETRIGGER_DMODE_LENGTH 1ULL
1676 #define CSR_ETRIGGER_DMODE(XLEN) (1ULL << ((XLEN) + -5ULL))
1677 /*
1678  * If this bit is implemented, the hardware sets it when this
1679  * trigger matches. The trigger's user can set or clear it at any
1680  * time. It is used to determine which
1681  * trigger(s) matched. If the bit is not implemented, it is always 0
1682  * and writing it has no effect.
1683  */
1684 #define CSR_ETRIGGER_HIT_OFFSET(XLEN) ((XLEN) + -6ULL)
1685 #define CSR_ETRIGGER_HIT_LENGTH 1ULL
1686 #define CSR_ETRIGGER_HIT(XLEN) (1ULL << ((XLEN) + -6ULL))
1687 /*
1688  * When set, enable this trigger for exceptions that are taken from VS
1689  * mode.
1690  * This bit is hard-wired to 0 if the hart does not support
1691  * virtualization mode.
1692  */
1693 #define CSR_ETRIGGER_VS_OFFSET 0xcULL
1694 #define CSR_ETRIGGER_VS_LENGTH 1ULL
1695 #define CSR_ETRIGGER_VS 0x1000ULL
1696 /*
1697  * When set, enable this trigger for exceptions that are taken from VU
1698  * mode.
1699  * This bit is hard-wired to 0 if the hart does not support
1700  * virtualization mode.
1701  */
1702 #define CSR_ETRIGGER_VU_OFFSET 0xbULL
1703 #define CSR_ETRIGGER_VU_LENGTH 1ULL
1704 #define CSR_ETRIGGER_VU 0x800ULL
1705 /*
1706  * When set, enable this trigger for exceptions that are taken from M
1707  * mode.
1708  */
1709 #define CSR_ETRIGGER_M_OFFSET 9ULL
1710 #define CSR_ETRIGGER_M_LENGTH 1ULL
1711 #define CSR_ETRIGGER_M 0x200ULL
1712 /*
1713  * When set, enable this trigger for exceptions that are taken from S/HS
1714  * mode.
1715  * This bit is hard-wired to 0 if the hart does not support
1716  * S-mode.
1717  */
1718 #define CSR_ETRIGGER_S_OFFSET 7ULL
1719 #define CSR_ETRIGGER_S_LENGTH 1ULL
1720 #define CSR_ETRIGGER_S 0x80ULL
1721 /*
1722  * When set, enable this trigger for exceptions that are taken from U
1723  * mode.
1724  * This bit is hard-wired to 0 if the hart does not support
1725  * U-mode.
1726  */
1727 #define CSR_ETRIGGER_U_OFFSET 6ULL
1728 #define CSR_ETRIGGER_U_LENGTH 1ULL
1729 #define CSR_ETRIGGER_U 0x40ULL
1730 /*
1731  * The action to take when the trigger fires. The values are explained
1732  * in xref:tab:action[].
1733  */
1734 #define CSR_ETRIGGER_ACTION_OFFSET 0ULL
1735 #define CSR_ETRIGGER_ACTION_LENGTH 6ULL
1736 #define CSR_ETRIGGER_ACTION 0x3fULL
1737 /*
1738  * breakpoint:
1739  */
1740 #define CSR_ETRIGGER_ACTION_BREAKPOINT 0
1741 /*
1742  * debug mode:
1743  */
1744 #define CSR_ETRIGGER_ACTION_DEBUG_MODE 1
1745 /*
1746  * trace on:
1747  */
1748 #define CSR_ETRIGGER_ACTION_TRACE_ON 2
1749 /*
1750  * trace off:
1751  */
1752 #define CSR_ETRIGGER_ACTION_TRACE_OFF 3
1753 /*
1754  * trace notify:
1755  */
1756 #define CSR_ETRIGGER_ACTION_TRACE_NOTIFY 4
1757 /*
1758  * external0:
1759  */
1760 #define CSR_ETRIGGER_ACTION_EXTERNAL0 8
1761 /*
1762  * external1:
1763  */
1764 #define CSR_ETRIGGER_ACTION_EXTERNAL1 9
1765 #define CSR_TMEXTTRIGGER 0x7a1
1766 #define CSR_TMEXTTRIGGER_TYPE_OFFSET(XLEN) ((XLEN) + -4ULL)
1767 #define CSR_TMEXTTRIGGER_TYPE_LENGTH 4ULL
1768 #define CSR_TMEXTTRIGGER_TYPE(XLEN) (0xfULL * (1ULL << ((XLEN) + -4ULL)))
1769 #define CSR_TMEXTTRIGGER_DMODE_OFFSET(XLEN) ((XLEN) + -5ULL)
1770 #define CSR_TMEXTTRIGGER_DMODE_LENGTH 1ULL
1771 #define CSR_TMEXTTRIGGER_DMODE(XLEN) (1ULL << ((XLEN) + -5ULL))
1772 /*
1773  * If this bit is implemented, the hardware sets it when this
1774  * trigger matches. The trigger's user can set or clear it at any
1775  * time. It is used to determine which
1776  * trigger(s) matched. If the bit is not implemented, it is always 0
1777  * and writing it has no effect.
1778  */
1779 #define CSR_TMEXTTRIGGER_HIT_OFFSET(XLEN) ((XLEN) + -6ULL)
1780 #define CSR_TMEXTTRIGGER_HIT_LENGTH 1ULL
1781 #define CSR_TMEXTTRIGGER_HIT(XLEN) (1ULL << ((XLEN) + -6ULL))
1782 /*
1783  * This optional bit, when set, causes this trigger to fire whenever an attached
1784  * interrupt controller signals a trigger.
1785  */
1786 #define CSR_TMEXTTRIGGER_INTCTL_OFFSET 0x16ULL
1787 #define CSR_TMEXTTRIGGER_INTCTL_LENGTH 1ULL
1788 #define CSR_TMEXTTRIGGER_INTCTL 0x400000ULL
1789 /*
1790  * Selects any combination of up to 16 TM external trigger inputs
1791  * that cause this trigger to fire.
1792  */
1793 #define CSR_TMEXTTRIGGER_SELECT_OFFSET 6ULL
1794 #define CSR_TMEXTTRIGGER_SELECT_LENGTH 0x10ULL
1795 #define CSR_TMEXTTRIGGER_SELECT 0x3fffc0ULL
1796 /*
1797  * The action to take when the trigger fires. The values are explained
1798  * in xref:tab:action[].
1799  */
1800 #define CSR_TMEXTTRIGGER_ACTION_OFFSET 0ULL
1801 #define CSR_TMEXTTRIGGER_ACTION_LENGTH 6ULL
1802 #define CSR_TMEXTTRIGGER_ACTION 0x3fULL
1803 /*
1804  * breakpoint:
1805  */
1806 #define CSR_TMEXTTRIGGER_ACTION_BREAKPOINT 0
1807 /*
1808  * debug mode:
1809  */
1810 #define CSR_TMEXTTRIGGER_ACTION_DEBUG_MODE 1
1811 /*
1812  * trace on:
1813  */
1814 #define CSR_TMEXTTRIGGER_ACTION_TRACE_ON 2
1815 /*
1816  * trace off:
1817  */
1818 #define CSR_TMEXTTRIGGER_ACTION_TRACE_OFF 3
1819 /*
1820  * trace notify:
1821  */
1822 #define CSR_TMEXTTRIGGER_ACTION_TRACE_NOTIFY 4
1823 /*
1824  * external0:
1825  */
1826 #define CSR_TMEXTTRIGGER_ACTION_EXTERNAL0 8
1827 /*
1828  * external1:
1829  */
1830 #define CSR_TMEXTTRIGGER_ACTION_EXTERNAL1 9
1831 #define CSR_TEXTRA32 0x7a3
1832 /*
1833  * Data used together with {textra32-mhselect}.
1834  */
1835 #define CSR_TEXTRA32_MHVALUE_OFFSET 0x1aULL
1836 #define CSR_TEXTRA32_MHVALUE_LENGTH 6ULL
1837 #define CSR_TEXTRA32_MHVALUE 0xfc000000ULL
1838 #define CSR_TEXTRA32_MHSELECT_OFFSET 0x17ULL
1839 #define CSR_TEXTRA32_MHSELECT_LENGTH 3ULL
1840 #define CSR_TEXTRA32_MHSELECT 0x3800000ULL
1841 /*
1842  * ignore: Ignore {textra32-mhvalue}.
1843  */
1844 #define CSR_TEXTRA32_MHSELECT_IGNORE 0
1845 /*
1846  * mcontext: This trigger will only match or fire if the low bits of
1847  * {csr-mcontext}/{csr-hcontext} equal {textra32-mhvalue}.
1848  */
1849 #define CSR_TEXTRA32_MHSELECT_MCONTEXT 4
1850 /*
1851  * 1, 5 (mcontext_select): This trigger will only match or fire if the
1852  * low bits of
1853  * {csr-mcontext}/{csr-hcontext} equal {{textra32-mhvalue}, mhselect[2]}.
1854  *
1855  * 2, 6 (vmid_select): This trigger will only match or fire if VMID in
1856  * hgatp equals the lower VMIDMAX
1857  * (defined in the Privileged Spec) bits of {{textra32-mhvalue}, mhselect[2]}.
1858  *
1859  * 3, 7 (reserved): Reserved.
1860  *
1861  * If the H extension is not supported, the only legal values are 0 and 4.
1862  */
1863 /*
1864  * When the least significant bit of this field is 1, it causes bits 7:0
1865  * in the comparison to be ignored, when {textra32-sselect}=1.
1866  * When the next most significant bit of this field is 1, it causes bits 15:8
1867  * to be ignored in the comparison, when {textra32-sselect}=1.
1868  */
1869 #define CSR_TEXTRA32_SBYTEMASK_OFFSET 0x12ULL
1870 #define CSR_TEXTRA32_SBYTEMASK_LENGTH 2ULL
1871 #define CSR_TEXTRA32_SBYTEMASK 0xc0000ULL
1872 /*
1873  * Data used together with {textra32-sselect}.
1874  *
1875  * This field should be tied to 0 when S-mode is not supported.
1876  */
1877 #define CSR_TEXTRA32_SVALUE_OFFSET 2ULL
1878 #define CSR_TEXTRA32_SVALUE_LENGTH 0x10ULL
1879 #define CSR_TEXTRA32_SVALUE 0x3fffcULL
1880 #define CSR_TEXTRA32_SSELECT_OFFSET 0ULL
1881 #define CSR_TEXTRA32_SSELECT_LENGTH 2ULL
1882 #define CSR_TEXTRA32_SSELECT 3ULL
1883 /*
1884  * ignore: Ignore {textra32-svalue}.
1885  */
1886 #define CSR_TEXTRA32_SSELECT_IGNORE 0
1887 /*
1888  * scontext: This trigger will only match or fire if the low bits of
1889  * {csr-scontext} equal {textra32-svalue}.
1890  */
1891 #define CSR_TEXTRA32_SSELECT_SCONTEXT 1
1892 /*
1893  * asid: This trigger will only match or fire if:
1894  *
1895  * * the mode is VS-mode or VU-mode and ASID in `vsatp`
1896  * equals the lower ASIDMAX (defined in the Privileged Spec) bits
1897  * of {textra32-svalue}.
1898  *
1899  * * in all other modes, ASID in `satp` equals the lower
1900  * ASIDMAX (defined in the Privileged Spec) bits of
1901  * {textra32-svalue}.
1902  */
1903 #define CSR_TEXTRA32_SSELECT_ASID 2
1904 /*
1905  * This field should be tied to 0 when S-mode is not supported.
1906  */
1907 #define CSR_TEXTRA64 0x7a3
1908 #define CSR_TEXTRA64_MHVALUE_OFFSET 0x33ULL
1909 #define CSR_TEXTRA64_MHVALUE_LENGTH 0xdULL
1910 #define CSR_TEXTRA64_MHVALUE 0xfff8000000000000ULL
1911 #define CSR_TEXTRA64_MHSELECT_OFFSET 0x30ULL
1912 #define CSR_TEXTRA64_MHSELECT_LENGTH 3ULL
1913 #define CSR_TEXTRA64_MHSELECT 0x7000000000000ULL
1914 /*
1915  * When the least significant bit of this field is 1, it causes bits 7:0
1916  * in the comparison to be ignored, when {textra64-sselect}=1.
1917  * Likewise, the second bit controls the comparison of bits 15:8,
1918  * third bit controls the comparison of bits 23:16,
1919  * and fourth bit controls the comparison of bits 31:24.
1920  */
1921 #define CSR_TEXTRA64_SBYTEMASK_OFFSET 0x24ULL
1922 #define CSR_TEXTRA64_SBYTEMASK_LENGTH 4ULL
1923 #define CSR_TEXTRA64_SBYTEMASK 0xf000000000ULL
1924 #define CSR_TEXTRA64_SVALUE_OFFSET 2ULL
1925 #define CSR_TEXTRA64_SVALUE_LENGTH 0x20ULL
1926 #define CSR_TEXTRA64_SVALUE 0x3fffffffcULL
1927 #define CSR_TEXTRA64_SSELECT_OFFSET 0ULL
1928 #define CSR_TEXTRA64_SSELECT_LENGTH 2ULL
1929 #define CSR_TEXTRA64_SSELECT 3ULL
1930 #define DM_DMSTATUS 0x11
1931 #define DM_DMSTATUS_NDMRESETPENDING_OFFSET 0x18ULL
1932 #define DM_DMSTATUS_NDMRESETPENDING_LENGTH 1ULL
1933 #define DM_DMSTATUS_NDMRESETPENDING 0x1000000ULL
1934 /*
1935  * false: Unimplemented, or {dmcontrol-ndmreset} is zero and no ndmreset is currently
1936  * in progress.
1937  */
1938 #define DM_DMSTATUS_NDMRESETPENDING_FALSE 0
1939 /*
1940  * true: {dmcontrol-ndmreset} is currently nonzero, or there is an ndmreset in progress.
1941  */
1942 #define DM_DMSTATUS_NDMRESETPENDING_TRUE 1
1943 #define DM_DMSTATUS_STICKYUNAVAIL_OFFSET 0x17ULL
1944 #define DM_DMSTATUS_STICKYUNAVAIL_LENGTH 1ULL
1945 #define DM_DMSTATUS_STICKYUNAVAIL 0x800000ULL
1946 /*
1947  * current: The per-hart `unavail` bits reflect the current state of the hart.
1948  */
1949 #define DM_DMSTATUS_STICKYUNAVAIL_CURRENT 0
1950 /*
1951  * sticky: The per-hart `unavail` bits are sticky. Once they are set, they will
1952  * not clear until the debugger acknowledges them using {dmcontrol-ackunavail}.
1953  */
1954 #define DM_DMSTATUS_STICKYUNAVAIL_STICKY 1
1955 /*
1956  * If 1, then there is an implicit `ebreak` instruction at the
1957  * non-existent word immediately after the Program Buffer. This saves
1958  * the debugger from having to write the `ebreak` itself, and
1959  * allows the Program Buffer to be one word smaller.
1960  *
1961  * This must be 1 when {abstractcs-progbufsize} is 1.
1962  */
1963 #define DM_DMSTATUS_IMPEBREAK_OFFSET 0x16ULL
1964 #define DM_DMSTATUS_IMPEBREAK_LENGTH 1ULL
1965 #define DM_DMSTATUS_IMPEBREAK 0x400000ULL
1966 /*
1967  * This field is 1 when all currently selected harts have been reset
1968  * and reset has not been acknowledged for any of them.
1969  */
1970 #define DM_DMSTATUS_ALLHAVERESET_OFFSET 0x13ULL
1971 #define DM_DMSTATUS_ALLHAVERESET_LENGTH 1ULL
1972 #define DM_DMSTATUS_ALLHAVERESET 0x80000ULL
1973 /*
1974  * This field is 1 when at least one currently selected hart has been
1975  * reset and reset has not been acknowledged for that hart.
1976  */
1977 #define DM_DMSTATUS_ANYHAVERESET_OFFSET 0x12ULL
1978 #define DM_DMSTATUS_ANYHAVERESET_LENGTH 1ULL
1979 #define DM_DMSTATUS_ANYHAVERESET 0x40000ULL
1980 /*
1981  * This field is 1 when all currently selected harts have their
1982  * ((resume ack bit)) set.
1983  */
1984 #define DM_DMSTATUS_ALLRESUMEACK_OFFSET 0x11ULL
1985 #define DM_DMSTATUS_ALLRESUMEACK_LENGTH 1ULL
1986 #define DM_DMSTATUS_ALLRESUMEACK 0x20000ULL
1987 /*
1988  * This field is 1 when any currently selected hart has its
1989  * ((resume ack bit)) set.
1990  */
1991 #define DM_DMSTATUS_ANYRESUMEACK_OFFSET 0x10ULL
1992 #define DM_DMSTATUS_ANYRESUMEACK_LENGTH 1ULL
1993 #define DM_DMSTATUS_ANYRESUMEACK 0x10000ULL
1994 /*
1995  * This field is 1 when all currently selected harts do not exist in
1996  * this hardware platform.
1997  */
1998 #define DM_DMSTATUS_ALLNONEXISTENT_OFFSET 0xfULL
1999 #define DM_DMSTATUS_ALLNONEXISTENT_LENGTH 1ULL
2000 #define DM_DMSTATUS_ALLNONEXISTENT 0x8000ULL
2001 /*
2002  * This field is 1 when any currently selected hart does not exist in
2003  * this hardware platform.
2004  */
2005 #define DM_DMSTATUS_ANYNONEXISTENT_OFFSET 0xeULL
2006 #define DM_DMSTATUS_ANYNONEXISTENT_LENGTH 1ULL
2007 #define DM_DMSTATUS_ANYNONEXISTENT 0x4000ULL
2008 /*
2009  * This field is 1 when all currently selected harts are
2010  * unavailable, or (if {dmstatus-stickyunavail} is 1) were
2011  * unavailable without that being acknowledged.
2012  */
2013 #define DM_DMSTATUS_ALLUNAVAIL_OFFSET 0xdULL
2014 #define DM_DMSTATUS_ALLUNAVAIL_LENGTH 1ULL
2015 #define DM_DMSTATUS_ALLUNAVAIL 0x2000ULL
2016 /*
2017  * This field is 1 when any currently selected hart is unavailable,
2018  * or (if {dmstatus-stickyunavail} is 1) was unavailable without
2019  * that being acknowledged.
2020  */
2021 #define DM_DMSTATUS_ANYUNAVAIL_OFFSET 0xcULL
2022 #define DM_DMSTATUS_ANYUNAVAIL_LENGTH 1ULL
2023 #define DM_DMSTATUS_ANYUNAVAIL 0x1000ULL
2024 /*
2025  * This field is 1 when all currently selected harts are running.
2026  */
2027 #define DM_DMSTATUS_ALLRUNNING_OFFSET 0xbULL
2028 #define DM_DMSTATUS_ALLRUNNING_LENGTH 1ULL
2029 #define DM_DMSTATUS_ALLRUNNING 0x800ULL
2030 /*
2031  * This field is 1 when any currently selected hart is running.
2032  */
2033 #define DM_DMSTATUS_ANYRUNNING_OFFSET 0xaULL
2034 #define DM_DMSTATUS_ANYRUNNING_LENGTH 1ULL
2035 #define DM_DMSTATUS_ANYRUNNING 0x400ULL
2036 /*
2037  * This field is 1 when all currently selected harts are halted.
2038  */
2039 #define DM_DMSTATUS_ALLHALTED_OFFSET 9ULL
2040 #define DM_DMSTATUS_ALLHALTED_LENGTH 1ULL
2041 #define DM_DMSTATUS_ALLHALTED 0x200ULL
2042 /*
2043  * This field is 1 when any currently selected hart is halted.
2044  */
2045 #define DM_DMSTATUS_ANYHALTED_OFFSET 8ULL
2046 #define DM_DMSTATUS_ANYHALTED_LENGTH 1ULL
2047 #define DM_DMSTATUS_ANYHALTED 0x100ULL
2048 #define DM_DMSTATUS_AUTHENTICATED_OFFSET 7ULL
2049 #define DM_DMSTATUS_AUTHENTICATED_LENGTH 1ULL
2050 #define DM_DMSTATUS_AUTHENTICATED 0x80ULL
2051 /*
2052  * false: Authentication is required before using the DM.
2053  */
2054 #define DM_DMSTATUS_AUTHENTICATED_FALSE 0
2055 /*
2056  * true: The authentication check has passed.
2057  */
2058 #define DM_DMSTATUS_AUTHENTICATED_TRUE 1
2059 /*
2060  * On components that don't implement authentication, this bit must be
2061  * preset as 1.
2062  */
2063 #define DM_DMSTATUS_AUTHBUSY_OFFSET 6ULL
2064 #define DM_DMSTATUS_AUTHBUSY_LENGTH 1ULL
2065 #define DM_DMSTATUS_AUTHBUSY 0x40ULL
2066 /*
2067  * ready: The authentication module is ready to process the next
2068  * read/write to {dm-authdata}.
2069  */
2070 #define DM_DMSTATUS_AUTHBUSY_READY 0
2071 /*
2072  * busy: The authentication module is busy. Accessing {dm-authdata} results
2073  * in unspecified behavior.
2074  */
2075 #define DM_DMSTATUS_AUTHBUSY_BUSY 1
2076 /*
2077  * {dmstatus-authbusy} only becomes set in immediate response to an access to
2078  * {dm-authdata}.
2079  */
2080 /*
2081  * 1 if this Debug Module supports halt-on-reset functionality
2082  * controllable by the {dmcontrol-setresethaltreq} and {dmcontrol-clrresethaltreq} bits.
2083  * 0 otherwise.
2084  */
2085 #define DM_DMSTATUS_HASRESETHALTREQ_OFFSET 5ULL
2086 #define DM_DMSTATUS_HASRESETHALTREQ_LENGTH 1ULL
2087 #define DM_DMSTATUS_HASRESETHALTREQ 0x20ULL
2088 #define DM_DMSTATUS_CONFSTRPTRVALID_OFFSET 4ULL
2089 #define DM_DMSTATUS_CONFSTRPTRVALID_LENGTH 1ULL
2090 #define DM_DMSTATUS_CONFSTRPTRVALID 0x10ULL
2091 /*
2092  * invalid: {dm-confstrptr0}--{dm-confstrptr3} hold information which
2093  * is not relevant to the configuration structure.
2094  */
2095 #define DM_DMSTATUS_CONFSTRPTRVALID_INVALID 0
2096 /*
2097  * valid: {dm-confstrptr0}--{dm-confstrptr3} hold the address of the
2098  * configuration structure.
2099  */
2100 #define DM_DMSTATUS_CONFSTRPTRVALID_VALID 1
2101 #define DM_DMSTATUS_VERSION_OFFSET 0ULL
2102 #define DM_DMSTATUS_VERSION_LENGTH 4ULL
2103 #define DM_DMSTATUS_VERSION 0xfULL
2104 /*
2105  * none: There is no Debug Module present.
2106  */
2107 #define DM_DMSTATUS_VERSION_NONE 0
2108 /*
2109  * 0.11: There is a Debug Module and it conforms to version 0.11 of this
2110  * specification.
2111  */
2112 #define DM_DMSTATUS_VERSION_0_11 1
2113 /*
2114  * 0.13: There is a Debug Module and it conforms to version 0.13 of this
2115  * specification.
2116  */
2117 #define DM_DMSTATUS_VERSION_0_13 2
2118 /*
2119  * 1.0: There is a Debug Module and it conforms to version 1.0 of this
2120  * specification.
2121  */
2122 #define DM_DMSTATUS_VERSION_1_0 3
2123 /*
2124  * custom: There is a Debug Module but it does not conform to any
2125  * available version of this spec.
2126  */
2127 #define DM_DMSTATUS_VERSION_CUSTOM 15
2128 #define DM_DMCONTROL 0x10
2129 /*
2130  * Writing 0 clears the halt request bit for all currently selected
2131  * harts. This may cancel outstanding halt requests for those harts.
2132  *
2133  * Writing 1 sets the halt request bit for all currently selected
2134  * harts. Running harts will halt whenever their halt request bit is
2135  * set.
2136  *
2137  * Writes apply to the new value of {hartsel} and {dmcontrol-hasel}.
2138  *
2139  * Writes to this bit should be ignored while an abstract command is
2140  * executing.
2141  */
2142 #define DM_DMCONTROL_HALTREQ_OFFSET 0x1fULL
2143 #define DM_DMCONTROL_HALTREQ_LENGTH 1ULL
2144 #define DM_DMCONTROL_HALTREQ 0x80000000ULL
2145 /*
2146  * Writing 1 causes the currently selected harts to resume once, if
2147  * they are halted when the write occurs. It also clears the resume
2148  * ack bit for those harts.
2149  *
2150  * {dmcontrol-resumereq} is ignored if {dmcontrol-haltreq} is set.
2151  *
2152  * Writes apply to the new value of {hartsel} and {dmcontrol-hasel}.
2153  *
2154  * Writes to this bit should be ignored while an abstract command is
2155  * executing.
2156  */
2157 #define DM_DMCONTROL_RESUMEREQ_OFFSET 0x1eULL
2158 #define DM_DMCONTROL_RESUMEREQ_LENGTH 1ULL
2159 #define DM_DMCONTROL_RESUMEREQ 0x40000000ULL
2160 /*
2161  * This optional field writes the reset bit for all the currently
2162  * selected harts. To perform a reset the debugger writes 1, and then
2163  * writes 0 to deassert the reset signal.
2164  *
2165  * While this bit is 1, the debugger must not change which harts are
2166  * selected.
2167  *
2168  * If this feature is not implemented, the bit always stays 0, so
2169  * after writing 1 the debugger can read the register back to see if
2170  * the feature is supported.
2171  *
2172  * Writes apply to the new value of {hartsel} and {dmcontrol-hasel}.
2173  */
2174 #define DM_DMCONTROL_HARTRESET_OFFSET 0x1dULL
2175 #define DM_DMCONTROL_HARTRESET_LENGTH 1ULL
2176 #define DM_DMCONTROL_HARTRESET 0x20000000ULL
2177 #define DM_DMCONTROL_ACKHAVERESET_OFFSET 0x1cULL
2178 #define DM_DMCONTROL_ACKHAVERESET_LENGTH 1ULL
2179 #define DM_DMCONTROL_ACKHAVERESET 0x10000000ULL
2180 /*
2181  * nop: No effect.
2182  */
2183 #define DM_DMCONTROL_ACKHAVERESET_NOP 0
2184 /*
2185  * ack: Clears `havereset` for any selected harts.
2186  */
2187 #define DM_DMCONTROL_ACKHAVERESET_ACK 1
2188 /*
2189  * Writes apply to the new value of {hartsel} and {dmcontrol-hasel}.
2190  *
2191  * Writes to this bit should be ignored while an abstract command is
2192  * executing.
2193  */
2194 #define DM_DMCONTROL_ACKUNAVAIL_OFFSET 0x1bULL
2195 #define DM_DMCONTROL_ACKUNAVAIL_LENGTH 1ULL
2196 #define DM_DMCONTROL_ACKUNAVAIL 0x8000000ULL
2197 /*
2198  * nop: No effect.
2199  */
2200 #define DM_DMCONTROL_ACKUNAVAIL_NOP 0
2201 /*
2202  * ack: Clears `unavail` for any selected harts that are currently available.
2203  */
2204 #define DM_DMCONTROL_ACKUNAVAIL_ACK 1
2205 /*
2206  * Writes apply to the new value of {hartsel} and {dmcontrol-hasel}.
2207  */
2208 /*
2209  * Selects the definition of currently selected harts.
2210  */
2211 #define DM_DMCONTROL_HASEL_OFFSET 0x1aULL
2212 #define DM_DMCONTROL_HASEL_LENGTH 1ULL
2213 #define DM_DMCONTROL_HASEL 0x4000000ULL
2214 /*
2215  * single: There is a single currently selected hart, that is selected by {hartsel}.
2216  */
2217 #define DM_DMCONTROL_HASEL_SINGLE 0
2218 /*
2219  * multiple: There may be multiple currently selected harts -- the hart
2220  * selected by {hartsel}, plus those selected by the hart array mask
2221  * register.
2222  */
2223 #define DM_DMCONTROL_HASEL_MULTIPLE 1
2224 /*
2225  * An implementation which does not implement the hart array mask register
2226  * must tie this field to 0. A debugger which wishes to use the hart array
2227  * mask register feature should set this bit and read back to see if the functionality
2228  * is supported.
2229  */
2230 /*
2231  * The low 10 bits of {hartsel}: the DM-specific index of the hart to
2232  * select. This hart is always part of the currently selected harts.
2233  */
2234 #define DM_DMCONTROL_HARTSELLO_OFFSET 0x10ULL
2235 #define DM_DMCONTROL_HARTSELLO_LENGTH 0xaULL
2236 #define DM_DMCONTROL_HARTSELLO 0x3ff0000ULL
2237 /*
2238  * The high 10 bits of {hartsel}: the DM-specific index of the hart to
2239  * select. This hart is always part of the currently selected harts.
2240  */
2241 #define DM_DMCONTROL_HARTSELHI_OFFSET 6ULL
2242 #define DM_DMCONTROL_HARTSELHI_LENGTH 0xaULL
2243 #define DM_DMCONTROL_HARTSELHI 0xffc0ULL
2244 /*
2245  * This optional field sets {keepalive} for all currently selected
2246  * harts, unless {dmcontrol-clrkeepalive} is simultaneously set to
2247  * 1.
2248  *
2249  * Writes apply to the new value of {hartsel} and {dmcontrol-hasel}.
2250  */
2251 #define DM_DMCONTROL_SETKEEPALIVE_OFFSET 5ULL
2252 #define DM_DMCONTROL_SETKEEPALIVE_LENGTH 1ULL
2253 #define DM_DMCONTROL_SETKEEPALIVE 0x20ULL
2254 /*
2255  * This optional field clears {keepalive} for all currently selected
2256  * harts.
2257  *
2258  * Writes apply to the new value of {hartsel} and {dmcontrol-hasel}.
2259  */
2260 #define DM_DMCONTROL_CLRKEEPALIVE_OFFSET 4ULL
2261 #define DM_DMCONTROL_CLRKEEPALIVE_LENGTH 1ULL
2262 #define DM_DMCONTROL_CLRKEEPALIVE 0x10ULL
2263 /*
2264  * This optional field writes the halt-on-reset request bit for all
2265  * currently selected harts, unless {dmcontrol-clrresethaltreq} is
2266  * simultaneously set to 1.
2267  * When set to 1, each selected hart will halt upon the next deassertion
2268  * of its reset. The halt-on-reset request bit is not automatically
2269  * cleared. The debugger must write to {dmcontrol-clrresethaltreq} to clear it.
2270  *
2271  * Writes apply to the new value of {hartsel} and {dmcontrol-hasel}.
2272  *
2273  * If {dmstatus-hasresethaltreq} is 0, this field is not implemented.
2274  *
2275  * Writes to this bit should be ignored while an abstract command is
2276  * executing.
2277  */
2278 #define DM_DMCONTROL_SETRESETHALTREQ_OFFSET 3ULL
2279 #define DM_DMCONTROL_SETRESETHALTREQ_LENGTH 1ULL
2280 #define DM_DMCONTROL_SETRESETHALTREQ 8ULL
2281 /*
2282  * This optional field clears the halt-on-reset request bit for all
2283  * currently selected harts.
2284  *
2285  * Writes apply to the new value of {hartsel} and {dmcontrol-hasel}.
2286  *
2287  * Writes to this bit should be ignored while an abstract command is
2288  * executing.
2289  */
2290 #define DM_DMCONTROL_CLRRESETHALTREQ_OFFSET 2ULL
2291 #define DM_DMCONTROL_CLRRESETHALTREQ_LENGTH 1ULL
2292 #define DM_DMCONTROL_CLRRESETHALTREQ 4ULL
2293 /*
2294  * This bit controls the reset signal from the DM to the rest of the
2295  * hardware platform. The signal should reset every part of the hardware platform, including
2296  * every hart, except for the DM and any logic required to access the
2297  * DM.
2298  * To perform a hardware platform reset the debugger writes 1,
2299  * and then writes 0
2300  * to deassert the reset.
2301  */
2302 #define DM_DMCONTROL_NDMRESET_OFFSET 1ULL
2303 #define DM_DMCONTROL_NDMRESET_LENGTH 1ULL
2304 #define DM_DMCONTROL_NDMRESET 2ULL
2305 /*
2306  * This bit serves as a reset signal for the Debug Module itself.
2307  * After changing the value of this bit, the debugger must poll
2308  * {dm-dmcontrol} until {dmcontrol-dmactive} has taken the requested value
2309  * before performing any action that assumes the requested {dmcontrol-dmactive}
2310  * state change has completed. Hardware may
2311  * take an arbitrarily long time to complete activation or deactivation and will
2312  * indicate completion by setting {dmcontrol-dmactive} to the requested value.
2313  * During this time, the DM may ignore any register writes.
2314  */
2315 #define DM_DMCONTROL_DMACTIVE_OFFSET 0ULL
2316 #define DM_DMCONTROL_DMACTIVE_LENGTH 1ULL
2317 #define DM_DMCONTROL_DMACTIVE 1ULL
2318 /*
2319  * inactive: The module's state, including authentication mechanism,
2320  * takes its reset values (the {dmcontrol-dmactive} bit is the only bit which can
2321  * be written to something other than its reset value). Any accesses
2322  * to the module may fail. Specifically, {dmstatus-version} might not return
2323  * correct data.
2324  *
2325  * When this value is written, the DM may ignore any other bits written
2326  * to {dmcontrol} in the same write.
2327  */
2328 #define DM_DMCONTROL_DMACTIVE_INACTIVE 0
2329 /*
2330  * active: The module functions normally.
2331  */
2332 #define DM_DMCONTROL_DMACTIVE_ACTIVE 1
2333 /*
2334  * No other mechanism should exist that may result in resetting the
2335  * Debug Module after power up.
2336  *
2337  * To place the Debug Module into a known state, a debugger should write 0 to {dmcontrol-dmactive},
2338  * poll until {dmcontrol-dmactive} is observed 0, write 1 to {dmcontrol-dmactive}, and
2339  * poll until {dmcontrol-dmactive} is observed 1.
2340  *
2341  * Implementations may pay attention to this bit to further aid
2342  * debugging, for example by preventing the Debug Module from being
2343  * power gated while debugging is active.
2344  */
2345 #define DM_HARTINFO 0x12
2346 /*
2347  * Number of `dscratch` registers available for the debugger
2348  * to use during program buffer execution, starting from {csr-dscratch0}.
2349  * The debugger can make no assumptions about the contents of these
2350  * registers between commands.
2351  */
2352 #define DM_HARTINFO_NSCRATCH_OFFSET 0x14ULL
2353 #define DM_HARTINFO_NSCRATCH_LENGTH 4ULL
2354 #define DM_HARTINFO_NSCRATCH 0xf00000ULL
2355 #define DM_HARTINFO_DATAACCESS_OFFSET 0x10ULL
2356 #define DM_HARTINFO_DATAACCESS_LENGTH 1ULL
2357 #define DM_HARTINFO_DATAACCESS 0x10000ULL
2358 /*
2359  * csr: The `data` registers are shadowed in the hart by CSRs.
2360  * Each CSR is DXLEN bits in size, and corresponds
2361  * to a single argument, per <<tab:datareg>>.
2362  */
2363 #define DM_HARTINFO_DATAACCESS_CSR 0
2364 /*
2365  * memory: The `data` registers are shadowed in the hart's memory map.
2366  * Each register takes up 4 bytes in the memory map.
2367  */
2368 #define DM_HARTINFO_DATAACCESS_MEMORY 1
2369 /*
2370  * If {hartinfo-dataaccess} is 0: Number of CSRs dedicated to
2371  * shadowing the `data` registers.
2372  *
2373  * If {hartinfo-dataaccess} is 1: Number of 32-bit words in the memory map
2374  * dedicated to shadowing the `data` registers.
2375  *
2376  * Since there are at most 12 `data` registers, the value in this
2377  * register must be 12 or smaller.
2378  */
2379 #define DM_HARTINFO_DATASIZE_OFFSET 0xcULL
2380 #define DM_HARTINFO_DATASIZE_LENGTH 4ULL
2381 #define DM_HARTINFO_DATASIZE 0xf000ULL
2382 /*
2383  * If {hartinfo-dataaccess} is 0: The number of the first CSR dedicated to
2384  * shadowing the `data` registers.
2385  *
2386  * If {hartinfo-dataaccess} is 1: Address of RAM where the data
2387  * registers are shadowed. This address is sign extended giving a
2388  * range of -2048 to 2047, easily addressed with a load or store using
2389  * `x0` as the address register.
2390  */
2391 #define DM_HARTINFO_DATAADDR_OFFSET 0ULL
2392 #define DM_HARTINFO_DATAADDR_LENGTH 0xcULL
2393 #define DM_HARTINFO_DATAADDR 0xfffULL
2394 #define DM_HAWINDOWSEL 0x14
2395 /*
2396  * The high bits of this field may be tied to 0, depending on how large
2397  * the array mask register is. E.g. on a hardware platform with 48 harts only bit 0
2398  * of this field may actually be writable.
2399  */
2400 #define DM_HAWINDOWSEL_HAWINDOWSEL_OFFSET 0ULL
2401 #define DM_HAWINDOWSEL_HAWINDOWSEL_LENGTH 0xfULL
2402 #define DM_HAWINDOWSEL_HAWINDOWSEL 0x7fffULL
2403 #define DM_HAWINDOW 0x15
2404 #define DM_HAWINDOW_MASKDATA_OFFSET 0ULL
2405 #define DM_HAWINDOW_MASKDATA_LENGTH 0x20ULL
2406 #define DM_HAWINDOW_MASKDATA 0xffffffffULL
2407 #define DM_ABSTRACTCS 0x16
2408 /*
2409  * Size of the Program Buffer, in 32-bit words. Valid sizes are 0 - 16.
2410  */
2411 #define DM_ABSTRACTCS_PROGBUFSIZE_OFFSET 0x18ULL
2412 #define DM_ABSTRACTCS_PROGBUFSIZE_LENGTH 5ULL
2413 #define DM_ABSTRACTCS_PROGBUFSIZE 0x1f000000ULL
2414 #define DM_ABSTRACTCS_BUSY_OFFSET 0xcULL
2415 #define DM_ABSTRACTCS_BUSY_LENGTH 1ULL
2416 #define DM_ABSTRACTCS_BUSY 0x1000ULL
2417 /*
2418  * ready: There is no abstract command currently being executed.
2419  */
2420 #define DM_ABSTRACTCS_BUSY_READY 0
2421 /*
2422  * busy: An abstract command is currently being executed.
2423  */
2424 #define DM_ABSTRACTCS_BUSY_BUSY 1
2425 /*
2426  * This bit is set as soon as {dm-command} is written, and is
2427  * not cleared until that command has completed.
2428  */
2429 /*
2430  * This optional bit controls whether program buffer and abstract
2431  * memory accesses are performed with the exact and full set of
2432  * permission checks that apply based on the current architectural
2433  * state of the hart performing the access, or with a relaxed set of
2434  * permission checks (e.g. PMP restrictions are ignored). The
2435  * details of the latter are implementation-specific.
2436  */
2437 #define DM_ABSTRACTCS_RELAXEDPRIV_OFFSET 0xbULL
2438 #define DM_ABSTRACTCS_RELAXEDPRIV_LENGTH 1ULL
2439 #define DM_ABSTRACTCS_RELAXEDPRIV 0x800ULL
2440 /*
2441  * full checks: Full permission checks apply.
2442  */
2443 #define DM_ABSTRACTCS_RELAXEDPRIV_FULL_CHECKS 0
2444 /*
2445  * relaxed checks: Relaxed permission checks apply.
2446  */
2447 #define DM_ABSTRACTCS_RELAXEDPRIV_RELAXED_CHECKS 1
2448 /*
2449  * Gets set if an abstract command fails. The bits in this field remain set until
2450  * they are cleared by writing 1 to them. No abstract command is
2451  * started until the value is reset to 0.
2452  *
2453  * This field only contains a valid value if {abstractcs-busy} is 0.
2454  */
2455 #define DM_ABSTRACTCS_CMDERR_OFFSET 8ULL
2456 #define DM_ABSTRACTCS_CMDERR_LENGTH 3ULL
2457 #define DM_ABSTRACTCS_CMDERR 0x700ULL
2458 /*
2459  * none: No error.
2460  */
2461 #define DM_ABSTRACTCS_CMDERR_NONE 0
2462 /*
2463  * busy: An abstract command was executing while {dm-command},
2464  * {dm-abstractcs}, or {dm-abstractauto} was written, or when one
2465  * of the `data` or `progbuf` registers was read or written.
2466  * This status is only written if {abstractcs-cmderr} contains 0.
2467  */
2468 #define DM_ABSTRACTCS_CMDERR_BUSY 1
2469 /*
2470  * not supported: The command in {dm-command} is not supported. It
2471  * may be supported with different options set, but it will not be
2472  * supported at a later time when the hart or system state are
2473  * different.
2474  */
2475 #define DM_ABSTRACTCS_CMDERR_NOT_SUPPORTED 2
2476 /*
2477  * exception: An exception occurred while executing the command
2478  * (e.g. while executing the Program Buffer).
2479  */
2480 #define DM_ABSTRACTCS_CMDERR_EXCEPTION 3
2481 /*
2482  * halt/resume: The abstract command couldn't execute because the
2483  * hart wasn't in the required state (running/halted), or unavailable.
2484  */
2485 #define DM_ABSTRACTCS_CMDERR_HALT_RESUME 4
2486 /*
2487  * bus: The abstract command failed due to a bus error (e.g.
2488  * alignment, access size, or timeout).
2489  */
2490 #define DM_ABSTRACTCS_CMDERR_BUS 5
2491 /*
2492  * reserved: Reserved for future use.
2493  */
2494 #define DM_ABSTRACTCS_CMDERR_RESERVED 6
2495 /*
2496  * other: The command failed for another reason.
2497  */
2498 #define DM_ABSTRACTCS_CMDERR_OTHER 7
2499 /*
2500  * Number of `data` registers that are implemented as part of the
2501  * abstract command interface. Valid sizes are 1 -- 12.
2502  */
2503 #define DM_ABSTRACTCS_DATACOUNT_OFFSET 0ULL
2504 #define DM_ABSTRACTCS_DATACOUNT_LENGTH 4ULL
2505 #define DM_ABSTRACTCS_DATACOUNT 0xfULL
2506 #define DM_COMMAND 0x17
2507 /*
2508  * The type determines the overall functionality of this
2509  * abstract command.
2510  */
2511 #define DM_COMMAND_CMDTYPE_OFFSET 0x18ULL
2512 #define DM_COMMAND_CMDTYPE_LENGTH 8ULL
2513 #define DM_COMMAND_CMDTYPE 0xff000000ULL
2514 /*
2515  * This field is interpreted in a command-specific manner,
2516  * described for each abstract command.
2517  */
2518 #define DM_COMMAND_CONTROL_OFFSET 0ULL
2519 #define DM_COMMAND_CONTROL_LENGTH 0x18ULL
2520 #define DM_COMMAND_CONTROL 0xffffffULL
2521 #define DM_ABSTRACTAUTO 0x18
2522 /*
2523  * When a bit in this field is 1, read or write accesses to the
2524  * corresponding `progbuf` word cause the DM to act as if the
2525  * current value in {dm-command} was written there again after the
2526  * access to `progbuf` completes.
2527  */
2528 #define DM_ABSTRACTAUTO_AUTOEXECPROGBUF_OFFSET 0x10ULL
2529 #define DM_ABSTRACTAUTO_AUTOEXECPROGBUF_LENGTH 0x10ULL
2530 #define DM_ABSTRACTAUTO_AUTOEXECPROGBUF 0xffff0000ULL
2531 /*
2532  * When a bit in this field is 1, read or write accesses to the
2533  * corresponding `data` word cause the DM to act as if the current
2534  * value in {dm-command} was written there again after the
2535  * access to `data` completes.
2536  */
2537 #define DM_ABSTRACTAUTO_AUTOEXECDATA_OFFSET 0ULL
2538 #define DM_ABSTRACTAUTO_AUTOEXECDATA_LENGTH 0xcULL
2539 #define DM_ABSTRACTAUTO_AUTOEXECDATA 0xfffULL
2540 #define DM_CONFSTRPTR0 0x19
2541 #define DM_CONFSTRPTR0_ADDR_OFFSET 0ULL
2542 #define DM_CONFSTRPTR0_ADDR_LENGTH 0x20ULL
2543 #define DM_CONFSTRPTR0_ADDR 0xffffffffULL
2544 #define DM_CONFSTRPTR1 0x1a
2545 #define DM_CONFSTRPTR1_ADDR_OFFSET 0ULL
2546 #define DM_CONFSTRPTR1_ADDR_LENGTH 0x20ULL
2547 #define DM_CONFSTRPTR1_ADDR 0xffffffffULL
2548 #define DM_CONFSTRPTR2 0x1b
2549 #define DM_CONFSTRPTR2_ADDR_OFFSET 0ULL
2550 #define DM_CONFSTRPTR2_ADDR_LENGTH 0x20ULL
2551 #define DM_CONFSTRPTR2_ADDR 0xffffffffULL
2552 #define DM_CONFSTRPTR3 0x1c
2553 #define DM_CONFSTRPTR3_ADDR_OFFSET 0ULL
2554 #define DM_CONFSTRPTR3_ADDR_LENGTH 0x20ULL
2555 #define DM_CONFSTRPTR3_ADDR 0xffffffffULL
2556 #define DM_NEXTDM 0x1d
2557 #define DM_NEXTDM_ADDR_OFFSET 0ULL
2558 #define DM_NEXTDM_ADDR_LENGTH 0x20ULL
2559 #define DM_NEXTDM_ADDR 0xffffffffULL
2560 #define DM_DATA0 0x04
2561 #define DM_DATA0_DATA_OFFSET 0ULL
2562 #define DM_DATA0_DATA_LENGTH 0x20ULL
2563 #define DM_DATA0_DATA 0xffffffffULL
2564 #define DM_DATA1 0x05
2565 #define DM_DATA2 0x06
2566 #define DM_DATA3 0x07
2567 #define DM_DATA4 0x08
2568 #define DM_DATA5 0x09
2569 #define DM_DATA6 0x0a
2570 #define DM_DATA7 0x0b
2571 #define DM_DATA8 0x0c
2572 #define DM_DATA9 0x0d
2573 #define DM_DATA10 0x0e
2574 #define DM_DATA11 0x0f
2575 #define DM_PROGBUF0 0x20
2576 #define DM_PROGBUF0_DATA_OFFSET 0ULL
2577 #define DM_PROGBUF0_DATA_LENGTH 0x20ULL
2578 #define DM_PROGBUF0_DATA 0xffffffffULL
2579 #define DM_PROGBUF1 0x21
2580 #define DM_PROGBUF2 0x22
2581 #define DM_PROGBUF3 0x23
2582 #define DM_PROGBUF4 0x24
2583 #define DM_PROGBUF5 0x25
2584 #define DM_PROGBUF6 0x26
2585 #define DM_PROGBUF7 0x27
2586 #define DM_PROGBUF8 0x28
2587 #define DM_PROGBUF9 0x29
2588 #define DM_PROGBUF10 0x2a
2589 #define DM_PROGBUF11 0x2b
2590 #define DM_PROGBUF12 0x2c
2591 #define DM_PROGBUF13 0x2d
2592 #define DM_PROGBUF14 0x2e
2593 #define DM_PROGBUF15 0x2f
2594 #define DM_AUTHDATA 0x30
2595 #define DM_AUTHDATA_DATA_OFFSET 0ULL
2596 #define DM_AUTHDATA_DATA_LENGTH 0x20ULL
2597 #define DM_AUTHDATA_DATA 0xffffffffULL
2598 #define DM_DMCS2 0x32
2599 #define DM_DMCS2_GROUPTYPE_OFFSET 0xbULL
2600 #define DM_DMCS2_GROUPTYPE_LENGTH 1ULL
2601 #define DM_DMCS2_GROUPTYPE 0x800ULL
2602 /*
2603  * halt: The remaining fields in this register configure halt groups.
2604  */
2605 #define DM_DMCS2_GROUPTYPE_HALT 0
2606 /*
2607  * resume: The remaining fields in this register configure resume groups.
2608  */
2609 #define DM_DMCS2_GROUPTYPE_RESUME 1
2610 /*
2611  * This field contains the currently selected DM external trigger.
2612  *
2613  * If a non-existent trigger value is written here, the hardware will
2614  * change it to a valid one or 0 if no DM external triggers exist.
2615  */
2616 #define DM_DMCS2_DMEXTTRIGGER_OFFSET 7ULL
2617 #define DM_DMCS2_DMEXTTRIGGER_LENGTH 4ULL
2618 #define DM_DMCS2_DMEXTTRIGGER 0x780ULL
2619 /*
2620  * When {dmcs2-hgselect} is 0, contains the group of the hart
2621  * specified by {hartsel}.
2622  *
2623  * When {dmcs2-hgselect} is 1, contains the group of the DM external
2624  * trigger selected by {dmcs2-dmexttrigger}.
2625  *
2626  * The value written to this field is ignored unless {dmcs2-hgwrite}
2627  * is also written 1.
2628  *
2629  * Group numbers are contiguous starting at 0, with the highest number
2630  * being implementation-dependent, and possibly different between
2631  * different group types. Debuggers should read back this field after
2632  * writing to confirm they are using a hart group that is supported.
2633  *
2634  * If groups aren't implemented, then this entire field is 0.
2635  */
2636 #define DM_DMCS2_GROUP_OFFSET 2ULL
2637 #define DM_DMCS2_GROUP_LENGTH 5ULL
2638 #define DM_DMCS2_GROUP 0x7cULL
2639 /*
2640  * When 1 is written and {dmcs2-hgselect} is 0, for every selected
2641  * hart the DM will change its group to the value written to {dmcs2-group},
2642  * if the hardware supports that group for that hart.
2643  * Implementations may also change the group of a minimal set of
2644  * unselected harts in the same way, if that is necessary due to
2645  * a hardware limitation.
2646  *
2647  * When 1 is written and {dmcs2-hgselect} is 1, the DM will change
2648  * the group of the DM external trigger selected by {dmcs2-dmexttrigger}
2649  * to the value written to {dmcs2-group}, if the hardware supports
2650  * that group for that trigger.
2651  *
2652  * Writing 0 has no effect.
2653  */
2654 #define DM_DMCS2_HGWRITE_OFFSET 1ULL
2655 #define DM_DMCS2_HGWRITE_LENGTH 1ULL
2656 #define DM_DMCS2_HGWRITE 2ULL
2657 #define DM_DMCS2_HGSELECT_OFFSET 0ULL
2658 #define DM_DMCS2_HGSELECT_LENGTH 1ULL
2659 #define DM_DMCS2_HGSELECT 1ULL
2660 /*
2661  * harts: Operate on harts.
2662  */
2663 #define DM_DMCS2_HGSELECT_HARTS 0
2664 /*
2665  * triggers: Operate on DM external triggers.
2666  */
2667 #define DM_DMCS2_HGSELECT_TRIGGERS 1
2668 /*
2669  * If there are no DM external triggers, this field must be tied to 0.
2670  */
2671 #define DM_HALTSUM0 0x40
2672 #define DM_HALTSUM0_HALTSUM0_OFFSET 0ULL
2673 #define DM_HALTSUM0_HALTSUM0_LENGTH 0x20ULL
2674 #define DM_HALTSUM0_HALTSUM0 0xffffffffULL
2675 #define DM_HALTSUM1 0x13
2676 #define DM_HALTSUM1_HALTSUM1_OFFSET 0ULL
2677 #define DM_HALTSUM1_HALTSUM1_LENGTH 0x20ULL
2678 #define DM_HALTSUM1_HALTSUM1 0xffffffffULL
2679 #define DM_HALTSUM2 0x34
2680 #define DM_HALTSUM2_HALTSUM2_OFFSET 0ULL
2681 #define DM_HALTSUM2_HALTSUM2_LENGTH 0x20ULL
2682 #define DM_HALTSUM2_HALTSUM2 0xffffffffULL
2683 #define DM_HALTSUM3 0x35
2684 #define DM_HALTSUM3_HALTSUM3_OFFSET 0ULL
2685 #define DM_HALTSUM3_HALTSUM3_LENGTH 0x20ULL
2686 #define DM_HALTSUM3_HALTSUM3 0xffffffffULL
2687 #define DM_SBCS 0x38
2688 #define DM_SBCS_SBVERSION_OFFSET 0x1dULL
2689 #define DM_SBCS_SBVERSION_LENGTH 3ULL
2690 #define DM_SBCS_SBVERSION 0xe0000000ULL
2691 /*
2692  * legacy: The System Bus interface conforms to mainline drafts of this
2693  * spec older than 1 January, 2018.
2694  */
2695 #define DM_SBCS_SBVERSION_LEGACY 0
2696 /*
2697  * 1.0: The System Bus interface conforms to this version of the spec.
2698  */
2699 #define DM_SBCS_SBVERSION_1_0 1
2700 /*
2701  * Other values are reserved for future versions.
2702  */
2703 /*
2704  * Set when the debugger attempts to read data while a read is in
2705  * progress, or when the debugger initiates a new access while one is
2706  * already in progress (while {sbcs-sbbusy} is set). It remains set until
2707  * it's explicitly cleared by the debugger.
2708  *
2709  * While this field is set, no more system bus accesses can be
2710  * initiated by the Debug Module.
2711  */
2712 #define DM_SBCS_SBBUSYERROR_OFFSET 0x16ULL
2713 #define DM_SBCS_SBBUSYERROR_LENGTH 1ULL
2714 #define DM_SBCS_SBBUSYERROR 0x400000ULL
2715 /*
2716  * When 1, indicates the system bus manager is busy. (Whether the
2717  * system bus itself is busy is related, but not the same thing.) This
2718  * bit goes high immediately when a read or write is requested for any
2719  * reason, and does not go low until the access is fully completed.
2720  *
2721  * Writes to {dm-sbcs} while {sbcs-sbbusy} is high result in undefined
2722  * behavior. A debugger must not write to {dm-sbcs} until it reads
2723  * {sbcs-sbbusy} as 0.
2724  */
2725 #define DM_SBCS_SBBUSY_OFFSET 0x15ULL
2726 #define DM_SBCS_SBBUSY_LENGTH 1ULL
2727 #define DM_SBCS_SBBUSY 0x200000ULL
2728 /*
2729  * When 1, every write to {dm-sbaddress0} automatically triggers a
2730  * system bus read at the new address.
2731  */
2732 #define DM_SBCS_SBREADONADDR_OFFSET 0x14ULL
2733 #define DM_SBCS_SBREADONADDR_LENGTH 1ULL
2734 #define DM_SBCS_SBREADONADDR 0x100000ULL
2735 /*
2736  * Select the access size to use for system bus accesses.
2737  */
2738 #define DM_SBCS_SBACCESS_OFFSET 0x11ULL
2739 #define DM_SBCS_SBACCESS_LENGTH 3ULL
2740 #define DM_SBCS_SBACCESS 0xe0000ULL
2741 /*
2742  * 8bit: 8-bit
2743  */
2744 #define DM_SBCS_SBACCESS_8BIT 0
2745 /*
2746  * 16bit: 16-bit
2747  */
2748 #define DM_SBCS_SBACCESS_16BIT 1
2749 /*
2750  * 32bit: 32-bit
2751  */
2752 #define DM_SBCS_SBACCESS_32BIT 2
2753 /*
2754  * 64bit: 64-bit
2755  */
2756 #define DM_SBCS_SBACCESS_64BIT 3
2757 /*
2758  * 128bit: 128-bit
2759  */
2760 #define DM_SBCS_SBACCESS_128BIT 4
2761 /*
2762  * If {sbcs-sbaccess} has an unsupported value when the DM starts a bus
2763  * access, the access is not performed and {sbcs-sberror} is set to 4.
2764  */
2765 /*
2766  * When 1, `sbaddress` is incremented by the access size (in
2767  * bytes) selected in {sbcs-sbaccess} after every system bus access.
2768  */
2769 #define DM_SBCS_SBAUTOINCREMENT_OFFSET 0x10ULL
2770 #define DM_SBCS_SBAUTOINCREMENT_LENGTH 1ULL
2771 #define DM_SBCS_SBAUTOINCREMENT 0x10000ULL
2772 /*
2773  * When 1, every read from {dm-sbdata0} automatically triggers a
2774  * system bus read at the (possibly auto-incremented) address.
2775  */
2776 #define DM_SBCS_SBREADONDATA_OFFSET 0xfULL
2777 #define DM_SBCS_SBREADONDATA_LENGTH 1ULL
2778 #define DM_SBCS_SBREADONDATA 0x8000ULL
2779 /*
2780  * When the Debug Module's system bus
2781  * manager encounters an error, this field gets set. The bits in this
2782  * field remain set until they are cleared by writing 1 to them.
2783  * While this field is non-zero, no more system bus accesses can be
2784  * initiated by the Debug Module.
2785  *
2786  * An implementation may report ``Other'' (7) for any error condition.
2787  */
2788 #define DM_SBCS_SBERROR_OFFSET 0xcULL
2789 #define DM_SBCS_SBERROR_LENGTH 3ULL
2790 #define DM_SBCS_SBERROR 0x7000ULL
2791 /*
2792  * none: There was no bus error.
2793  */
2794 #define DM_SBCS_SBERROR_NONE 0
2795 /*
2796  * timeout: There was a timeout.
2797  */
2798 #define DM_SBCS_SBERROR_TIMEOUT 1
2799 /*
2800  * address: A bad address was accessed.
2801  */
2802 #define DM_SBCS_SBERROR_ADDRESS 2
2803 /*
2804  * alignment: There was an alignment error.
2805  */
2806 #define DM_SBCS_SBERROR_ALIGNMENT 3
2807 /*
2808  * size: An access of unsupported size was requested.
2809  */
2810 #define DM_SBCS_SBERROR_SIZE 4
2811 /*
2812  * other: Other.
2813  */
2814 #define DM_SBCS_SBERROR_OTHER 7
2815 /*
2816  * Width of system bus addresses in bits. (0 indicates there is no bus
2817  * access support.)
2818  */
2819 #define DM_SBCS_SBASIZE_OFFSET 5ULL
2820 #define DM_SBCS_SBASIZE_LENGTH 7ULL
2821 #define DM_SBCS_SBASIZE 0xfe0ULL
2822 /*
2823  * 1 when 128-bit system bus accesses are supported.
2824  */
2825 #define DM_SBCS_SBACCESS128_OFFSET 4ULL
2826 #define DM_SBCS_SBACCESS128_LENGTH 1ULL
2827 #define DM_SBCS_SBACCESS128 0x10ULL
2828 /*
2829  * 1 when 64-bit system bus accesses are supported.
2830  */
2831 #define DM_SBCS_SBACCESS64_OFFSET 3ULL
2832 #define DM_SBCS_SBACCESS64_LENGTH 1ULL
2833 #define DM_SBCS_SBACCESS64 8ULL
2834 /*
2835  * 1 when 32-bit system bus accesses are supported.
2836  */
2837 #define DM_SBCS_SBACCESS32_OFFSET 2ULL
2838 #define DM_SBCS_SBACCESS32_LENGTH 1ULL
2839 #define DM_SBCS_SBACCESS32 4ULL
2840 /*
2841  * 1 when 16-bit system bus accesses are supported.
2842  */
2843 #define DM_SBCS_SBACCESS16_OFFSET 1ULL
2844 #define DM_SBCS_SBACCESS16_LENGTH 1ULL
2845 #define DM_SBCS_SBACCESS16 2ULL
2846 /*
2847  * 1 when 8-bit system bus accesses are supported.
2848  */
2849 #define DM_SBCS_SBACCESS8_OFFSET 0ULL
2850 #define DM_SBCS_SBACCESS8_LENGTH 1ULL
2851 #define DM_SBCS_SBACCESS8 1ULL
2852 #define DM_SBADDRESS0 0x39
2853 /*
2854  * Accesses bits 31:0 of the physical address in `sbaddress`.
2855  */
2856 #define DM_SBADDRESS0_ADDRESS_OFFSET 0ULL
2857 #define DM_SBADDRESS0_ADDRESS_LENGTH 0x20ULL
2858 #define DM_SBADDRESS0_ADDRESS 0xffffffffULL
2859 #define DM_SBADDRESS1 0x3a
2860 /*
2861  * Accesses bits 63:32 of the physical address in `sbaddress` (if
2862  * the system address bus is that wide).
2863  */
2864 #define DM_SBADDRESS1_ADDRESS_OFFSET 0ULL
2865 #define DM_SBADDRESS1_ADDRESS_LENGTH 0x20ULL
2866 #define DM_SBADDRESS1_ADDRESS 0xffffffffULL
2867 #define DM_SBADDRESS2 0x3b
2868 /*
2869  * Accesses bits 95:64 of the physical address in `sbaddress` (if
2870  * the system address bus is that wide).
2871  */
2872 #define DM_SBADDRESS2_ADDRESS_OFFSET 0ULL
2873 #define DM_SBADDRESS2_ADDRESS_LENGTH 0x20ULL
2874 #define DM_SBADDRESS2_ADDRESS 0xffffffffULL
2875 #define DM_SBADDRESS3 0x37
2876 /*
2877  * Accesses bits 127:96 of the physical address in `sbaddress` (if
2878  * the system address bus is that wide).
2879  */
2880 #define DM_SBADDRESS3_ADDRESS_OFFSET 0ULL
2881 #define DM_SBADDRESS3_ADDRESS_LENGTH 0x20ULL
2882 #define DM_SBADDRESS3_ADDRESS 0xffffffffULL
2883 #define DM_SBDATA0 0x3c
2884 /*
2885  * Accesses bits 31:0 of `sbdata`.
2886  */
2887 #define DM_SBDATA0_DATA_OFFSET 0ULL
2888 #define DM_SBDATA0_DATA_LENGTH 0x20ULL
2889 #define DM_SBDATA0_DATA 0xffffffffULL
2890 #define DM_SBDATA1 0x3d
2891 /*
2892  * Accesses bits 63:32 of `sbdata` (if the system bus is that
2893  * wide).
2894  */
2895 #define DM_SBDATA1_DATA_OFFSET 0ULL
2896 #define DM_SBDATA1_DATA_LENGTH 0x20ULL
2897 #define DM_SBDATA1_DATA 0xffffffffULL
2898 #define DM_SBDATA2 0x3e
2899 /*
2900  * Accesses bits 95:64 of `sbdata` (if the system bus is that
2901  * wide).
2902  */
2903 #define DM_SBDATA2_DATA_OFFSET 0ULL
2904 #define DM_SBDATA2_DATA_LENGTH 0x20ULL
2905 #define DM_SBDATA2_DATA 0xffffffffULL
2906 #define DM_SBDATA3 0x3f
2907 /*
2908  * Accesses bits 127:96 of `sbdata` (if the system bus is that
2909  * wide).
2910  */
2911 #define DM_SBDATA3_DATA_OFFSET 0ULL
2912 #define DM_SBDATA3_DATA_LENGTH 0x20ULL
2913 #define DM_SBDATA3_DATA 0xffffffffULL
2914 #define DM_CUSTOM 0x1f
2915 #define DM_CUSTOM0 0x70
2916 #define DM_CUSTOM1 0x71
2917 #define DM_CUSTOM2 0x72
2918 #define DM_CUSTOM3 0x73
2919 #define DM_CUSTOM4 0x74
2920 #define DM_CUSTOM5 0x75
2921 #define DM_CUSTOM6 0x76
2922 #define DM_CUSTOM7 0x77
2923 #define DM_CUSTOM8 0x78
2924 #define DM_CUSTOM9 0x79
2925 #define DM_CUSTOM10 0x7a
2926 #define DM_CUSTOM11 0x7b
2927 #define DM_CUSTOM12 0x7c
2928 #define DM_CUSTOM13 0x7d
2929 #define DM_CUSTOM14 0x7e
2930 #define DM_CUSTOM15 0x7f
2931 #define SHORTNAME 0x123
2932 /*
2933  * Description of what this field is used for.
2934  */
2935 #define SHORTNAME_FIELD_OFFSET 0ULL
2936 #define SHORTNAME_FIELD_LENGTH 8ULL
2937 #define SHORTNAME_FIELD 0xffULL
2938 /*
2939  * This is 0 to indicate Access Register Command.
2940  */
2941 #define AC_ACCESS_REGISTER_CMDTYPE_OFFSET 0x18ULL
2942 #define AC_ACCESS_REGISTER_CMDTYPE_LENGTH 8ULL
2943 #define AC_ACCESS_REGISTER_CMDTYPE 0xff000000ULL
2944 #define AC_ACCESS_REGISTER_AARSIZE_OFFSET 0x14ULL
2945 #define AC_ACCESS_REGISTER_AARSIZE_LENGTH 3ULL
2946 #define AC_ACCESS_REGISTER_AARSIZE 0x700000ULL
2947 /*
2948  * 32bit: Access the lowest 32 bits of the register.
2949  */
2950 #define AC_ACCESS_REGISTER_AARSIZE_32BIT 2
2951 /*
2952  * 64bit: Access the lowest 64 bits of the register.
2953  */
2954 #define AC_ACCESS_REGISTER_AARSIZE_64BIT 3
2955 /*
2956  * 128bit: Access the lowest 128 bits of the register.
2957  */
2958 #define AC_ACCESS_REGISTER_AARSIZE_128BIT 4
2959 /*
2960  * If {accessregister-aarsize} specifies a size larger than the register's actual size,
2961  * then the access must fail. If a register is accessible, then reads of {accessregister-aarsize}
2962  * less than or equal to the register's actual size must be supported.
2963  * Writing less than the full register may be supported, but what
2964  * happens to the high bits in that case is UNSPECIFIED.
2965  *
2966  * This field controls the Argument Width as referenced in
2967  * xref:tab:datareg[].
2968  */
2969 #define AC_ACCESS_REGISTER_AARPOSTINCREMENT_OFFSET 0x13ULL
2970 #define AC_ACCESS_REGISTER_AARPOSTINCREMENT_LENGTH 1ULL
2971 #define AC_ACCESS_REGISTER_AARPOSTINCREMENT 0x80000ULL
2972 /*
2973  * disabled: No effect. This variant must be supported.
2974  */
2975 #define AC_ACCESS_REGISTER_AARPOSTINCREMENT_DISABLED 0
2976 /*
2977  * enabled: After a successful register access, {accessregister-regno} is
2978  * incremented. Incrementing past the highest supported value
2979  * causes {accessregister-regno} to become UNSPECIFIED. Supporting
2980  * this variant is optional. It is undefined whether the increment
2981  * happens when {accessregister-transfer} is 0.
2982  */
2983 #define AC_ACCESS_REGISTER_AARPOSTINCREMENT_ENABLED 1
2984 #define AC_ACCESS_REGISTER_POSTEXEC_OFFSET 0x12ULL
2985 #define AC_ACCESS_REGISTER_POSTEXEC_LENGTH 1ULL
2986 #define AC_ACCESS_REGISTER_POSTEXEC 0x40000ULL
2987 /*
2988  * disabled: No effect. This variant must be supported, and is the only
2989  * supported one if {abstractcs-progbufsize} is 0.
2990  */
2991 #define AC_ACCESS_REGISTER_POSTEXEC_DISABLED 0
2992 /*
2993  * enabled: Execute the program in the Program Buffer exactly once after
2994  * performing the transfer, if any. Supporting this variant is
2995  * optional.
2996  */
2997 #define AC_ACCESS_REGISTER_POSTEXEC_ENABLED 1
2998 #define AC_ACCESS_REGISTER_TRANSFER_OFFSET 0x11ULL
2999 #define AC_ACCESS_REGISTER_TRANSFER_LENGTH 1ULL
3000 #define AC_ACCESS_REGISTER_TRANSFER 0x20000ULL
3001 /*
3002  * disabled: Don't do the operation specified by {accessregister-write}.
3003  */
3004 #define AC_ACCESS_REGISTER_TRANSFER_DISABLED 0
3005 /*
3006  * enabled: Do the operation specified by {accessregister-write}.
3007  */
3008 #define AC_ACCESS_REGISTER_TRANSFER_ENABLED 1
3009 /*
3010  * This bit can be used to just execute the Program Buffer without
3011  * having to worry about placing valid values into {accessregister-aarsize} or {accessregister-regno}.
3012  */
3013 /*
3014  * When {accessregister-transfer} is set:
3015  */
3016 #define AC_ACCESS_REGISTER_WRITE_OFFSET 0x10ULL
3017 #define AC_ACCESS_REGISTER_WRITE_LENGTH 1ULL
3018 #define AC_ACCESS_REGISTER_WRITE 0x10000ULL
3019 /*
3020  * arg0: Copy data from the specified register into `arg0` portion
3021  * of `data`.
3022  */
3023 #define AC_ACCESS_REGISTER_WRITE_ARG0 0
3024 /*
3025  * register: Copy data from `arg0` portion of `data` into the
3026  * specified register.
3027  */
3028 #define AC_ACCESS_REGISTER_WRITE_REGISTER 1
3029 /*
3030  * Number of the register to access, as described in
3031  * xref:tab:regno[].
3032  * {csr-dpc} may be used as an alias for PC if this command is
3033  * supported on a non-halted hart.
3034  */
3035 #define AC_ACCESS_REGISTER_REGNO_OFFSET 0ULL
3036 #define AC_ACCESS_REGISTER_REGNO_LENGTH 0x10ULL
3037 #define AC_ACCESS_REGISTER_REGNO 0xffffULL
3038 /*
3039  * This is 1 to indicate Quick Access command.
3040  */
3041 #define AC_QUICK_ACCESS_CMDTYPE_OFFSET 0x18ULL
3042 #define AC_QUICK_ACCESS_CMDTYPE_LENGTH 8ULL
3043 #define AC_QUICK_ACCESS_CMDTYPE 0xff000000ULL
3044 /*
3045  * This is 2 to indicate Access Memory Command.
3046  */
3047 #define AC_ACCESS_MEMORY_CMDTYPE_OFFSET 0x18ULL
3048 #define AC_ACCESS_MEMORY_CMDTYPE_LENGTH 8ULL
3049 #define AC_ACCESS_MEMORY_CMDTYPE 0xff000000ULL
3050 /*
3051  * An implementation does not have to implement both virtual and
3052  * physical accesses, but it must fail accesses that it doesn't
3053  * support.
3054  */
3055 #define AC_ACCESS_MEMORY_AAMVIRTUAL_OFFSET 0x17ULL
3056 #define AC_ACCESS_MEMORY_AAMVIRTUAL_LENGTH 1ULL
3057 #define AC_ACCESS_MEMORY_AAMVIRTUAL 0x800000ULL
3058 /*
3059  * physical: Addresses are physical (to the hart they are performed on).
3060  */
3061 #define AC_ACCESS_MEMORY_AAMVIRTUAL_PHYSICAL 0
3062 /*
3063  * virtual: Addresses are virtual, and translated the way they would be from
3064  * M-mode, with `MPRV` set.
3065  */
3066 #define AC_ACCESS_MEMORY_AAMVIRTUAL_VIRTUAL 1
3067 /*
3068  * Debug Modules on systems without address translation (i.e. virtual addresses equal physical)
3069  * may optionally allow {accessmemory-aamvirtual} set to 1, which would produce the same result as
3070  * that same abstract command with {accessmemory-aamvirtual} cleared.
3071  */
3072 #define AC_ACCESS_MEMORY_AAMSIZE_OFFSET 0x14ULL
3073 #define AC_ACCESS_MEMORY_AAMSIZE_LENGTH 3ULL
3074 #define AC_ACCESS_MEMORY_AAMSIZE 0x700000ULL
3075 /*
3076  * 8bit: Access the lowest 8 bits of the memory location.
3077  */
3078 #define AC_ACCESS_MEMORY_AAMSIZE_8BIT 0
3079 /*
3080  * 16bit: Access the lowest 16 bits of the memory location.
3081  */
3082 #define AC_ACCESS_MEMORY_AAMSIZE_16BIT 1
3083 /*
3084  * 32bit: Access the lowest 32 bits of the memory location.
3085  */
3086 #define AC_ACCESS_MEMORY_AAMSIZE_32BIT 2
3087 /*
3088  * 64bit: Access the lowest 64 bits of the memory location.
3089  */
3090 #define AC_ACCESS_MEMORY_AAMSIZE_64BIT 3
3091 /*
3092  * 128bit: Access the lowest 128 bits of the memory location.
3093  */
3094 #define AC_ACCESS_MEMORY_AAMSIZE_128BIT 4
3095 /*
3096  * After a memory access has completed, if this bit is 1, increment
3097  * `arg1` (which contains the address used) by the number of bytes
3098  * encoded in {accessmemory-aamsize}.
3099  *
3100  * Supporting this variant is optional, but highly recommended for
3101  * performance reasons.
3102  */
3103 #define AC_ACCESS_MEMORY_AAMPOSTINCREMENT_OFFSET 0x13ULL
3104 #define AC_ACCESS_MEMORY_AAMPOSTINCREMENT_LENGTH 1ULL
3105 #define AC_ACCESS_MEMORY_AAMPOSTINCREMENT 0x80000ULL
3106 #define AC_ACCESS_MEMORY_WRITE_OFFSET 0x10ULL
3107 #define AC_ACCESS_MEMORY_WRITE_LENGTH 1ULL
3108 #define AC_ACCESS_MEMORY_WRITE 0x10000ULL
3109 /*
3110  * arg0: Copy data from the memory location specified in `arg1` into
3111  * the low bits of `arg0`. The value of the remaining bits of
3112  * `arg0` are UNSPECIFIED.
3113  */
3114 #define AC_ACCESS_MEMORY_WRITE_ARG0 0
3115 /*
3116  * memory: Copy data from the low bits of `arg0` into the memory
3117  * location specified in `arg1`.
3118  */
3119 #define AC_ACCESS_MEMORY_WRITE_MEMORY 1
3120 /*
3121  * These bits are reserved for target-specific uses.
3122  */
3123 #define AC_ACCESS_MEMORY_TARGET_SPECIFIC_OFFSET 0xeULL
3124 #define AC_ACCESS_MEMORY_TARGET_SPECIFIC_LENGTH 2ULL
3125 #define AC_ACCESS_MEMORY_TARGET_SPECIFIC 0xc000ULL
3126 #define VIRT_PRIV virtual
3127 /*
3128  * Contains the virtualization mode the hart was operating in when Debug
3129  * Mode was entered. The encoding is described in <<tab:privmode>>,
3130  * and matches the virtualization mode encoding from the Privileged Spec.
3131  * A user can write this value to change the hart's virtualization mode
3132  * when exiting Debug Mode.
3133  */
3134 #define VIRT_PRIV_V_OFFSET 2ULL
3135 #define VIRT_PRIV_V_LENGTH 1ULL
3136 #define VIRT_PRIV_V 4ULL
3137 /*
3138  * Contains the privilege mode the hart was operating in when Debug
3139  * Mode was entered. The encoding is described in <<tab:privmode>>, and matches the privilege mode encoding from
3140  * the Privileged Spec. A user can write this
3141  * value to change the hart's privilege mode when exiting Debug Mode.
3142  */
3143 #define VIRT_PRIV_PRV_OFFSET 0ULL
3144 #define VIRT_PRIV_PRV_LENGTH 2ULL
3145 #define VIRT_PRIV_PRV 3ULL
3206 };
3208  struct {
3209  unsigned int value; int is_set;
3211  struct {
3212  unsigned int value; int is_set;
3213  } XLEN;
3214  struct {
3215  unsigned int value; int is_set;
3217 };
3218 
3220  const char *name;
3221  unsigned int lsb; // inclusive
3222  unsigned int msb; // inclusive
3223  const char **values; // If non-NULL, array of human-readable string for each possible value
3224 };
3227  struct riscv_debug_reg_field_list (*get_next)(struct riscv_debug_reg_ctx context);
3228 };
3230  const char *name;
3231  struct riscv_debug_reg_field_list (* const get_fields_head)(struct riscv_debug_reg_ctx context);
3232 };
3234 #endif
struct riscv_debug_reg_info get_riscv_debug_reg_info(enum riscv_debug_reg_ordinal reg_ordinal)
riscv_debug_reg_ordinal
@ DM_AUTHDATA_ORDINAL
@ DM_CONFSTRPTR0_ORDINAL
@ CSR_TEXTRA64_ORDINAL
@ DM_DMSTATUS_ORDINAL
@ CSR_MCONTEXT_ORDINAL
@ DM_SBADDRESS0_ORDINAL
@ DM_ABSTRACTAUTO_ORDINAL
@ CSR_SCONTEXT_ORDINAL
@ DTM_IDCODE_ORDINAL
@ CSR_MCONTROL6_ORDINAL
@ CSR_ETRIGGER_ORDINAL
@ DM_SBDATA0_ORDINAL
@ CSR_TDATA1_ORDINAL
@ DM_COMMAND_ORDINAL
@ DM_SBDATA2_ORDINAL
@ DM_PROGBUF0_ORDINAL
@ DM_CONFSTRPTR2_ORDINAL
@ CSR_TMEXTTRIGGER_ORDINAL
@ DM_ABSTRACTCS_ORDINAL
@ CSR_ICOUNT_ORDINAL
@ DM_SBADDRESS1_ORDINAL
@ DM_DMCS2_ORDINAL
@ VIRT_PRIV_ORDINAL
@ DTM_DMI_ORDINAL
@ DM_HAWINDOW_ORDINAL
@ AC_ACCESS_MEMORY_ORDINAL
@ DM_SBDATA1_ORDINAL
@ CSR_ITRIGGER_ORDINAL
@ CSR_TSELECT_ORDINAL
@ CSR_TINFO_ORDINAL
@ DTM_BYPASS_ORDINAL
@ DM_SBADDRESS3_ORDINAL
@ AC_QUICK_ACCESS_ORDINAL
@ CSR_DPC_ORDINAL
@ CSR_DSCRATCH1_ORDINAL
@ DM_NEXTDM_ORDINAL
@ CSR_DCSR_ORDINAL
@ DTM_DTMCS_ORDINAL
@ CSR_DSCRATCH0_ORDINAL
@ DM_HAWINDOWSEL_ORDINAL
@ SHORTNAME_ORDINAL
@ CSR_TDATA3_ORDINAL
@ CSR_TEXTRA32_ORDINAL
@ CSR_TDATA2_ORDINAL
@ DM_CONFSTRPTR3_ORDINAL
@ CSR_TCONTROL_ORDINAL
@ DM_SBDATA3_ORDINAL
@ CSR_MCONTROL_ORDINAL
@ DM_HALTSUM2_ORDINAL
@ DM_HALTSUM1_ORDINAL
@ DM_HARTINFO_ORDINAL
@ DM_SBCS_ORDINAL
@ DM_SBADDRESS2_ORDINAL
@ DM_HALTSUM3_ORDINAL
@ DM_DMCONTROL_ORDINAL
@ DM_HALTSUM0_ORDINAL
@ DM_DATA0_ORDINAL
@ DM_CONFSTRPTR1_ORDINAL
@ AC_ACCESS_REGISTER_ORDINAL
struct riscv_debug_reg_ctx::@122 DXLEN
struct riscv_debug_reg_ctx::@123 XLEN
struct riscv_debug_reg_ctx::@124 abits
struct riscv_debug_reg_field_info field
struct riscv_debug_reg_field_list(* get_next)(struct riscv_debug_reg_ctx context)
struct riscv_debug_reg_field_list(*const get_fields_head)(struct riscv_debug_reg_ctx context)