7 releases (stable)
2.1.0 | May 23, 2021 |
---|---|
2.0.1 | May 21, 2021 |
1.0.1 | May 20, 2021 |
0.1.0 | Sep 24, 2020 |
0.0.0 | Sep 22, 2020 |
#1794 in Embedded development
57 downloads per month
Used in syscon-rs
10KB
94 lines
mmio
Abstractions for performing memory-mapped I/O.
Code of Conduct
See the Rust Code of Conduct.
Contribution
See CONTRIBUTING.md.
Changelog
See CHANGELOG.md.
License
See LICENSE.md.
lib.rs
:
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');