feat: UIO backend support for multiple memory maps#563
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
I just had a quick glance, the general coding style looks good and modern. The formatting is not to our style tough, please run clang-format (if you use dragon, simply call The only "real" comment I have is that there are no tests. Do you feel confident enough to extend the |
|
Not sure the dummy supports this either, but leaning towards "no" |
Hi, Where can I find |
|
The dummy is available from the ChimeraTK github https://github.com/ChimeraTK/uio-dummy |
Thank you. In principle, I can look at it and try extending the module and and the tests.. Though I do not have kernel development experience. Therefore I will need some time to see if I am able to do the required modifications. |
…dexValid available before opening the device
|
Additional test-related changes:
NotesTest passes on modified |
UIO backend: support for multiple memory maps
Previously the UIO backend only supported a single memory-mapped region (map0) and rejected any
access to other maps. This MR extends it to support up to
MAX_UIO_MAPS(5) regions, matchingthe mainline kernel limit.
Changes
UioMapas a private inner class ofUioAccess, encapsulating the lifecycle of asingle UIO memory region. It is move-only (copy deleted), uses RAII for
mmap/munmap, andvalidates address bounds on every read/write with detailed error messages.
getMap(), avoiding unnecessarymmapcallsfor regions that are never used.
open()now probes the sysfs directory tree to count how many maps the device exposes, storingthe result in
_maps_number.mapIndexValid()is exposed publicly soUioBackend::barIndexValid()can delegate to it,replacing the hardcoded
bar == 0check.UioMMap()/UioUnmap()helpers and the single-map fields (_deviceUserBase,_deviceKernelBase,_deviceMemSize).std::format(C++23) instead of+concatenation.= defaultconstructor,nullptrforNULL,static_cast<off_t>for the
mmapoffset narrowing conversion.testUioBackendUnified.cpp. SetBSP.*registers inuioBackendTest.mapptomap0,FCM.*registers tomap2and all other registers tomap1.BROKEN.REGto unmappedmap3to check that the backend generates an exception on access.Notes
Test passes on modified
uio-dummymodule of ChimeraTK/uio-dummy#18