Skip to content

Commit fbb102e

Browse files
committed
Semihosting 2 of 3: Cosmetic improvements
Cosmetic, non-functional improvements in `riscv_semihosting_detect_magic_sequence()`. Change-Id: I935d3847749a02e4f579900a0971c30a5cc826b7 Signed-off-by: Jan Matyas <[email protected]>
1 parent c4ea6d1 commit fbb102e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/target/riscv/riscv_semihosting.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ static int riscv_semihosting_detect_magic_sequence(struct target *target,
5353

5454
/* Read three uncompressed instructions:
5555
* The previous, the current one (pointed to by PC) and the next one. */
56+
const target_addr_t sequence_start_address = pc - 4;
5657
for (int i = 0; i < 3; i++) {
5758
uint8_t buf[4];
5859

5960
/* Instruction memories may not support arbitrary read size.
6061
* Use any size that will work. */
61-
const target_addr_t address = (pc - 4) + 4 * i;
62+
const target_addr_t address = sequence_start_address + (4 * i);
6263
int result = riscv_read_by_any_size(target, address, 4, buf);
6364
if (result != ERROR_OK) {
6465
*sequence_found = false;
@@ -67,7 +68,7 @@ static int riscv_semihosting_detect_magic_sequence(struct target *target,
6768

6869
const uint32_t value = target_buffer_get_u32(target, buf);
6970

70-
LOG_TARGET_DEBUG(target, "compare 0x%08x from 0x%" PRIx64 " against 0x%08x",
71+
LOG_TARGET_DEBUG(target, "compare 0x%08" PRIx32 " from 0x%" PRIx64 " against 0x%08" PRIx32,
7172
value, address, magic[i]);
7273
if (value != magic[i]) {
7374
LOG_TARGET_DEBUG(target, "Not a RISC-V semihosting sequence");

0 commit comments

Comments
 (0)