Optimized use of memory pools.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15206 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
a4faaf9a79
commit
24d0d0e4fb
|
@ -113,17 +113,20 @@ static bool fs_ready = false;
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/* VFS overlay driver object representing the root directory.*/
|
/* VFS overlay driver object representing the root directory.*/
|
||||||
static vfs_overlay_driver_c root_driver;
|
static vfs_overlay_driver_c root_overlay_driver;
|
||||||
|
|
||||||
vfs_driver_c *vfs_root = (vfs_driver_c *)&root_driver;
|
|
||||||
|
|
||||||
/* VFS streams driver object representing the /dev directory.*/
|
/* VFS streams driver object representing the /dev directory.*/
|
||||||
static vfs_streams_driver_c vfs_dev;
|
static vfs_streams_driver_c vfs_dev;
|
||||||
|
|
||||||
|
/* VFS FatFS driver object representing the root directory.*/
|
||||||
|
static vfs_fatfs_driver_c root_driver;
|
||||||
|
|
||||||
|
vfs_driver_c *vfs_root = (vfs_driver_c *)&root_overlay_driver;
|
||||||
|
|
||||||
static NullStream nullstream;
|
static NullStream nullstream;
|
||||||
|
|
||||||
/* Stream to be exposed under /dev as files.*/
|
/* Stream to be exposed under /dev as files.*/
|
||||||
static const drv_stream_element_t streams[] = {
|
static const drv_streams_element_t streams[] = {
|
||||||
{"VSD1", (BaseSequentialStream *)&PORTAB_SD1},
|
{"VSD1", (BaseSequentialStream *)&PORTAB_SD1},
|
||||||
{"null", (BaseSequentialStream *)&nullstream},
|
{"null", (BaseSequentialStream *)&nullstream},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
|
@ -244,10 +247,12 @@ int main(void) {
|
||||||
* and performs the board-specific initializations.
|
* and performs the board-specific initializations.
|
||||||
* - Kernel initialization, the main() function becomes a thread and the
|
* - Kernel initialization, the main() function becomes a thread and the
|
||||||
* RTOS is active.
|
* RTOS is active.
|
||||||
|
* - Virtual File System initialization.
|
||||||
* - Shell manager initialization.
|
* - Shell manager initialization.
|
||||||
*/
|
*/
|
||||||
halInit();
|
halInit();
|
||||||
chSysInit();
|
chSysInit();
|
||||||
|
vfsInit();
|
||||||
shellInit();
|
shellInit();
|
||||||
|
|
||||||
/* Board-dependent setup code.*/
|
/* Board-dependent setup code.*/
|
||||||
|
@ -266,7 +271,8 @@ int main(void) {
|
||||||
|
|
||||||
/* Initializing an overlay VFS object overlaying a FatFS driver,
|
/* Initializing an overlay VFS object overlaying a FatFS driver,
|
||||||
no need for names, both are root.*/
|
no need for names, both are root.*/
|
||||||
drvOverlayObjectInit(&root_driver, drvFatFSInit(""), "");
|
drvOverlayObjectInit(&root_overlay_driver,
|
||||||
|
drvFatFSObjectInit(&root_driver, ""), "");
|
||||||
#else
|
#else
|
||||||
/* Initializing an overlay VFS object as a root, no overlaid driver,
|
/* Initializing an overlay VFS object as a root, no overlaid driver,
|
||||||
no need for a name.*/
|
no need for a name.*/
|
||||||
|
@ -274,7 +280,7 @@ int main(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Registering a streams VFS driver on the VFS overlay root as "/dev".*/
|
/* Registering a streams VFS driver on the VFS overlay root as "/dev".*/
|
||||||
msg = drvOverlayRegisterDriver(&root_driver,
|
msg = drvOverlayRegisterDriver(&root_overlay_driver,
|
||||||
drvStreamsObjectInit(&vfs_dev,
|
drvStreamsObjectInit(&vfs_dev,
|
||||||
"dev",
|
"dev",
|
||||||
&streams[0]));
|
&streams[0]));
|
||||||
|
|
|
@ -102,9 +102,34 @@ static const struct BaseSequentialStreamVMT file_stream_vmt = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Single FatFS driver instance.
|
* @brief Static members of @p vfs_fatfs_driver_c.
|
||||||
*/
|
*/
|
||||||
vfs_fatfs_driver_c vfs_fatfs;
|
static struct {
|
||||||
|
/**
|
||||||
|
* @brief Pool of file system objects.
|
||||||
|
*/
|
||||||
|
memory_pool_t fs_nodes_pool;
|
||||||
|
/**
|
||||||
|
* @brief Pool of file info objects.
|
||||||
|
*/
|
||||||
|
memory_pool_t info_nodes_pool;
|
||||||
|
/**
|
||||||
|
* @brief Pool of directory nodes.
|
||||||
|
*/
|
||||||
|
memory_pool_t dir_nodes_pool;
|
||||||
|
/**
|
||||||
|
* @brief Pool of file nodes.
|
||||||
|
*/
|
||||||
|
memory_pool_t file_nodes_pool;
|
||||||
|
/**
|
||||||
|
* @brief Static storage of directory nodes.
|
||||||
|
*/
|
||||||
|
vfs_fatfs_dir_node_c dir_nodes[DRV_CFG_FATFS_DIR_NODES_NUM];
|
||||||
|
/**
|
||||||
|
* @brief Static storage of file nodes.
|
||||||
|
*/
|
||||||
|
vfs_fatfs_file_node_c file_nodes[DRV_CFG_FATFS_FILE_NODES_NUM];
|
||||||
|
} vfs_fatfs_driver_static;
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Module local functions. */
|
/* Module local functions. */
|
||||||
|
@ -188,7 +213,7 @@ static msg_t drv_open_dir(void *instance,
|
||||||
vfs_fatfs_dir_node_c *ffdnp;
|
vfs_fatfs_dir_node_c *ffdnp;
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
|
|
||||||
ffdnp = chPoolAlloc(&drvp->dir_nodes_pool);
|
ffdnp = chPoolAlloc(&vfs_fatfs_driver_static.dir_nodes_pool);
|
||||||
if (ffdnp != NULL) {
|
if (ffdnp != NULL) {
|
||||||
|
|
||||||
/* Node object initialization.*/
|
/* Node object initialization.*/
|
||||||
|
@ -202,7 +227,7 @@ static msg_t drv_open_dir(void *instance,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
chPoolFree(&drvp->dir_nodes_pool, (void *)ffdnp);
|
chPoolFree(&vfs_fatfs_driver_static.dir_nodes_pool, (void *)ffdnp);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = translate_error(res);
|
err = translate_error(res);
|
||||||
|
@ -230,7 +255,7 @@ static msg_t drv_open_file(void *instance,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fffnp = chPoolAlloc(&drvp->file_nodes_pool);
|
fffnp = chPoolAlloc(&vfs_fatfs_driver_static.file_nodes_pool);
|
||||||
if (fffnp != NULL) {
|
if (fffnp != NULL) {
|
||||||
|
|
||||||
/* Node object initialization.*/
|
/* Node object initialization.*/
|
||||||
|
@ -245,7 +270,7 @@ static msg_t drv_open_file(void *instance,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
chPoolFree(&drvp->file_nodes_pool, (void *)fffnp);
|
chPoolFree(&vfs_fatfs_driver_static.file_nodes_pool, (void *)fffnp);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = translate_error(res);
|
err = translate_error(res);
|
||||||
|
@ -257,12 +282,11 @@ static msg_t drv_open_file(void *instance,
|
||||||
|
|
||||||
static void node_dir_release(void *instance) {
|
static void node_dir_release(void *instance) {
|
||||||
vfs_fatfs_dir_node_c *ffdnp = (vfs_fatfs_dir_node_c *)instance;
|
vfs_fatfs_dir_node_c *ffdnp = (vfs_fatfs_dir_node_c *)instance;
|
||||||
vfs_fatfs_driver_c *drvp = (vfs_fatfs_driver_c *)ffdnp->driver;
|
|
||||||
|
|
||||||
__referenced_object_release_impl(instance);
|
__referenced_object_release_impl(instance);
|
||||||
if (__referenced_object_getref_impl(instance) == 0U) {
|
if (__referenced_object_getref_impl(instance) == 0U) {
|
||||||
|
|
||||||
chPoolFree(&drvp->dir_nodes_pool, (void *)ffdnp);
|
chPoolFree(&vfs_fatfs_driver_static.dir_nodes_pool, (void *)ffdnp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,11 +311,10 @@ static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
vfs_fatfs_dir_node_c *ffdnp = (vfs_fatfs_dir_node_c *)instance;
|
vfs_fatfs_dir_node_c *ffdnp = (vfs_fatfs_dir_node_c *)instance;
|
||||||
vfs_fatfs_driver_c *drvp = (vfs_fatfs_driver_c *)ffdnp->driver;
|
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
FILINFO *fip;
|
FILINFO *fip;
|
||||||
|
|
||||||
fip = (FILINFO *)chPoolAlloc(&drvp->info_nodes_pool);
|
fip = (FILINFO *)chPoolAlloc(&vfs_fatfs_driver_static.info_nodes_pool);
|
||||||
if (fip != NULL) {
|
if (fip != NULL) {
|
||||||
|
|
||||||
res = f_readdir(&ffdnp->dir, fip);
|
res = f_readdir(&ffdnp->dir, fip);
|
||||||
|
@ -311,7 +334,7 @@ static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) {
|
||||||
err = translate_error(res);
|
err = translate_error(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
chPoolFree(&drvp->info_nodes_pool, (void *)fip);
|
chPoolFree(&vfs_fatfs_driver_static.info_nodes_pool, (void *)fip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (false);
|
while (false);
|
||||||
|
@ -321,12 +344,11 @@ static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) {
|
||||||
|
|
||||||
static void node_file_release(void *instance) {
|
static void node_file_release(void *instance) {
|
||||||
vfs_fatfs_file_node_c *fffnp = (vfs_fatfs_file_node_c *)instance;
|
vfs_fatfs_file_node_c *fffnp = (vfs_fatfs_file_node_c *)instance;
|
||||||
vfs_fatfs_driver_c *drvp = (vfs_fatfs_driver_c *)fffnp->driver;
|
|
||||||
|
|
||||||
__referenced_object_release_impl(instance);
|
__referenced_object_release_impl(instance);
|
||||||
if (__referenced_object_getref_impl(instance) == 0U) {
|
if (__referenced_object_getref_impl(instance) == 0U) {
|
||||||
|
|
||||||
chPoolFree(&drvp->file_nodes_pool, (void *)fffnp);
|
chPoolFree(&vfs_fatfs_driver_static.file_nodes_pool, (void *)fffnp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,6 +465,36 @@ static msg_t file_stream_get(void *instance) {
|
||||||
/* Module exported functions. */
|
/* Module exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Module initialization.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
void __vfs_fatfs_driver_init(void) {
|
||||||
|
|
||||||
|
/* Initializing pools.*/
|
||||||
|
chPoolObjectInit(&vfs_fatfs_driver_static.dir_nodes_pool,
|
||||||
|
sizeof (vfs_fatfs_dir_node_c),
|
||||||
|
chCoreAllocAlignedI);
|
||||||
|
chPoolObjectInit(&vfs_fatfs_driver_static.file_nodes_pool,
|
||||||
|
sizeof (vfs_fatfs_file_node_c),
|
||||||
|
chCoreAllocAlignedI);
|
||||||
|
chPoolObjectInit(&vfs_fatfs_driver_static.info_nodes_pool,
|
||||||
|
sizeof (FILINFO),
|
||||||
|
chCoreAllocAlignedI);
|
||||||
|
chPoolObjectInit(&vfs_fatfs_driver_static.fs_nodes_pool,
|
||||||
|
sizeof (FATFS),
|
||||||
|
chCoreAllocAlignedI);
|
||||||
|
|
||||||
|
/* Preloading pools.*/
|
||||||
|
chPoolLoadArray(&vfs_fatfs_driver_static.dir_nodes_pool,
|
||||||
|
&vfs_fatfs_driver_static.dir_nodes[0],
|
||||||
|
DRV_CFG_FATFS_DIR_NODES_NUM);
|
||||||
|
chPoolLoadArray(&vfs_fatfs_driver_static.file_nodes_pool,
|
||||||
|
&vfs_fatfs_driver_static.file_nodes[0],
|
||||||
|
DRV_CFG_FATFS_FILE_NODES_NUM);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief VFS FatFS object initialization.
|
* @brief VFS FatFS object initialization.
|
||||||
*
|
*
|
||||||
|
@ -452,34 +504,13 @@ static msg_t file_stream_get(void *instance) {
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
vfs_driver_c *drvFatFSInit(const char *rootname) {
|
vfs_driver_c *drvFatFSObjectInit(vfs_fatfs_driver_c *vffdp,
|
||||||
|
const char *rootname) {
|
||||||
|
|
||||||
__base_object_objinit_impl(&vfs_fatfs, &driver_vmt);
|
__base_object_objinit_impl(vffdp, &driver_vmt);
|
||||||
vfs_fatfs.rootname = rootname;
|
vffdp->rootname = rootname;
|
||||||
|
|
||||||
/* Initializing pools.*/
|
return (vfs_driver_c *)vffdp;
|
||||||
chPoolObjectInit(&vfs_fatfs.dir_nodes_pool,
|
|
||||||
sizeof (vfs_fatfs_dir_node_c),
|
|
||||||
chCoreAllocAlignedI);
|
|
||||||
chPoolObjectInit(&vfs_fatfs.file_nodes_pool,
|
|
||||||
sizeof (vfs_fatfs_file_node_c),
|
|
||||||
chCoreAllocAlignedI);
|
|
||||||
chPoolObjectInit(&vfs_fatfs.info_nodes_pool,
|
|
||||||
sizeof (FILINFO),
|
|
||||||
chCoreAllocAlignedI);
|
|
||||||
chPoolObjectInit(&vfs_fatfs.fs_nodes_pool,
|
|
||||||
sizeof (FATFS),
|
|
||||||
chCoreAllocAlignedI);
|
|
||||||
|
|
||||||
/* Preloading pools.*/
|
|
||||||
chPoolLoadArray(&vfs_fatfs.dir_nodes_pool,
|
|
||||||
&vfs_fatfs.drv_dir_nodes[0],
|
|
||||||
DRV_CFG_FATFS_DIR_NODES_NUM);
|
|
||||||
chPoolLoadArray(&vfs_fatfs.file_nodes_pool,
|
|
||||||
&vfs_fatfs.drv_file_nodes[0],
|
|
||||||
DRV_CFG_FATFS_FILE_NODES_NUM);
|
|
||||||
|
|
||||||
return (vfs_driver_c *)&vfs_fatfs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -498,7 +529,7 @@ msg_t drvFatFSMount(const char *name, bool mountnow) {
|
||||||
|
|
||||||
fs = f_getfs(name);
|
fs = f_getfs(name);
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
fs = chPoolAlloc(&vfs_fatfs.fs_nodes_pool);
|
fs = chPoolAlloc(&vfs_fatfs_driver_static.fs_nodes_pool);
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
return VFS_RET_ENOMEM;
|
return VFS_RET_ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -526,7 +557,7 @@ msg_t drvFatFSUnmount(const char *name) {
|
||||||
|
|
||||||
res = f_unmount(name);
|
res = f_unmount(name);
|
||||||
|
|
||||||
chPoolFree(&vfs_fatfs.fs_nodes_pool, (void *)fs);
|
chPoolFree(&vfs_fatfs_driver_static.fs_nodes_pool, (void *)fs);
|
||||||
|
|
||||||
return translate_error(res);
|
return translate_error(res);
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,13 +138,7 @@ typedef struct vfs_fatfs_file_node {
|
||||||
* @brief @p vfs_fatfs_driver_c specific data.
|
* @brief @p vfs_fatfs_driver_c specific data.
|
||||||
*/
|
*/
|
||||||
#define __vfs_fatfs_driver_data \
|
#define __vfs_fatfs_driver_data \
|
||||||
__vfs_driver_data \
|
__vfs_driver_data
|
||||||
memory_pool_t file_nodes_pool; \
|
|
||||||
memory_pool_t dir_nodes_pool; \
|
|
||||||
memory_pool_t info_nodes_pool; \
|
|
||||||
memory_pool_t fs_nodes_pool; \
|
|
||||||
vfs_fatfs_dir_node_c drv_dir_nodes[DRV_CFG_FATFS_DIR_NODES_NUM]; \
|
|
||||||
vfs_fatfs_file_node_c drv_file_nodes[DRV_CFG_FATFS_FILE_NODES_NUM];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p vfs_fatfs_driver_c virtual methods table.
|
* @brief @p vfs_fatfs_driver_c virtual methods table.
|
||||||
|
@ -177,7 +171,9 @@ extern vfs_fatfs_driver_c vfs_fatfs;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
vfs_driver_c *drvFatFSInit(const char *rootname);
|
void __vfs_fatfs_driver_init(void);
|
||||||
|
vfs_driver_c *drvFatFSObjectInit(vfs_fatfs_driver_c *vffdp,
|
||||||
|
const char *rootname);
|
||||||
msg_t drvFatFSMount(const char *name, bool mountnow);
|
msg_t drvFatFSMount(const char *name, bool mountnow);
|
||||||
msg_t drvFatFSUnmount(const char *name);
|
msg_t drvFatFSUnmount(const char *name);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -70,6 +70,20 @@ static const struct vfs_overlay_dir_node_vmt dir_node_vmt = {
|
||||||
.dir_next = node_dir_next
|
.dir_next = node_dir_next
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Static members of @p vfs_overlay_driver_c.
|
||||||
|
*/
|
||||||
|
static struct {
|
||||||
|
/**
|
||||||
|
* @brief Pool of directory nodes.
|
||||||
|
*/
|
||||||
|
memory_pool_t dir_nodes_pool;
|
||||||
|
/**
|
||||||
|
* @brief Static storage of directory nodes.
|
||||||
|
*/
|
||||||
|
vfs_overlay_dir_node_c dir_nodes[DRV_CFG_OVERLAY_DIR_NODES_NUM];
|
||||||
|
} vfs_overlay_driver_static;
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Module local functions. */
|
/* Module local functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -117,7 +131,7 @@ static msg_t drv_open_dir(void *instance,
|
||||||
if (*scanpath == '\0') {
|
if (*scanpath == '\0') {
|
||||||
|
|
||||||
/* Creating a root directory node.*/
|
/* Creating a root directory node.*/
|
||||||
vfs_overlay_dir_node_c *odnp = chPoolAlloc(&drvp->dir_nodes_pool);
|
vfs_overlay_dir_node_c *odnp = chPoolAlloc(&vfs_overlay_driver_static.dir_nodes_pool);
|
||||||
if (odnp != NULL) {
|
if (odnp != NULL) {
|
||||||
|
|
||||||
/* Node object initialization.*/
|
/* Node object initialization.*/
|
||||||
|
@ -212,12 +226,11 @@ static msg_t drv_open_file(void *instance,
|
||||||
|
|
||||||
static void node_dir_release(void *instance) {
|
static void node_dir_release(void *instance) {
|
||||||
vfs_overlay_dir_node_c *odnp = (vfs_overlay_dir_node_c *)instance;
|
vfs_overlay_dir_node_c *odnp = (vfs_overlay_dir_node_c *)instance;
|
||||||
vfs_overlay_driver_c *drvp = (vfs_overlay_driver_c *)odnp->driver;
|
|
||||||
|
|
||||||
__referenced_object_release_impl(instance);
|
__referenced_object_release_impl(instance);
|
||||||
if (__referenced_object_getref_impl(instance) == 0U) {
|
if (__referenced_object_getref_impl(instance) == 0U) {
|
||||||
|
|
||||||
chPoolFree(&drvp->dir_nodes_pool, (void *)odnp);
|
chPoolFree(&vfs_overlay_driver_static.dir_nodes_pool, (void *)odnp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +277,24 @@ static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) {
|
||||||
/* Module exported functions. */
|
/* Module exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Module initialization.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
void __vfs_overlay_driver_init(void) {
|
||||||
|
|
||||||
|
/* Initializing pools.*/
|
||||||
|
chPoolObjectInit(&vfs_overlay_driver_static.dir_nodes_pool,
|
||||||
|
sizeof (vfs_overlay_dir_node_c),
|
||||||
|
chCoreAllocAlignedI);
|
||||||
|
|
||||||
|
/* Preloading pools.*/
|
||||||
|
chPoolLoadArray(&vfs_overlay_driver_static.dir_nodes_pool,
|
||||||
|
&vfs_overlay_driver_static.dir_nodes[0],
|
||||||
|
DRV_CFG_OVERLAY_DIR_NODES_NUM);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief VFS overlay object initialization.
|
* @brief VFS overlay object initialization.
|
||||||
*
|
*
|
||||||
|
@ -283,16 +314,6 @@ vfs_driver_c *drvOverlayObjectInit(vfs_overlay_driver_c *vodp,
|
||||||
vodp->overlaid_drv = overlaid_drv;
|
vodp->overlaid_drv = overlaid_drv;
|
||||||
vodp->next_driver = 0U;
|
vodp->next_driver = 0U;
|
||||||
|
|
||||||
/* Initializing pools.*/
|
|
||||||
chPoolObjectInit(&vodp->dir_nodes_pool,
|
|
||||||
sizeof (vfs_overlay_dir_node_c),
|
|
||||||
chCoreAllocAlignedI);
|
|
||||||
|
|
||||||
/* Preloading pools.*/
|
|
||||||
chPoolLoadArray(&vodp->dir_nodes_pool,
|
|
||||||
&vodp->dir_nodes[0],
|
|
||||||
DRV_CFG_OVERLAY_DIR_NODES_NUM);
|
|
||||||
|
|
||||||
return (vfs_driver_c *)vodp;
|
return (vfs_driver_c *)vodp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,12 +107,8 @@ typedef struct vfs_overlay_dir_node {
|
||||||
*/
|
*/
|
||||||
#define __vfs_overlay_driver_data \
|
#define __vfs_overlay_driver_data \
|
||||||
__vfs_driver_data \
|
__vfs_driver_data \
|
||||||
/* Pool of directory nodes.*/ \
|
|
||||||
memory_pool_t dir_nodes_pool; \
|
|
||||||
/* Driver to be overlaid or NULL.*/ \
|
/* Driver to be overlaid or NULL.*/ \
|
||||||
vfs_driver_c *overlaid_drv; \
|
vfs_driver_c *overlaid_drv; \
|
||||||
/* Static storage of directory nodes.*/ \
|
|
||||||
vfs_overlay_dir_node_c dir_nodes[DRV_CFG_OVERLAY_DIR_NODES_NUM]; \
|
|
||||||
/* Next registration slot.*/ \
|
/* Next registration slot.*/ \
|
||||||
unsigned next_driver; \
|
unsigned next_driver; \
|
||||||
/* Registration slots.*/ \
|
/* Registration slots.*/ \
|
||||||
|
@ -147,6 +143,7 @@ typedef struct vfs_overlay_driver {
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
void __vfs_overlay_driver_init(void);
|
||||||
vfs_driver_c *drvOverlayObjectInit(vfs_overlay_driver_c *vodp,
|
vfs_driver_c *drvOverlayObjectInit(vfs_overlay_driver_c *vodp,
|
||||||
vfs_driver_c *overlaid_drv,
|
vfs_driver_c *overlaid_drv,
|
||||||
const char *rootname);
|
const char *rootname);
|
||||||
|
|
|
@ -64,7 +64,7 @@ static void node_dir_release(void *instance);
|
||||||
static msg_t node_dir_first(void *instance, vfs_node_info_t *nip);
|
static msg_t node_dir_first(void *instance, vfs_node_info_t *nip);
|
||||||
static msg_t node_dir_next(void *instance, vfs_node_info_t *nip);
|
static msg_t node_dir_next(void *instance, vfs_node_info_t *nip);
|
||||||
|
|
||||||
static const struct vfs_stream_dir_node_vmt dir_node_vmt = {
|
static const struct vfs_streams_dir_node_vmt dir_node_vmt = {
|
||||||
.release = node_dir_release,
|
.release = node_dir_release,
|
||||||
.dir_first = node_dir_first,
|
.dir_first = node_dir_first,
|
||||||
.dir_next = node_dir_next
|
.dir_next = node_dir_next
|
||||||
|
@ -78,7 +78,7 @@ static msg_t node_file_setpos(void *instance, vfs_offset_t offset);
|
||||||
static vfs_offset_t node_file_getpos(void *instance);
|
static vfs_offset_t node_file_getpos(void *instance);
|
||||||
static vfs_offset_t node_file_getsize(void *instance);
|
static vfs_offset_t node_file_getsize(void *instance);
|
||||||
|
|
||||||
static const struct vfs_stream_file_node_vmt file_node_vmt = {
|
static const struct vfs_streams_file_node_vmt file_node_vmt = {
|
||||||
.release = node_file_release,
|
.release = node_file_release,
|
||||||
.file_get_stream = node_file_get_stream,
|
.file_get_stream = node_file_get_stream,
|
||||||
.file_read = node_file_read,
|
.file_read = node_file_read,
|
||||||
|
@ -88,6 +88,28 @@ static const struct vfs_stream_file_node_vmt file_node_vmt = {
|
||||||
.file_getsize = node_file_getsize
|
.file_getsize = node_file_getsize
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Static members of @p vfs_streams_driver_c.
|
||||||
|
*/
|
||||||
|
static struct {
|
||||||
|
/**
|
||||||
|
* @brief Pool of directory nodes.
|
||||||
|
*/
|
||||||
|
memory_pool_t dir_nodes_pool;
|
||||||
|
/**
|
||||||
|
* @brief Pool of file nodes.
|
||||||
|
*/
|
||||||
|
memory_pool_t file_nodes_pool;
|
||||||
|
/**
|
||||||
|
* @brief Static storage of directory nodes.
|
||||||
|
*/
|
||||||
|
vfs_streams_dir_node_c dir_nodes[DRV_CFG_STREAMS_DIR_NODES_NUM];
|
||||||
|
/**
|
||||||
|
* @brief Static storage of file nodes.
|
||||||
|
*/
|
||||||
|
vfs_streams_file_node_c file_nodes[DRV_CFG_STREAMS_FILE_NODES_NUM];
|
||||||
|
} vfs_streams_driver_static;
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Module local functions. */
|
/* Module local functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -99,7 +121,7 @@ static msg_t drv_open_dir(void *instance,
|
||||||
msg_t err;
|
msg_t err;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
vfs_stream_dir_node_c *sdnp;
|
vfs_streams_dir_node_c *sdnp;
|
||||||
|
|
||||||
err = vfs_parse_match_separator(&path);
|
err = vfs_parse_match_separator(&path);
|
||||||
VFS_BREAK_ON_ERROR(err);
|
VFS_BREAK_ON_ERROR(err);
|
||||||
|
@ -107,7 +129,7 @@ static msg_t drv_open_dir(void *instance,
|
||||||
err = vfs_parse_match_end(&path);
|
err = vfs_parse_match_end(&path);
|
||||||
VFS_BREAK_ON_ERROR(err);
|
VFS_BREAK_ON_ERROR(err);
|
||||||
|
|
||||||
sdnp = chPoolAlloc(&drvp->dir_nodes_pool);
|
sdnp = chPoolAlloc(&vfs_streams_driver_static.dir_nodes_pool);
|
||||||
if (sdnp != NULL) {
|
if (sdnp != NULL) {
|
||||||
|
|
||||||
/* Node object initialization.*/
|
/* Node object initialization.*/
|
||||||
|
@ -131,7 +153,7 @@ static msg_t drv_open_file(void *instance,
|
||||||
int oflag,
|
int oflag,
|
||||||
vfs_file_node_c **vfnpp) {
|
vfs_file_node_c **vfnpp) {
|
||||||
vfs_streams_driver_c *drvp = (vfs_streams_driver_c *)instance;
|
vfs_streams_driver_c *drvp = (vfs_streams_driver_c *)instance;
|
||||||
const drv_stream_element_t *dsep;
|
const drv_streams_element_t *dsep;
|
||||||
msg_t err;
|
msg_t err;
|
||||||
|
|
||||||
(void)oflag;
|
(void)oflag;
|
||||||
|
@ -151,9 +173,9 @@ static msg_t drv_open_file(void *instance,
|
||||||
dsep = &drvp->streams[0];
|
dsep = &drvp->streams[0];
|
||||||
while (dsep->name != NULL) {
|
while (dsep->name != NULL) {
|
||||||
if (strncmp(fname, dsep->name, VFS_CFG_MAX_NAMELEN) == 0) {
|
if (strncmp(fname, dsep->name, VFS_CFG_MAX_NAMELEN) == 0) {
|
||||||
vfs_stream_file_node_c *sfnp;
|
vfs_streams_file_node_c *sfnp;
|
||||||
|
|
||||||
sfnp = chPoolAlloc(&drvp->file_nodes_pool);
|
sfnp = chPoolAlloc(&vfs_streams_driver_static.file_nodes_pool);
|
||||||
if (sfnp != NULL) {
|
if (sfnp != NULL) {
|
||||||
|
|
||||||
/* Node object initialization.*/
|
/* Node object initialization.*/
|
||||||
|
@ -179,18 +201,17 @@ static msg_t drv_open_file(void *instance,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void node_dir_release(void *instance) {
|
static void node_dir_release(void *instance) {
|
||||||
vfs_stream_dir_node_c *sdnp = (vfs_stream_dir_node_c *)instance;
|
vfs_streams_dir_node_c *sdnp = (vfs_streams_dir_node_c *)instance;
|
||||||
vfs_streams_driver_c *drvp = (vfs_streams_driver_c *)sdnp->driver;
|
|
||||||
|
|
||||||
__referenced_object_release_impl(instance);
|
__referenced_object_release_impl(instance);
|
||||||
if (__referenced_object_getref_impl(instance) == 0U) {
|
if (__referenced_object_getref_impl(instance) == 0U) {
|
||||||
|
|
||||||
chPoolFree(&drvp->dir_nodes_pool, (void *)sdnp);
|
chPoolFree(&vfs_streams_driver_static.dir_nodes_pool, (void *)sdnp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static msg_t node_dir_first(void *instance, vfs_node_info_t *nip) {
|
static msg_t node_dir_first(void *instance, vfs_node_info_t *nip) {
|
||||||
vfs_stream_dir_node_c *sdnp = (vfs_stream_dir_node_c *)instance;
|
vfs_streams_dir_node_c *sdnp = (vfs_streams_dir_node_c *)instance;
|
||||||
|
|
||||||
sdnp->index = 0U;
|
sdnp->index = 0U;
|
||||||
|
|
||||||
|
@ -198,7 +219,7 @@ static msg_t node_dir_first(void *instance, vfs_node_info_t *nip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) {
|
static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) {
|
||||||
vfs_stream_dir_node_c *sdnp = (vfs_stream_dir_node_c *)instance;
|
vfs_streams_dir_node_c *sdnp = (vfs_streams_dir_node_c *)instance;
|
||||||
vfs_streams_driver_c *vsdp = (vfs_streams_driver_c *)sdnp->driver;
|
vfs_streams_driver_c *vsdp = (vfs_streams_driver_c *)sdnp->driver;
|
||||||
|
|
||||||
if (vsdp->streams[sdnp->index].name != NULL) {
|
if (vsdp->streams[sdnp->index].name != NULL) {
|
||||||
|
@ -216,30 +237,29 @@ static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void node_file_release(void *instance) {
|
static void node_file_release(void *instance) {
|
||||||
vfs_stream_file_node_c *sfnp = (vfs_stream_file_node_c *)instance;
|
vfs_streams_file_node_c *sfnp = (vfs_streams_file_node_c *)instance;
|
||||||
vfs_streams_driver_c *drvp = (vfs_streams_driver_c *)sfnp->driver;
|
|
||||||
|
|
||||||
__referenced_object_release_impl(instance);
|
__referenced_object_release_impl(instance);
|
||||||
if (__referenced_object_getref_impl(instance) == 0U) {
|
if (__referenced_object_getref_impl(instance) == 0U) {
|
||||||
|
|
||||||
chPoolFree(&drvp->file_nodes_pool, (void *)sfnp);
|
chPoolFree(&vfs_streams_driver_static.file_nodes_pool, (void *)sfnp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static BaseSequentialStream *node_file_get_stream(void *instance) {
|
static BaseSequentialStream *node_file_get_stream(void *instance) {
|
||||||
vfs_stream_file_node_c *sfnp = (vfs_stream_file_node_c *)instance;
|
vfs_streams_file_node_c *sfnp = (vfs_streams_file_node_c *)instance;
|
||||||
|
|
||||||
return sfnp->stream;
|
return sfnp->stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t node_file_read(void *instance, uint8_t *buf, size_t n) {
|
static ssize_t node_file_read(void *instance, uint8_t *buf, size_t n) {
|
||||||
vfs_stream_file_node_c *sfnp = (vfs_stream_file_node_c *)instance;
|
vfs_streams_file_node_c *sfnp = (vfs_streams_file_node_c *)instance;
|
||||||
|
|
||||||
return streamRead(sfnp->stream, buf, n);
|
return streamRead(sfnp->stream, buf, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t node_file_write(void *instance, const uint8_t *buf, size_t n) {
|
static ssize_t node_file_write(void *instance, const uint8_t *buf, size_t n) {
|
||||||
vfs_stream_file_node_c *sfnp = (vfs_stream_file_node_c *)instance;
|
vfs_streams_file_node_c *sfnp = (vfs_streams_file_node_c *)instance;
|
||||||
|
|
||||||
return streamWrite(sfnp->stream, buf, n);
|
return streamWrite(sfnp->stream, buf, n);
|
||||||
}
|
}
|
||||||
|
@ -270,40 +290,48 @@ static vfs_offset_t node_file_getsize(void *instance) {
|
||||||
/* Module exported functions. */
|
/* Module exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Module initialization.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
void __vfs_streams_driver_init(void) {
|
||||||
|
|
||||||
|
/* Initializing pools.*/
|
||||||
|
chPoolObjectInit(&vfs_streams_driver_static.dir_nodes_pool,
|
||||||
|
sizeof (vfs_streams_dir_node_c),
|
||||||
|
chCoreAllocAlignedI);
|
||||||
|
chPoolObjectInit(&vfs_streams_driver_static.file_nodes_pool,
|
||||||
|
sizeof (vfs_streams_file_node_c),
|
||||||
|
chCoreAllocAlignedI);
|
||||||
|
|
||||||
|
/* Preloading pools.*/
|
||||||
|
chPoolLoadArray(&vfs_streams_driver_static.dir_nodes_pool,
|
||||||
|
&vfs_streams_driver_static.dir_nodes[0],
|
||||||
|
DRV_CFG_STREAMS_DIR_NODES_NUM);
|
||||||
|
chPoolLoadArray(&vfs_streams_driver_static.file_nodes_pool,
|
||||||
|
&vfs_streams_driver_static.file_nodes[0],
|
||||||
|
DRV_CFG_STREAMS_FILE_NODES_NUM);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief VFS streams object initialization.
|
* @brief VFS streams object initialization.
|
||||||
*
|
*
|
||||||
* @param[out] vsdp pointer to a @p vfs_streams_driver_c structure
|
* @param[out] vsdp pointer to a @p vfs_streams_driver_c structure
|
||||||
* @param[in] rootname name to be attributed to this object
|
* @param[in] rootname name to be attributed to this object
|
||||||
* @param[in] streams pointer to an array of @p drv_stream_element_t objects
|
* @param[in] streams pointer to an array of @p drv_streams_element_t objects
|
||||||
* @return A pointer to this initialized object.
|
* @return A pointer to this initialized object.
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
vfs_driver_c *drvStreamsObjectInit(vfs_streams_driver_c *vsdp,
|
vfs_driver_c *drvStreamsObjectInit(vfs_streams_driver_c *vsdp,
|
||||||
const char *rootname,
|
const char *rootname,
|
||||||
const drv_stream_element_t *streams) {
|
const drv_streams_element_t *streams) {
|
||||||
|
|
||||||
__base_object_objinit_impl(vsdp, &driver_vmt);
|
__base_object_objinit_impl(vsdp, &driver_vmt);
|
||||||
vsdp->rootname = rootname;
|
vsdp->rootname = rootname;
|
||||||
vsdp->streams = streams;
|
vsdp->streams = streams;
|
||||||
|
|
||||||
/* Initializing pools.*/
|
|
||||||
chPoolObjectInit(&vsdp->dir_nodes_pool,
|
|
||||||
sizeof (vfs_stream_dir_node_c),
|
|
||||||
chCoreAllocAlignedI);
|
|
||||||
chPoolObjectInit(&vsdp->file_nodes_pool,
|
|
||||||
sizeof (vfs_stream_file_node_c),
|
|
||||||
chCoreAllocAlignedI);
|
|
||||||
|
|
||||||
/* Preloading pools.*/
|
|
||||||
chPoolLoadArray(&vsdp->dir_nodes_pool,
|
|
||||||
&vsdp->dir_nodes[0],
|
|
||||||
DRV_CFG_STREAMS_DIR_NODES_NUM);
|
|
||||||
chPoolLoadArray(&vsdp->file_nodes_pool,
|
|
||||||
&vsdp->file_nodes[0],
|
|
||||||
DRV_CFG_STREAMS_FILE_NODES_NUM);
|
|
||||||
|
|
||||||
return (vfs_driver_c *)vsdp;
|
return (vfs_driver_c *)vsdp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
/**
|
/**
|
||||||
* @brief Type of a stream association structure.
|
* @brief Type of a stream association structure.
|
||||||
*/
|
*/
|
||||||
typedef struct drv_stream_element {
|
typedef struct drv_streams_element {
|
||||||
/**
|
/**
|
||||||
* @brief Filename for the stream.
|
* @brief Filename for the stream.
|
||||||
*/
|
*/
|
||||||
|
@ -75,69 +75,69 @@ typedef struct drv_stream_element {
|
||||||
* @brief Pointer to the stream.
|
* @brief Pointer to the stream.
|
||||||
*/
|
*/
|
||||||
BaseSequentialStream *stream;
|
BaseSequentialStream *stream;
|
||||||
} drv_stream_element_t;
|
} drv_streams_element_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p vfs_stream_dir_node_c specific methods.
|
* @brief @p vfs_streams_dir_node_c specific methods.
|
||||||
*/
|
*/
|
||||||
#define __vfs_stream_dir_node_methods \
|
#define __vfs_streams_dir_node_methods \
|
||||||
__vfs_directory_node_methods
|
__vfs_directory_node_methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p vfs_stream_dir_node_c specific data.
|
* @brief @p vfs_streams_dir_node_c specific data.
|
||||||
*/
|
*/
|
||||||
#define __vfs_stream_dir_node_data \
|
#define __vfs_streams_dir_node_data \
|
||||||
__vfs_directory_node_data \
|
__vfs_directory_node_data \
|
||||||
unsigned index;
|
unsigned index;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p vfs_stream_dir_node_c virtual methods table.
|
* @brief @p vfs_streams_dir_node_c virtual methods table.
|
||||||
*/
|
*/
|
||||||
struct vfs_stream_dir_node_vmt {
|
struct vfs_streams_dir_node_vmt {
|
||||||
__vfs_stream_dir_node_methods
|
__vfs_streams_dir_node_methods
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Type of a stream dir VFS node class.
|
* @brief Type of a stream dir VFS node class.
|
||||||
*/
|
*/
|
||||||
typedef struct vfs_stream_dir_node {
|
typedef struct vfs_streams_dir_node {
|
||||||
/**
|
/**
|
||||||
* @brief Virtual Methods Table.
|
* @brief Virtual Methods Table.
|
||||||
*/
|
*/
|
||||||
const struct vfs_stream_dir_node_vmt *vmt;
|
const struct vfs_streams_dir_node_vmt *vmt;
|
||||||
__vfs_stream_dir_node_data
|
__vfs_streams_dir_node_data
|
||||||
} vfs_stream_dir_node_c;
|
} vfs_streams_dir_node_c;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p vfs_stream_file_node_c specific methods.
|
* @brief @p vfs_streams_file_node_c specific methods.
|
||||||
*/
|
*/
|
||||||
#define __vfs_stream_file_node_methods \
|
#define __vfs_streams_file_node_methods \
|
||||||
__vfs_file_node_methods
|
__vfs_file_node_methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p vfs_stream_file_node_c specific data.
|
* @brief @p vfs_streams_file_node_c specific data.
|
||||||
*/
|
*/
|
||||||
#define __vfs_stream_file_node_data \
|
#define __vfs_streams_file_node_data \
|
||||||
__vfs_file_node_data \
|
__vfs_file_node_data \
|
||||||
BaseSequentialStream *stream;
|
BaseSequentialStream *stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p vfs_stream_file_node_c virtual methods table.
|
* @brief @p vfs_streams_file_node_c virtual methods table.
|
||||||
*/
|
*/
|
||||||
struct vfs_stream_file_node_vmt {
|
struct vfs_streams_file_node_vmt {
|
||||||
__vfs_stream_file_node_methods
|
__vfs_streams_file_node_methods
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Type of a stream file VFS node class.
|
* @brief Type of a stream file VFS node class.
|
||||||
*/
|
*/
|
||||||
typedef struct vfs_stream_file_node {
|
typedef struct vfs_streams_file_node {
|
||||||
/**
|
/**
|
||||||
* @brief Virtual Methods Table.
|
* @brief Virtual Methods Table.
|
||||||
*/
|
*/
|
||||||
const struct vfs_stream_file_node_vmt *vmt;
|
const struct vfs_streams_file_node_vmt *vmt;
|
||||||
__vfs_stream_file_node_data
|
__vfs_streams_file_node_data
|
||||||
} vfs_stream_file_node_c;
|
} vfs_streams_file_node_c;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p vfs_streams_driver_c specific methods.
|
* @brief @p vfs_streams_driver_c specific methods.
|
||||||
|
@ -150,11 +150,7 @@ typedef struct vfs_stream_file_node {
|
||||||
*/
|
*/
|
||||||
#define __vfs_streams_driver_data \
|
#define __vfs_streams_driver_data \
|
||||||
__vfs_driver_data \
|
__vfs_driver_data \
|
||||||
const drv_stream_element_t *streams; \
|
const drv_streams_element_t *streams;
|
||||||
memory_pool_t file_nodes_pool; \
|
|
||||||
memory_pool_t dir_nodes_pool; \
|
|
||||||
vfs_stream_dir_node_c dir_nodes[DRV_CFG_STREAMS_DIR_NODES_NUM]; \
|
|
||||||
vfs_stream_file_node_c file_nodes[DRV_CFG_STREAMS_FILE_NODES_NUM];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p vfs_streams_driver_c virtual methods table.
|
* @brief @p vfs_streams_driver_c virtual methods table.
|
||||||
|
@ -185,9 +181,10 @@ typedef struct vfs_streams_driver {
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
void __vfs_streams_driver_init(void);
|
||||||
vfs_driver_c *drvStreamsObjectInit(vfs_streams_driver_c *vsdp,
|
vfs_driver_c *drvStreamsObjectInit(vfs_streams_driver_c *vsdp,
|
||||||
const char *rootname,
|
const char *rootname,
|
||||||
const drv_stream_element_t *streams);
|
const drv_streams_element_t *streams);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -106,6 +106,7 @@ extern vfs_driver_c *vfs_root;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
void vfsInit(void);
|
||||||
msg_t vfsOpenDirectory(const char *name,
|
msg_t vfsOpenDirectory(const char *name,
|
||||||
vfs_directory_node_c **vdnpp);
|
vfs_directory_node_c **vdnpp);
|
||||||
void vfsCloseDirectory(vfs_directory_node_c *vdnp);
|
void vfsCloseDirectory(vfs_directory_node_c *vdnp);
|
||||||
|
|
|
@ -53,6 +53,26 @@
|
||||||
/* Module exported functions. */
|
/* Module exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief VFS initialization.
|
||||||
|
*
|
||||||
|
* @init
|
||||||
|
*/
|
||||||
|
void vfsInit(void) {
|
||||||
|
|
||||||
|
#if VFS_CFG_ENABLE_DRV_OVERLAY == TRUE
|
||||||
|
__vfs_overlay_driver_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if VFS_CFG_ENABLE_DRV_STREAMS == TRUE
|
||||||
|
__vfs_streams_driver_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if VFS_CFG_ENABLE_DRV_FATFS == TRUE
|
||||||
|
__vfs_fatfs_driver_init();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Opens a VFS directory.
|
* @brief Opens a VFS directory.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue