[−][src]Struct sunrise_kernel::utils::io::Mmio
A value that can only be accessed volatilely.
Generally used behind a pointer, as such:
use sunrise_libutils::io::{Io, Mmio}; /// Layout of Mmio registers of a random device. /// /// This struct is repr packed so its field are not re-ordered, /// and no undesired padding is added. /// /// Be careful though, in rust reading an unaligned field is undefined behaviour, /// so you must make sure it is correctly aligned. #[repr(packed)] struct DeviceFooRegisters { register_control: Mmio<u16>, register_command: Mmio<u16>, } let device_address = 0xabcdef00 as *mut DeviceFooRegisters; let device: &mut DeviceFooRegisters = unsafe { // safety: make sure that device_address is valid and we're not violating // rust's aliasing rules. device_address.as_mut().unwrap() }; let status = device.register_control.read(); device.register_command.write(0xF00D);
Fields
value: MaybeUninit<T>
The value. Can only be accessed through .read()
Implementations
impl<T> Mmio<T>
[src]
pub fn new() -> Mmio<T>
[src]
Create a new Mmio without initializing.
Mostly unused, you would almost always get a Mmio by casting a raw pointer to a &mut Mmio.
Trait Implementations
impl<T> Debug for Mmio<T> where
T: Copy + Debug,
[src]
T: Copy + Debug,
impl<T> Io for Mmio<T> where
T: Copy,
[src]
T: Copy,
type Value = T
The width of the IO access. Should be a primitive type like u8, u16, u32... Read more
fn read(&self) -> T
[src]
Performs a volatile read of the value.
fn write(&mut self, value: T)
[src]
Performs a volatile write of the value.
fn readf(&self, flags: Self::Value) -> bool where
Self::Value: PartialEq<Self::Value>,
Self::Value: BitAnd<Self::Value>,
<Self::Value as BitAnd<Self::Value>>::Output == Self::Value,
[src]
Self::Value: PartialEq<Self::Value>,
Self::Value: BitAnd<Self::Value>,
<Self::Value as BitAnd<Self::Value>>::Output == Self::Value,
fn writef(&mut self, flags: Self::Value, value: bool) where
Self::Value: PartialEq<Self::Value>,
Self::Value: BitAnd<Self::Value>,
Self::Value: BitOr<Self::Value>,
Self::Value: Not,
<Self::Value as BitAnd<Self::Value>>::Output == Self::Value,
<Self::Value as BitOr<Self::Value>>::Output == Self::Value,
<Self::Value as Not>::Output == Self::Value,
[src]
Self::Value: PartialEq<Self::Value>,
Self::Value: BitAnd<Self::Value>,
Self::Value: BitOr<Self::Value>,
Self::Value: Not,
<Self::Value as BitAnd<Self::Value>>::Output == Self::Value,
<Self::Value as BitOr<Self::Value>>::Output == Self::Value,
<Self::Value as Not>::Output == Self::Value,
Auto Trait Implementations
impl<T> RefUnwindSafe for Mmio<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Mmio<T> where
T: Send,
T: Send,
impl<T> Sync for Mmio<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Mmio<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Mmio<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,