diff options
| author | Damien George <damien@micropython.org> | 2022-03-04 10:52:35 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-12-23 13:04:54 +1100 |
| commit | 50637ff239cb6a09294f49fe2d2534c2d7ae8b76 (patch) | |
| tree | 0ae529c80982e0d9ecce6534065ae67a3dca4268 /extmod/modvfs.c | |
| parent | 4729a895046908414b239f02256ac3334d1b2c15 (diff) | |
extmod/vfs_rom: Add VfsRom filesystem object.
This commit defines a new ROMFS filesystem for storing read-only files that
can be memory mapped, and a new VfsRom driver. Files opened from this
filesystem support the buffer protocol. This allows naturally getting the
memory-mapped address of the file using:
- memoryview(file)
- uctypes.addressof(file)
Furthermore, if these files are .mpy files then their content can be
referenced in-place when importing. Such imports take up a lot less RAM
than importing from a normal filesystem. This is essentially dynamically
frozen .mpy files, building on the revamped v6 .mpy file format.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/modvfs.c')
| -rw-r--r-- | extmod/modvfs.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/extmod/modvfs.c b/extmod/modvfs.c index 32dc0e5d0..df422365b 100644 --- a/extmod/modvfs.c +++ b/extmod/modvfs.c @@ -32,6 +32,7 @@ #include "extmod/vfs_fat.h" #include "extmod/vfs_lfs.h" #include "extmod/vfs_posix.h" +#include "extmod/vfs_rom.h" #if !MICROPY_VFS #error "MICROPY_PY_VFS requires MICROPY_VFS" @@ -51,6 +52,9 @@ static const mp_rom_map_elem_t vfs_module_globals_table[] = { #if MICROPY_VFS_LFS2 { MP_ROM_QSTR(MP_QSTR_VfsLfs2), MP_ROM_PTR(&mp_type_vfs_lfs2) }, #endif + #if MICROPY_VFS_ROM + { MP_ROM_QSTR(MP_QSTR_VfsRom), MP_ROM_PTR(&mp_type_vfs_rom) }, + #endif #if MICROPY_VFS_POSIX { MP_ROM_QSTR(MP_QSTR_VfsPosix), MP_ROM_PTR(&mp_type_vfs_posix) }, #endif |
