Skip to main content

MmioPtr

Struct MmioPtr 

Source
pub struct MmioPtr<T, Access: Accessible>(/* private fields */);
Expand description

Represents a pointer to an MMIO address - with specific access permissions - at which a register might be located.

Implementations§

Source§

impl<T, R> MmioPtr<T, (R, NoWrite)>
where (R, NoWrite): Accessible,

Source

pub const unsafe fn new(ptr: *const T) -> Self

Constructs a new, read-only MMIO pointer wrapper.

§Safety

The caller must guarantee the safety preconditions of [core::ptr::read_volatile()] for the lifetime of MmioPtr. In particular…

  • that ptr is aligned and points to a mapped MMIO address;

  • the mapping remains valid for the lifetime of the returned MmioPtr (and any copies of it);

  • accesses must never trap.

Note that it is not assumed that the backing memory is immutable.

Source

pub const fn as_ptr(self) -> *const T

Returns the underlying pointer.

Source§

impl<T, Access: Writable> MmioPtr<T, Access>

Source

pub const unsafe fn new(ptr: *mut T) -> Self

Constructs a new, writable MMIO pointer wrapper.

§Safety

The caller must guarantee the safety preconditions of [core::ptr::read_volatile()] (if readable) and [core::ptr::write_volatile()] for the lifetime of MmioPtr. In particular…

  • that ptr is aligned and points to a mapped MMIO address;

  • the mapping remains valid for the lifetime of the returned MmioPtr (and any copies of it);

  • accesses must never trap.

Also,

  • If Access expresses safe-writability (see SafeWrite), that writing any value whatsoever to this address cannot result in undefined behaviour.

Note that it is not assumed that the backing memory is immutable, or that a writable MmioPtr has exclusive access to it.

Source

pub const fn as_ptr(self) -> *mut T

Returns the underlying pointer.

Source§

impl<T, Access: Accessible> MmioPtr<T, Access>

Source

pub const fn restrict<NewAccess>(self) -> MmioPtr<T, NewAccess>
where NewAccess: Accessible, Access: AccessRestrictsTo<NewAccess>,

Restricts the access permissions of this pointer.

Trait Implementations§

Source§

impl<T, Access: Accessible> Clone for MmioPtr<T, Access>

Source§

fn clone(&self) -> Self

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

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

Performs copy-assignment from source. Read more
Source§

impl<T, Access: Accessible> Copy for MmioPtr<T, Access>

Source§

impl<T: Debug, Access: Debug + Accessible> Debug for MmioPtr<T, Access>

Source§

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

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

impl<T, Access> IoHandle for MmioPtr<T, Access>
where T: Copy, Access: Accessible,

Source§

type Base = T

The underlying base type of the register (assumed integral in practice).
Source§

impl<Access> ReadHandle for MmioPtr<u8, Access>
where Access: Readable,

Source§

unsafe fn read_raw(&self) -> u8

Performs the read. Read more
Source§

impl<Access> ReadHandle for MmioPtr<u16, Access>
where Access: Readable,

Source§

unsafe fn read_raw(&self) -> u16

Performs the read. Read more
Source§

impl<Access> ReadHandle for MmioPtr<u32, Access>
where Access: Readable,

Source§

unsafe fn read_raw(&self) -> u32

Performs the read. Read more
Source§

impl<Access> ReadHandle for MmioPtr<u64, Access>
where Access: Readable,

Source§

unsafe fn read_raw(&self) -> u64

Performs the read. Read more
Source§

impl<T, Access: Accessible> Send for MmioPtr<T, Access>

Source§

impl<T, Access: Accessible> Sync for MmioPtr<T, Access>

Source§

impl<Access> WriteHandle for MmioPtr<u8, Access>
where Access: Writable,

Source§

unsafe fn write_raw(&self, value: u8)

Performs the write of the provided value. Read more
Source§

impl<Access> WriteHandle for MmioPtr<u16, Access>
where Access: Writable,

Source§

unsafe fn write_raw(&self, value: u16)

Performs the write of the provided value. Read more
Source§

impl<Access> WriteHandle for MmioPtr<u32, Access>
where Access: Writable,

Source§

unsafe fn write_raw(&self, value: u32)

Performs the write of the provided value. Read more
Source§

impl<Access> WriteHandle for MmioPtr<u64, Access>
where Access: Writable,

Source§

unsafe fn write_raw(&self, value: u64)

Performs the write of the provided value. Read more

Auto Trait Implementations§

§

impl<T, Access> Freeze for MmioPtr<T, Access>

§

impl<T, Access> RefUnwindSafe for MmioPtr<T, Access>
where T: RefUnwindSafe, Access: RefUnwindSafe,

§

impl<T, Access> Unpin for MmioPtr<T, Access>
where Access: Unpin,

§

impl<T, Access> UnsafeUnpin for MmioPtr<T, Access>

§

impl<T, Access> UnwindSafe for MmioPtr<T, Access>
where T: RefUnwindSafe, Access: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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<Layout, Base> LayoutOver<Base> for Layout
where Layout: Copy + From<Base> + Into<Base>,

§

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

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

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

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

Performs the conversion.