Merge pull request #995 from en-sc/en-sc/ctx-fix

target/riscv: cleanup `get_riscv_debug_reg_ctx()`
This commit is contained in:
Jan Matyas 2024-01-25 06:50:12 +01:00 committed by GitHub
commit f6776563bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -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;

View File

@ -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;
}