In this recipe, we will see how to map an I/O memory region within the process memory space to gain access to our peripheral's internal by simply using a pointer in memory.
Accessing I/O memory with mmap()
Getting ready
Now, let's see how we can implement a custom mmap() system call for our chrdev driver.
Since we have a virtual device totally mapped into memory, we may suppose that the buf buffer within struct chrdev_device represents the memory areas to be mapped. Also, we need to dynamically allocate it for it to be remapped; this is due to the fact that kernel virtual memory addresses cannot be remapped using the remap_pfn_range() function.
This is the only limitation of remap_pfn_range(), which is unable to...