[−][src]Function sunrise_libuser::mem::map_mmio
pub fn map_mmio<T>(physical_address: usize) -> Result<*mut T, KernelError>
Maps a Mmio struct in the virtual memory of this process.
This function preserves the offset relative to PAGE_SIZE
.
Example
use sunrise_libutils::io::{Io, Mmio}; use sunrise_libuser::mem::map_mmio; /// Found at physical address 0xabc00030 #[repr(packed)] struct DeviceFoo { header: Mmio<u32>, version: Mmio<u32>, field_a: Mmio<u16>, field_b: Mmio<u16>, } let mapped_data: *mut DeviceFoo = map_mmio::<DeviceFoo>(0xabc00030).unwrap(); // = virtual address 0x7030 unsafe { assert_eq!((*mapped_data).version.read(), 0x010200); }