pub struct Register<Layout, Access, Io>{ /* private fields */ }Expand description
Register represents a structured register layout, and its access
interface and permissions. This is the core abstraction of the crate.
If Access expresses unsafe-writability, then all write methods are marked
as unsafe.
Implementations§
Source§impl<Spec, Layout> Register<Layout, <Spec as SystemRegisterSpec>::Access, SysRegIo<Spec>>where
Spec: SystemRegisterSpec,
Layout: LayoutOver<u64>,
impl<Spec, Layout> Register<Layout, <Spec as SystemRegisterSpec>::Access, SysRegIo<Spec>>where
Spec: SystemRegisterSpec,
Layout: LayoutOver<u64>,
Source§impl<Layout, Base, Access> Register<Layout, Access, MmioPtr<Base, Access>>where
Layout: LayoutOver<Base>,
Base: Copy,
Access: Accessible,
impl<Layout, Base, Access> Register<Layout, Access, MmioPtr<Base, Access>>where
Layout: LayoutOver<Base>,
Base: Copy,
Access: Accessible,
Sourcepub const fn new<InputAccess>(ptr: MmioPtr<Base, InputAccess>) -> Selfwhere
InputAccess: AccessRestrictsTo<Access>,
pub const fn new<InputAccess>(ptr: MmioPtr<Base, InputAccess>) -> Selfwhere
InputAccess: AccessRestrictsTo<Access>,
Constructs a new memory-backed register from a pointer wrapper.
Source§impl<Encoding, Layout> Register<Layout, <Encoding as ControlAndStatusRegisterEncoding>::Access, CsrIo<Encoding>>where
Encoding: ControlAndStatusRegisterEncoding,
Layout: LayoutOver<u64>,
impl<Encoding, Layout> Register<Layout, <Encoding as ControlAndStatusRegisterEncoding>::Access, CsrIo<Encoding>>where
Encoding: ControlAndStatusRegisterEncoding,
Layout: LayoutOver<u64>,
Source§impl<const N: u32, Layout> Register<Layout, <CrIo<N> as ControlRegister>::Access, CrIo<N>>where
CrIo<N>: ControlRegister,
Layout: LayoutOver<u64>,
impl<const N: u32, Layout> Register<Layout, <CrIo<N> as ControlRegister>::Access, CrIo<N>>where
CrIo<N>: ControlRegister,
Layout: LayoutOver<u64>,
Source§impl<const N: u32, Layout> Register<Layout, <XcrIo<N> as ControlRegister>::Access, XcrIo<N>>where
XcrIo<N>: ControlRegister,
Layout: LayoutOver<u64>,
impl<const N: u32, Layout> Register<Layout, <XcrIo<N> as ControlRegister>::Access, XcrIo<N>>where
XcrIo<N>: ControlRegister,
Layout: LayoutOver<u64>,
Source§impl<const ID: u32, Layout, Access> Register<Layout, Access, MsrIo<ID>>where
Layout: LayoutOver<u64>,
Access: Accessible,
impl<const ID: u32, Layout, Access> Register<Layout, Access, MsrIo<ID>>where
Layout: LayoutOver<u64>,
Access: Accessible,
Source§impl<Layout, Base, Access> Register<Layout, Access, PortIo<Base, Access>>where
Layout: LayoutOver<Base>,
Base: Copy,
Access: Accessible,
impl<Layout, Base, Access> Register<Layout, Access, PortIo<Base, Access>>where
Layout: LayoutOver<Base>,
Base: Copy,
Access: Accessible,
Source§impl<Layout, Access, Io> Register<Layout, Access, Io>
impl<Layout, Access, Io> Register<Layout, Access, Io>
Sourcepub const unsafe fn from_io(io: Io) -> Self
pub const unsafe fn from_io(io: Io) -> Self
Constructs a new register from an I/O handle.
§Safety
The caller must guarantee…
-
that the provided I/O handle meets the implementation-specific access safety preconditions for the duration of the lifetimes of the register instance and any copies of it (e.g., in the case of an MMIO pointer, that the pointer is aligned and the memory it points to remains mapped for those lifetimes);
-
and that
Accesscorrectly models the safe nature of access in this context.
pub const fn io(&self) -> &Io
pub fn into_io(self) -> Io
Sourcepub fn read(&self) -> Layoutwhere
Access: Readable,
Io: ReadHandle,
pub fn read(&self) -> Layoutwhere
Access: Readable,
Io: ReadHandle,
Reads from the register, if the backend and register permit it.
Source§impl<Layout, R, Io> Register<Layout, (R, SafeWrite), Io>
impl<Layout, R, Io> Register<Layout, (R, SafeWrite), Io>
Sourcepub fn write(&self, value: Layout)
pub fn write(&self, value: Layout)
Writes to the register, if the backend and register permit it.
Sourcepub fn modify<ModifyFn, Ret>(&self, cb: ModifyFn) -> Ret
pub fn modify<ModifyFn, Ret>(&self, cb: ModifyFn) -> Ret
Modifies the contents of the register, if the register and backend admit both reads and writes, returning whatever state the modification callback wanted to forward.
Sourcepub fn atomic_swap(&self, value: Layout) -> Layout
pub fn atomic_swap(&self, value: Layout) -> Layout
Atomically swaps the contents of the register with the provided value, returning the original contents.
Sourcepub fn atomic_set_bits(&self, bits: Layout) -> Layout
pub fn atomic_set_bits(&self, bits: Layout) -> Layout
Atomically sets the provided bits on the contents of the register, returning the original contents.
Sourcepub fn atomic_clear_bits(&self, bits: Layout) -> Layout
pub fn atomic_clear_bits(&self, bits: Layout) -> Layout
Atomically clears the provided bits on the contents of the register, returning the original contents.
Source§impl<Layout, R, Io> Register<Layout, (R, UnsafeWrite), Io>
impl<Layout, R, Io> Register<Layout, (R, UnsafeWrite), Io>
Sourcepub unsafe fn write(&self, value: Layout)
pub unsafe fn write(&self, value: Layout)
Writes to the register, if the backend and register permit it.
§Safety
The caller must guarantee that the write does not result in undefined behaviour.
Sourcepub unsafe fn modify<ModifyFn, Ret>(&self, cb: ModifyFn) -> Ret
pub unsafe fn modify<ModifyFn, Ret>(&self, cb: ModifyFn) -> Ret
Modifies the contents of the register, if the register and backend admit both reads and writes, returning whatever state the modification callback wanted to forward.
§Safety
The caller must guarantee that the write does not result in undefined behaviour.
Sourcepub unsafe fn atomic_swap(&self, value: Layout) -> Layout
pub unsafe fn atomic_swap(&self, value: Layout) -> Layout
Atomically swaps the contents of the register with the provided value, returning the original contents.
§Safety
The caller must guarantee that the write does not result in undefined behaviour.
Sourcepub unsafe fn atomic_set_bits(&self, bits: Layout) -> Layout
pub unsafe fn atomic_set_bits(&self, bits: Layout) -> Layout
Atomically sets the provided bits on the contents of the register, returning the original contents.
§Safety
The caller must guarantee that the write does not result in undefined behaviour.
Sourcepub unsafe fn atomic_clear_bits(&self, bits: Layout) -> Layout
pub unsafe fn atomic_clear_bits(&self, bits: Layout) -> Layout
Atomically clears the provided bits on the contents of the register, returning the original contents.
§Safety
The caller must guarantee that the write does not result in undefined behaviour.
Trait Implementations§
Source§impl<Layout, Access, Io> Clone for Register<Layout, Access, Io>where
Io: IoHandle + Clone,
Layout: LayoutOver<<Io as IoHandle>::Base> + Clone,
Access: Accessible + Clone,
impl<Layout, Access, Io> Clone for Register<Layout, Access, Io>where
Io: IoHandle + Clone,
Layout: LayoutOver<<Io as IoHandle>::Base> + Clone,
Access: Accessible + Clone,
impl<Layout, Access, Io> Copy for Register<Layout, Access, Io>where
Io: IoHandle + Copy,
Layout: LayoutOver<<Io as IoHandle>::Base> + Copy,
Access: Accessible + Copy,
Source§impl<Layout, Access, Io> Debug for Register<Layout, Access, Io>where
Io: IoHandle + Debug,
Layout: LayoutOver<<Io as IoHandle>::Base> + Debug,
Access: Accessible + Debug,
impl<Layout, Access, Io> Debug for Register<Layout, Access, Io>where
Io: IoHandle + Debug,
Layout: LayoutOver<<Io as IoHandle>::Base> + Debug,
Access: Accessible + Debug,
Source§impl<Layout, R, Io> SafeWriteReg<Layout> for Register<Layout, (R, SafeWrite), Io>
impl<Layout, R, Io> SafeWriteReg<Layout> for Register<Layout, (R, SafeWrite), Io>
Source§impl<Layout, R, Io> UnsafeWriteReg<Layout> for Register<Layout, (R, UnsafeWrite), Io>
impl<Layout, R, Io> UnsafeWriteReg<Layout> for Register<Layout, (R, UnsafeWrite), Io>
Auto Trait Implementations§
impl<Layout, Access, Io> Freeze for Register<Layout, Access, Io>where
Io: Freeze,
impl<Layout, Access, Io> RefUnwindSafe for Register<Layout, Access, Io>where
Io: RefUnwindSafe,
Layout: RefUnwindSafe,
Access: RefUnwindSafe,
impl<Layout, Access, Io> Send for Register<Layout, Access, Io>where
Io: Send,
Layout: Send,
Access: Send,
impl<Layout, Access, Io> Sync for Register<Layout, Access, Io>where
Io: Sync,
Layout: Sync,
Access: Sync,
impl<Layout, Access, Io> Unpin for Register<Layout, Access, Io>where
Io: Unpin,
Layout: Unpin,
Access: Unpin,
impl<Layout, Access, Io> UnsafeUnpin for Register<Layout, Access, Io>where
Io: UnsafeUnpin,
impl<Layout, Access, Io> UnwindSafe for Register<Layout, Access, Io>where
Io: UnwindSafe,
Layout: UnwindSafe,
Access: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)