Skip to content

Commit

Permalink
Merge pull request #3353 from chipsalliance/mergify/bp/master/pr-3347
Browse files Browse the repository at this point in the history
Update debug_rom source to use CSR_DSCRATCH0 (backport #3347)
  • Loading branch information
jerryz123 authored May 10, 2023
2 parents c7ae771 + 9387ed2 commit 0ecf506
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions scripts/debug_rom/debug_rom.S
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ _entry:
// This fence is required because the execution may have written something
// into the Abstract Data or Program Buffer registers.
fence
csrw CSR_DSCRATCH, s0 // Save s0 to allow signaling MHARTID
csrw CSR_DSCRATCH0, s0 // Save s0 to allow signaling MHARTID

// We continue to let the hart know that we are halted in order that
// a DM which was reset is still made aware that a hart is halted.
Expand All @@ -49,7 +49,7 @@ entry_loop:
andi s0, s0, (1 << FLAG_GO)
beqz s0, _resume // If GO is clear at this point, RESUME must be set.

csrr s0, CSR_DSCRATCH // Restore s0 here
csrr s0, CSR_DSCRATCH0 // Restore s0 here
sw zero, GOING(zero) // When debug module sees this write, the GO flag is reset.
jalr zero, zero, %lo(whereto) // Rocket-Chip has a specific hack which is that jalr in
// Debug Mode will flush the I-Cache. We need that so that the
Expand All @@ -58,7 +58,7 @@ entry_loop:
_resume:
csrr s0, CSR_MHARTID
sw s0, RESUMING(zero) // When Debug Module sees this write, the RESUME flag is reset.
csrr s0, CSR_DSCRATCH // Restore s0
csrr s0, CSR_DSCRATCH0 // Restore s0
dret

_exception:
Expand Down
8 changes: 4 additions & 4 deletions scripts/debug_rom/debug_rom_nonzero.S
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "riscv-pk/encoding.h"

#ifndef CSR_DSCRATCH1
#define CSR_DSCRATCH1 (CSR_DSCRATCH + 1)
#define CSR_DSCRATCH1 (CSR_DSCRATCH0 + 1)
#endif

// These are implementation-specific addresses in the Debug Module, relative to entry
Expand Down Expand Up @@ -39,7 +39,7 @@ _entry:
// This fence is required because the execution may have written something
// into the Abstract Data or Program Buffer registers.
fence
csrw CSR_DSCRATCH, s0 // Save s0 to allow signaling MHARTID
csrw CSR_DSCRATCH0, s0 // Save s0 to allow signaling MHARTID
la s1, entry // s1 = base (0x800 into debug region)

// We continue to let the hart know that we are halted in order that
Expand All @@ -57,7 +57,7 @@ entry_loop:
andi s0, s0, (1 << FLAG_GO)
beqz s0, _resume // If GO is clear at this point, RESUME must be set.

csrr s0, CSR_DSCRATCH // Restore s0 here
csrr s0, CSR_DSCRATCH0 // Restore s0 here

//TODO: 0x48 is a hack for (icache-entry) constant
jalr zero, 0x48(s1) // Rocket-Chip has a specific hack which is that jalr in
Expand All @@ -72,7 +72,7 @@ icache:
_resume:
csrr s0, CSR_MHARTID
sw s0, RESUMING(s1) // When Debug Module sees this write, the RESUME flag is reset.
csrr s0, CSR_DSCRATCH // Restore s0
csrr s0, CSR_DSCRATCH0 // Restore s0
csrr s1, CSR_DSCRATCH1 // Restore s1
dret

Expand Down

0 comments on commit 0ecf506

Please sign in to comment.