IoMem in kernel::io_mem
A mapped hardware window is reached through an IoMem value that carries the window's size in its type. You read and write device registers through width-specific calls, readb for one byte up to readq…
Talking to hardware means reading and writing at fixed offsets inside a mapped window, in exactly the width the device expects, with the compiler forbidden from optimising the accesses away or reordering them. The kernel crate's input and output type provides width-specific operations and checks the offset against the window's size, at compile time when the size is known and at run time through a fallible variant when it is not. That removes the C bug of an offset that walks past the end of the mapping into whatever is next in the address space. It also stops you reading a four-byte register two bytes at a time, which some devices simply refuse.
A mapped hardware window is reached through an IoMem value that carries the window's size in its type. You read and write device registers through width-specific calls, readb for one byte up to readq…