Skip to main content

ExecutableInstructionCsr

Trait ExecutableInstructionCsr 

Source
pub trait ExecutableInstructionCsr<ExtState, CustomError = CustomErrorPlaceholder>
where Self: Instruction, ExtState: ?Sized,
{ // Provided methods fn prepare_csr_read( ext_state: &ExtState, csr_index: u16, raw_value: <<Self as Instruction>::Reg as Register>::Type, output_value: &mut <<Self as Instruction>::Reg as Register>::Type, ) -> Result<bool, CsrError<CustomError>> { ... } fn prepare_csr_write( ext_state: &mut ExtState, csr_index: u16, write_value: <<Self as Instruction>::Reg as Register>::Type, output_value: &mut <<Self as Instruction>::Reg as Register>::Type, ) -> Result<bool, CsrError<CustomError>> { ... } }

Provided Methods§

Source

fn prepare_csr_read( ext_state: &ExtState, csr_index: u16, raw_value: <<Self as Instruction>::Reg as Register>::Type, output_value: &mut <<Self as Instruction>::Reg as Register>::Type, ) -> Result<bool, CsrError<CustomError>>

Prepare CSR read.

This method is called on each extension one by one with the raw_value (contents of the corresponding CSR register) and initially zero-initialized output_value. In return value every extension can accept (Ok(true)), ignore (Ok(false)) or reject (Err(CsrError)) read request. For accepted reads the extension must update output_value accordingly, which will be the value used by the Zicsr extension handler.

Some extensions will just copy raw_value to output value, others will copy only some bits or zero some bits of the raw_value, as required by the specification.

If no extension returns Ok(true), the read operation is implicitly rejected as illegal access.

Source

fn prepare_csr_write( ext_state: &mut ExtState, csr_index: u16, write_value: <<Self as Instruction>::Reg as Register>::Type, output_value: &mut <<Self as Instruction>::Reg as Register>::Type, ) -> Result<bool, CsrError<CustomError>>

Prepare CSR write.

This method is called on each extension one by one with write_value being prepared by the Zicsr extension handler. In return value every extension can accept (Ok(true)), ignore (Ok(false)) or reject (Err(CsrError)) write request. For accepted writes the extension must update output_value accordingly, which will be written to the corresponding CSR register.

Some extensions will just copy write_value to output value, others will copy some bits or zero some bits of the write_value, as required by the specification.

If no extension returns Ok(true), the write operation is implicitly rejected as illegal access.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32BInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32Instruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32MInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZbaInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZbbInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZbcInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZbkbInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZbkcInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZbkxInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZbsInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZcaInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZcbInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZcmpInstruction<Reg>
where Reg: ZcmpRegister<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZknInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZkndInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZkneInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZknhInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZmmulInstruction<Reg>
where Reg: Register<Type = u32>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64BInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64Instruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64MInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZbaInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZbbInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZbcInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZbkbInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZbkcInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZbkxInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZbsInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZcaInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZcbInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZcmpInstruction<Reg>
where Reg: ZcmpRegister<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZknInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZkndInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZkneInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZknhInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZmmulInstruction<Reg>
where Reg: Register<Type = u64>,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZicondInstruction<Reg>
where Reg: Register,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZicsrInstruction<Reg>
where Reg: Register,

§

impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Zve64xInstruction<Reg>
where Reg: Register, ExtState: Csrs<Reg, CustomError>,

§

fn prepare_csr_read( _ext_state: &ExtState, csr_index: u16, raw_value: Reg::Type, output_value: &mut Reg::Type, ) -> Result<bool, CsrError<CustomError>>

Validate reads to vector CSRs from Zicsr instructions.

All vector CSRs are accessible from unprivileged code (U-mode). Reads are pass-through: the raw value stored in the CSR is the output value.

§

fn prepare_csr_write( ext_state: &mut ExtState, csr_index: u16, write_value: Reg::Type, output_value: &mut Reg::Type, ) -> Result<bool, CsrError<CustomError>>

Validate, sanitize, and mirror writes to vector CSRs from Zicsr instructions.

Enforces WARL semantics and vcsr mirroring:

  • vl, vtype, vlenb are read-only: writes are rejected
  • vxsat: only bit 0 is writable; mirrors into vcsr[0]
  • vxrm: only bits [1:0] are writable; mirrors into vcsr[2:1]
  • vcsr: only bits [2:0] are writable; mirrors into vxsat and vxrm
  • vstart: full XLEN write allowed (WARL, implementation may restrict range)

Implementors§