aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtul Khare <atulkhare@rivosinc.com>2023-05-17 12:40:01 -0700
committerAtul Khare <atulkhare@rivosinc.com>2023-05-17 12:59:45 -0700
commitbb631e660fcb5ad4836b1f7c33db5c0a903272c1 (patch)
tree2621ea3351504737268a2edbdbc4d99233850562
parent7ad4123ade75475811119a371251825bed39bb1a (diff)
downloadspike-bb631e660fcb5ad4836b1f7c33db5c0a903272c1.zip
spike-bb631e660fcb5ad4836b1f7c33db5c0a903272c1.tar.gz
spike-bb631e660fcb5ad4836b1f7c33db5c0a903272c1.tar.bz2
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.
-rw-r--r--riscv/triggers.cc11
-rw-r--r--riscv/triggers.h2
2 files changed, 7 insertions, 6 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc
index 86dcc81..51dcf18 100644
--- a/riscv/triggers.cc
+++ b/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 {
- 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_S: return state->v ? vs : s;
- case PRV_U: return state->v ? vu : u;
+ case PRV_S: return v ? vs : s;
+ case PRV_U: return v ? vu : u;
default: assert(false);
}
}
diff --git a/riscv/triggers.h b/riscv/triggers.h
index aeda4d5..94e7e5c 100644
--- a/riscv/triggers.h
+++ b/riscv/triggers.h
@@ -102,7 +102,7 @@ protected:
private:
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;
struct mhselect_interpretation {