@@ -548,13 +548,17 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept {
548548 | (has_page ? MSTATUS_TVM : 0 )
549549 | (has_gva ? MSTATUS_GVA : 0 )
550550 | (has_mpv ? MSTATUS_MPV : 0 )
551+ | (proc->extension_enabled (EXT_SMDBLTRP) ? MSTATUS_MDT : 0 )
551552 | (proc->extension_enabled (EXT_ZICFILP) ? (MSTATUS_SPELP | MSTATUS_MPELP) : 0 )
552553 | (proc->extension_enabled (EXT_SSDBLTRP) ? SSTATUS_SDT : 0 )
553554 ;
554555
555556 const reg_t requested_mpp = proc->legalize_privilege (get_field (val, MSTATUS_MPP));
556557 const reg_t adjusted_val = set_field (val, MSTATUS_MPP, requested_mpp);
557- const reg_t new_mstatus = (read () & ~mask) | (adjusted_val & mask);
558+ reg_t new_mstatus = (read () & ~mask) | (adjusted_val & mask);
559+ if (new_mstatus & MSTATUS_MDT) {
560+ new_mstatus = new_mstatus & ~MSTATUS_MIE;
561+ }
558562 maybe_flush_tlb (new_mstatus);
559563 this ->val = adjust_sd (new_mstatus);
560564 return true ;
@@ -569,6 +573,7 @@ reg_t mstatus_csr_t::compute_mstatus_initial_value() const noexcept {
569573 | (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 )
570574 | (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 )
571575 | (proc->get_mmu ()->is_target_big_endian () ? big_endian_bits : 0 )
576+ | (proc->extension_enabled (EXT_SMDBLTRP) ? MSTATUS_MDT : 0 )
572577 | 0 ; // initial value for mstatus
573578}
574579
@@ -1343,6 +1348,8 @@ dcsr_csr_t::dcsr_csr_t(processor_t* const proc, const reg_t addr):
13431348 halt(false ),
13441349 v(false ),
13451350 cause(0 ),
1351+ ext_cause(0 ),
1352+ cetrig(0 ),
13461353 pelp(elp_t ::NO_LP_EXPECTED) {
13471354}
13481355
@@ -1363,6 +1370,9 @@ reg_t dcsr_csr_t::read() const noexcept {
13631370 result = set_field (result, DCSR_STOPCOUNT, 0 );
13641371 result = set_field (result, DCSR_STOPTIME, 0 );
13651372 result = set_field (result, DCSR_CAUSE, cause);
1373+ result = set_field (result, DCSR_EXTCAUSE, ext_cause);
1374+ if (proc->extension_enabled (EXT_SMDBLTRP))
1375+ result = set_field (result, DCSR_CETRIG, cetrig);
13661376 result = set_field (result, DCSR_STEP, step);
13671377 result = set_field (result, DCSR_PRV, prv);
13681378 result = set_field (result, CSR_DCSR_V, v);
@@ -1382,12 +1392,14 @@ bool dcsr_csr_t::unlogged_write(const reg_t val) noexcept {
13821392 v = proc->extension_enabled (' H' ) ? get_field (val, CSR_DCSR_V) : false ;
13831393 pelp = proc->extension_enabled (EXT_ZICFILP) ?
13841394 static_cast <elp_t >(get_field (val, DCSR_PELP)) : elp_t ::NO_LP_EXPECTED;
1395+ cetrig = proc->extension_enabled (EXT_SMDBLTRP) ? get_field (val, DCSR_CETRIG) : false ;
13851396 return true ;
13861397}
13871398
1388- void dcsr_csr_t::update_fields (const uint8_t cause, const reg_t prv,
1399+ void dcsr_csr_t::update_fields (const uint8_t cause, uint8_t ext_cause, const reg_t prv,
13891400 const bool v, const elp_t pelp) noexcept {
13901401 this ->cause = cause;
1402+ this ->ext_cause = ext_cause;
13911403 this ->prv = prv;
13921404 this ->v = v;
13931405 this ->pelp = pelp;
0 commit comments