diff --git a/riscv/processor.cc b/riscv/processor.cc index 80a47d93..7e50594e 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -497,8 +497,8 @@ void processor_t::take_trap(trap_t& t, reg_t epc) reg_t s = state.mstatus->read(); if ( extension_enabled(EXT_SMDBLTRP)) { - if (get_field(s, MSTATUS_MDT) || !nmie) { - // Critical error - Double trap in M-mode or trap when nmie is 0 + if (get_field(s, MSTATUS_MDT) && (!state.mnstatus || !nmie)) { + // Critical error - Double trap in M-mode when Smrnmi not implemented or nmie is 0 // RNMI is not modeled else double trap in M-mode would trap to // RNMI handler instead of leading to a critical error state.critical_error = 1; diff --git a/riscv/remote_bitbang.cc b/riscv/remote_bitbang.cc index 182b3713..32775f2a 100644 --- a/riscv/remote_bitbang.cc +++ b/riscv/remote_bitbang.cc @@ -184,3 +184,7 @@ void remote_bitbang_t::execute_commands() } } } + +bool remote_bitbang_t::is_client_connected() const{ + return client_fd != 0; +} \ No newline at end of file diff --git a/riscv/remote_bitbang.h b/riscv/remote_bitbang.h index b5b73bfd..e08d6458 100644 --- a/riscv/remote_bitbang.h +++ b/riscv/remote_bitbang.h @@ -15,6 +15,9 @@ public: // Do a bit of work. void tick(); + // Check if any client is connected + bool is_client_connected() const; + private: jtag_dtm_t *tap;