@@ -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,10 @@ 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 )
635+ return 0x2 << ((xlen )- 4 )
635636def MCONTROL_DMODE (xlen ):
636637 return 1 << ((xlen )- 5 )
637638def MCONTROL_MASKMAX (xlen ):
@@ -677,15 +678,18 @@ def early_applicable(self):
677678 self .hart .instruction_hardware_breakpoint_count >= 1
678679
679680 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 ()
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 ()
685685
686686 self .gdb .command ("delete" )
687687 #self.gdb.hbreak("rot13")
688- tdata1 = MCONTROL_DMODE (self .hart .xlen )
688+ xlen = self .hart .xlen
689+ dmstatus = self .gdb .command ("monitor riscv dmi_read 0x11" )
690+ dmstatus_version = int (dmstatus , 16 ) & 0xf
691+ tdata1 = MCONTROL_TYPE (dmstatus_version , xlen )
692+ tdata1 |= MCONTROL_DMODE (xlen )
689693 tdata1 = set_field (tdata1 , MCONTROL_ACTION , MCONTROL_ACTION_DEBUG_MODE )
690694 tdata1 = set_field (tdata1 , MCONTROL_MATCH , MCONTROL_MATCH_EQUAL )
691695 tdata1 |= MCONTROL_M | MCONTROL_S | MCONTROL_U | MCONTROL_EXECUTE
@@ -697,7 +701,7 @@ def test(self):
697701 if value != tselect :
698702 raise TestNotApplicable
699703 self .gdb .p (f"$tdata1=0x{ tdata1 :x} " )
700- value = self .gdb .p ("$tselect " )
704+ value = self .gdb .p ("$tdata1 " )
701705 if value == tdata1 :
702706 break
703707 self .gdb .p ("$tdata1=0" )
@@ -710,6 +714,7 @@ def test(self):
710714 self .gdb .p ("$pc" )
711715 assertRegex (output , r"[bB]reakpoint" )
712716 assertIn ("rot13 " , output )
717+ self .gdb .stepi ()
713718 self .gdb .p ("$tdata2=&crc32a" )
714719 self .gdb .c ()
715720 before = self .gdb .p ("$pc" )
@@ -1396,8 +1401,7 @@ def test(self):
13961401
13971402class TriggerDmode (TriggerTest ):
13981403 def early_applicable (self ):
1399- return self .hart .honors_tdata1_hmode and \
1400- self .hart .instruction_hardware_breakpoint_count > 0
1404+ return self .hart .instruction_hardware_breakpoint_count > 0
14011405
14021406 def check_triggers (self , tdata1_lsbs , tdata2 ):
14031407 dmode = 1 << (self .hart .xlen - 5 )
0 commit comments