diff options
-rw-r--r-- | riscv/execute.cc | 12 | ||||
-rw-r--r-- | riscv/processor.cc | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/riscv/execute.cc b/riscv/execute.cc index c922602..cd6ae1a 100644 --- a/riscv/execute.cc +++ b/riscv/execute.cc @@ -203,7 +203,7 @@ static inline reg_t execute_insn_logged(processor_t* p, reg_t pc, insn_fetch_t f bool processor_t::slow_path() { return debug || state.single_step != state.STEP_NONE || state.debug_mode || - log_commits_enabled || histogram_enabled; + log_commits_enabled || histogram_enabled || in_wfi; } // fetch/decode/execute loop @@ -242,10 +242,6 @@ void processor_t::step(size_t n) try { take_pending_interrupt(); - if (unlikely(in_wfi)) { - // No unmasked pending interrupt, so remain in wfi - throw wait_for_interrupt_t(); - } if (unlikely(slow_path())) { @@ -265,6 +261,12 @@ void processor_t::step(size_t n) state.single_step = state.STEP_STEPPED; } + // debug mode wfis must nop + if (unlikely(in_wfi && !state.debug_mode)) { + throw wait_for_interrupt_t(); + } + + in_wfi = false; insn_fetch_t fetch = mmu->load_insn(pc); if (debug && !state.serialized) disasm(fetch.insn); diff --git a/riscv/processor.cc b/riscv/processor.cc index 666884f..c3c5d8f 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -537,6 +537,7 @@ void processor_t::reset() state.dcsr->halt = halt_on_reset; halt_on_reset = false; VU.reset(); + in_wfi = false; if (n_pmp > 0) { // For backwards compatibility with software that is unaware of PMP, @@ -744,6 +745,7 @@ void processor_t::enter_debug_mode(uint8_t cause) set_privilege(PRV_M); state.dpc->write(state.pc); state.pc = DEBUG_ROM_ENTRY; + in_wfi = false; } void processor_t::debug_output_log(std::stringstream *s) |