mirror of https://github.com/rusefi/ChibiOS.git
LittleFS VFS driver preliminary work.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@16673 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
07555ce8f7
commit
44c30bc4e4
|
@ -1,11 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ENTITY vfs_drivers SYSTEM "vfs_drivers.xml">
|
||||
<!ENTITY vfs_nodes SYSTEM "vfs_nodes.xml">
|
||||
<!ENTITY vfs_driver_template SYSTEM "vfs_driver_template.xml">
|
||||
<!ENTITY vfs_driver_overlay SYSTEM "vfs_driver_overlay.xml">
|
||||
<!ENTITY vfs_driver_fatfs SYSTEM "vfs_driver_fatfs.xml">
|
||||
<!ENTITY vfs_driver_streams SYSTEM "vfs_driver_streams.xml">
|
||||
<!ENTITY vfs_drivers SYSTEM "vfs_drivers.xml">
|
||||
<!ENTITY vfs_nodes SYSTEM "vfs_nodes.xml">
|
||||
<!ENTITY vfs_driver_template SYSTEM "vfs_driver_template.xml">
|
||||
<!ENTITY vfs_driver_overlay SYSTEM "vfs_driver_overlay.xml">
|
||||
<!ENTITY vfs_driver_fatfs SYSTEM "vfs_driver_fatfs.xml">
|
||||
<!ENTITY vfs_driver_littlefs SYSTEM "vfs_driver_littlefs.xml">
|
||||
<!ENTITY vfs_driver_streams SYSTEM "vfs_driver_streams.xml">
|
||||
]>
|
||||
<!-- Class/interfaces definitions -->
|
||||
<instance
|
||||
|
@ -20,6 +21,7 @@
|
|||
<!-- &vfs_driver_template; -->
|
||||
&vfs_driver_overlay;
|
||||
&vfs_driver_fatfs;
|
||||
&vfs_driver_littlefs;
|
||||
&vfs_driver_streams;
|
||||
</modules>
|
||||
</instance>
|
||||
|
|
|
@ -0,0 +1,271 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- C module definition -->
|
||||
<module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://www.chibios.org/xml/schema/ccode/modules.xsd"
|
||||
name="drvlittlefs" descr="VFS Little Driver"
|
||||
check="VFS_CFG_ENABLE_DRV_LITTLEFS == TRUE" sourcepath="drivers/littlefs"
|
||||
headerpath="drivers/littlefs" editcode="true">
|
||||
<imports>
|
||||
<import>vfs_nodes.xml</import>
|
||||
<import>vfs_drivers.xml</import>
|
||||
</imports>
|
||||
<public>
|
||||
<includes>
|
||||
<include style="regular">oop_sequential_stream.h</include>
|
||||
</includes>
|
||||
<configs>
|
||||
<config name="DRV_CFG_LITTLEFS_FS_NUM" default="1">
|
||||
<brief>Maximum number of LittleFS file systems mounted.</brief>
|
||||
<assert invalid="$N < 1" />
|
||||
</config>
|
||||
<config name="DRV_CFG_LITTLEFS_DIR_NODES_NUM" default="1">
|
||||
<brief>Number of directory nodes pre-allocated in the pool.</brief>
|
||||
<assert invalid="$N < 1" />
|
||||
</config>
|
||||
<config name="DRV_CFG_LITTLEFS_FILE_NODES_NUM" default="1">
|
||||
<brief>Number of file nodes pre-allocated in the pool.</brief>
|
||||
<assert invalid="$N < 1" />
|
||||
</config>
|
||||
</configs>
|
||||
<types>
|
||||
<class type="regular" name="vfs_littlefs_driver" namespace="lfsdrv"
|
||||
ancestorname="vfs_driver" descr="VFS littlefs driver">
|
||||
<fields></fields>
|
||||
<methods>
|
||||
<objinit callsuper="true">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</objinit>
|
||||
<dispose>
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</dispose>
|
||||
<override>
|
||||
<method shortname="setcwd">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
<method shortname="getcwd">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
<method shortname="stat">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
<method shortname="opendir">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
<method shortname="openfile">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
<method shortname="unlink">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
<method shortname="rename">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
<method shortname="mkdir">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
<method shortname="rmdir">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
</override>
|
||||
</methods>
|
||||
</class>
|
||||
</types>
|
||||
<variables>
|
||||
<variable name="vfs_littlefs_driver_static"
|
||||
ctype="struct vfs_littlefs_driver_static_struct">
|
||||
<brief>Global state of @p vfs_littlefs_driver_c</brief>
|
||||
</variable>
|
||||
</variables>
|
||||
<functions>
|
||||
<function name="__drv_littlefs_init" ctype="void">
|
||||
<brief>Module initialization.</brief>
|
||||
<init />
|
||||
<implementation><![CDATA[
|
||||
|
||||
/* Initializing pools.*/
|
||||
chPoolObjectInit(&vfs_littlefs_driver_static.dir_nodes_pool,
|
||||
sizeof (vfs_littlefs_dir_node_c),
|
||||
chCoreAllocAlignedI);
|
||||
chPoolObjectInit(&vfs_littlefs_driver_static.file_nodes_pool,
|
||||
sizeof (vfs_littlefs_file_node_c),
|
||||
chCoreAllocAlignedI);
|
||||
chPoolObjectInit(&vfs_littlefs_driver_static.info_nodes_pool,
|
||||
sizeof (struct lfs_info),
|
||||
chCoreAllocAlignedI);
|
||||
chPoolObjectInit(&vfs_littlefs_driver_static.fs_pool,
|
||||
sizeof (lfs_t),
|
||||
chCoreAllocAlignedI);
|
||||
|
||||
/* Preloading pools.*/
|
||||
chPoolLoadArray(&vfs_littlefs_driver_static.dir_nodes_pool,
|
||||
&vfs_littlefs_driver_static.dir_nodes[0],
|
||||
DRV_CFG_LITTLEFS_DIR_NODES_NUM);
|
||||
chPoolLoadArray(&vfs_littlefs_driver_static.file_nodes_pool,
|
||||
&vfs_littlefs_driver_static.file_nodes[0],
|
||||
DRV_CFG_LITTLEFS_FILE_NODES_NUM);
|
||||
chPoolLoadArray(&vfs_littlefs_driver_static.fs_pool,
|
||||
&vfs_littlefs_driver_static.fs[0],
|
||||
DRV_CFG_LITTLEFS_FS_NUM);]]></implementation>
|
||||
</function>
|
||||
<function name="lfsdrvMount" ctype="msg_t">
|
||||
<brief>Mounts a LittleFS volume.</brief>
|
||||
<param name="name" ctype="const char *" dir="in"><![CDATA[Name to
|
||||
be assigned to the volume, see LittleFS @p f_mount() documentation
|
||||
because there are several options.]]></param>
|
||||
<param name="mountnow" ctype="bool" dir="in"> Immediate mount option.
|
||||
</param>
|
||||
<return>The operation result.</return>
|
||||
<api />
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</function>
|
||||
<function name="lfsdrvUnmount" ctype="msg_t">
|
||||
<brief>Unmounts a LittleFS volume.</brief>
|
||||
<param name="name" ctype="const char *" dir="in"> Name of the volume to
|
||||
be unmounted.
|
||||
</param>
|
||||
<return>The operation result.</return>
|
||||
<api />
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</function>
|
||||
</functions>
|
||||
</public>
|
||||
<private>
|
||||
<includes_always>
|
||||
<include style="regular">vfs.h</include>
|
||||
</includes_always>
|
||||
<includes>
|
||||
<include style="regular">ff.h</include>
|
||||
</includes>
|
||||
<types>
|
||||
<class type="regular" name="vfs_littlefs_dir_node" namespace="ffdir"
|
||||
ancestorname="vfs_directory_node" descr="VFS littlefs directory node">
|
||||
<fields>
|
||||
<field name="dir" ctype="lfs_dir_t">
|
||||
<brief>LittleFS inner @p lfs_dir_t structure.</brief>
|
||||
</field>
|
||||
</fields>
|
||||
<methods>
|
||||
<objinit callsuper="false">
|
||||
<param name="driver" ctype="vfs_driver_c *" dir="in">Pointer to
|
||||
the controlling driver.</param>
|
||||
<param name="mode" ctype="vfs_mode_t" dir="in">Node mode flags.</param>
|
||||
<implementation><![CDATA[
|
||||
self = __vfsdir_objinit_impl(ip, vmt, (vfs_driver_c *)driver, mode);]]></implementation>
|
||||
</objinit>
|
||||
<dispose>
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</dispose>
|
||||
<override>
|
||||
<method shortname="stat">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
<method shortname="first">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
<method shortname="next">
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</method>
|
||||
</override>
|
||||
</methods>
|
||||
</class>
|
||||
<class type="regular" name="vfs_littlefs_file_node" namespace="fffile"
|
||||
ancestorname="vfs_file_node" descr="VFS littlefs file node">
|
||||
<implements>
|
||||
<if name="sequential_stream">
|
||||
<method shortname="write">
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</method>
|
||||
<method shortname="read">
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</method>
|
||||
<method shortname="put">
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</method>
|
||||
<method shortname="get">
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</method>
|
||||
</if>
|
||||
</implements>
|
||||
<fields>
|
||||
<field name="file" ctype="lfs_file_t">
|
||||
<brief>LittleFS inner @p lfs_file_t structure.</brief>
|
||||
</field>
|
||||
</fields>
|
||||
<methods>
|
||||
<objinit callsuper="false">
|
||||
<param name="driver" ctype="vfs_driver_c *" dir="in"> Pointer to
|
||||
the controlling driver.
|
||||
</param>
|
||||
<param name="mode" ctype="vfs_mode_t" dir="in"> Node mode flags.
|
||||
</param>
|
||||
<implementation><![CDATA[
|
||||
self = __vfsfile_objinit_impl(ip, vmt, (vfs_driver_c *)driver, mode);]]></implementation>
|
||||
</objinit>
|
||||
<dispose>
|
||||
<implementation><![CDATA[]]></implementation>
|
||||
</dispose>
|
||||
<override>
|
||||
<method shortname="stat">
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</method>
|
||||
<method shortname="read">
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</method>
|
||||
<method shortname="write">
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</method>
|
||||
<method shortname="setpos">
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</method>
|
||||
<method shortname="getpos">
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</method>
|
||||
<method shortname="getstream">
|
||||
<implementation><![CDATA[
|
||||
]]></implementation>
|
||||
</method>
|
||||
</override>
|
||||
</methods>
|
||||
</class>
|
||||
<struct name="vfs_littlefs_driver_static_struct">
|
||||
<brief>Global state of @p vfs_littlefs_driver_c.</brief>
|
||||
<fields>
|
||||
<field name="fs_pool" ctype="memory_pool_t">
|
||||
<brief>Pool of file system objects.</brief>
|
||||
</field>
|
||||
<field name="info_nodes_pool" ctype="memory_pool_t">
|
||||
<brief>Pool of file info objects.</brief>
|
||||
</field>
|
||||
<field name="dir_nodes_pool" ctype="memory_pool_t">
|
||||
<brief>Pool of directory nodes.</brief>
|
||||
</field>
|
||||
<field name="file_nodes_pool" ctype="memory_pool_t">
|
||||
<brief>Pool of file nodes.</brief>
|
||||
</field>
|
||||
<field name="fs" ctype="lfs_t$I$N[DRV_CFG_LITTLEFS_FS_NUM]">
|
||||
<brief>Pool of file system objects.</brief>
|
||||
</field>
|
||||
<field name="dir_nodes"
|
||||
ctype="vfs_littlefs_dir_node_c$I$N[DRV_CFG_LITTLEFS_DIR_NODES_NUM]">
|
||||
<brief>Static storage of directory nodes.</brief>
|
||||
</field>
|
||||
<field name="file_nodes"
|
||||
ctype="vfs_littlefs_file_node_c$I$N[DRV_CFG_LITTLEFS_FILE_NODES_NUM]">
|
||||
<brief>Static storage of file nodes.</brief>
|
||||
</field>
|
||||
</fields>
|
||||
</struct>
|
||||
</types>
|
||||
</private>
|
||||
</module>
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file drvlittlefs.c
|
||||
* @brief Generated VFS Little Driver source.
|
||||
* @note This is a generated file, do not edit directly.
|
||||
*
|
||||
* @addtogroup DRVLITTLEFS
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
#if (VFS_CFG_ENABLE_DRV_LITTLEFS == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local definitions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Global state of @p vfs_littlefs_driver_c.
|
||||
*/
|
||||
struct vfs_littlefs_driver_static_struct vfs_littlefs_driver_static;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @class vfs_littlefs_dir_node_c
|
||||
* @extends base_object_c, referenced_object_c, vfs_node_c,
|
||||
* vfs_directory_node_c.
|
||||
*
|
||||
*
|
||||
* @name Class @p vfs_littlefs_dir_node_c structures
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Type of a VFS littlefs directory node class.
|
||||
*/
|
||||
typedef struct vfs_littlefs_dir_node vfs_littlefs_dir_node_c;
|
||||
|
||||
/**
|
||||
* @brief Class @p vfs_littlefs_dir_node_c virtual methods table.
|
||||
*/
|
||||
struct vfs_littlefs_dir_node_vmt {
|
||||
/* From base_object_c.*/
|
||||
void (*dispose)(void *ip);
|
||||
/* From referenced_object_c.*/
|
||||
void * (*addref)(void *ip);
|
||||
object_references_t (*release)(void *ip);
|
||||
/* From vfs_node_c.*/
|
||||
msg_t (*stat)(void *ip, vfs_stat_t *sp);
|
||||
/* From vfs_directory_node_c.*/
|
||||
msg_t (*first)(void *ip, vfs_direntry_info_t *dip);
|
||||
msg_t (*next)(void *ip, vfs_direntry_info_t *dip);
|
||||
/* From vfs_littlefs_dir_node_c.*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Structure representing a VFS littlefs directory node class.
|
||||
*/
|
||||
struct vfs_littlefs_dir_node {
|
||||
/**
|
||||
* @brief Virtual Methods Table.
|
||||
*/
|
||||
const struct vfs_littlefs_dir_node_vmt *vmt;
|
||||
/**
|
||||
* @brief Number of references to the object.
|
||||
*/
|
||||
object_references_t references;
|
||||
/**
|
||||
* @brief Driver handling this node.
|
||||
*/
|
||||
vfs_driver_c *driver;
|
||||
/**
|
||||
* @brief Node mode information.
|
||||
*/
|
||||
vfs_mode_t mode;
|
||||
/**
|
||||
* @brief LittleFS inner @p lfs_dir_t structure.
|
||||
*/
|
||||
lfs_dir_t dir;
|
||||
};
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @class vfs_littlefs_file_node_c
|
||||
* @extends base_object_c, referenced_object_c, vfs_node_c,
|
||||
* vfs_file_node_c.
|
||||
* @implements sequential_stream_i
|
||||
*
|
||||
*
|
||||
* @name Class @p vfs_littlefs_file_node_c structures
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Type of a VFS littlefs file node class.
|
||||
*/
|
||||
typedef struct vfs_littlefs_file_node vfs_littlefs_file_node_c;
|
||||
|
||||
/**
|
||||
* @brief Class @p vfs_littlefs_file_node_c virtual methods table.
|
||||
*/
|
||||
struct vfs_littlefs_file_node_vmt {
|
||||
/* From base_object_c.*/
|
||||
void (*dispose)(void *ip);
|
||||
/* From referenced_object_c.*/
|
||||
void * (*addref)(void *ip);
|
||||
object_references_t (*release)(void *ip);
|
||||
/* From vfs_node_c.*/
|
||||
msg_t (*stat)(void *ip, vfs_stat_t *sp);
|
||||
/* From vfs_file_node_c.*/
|
||||
ssize_t (*read)(void *ip, uint8_t *buf, size_t n);
|
||||
ssize_t (*write)(void *ip, const uint8_t *buf, size_t n);
|
||||
msg_t (*setpos)(void *ip, vfs_offset_t offset, vfs_seekmode_t whence);
|
||||
vfs_offset_t (*getpos)(void *ip);
|
||||
sequential_stream_i * (*getstream)(void *ip);
|
||||
/* From vfs_littlefs_file_node_c.*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Structure representing a VFS littlefs file node class.
|
||||
*/
|
||||
struct vfs_littlefs_file_node {
|
||||
/**
|
||||
* @brief Virtual Methods Table.
|
||||
*/
|
||||
const struct vfs_littlefs_file_node_vmt *vmt;
|
||||
/**
|
||||
* @brief Number of references to the object.
|
||||
*/
|
||||
object_references_t references;
|
||||
/**
|
||||
* @brief Driver handling this node.
|
||||
*/
|
||||
vfs_driver_c *driver;
|
||||
/**
|
||||
* @brief Node mode information.
|
||||
*/
|
||||
vfs_mode_t mode;
|
||||
/**
|
||||
* @brief Implemented interface @p sequential_stream_i.
|
||||
*/
|
||||
sequential_stream_i stm;
|
||||
/**
|
||||
* @brief LittleFS inner @p lfs_file_t structure.
|
||||
*/
|
||||
lfs_file_t file;
|
||||
};
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Global state of @p vfs_littlefs_driver_c.
|
||||
*/
|
||||
struct vfs_littlefs_driver_static_struct {
|
||||
/**
|
||||
* @brief Pool of file system objects.
|
||||
*/
|
||||
memory_pool_t fs_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 Pool of file system objects.
|
||||
*/
|
||||
lfs_t fs[DRV_CFG_LITTLEFS_FS_NUM];
|
||||
/**
|
||||
* @brief Static storage of directory nodes.
|
||||
*/
|
||||
vfs_littlefs_dir_node_c dir_nodes[DRV_CFG_LITTLEFS_DIR_NODES_NUM];
|
||||
/**
|
||||
* @brief Static storage of file nodes.
|
||||
*/
|
||||
vfs_littlefs_file_node_c file_nodes[DRV_CFG_LITTLEFS_FILE_NODES_NUM];
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/* Module code has been generated into an hand-editable file and included
|
||||
here.*/
|
||||
#include "drvlittlefs_impl.inc"
|
||||
|
||||
#endif /* VFS_CFG_ENABLE_DRV_LITTLEFS == TRUE */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file drvlittlefs.h
|
||||
* @brief Generated VFS Little Driver header.
|
||||
* @note This is a generated file, do not edit directly.
|
||||
*
|
||||
* @addtogroup DRVLITTLEFS
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef DRVLITTLEFS_H
|
||||
#define DRVLITTLEFS_H
|
||||
|
||||
#if (VFS_CFG_ENABLE_DRV_LITTLEFS == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
#include "oop_sequential_stream.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Configuration options
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Maximum number of LittleFS file systems mounted.
|
||||
*/
|
||||
#if !defined(DRV_CFG_LITTLEFS_FS_NUM) || defined(__DOXYGEN__)
|
||||
#define DRV_CFG_LITTLEFS_FS_NUM 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of directory nodes pre-allocated in the pool.
|
||||
*/
|
||||
#if !defined(DRV_CFG_LITTLEFS_DIR_NODES_NUM) || defined(__DOXYGEN__)
|
||||
#define DRV_CFG_LITTLEFS_DIR_NODES_NUM 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of file nodes pre-allocated in the pool.
|
||||
*/
|
||||
#if !defined(DRV_CFG_LITTLEFS_FILE_NODES_NUM) || defined(__DOXYGEN__)
|
||||
#define DRV_CFG_LITTLEFS_FILE_NODES_NUM 1
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/* Checks on DRV_CFG_LITTLEFS_FS_NUM configuration.*/
|
||||
#if DRV_CFG_LITTLEFS_FS_NUM < 1
|
||||
#error "invalid DRV_CFG_LITTLEFS_FS_NUM value"
|
||||
#endif
|
||||
|
||||
/* Checks on DRV_CFG_LITTLEFS_DIR_NODES_NUM configuration.*/
|
||||
#if DRV_CFG_LITTLEFS_DIR_NODES_NUM < 1
|
||||
#error "invalid DRV_CFG_LITTLEFS_DIR_NODES_NUM value"
|
||||
#endif
|
||||
|
||||
/* Checks on DRV_CFG_LITTLEFS_FILE_NODES_NUM configuration.*/
|
||||
#if DRV_CFG_LITTLEFS_FILE_NODES_NUM < 1
|
||||
#error "invalid DRV_CFG_LITTLEFS_FILE_NODES_NUM value"
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @class vfs_littlefs_driver_c
|
||||
* @extends base_object_c, vfs_driver_c.
|
||||
*
|
||||
*
|
||||
* @name Class @p vfs_littlefs_driver_c structures
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Type of a VFS littlefs driver class.
|
||||
*/
|
||||
typedef struct vfs_littlefs_driver vfs_littlefs_driver_c;
|
||||
|
||||
/**
|
||||
* @brief Class @p vfs_littlefs_driver_c virtual methods table.
|
||||
*/
|
||||
struct vfs_littlefs_driver_vmt {
|
||||
/* From base_object_c.*/
|
||||
void (*dispose)(void *ip);
|
||||
/* From vfs_driver_c.*/
|
||||
msg_t (*setcwd)(void *ip, const char *path);
|
||||
msg_t (*getcwd)(void *ip, char *buf, size_t size);
|
||||
msg_t (*stat)(void *ip, const char *path, vfs_stat_t *sp);
|
||||
msg_t (*opendir)(void *ip, const char *path, vfs_directory_node_c **vdnpp);
|
||||
msg_t (*openfile)(void *ip, const char *path, int flags, vfs_file_node_c **vfnpp);
|
||||
msg_t (*unlink)(void *ip, const char *path);
|
||||
msg_t (*rename)(void *ip, const char *oldpath, const char *newpath);
|
||||
msg_t (*mkdir)(void *ip, const char *path, vfs_mode_t mode);
|
||||
msg_t (*rmdir)(void *ip, const char *path);
|
||||
/* From vfs_littlefs_driver_c.*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Structure representing a VFS littlefs driver class.
|
||||
*/
|
||||
struct vfs_littlefs_driver {
|
||||
/**
|
||||
* @brief Virtual Methods Table.
|
||||
*/
|
||||
const struct vfs_littlefs_driver_vmt *vmt;
|
||||
};
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
extern struct vfs_littlefs_driver_static_struct vfs_littlefs_driver_static;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Methods of vfs_littlefs_driver_c.*/
|
||||
void *__lfsdrv_objinit_impl(void *ip, const void *vmt);
|
||||
void __lfsdrv_dispose_impl(void *ip);
|
||||
msg_t __lfsdrv_setcwd_impl(void *ip, const char *path);
|
||||
msg_t __lfsdrv_getcwd_impl(void *ip, char *buf, size_t size);
|
||||
msg_t __lfsdrv_stat_impl(void *ip, const char *path, vfs_stat_t *sp);
|
||||
msg_t __lfsdrv_opendir_impl(void *ip, const char *path,
|
||||
vfs_directory_node_c **vdnpp);
|
||||
msg_t __lfsdrv_openfile_impl(void *ip, const char *path, int flags,
|
||||
vfs_file_node_c **vfnpp);
|
||||
msg_t __lfsdrv_unlink_impl(void *ip, const char *path);
|
||||
msg_t __lfsdrv_rename_impl(void *ip, const char *oldpath,
|
||||
const char *newpath);
|
||||
msg_t __lfsdrv_mkdir_impl(void *ip, const char *path, vfs_mode_t mode);
|
||||
msg_t __lfsdrv_rmdir_impl(void *ip, const char *path);
|
||||
/* Regular functions.*/
|
||||
void __drv_littlefs_init(void);
|
||||
msg_t lfsdrvMount(const char *name, bool mountnow);
|
||||
msg_t lfsdrvUnmount(const char *name);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module inline functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Default constructor of vfs_littlefs_driver_c
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
*
|
||||
* @brief Default initialization function of @p vfs_littlefs_driver_c.
|
||||
*
|
||||
* @param[out] self Pointer to a @p vfs_littlefs_driver_c instance
|
||||
* to be initialized.
|
||||
* @return Pointer to the initialized object.
|
||||
*
|
||||
* @objinit
|
||||
*/
|
||||
CC_FORCE_INLINE
|
||||
static inline vfs_littlefs_driver_c *lfsdrvObjectInit(vfs_littlefs_driver_c *self) {
|
||||
extern const struct vfs_littlefs_driver_vmt __vfs_littlefs_driver_vmt;
|
||||
|
||||
return __lfsdrv_objinit_impl(self, &__vfs_littlefs_driver_vmt);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
#endif /* VFS_CFG_ENABLE_DRV_LITTLEFS == TRUE */
|
||||
|
||||
#endif /* DRVLITTLEFS_H */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,697 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/* This is an, automatically generated, implementation file that can be
|
||||
manually edited, it is not re-generated if already present.*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Module initialization.
|
||||
*
|
||||
* @init
|
||||
*/
|
||||
void __drv_littlefs_init(void) {
|
||||
|
||||
/* Initializing pools.*/
|
||||
chPoolObjectInit(&vfs_littlefs_driver_static.dir_nodes_pool,
|
||||
sizeof (vfs_littlefs_dir_node_c),
|
||||
chCoreAllocAlignedI);
|
||||
chPoolObjectInit(&vfs_littlefs_driver_static.file_nodes_pool,
|
||||
sizeof (vfs_littlefs_file_node_c),
|
||||
chCoreAllocAlignedI);
|
||||
chPoolObjectInit(&vfs_littlefs_driver_static.info_nodes_pool,
|
||||
sizeof (struct lfs_info),
|
||||
chCoreAllocAlignedI);
|
||||
chPoolObjectInit(&vfs_littlefs_driver_static.fs_pool,
|
||||
sizeof (lfs_t),
|
||||
chCoreAllocAlignedI);
|
||||
|
||||
/* Preloading pools.*/
|
||||
chPoolLoadArray(&vfs_littlefs_driver_static.dir_nodes_pool,
|
||||
&vfs_littlefs_driver_static.dir_nodes[0],
|
||||
DRV_CFG_LITTLEFS_DIR_NODES_NUM);
|
||||
chPoolLoadArray(&vfs_littlefs_driver_static.file_nodes_pool,
|
||||
&vfs_littlefs_driver_static.file_nodes[0],
|
||||
DRV_CFG_LITTLEFS_FILE_NODES_NUM);
|
||||
chPoolLoadArray(&vfs_littlefs_driver_static.fs_pool,
|
||||
&vfs_littlefs_driver_static.fs[0],
|
||||
DRV_CFG_LITTLEFS_FS_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mounts a LittleFS volume.
|
||||
*
|
||||
* @param[in] name Name to be assigned to the volume, see LittleFS
|
||||
* @p f_mount() documentation because there are
|
||||
* several options.
|
||||
* @param[in] mountnow Immediate mount option.
|
||||
* @return The operation result.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
msg_t lfsdrvMount(const char *name, bool mountnow) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Unmounts a LittleFS volume.
|
||||
*
|
||||
* @param[in] name Name of the volume to be unmounted.
|
||||
* @return The operation result.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
msg_t lfsdrvUnmount(const char *name) {
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module class "vfs_littlefs_dir_node_c" methods. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Methods implementations of vfs_littlefs_dir_node_c
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @memberof vfs_littlefs_dir_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Implementation of object creation.
|
||||
* @note This function is meant to be used by derived classes.
|
||||
*
|
||||
* @param[out] ip Pointer to a @p vfs_littlefs_dir_node_c
|
||||
* instance to be initialized.
|
||||
* @param[in] vmt VMT pointer for the new object.
|
||||
* @param[in] driver Pointer to the controlling driver.
|
||||
* @param[in] mode Node mode flags.
|
||||
* @return A new reference to the object.
|
||||
*/
|
||||
static void *__ffdir_objinit_impl(void *ip, const void *vmt,
|
||||
vfs_driver_c *driver, vfs_mode_t mode) {
|
||||
vfs_littlefs_dir_node_c *self = (vfs_littlefs_dir_node_c *)ip;
|
||||
|
||||
/* Initialization code.*/
|
||||
self = __vfsdir_objinit_impl(ip, vmt, (vfs_driver_c *)driver, mode);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_dir_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Implementation of object finalization.
|
||||
* @note This function is meant to be used by derived classes.
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_dir_node_c
|
||||
* instance to be disposed.
|
||||
*/
|
||||
static void __ffdir_dispose_impl(void *ip) {
|
||||
vfs_littlefs_dir_node_c *self = (vfs_littlefs_dir_node_c *)ip;
|
||||
|
||||
/* No finalization code.*/
|
||||
(void)self;
|
||||
|
||||
/* Finalization of the ancestors-defined parts.*/
|
||||
__vfsdir_dispose_impl(self);
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_dir_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsNodeStat().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_dir_node_c
|
||||
* instance.
|
||||
* @param[out] sp Pointer to a @p vfs_stat_t structure.
|
||||
* @return The operation result.
|
||||
*/
|
||||
static msg_t __ffdir_stat_impl(void *ip, vfs_stat_t *sp) {
|
||||
vfs_littlefs_dir_node_c *self = (vfs_littlefs_dir_node_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_dir_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDirReadFirst().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_dir_node_c
|
||||
* instance.
|
||||
* @param[out] dip Pointer to a @p vfs_direntry_info_t structure.
|
||||
* @return The operation result.
|
||||
*/
|
||||
static msg_t __ffdir_first_impl(void *ip, vfs_direntry_info_t *dip) {
|
||||
vfs_littlefs_dir_node_c *self = (vfs_littlefs_dir_node_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_dir_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDirReadNext().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_dir_node_c
|
||||
* instance.
|
||||
* @param[out] dip Pointer to a @p vfs_direntry_info_t structure.
|
||||
* @return The operation result.
|
||||
*/
|
||||
static msg_t __ffdir_next_impl(void *ip, vfs_direntry_info_t *dip) {
|
||||
vfs_littlefs_dir_node_c *self = (vfs_littlefs_dir_node_c *)ip;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief VMT structure of VFS littlefs directory node class.
|
||||
* @note It is public because accessed by the inlined constructor.
|
||||
*/
|
||||
static const struct vfs_littlefs_dir_node_vmt __vfs_littlefs_dir_node_vmt = {
|
||||
.dispose = __ffdir_dispose_impl,
|
||||
.addref = __ro_addref_impl,
|
||||
.release = __ro_release_impl,
|
||||
.stat = __ffdir_stat_impl,
|
||||
.first = __ffdir_first_impl,
|
||||
.next = __ffdir_next_impl
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Default constructor of vfs_littlefs_dir_node_c
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @memberof vfs_littlefs_dir_node_c
|
||||
*
|
||||
* @brief Default initialization function of @p vfs_littlefs_dir_node_c.
|
||||
*
|
||||
* @param[out] self Pointer to a @p vfs_littlefs_dir_node_c
|
||||
* instance to be initialized.
|
||||
* @param[in] driver Pointer to the controlling driver.
|
||||
* @param[in] mode Node mode flags.
|
||||
* @return Pointer to the initialized object.
|
||||
*
|
||||
* @objinit
|
||||
*/
|
||||
static vfs_littlefs_dir_node_c *ffdirObjectInit(vfs_littlefs_dir_node_c *self,
|
||||
vfs_driver_c *driver,
|
||||
vfs_mode_t mode) {
|
||||
|
||||
return __ffdir_objinit_impl(self, &__vfs_littlefs_dir_node_vmt, driver, mode);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module class "vfs_littlefs_file_node_c" methods. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Interfaces implementation of vfs_littlefs_file_node_c
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @private
|
||||
*
|
||||
* @brief Implementation of interface method @p stmWrite().
|
||||
*
|
||||
* @param[in,out] ip Pointer to the @p sequential_stream_i class
|
||||
* interface.
|
||||
* @param[in] bp Pointer to the data buffer.
|
||||
* @param[in] n The maximum amount of data to be transferred.
|
||||
* @return The number of bytes transferred. The returned
|
||||
* value can be less than the specified number of
|
||||
* bytes if an end-of-file condition has been met.
|
||||
*/
|
||||
static size_t __fffile_stm_write_impl(void *ip, const uint8_t *bp, size_t n) {
|
||||
vfs_littlefs_file_node_c *self = oopIfGetOwner(vfs_littlefs_file_node_c, ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @private
|
||||
*
|
||||
* @brief Implementation of interface method @p stmRead().
|
||||
*
|
||||
* @param[in,out] ip Pointer to the @p sequential_stream_i class
|
||||
* interface.
|
||||
* @param[out] bp Pointer to the data buffer.
|
||||
* @param[in] n The maximum amount of data to be transferred.
|
||||
* @return The number of bytes transferred. The returned
|
||||
* value can be less than the specified number of
|
||||
* bytes if an end-of-file condition has been met.
|
||||
*/
|
||||
static size_t __fffile_stm_read_impl(void *ip, uint8_t *bp, size_t n) {
|
||||
vfs_littlefs_file_node_c *self = oopIfGetOwner(vfs_littlefs_file_node_c, ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @private
|
||||
*
|
||||
* @brief Implementation of interface method @p stmPut().
|
||||
*
|
||||
* @param[in,out] ip Pointer to the @p sequential_stream_i class
|
||||
* interface.
|
||||
* @param[in] b The byte value to be written to the stream.
|
||||
* @return The operation status.
|
||||
*/
|
||||
static int __fffile_stm_put_impl(void *ip, uint8_t b) {
|
||||
vfs_littlefs_file_node_c *self = oopIfGetOwner(vfs_littlefs_file_node_c, ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @private
|
||||
*
|
||||
* @brief Implementation of interface method @p stmGet().
|
||||
*
|
||||
* @param[in,out] ip Pointer to the @p sequential_stream_i class
|
||||
* interface.
|
||||
* @return A byte value from the stream.
|
||||
*/
|
||||
static int __fffile_stm_get_impl(void *ip) {
|
||||
vfs_littlefs_file_node_c *self = oopIfGetOwner(vfs_littlefs_file_node_c, ip);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Methods implementations of vfs_littlefs_file_node_c
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Implementation of object creation.
|
||||
* @note This function is meant to be used by derived classes.
|
||||
*
|
||||
* @param[out] ip Pointer to a @p vfs_littlefs_file_node_c
|
||||
* instance to be initialized.
|
||||
* @param[in] vmt VMT pointer for the new object.
|
||||
* @param[in] driver Pointer to the controlling driver.
|
||||
* @param[in] mode Node mode flags.
|
||||
* @return A new reference to the object.
|
||||
*/
|
||||
static void *__fffile_objinit_impl(void *ip, const void *vmt,
|
||||
vfs_driver_c *driver, vfs_mode_t mode) {
|
||||
vfs_littlefs_file_node_c *self = (vfs_littlefs_file_node_c *)ip;
|
||||
|
||||
/* Initialization of interface sequential_stream_i.*/
|
||||
{
|
||||
static const struct sequential_stream_vmt fffile_stm_vmt = {
|
||||
.instance_offset = offsetof(vfs_littlefs_file_node_c, stm),
|
||||
.write = __fffile_stm_write_impl,
|
||||
.read = __fffile_stm_read_impl,
|
||||
.put = __fffile_stm_put_impl,
|
||||
.get = __fffile_stm_get_impl,
|
||||
.unget = NULL /* Missing implementation.*/
|
||||
};
|
||||
oopIfObjectInit(&self->stm, &fffile_stm_vmt);
|
||||
}
|
||||
|
||||
/* Initialization code.*/
|
||||
self = __vfsfile_objinit_impl(ip, vmt, (vfs_driver_c *)driver, mode);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Implementation of object finalization.
|
||||
* @note This function is meant to be used by derived classes.
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_file_node_c
|
||||
* instance to be disposed.
|
||||
*/
|
||||
static void __fffile_dispose_impl(void *ip) {
|
||||
vfs_littlefs_file_node_c *self = (vfs_littlefs_file_node_c *)ip;
|
||||
|
||||
/* No finalization code.*/
|
||||
(void)self;
|
||||
|
||||
/* Finalization of the ancestors-defined parts.*/
|
||||
__vfsfile_dispose_impl(self);
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsNodeStat().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_file_node_c
|
||||
* instance.
|
||||
* @param[out] sp Pointer to a @p vfs_stat_t structure.
|
||||
* @return The operation result.
|
||||
*/
|
||||
static msg_t __fffile_stat_impl(void *ip, vfs_stat_t *sp) {
|
||||
vfs_littlefs_file_node_c *self = (vfs_littlefs_file_node_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsFileRead().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_file_node_c
|
||||
* instance.
|
||||
* @param[out] buf Pointer to the data buffer.
|
||||
* @param[in] n Maximum amount of data to be transferred.
|
||||
* @return The transferred number of bytes or an error.
|
||||
*/
|
||||
static ssize_t __fffile_read_impl(void *ip, uint8_t *buf, size_t n) {
|
||||
vfs_littlefs_file_node_c *self = (vfs_littlefs_file_node_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsFileWrite().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_file_node_c
|
||||
* instance.
|
||||
* @param[in] buf Pointer to the data buffer.
|
||||
* @param[in] n Maximum amount of data to be transferred.
|
||||
* @return The transferred number of bytes or an error.
|
||||
*/
|
||||
static ssize_t __fffile_write_impl(void *ip, const uint8_t *buf, size_t n) {
|
||||
vfs_littlefs_file_node_c *self = (vfs_littlefs_file_node_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsFileSetPosition().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_file_node_c
|
||||
* instance.
|
||||
* @param[in] offset Offset to be applied.
|
||||
* @param[in] whence Seek mode to be used.
|
||||
* @return The operation result.
|
||||
*/
|
||||
static msg_t __fffile_setpos_impl(void *ip, vfs_offset_t offset,
|
||||
vfs_seekmode_t whence) {
|
||||
vfs_littlefs_file_node_c *self = (vfs_littlefs_file_node_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsFileGetPosition().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_file_node_c
|
||||
* instance.
|
||||
* @return The current file position.
|
||||
*/
|
||||
static vfs_offset_t __fffile_getpos_impl(void *ip) {
|
||||
vfs_littlefs_file_node_c *self = (vfs_littlefs_file_node_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsFileGetStream().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_file_node_c
|
||||
* instance.
|
||||
* @return Pointer to the HAL stream interface.
|
||||
*/
|
||||
static sequential_stream_i *__fffile_getstream_impl(void *ip) {
|
||||
vfs_littlefs_file_node_c *self = (vfs_littlefs_file_node_c *)ip;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief VMT structure of VFS littlefs file node class.
|
||||
* @note It is public because accessed by the inlined constructor.
|
||||
*/
|
||||
static const struct vfs_littlefs_file_node_vmt __vfs_littlefs_file_node_vmt = {
|
||||
.dispose = __fffile_dispose_impl,
|
||||
.addref = __ro_addref_impl,
|
||||
.release = __ro_release_impl,
|
||||
.stat = __fffile_stat_impl,
|
||||
.read = __fffile_read_impl,
|
||||
.write = __fffile_write_impl,
|
||||
.setpos = __fffile_setpos_impl,
|
||||
.getpos = __fffile_getpos_impl,
|
||||
.getstream = __fffile_getstream_impl
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Default constructor of vfs_littlefs_file_node_c
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @memberof vfs_littlefs_file_node_c
|
||||
*
|
||||
* @brief Default initialization function of @p vfs_littlefs_file_node_c.
|
||||
*
|
||||
* @param[out] self Pointer to a @p vfs_littlefs_file_node_c
|
||||
* instance to be initialized.
|
||||
* @param[in] driver Pointer to the controlling driver.
|
||||
* @param[in] mode Node mode flags.
|
||||
* @return Pointer to the initialized object.
|
||||
*
|
||||
* @objinit
|
||||
*/
|
||||
static vfs_littlefs_file_node_c *fffileObjectInit(vfs_littlefs_file_node_c *self,
|
||||
vfs_driver_c *driver,
|
||||
vfs_mode_t mode) {
|
||||
|
||||
return __fffile_objinit_impl(self, &__vfs_littlefs_file_node_vmt, driver,
|
||||
mode);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module class "vfs_littlefs_driver_c" methods. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Methods implementations of vfs_littlefs_driver_c
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Implementation of object creation.
|
||||
* @note This function is meant to be used by derived classes.
|
||||
*
|
||||
* @param[out] ip Pointer to a @p vfs_littlefs_driver_c instance
|
||||
* to be initialized.
|
||||
* @param[in] vmt VMT pointer for the new object.
|
||||
* @return A new reference to the object.
|
||||
*/
|
||||
void *__lfsdrv_objinit_impl(void *ip, const void *vmt) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
|
||||
/* Initialization of the ancestors-defined parts.*/
|
||||
__vfsdrv_objinit_impl(self, vmt);
|
||||
|
||||
/* No initialization code.*/
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Implementation of object finalization.
|
||||
* @note This function is meant to be used by derived classes.
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_driver_c instance
|
||||
* to be disposed.
|
||||
*/
|
||||
void __lfsdrv_dispose_impl(void *ip) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
|
||||
/* No finalization code.*/
|
||||
(void)self;
|
||||
|
||||
/* Finalization of the ancestors-defined parts.*/
|
||||
__vfsdrv_dispose_impl(self);
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDrvChangeCurrentDirectory().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_driver_c instance.
|
||||
* @param[in] path Path of the new current directory.
|
||||
* @return The operation result.
|
||||
*/
|
||||
msg_t __lfsdrv_setcwd_impl(void *ip, const char *path) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDrvGetCurrentDirectory().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_driver_c instance.
|
||||
* @param[out] buf Buffer for the path string.
|
||||
* @param[in] size Size of the buffer.
|
||||
* @return The operation result.
|
||||
*/
|
||||
msg_t __lfsdrv_getcwd_impl(void *ip, char *buf, size_t size) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDrvStat().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_driver_c instance.
|
||||
* @param[in] path Absolute path of the node to be examined.
|
||||
* @param[out] sp Pointer to a @p vfs_stat_t structure.
|
||||
* @return The operation result.
|
||||
*/
|
||||
msg_t __lfsdrv_stat_impl(void *ip, const char *path, vfs_stat_t *sp) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDrvOpenDirectory().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_driver_c instance.
|
||||
* @param[in] path Absolute path of the directory to be opened.
|
||||
* @param[out] vdnpp Pointer to the pointer to the instantiated @p
|
||||
* vfs_directory_node_c object.
|
||||
* @return The operation result.
|
||||
*/
|
||||
msg_t __lfsdrv_opendir_impl(void *ip, const char *path,
|
||||
vfs_directory_node_c **vdnpp) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDrvOpenFile().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_driver_c instance.
|
||||
* @param[in] path Absolute path of the directory to be opened.
|
||||
* @param[in] flags File open flags.
|
||||
* @param[out] vfnpp Pointer to the pointer to the instantiated @p
|
||||
* vfs_file_node_c object.
|
||||
* @return The operation result.
|
||||
*/
|
||||
msg_t __lfsdrv_openfile_impl(void *ip, const char *path, int flags,
|
||||
vfs_file_node_c **vfnpp) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDrvUnlink().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_driver_c instance.
|
||||
* @param[in] path Path of the file to be unlinked.
|
||||
* @return The operation result.
|
||||
*/
|
||||
msg_t __lfsdrv_unlink_impl(void *ip, const char *path) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDrvRename().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_driver_c instance.
|
||||
* @param[in] oldpath Path of the node to be renamed.
|
||||
* @param[in] newpath New path of the renamed node.
|
||||
* @return The operation result.
|
||||
*/
|
||||
msg_t __lfsdrv_rename_impl(void *ip, const char *oldpath, const char *newpath) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDrvMkdir().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_driver_c instance.
|
||||
* @param[in] path Path of the directory to be created.
|
||||
* @param[in] mode Mode flags for the directory.
|
||||
* @return The operation result.
|
||||
*/
|
||||
msg_t __lfsdrv_mkdir_impl(void *ip, const char *path, vfs_mode_t mode) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof vfs_littlefs_driver_c
|
||||
* @protected
|
||||
*
|
||||
* @brief Override of method @p vfsDrvRmdir().
|
||||
*
|
||||
* @param[in,out] ip Pointer to a @p vfs_littlefs_driver_c instance.
|
||||
* @param[in] path Path of the directory to be removed.
|
||||
* @return The operation result.
|
||||
*/
|
||||
msg_t __lfsdrv_rmdir_impl(void *ip, const char *path) {
|
||||
vfs_littlefs_driver_c *self = (vfs_littlefs_driver_c *)ip;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief VMT structure of VFS littlefs driver class.
|
||||
* @note It is public because accessed by the inlined constructor.
|
||||
*/
|
||||
const struct vfs_littlefs_driver_vmt __vfs_littlefs_driver_vmt = {
|
||||
.dispose = __lfsdrv_dispose_impl,
|
||||
.setcwd = __lfsdrv_setcwd_impl,
|
||||
.getcwd = __lfsdrv_getcwd_impl,
|
||||
.stat = __lfsdrv_stat_impl,
|
||||
.opendir = __lfsdrv_opendir_impl,
|
||||
.openfile = __lfsdrv_openfile_impl,
|
||||
.unlink = __lfsdrv_unlink_impl,
|
||||
.rename = __lfsdrv_rename_impl,
|
||||
.mkdir = __lfsdrv_mkdir_impl,
|
||||
.rmdir = __lfsdrv_rmdir_impl
|
||||
};
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -103,6 +103,15 @@
|
|||
#include "drvfatfs.h"
|
||||
#endif
|
||||
|
||||
/* TODO temporary */
|
||||
#define VFS_CFG_ENABLE_DRV_LITTLEFS FALSE
|
||||
#define DRV_CFG_LITTLEFS_DIR_NODES_NUM 1
|
||||
#define DRV_CFG_LITTLEFS_FILE_NODES_NUM 1
|
||||
#define DRV_CFG_LITTLEFS_FS_NUM 1
|
||||
#if VFS_CFG_ENABLE_DRV_LITTLEFS == TRUE
|
||||
#include "drvlittlefs.h"
|
||||
#endif
|
||||
|
||||
/* TODO temporary */
|
||||
#define VFS_CFG_ENABLE_DRV_SFS FALSE
|
||||
#define DRV_CFG_SFS_DIR_NODES_NUM 1
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio
|
||||
ChibiOS - Copyright (C) 2006..2024 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -8,6 +8,7 @@ VFSSRC := $(CHIBIOS)/os/vfs/src/vfspaths.c \
|
|||
$(CHIBIOS)/os/vfs/drivers/template/drvtemplate.c \
|
||||
$(CHIBIOS)/os/vfs/drivers/sfs/drvsfs.c \
|
||||
$(CHIBIOS)/os/vfs/drivers/fatfs/drvfatfs.c \
|
||||
$(CHIBIOS)/os/vfs/drivers/littlefs/drvlittlefs.c \
|
||||
$(CHIBIOS)/os/vfs/drivers/overlay/drvoverlay.c \
|
||||
$(CHIBIOS)/os/vfs/drivers/streams/drvstreams.c
|
||||
|
||||
|
@ -17,6 +18,7 @@ VFSINC := $(CHIBIOS)/os/common/include \
|
|||
$(CHIBIOS)/os/vfs/drivers/template \
|
||||
$(CHIBIOS)/os/vfs/drivers/sfs \
|
||||
$(CHIBIOS)/os/vfs/drivers/fatfs \
|
||||
$(CHIBIOS)/os/vfs/drivers/littlefs \
|
||||
$(CHIBIOS)/os/vfs/drivers/overlay \
|
||||
$(CHIBIOS)/os/vfs/drivers/streams
|
||||
|
||||
|
|
Loading…
Reference in New Issue