diff options
author | Andrew Waterman <andrew@sifive.com> | 2023-07-25 15:19:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-25 15:19:53 -0700 |
commit | 60c08b1ea5e3d96a97c235db87d472a7cfb2611b (patch) | |
tree | afc79314b2e7cb6d46225ef75fa97115b0fbe010 /riscv/csrs.h | |
parent | 4d0171931c4e8f03d9038da98eb4003789b1ac4c (diff) | |
parent | bc5842f94517c5fa760409cf8c956bbc7c37ead5 (diff) | |
download | riscv-isa-sim-60c08b1ea5e3d96a97c235db87d472a7cfb2611b.zip riscv-isa-sim-60c08b1ea5e3d96a97c235db87d472a7cfb2611b.tar.gz riscv-isa-sim-60c08b1ea5e3d96a97c235db87d472a7cfb2611b.tar.bz2 |
Merge pull request #1383 from rivosinc/sscrind_feature
Add Smcsrind / Sscsrind support
Diffstat (limited to 'riscv/csrs.h')
-rw-r--r-- | riscv/csrs.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/riscv/csrs.h b/riscv/csrs.h index e483ea3..cf48673 100644 --- a/riscv/csrs.h +++ b/riscv/csrs.h @@ -6,8 +6,12 @@ #include "encoding.h" // For reg_t: #include "decode.h" +// For std::unordered_map +#include <unordered_map> // For std::shared_ptr #include <memory> +// For std::optional +#include <optional> // For access_type: #include "memtracer.h" #include <cassert> @@ -794,4 +798,28 @@ class jvt_csr_t: public basic_csr_t { jvt_csr_t(processor_t* const proc, const reg_t addr, const reg_t init); virtual void verify_permissions(insn_t insn, bool write) const override; }; + +// Sscsrind registers needs permissions checked +// (the original virtualized_csr_t does not call verify_permission of the underlying CSRs) +class virtualized_indirect_csr_t: public virtualized_csr_t { + public: + virtualized_indirect_csr_t(processor_t* const proc, csr_t_p orig, csr_t_p virt); + virtual void verify_permissions(insn_t insn, bool write) const override; +}; + +class sscsrind_reg_csr_t : public csr_t { + public: + typedef std::shared_ptr<sscsrind_reg_csr_t> sscsrind_reg_csr_t_p; + sscsrind_reg_csr_t(processor_t* const proc, const reg_t addr, csr_t_p iselect); + reg_t read() const noexcept override; + virtual void verify_permissions(insn_t insn, bool write) const override; + void add_ireg_proxy(const reg_t iselect_val, csr_t_p proxy_csr); + protected: + virtual bool unlogged_write(const reg_t val) noexcept override; + private: + csr_t_p iselect; + std::unordered_map<reg_t, csr_t_p> ireg_proxy; + csr_t_p get_reg() const noexcept; +}; + #endif |