From a154c42a9ba0ffca021825117542f5285084bba8 Mon Sep 17 00:00:00 2001 From: Rupert Swarbrick Date: Fri, 28 Feb 2020 13:50:38 +0000 Subject: Add do-nothing support for mcountinhibit CSR This CSR appeared in version 1.11 of the ISA and is described in the Volume II: Privileged Architecture manual. It's an optional register and should read as zero if not implemented, which is what this patch does. --- riscv/encoding.h | 2 ++ riscv/processor.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/riscv/encoding.h b/riscv/encoding.h index 26142db..a1d6c7c 100644 --- a/riscv/encoding.h +++ b/riscv/encoding.h @@ -1617,6 +1617,7 @@ #define CSR_MIE 0x304 #define CSR_MTVEC 0x305 #define CSR_MCOUNTEREN 0x306 +#define CSR_MCOUNTINHIBIT 0x320 #define CSR_MSCRATCH 0x340 #define CSR_MEPC 0x341 #define CSR_MCAUSE 0x342 @@ -2538,6 +2539,7 @@ DECLARE_CSR(mideleg, CSR_MIDELEG) DECLARE_CSR(mie, CSR_MIE) DECLARE_CSR(mtvec, CSR_MTVEC) DECLARE_CSR(mcounteren, CSR_MCOUNTEREN) +DECLARE_CSR(mcountinhibit, CSR_MCOUNTINHIBIT) DECLARE_CSR(mscratch, CSR_MSCRATCH) DECLARE_CSR(mepc, CSR_MEPC) DECLARE_CSR(mcause, CSR_MCAUSE) diff --git a/riscv/processor.cc b/riscv/processor.cc index d458e39..17b8796 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -888,6 +888,7 @@ reg_t processor_t::get_csr(int which) break; case CSR_SCOUNTEREN: return state.scounteren; case CSR_MCOUNTEREN: return state.mcounteren; + case CSR_MCOUNTINHIBIT: return 0; case CSR_SSTATUS: { reg_t mask = SSTATUS_SIE | SSTATUS_SPIE | SSTATUS_SPP | SSTATUS_FS | (supports_extension('V') ? SSTATUS_VS : 0) -- cgit v1.1