Browse Source

Enhance mode_match() functionality

The current version of mode_match() is based on the current privilege
level. This adds an explicit privilege and virtual mode parameters in
anticipation of an upcoming patch for matching trap triggers.
pull/1350/head
Atul Khare 3 years ago
parent
commit
31f5ede662
  1. 11
      riscv/triggers.cc
  2. 2
      riscv/triggers.h

11
riscv/triggers.cc

@ -56,15 +56,16 @@ void trigger_t::tdata3_write(processor_t * const proc, const reg_t val) noexcept
} }
bool trigger_t::common_match(processor_t * const proc) const noexcept { bool trigger_t::common_match(processor_t * const proc) const noexcept {
return mode_match(proc->get_state()) && textra_match(proc); auto state = proc->get_state();
return mode_match(state->prv, state->v) && textra_match(proc);
} }
bool trigger_t::mode_match(state_t * const state) const noexcept bool trigger_t::mode_match(reg_t prv, bool v) const noexcept
{ {
switch (state->prv) { switch (prv) {
case PRV_M: return m; case PRV_M: return m;
case PRV_S: return state->v ? vs : s; case PRV_S: return v ? vs : s;
case PRV_U: return state->v ? vu : u; case PRV_U: return v ? vu : u;
default: assert(false); default: assert(false);
} }
} }

2
riscv/triggers.h

@ -102,7 +102,7 @@ protected:
private: private:
unsigned legalize_mhselect(bool h_enabled) const noexcept; unsigned legalize_mhselect(bool h_enabled) const noexcept;
bool mode_match(state_t * const state) const noexcept; bool mode_match(reg_t prv, bool v) const noexcept;
bool textra_match(processor_t * const proc) const noexcept; bool textra_match(processor_t * const proc) const noexcept;
struct mhselect_interpretation { struct mhselect_interpretation {

Loading…
Cancel
Save