@@ -613,11 +613,10 @@ def early_applicable(self):
613
613
return self .hart .instruction_hardware_breakpoint_count > 0
614
614
615
615
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 ()
621
620
622
621
self .gdb .command ("delete" )
623
622
self .gdb .hbreak ("rot13" )
@@ -630,8 +629,10 @@ def test(self):
630
629
self .gdb .b ("_exit" )
631
630
self .exit ()
632
631
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 )
635
636
def MCONTROL_DMODE (xlen ):
636
637
return 1 << ((xlen )- 5 )
637
638
def MCONTROL_MASKMAX (xlen ):
@@ -677,15 +678,18 @@ def early_applicable(self):
677
678
self .hart .instruction_hardware_breakpoint_count >= 1
678
679
679
680
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 ()
685
685
686
686
self .gdb .command ("delete" )
687
687
#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 )
689
693
tdata1 = set_field (tdata1 , MCONTROL_ACTION , MCONTROL_ACTION_DEBUG_MODE )
690
694
tdata1 = set_field (tdata1 , MCONTROL_MATCH , MCONTROL_MATCH_EQUAL )
691
695
tdata1 |= MCONTROL_M | MCONTROL_S | MCONTROL_U | MCONTROL_EXECUTE
@@ -697,7 +701,7 @@ def test(self):
697
701
if value != tselect :
698
702
raise TestNotApplicable
699
703
self .gdb .p (f"$tdata1=0x{ tdata1 :x} " )
700
- value = self .gdb .p ("$tselect " )
704
+ value = self .gdb .p ("$tdata1 " )
701
705
if value == tdata1 :
702
706
break
703
707
self .gdb .p ("$tdata1=0" )
@@ -710,6 +714,7 @@ def test(self):
710
714
self .gdb .p ("$pc" )
711
715
assertRegex (output , r"[bB]reakpoint" )
712
716
assertIn ("rot13 " , output )
717
+ self .gdb .stepi ()
713
718
self .gdb .p ("$tdata2=&crc32a" )
714
719
self .gdb .c ()
715
720
before = self .gdb .p ("$pc" )
@@ -1396,8 +1401,7 @@ def test(self):
1396
1401
1397
1402
class TriggerDmode (TriggerTest ):
1398
1403
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
1401
1405
1402
1406
def check_triggers (self , tdata1_lsbs , tdata2 ):
1403
1407
dmode = 1 << (self .hart .xlen - 5 )
0 commit comments