In our preceding recipes, we used MMIO to access peripheral devices from user-space Linux applications. This interface, however, is not the recommended way of communication between user-space applications and device drivers.
In Unix-like operating systems such as Linux, most of the peripheral devices can be accessed in the same way as regular files using so-called device files. When an application opens a device file, it can read from it, fetching data from the corresponding device, or write to it, sending data to the device.
In many cases, device drivers cannot work with unstructured data streams. They expect data exchange organized in the form of requests and responses, where each request and response has a specific and fixed format.
This kind of communication is covered by the ioctl system call. It accepts a device-dependant...