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

Commit c3dd766

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

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
@@ -904,11 +904,10 @@ bool riscv_csr_write(riscv_hart_s *const hart, const uint16_t reg, const void *c
904904
return true;
905905
}
906906

907-
static target_addr_t riscv_pc_read(riscv_hart_s *const hart)
907+
static target_addr64_t riscv_pc_read(riscv_hart_s *const hart)
908908
{
909-
target_addr_t data = 0;
909+
target_addr64_t data = 0;
910910
riscv_csr_read(hart, RV_DPC, &data);
911-
//riscv32_reg_read(target, 32, &data, sizeof(data));
912911
return data;
913912
}
914913

@@ -1147,7 +1146,7 @@ static void riscv_halt_resume(target_s *target, const bool step)
11471146
dcsr_cause &= RV_DCSR_CAUSE_MASK;
11481147
if (dcsr_cause == RV_HALT_CAUSE_EBREAK) {
11491148
/* Read the instruction to resume on */
1150-
uint32_t program_counter = riscv_pc_read(hart);
1149+
target_addr64_t program_counter = riscv_pc_read(hart);
11511150
/* If it actually is a breakpoint instruction, update the program counter one past it. */
11521151
if (target_mem32_read32(target, program_counter) == RV_EBREAK) {
11531152
program_counter += 4U;
@@ -1183,9 +1182,9 @@ static target_halt_reason_e riscv_halt_poll(target_s *const target, target_addr6
11831182
switch (status) {
11841183
case RV_HALT_CAUSE_EBREAK: {
11851184
/* If we've hit a programmed breakpoint, check for semihosting call. */
1186-
const target_addr_t program_counter = riscv_pc_read(hart);
1185+
const target_addr64_t program_counter = riscv_pc_read(hart);
11871186
uint32_t instructions[3] = {0};
1188-
target_mem32_read(target, &instructions, program_counter - 4U, 12);
1187+
target_mem64_read(target, &instructions, program_counter - 4U, sizeof(instructions));
11891188
/* A semihosting call is three consecutive uncompressed instructions: slli zero, zero 0x1f; ebreak, srai zero, zero, 7. */
11901189
if (instructions[0] == RV_ENTRY_NOP && instructions[1] == RV_EBREAK && instructions[2] == RV_EXIT_NOP) {
11911190
if (riscv_hostio_request(target))

0 commit comments

Comments
 (0)