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

RISC-V Semihosting 2 of 3: Refactor magic sequence detection #1199

Open
wants to merge 3 commits into
base: riscv
Choose a base branch
from

Conversation

JanMatCodasip
Copy link
Collaborator

Refactor (clean up) the code in riscv_semihosting.c by moving
the magic sequence detection to its own function.

Variable `target->semihosting` is always initialized
in risv_init_target() to a non-NULL value.

For that reason, checks like `if (target->semihosting)`
are redundant (dead code).

Remove them to not confuse code readers. Replace them by assertions.

Change-Id: I85ef52300e240cfcb0119db6169993bc4767de8f
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
Refactor (clean up) the code in riscv_semihosting.c by moving
the magic sequence detection to its own function.

Change-Id: I3a3ce991336ceeeff023d459d0e28558059554e0
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
@JanMatCodasip JanMatCodasip changed the title Semihosting 2 of 3: Refactor magic sequence detection RISC-V Semihosting 2 of 3: Refactor magic sequence detection Jan 7, 2025
@JanMatCodasip
Copy link
Collaborator Author

JanMatCodasip commented Jan 7, 2025

Note: This MR is built on top of #1198.

Cosmetic, non-functional improvements
in `riscv_semihosting_detect_magic_sequence()`.

Change-Id: I935d3847749a02e4f579900a0971c30a5cc826b7
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
@JanMatCodasip JanMatCodasip requested a review from en-sc January 8, 2025 06:50
return SEMIHOSTING_NONE;
}
if (!sequence_found) {
LOG_TARGET_DEBUG(target, " -> NONE (no magic)");
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe move this printout inside riscv_semihosting_detect_magic_sequence?

		if (result != ERROR_OK) {
			*sequence_found = false;
			return result;
		}

Having context-dependent printout like this is somewhat confusing.

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