mmap EINVAL error on UIO device

江枫思渺然 提交于 2019-12-07 07:15:25

mmap offset is handled differently for /dev/mem then for UIO devices. It is not possible to use an arbitrary offset, instead it is only possible to map the start of each region. The above example only has one region defined in the device tree but it is possible to define multiple regions:

reg = <0x40000000 0x10000>,
      <0x40010000 0x10000>,
      <0x40020000 0x10000>,
      <0x40030000 0x10000>;
reg-names = "region0", "id", "region2", "gpio";

Access to each region/mapping is not obvious, as described here: https://lwn.net/Articles/232575/

The offset for accessing the n-th regions should be:

n * sysconf(_SC_PAGESIZE)

On arm the page size is a 12 bit window 0x1000.

Some more generic documentation. http://elinux.org/images/b/b0/Uio080417celfelc08.pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!