@@ -199,6 +199,14 @@ static void decode_dmi(char *text, unsigned address, unsigned data)
199199 uint64_t mask ;
200200 const char * name ;
201201 } description [] = {
202+ { DMI_DMCONTROL , DMI_DMCONTROL_HALTREQ , "haltreq" },
203+ { DMI_DMCONTROL , DMI_DMCONTROL_RESUMEREQ , "resumereq" },
204+ { DMI_DMCONTROL , DMI_DMCONTROL_HARTRESET , "hartreset" },
205+ { DMI_DMCONTROL , DMI_DMCONTROL_HASEL , "hasel" },
206+ { DMI_DMCONTROL , DMI_DMCONTROL_HARTSEL , "hartsel" },
207+ { DMI_DMCONTROL , DMI_DMCONTROL_NDMRESET , "ndmreset" },
208+ { DMI_DMCONTROL , DMI_DMCONTROL_DMACTIVE , "dmactive" },
209+
202210 { DMI_DMSTATUS , DMI_DMSTATUS_ALLRESUMEACK , "allresumeack" },
203211 { DMI_DMSTATUS , DMI_DMSTATUS_ANYRESUMEACK , "anyresumeack" },
204212 { DMI_DMSTATUS , DMI_DMSTATUS_ALLNONEXISTENT , "allnonexistent" },
@@ -1874,7 +1882,16 @@ void riscv013_reset_current_hart(struct target *target)
18741882 control = set_field (control , DMI_DMCONTROL_NDMRESET , 0 );
18751883 dmi_write (target , DMI_DMCONTROL , control );
18761884
1877- while (get_field (dmi_read (target , DMI_DMSTATUS ), DMI_DMSTATUS_ALLHALTED ) == 0 );
1885+ for (unsigned i = 0 ; i < 256 ; i ++ ) {
1886+ uint32_t dmstatus = dmi_read (target , DMI_DMSTATUS );
1887+ if (get_field (dmstatus , DMI_DMSTATUS_ALLHALTED )) {
1888+ break ;
1889+ }
1890+ if (i == 255 ) {
1891+ LOG_ERROR ("Hart didn't halt coming out of reset; dmstatus=0x%x" ,
1892+ dmstatus );
1893+ }
1894+ }
18781895
18791896 control = set_field (control , DMI_DMCONTROL_HALTREQ , 0 );
18801897 dmi_write (target , DMI_DMCONTROL , control );
0 commit comments