Skip to content
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

Open
wants to merge 1 commit into
base: riscv
Choose a base branch
from

Conversation

en-sc
Copy link
Collaborator

@en-sc en-sc commented Nov 14, 2024

  • Deprecate riscv set_ebreak* commands.
  • Introduce RISC-V-sepecific configure parameter -ebreak instead.
  • Separate controls for VS and VU modes.

Change-Id: I0ff88318dcb52af6923eb9f20f9d0c056ad09cf0

@en-sc en-sc force-pushed the en-sc/ebreak branch 2 times, most recently from 6b1faa6 to ccb13a1 Compare November 14, 2024 15:51
@en-sc
Copy link
Collaborator Author

en-sc commented Nov 26, 2024

@JanMatCodasip, @MarekVCodasip ping

Copy link
Collaborator

@JanMatCodasip JanMatCodasip left a 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.h Outdated Show resolved Hide resolved
src/target/riscv/riscv.h Outdated Show resolved Hide resolved
src/target/riscv/riscv.h Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Outdated Show resolved Hide resolved
src/target/riscv/riscv.c Outdated Show resolved Hide resolved
{
struct riscv_private_config *pc = target->private_config;
if (!pc) {
pc = default_riscv_private_config();
Copy link
Collaborator Author

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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>
Copy link
Collaborator

@JanMatCodasip JanMatCodasip left a 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.

Comment on lines +1077 to +1085
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;
}
Copy link
Collaborator

@JanMatCodasip JanMatCodasip Dec 12, 2024

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.

Comment on lines +558 to +561
if (!buffer)
len += snprintf(NULL, 0, format, separator, ctl, mode);
else
len += sprintf(buffer + len, format, separator, ctl, mode);
Copy link
Collaborator

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 like priv_mode (because it is the RISC-V privilege mode)
  • mode should be named something like ebreak_config, ebreak_behavior, or similar
Suggested change
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you like:

Suggested change
static struct riscv_private_config *default_riscv_private_config(void)
static struct riscv_private_config *alloc_default_riscv_private_config(void)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants