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

Commit d1f6de5

Browse files
committed
riscv_debug: Prepare for 64-bit DPC and address space in semihosting
1 parent c694bd6 commit d1f6de5

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/target/riscv_debug.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -906,11 +906,10 @@ bool riscv_csr_write(riscv_hart_s *const hart, const uint16_t reg, const void *c
906906
return true;
907907
}
908908

909-
static target_addr_t riscv_pc_read(riscv_hart_s *const hart)
909+
static target_addr64_t riscv_pc_read(riscv_hart_s *const hart)
910910
{
911-
target_addr_t data = 0;
911+
target_addr64_t data = 0U;
912912
riscv_csr_read(hart, RV_DPC, &data);
913-
//riscv32_reg_read(target, 32, &data, sizeof(data));
914913
return data;
915914
}
916915

@@ -1168,7 +1167,7 @@ static void riscv_halt_resume(target_s *target, const bool step)
11681167
dcsr_cause &= RV_DCSR_CAUSE_MASK;
11691168
if (dcsr_cause == RV_HALT_CAUSE_EBREAK) {
11701169
/* Read the instruction to resume on */
1171-
uint32_t program_counter = riscv_pc_read(hart);
1170+
target_addr64_t program_counter = riscv_pc_read(hart);
11721171
/* If it actually is a breakpoint instruction, update the program counter one past it. */
11731172
if (target_mem32_read32(target, program_counter) == RV_EBREAK) {
11741173
program_counter += 4U;
@@ -1204,9 +1203,9 @@ static target_halt_reason_e riscv_halt_poll(target_s *const target, target_addr6
12041203
switch (status) {
12051204
case RV_HALT_CAUSE_EBREAK: {
12061205
/* If we've hit a programmed breakpoint, check for semihosting call. */
1207-
const target_addr_t program_counter = riscv_pc_read(hart);
1206+
const target_addr64_t program_counter = riscv_pc_read(hart);
12081207
uint32_t instructions[3] = {0};
1209-
target_mem32_read(target, &instructions, program_counter - 4U, 12);
1208+
target_mem64_read(target, &instructions, program_counter - 4U, sizeof(instructions));
12101209
/* A semihosting call is three consecutive uncompressed instructions: slli zero, zero 0x1f; ebreak, srai zero, zero, 7. */
12111210
if (instructions[0] == RV_ENTRY_NOP && instructions[1] == RV_EBREAK && instructions[2] == RV_EXIT_NOP) {
12121211
if (riscv_hostio_request(target))

0 commit comments

Comments
 (0)