nuttx/include/nuttx
Marco Casaroli e0cc0244c5 fs/xipfs: Add a contiguous execute-in-place file system.
ROMFS is the usual way to carry executables on a NOMMU target with memory
mapped NOR flash: it can hand out a real flash pointer from mmap(), so the
NXFLAT loader maps a module's text in place instead of copying it into RAM.
But a ROMFS image is built on the host and is read only, so a module cannot
be downloaded onto the board at run time.

xipfs is a writable file system with the same in-place property.  Each file
is stored as one physically contiguous, erase-block aligned extent, so an
mmap() of it resolves to flash_base + extent_offset and a loader can execute
the file where it already lies.  This needs the underlying MTD driver to
answer BIOC_XIPBASE; on the RP2350 rp23xx_flash_mtd.c does.

Files are write once.  A file is created, its size is declared, it is
written sequentially, closed, and is thereafter immutable until it is
deleted.  That is the whole life cycle of a downloaded module, and it is
what licenses the design: the exact extent is reserved at create time, so
no file ever grows, moves, or fragments internally.  Random writes, appends
and truncation of a written file are not supported and are refused.

The only source of fragmentation is therefore free space holes left by
deletes.  Allocation fails with -ENOSPC when no single contiguous run is
large enough, and never defragments on its own; the caller decides whether
to compact and retry, through XIPFSIOC_DEFRAG.  Defragmentation is manual,
best effort and interruptible: it is a loop of atomic single-extent
relocations, each one copy, commit, erase, so every stop point -- a time
budget, a pinned extent, an erase error -- leaves a consistent layout that
is simply less compact.  It reports the largest contiguous run it achieved,
which is what tells the caller whether the retry will fit.

Metadata is committed power safely.  Two metadata block sets are used in
ping-pong, each generation carrying a sequence number and a CRC, and every
state change is ordered as write the new data, flip the metadata reference,
then erase what the old one referenced.  Mount scans both sets and selects
the last fully valid generation, so a torn write costs the interrupted
operation and nothing else.

A mapping takes a pin on the extent, and the pin lives on the extent rather
than on the file descriptor, so three running instances of one module hold
three pins and the extent becomes movable only when the last one goes.
Defragmentation skips pinned extents, which is what stops it relocating
code that is executing.  The pin is released by munmap() or by the task
teardown walk, so a task that dies without unmapping does not leak it.

Directories are records in that same generation, carrying their own identity
and the identity of the directory holding them; the root is implicit and owns
identity zero.  They are deliberately NOT objects in the data region, which
is what keeps the commit story in one piece: mkdir and rmdir add or remove a
record and commit one generation, exactly as create and unlink do, so there
is never a multi-object update to journal or an orphan to collect at mount.
An empty directory therefore exists, survives a remount, and costs one entry
out of the volume's fixed supply and no flash blocks at all.

A name is one path component; depth comes from the parent, so XIPFS_NAME_MAX
bounds a component, which is what statfs reports it as.  Mount rebuilds the
tree and checks that it is one: identities unique, names unique within a
directory, every parent a live directory, and following parents reaching the
root -- a cycle on the medium would otherwise hang a path walk rather than
merely answering wrongly.  '.' and '..' are refused as components, since an
entry stored under either could never be reached again.

The commands that act on the volume rather than on one file --
XIPFSIOC_DEFRAG and XIPFSIOC_LISTPINNED -- are reached through the ioctldir
method, on a descriptor for the mountpoint directory.  They are accepted on
a descriptor for a file inside the volume too, but that route holds the file
open for the duration and an open extent cannot be relocated, so a pass
asked for that way is obstructed by the act of asking.

mmap() falls back to the generic RAM copy for ordinary readers when the
media cannot be addressed directly.  A module loader must not silently get
a RAM copy, so MAP_XIP_STRICT is added: with it the mapping either resolves
in place or fails with -ENXIO, which the caller can turn into defragment
and retry.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-07-29 07:49:03 -03:00
..
1wire 1wire: Move onewire_valid_rom to 1wire_crc.h 2026-06-26 22:50:43 +08:00
aie nuttx ai driver update 2024-10-17 22:35:40 +08:00
analog stm32h7/dac: add DMA stream mode with ioctl-driven double-buffering 2026-07-26 14:26:47 -03:00
audio drivers/audio/i2s: Fix unsigned integers in function signatures 2026-07-05 15:06:04 +08:00
binfmt binfmt: Add a configuration flag to store the module filename 2025-11-01 22:59:47 +08:00
can sja1000: replace enter_critical_section with spinlock 2026-01-08 09:15:04 -03:00
clk drivers/clk: use uintptr_t for register addresses 2026-06-18 21:52:33 +08:00
contactless include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
coresight style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
crypto drivers/crypto: add Microchip RNG90 driver 2026-06-14 18:41:09 +08:00
dma include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
drivers serial/uart_rpmsg: add _raw version of driver 2026-02-23 09:19:57 -03:00
eeprom mtd/at25ee: Use eeprom/spi_xx25xx internally 2025-12-17 19:03:54 +01:00
efuse include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
fs fs/xipfs: Add a contiguous execute-in-place file system. 2026-07-29 07:49:03 -03:00
himem include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
hwspinlock include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
i2c drivers/i2c: add ioexpander-based lower-half implementation for I2C bit-bang 2026-01-01 17:08:47 +08:00
i3c style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
input drivers/mpr121: Add support to MPR121 Capacitive Keypad 2026-04-23 15:56:32 -03:00
ioexpander drives/ioexpander: add support to PI4IOE IO Expander 2026-07-28 10:18:01 +08:00
lcd style: Fix "the the" typo across the codebase. 2026-03-23 11:07:49 +01:00
leds !drivers/pwm: remove PWM_MULTICHAN option 2026-05-18 11:35:25 -04:00
lib lib/math32: Avoid __uint128_t casts for LDC ImportC 2026-07-21 17:11:03 -03:00
math drivers/math: use small lock to replace enter_critical_section 2026-01-08 11:17:17 +08:00
mbox include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
mm protect: move us_heap to userspace_data_s 2026-02-02 11:06:53 +08:00
modem style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
motor style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
mtd drivers/mtd/gd25: add QSPI support 2026-06-21 09:43:29 -03:00
net boards/mips: Add networking support to CI20 board 2026-07-17 16:14:14 -03:00
note note/ram: support multiple noterams to dump data when panic occurs 2026-01-24 19:33:17 +08:00
nx nuttx/nx: compilation error occurs 2026-04-14 13:35:26 +08:00
pci drivers/pci:write legacy num to config space when enable legacy irq 2026-01-30 12:50:42 +08:00
pinctrl include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
power style: Fix "the the" typo across the codebase. 2026-03-23 11:07:49 +01:00
rc style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
regmap include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
reset style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
rf include: migrate license to ASF 2024-11-06 19:46:13 +08:00
rpmsg drivers/rpmsg: use NuttX atomic_t API instead of C11 atomics 2026-05-21 06:28:36 +08:00
rptun rptun: add configuring the stack of rptun as static 2026-01-19 14:18:27 +08:00
segger include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
sensors drivers/sensors: add LIS3DSH accelerometer uORB driver 2026-07-25 14:45:40 +02:00
serial drivers/serial: Modify serial/pty to allow NSH/Telnet line edit 2026-07-22 22:07:18 +08:00
spi stm32h5/qspi: add QSPIMEM_QUADDATA flag for 1-1-4 transfers 2026-06-21 09:43:29 -03:00
syslog driver/ramlog: Implement the rate limiting function for ramlog driver. 2026-01-27 03:17:05 +08:00
timers drivers/watchdog: fix capture automonitor notifier context 2026-07-17 14:59:47 +08:00
usb drivers/usbhost/usbhost_cdcecm.c: Added support for Host CDC-ECM 2026-05-06 06:20:03 +08:00
usrsock include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
vhost drivers/vhost: add vhost_get_vq_buffers() to collect scatter-gather buffers 2026-02-04 02:32:02 +08:00
video video/fb: fix compilation errors 2026-04-13 19:55:44 +08:00
virtio include/nuttx/virtio: allow common virtio helpers to be used by vhost 2026-02-04 02:32:02 +08:00
wireless wireless/cc1101: Add MSK/4-FSK, dynamic PATABLE ramping, and fix IOCTL safety 2026-03-11 16:05:19 +01:00
.gitignore
addrenv.h addrenv: support addrenv when mpu is used 2026-01-26 16:27:19 +08:00
allsyms.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
arch.h style: Fix "the the" typo across the codebase. 2026-03-23 11:07:49 +01:00
ascii.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
atexit.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
atomic.h include/nuttx/atomic.h: fix C++ definition conflicts 2025-12-22 15:27:39 +08:00
bits.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
board.h drivers/usbhost/usbhost_enumerate.c: Allow selecting USB configuration 2026-05-06 06:20:03 +08:00
cache.h nuttx/cache.h: fix the compile warning in sim when enable OpenAMP 2025-12-31 02:36:29 +08:00
can.h drivers/can: move CAN utils to CAN common files 2025-05-14 10:30:25 -03:00
cancelpt.h sched/cancelpt: Fix MISRA C 2012 Rule 10.4 violations 2026-02-02 21:09:40 +08:00
circbuf.h lib/circbuf: add static initialize macro helper 2024-12-17 20:48:23 +08:00
clock.h !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
clock_notifier.h fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes 2026-01-30 17:20:24 +08:00
compiler.h float.h: improve long double related definitions 2026-07-02 09:02:21 -03:00
coredump.h coredump: fix issue that nvic region overlapped by board memory region 2025-01-24 09:15:56 +08:00
crc8.h libs/crc: implement AUTOSAR-compatible CRC algorithm 2026-01-30 17:32:15 +08:00
crc16.h libs/crc: implement AUTOSAR-compatible CRC algorithm 2026-01-30 17:32:15 +08:00
crc32.h libc/crc32: add IEEE-compatible crc32_ieee for Linux/zlib interop 2026-07-03 10:18:28 +08:00
crc64.h !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
debug.h include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
elf.h nuttx/elf.h: Fix build error with unknown type name 'bool'. 2024-10-15 12:35:10 +08:00
environ.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
envpath.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
ethtool.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
event.h [!] sched/event: Remove wait object dependency from event implementation 2025-10-31 19:56:32 -03:00
fdcheck.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
fdt.h qemu/armv7a: register cfi flash 2025-02-11 17:23:44 +08:00
gdbstub.h gdbstub: change send buffer to const char 2025-01-20 20:07:13 +08:00
hashtable.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
hrtimer.h sched/hrtimer: Update the comments. 2026-02-02 13:26:22 +08:00
idr.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
init.h sched: add trace points during system startup and board initialization 2026-01-27 03:18:11 +08:00
instrument.h style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
ipcc.h style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
irq.h sched/irq: Consolidate IRQ bounds checking into IRQ_TO_NDX macro 2026-01-28 13:35:30 +08:00
kmalloc.h userspace: Exclude nuttx/arch.h 2024-11-01 16:59:37 +08:00
kthread.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
lin.h LIN:adjust the LIN flag 2026-01-08 23:15:31 +08:00
lirc.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
list.h list: Fix the list conflicts. 2026-01-19 14:12:09 +08:00
list_type.h list: Fix the list conflicts. 2026-01-19 14:12:09 +08:00
macro.h macro: use portable variadic macros 2026-01-22 22:14:00 +08:00
memoryregion.h libs/misc/memoryregion: remove unused memory_region 2024-10-18 21:32:48 +08:00
mmcsd.h mmcsd:add postsleep fields for mmc_ioc_cmd 2024-10-15 02:06:00 +08:00
module.h libc/elf: rename modlib to libelf 2025-04-11 09:43:22 +08:00
mqueue.h !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
mutex.h sched/pthread: move pthread mutex from syscall to user-space 2026-01-22 12:40:49 -03:00
notifier.h include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
nuttx.h macro/align: Fix ALIGN_UP and ALIGN_DOWN 2025-01-11 12:13:10 +08:00
page.h style: Fix "is is" typo across the codebase. 2026-03-24 09:39:26 +08:00
panic_notifier.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
pgalloc.h mm/gran: add gran_alloc_align API 2025-05-12 15:01:37 +08:00
progmem.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
pthread.h pthread: move pthread_cond to userspace 2026-01-26 16:26:39 +08:00
queue.h include: queue.h: Make flink clear after sq_rem 2024-10-16 13:56:49 +08:00
random.h libc: Refine the arc4random_buf implementation 2024-10-26 18:04:21 -03:00
reboot_notifier.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
rwsem.h sched/sem_rw.c: Add downgrade_write API for sem_rw 2026-01-07 22:47:09 +08:00
sched.h arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y 2026-06-16 17:07:32 +08:00
sched_note.h note: add NOTE_DUMP_BINARY support for binary log dumping 2026-01-27 21:56:03 +08:00
scsi.h style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
sdio.h arch/arm/src/stm32{h7,f7,l4}: add 4-bit wide bus support for MMC/eMMC cards 2026-07-21 08:51:38 -03:00
sdio_slave.h style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
semaphore.h include/nuttx/semaphore.h: parenthesize NXSEM helper args 2026-06-05 10:35:46 -04:00
seqlock.h seqlock: Fix struct name and constants. 2025-12-22 10:22:06 -03:00
signal.h sched/signal: Remove shadow definitions to reduce unnecessary API 2025-10-14 17:40:18 +08:00
spawn.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
spinlock.h sched/spinlock: Add time statistics in func enter_critical_section(). 2026-01-27 21:59:14 +08:00
spinlock_type.h seqlock: Fix struct name and constants. 2025-12-22 10:22:06 -03:00
streams.h libc/stream: Add support for lib_scanf 2025-06-20 09:48:39 +08:00
symtab.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
tee.h drivers/misc/optee: Expanded RPC support. 2025-08-06 02:29:33 +08:00
thermal.h drivers/thermal: Add support for passive trip point 2025-02-16 11:22:41 -03:00
tls.h pthread: remove tl_lock 2026-01-26 20:56:12 +08:00
trace.h trace: fix macro line continuation formatting 2026-01-25 10:45:26 -03:00
uorb.h drivers/sensors: add initial support for fixed-point data for sensors 2026-05-02 00:56:42 +08:00
userspace.h protect: move us_heap to userspace_data_s 2026-02-02 11:06:53 +08:00
vt100.h Documentation: nsh: document the top command 2026-07-11 09:15:15 -03:00
wdog.h drivers: Fix comment typos — 'Pubic' → 'Public' across drivers and headers. 2026-07-02 13:29:48 +08:00
wqueue.h !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
zoneinfo.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00