@@ -613,11 +613,10 @@ def early_applicable(self):
613613 return self .hart .instruction_hardware_breakpoint_count > 0
614614
615615 def test (self ):
616- if not self .hart .honors_tdata1_hmode :
617- # Run to main before setting the breakpoint, because startup code
618- # will otherwise clear the trigger that we set.
619- self .gdb .b ("main" )
620- self .gdb .c ()
616+ # Run to main before setting the breakpoint, because startup code
617+ # will otherwise clear the trigger that we set.
618+ self .gdb .b ("main" )
619+ self .gdb .c ()
621620
622621 self .gdb .command ("delete" )
623622 self .gdb .hbreak ("rot13" )
@@ -630,8 +629,9 @@ def test(self):
630629 self .gdb .b ("_exit" )
631630 self .exit ()
632631
633- def MCONTROL_TYPE (xlen ):
634- return 0xf << ((xlen )- 4 )
632+ def MCONTROL_TYPE (version , xlen ):
633+ if version == 0x3 :
634+ return 0x6 << ((xlen )- 4 )
635635def MCONTROL_DMODE (xlen ):
636636 return 1 << ((xlen )- 5 )
637637def MCONTROL_MASKMAX (xlen ):
@@ -677,15 +677,18 @@ def early_applicable(self):
677677 self .hart .instruction_hardware_breakpoint_count >= 1
678678
679679 def test (self ):
680- if not self .hart .honors_tdata1_hmode :
681- # Run to main before setting the breakpoint, because startup code
682- # will otherwise clear the trigger that we set.
683- self .gdb .b ("main" )
684- self .gdb .c ()
680+ # Run to main before setting the breakpoint, because startup code
681+ # will otherwise clear the trigger that we set.
682+ self .gdb .b ("main" )
683+ self .gdb .c ()
685684
686685 self .gdb .command ("delete" )
687686 #self.gdb.hbreak("rot13")
688- tdata1 = MCONTROL_DMODE (self .hart .xlen )
687+ xlen = self .hart .xlen
688+ dmstatus = self .gdb .command ("monitor riscv dmi_read 0x11" )
689+ dmstatus_version = int (dmstatus , 16 ) & 0xf
690+ tdata1 = MCONTROL_TYPE (dmstatus_version , xlen )
691+ tdata1 |= MCONTROL_DMODE (xlen )
689692 tdata1 = set_field (tdata1 , MCONTROL_ACTION , MCONTROL_ACTION_DEBUG_MODE )
690693 tdata1 = set_field (tdata1 , MCONTROL_MATCH , MCONTROL_MATCH_EQUAL )
691694 tdata1 |= MCONTROL_M | MCONTROL_S | MCONTROL_U | MCONTROL_EXECUTE
@@ -697,7 +700,7 @@ def test(self):
697700 if value != tselect :
698701 raise TestNotApplicable
699702 self .gdb .p (f"$tdata1=0x{ tdata1 :x} " )
700- value = self .gdb .p ("$tselect " )
703+ value = self .gdb .p ("$tdata1 " )
701704 if value == tdata1 :
702705 break
703706 self .gdb .p ("$tdata1=0" )
@@ -710,6 +713,7 @@ def test(self):
710713 self .gdb .p ("$pc" )
711714 assertRegex (output , r"[bB]reakpoint" )
712715 assertIn ("rot13 " , output )
716+ self .gdb .stepi ()
713717 self .gdb .p ("$tdata2=&crc32a" )
714718 self .gdb .c ()
715719 before = self .gdb .p ("$pc" )
@@ -1396,8 +1400,7 @@ def test(self):
13961400
13971401class TriggerDmode (TriggerTest ):
13981402 def early_applicable (self ):
1399- return self .hart .honors_tdata1_hmode and \
1400- self .hart .instruction_hardware_breakpoint_count > 0
1403+ return self .hart .instruction_hardware_breakpoint_count > 0
14011404
14021405 def check_triggers (self , tdata1_lsbs , tdata2 ):
14031406 dmode = 1 << (self .hart .xlen - 5 )
0 commit comments