-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
target/riscv: new ebreak
controls
#1168
base: riscv
Are you sure you want to change the base?
Conversation
6b1faa6
to
ccb13a1
Compare
@JanMatCodasip, @MarekVCodasip ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the change looks all right - thank you.
I have finished my review and do not expect to have any further comments.
src/target/riscv/riscv.c
Outdated
{ | ||
struct riscv_private_config *pc = target->private_config; | ||
if (!pc) { | ||
pc = default_riscv_private_config(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an issue with private_config
deallocation in case of an error.
Please, see https://review.openocd.org/c/openocd/+/8637/comments/512687b3_e6274fb6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed by https://review.openocd.org/c/openocd/+/8642
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is somewhat minor and is not specific to this patch.
IMHO, the patch can be merged without the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree - no problem with merging this now.
* Deprecate `riscv set_ebreak*` commands. * Introduce RISC-V-sepecific `configure` parameter `-ebreak` instead. * Separate controls for VS and VU modes. Change-Id: I0ff88318dcb52af6923eb9f20f9d0c056ad09cf0 Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for addressing the suggestions so far.
I have noticed three more items, and shouldn't have more comments than that.
static uint64_t set_ebreakx_fields(uint64_t dcsr, const struct target *target) | ||
{ | ||
const struct riscv_private_config * const config = riscv_private_config(target); | ||
dcsr = set_field(dcsr, DCSR_EBREAKM, config->dcsr_ebreak_fields[RISCV_MODE_M]); | ||
dcsr = set_field(dcsr, DCSR_EBREAKS, config->dcsr_ebreak_fields[RISCV_MODE_S]); | ||
dcsr = set_field(dcsr, DCSR_EBREAKU, config->dcsr_ebreak_fields[RISCV_MODE_U]); | ||
dcsr = set_field(dcsr, DCSR_EBREAKH, 1); | ||
return dcsr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no ebreakh
field in register dcsr
anymore, so this looks like outdated code.
I believe that the other variant of the dcsr.ebreakX manipulation -- which is on line 1615 -- is the correct one.
I don't mind if this part is fixed in a separate pull request.
if (!buffer) | ||
len += snprintf(NULL, 0, format, separator, ctl, mode); | ||
else | ||
len += sprintf(buffer + len, format, separator, ctl, mode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detail but important for readability:
ctl
should be named something likepriv_mode
(because it is the RISC-V privilege mode)mode
should be named something likeebreak_config
,ebreak_behavior
, or similar
if (!buffer) | |
len += snprintf(NULL, 0, format, separator, ctl, mode); | |
else | |
len += sprintf(buffer + len, format, separator, ctl, mode); | |
if (!buffer) | |
len += snprintf(NULL, 0, format, separator, priv_mode, ebreak_config); | |
else | |
len += sprintf(buffer + len, format, separator, priv_mode, ebreak_config); |
{ .name = NULL, .value = RISCV_CFG_INVALID } | ||
}; | ||
|
||
static struct riscv_private_config *default_riscv_private_config(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you like:
static struct riscv_private_config *default_riscv_private_config(void) | |
static struct riscv_private_config *alloc_default_riscv_private_config(void) |
riscv set_ebreak*
commands.configure
parameter-ebreak
instead.Change-Id: I0ff88318dcb52af6923eb9f20f9d0c056ad09cf0