pub trait ExecutableInstructionCsr<ExtState, CustomError = CustomErrorPlaceholder>where
Self: Instruction,{
// Provided methods
fn prepare_csr_read(
ext_state: &ExtState,
csr_index: u16,
will_write: bool,
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§
Sourcefn prepare_csr_read(
ext_state: &ExtState,
csr_index: u16,
will_write: bool,
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_read( ext_state: &ExtState, csr_index: u16, will_write: bool, 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.
will_write indicates whether the CSR instruction performing this read will also perform a
write immediately afterward (as part of the same instruction). It is always true for
csrrw{,i}, and true for csrrs{,i}/csrrc{,i} unless their rs1/zimm operand is
zero (in which case they are a pure read with no write). Some CSRs (e.g. Zkr’s seed)
are only legal to access through a genuine read-write instruction and must reject the read
when will_write is false.
If no extension returns Ok(true), the read operation is implicitly rejected as illegal
access.
Sourcefn 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>>
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".
Implementations on Foreign Types§
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32AInstruction<Reg>where
Reg: Register<Type = u32>,
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 Rv32ZaamoInstruction<Reg>where
Reg: Register<Type = u32>,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZabhaInstruction<Reg>where
Reg: Register<Type = u32>,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZacasInstruction<Reg>where
Reg: Register<Type = u32>,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZalasrInstruction<Reg>where
Reg: Register<Type = u32>,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv32ZalrscInstruction<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>
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 Rv64AInstruction<Reg>where
Reg: Register<Type = u64>,
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 Rv64ZaamoInstruction<Reg>where
Reg: Register<Type = u64>,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZabhaInstruction<Reg>where
Reg: Register<Type = u64>,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZacasInstruction<Reg>where
Reg: Register<Type = u64>,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZalasrInstruction<Reg>where
Reg: Register<Type = u64>,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for Rv64ZalrscInstruction<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>
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 ZawrsInstruction<Reg>where
Reg: Register,
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 ZkrInstruction<Reg>where
Reg: Register + Register,
ExtState: ZkrSeedSource,
CustomError:,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZkrInstruction<Reg>where
Reg: Register + Register,
ExtState: ZkrSeedSource,
CustomError:,
§fn prepare_csr_read(
_ext_state: &ExtState,
csr_index: u16,
will_write: bool,
raw_value: Reg::Type,
output_value: &mut Reg::Type,
) -> Result<bool, CsrError<CustomError>>
fn prepare_csr_read( _ext_state: &ExtState, csr_index: u16, will_write: bool, raw_value: Reg::Type, output_value: &mut Reg::Type, ) -> Result<bool, CsrError<CustomError>>
Reads of seed are pass-through: the raw stored value already reflects the outcome of the
most recent poll (see [Self::prepare_csr_write()]).
Per specification, only genuine read-write accesses (not e.g. csrrs/csrrc with
rs1 = x0) are legal against seed; a pure read is rejected as an illegal access.
§fn prepare_csr_write(
ext_state: &mut ExtState,
csr_index: u16,
write_value: Reg::Type,
output_value: &mut Reg::Type,
) -> Result<bool, CsrError<CustomError>>
fn prepare_csr_write( ext_state: &mut ExtState, csr_index: u16, write_value: Reg::Type, output_value: &mut Reg::Type, ) -> Result<bool, CsrError<CustomError>>
Writes to seed ignore the write value entirely (per specification) and instead poll the
entropy source once, storing the newly encoded ZkrSeedPoll to be observed by the next
read
§impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZvbbInstruction<Reg>where
Reg: Register + Register,
ExtState: Csrs<Reg, CustomError>,
CustomError:,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZvbbInstruction<Reg>where
Reg: Register + Register,
ExtState: Csrs<Reg, CustomError>,
CustomError:,
§fn prepare_csr_read(
_ext_state: &ExtState,
csr_index: u16,
_will_write: bool,
raw_value: Reg::Type,
output_value: &mut Reg::Type,
) -> Result<bool, CsrError<CustomError>>
fn prepare_csr_read( _ext_state: &ExtState, csr_index: u16, _will_write: bool, 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>>
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,vlenbare read-only: writes are rejectedvxsat: only bit 0 is writable; mirrors intovcsr[0]vxrm: only bits[1:0]are writable; mirrors intovcsr[2:1]vcsr: only bits[2:0]are writable; mirrors intovxsatandvxrmvstart: full XLEN write allowed (WARL, implementation may restrict range)
§impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZvbcInstruction<Reg>where
Reg: Register + Register,
ExtState: Csrs<Reg, CustomError>,
CustomError:,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZvbcInstruction<Reg>where
Reg: Register + Register,
ExtState: Csrs<Reg, CustomError>,
CustomError:,
§fn prepare_csr_read(
_ext_state: &ExtState,
csr_index: u16,
_will_write: bool,
raw_value: Reg::Type,
output_value: &mut Reg::Type,
) -> Result<bool, CsrError<CustomError>>
fn prepare_csr_read( _ext_state: &ExtState, csr_index: u16, _will_write: bool, 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>>
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,vlenbare read-only: writes are rejectedvxsat: only bit 0 is writable; mirrors intovcsr[0]vxrm: only bits[1:0]are writable; mirrors intovcsr[2:1]vcsr: only bits[2:0]are writable; mirrors intovxsatandvxrmvstart: full XLEN write allowed (WARL, implementation may restrict range)
§impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZveXxInstruction<Reg>where
Reg: Register + Register,
ExtState: Csrs<Reg, CustomError>,
CustomError:,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZveXxInstruction<Reg>where
Reg: Register + Register,
ExtState: Csrs<Reg, CustomError>,
CustomError:,
§fn prepare_csr_read(
_ext_state: &ExtState,
csr_index: u16,
_will_write: bool,
raw_value: Reg::Type,
output_value: &mut Reg::Type,
) -> Result<bool, CsrError<CustomError>>
fn prepare_csr_read( _ext_state: &ExtState, csr_index: u16, _will_write: bool, 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>>
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,vlenbare read-only: writes are rejectedvxsat: only bit 0 is writable; mirrors intovcsr[0]vxrm: only bits[1:0]are writable; mirrors intovcsr[2:1]vcsr: only bits[2:0]are writable; mirrors intovxsatandvxrmvstart: full XLEN write allowed (WARL, implementation may restrict range)
§impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZvkbInstruction<Reg>where
Reg: Register + Register,
ExtState: Csrs<Reg, CustomError>,
CustomError:,
impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError> for ZvkbInstruction<Reg>where
Reg: Register + Register,
ExtState: Csrs<Reg, CustomError>,
CustomError:,
§fn prepare_csr_read(
_ext_state: &ExtState,
csr_index: u16,
_will_write: bool,
raw_value: Reg::Type,
output_value: &mut Reg::Type,
) -> Result<bool, CsrError<CustomError>>
fn prepare_csr_read( _ext_state: &ExtState, csr_index: u16, _will_write: bool, 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>>
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,vlenbare read-only: writes are rejectedvxsat: only bit 0 is writable; mirrors intovcsr[0]vxrm: only bits[1:0]are writable; mirrors intovcsr[2:1]vcsr: only bits[2:0]are writable; mirrors intovxsatandvxrmvstart: full XLEN write allowed (WARL, implementation may restrict range)