static void commit_log_stash_privilege(state_t* state)
{
#ifdef RISCV_ENABLE_COMMITLOG
- state->last_inst_priv = get_field(state->mstatus, MSTATUS_PRV);
+ state->last_inst_priv = state->prv;
#endif
}
{
commit_log_stash_privilege(p->get_state());
reg_t npc = fetch.func(p, fetch.insn, pc);
- if (npc != PC_SERIALIZE) {
+ if (!invalid_pc(npc)) {
commit_log_print_insn(p->get_state(), pc, fetch.insn);
p->update_histogram(pc);
}
// fetch/decode/execute loop
void processor_t::step(size_t n)
{
- while (run && n > 0) {
+ if (state.dcsr.debugint && state.dcsr.cause == DCSR_CAUSE_NONE) {
+ enter_debug_mode(DCSR_CAUSE_DEBUGINT);
+ }
+
+ while (n > 0) {
size_t instret = 0;
reg_t pc = state.pc;
mmu_t* _mmu = mmu;
#define advance_pc() \
- if (unlikely(pc == PC_SERIALIZE)) { \
+ if (unlikely(invalid_pc(pc))) { \
+ switch (pc) { \
+ case PC_SERIALIZE_BEFORE: state.serialized = true; break; \
+ case PC_SERIALIZE_AFTER: instret++; break; \
+ default: abort(); \
+ } \
pc = state.pc; \
- state.serialized = true; \
break; \
} else { \
state.pc = pc; \
try
{
- check_timer();
take_interrupt();
if (unlikely(debug))
catch(trap_t& t)
{
take_trap(t, pc);
+ n = instret;
}
state.minstret += instret;