Skip to content

Commit

Permalink
Improve riscv expose_[csrs|custom] commands (#536)
Browse files Browse the repository at this point in the history
* Improve riscv expose_[csrs|custom] commands

* Add option to specify custom name for registers.
* Allow to call commands multiple times without loss of previous data.
* Make sure the commands can only be used in the config phase (before "init").
* Validity checks and warnings.
* Change commands to be per target.
* Fix memory leaks.
* Also fix unrelated memory leaks to keep valgrind happy.

Signed-off-by: Samuel Obuch <sobuch@codasip.com>

* fixes after review

* improve error message
  • Loading branch information
sobuch authored Oct 1, 2020
1 parent 2c909f8 commit 6db3ed2
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 116 deletions.
15 changes: 9 additions & 6 deletions doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -9641,21 +9641,24 @@ OpenOCD exposes each hart as a separate core.

@subsection RISC-V Debug Configuration Commands

@deffn Command {riscv expose_csrs} n0[-m0][,n1[-m1]]...
Configure a list of inclusive ranges for CSRs to expose in addition to the
standard ones. This must be executed before `init`.
@deffn Command {riscv expose_csrs} n[-m|=name] [...]
Configure which CSRs to expose in addition to the standard ones. The CSRs to expose
can be specified as individual register numbers or register ranges (inclusive). For the
individually listed CSRs, a human-readable name can optionally be set.
This command must be executed before `init`.

By default OpenOCD attempts to expose only CSRs that are mentioned in a spec,
and then only if the corresponding extension appears to be implemented. This
command can be used if OpenOCD gets this wrong, or a target implements custom
CSRs.
@end deffn

@deffn Command {riscv expose_custom} n0[-m0][,n1[-m1]]...
@deffn Command {riscv expose_custom} n[-m|=name] [...]
The RISC-V Debug Specification allows targets to expose custom registers
through abstract commands. (See Section 3.5.1.1 in that document.) This command
configures a list of inclusive ranges of those registers to expose. Number 0
indicates the first custom register, whose abstract command number is 0xc000.
configures individual registers or register ranges (inclusive) that shall be exposed.
Number 0 indicates the first custom register, whose abstract command number is 0xc000.
For individually listed registers, a human-readable name can be optionally provided.
This command must be executed before `init`.
@end deffn

Expand Down
Loading

0 comments on commit 6db3ed2

Please sign in to comment.