@@ -505,12 +505,16 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept {
505
505
| (has_page ? MSTATUS_TVM : 0 )
506
506
| (has_gva ? MSTATUS_GVA : 0 )
507
507
| (has_mpv ? MSTATUS_MPV : 0 )
508
+ | (proc->extension_enabled (EXT_SMDBLTRP) ? MSTATUS_MDT : 0 )
508
509
| (proc->extension_enabled (EXT_ZICFILP) ? (MSTATUS_SPELP | MSTATUS_MPELP) : 0 )
509
510
;
510
511
511
512
const reg_t requested_mpp = proc->legalize_privilege (get_field (val, MSTATUS_MPP));
512
513
const reg_t adjusted_val = set_field (val, MSTATUS_MPP, requested_mpp);
513
- const reg_t new_mstatus = (read () & ~mask) | (adjusted_val & mask);
514
+ reg_t new_mstatus = (read () & ~mask) | (adjusted_val & mask);
515
+ if (new_mstatus & MSTATUS_MDT) {
516
+ new_mstatus = new_mstatus & ~MSTATUS_MIE;
517
+ }
514
518
maybe_flush_tlb (new_mstatus);
515
519
this ->val = adjust_sd (new_mstatus);
516
520
return true ;
@@ -525,6 +529,7 @@ reg_t mstatus_csr_t::compute_mstatus_initial_value() const noexcept {
525
529
| (proc->extension_enabled_const (' U' ) && (proc->get_const_xlen () != 32 ) ? set_field ((reg_t )0 , MSTATUS_UXL, xlen_to_uxl (proc->get_const_xlen ())) : 0 )
526
530
| (proc->extension_enabled_const (' S' ) && (proc->get_const_xlen () != 32 ) ? set_field ((reg_t )0 , MSTATUS_SXL, xlen_to_uxl (proc->get_const_xlen ())) : 0 )
527
531
| (proc->get_mmu ()->is_target_big_endian () ? big_endian_bits : 0 )
532
+ | (proc->extension_enabled (EXT_SMDBLTRP) ? MSTATUS_MDT : 0 )
528
533
| 0 ; // initial value for mstatus
529
534
}
530
535
@@ -1295,6 +1300,8 @@ dcsr_csr_t::dcsr_csr_t(processor_t* const proc, const reg_t addr):
1295
1300
halt(false ),
1296
1301
v(false ),
1297
1302
cause(0 ),
1303
+ ext_cause(0 ),
1304
+ cetrig(0 ),
1298
1305
pelp(elp_t ::NO_LP_EXPECTED) {
1299
1306
}
1300
1307
@@ -1315,6 +1322,9 @@ reg_t dcsr_csr_t::read() const noexcept {
1315
1322
result = set_field (result, DCSR_STOPCOUNT, 0 );
1316
1323
result = set_field (result, DCSR_STOPTIME, 0 );
1317
1324
result = set_field (result, DCSR_CAUSE, cause);
1325
+ result = set_field (result, DCSR_EXTCAUSE, ext_cause);
1326
+ if (proc->extension_enabled (EXT_SMDBLTRP))
1327
+ result = set_field (result, DCSR_CETRIG, cetrig);
1318
1328
result = set_field (result, DCSR_STEP, step);
1319
1329
result = set_field (result, DCSR_PRV, prv);
1320
1330
result = set_field (result, CSR_DCSR_V, v);
@@ -1335,12 +1345,14 @@ bool dcsr_csr_t::unlogged_write(const reg_t val) noexcept {
1335
1345
v = proc->extension_enabled (' H' ) ? get_field (val, CSR_DCSR_V) : false ;
1336
1346
pelp = proc->extension_enabled (EXT_ZICFILP) ?
1337
1347
static_cast <elp_t >(get_field (val, DCSR_PELP)) : elp_t ::NO_LP_EXPECTED;
1348
+ cetrig = proc->extension_enabled (EXT_SMDBLTRP) ? get_field (val, DCSR_CETRIG) : false ;
1338
1349
return true ;
1339
1350
}
1340
1351
1341
- void dcsr_csr_t::update_fields (const uint8_t cause, const reg_t prv,
1352
+ void dcsr_csr_t::update_fields (const uint8_t cause, uint8_t ext_cause, const reg_t prv,
1342
1353
const bool v, const elp_t pelp) noexcept {
1343
1354
this ->cause = cause;
1355
+ this ->ext_cause = ext_cause;
1344
1356
this ->prv = prv;
1345
1357
this ->v = v;
1346
1358
this ->pelp = pelp;
0 commit comments