JianyuWang0623 opened a new pull request, #22091:
URL: https://github.com/apache/nuttx/pull/22091
## Summary
This series makes /dev/mem behave as a single linearized file over its
memory regions and fixes multi-region access:
1. misc/dev_mem.c:add <nuttx/fs/fs.h> to fix compile error
2. misc/dev_mem.c:support memory device to write custom memory addr
3. driver/dev_mem: Support seek function
4. drivers/misc: fix devmem_read/write to correctly handle f_pos across
multiple regions
5. drivers/misc: Fix Coverity dead code in dev_mem.c
## Impact
- /dev/mem read/write: f_pos becomes a file offset into the concatenated
regions instead of an absolute address. Users that lseek()ed to absolute
addresses must switch to offsets (or raw memory access).
- New: devmem_register_region() registers a mem device with a custom
region set at a chosen path (registered with the same 0600 permissions
as /dev/mem).
- SEEK_END now supported (total of all region sizes).
- Behavior-neutral: Coverity dead-code fix; header include fix restores
CONFIG_DEV_MEM=y builds.
## Testing
qemu-armv8a:nsh, CONFIG_DEV_MEM=y, regions .text 323584 / .data 16 /
.bss 67152 (total 390752 bytes); baseline is master with only the
<nuttx/fs/fs.h> include added so it builds:
- sequential read: 390752 bytes on both (whole .text+.data+.bss)
- SEEK_END: ENOSYS on master, 390752 with this series
- lseek to .data/.bss offsets then read: wrong data on master (returns
.text bytes), correct (memcmp=0) with this series
- lseek to absolute addresses then read: works on master, -EINVAL here
(offset semantics)
- mmap at absolute addresses: identical and correct on both; mmap at a
file offset: -EINVAL on both
- devmem_register_region: two 64-byte custom regions, sequential and
cross-region read/write/seek all correct
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]