sbi_spec::binary

Struct Physical

Source
pub struct Physical<P> { /* private fields */ }
Expand description

Physical slice wrapper with type annotation.

This struct wraps slices in RISC-V physical memory by low and high part of the physical base address as well as its length. It is usually used by SBI extensions as parameter types to pass base address and length parameters on physical memory other than a virtual one.

Generic parameter P represents a hint of how this physical slice would be used. For example, Physical<&[u8]> represents an immutable reference to physical byte slice, while Physical<&mut [u8]> represents a mutable one.

An SBI implementation should load or store memory using both phys_addr_lo and phys_addr_hi combined as base address. A supervisor program (kernels etc.) should provide continuous physical memory, wrapping its reference using this structure before passing into SBI runtime.

Implementations§

Source§

impl<P> Physical<P>

Source

pub const fn new( num_bytes: usize, phys_addr_lo: usize, phys_addr_hi: usize, ) -> Self

Create a physical memory slice by length and physical address.

Source

pub const fn num_bytes(&self) -> usize

Returns length of the physical memory slice.

Source

pub const fn phys_addr_lo(&self) -> usize

Returns low-part base address of physical memory slice.

Source

pub const fn phys_addr_hi(&self) -> usize

Returns high-part base address of physical memory slice.

Trait Implementations§

Source§

impl<P: Clone> Clone for Physical<P>

Source§

fn clone(&self) -> Physical<P>

Returns a copy 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<P: Copy> Copy for Physical<P>

Auto Trait Implementations§

§

impl<P> Freeze for Physical<P>

§

impl<P> RefUnwindSafe for Physical<P>
where P: RefUnwindSafe,

§

impl<P> Send for Physical<P>
where P: Send,

§

impl<P> Sync for Physical<P>
where P: Sync,

§

impl<P> Unpin for Physical<P>
where P: Unpin,

§

impl<P> UnwindSafe for Physical<P>
where P: UnwindSafe,

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.