Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit eea215d

Browse files
committed
riscv_debug: Bypass target_reg_read() indirection in semihosting, use 64-bit
1 parent 1aa5e4a commit eea215d

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/target/riscv_debug.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -919,16 +919,17 @@ static target_addr64_t riscv_pc_read(riscv_hart_s *const hart)
919919
static bool riscv_hostio_request(target_s *const target)
920920
{
921921
/* Read out syscall number from a0/x10 and first argument from a1/x11 */
922-
uint32_t syscall = 0U;
923-
target_reg_read(target, RV_GPR_A0 - RV_GPR_BASE, &syscall, sizeof(syscall));
924-
uint32_t a1 = 0U;
925-
target_reg_read(target, RV_GPR_A1 - RV_GPR_BASE, &a1, sizeof(a1));
922+
riscv_hart_s *const hart = riscv_hart_struct(target);
923+
uint64_t syscall = 0U;
924+
riscv_csr_read(hart, RV_GPR_A0, &syscall);
925+
uint64_t a1 = 0U;
926+
riscv_csr_read(hart, RV_GPR_A1, &a1);
926927

927928
/* Hand off to the main semihosting implementation */
928929
const int32_t result = semihosting_request(target, syscall, a1);
929930

930931
/* Write the result back to the target */
931-
target_reg_write(target, RV_GPR_A0 - RV_GPR_BASE, &result, sizeof(result));
932+
riscv_csr_write(hart, RV_GPR_A0, &result);
932933
/* Return if the request was in any way interrupted */
933934
return target->tc->interrupted;
934935
}

0 commit comments

Comments
 (0)