Welcome to the Linux Foundation Forum!

how to interpret uio maps/mapN/addr value?

Options
ags
ags Posts: 1

I'm using a BeagleBone Black and using the onboard real-time microcontroller (PRUSS) that is exposed through uio. Reading the documentation here: https://www.kernel.org/doc/htmldocs/uio-howto/about.html

says this:

From userspace, 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...

What does this mean? If .../maps/mapN/addr provides the address used to access the io device, then why is there a need for an additional offset (in increments of the page size) for each individual map (io device's accessible memory region)? In the Angstrom distro provided withe the BBB, the PRUSS uio kernel driver seems to provide the physical memory offset to the PRUSS as the value of maps/map0/addr, and the physical memory offset to DRAM reserved by the uio_pruss driver as the value of maps/map1/addr. However, examples provided on how to use the uio_pruss driver here: https://github.com/beagleboard/am335x_pru_package/blob/master/pru_sw/app_loader/interface/prussdrv.c maps physical memory with this statement:

prussdrv.extram_base =

mmap(0, prussdrv.extram_map_size, PROT_READ | PROT_WRITE,

MAP_SHARED, prussdrv.mmap_fd, PRUSS_UIO_MAP_OFFSET_EXTRAM);

which uses a hardcoded values set here: https://github.com/beagleboard/am335x_pru_package/blob/master/pru_sw/app_loader/interface/__prussdrv.h to these values, which don't use the maps/map<0/1>/addr values at all:

#define PAGE_SIZE 4096

#define PRUSS_UIO_MAP_OFFSET_PRUSS 0*PAGE_SIZE

#define PRUSS_UIO_MAP_OFFSET_EXTRAM 1*PAGE_SIZE

and then calculate the value of the DRAM address by adding one page to the address returned by maps/map0/addr. This doesn't seem correct, although I can see where it came from in the documentation quoted above.

So how are the maps/mapN/addr values supposed to be used correctly?

Categories

Upcoming Training