diff options
author | Atish Patra <atish.patra@wdc.com> | 2021-07-10 09:18:14 -0700 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-07-11 10:38:23 +0530 |
commit | 764a17d852a8cc80050016a6e2ccdcaddd43f68c (patch) | |
tree | 03db9a920bfd843301af4c7eecac02bb76921eb1 /lib/sbi/sbi_trap.c | |
parent | 37f9b0f2f265b2f312d974fb8d100b85b3faf94f (diff) |
lib: sbi: Implement firmware counters
RISC-V SBI v0.3 specification defines a set of firmware events that can
provide additional information about the current firmware context. All
of the firmware event monitoring are enabled now. The firmware
events must be defined as raw perf event with MSB set as specified in the
specification.
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_trap.c')
-rw-r--r-- | lib/sbi/sbi_trap.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index 1ba6490..5781fea 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -16,6 +16,7 @@ #include <sbi/sbi_illegal_insn.h> #include <sbi/sbi_ipi.h> #include <sbi/sbi_misaligned_ldst.h> +#include <sbi/sbi_pmu.h> #include <sbi/sbi_scratch.h> #include <sbi/sbi_timer.h> #include <sbi/sbi_trap.h> @@ -257,6 +258,12 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) rc = sbi_ecall_handler(regs); msg = "ecall handler failed"; break; + case CAUSE_LOAD_ACCESS: + sbi_pmu_ctr_incr_fw(SBI_PMU_FW_ACCESS_LOAD); + break; + case CAUSE_STORE_ACCESS: + sbi_pmu_ctr_incr_fw(SBI_PMU_FW_ACCESS_STORE); + break; default: /* If the trap came from S or U mode, redirect it there */ trap.epc = regs->mepc; |