(c) Copyright 2026 Roche
This driver provides a UIO interface to the register map of a PCI device and to a shared memory region.
The module requires 4 parameters to be set:
shm_offset: Offset of the shared memory region in the physical address space.shm_length: Length of the shared memory region.pcie_vendor_id: PCIe vendor ID of the device to be mapped.pcie_device_id: PCIe device ID of the device to be mapped.
These parameters can be set either through the kernel command line or while loading the module.
uioaccess.shm_offset=XXG uioaccess.shm_length=YYG uioaccess.pcie_vendor_id=0xXXXX uioaccess.pcie_device_id=0xXXXXor as parameters to the modprobe command:
modprobe uioaccess shm_offset=XXG shm_length=YYG pcie_vendor_id=0x0BAD pcie_device_id=0xCAFEThe default offset and length are XG and YYG respectively. These are
invalid values since they cannot be converted to addresses, leading to an error
while loading the module. This ensures that the module does not use random
default values that might lead to system instability.
Valid values must be part of a reserved memory region either defined through
the memmap=YYG$XG kernel command line, through the device tree, or other means.
If an unreserved memory region is used, the user space application might crash the
system when accessing the mapping. The module does not check whether the
provided memory region is reserved or not.
The registered UIO device has the name uioaccess and offers two mappings:
shm and register_map. These mappings can be mapped into user space using
the mmap system call and used by the software.
The name of the UIO device can be queried using the following path:
/sys/class/uio/uioX/name
where X is the number of the UIO device.
The name of the mappings can be queried using the following path:
/sys/class/uio/uioX/maps/mapY/name
where X is the number of the UIO device and Y is the number of the mapping.
The address of the mappings can be queried using the following path:
/sys/class/uio/uioX/maps/mapY/addr
where X is the number of the UIO device and Y is the number of the mapping.
addr is the physical address of the mapping.
The size of the mappings can be queried using the following path:
/sys/class/uio/uioX/maps/mapY/size
where X is the number of the UIO device and Y is the number of the mapping.
size is the size, in bytes, of the mapping.
The offset of the mappings can be queried using the following path:
/sys/class/uio/uioX/maps/mapY/offset
where X is the number of the UIO device and Y is the number of the mapping.
offset is the offset, in bytes, that has to be added to the pointer returned
by mmap() to get to the actual device memory. This is important if the device’s
memory is not page-aligned. Remember that pointers returned by mmap() are
always page-aligned, so it is good style to always add this offset.
The UIO device can be opened using the following path:
/dev/uioX
where X is the number of the UIO device.
The UIO device can be closed using the close system call.
The mappings can be mapped into user space using the mmap system call.
The mappings can be unmapped from user space using the munmap system call.
From user space, the different mappings are distinguished by adjusting the
offset parameter of the mmap() call. To map the memory of mapping N, you have
to use N times the page size as your offset:
offset = N * getpagesize();