diff options
author | Jan Matyas <50193733+JanMatCodasip@users.noreply.github.com> | 2024-01-25 06:50:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-25 06:50:12 +0100 |
commit | f6776563bddf0f07560ccc5093fe8cf2c705134b (patch) | |
tree | 8bce3b62e224bb218e45f53462ddfd93b202d869 /src/target | |
parent | 78a719fad3ed151dd525dbcc2e2ea7b3140e142e (diff) | |
parent | cd07c4447b5a3b8f8b3a695d16f253c1c949c0f1 (diff) | |
download | riscv-openocd-f6776563bddf0f07560ccc5093fe8cf2c705134b.zip riscv-openocd-f6776563bddf0f07560ccc5093fe8cf2c705134b.tar.gz riscv-openocd-f6776563bddf0f07560ccc5093fe8cf2c705134b.tar.bz2 |
Merge pull request #995 from en-sc/en-sc/ctx-fix
target/riscv: cleanup `get_riscv_debug_reg_ctx()`
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/riscv/riscv-013.c | 12 | ||||
-rw-r--r-- | src/target/target.h | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index b2d68b2..423a043 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -280,13 +280,17 @@ static dm013_info_t *get_dm(struct target *target) return dm; } -static riscv_debug_reg_ctx_t get_riscv_debug_reg_ctx(struct target *target) +static riscv_debug_reg_ctx_t get_riscv_debug_reg_ctx(const struct target *target) { - RISCV_INFO(r); + if (!target_was_examined(target)) { + const riscv_debug_reg_ctx_t default_context = {0}; + return default_context; + } + RISCV013_INFO(info); const riscv_debug_reg_ctx_t context = { - .XLEN = { .value = r->xlen, .is_set = true }, - .DXLEN = { .value = r->xlen, .is_set = true }, + .XLEN = { .value = riscv_xlen(target), .is_set = true }, + .DXLEN = { .value = riscv_xlen(target), .is_set = true }, .abits = { .value = info->abits, .is_set = true }, }; return context; diff --git a/src/target/target.h b/src/target/target.h index 975561b..8b50dcc 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -438,7 +438,7 @@ const char *target_type_name(struct target *target); int target_examine_one(struct target *target); /** @returns @c true if target_set_examined() has been called. */ -static inline bool target_was_examined(struct target *target) +static inline bool target_was_examined(const struct target *target) { return target->examined; } |