mmap() device memory
Prev | Chapter 4. Writing a driver in userspace | Next

## mmap() device memory

After you made sure you've got the right device with the memory mappings you need, all you have to do is to call `mmap()` to map the device's memory to userspace.

The parameter `offset` of the `mmap()` call has a special meaning for UIO devices: It is used to select which mapping of your device you want to map. To map the memory of mapping N, you have to use N times the page size as your offset:

    	offset = N * getpagesize();

N starts from zero, so if you've got only one memory range to map, set `offset = 0`. A drawback of this technique is that memory is always mapped beginning with its start address.

Prev | Up | Next
Chapter 4. Writing a driver in userspace | Home | Waiting for interrupts