diff options
-rwxr-xr-x | debug/programs/entry.S | 12 | ||||
-rw-r--r-- | debug/targets.py | 3 | ||||
-rw-r--r-- | debug/testlib.py | 10 |
3 files changed, 23 insertions, 2 deletions
diff --git a/debug/programs/entry.S b/debug/programs/entry.S index 091efa4..09cad53 100755 --- a/debug/programs/entry.S +++ b/debug/programs/entry.S @@ -204,6 +204,18 @@ trap_entry: loop_forever: j loop_forever + .align 2 +precease: + // Loop a while so that OpenOCD might have confirmed the resume before the + // hart becomes unavailable. + li t1, 100000 +1: + addi t1, t1, -1 + bnez t1, 1b +cease: + .word 0x30500073 // cease + j loop_forever + // Fill the stack with data so we can see if it was overrun. .section .data .align 4 diff --git a/debug/targets.py b/debug/targets.py index b2ed01b..ddd39d5 100644 --- a/debug/targets.py +++ b/debug/targets.py @@ -50,6 +50,9 @@ class Hart: # is fine. system = None + # Supports the cease instruction, which causes a hart to become unavailable. + support_cease = False + def __init__(self, misa=None, system=None, link_script_path=None): if misa: self.misa = misa diff --git a/debug/testlib.py b/debug/testlib.py index 1559d2c..20264e9 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -1226,13 +1226,19 @@ class GdbTest(BaseTest): del self.gdb BaseTest.classTeardown(self) - def parkOtherHarts(self): + def parkOtherHarts(self, symbol=None): """Park harts besides the currently selected one in loop_forever().""" for hart in self.target.harts: # Park all harts that we're not using in a safe place. if hart != self.hart: self.gdb.select_hart(hart) - self.gdb.p("$pc=loop_forever") + if symbol is None: + if hart.support_cease: + self.gdb.p("$pc=cease") + else: + self.gdb.p("$pc=loop_forever") + else: + self.gdb.p(f"$pc={symbol}") self.gdb.select_hart(self.hart) |