Loading...
Searching...
No Matches
xipfs_fs.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024-2026 Université de Lille
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
19
20#ifndef FS_XIPFS_FS_H
21#define FS_XIPFS_FS_H
22
23#include "vfs.h"
24#include "mtd_flashpage.h"
25#include "mutex.h"
26#include "include/xipfs.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
47#define XIPFS_PARTITION_CORE(id, path, data, data_bytesize) \
48 static mutex_t execution_mutex_##id = MUTEX_INIT; \
49 static mutex_t mutex_##id = MUTEX_INIT; \
50 static vfs_xipfs_mount_t id = { \
51 .vfs_mp = { \
52 .fs = &xipfs_file_system, \
53 .mount_point = path, \
54 }, \
55 .magic = XIPFS_MAGIC, \
56 .mount_path = path, \
57 .page_num = data_bytesize / XIPFS_NVM_PAGE_SIZE, \
58 .page_addr = (void *)data, \
59 .execution_mutex = &execution_mutex_##id, \
60 .mutex = &mutex_##id \
61 }
62
73#define XIPFS_NEW_PARTITION(id, path, num) \
74 FLASH_WRITABLE_INIT(xipfs_part_##id, num); \
75 XIPFS_PARTITION_CORE(id, path, xipfs_part_##id, num * XIPFS_NVM_PAGE_SIZE)
76
89#define XIPFS_START_PARTITION_INCLUSION(id) \
90 __attribute__((aligned(XIPFS_NVM_PAGE_SIZE))) \
91 __attribute__((section(".rodata.xipfs." #id)))
92
105#define XIPFS_END_PARTITION_INCLUSION(id, path, data, data_bytesize) \
106 XIPFS_PARTITION_CORE(id, path, data, data_bytesize)
107
135
138
160int xipfs_construct_from_flashpage(mtd_flashpage_t *flashpage, const char *path,
161 mutex_t *execution_mutex, mutex_t *mutex,
162 vfs_xipfs_mount_t *vfs_xipfs_mount);
163
164/* Extended driver handling executables */
165
178int xipfs_extended_driver_new_file(const char *full_path, uint32_t size,
179 uint32_t exec);
180
192int xipfs_extended_driver_execv(const char *full_path, char *const argv[]);
193
194#ifdef XIPFS_ENABLE_SAFE_EXEC_SUPPORT
195
208int xipfs_extended_driver_safe_execv(const char *full_path,
209 char *const argv[]);
210
211#endif /* XIPFS_ENABLE_SAFE_EXEC_SUPPORT */
212
213#ifdef __cplusplus
214}
215#endif
216
217#endif /* FS_XIPFS_FS_H */
struct vfs_mount_struct vfs_mount_t
struct vfs_mount_struct typedef
Definition vfs.h:371
int xipfs_extended_driver_execv(const char *full_path, char *const argv[])
Executes an executable file with arguments.
const vfs_file_system_t xipfs_file_system
The xipfs vfs driver.
int xipfs_extended_driver_new_file(const char *full_path, uint32_t size, uint32_t exec)
Executable or regular new file.
int xipfs_construct_from_flashpage(mtd_flashpage_t *flashpage, const char *path, mutex_t *execution_mutex, mutex_t *mutex, vfs_xipfs_mount_t *vfs_xipfs_mount)
vfs_xipfs_mount_t constructor from a mtd_flashpage_t.
struct vfs_xipfs_mount_s vfs_xipfs_mount_t
xipfs descriptor for vfs integration.
Interface definition for the flashpage memory driver.
Mutex for thread synchronization.
MTD flashpage descriptor.
Mutex structure.
Definition mutex.h:36
A file system driver.
Definition vfs.h:386
xipfs descriptor for vfs integration.
Definition xipfs_fs.h:126
size_t page_num
number of flash page
Definition xipfs_fs.h:130
mutex_t * mutex
For regular and deletion operations.
Definition xipfs_fs.h:133
mutex_t * execution_mutex
For execution and deletion operations.
Definition xipfs_fs.h:132
const char * mount_path
mount point path
Definition xipfs_fs.h:129
unsigned magic
xipfs magic number
Definition xipfs_fs.h:128
vfs_mount_t vfs_mp
VFS mount point.
Definition xipfs_fs.h:127
void * page_addr
first flash page address
Definition xipfs_fs.h:131