aboutsummaryrefslogtreecommitdiff
path: root/src/target
AgeCommit message (Collapse)AuthorFilesLines
7 daysMerge pull request #1267 from en-sc/en-sc/from_upstreamHEADlatestriscvEvgeniy Naydanov40-410/+389
Merge up to afbd01b0a46f3a81fe6076c002ad66973dcfb64c from upstream
11 daysMerge pull request #1274 from en-sc/en-sc/add-more-info-in-sample-memoryEvgeniy Naydanov1-2/+2
target/riscv: improve error messaging in case `sbasize` is zero
2025-08-06target/riscv: fix get mode filed for vsatp and hgatpMark Zhuang1-2/+4
Add the necessary get_filed and add a comment to indicate this section is for VU/VS mode
2025-08-06target/riscv: fix address translation in hypervisor modezhefan.lv1-17/+0
address translation don't need to care hstatus.HU
2025-07-07target/riscv: improve error messaging in case `sbasize` is zeroSriram Shanmuga1-2/+2
From: Sriram Shanmuga <sriramharshalee@gmail.com> RISC-V Debug Specification v1.0 [3.14.22. System Bus Access Control and Status (`sbcs`, at 0x38)] states in `sbasize` field description: > Width of system bus addresses in bits. (0 indicates there is no bus access support.) Before the patch, the error message did not include the information about `sbcs.sbasize` being zero wich made it quite undescriptive: ``` [riscv.cpu] Turning off memory sampling because it failed. ``` Fixes #1270 Change-Id: I5402dd57dc9a81f65ee4c67d24e11c366006427c Signed-off-by: Sriram Shanmuga <sriramharshalee@gmail.com> Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2025-06-12target/riscv: check nextdm address in abits rangeMark Zhuang1-0/+7
When abits not correctly configured, we hope to detect it as soon as possible.
2025-05-05Merge up to afbd01b0a46f3a81fe6076c002ad66973dcfb64c from upstreamEvgeniy Naydanov40-410/+389
Change-Id: I719167dc34a1a29ae32f8d4f27f2d3cd7a04e47b
2025-05-01transport: use a bitmask for the transportAntonio Borneo2-3/+3
Move the transport's names in a local array in the transport framework. Replace the string struct transport::name, that identifies the transport, with a bitmask where each bit corresponds to one of the available transports. Change-Id: I6bdf7264d5979c355299f63fcf80bf54dcd95cee Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8674 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de>
2025-05-01target: stm8: drop include file stm8.hAntonio Borneo3-66/+47
The file stm8.h is only included by stm8.c and provides some basic declaration that can be simply part of the C file. Drop the file stm8.h and move its content in stm8.c Replace the macro 'STM8_NUM_CORE_REGS' with the existing macro 'STM8_NUM_REGS'. While there: - drop the useless include of "hello.h". Change-Id: Iecd1a27f0630cdbbfd51033d34aa3d468aa63464 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8856 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de>
2025-04-19target: drop unused parameter to target_create()Antonio Borneo36-42/+40
The parameter Jim_Interp to the target API target_create() is not used by any target. Drop it. Change-Id: I67c492078a6c808db974505f9e297c45165f64d0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8831 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2025-04-19target: rewrite function target_configure() as COMMAND_HELPERAntonio Borneo1-209/+225
The function target_configure() is used by the commands 'target create', 'configure' and 'cget', already rewritten as COMMAND_HANDLER. Rewrite the common function as COMMAND_HELPER. While there: - fix the check on arguments, even if it should be coded better; - keep jimtcl code for target_type::target_jim_configure() and for rtos_create(); these would be rewritten later on. Change-Id: I7e5699ca6d124e34d3b2199714e3ce584bfcce80 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8829 Tested-by: jenkins
2025-04-19target: rewrite commands 'configure' and 'cget' as COMMAND_HANDLERAntonio Borneo1-15/+21
Rewrite only the command, but still use the old jimtcl specific code shared with 'target create'. Change-Id: Ie5e1c9eb237531121c2d143d1732cf281dfdc9ff Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8828 Tested-by: jenkins
2025-04-19target: rewrite command 'target create' as COMMAND_HANDLERAntonio Borneo1-82/+65
Rewrite only the command, but still use the old jimtcl specific code shared with 'configure' and 'cget'. Change-Id: I7cf220e494f0ebbf123f8075b1feb9251fd7f569 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8827 Tested-by: jenkins
2025-04-19target: rewrite command 'invoke-event' as COMMAND_HANDLERAntonio Borneo1-22/+18
The command shares with command 'target create' the struct jim_nvp nvp_target_event[] - Convert the 'struct jim_nvp' in 'struct nvp'. - Create an alias 'struct jim_nvp' to decouple the commands 'invoke-event' and 'target create', abusing the fact that the actual layout of the two struct's type is the same. This alias will be dropped in a following change. - Rewrite the command 'invoke-event' and the helper function target_event_name(). Change-Id: I537732fe4c08042cc02bcd0f72142254d7968fa6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8826 Tested-by: jenkins
2025-04-19target: don't free working areas during 'configure -chain-position'Antonio Borneo1-1/+0
Since commit ef1cfb23947b ("Duane Ellis: "target as an [tcl] object" feature.") merged in 2008, the commands: $target_name configure -chain-position ... target create ... -chain-position ... cause the allocated working area to be freed. There is no reason for this, it is probably caused by an incorrect copy/paste from the author. Drop the call to target_free_all_working_areas(). Change-Id: I61a9303afe7fee6953669218330635c0b965b20d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8825 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2025-04-07Merge up to 6834f022b96fb1c7f5829166578e01a0ac223cb0 from upstreamEvgeniy Naydanov13-173/+225
Change-Id: Idaef3f5911bde237bd47d1d921acc186a06ea8f8
2025-04-05target: remove events that are set to empty stringAntonio Borneo1-1/+11
Current code allows replacing the body of an existing event, but it doesn't provides a way to remove it. Replacing the event with an empty string makes the event still present and visible through $target_name eventlist The presence of empty events makes more complex checking for the event not set or set to empty. Remove the event when set to empty string. While there, add 'Jim_Length' to the list of allowed CamelCase symbols, avoiding the associated checkpatch error. Change-Id: I1ec2e1a71d298a0eba0b6863902645bcc6c4cb09 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8814 Tested-by: jenkins
2025-04-05target: use list for target eventsAntonio Borneo2-24/+26
To simplify removing an event when it's set to an empty string, switch event list from hardcoded simply linked list to helper's double linked list. While there, move the declaration of struct target_event_action in 'target.c' as it is not anymore visible outside. Change-Id: I799754c80055dc6d22db55aca483757e833714ff Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8813 Tested-by: jenkins
2025-04-05target: fix memory leak in handle_target_write_memory()Antonio Borneo1-0/+1
Commit f55ec6d44922 ("target: rewrite command 'write_memory' as COMMAND_HANDLER") adds a new return statement without freeing the allocated buffer. Add the needed free(). Fixes: f55ec6d44922 ("target: rewrite command 'write_memory' as COMMAND_HANDLER") Change-Id: I676d658118b32f4d7cc71eda3436bb52f1966cd8 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8822 Tested-by: jenkins
2025-03-31Merge pull request #1222 from sobuch/fix_maskisr_change_unrelated_mstatus_bitsEvgeniy Naydanov2-44/+27
target/riscv: only update mstatus.*ie bits with set_maskisr steponly
2025-03-29target: rewrite command 'get_reg' as COMMAND_HANDLERAntonio Borneo1-55/+26
Print one register per line. Repeated registers will be printed each time. While there, fix the 'usage' string. Change-Id: I4eb21696705bdf15cd2cb7a4a9caa41f9ffdbf64 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8583 Tested-by: jenkins Reviewed-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2025-03-29target/aarch64: Cleanup on exitAdrien Grassein1-0/+8
Restore target configuration on exit so that OpenOCD get correct values when restarting. Change-Id: I8cbba1fdae1d3c4a580197b7a97691443780ed06 Signed-off-by: Adrien Grassein <agrassein@nanoxplore.com> Signed-off-by: Adrien Charruel <acharruel@nanoxplore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8654 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-03-29target: drop last instances of 'target->cmd_name'Antonio Borneo4-16/+15
The helper function 'target_name()' or, better, the log functions 'LOG_TARGET_xxx(target, ...)' should be used in place of taking the target name directly from 'target->cmd_name'. Replace the remaining instances in the code. While there: - address some indentation, - drop trailing punctuation in log message, - replace one LOG WARNING with LOG_TARGET_WARNING. Change-Id: Ie6cf4c174ffe91b975c983e4697c735766267041 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8806 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de>
2025-03-29target/armv8: Handle instruction cache invalidateAdrien Grassein4-0/+68
Some armv8 target have separate i-cache and d-cache. The actual code only handles the flush of the d-cache. Change-Id: I61a223b43c71646bbbed8fa63825360c67700988 Signed-off-by: Adrien Grassein <agrassein@nanoxplore.com> Signed-off-by: Adrien Charruel <acharruel@nanoxplore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8655 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2025-03-29target: rewrite command 'write_memory' as COMMAND_HANDLERAntonio Borneo1-52/+38
While there: - drop the command name from the error messages; - check the returned value from Jim_GetWide() to detect incorrect numeric values. Change-Id: I399402ac11b6d459f1771e59e44210aef3e2a637 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8582 Tested-by: jenkins Reviewed-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2025-03-29target: read_memory: drop command name from error messagesAntonio Borneo1-4/+4
The error message should not report the command name as it should be already clear from the context. Change-Id: I219e31be808bf6ff1924ce60f3025fb48ed7b125 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8803 Tested-by: jenkins
2025-03-28Merge pull request #1235 from fk-sc/fk-sc/abstract-cmd-cacheEvgeniy Naydanov1-121/+154
target/riscv: implement abstract command cache
2025-03-25target/riscv: implement abstract command cache Implemented cache of ↵Farid Khaydari1-121/+154
unsupported abstract commands. It's purpose is to replace set of caching variables to one. So this commit provides one ac_not_supported_cache instead of abstract_read_csr_supported, abstract_write_csr_supported, abstract_read_fpr_supported, abstract_write_fpr_supported, has_aampostincrement. Dropped check for buggy aampostincrement Fixes #1232 Change-Id: I9690d9d79e3d1f593b63740b989074dcf0285637 Signed-off-by: Farid Khaydari <f.khaydari@syntacore.com>
2025-03-20Merge pull request #1240 from en-sc/en-sc/ebreak-cfg-updateEvgeniy Naydanov1-1/+4
target/riscv: avoid `config` modification on `jim_getopt_obj()` failure
2025-03-17Merge pull request #1221 from aap-sc/aap-sc/expose_csr_fixupEvgeniy Naydanov1-2/+2
fix expose_csr for CSR with address "0"
2025-03-17Merge pull request #1236 from en-sc/en-sc/from_upstreamEvgeniy Naydanov46-284/+303
Merge up to a168c634126e9e6bb95c6e68b2db5afbb099abf7 from upstream
2025-03-15target/armv8: regularly send keep_alive packet.Adrien Grassein1-0/+1
Flushing all d-cache may be a long operation. We need to send keep_alive regularly to keep the connection alive. If not done a warning is emitted. Change-Id: I52c3ee9a9f9b8a1dc0b8d5439e8b71212f56165a Signed-off-by: Adrien Grassein <agrassein@nanoxplore.com> Signed-off-by: Adrien Charruel <acharruel@nanoxplore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8659 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2025-03-15target/arm_adiv5: print DAP name if not foundMarc Schink1-1/+3
If a DAP is not found, include its name in the error message. Change-Id: Icffc52894a1c5573f938b1f3e3b53441167f085e Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/8636 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-03-14target/riscv: only restore mstatus.*ie bits in riscv_interrupts_restoreSamuel Obuch2-44/+27
When value of mstatus CSR changes while stepping with "set_maskisr steponly", OpenOCD should not write back the old value to mstatus when reenabling interrupts. Signed-off-by: Samuel Obuch <samuel.obuch@espressif.com>
2025-03-14target/riscv: avoid `config` modification on `jim_getopt_obj()` failureEvgeniy Naydanov1-1/+4
Currently, `jim_getopt_obj()` only fails if `goi->argc` is zero, Link: https://github.com/riscv-collab/riscv-openocd/blob/41a225460c3b9a6c1f61a0777f101ff009f56007/src/helper/jim-nvp.c#L174-L185 so the check at the start of `jim_configure_ebreak()` Link: https://github.com/riscv-collab/riscv-openocd/blob/41a225460c3b9a6c1f61a0777f101ff009f56007/src/target/riscv/riscv.c#L526-L530 guarantees that the call will succeed. However, the modification makes the code more robust and future-proof. Change-Id: Ic8c2e057a285bf679d26e21bda138a1d2ae5d5ce Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2025-03-14riscv-011: Don't trigger semihosting before the target is examinedJan Matyas1-2/+10
In riscv-011 target, the handle_halt() function, and thus also riscv_semihosting(), can get called from within examine() before the examination is actually complete! The chain of the function calls is: - examine() -> riscv011_poll() -> poll_target() -> handle_halt() -> riscv_semihosting() If the target is already halted due to a breakpoint (dcsr.cause = SWBP) at the time OpenOCD connects to it, semihosting will be attempted before completing the examination, and the examination will fail. This issue was observed on HiFive1 Rev A01. Hot-fix this by making shure that semihosting is not attempted before the target gets successfully examined. Change-Id: Iccfa0da35d47a430d8674131ebd2eb8e5e2922c0 Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
2025-03-10Merge pull request #1238 from en-sc/en-sc/abits-zeroEvgeniy Naydanov1-0/+5
src/target/riscv: error out of the `examine()` in case `abits` is zero
2025-03-09target/armv8: fix 128-bit register writesDaniel Goehring1-1/+2
Assert checking was recently added to the "buf_get_u64()" procedure for the buffer size argument. For 128-bit register writes, instead of calling "buf_get_u64()" with a 128-bit argument which fails the assert check, use two 64-bit calls. Change-Id: I32ddbdb7bbe68c43f3b0a27738537391a227b08c Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8801 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-03-09target/target: fix RTOS thread awareness supportDaniel Goehring1-13/+10
This prior patch replaces "LOG_xxx()" with "LOG_TARGET_xxx()" to indicate which target the message belongs to. commit 7f2db80ebc16 ("rtos/hwthread: Use LOG_TARGET_xxx()") To support this change for hardware thread awareness, the target command name needs to be established before calling the "target_configure()" routine. Change-Id: I0dc70c23b84e983a2ee694fb5b9d01758f5c84a3 Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8800 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-03-08target: fix wrap-around detection for read_memory/write_memoryParshintsev Anatoly1-12/+18
while at it change the order of checks for requested region sizes to get rid of potential overflow during multiplication. Change-Id: I97dac68e7024591cfd7abb70c8c62dff791298fe Signed-off-by: Parshintsev Anatoly <anatoly.parshintsev@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8572 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-03-07Merge pull request #1225 from ↵Evgeniy Naydanov7-161/+270
JanMatCodasip/jm-codasip/fix-datatypes-around-program Fix data types around opcodes.h and program.{c,h}
2025-03-07src/target/riscv: error out of the `examine()` in case `abits` is zeroEvgeniy Naydanov1-0/+5
The spec requires `abits` to be no less then 7 ( [3.1. Debug Module Interface (DMI)]): > The DMI uses between 7 and 32 address bits Commit a450a7d4966a19c48b2543810f5b8370af6383e5 ("Fix data types around batch.{c,h}") introduced a check that issues a warning if `abits` is less then 7. The reason it's a warning and not an error -- on Spike `abits` is 6. However, if the examination is to proceed when `abits` is zero, an assert in `get_dmi_scan_length()` will trigger when attempting to communicate over DMI. Link: https://github.com/JanMatCodasip/riscv-openocd/blob/a450a7d4966a19c48b2543810f5b8370af6383e5/src/target/riscv/batch.c#L25 It's impossible to communicate over DMI with `abits == 0`, so an error is returned instead of a warning in this case. Change-Id: Ice4622adccfc8304b37bc678253cc19d8ac1457e Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2025-03-07Merge pull request #1171 from lz-bro/handle-all-trigger-haltEvgeniy Naydanov2-0/+61
target/riscv: Fix SMP group is in inconsistent state
2025-03-07fix expose_csr for CSR with address "0"Parshintsev Anatoly1-2/+2
This change is a quick-and-dirty workaround for the problem when user wants to expose CSR with address "0" and instead of user-specified name "csr0" was used. The problem looks as follows: riscv013_reg_examine_all eventually calls init_cache_entry for all CSRs. init_cache_entry eventually results in a call to riscv_reg_gdb_regno_name. Then in case of non-standard CSRs we have the following logic: ``` // NULL when regno == 0, since names are not generated yet if (info->reg_names[regno]) return info->reg_names[regno] ... if (regno >= GDB_REGNO_CSR0 && regno <= GDB_REGNO_CSR4095) { // generate names for all exposed CSRs (the function // lazy-initializes all the required names) init_custom_csr_names(target); // And here we have an error, since we overwrite the name generated // by init_custom_csr_names info->reg_names[regno] = init_reg_name_with_prefix("csr", regno - GDB_REGNO_CSR0); ... ``` The error happens because when initially this function is called with regno = 0, the first condition false, so we have to go and generate all the names.
2025-03-05Merge up to a168c634126e9e6bb95c6e68b2db5afbb099abf7 from upstreamEvgeniy Naydanov46-284/+303
There was a bunch of conflicts due to commit 297844cf46c7de5faa9de1c4a9f223b505dc3e9c ("target: Use 'bool' data type in target_{step,resume}") Resolved by updating the corresponding data types throughout the codebase. Change-Id: I9574deeda754b2843b69b4afe80b293d4b357ddd Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2025-03-04target/riscv: Fix SMP group is in inconsistent stateliangzhen2-0/+61
If the harts are just in the process of halting due to being members of the halt group, we should wait until they finish halting, so that the true halt reason can be discovered (e.g. semihosting request, and then handled correctly).
2025-03-01target: algorithm: change reg_name to const in init_reg_param()Antonio Borneo2-3/+4
The function init_reg_param() initializes a struct where the pointer reg_name is assigned to a 'const char *'. Change the prototype of init_reg_param() to make also the reg_name parameter as 'const char *'. Change-Id: Ib999eaa5786ad24aa2a361070162c6f362784758 Reported-by: Marek Kraus <gamelaster@outlook.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8797 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Marek Kraus <gamelaster@outlook.com>
2025-02-28Clean up return type of riscv_progbuf_size() + relatedJan Matyas5-13/+11
SSIA Change-Id: I3e0b2fad84411c530f56cdbe33f3d8b4dbf81cf6 Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
2025-02-26riscv-011: Fix datatypes to correspond to opcodes.hJan Matyas1-16/+21
Callers of functions from opcodes.h need to be updated accordingly, too. Change-Id: Ic42156b2843be682bc1cf9c720b73687008a2aa6 Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
2025-02-26opcodes.h: Do not use casts in MIN_* and MAX_* macrosJan Matyas1-9/+9
This is to make it consistent with stdint.h. Change-Id: Ibba824dad431b3a1675700ad4cc15f3e39a187f7 Signed-off-by: Jan Matyas <jan.matyas@codasip.com>