@@ -11573,11 +11573,9 @@ an error if current CPU does not support DSP.
1157311573@section RISC-V Architecture
1157411574
1157511575@uref{http://riscv.org/, RISC-V} is a free and open ISA. OpenOCD supports JTAG
11576- debug of RV32 and RV64 cores in heterogeneous multicore systems of up to 32
11577- harts. (It's possible to increase this limit to 1024 by changing
11578- RISCV_MAX_HARTS in riscv.h.) OpenOCD primarily supports 0.13 of the RISC-V
11579- Debug Specification, but there is also support for legacy targets that
11580- implement version 0.11.
11576+ debug of RV32 and RV64 cores in heterogeneous multicore systems of up to 2^20
11577+ harts. OpenOCD primarily supports 0.13 of the RISC-V Debug Specification,
11578+ but there is also support for legacy targets that implement version 0.11.
1158111579
1158211580@subsection RISC-V Terminology
1158311581
@@ -11622,8 +11620,34 @@ follows:
1162211620</feature>
1162311621@end example
1162411622
11623+ @subsection RISC-V @code{$target_name configure} options
11624+ @itemize
11625+ @item @code{-ebreak} [@option{m}|@option{s}|@option{u}|@option{vs}|@option{vu}]
11626+ @option{exception}|@option{halt} -- sets the desired behavior of @code{ebreak}
11627+ instruction on the target. Defaults to @option{halt} in all execution modes.
11628+
11629+ @itemize
11630+ @item The last argument specifies which action should be taken when a hart
11631+ executes a @code{ebreak}.
11632+
11633+ @item The first argument specifies in which execution mode the @code{ebreak}
11634+ behavior should change. If this option is omitted the configuration affects
11635+ all execution modes.
11636+
11637+ @item @code{cget} returns a TCL @code{dict} of execution mode - @code{ebreak}
11638+ action pairs.
11639+ @end itemize
11640+ @end itemize
11641+
1162511642@subsection RISC-V Debug Configuration Commands
1162611643
11644+ @deffn {Command} {riscv dump_sample_buf} [base64]
11645+ Dump and clear the contents of the sample buffer. Which samples are collected
11646+ is configured with @code{riscv memory_sample}. If the optional base64
11647+ argument is passed, the raw buffer is dumped in base64 format, so that
11648+ external tools can gather the data efficiently.
11649+ @end deffn
11650+
1162711651@deffn {Config Command} {riscv expose_csrs} n[-m|=name] [...]
1162811652Configure which CSRs to expose in addition to the standard ones. The CSRs to expose
1162911653can be specified as individual register numbers or register ranges (inclusive). For the
@@ -11638,13 +11662,13 @@ CSRs.
1163811662
1163911663@example
1164011664# Expose a single RISC-V CSR number 128 under the name "csr128":
11641- $_TARGETNAME expose_csrs 128
11665+ riscv expose_csrs 128
1164211666
1164311667# Expose multiple RISC-V CSRs 128..132 under names "csr128" through "csr132":
11644- $_TARGETNAME expose_csrs 128-132
11668+ riscv expose_csrs 128-132
1164511669
1164611670# Expose a single RISC-V CSR number 1996 under custom name "csr_myregister":
11647- $_TARGETNAME expose_csrs 1996=myregister
11671+ riscv expose_csrs 1996=myregister
1164811672@end example
1164911673@end deffn
1165011674
@@ -11672,8 +11696,43 @@ $_TARGETNAME expose_custom 32=myregister
1167211696@end example
1167311697@end deffn
1167411698
11699+ @deffn {Config Command} {riscv hide_csrs} n[-m] [,n1[-m1]] [...]
11700+ The RISC-V Specification defines many CSRs, and we may want to avoid showing
11701+ each CSR to the user, as they may not be relevant to the task at hand. For
11702+ example, we may choose not to show trigger or PMU registers for simple
11703+ debugging scenarios. This command allows to mark individual registers or
11704+ register ranges (inclusive) as "hidden". Such hidden registers won't be
11705+ displayed in GDB or @code{reg} command output.
11706+
11707+ @example
11708+
11709+ # Hide range of RISC-V CSRs
11710+ # CSR_TSELECT - 1952 and CSR_TDATA1 - 1953
11711+ $_TARGETNAME riscv hide_csrs 1952-1953
11712+
11713+ @end example
11714+ @end deffn
11715+
11716+ @deffn {Command} {riscv memory_sample} bucket address|clear [size=4]
11717+ Configure OpenOCD to frequently read size bytes at the given addresses.
11718+ Execute the command with no arguments to see the current configuration. Use
11719+ clear to stop using a given bucket.
11720+
11721+ OpenOCD will allocate a 1MB sample buffer, and when it fills up no more
11722+ samples will be collected until it is emptied with @code{riscv
11723+ dump_sample_buf}.
11724+ @end deffn
11725+
11726+ @deffn {Command} {riscv repeat_read} count address [size=4]
11727+ Quickly read count words of the given size from address. This can be useful
11728+ to read out a buffer that's memory-mapped to be accessed through a single
11729+ address, or to sample a changing value in a memory-mapped device.
11730+ @end deffn
11731+
1167511732@deffn {Command} {riscv info}
11676- Displays some information OpenOCD detected about the target.
11733+ Displays some information OpenOCD detected about the target. Output's format
11734+ allows to use it directly with TCL's `array set` function. In case obtaining an
11735+ info point failed, the corresponding value is displayed as "unavailable".
1167711736@end deffn
1167811737
1167911738@deffn {Command} {riscv reset_delays} [wait]
@@ -11687,11 +11746,6 @@ Set the wall-clock timeout (in seconds) for individual commands. The default
1168711746should work fine for all but the slowest targets (eg. simulators).
1168811747@end deffn
1168911748
11690- @deffn {Command} {riscv set_reset_timeout_sec} [seconds]
11691- Set the maximum time to wait for a hart to come out of reset after reset is
11692- deasserted.
11693- @end deffn
11694-
1169511749@deffn {Command} {riscv set_mem_access} method1 [method2] [method3]
1169611750Specify which RISC-V memory access method(s) shall be used, and in which order
1169711751of priority. At least one method must be specified.
@@ -11710,16 +11764,18 @@ This command can be used to change the memory access methods if the default
1171011764behavior is not suitable for a particular target.
1171111765@end deffn
1171211766
11713- @deffn {Command} {riscv set_enable_virtual} on|off
11714- When on, memory accesses are performed on physical or virtual memory depending
11715- on the current system configuration. When off (default), all memory accessses are performed
11716- on physical memory.
11717- @end deffn
11718-
11719- @deffn {Command} {riscv set_enable_virt2phys} on|off
11720- When on (default), memory accesses are performed on physical or virtual memory
11721- depending on the current satp configuration. When off, all memory accessses are
11722- performed on physical memory.
11767+ @deffn {Command} {riscv virt2phys_mode} [@option{hw}|@option{sw}|@option{off}]
11768+ Configure how OpenOCD translates virtual addresses to physical:
11769+ @itemize @bullet
11770+ @item @option{sw} - OpenOCD translates virtual addresses explicitly by
11771+ traversing the page table entries (by performing physical memory accesses to
11772+ read the respective entries). This is the default mode.
11773+ @item @option{hw} - Virtual addresses are translated implicitly by hardware.
11774+ (Virtual memory access will fail with an error if the hardware doesn't
11775+ support the necessary functionality.)
11776+ @item @option{off} - Virtual addresses are not translated (identity mapping is assumed).
11777+ @end itemize
11778+ Returns current translation mode if called without arguments.
1172311779@end deffn
1172411780
1172511781@deffn {Command} {riscv resume_order} normal|reversed
@@ -11756,10 +11812,15 @@ Display/set the current core displayed in GDB. This is needed only if
1175611812@code{riscv smp} was used.
1175711813@end deffn
1175811814
11759- @deffn {Command} {riscv use_bscan_tunnel} value
11815+ @deffn {Command} {riscv use_bscan_tunnel} width [type]
1176011816Enable or disable use of a BSCAN tunnel to reach the Debug Module. Supply the
11761- width of the DM transport TAP's instruction register to enable. Supply a
11762- value of 0 to disable.
11817+ @var{width} of the DM transport TAP's instruction register to enable. The
11818+ @var{width} should fit into 7 bits. Supply a value of 0 to disable.
11819+ Pass a second argument (optional) to indicate Bscan Tunnel Type:
11820+ @enumerate
11821+ @item 0:(default) NESTED_TAP
11822+ @item 1: DATA_REGISTER
11823+ @end enumerate
1176311824
1176411825This BSCAN tunnel interface is specific to SiFive IP. Anybody may implement
1176511826it, but currently there is no good documentation on it. In a nutshell, this
@@ -11775,19 +11836,43 @@ tunneled DR scan consists of:
1177511836@end enumerate
1177611837@end deffn
1177711838
11778- @deffn {Command} {riscv set_ebreakm} on|off
11779- Control dcsr.ebreakm. When on (default), M-mode ebreak instructions trap to
11780- OpenOCD. When off, they generate a breakpoint exception handled internally .
11839+ @deffn {Command} {riscv set_bscan_tunnel_ir} value
11840+ Allows the use_bscan_tunnel feature to target non Xilinx device by
11841+ specifying the JTAG TAP IR used to access the bscan tunnel .
1178111842@end deffn
1178211843
11783- @deffn {Command} {riscv set_ebreaks} on|off
11784- Control dcsr.ebreaks. When on (default), S-mode ebreak instructions trap to
11785- OpenOCD. When off, they generate a breakpoint exception handled internally.
11844+ @deffn {Command} {riscv set_maskisr} [@option{off}|@option{steponly}]
11845+ Selects whether interrupts will be disabled when single stepping. The default configuration is @option{off}.
11846+ This feature is only useful on hardware that always steps into interrupts and doesn't support dcsr.stepie=0.
11847+ Keep in mind, disabling the option does not guarantee that single stepping will go into interrupt handlers.
11848+ To make that happen, dcsr.stepie would have to be written to 1 as well.
1178611849@end deffn
1178711850
11788- @deffn {Command} {riscv set_ebreaku} on|off
11789- Control dcsr.ebreaku. When on (default), U-mode ebreak instructions trap to
11790- OpenOCD. When off, they generate a breakpoint exception handled internally.
11851+ The commands below can be used to prevent OpenOCD from using certain RISC-V trigger features.
11852+ For example in cases when there are known issues in the target hardware.
11853+
11854+ @deffn {Command} {riscv set_enable_trigger_feature} [(@option{eq}|@option{napot}|@option{ge_lt}|@option{all}) (@option{wp}|@option{none})]
11855+ Control which RISC-V trigger features can be used by OpenOCD placing watchpoints.
11856+ All trigger features are allowed by default. Only new watchpoints, inserted after this command,
11857+ are affected (watchpoints that were already placed before are not changed).
11858+
11859+ The first argument selects one of the configurable RISC-V trigger features:
11860+
11861+ @itemize @minus
11862+ @item @option{eq}: Equality match trigger
11863+ @item @option{napot}: NAPOT trigger
11864+ @item @option{ge_lt}: Chained pair of `greater-equal` and `less-than` triggers
11865+ @item @option{all}: All trigger features which were described above
11866+ @end itemize
11867+
11868+ The second argument configures how OpenOCD should use the selected trigger feature:
11869+
11870+ @itemize @minus
11871+ @item @option{wp}: Enable this trigger feature for watchpoints - allow OpenOCD to use it. (Default.)
11872+ @item @option{none}: Disable the use of this trigger feature. OpenOCD will not attempt to use it.
11873+ @end itemize
11874+
11875+ With no parameters, prints current trigger features configuration.
1179111876@end deffn
1179211877
1179311878@subsection RISC-V Authentication Commands
@@ -11800,25 +11885,156 @@ set challenge [riscv authdata_read]
1180011885riscv authdata_write [expr @{$challenge + 1@}]
1180111886@end example
1180211887
11803- @deffn {Command} {riscv authdata_read}
11804- Return the 32-bit value read from authdata.
11888+ @deffn {Command} {riscv authdata_read} [index=0]
11889+ Return the 32-bit value read from authdata or authdata0 (index=0), or
11890+ authdata1 (index=1).
1180511891@end deffn
1180611892
11807- @deffn {Command} {riscv authdata_write} value
11808- Write the 32-bit value to authdata.
11893+ @deffn {Command} {riscv authdata_write} [index=0] value
11894+ Write the 32-bit value to authdata or authdata0 (index=0), or authdata1
11895+ (index=1).
1180911896@end deffn
1181011897
1181111898@subsection RISC-V DMI Commands
1181211899
11813- The following commands allow direct access to the Debug Module Interface, which
11814- can be used to interact with custom debug features.
11900+ The following commands allow for direct low-level access to the registers
11901+ of the Debug Module (DM). They can be useful to access custom features in the DM.
11902+
11903+ @deffn {Command} {riscv dm_read} reg_address
11904+ Perform a 32-bit read from the register indicated by reg_address from the DM of the
11905+ current target.
11906+ @end deffn
11907+
11908+ @deffn {Command} {riscv dm_write} reg_address value
11909+ Write the 32-bit value to the register indicated by reg_address from the DM of the
11910+ current target.
11911+ @end deffn
11912+
11913+ The following commands allow for direct low-level access to the Debug Module
11914+ Interface (DMI). They can be useful to access any device that resides on the DMI.
1181511915
1181611916@deffn {Command} {riscv dmi_read} address
11817- Perform a 32-bit DMI read at address, returning the value.
11917+ Perform a 32-bit read from the given DMI address, returning the value.
1181811918@end deffn
1181911919
1182011920@deffn {Command} {riscv dmi_write} address value
11821- Perform a 32-bit DMI write of value at address.
11921+ Perform a 32-bit write to the given DMI address.
11922+ @end deffn
11923+
11924+ @subsection RISC-V Trigger Commands
11925+
11926+ The RISC-V Debug Specification defines several optional trigger types that don't
11927+ map cleanly onto OpenOCD's notion of hardware breakpoints. For the types that
11928+ the target supports, these commands let you
11929+ set those triggers directly. (It's also possible to do so by writing the
11930+ appropriate CSRs.)
11931+
11932+ @deffn {Command} {riscv etrigger set} [@option{m}] [@option{s}] [@option{u}] [@option{vs}] [@option{vu}] exception_codes
11933+ Set an exception trigger (type 5) on the current target, which halts the target when it
11934+ fires. @option{m}, @option{s}, @option{u}, @option{vs}, and @option{vu} control
11935+ which execution modes the trigger fires in. @var{exception_codes} is a bit
11936+ field, where each bit corresponds to an exception code in mcause (defined in the
11937+ RISC-V Privileged Spec). The etrigger will fire on the exceptions whose bits are
11938+ set in @var{exception_codes}.
11939+
11940+ For details on this trigger type, see the RISC-V Debug Specification.
11941+ @end deffn
11942+
11943+ @deffn {Command} {riscv etrigger clear}
11944+ Clear the type 5 trigger that was set using @command{riscv etrigger set}.
11945+ @end deffn
11946+
11947+ @deffn {Command} {riscv icount set} [@option{m}] [@option{s}] [@option{u}] [@option{vs}] [@option{vu}] [@option{pending}] count
11948+ Set an instruction count
11949+ trigger (type 3) on the current target, which halts the target when it fires.
11950+ @option{m}, @option{s}, @option{u}, @option{vs}, and @option{vu} control which
11951+ execution modes the trigger fires in. If [@option{pending}] is passed then the
11952+ pending bit is set, which is unlikely to be useful unless you're debugging the
11953+ hardware implementation of this trigger.
11954+ @var{count} sets the number of instructions to execute before the trigger is
11955+ taken.
11956+
11957+ For details on this trigger type, see the RISC-V Debug Specification.
11958+ @end deffn
11959+
11960+ @deffn {Command} {riscv icount clear}
11961+ Clear the type 3 trigger that was set using @command{riscv icount set}.
11962+ @end deffn
11963+
11964+ @deffn {Command} {riscv itrigger set} [@option{m}] [@option{s}] [@option{u}] [@option{vs}] [@option{vu}] [@option{nmi}] mie_bits
11965+ Set an interrupt trigger (type 4) on the current target, which halts the target when it
11966+ fires. @option{m}, @option{s}, @option{u}, @option{vs}, and @option{vu} control
11967+ which execution modes the trigger fires in. If [@option{nmi}] is passed then
11968+ the trigger will fire on non-maskable interrupts in those modes. @var{mie_bits}
11969+ controls which interrupts the trigger fires on, using the same bit assignments
11970+ as in the mie CSR (defined in the RISC-V Privileged Spec).
11971+
11972+ For details on this trigger type, see the RISC-V Debug Specification.
11973+ @end deffn
11974+
11975+ @deffn {Command} {riscv reserve_trigger} [index @option{on|off}]
11976+ Manages the set of reserved triggers. Reserving a trigger results in OpenOCD
11977+ not using it internally (e.g. skipping it when setting a watchpoint or a
11978+ hardware breakpoint), so that the user or the application has unfettered
11979+ control over the trigger. By default there are no reserved triggers.
11980+
11981+ @enumerate
11982+ @item @var{index} specifies the index of a trigger to reserve or free up.
11983+ @item The second argument specifies whether the trigger should be reserved
11984+ (@var{on}) or a prior reservation cancelled (@var{off}).
11985+ @item If called without parameters, returns indices of reserved triggers.
11986+ @end enumerate
11987+
11988+ @end deffn
11989+
11990+ @deffn {Command} {riscv itrigger clear}
11991+ Clear the type 4 trigger that was set using @command{riscv itrigger set}.
11992+ @end deffn
11993+
11994+ @subsection RISC-V Program Buffer Commands
11995+
11996+ Program Buffer is an optional feature of RISC-V targets - it is a mechanism that debuggers
11997+ can use to execute sequences of arbitrary instructions (small programs) on the target.
11998+ For details on the Program Buffer, please refer to the RISC-V Debug Specification.
11999+
12000+ @deffn {Command} {riscv exec_progbuf} inst1 [inst2 [... inst16]]
12001+ Execute the given sequence of instructions on the target using the Program Buffer.
12002+ The command can only be used on halted targets.
12003+
12004+ The instructions @var{inst1} .. @var{inst16} shall be specified in their binary form
12005+ (as 32-bit integers). In case a pair of compressed (16-bit) instructions is used,
12006+ the first instruction should be placed to the lower 16-bits of the 32-bit value.
12007+ The terminating @var{ebreak} instruction needs not be specified - it is added
12008+ automatically if needed.
12009+ @end deffn
12010+
12011+ Examples:
12012+
12013+ @example
12014+ # Execute 32-bit instructions "fence rw,rw" (0x0330000f)
12015+ # and "fence.i" (0x0000100f) using the Program Buffer,
12016+ # in this order:
12017+
12018+ riscv exec_progbuf 0x0330000f 0x0000100f
12019+
12020+ # Execute 16-bit instructions "c.addi s0,s0,1" (0x0405)
12021+ # and "c.add s1,s1,s0" (0x94a2) using the Program Buffer,
12022+ # in this order:
12023+
12024+ riscv exec_progbuf 0x94a20405
12025+ @end example
12026+
12027+ @deffn {Command} {riscv autofence} [on|off]
12028+ When on (default), OpenOCD will automatically execute RISC-V fence instructions
12029+ (@var{fence.i} and @var{fence rw, rw}) in these cases:
12030+ @itemize @bullet
12031+ @item before step or resume,
12032+ @item before memory read via the Program Buffer,
12033+ @item after memory write via the Program Buffer.
12034+ @end itemize
12035+ When off, users need to take care of memory coherency themselves, for example
12036+ using the @var{riscv exec_progbuf} command to execute fences or CMO instructions
12037+ (RISC-V Cache Management Operations).
1182212038@end deffn
1182312039
1182412040@section ARC Architecture
0 commit comments