1 use core
::ptr
::{read_volatile, write_volatile, addr_of, addr_of_mut}
;
2 use core
::mem
::MaybeUninit
;
3 use core
::ops
::{BitAnd, BitOr, Not}
;
13 /// Create a new Mmio without initializing
14 #[deprecated = "unsound because it's possible to read even though it's uninitialized"]
15 pub fn new() -> Self {
16 unsafe { Self::uninit() }
18 pub unsafe fn zeroed() -> Self {
20 value
: MaybeUninit
::zeroed(),
23 pub unsafe fn uninit() -> Self {
25 value
: MaybeUninit
::uninit(),
28 pub const fn from(value
: T
) -> Self {
30 value
: MaybeUninit
::new(value
),
35 impl<T
> Io
for Mmio
<T
> where T
: Copy
+ PartialEq
+ BitAnd
<Output
= T
> + BitOr
<Output
= T
> + Not
<Output
= T
> {
39 unsafe { read_volatile(addr_of!(self.value).cast::<T>()) }
42 fn write(&mut self, value
: T
) {
43 unsafe { write_volatile(addr_of_mut!(self.value).cast::<T>(), value) }
;