So, how exactly can you access and perform I/O (reads and writes) on peripheral I/O memory via the MMIO approach? The kernel provides APIs allowing you to both read and write chip memory. By using these APIs (or macros/inline functions), you can perform I/O, such as reads and writes, in four possible bit-widths; that is, 8-bit, 16-bit, 32-bit, and, on 64-bit systems, 64-bit:
- MMIO reads: ioread8(), ioread16(), ioread32(), and ioread64()
- MMIO writes:Â iowrite8(), iowrite16(), iowrite32(), and iowrite64()
The signatures of the I/O read routines are as follows:
#include <linux/io.h>
u8 ioread8(const volatile void __iomem *addr);
u16 ioread16(const volatile void __iomem *addr);
u32 ioread32(const volatile void __iomem *addr);
#ifdef CONFIG_64BIT
u64 ioread64(const volatile void __iomem *addr);
#endif
The single parameter for the ioreadN() APIs is the address of the I/O memory location that must be read from. Typically...