Struct Forward

Source
pub struct Forward;
Expand description

Forwards SBI calls onto current supervisor environment.

If crate feature forward is enabled, this structure implements all RustSBI extensions by forwarding the calls into the current supervisor environment. This is done by sbi-rt crate; thus Forward is only available when it’s running in RISC-V SBI environments.

Forward implements all RustSBI traits, but is only effective if #[cfg(feature = "forward")] is enabled. Otherwise, struct Forward is unimplemented!() on SBI calls.

§Examples

This structure can be used as a structure field in #[derive(RustSBI)], with helper macro #[rustsbi(extension_1, extension_2, ...)] annotating what extensions should be forwarded to sbi-rt in the structure.

use rustsbi::{Forward, RustSBI};

// Forwards fence, timer and console extensions, but the hsm extension
// is still handled by the `hsm` field variable.
#[derive(RustSBI)]
struct VmSBI {
    hsm: VmHsm,
    #[rustsbi(fence, timer, console, info)]
    forward: Forward,
}

Trait Implementations§

Source§

impl Clone for Forward

Source§

fn clone(&self) -> Forward

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Console for Forward

Source§

fn write(&self, bytes: Physical<&[u8]>) -> SbiRet

Write bytes to the debug console from input memory. Read more
Source§

fn read(&self, bytes: Physical<&mut [u8]>) -> SbiRet

Read bytes from the debug console into an output memory. Read more
Source§

fn write_byte(&self, byte: u8) -> SbiRet

Write a single byte to the debug console. Read more
Source§

impl Cppc for Forward

Source§

fn probe(&self, reg_id: u32) -> SbiRet

Probe whether the CPPC register as specified by the reg_id parameter is implemented or not by the platform. Read more
Source§

fn read(&self, reg_id: u32) -> SbiRet

Reads the register as specified in the reg_id parameter. Read more
Source§

fn read_hi(&self, reg_id: u32) -> SbiRet

Reads the upper 32-bit value of the register specified in the reg_id parameter. Read more
Source§

fn write(&self, reg_id: u32, val: u64) -> SbiRet

Writes the value passed in the val parameter to the register as specified in the reg_id parameter. Read more
Source§

impl Debug for Forward

Source§

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

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

impl EnvInfo for Forward

Source§

fn mvendorid(&self) -> usize

Vendor ID for the supervisor environment. Read more
Source§

fn marchid(&self) -> usize

Architecture ID for the supervisor environment. Read more
Source§

fn mimpid(&self) -> usize

Implementation ID for the supervisor environment. Read more
Source§

impl Hsm for Forward

Source§

fn hart_start(&self, hartid: usize, start_addr: usize, opaque: usize) -> SbiRet

Request the SBI implementation to start executing the given hart at specified address in supervisor-mode. Read more
Source§

fn hart_stop(&self) -> SbiRet

Request the SBI implementation to stop executing the calling hart in supervisor-mode and return its ownership to the SBI implementation. Read more
Source§

fn hart_get_status(&self, hartid: usize) -> SbiRet

Get the current status (or HSM state id) of the given hart. Read more
Source§

fn hart_suspend( &self, suspend_type: u32, resume_addr: usize, opaque: usize, ) -> SbiRet

Request the SBI implementation to put the calling hart in a platform specific suspend (or low-power) state specified by the suspend_type parameter. Read more
Source§

impl Ipi for Forward

Source§

fn send_ipi(&self, hart_mask: HartMask) -> SbiRet

Send an inter-processor interrupt to all the harts defined in hart_mask. Read more
Source§

impl Nacl for Forward

Source§

fn probe_feature(&self, feature_id: u32) -> SbiRet

Probe nested acceleration feature. Read more
Source§

fn set_shmem(&self, shmem: SharedPtr<[u8; 8192]>, flags: usize) -> SbiRet

Set nested acceleration shared memory. Read more
Source§

fn sync_csr(&self, csr_num: usize) -> SbiRet

Synchronize shared memory CSRs. Read more
Source§

fn sync_hfence(&self, entry_index: usize) -> SbiRet

Synchronize shared memory HFENCEs. Read more
Source§

fn sync_sret(&self) -> SbiRet

Synchronize shared memory and emulate SRET. Read more
Source§

impl Pmu for Forward

Source§

fn num_counters(&self) -> usize

Returns the number of counters (both hardware and firmware). Read more
Source§

fn counter_get_info(&self, counter_idx: usize) -> SbiRet

Get details about the specified counter such as underlying CSR number, width of the counter, type of counter (hardware/firmware, etc.). Read more
Source§

fn counter_config_matching( &self, counter_idx_base: usize, counter_idx_mask: usize, config_flags: usize, event_idx: usize, event_data: u64, ) -> SbiRet

Find and configure a counter from a set of counters which is not started (or enabled) and can monitor the specified event. Read more
Source§

fn counter_start( &self, counter_idx_base: usize, counter_idx_mask: usize, start_flags: usize, initial_value: u64, ) -> SbiRet

Start or enable a set of counters on the calling HART with the specified initial value. Read more
Source§

fn counter_stop( &self, counter_idx_base: usize, counter_idx_mask: usize, stop_flags: usize, ) -> SbiRet

Stop or disable a set of counters on the calling HART. Read more
Source§

fn counter_fw_read(&self, counter_idx: usize) -> SbiRet

Provide the current value of a firmware counter in SbiRet.value. Read more
Source§

fn counter_fw_read_hi(&self, counter_idx: usize) -> SbiRet

Provide the upper 32 bits from the current value of firmware counter in SbiRet.value. Read more
Source§

impl Reset for Forward

Source§

fn system_reset(&self, reset_type: u32, reset_reason: u32) -> SbiRet

Reset the system based on provided reset_type and reset_reason. Read more
Source§

impl Rfence for Forward

Source§

fn remote_fence_i(&self, hart_mask: HartMask) -> SbiRet

Instructs remote harts to execute FENCE.I instruction. Read more
Source§

fn remote_sfence_vma( &self, hart_mask: HartMask, start_addr: usize, size: usize, ) -> SbiRet

Instructs the remote harts to execute one or more SFENCE.VMA instructions, covering the range of virtual addresses between start_addr and size. Read more
Source§

fn remote_sfence_vma_asid( &self, hart_mask: HartMask, start_addr: usize, size: usize, asid: usize, ) -> SbiRet

Instruct the remote harts to execute one or more SFENCE.VMA instructions, covering the range of virtual addresses between start_addr and size. This covers only the given address space by asid. Read more
Source§

fn remote_hfence_gvma_vmid( &self, hart_mask: HartMask, start_addr: usize, size: usize, vmid: usize, ) -> SbiRet

Instruct the remote harts to execute one or more HFENCE.GVMA instructions, covering the range of guest physical addresses between start_addr and size only for the given virtual machine by vmid. Read more
Source§

fn remote_hfence_gvma( &self, hart_mask: HartMask, start_addr: usize, size: usize, ) -> SbiRet

Instruct the remote harts to execute one or more HFENCE.GVMA instructions, covering the range of guest physical addresses between start_addr and size for all the guests. Read more
Source§

fn remote_hfence_vvma_asid( &self, hart_mask: HartMask, start_addr: usize, size: usize, asid: usize, ) -> SbiRet

Instruct the remote harts to execute one or more HFENCE.VVMA instructions, covering the range of guest virtual addresses between start_addr and size for the given address space by asid and current virtual machine (by vmid in hgatp CSR) of calling hart. Read more
Source§

fn remote_hfence_vvma( &self, hart_mask: HartMask, start_addr: usize, size: usize, ) -> SbiRet

Instruct the remote harts to execute one or more HFENCE.VVMA instructions, covering the range of guest virtual addresses between start_addr and size for current virtual machine (by vmid in hgatp CSR) of calling hart. Read more
Source§

impl Sta for Forward

Source§

fn set_shmem(&self, shmem: SharedPtr<[u8; 64]>, flags: usize) -> SbiRet

Set Steal-time Shared Memory Address. Read more
Source§

impl Susp for Forward

Source§

fn system_suspend( &self, sleep_type: u32, resume_addr: usize, opaque: usize, ) -> SbiRet

Request the SBI implementation to put the system transitions to a sleep state. Read more
Source§

impl Timer for Forward

Source§

fn set_timer(&self, stime_value: u64)

Programs the clock for the next event after stime_value time. Read more

Auto Trait Implementations§

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