Skip to main content

Csrs

Struct Csrs 

Source
pub struct Csrs {
    pub tvec: i64,
    pub tcause: i64,
    pub tepc: i64,
    pub tval: i64,
    pub tpriv: Priv,
    pub ie: Word,
    pub ip: Word,
    pub tie: Word,
    pub ptbr: i64,
    pub scratch: i64,
}
Expand description

The control and status registers.

Fields§

§tvec: i64

Trap vector base. Zero leaves traps fatal, which is the reset state.

§tcause: i64

Cause of the last trap.

§tepc: i64

Program counter saved on the last trap.

§tval: i64

Value associated with the last trap.

§tpriv: Priv

Privilege saved on the last trap.

§ie: Word

Interrupt enable mask, one trit per source.

§ip: Word

Interrupt pending mask, one trit per source.

§tie: Word

Interrupt enable saved when the last trap was taken.

Taking a trap clears ie and stores the old value here; tret restores it. Without this a level-triggered source re-fires before the handler’s first instruction and the handler never runs.

§ptbr: i64

Page table base. Zero disables translation.

§scratch: i64

Scratch space for the handler.

Implementations§

Source§

impl Csrs

Source

pub fn read(&self, n: i64, current: Priv) -> Option<i64>

Reads a register by number. None if the number is not defined.

Source

pub fn write(&mut self, n: i64, v: i64) -> Option<bool>

Writes a register by number.

Some(false) for a register that exists but is read-only, None for one that does not exist. Writing a read-only register is silently ignored rather than trapping, matching the way r0 discards writes.

Source

pub fn pending_interrupt(&self) -> Option<Cause>

The interrupt to take, if any.

A source fires when it is both pending and enabled, which is a per-trit minimum: Kleene AND over the two masks (D-06). The lowest such trit wins, so a lower-numbered source has priority.

Source

pub fn set_pending(&mut self, source: usize, on: bool)

Sets or clears one trit of the pending mask.

Trait Implementations§

Source§

impl Clone for Csrs

Source§

fn clone(&self) -> Csrs

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Csrs

Source§

impl Debug for Csrs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Csrs

Source§

fn default() -> Csrs

Returns the “default value” for a type. Read more
Source§

impl Eq for Csrs

Source§

impl PartialEq for Csrs

Source§

fn eq(&self, other: &Csrs) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Csrs

Auto Trait Implementations§

§

impl Freeze for Csrs

§

impl RefUnwindSafe for Csrs

§

impl Send for Csrs

§

impl Sync for Csrs

§

impl Unpin for Csrs

§

impl UnsafeUnpin for Csrs

§

impl UnwindSafe for Csrs

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.