Struct sbi_rt::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 ) -> Physical<P>

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 for Physical<P>
where P: Clone,

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 for Physical<P>
where P: Copy,

Auto Trait Implementations§

§

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

§

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

§

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.