Skip to main content

Csr

Enum Csr 

Source
#[repr(u32)]
pub enum Csr {
Show 16 variants Mstatus = 768, Misa = 769, Mie = 772, Mtvec = 773, Mscratch = 832, Mepc = 833, Mcause = 834, Mtval = 835, Mip = 836, Cycle = 3_072, Mvendorid = 3_857, PrintInt = 310, PrintHex = 311, PrintStr = 312, PrintChar = 313, ReadKbd = 320,
}
Expand description

CSR addresses used by the emulator.

The standard machine-mode CSRs follow the RISC-V privileged spec. The Print* and ReadKbd entries (0x1360x140) are custom debug extensions inherited from the original mini-rv32ima: they let bare-metal code print integers, hex values, strings, and characters without needing a UART driver.

Variants§

§

Mstatus = 768

Machine status register.

§

Misa = 769

Machine ISA register (reports RV32IMA to the kernel).

§

Mie = 772

Machine interrupt-enable register.

§

Mtvec = 773

Machine trap-handler base address.

§

Mscratch = 832

Machine scratch register (used by trap handlers for context save).

§

Mepc = 833

Machine exception PC — address of the trapping instruction.

§

Mcause = 834

Machine cause register.

§

Mtval = 835

Machine trap value (faulting address or instruction).

§

Mip = 836

Machine interrupt-pending register.

§

Cycle = 3_072

Cycle counter (lower 32 bits).

§

Mvendorid = 3_857

Vendor ID (returns 0xff0ff0ff).

§

PrintInt = 310

Write a signed integer to stdout.

§

PrintHex = 311

Write a hex word to stdout.

§

PrintStr = 312

Write a null-terminated string from RAM to stdout.

§

PrintChar = 313

Write a single character to stdout.

§

ReadKbd = 320

Read one byte from stdin (-1 if none available).

Auto Trait Implementations§

§

impl Freeze for Csr

§

impl RefUnwindSafe for Csr

§

impl Send for Csr

§

impl Sync for Csr

§

impl Unpin for Csr

§

impl UnsafeUnpin for Csr

§

impl UnwindSafe for Csr

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> 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, 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.