Crate mmio

Source
Expand description

Abstractions for performing memory-mapped I/O.

Memory-mapped I/O (MMIO) requires working with raw pointers and volatile memory accesses, both of which require manually reasoning about safety. This crate provides the VolBox (pronounced “volatile box”) smart pointer, which expresses unique ownership of a volatile memory location. Additionally, it follows the “unsafe initialization, safe use” pattern to offload safety reasoning to the borrow checker after VolBox::new.

Importantly, this crate is careful to never create references to volatile memory locations.

§Examples

let mut thr = unsafe {
    VolBox::<u8, Allow, Allow>::new(0x1000_0000 as *mut u8)
};
let lsr = unsafe {
    VolBox::<u8, Allow, Allow>::new(0x1000_0005 as *mut u8)
};
loop {
    if lsr.read() & 0x20 != 0x0 {
        break;
    }
}
thr.write(b'\n');

Structs§

VolBox
An owned memory location for volatile reads and writes.

Enums§

Allow
Allow access to a memory location.
Deny
Deny access to a memory location.
Warn
Allow access to a memory location under additional safety rules.