Tentative VFS subsystem.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15114 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
1566238b27
commit
656692ac4d
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
|
||||||
|
2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS.
|
||||||
|
|
||||||
|
ChibiOS is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation version 3 of the License.
|
||||||
|
|
||||||
|
ChibiOS is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file vfs/include/vfs.h
|
||||||
|
* @brief VFS main header file.
|
||||||
|
* @details Main header of the ChibiOS Virtual File System.
|
||||||
|
*
|
||||||
|
* @addtogroup VFS
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VFS_H
|
||||||
|
#define VFS_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ChibiOS/VFS identification macro.
|
||||||
|
*/
|
||||||
|
#define __CHIBIOS_VFS__
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stable release flag.
|
||||||
|
*/
|
||||||
|
#define CH_VFS_STABLE 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ChibiOS/VFS version identification
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @brief Kernel version string.
|
||||||
|
*/
|
||||||
|
#define CH_VFS_VERSION "1.0.0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Kernel version major number.
|
||||||
|
*/
|
||||||
|
#define CH_VFS_MAJOR 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Kernel version minor number.
|
||||||
|
*/
|
||||||
|
#define CH_VFS_MINOR 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Kernel version patch number.
|
||||||
|
*/
|
||||||
|
#define CH_VFS_PATCH 0
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/* Dependencies.*/
|
||||||
|
#include "ch.h"
|
||||||
|
|
||||||
|
/* License.*/
|
||||||
|
#include "chlicense.h"
|
||||||
|
|
||||||
|
/* Configuration headers, checks and licensing restrictions.*/
|
||||||
|
#include "vfsconf.h"
|
||||||
|
#include "vfschecks.h"
|
||||||
|
|
||||||
|
/* Base VFS headers.*/
|
||||||
|
#include "vfsnodes.h"
|
||||||
|
#include "vfsdrivers.h"
|
||||||
|
#include "vfssystem.h"
|
||||||
|
|
||||||
|
#endif /* VFS_H */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
|
||||||
|
2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS.
|
||||||
|
|
||||||
|
ChibiOS is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation version 3 of the License.
|
||||||
|
|
||||||
|
ChibiOS is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file vfs/include/vfschchecks.h
|
||||||
|
* @brief Configuration file checks header.
|
||||||
|
*
|
||||||
|
* @addtogroup VFS_CHECKS
|
||||||
|
* @details This module performs a series of checks on configuration data,
|
||||||
|
* it is able to detect and reject obsolete or incomplete
|
||||||
|
* @p vfsconf.h files.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VFSCHECKS_H
|
||||||
|
#define VFSCHECKS_H
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module constants. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module pre-compile time settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/* Configuration file checks.*/
|
||||||
|
#if !defined(_CHIBIOS_VFS_CONF_)
|
||||||
|
#error "invalid configuration file"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_CHIBIOS_VFS_CONF_VER_1_0_)
|
||||||
|
#error "obsolete or unknown configuration file"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configuration options checks.*/
|
||||||
|
#if !defined(VFS_CFG_MAX_DRIVERS)
|
||||||
|
#error "VFS_CFG_MAX_DRIVERS not defined in chconf.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (VFS_CFG_MAX_DRIVERS < 1) || (VFS_CFG_MAX_DRIVERS > 16)
|
||||||
|
#error "invalid value for VFS_CFG_MAX_DRIVERS"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Derived constants and error checks. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module data structures and types. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module macros. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* External declarations. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module inline functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#endif /* VFSCHECKS_H */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
|
||||||
|
2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS.
|
||||||
|
|
||||||
|
ChibiOS is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation version 3 of the License.
|
||||||
|
|
||||||
|
ChibiOS is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file vfs/include/vfsdrivers.h
|
||||||
|
* @brief VFS drivers header file.
|
||||||
|
*
|
||||||
|
* @addtogroup VFS_DRIVERS
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VFSDRIVERS_H
|
||||||
|
#define VFSDRIVERS_H
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module constants. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module pre-compile time settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Derived constants and error checks. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module data structures and types. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief @p vfs_node_t specific methods.
|
||||||
|
*/
|
||||||
|
#define __vfs_driver_methods \
|
||||||
|
/* Instance offset, used for multiple inheritance, normally zero. It
|
||||||
|
represents the offset between the current object and the container
|
||||||
|
object*/ \
|
||||||
|
size_t instance_offset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief @p vfs_node_t specific data.
|
||||||
|
*/
|
||||||
|
#define __vfs_driver_data
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief @p vfs_node_t virtual methods table.
|
||||||
|
*/
|
||||||
|
struct vfs_driver_vmt {
|
||||||
|
__vfs_driver_methods
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of a structure representing a VFS driver.
|
||||||
|
*/
|
||||||
|
typedef struct vfs_driver {
|
||||||
|
/**
|
||||||
|
* @brief Virtual Methods Table.
|
||||||
|
*/
|
||||||
|
const struct vfs_driver_vmt *vmt;
|
||||||
|
__vfs_driver_data
|
||||||
|
} vfs_driver_t;
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module macros. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* External declarations. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* VFSDRIVERS_H */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,118 @@
|
||||||
|
/*
|
||||||
|
ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
|
||||||
|
2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS.
|
||||||
|
|
||||||
|
ChibiOS is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation version 3 of the License.
|
||||||
|
|
||||||
|
ChibiOS is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file vfs/include/vfsnodes.h
|
||||||
|
* @brief VFS nodes header file.
|
||||||
|
*
|
||||||
|
* @addtogroup VFS_NODES
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VFSNODES_H
|
||||||
|
#define VFSNODES_H
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module constants. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module pre-compile time settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Derived constants and error checks. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module data structures and types. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/* Forward declaration because nodes holds references to drivers.*/
|
||||||
|
typedef struct vfs_driver vfs_driver_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of a VFS node.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
VFS_NODE_TYPE_DIRECTORY = 0,/**< VFS_NODE_TYPE_DIRECTORY */
|
||||||
|
VFS_NODE_TYPE_FILE = 1 /**< VFS_NODE_TYPE_FILE */
|
||||||
|
} vfs_node_type_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief @p vfs_node_t specific methods.
|
||||||
|
*/
|
||||||
|
#define __vfs_node_methods \
|
||||||
|
/* Instance offset, used for multiple inheritance, normally zero. It
|
||||||
|
represents the offset between the current object and the container
|
||||||
|
object*/ \
|
||||||
|
size_t instance_offset; \
|
||||||
|
/* Node release, the object is disposed when the counter reaches zero.*/ \
|
||||||
|
void (*release)(void *instance); \
|
||||||
|
/* Node type getter function.*/ \
|
||||||
|
vfs_node_type_t (*get_type)(void *instance); \
|
||||||
|
/* Node name getter function.*/ \
|
||||||
|
char (*get_name)(void *instance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief @p vfs_node_t specific data.
|
||||||
|
*/
|
||||||
|
#define __vfs_node_data \
|
||||||
|
/* Number of references to this node.*/ \
|
||||||
|
unsigned references_counter; \
|
||||||
|
/* Driver handling this node.*/ \
|
||||||
|
vfs_driver_t *driver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief @p vfs_node_t virtual methods table.
|
||||||
|
*/
|
||||||
|
struct vfs_node_vmt {
|
||||||
|
__vfs_node_methods
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of a structure representing a VFS node.
|
||||||
|
*/
|
||||||
|
typedef struct vfs_node {
|
||||||
|
/**
|
||||||
|
* @brief Virtual Methods Table.
|
||||||
|
*/
|
||||||
|
const struct vfs_node_vmt *vmt;
|
||||||
|
__vfs_node_data
|
||||||
|
} vfs_node_t;
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module macros. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* External declarations. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* VFSNODES_H */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*
|
||||||
|
ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
|
||||||
|
2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS.
|
||||||
|
|
||||||
|
ChibiOS is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation version 3 of the License.
|
||||||
|
|
||||||
|
ChibiOS is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file vfs/include/vfssystem.h
|
||||||
|
* @brief VFS system header file.
|
||||||
|
*
|
||||||
|
* @addtogroup VFS_NODES
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VFSSYSTEM_H
|
||||||
|
#define VFSSYSTEM_H
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module constants. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module pre-compile time settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Derived constants and error checks. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module data structures and types. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief @p vfs_system_node_t specific methods.
|
||||||
|
*/
|
||||||
|
#define __vfs_system_node_methods \
|
||||||
|
__vfs_node_methods
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief @p vfs_system_node_t specific data.
|
||||||
|
*/
|
||||||
|
#define __vfs_system_node_data \
|
||||||
|
__vfs_node_data
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief @p vfs_system_node_t virtual methods table.
|
||||||
|
*/
|
||||||
|
struct vfs_system_node_vmt {
|
||||||
|
__vfs_system_node_methods
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of a structure representing a VFS system node.
|
||||||
|
*/
|
||||||
|
typedef struct vfs_system_node {
|
||||||
|
/**
|
||||||
|
* @brief Virtual Methods Table.
|
||||||
|
*/
|
||||||
|
const struct vfs_system_node_vmt *vmt;
|
||||||
|
__vfs_system_node_data
|
||||||
|
} vfs_system_node_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of a structure representing the VFS system.
|
||||||
|
*/
|
||||||
|
typedef struct vfs_system {
|
||||||
|
/**
|
||||||
|
* @brief Absolute root node.
|
||||||
|
*/
|
||||||
|
vfs_node_t *root_node;
|
||||||
|
} vfs_system_t;
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module macros. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* External declarations. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* VFSSYSTEM_H */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
ChibiOS - Copyright (C) 2006..2020 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 templates/vfsconf.h
|
||||||
|
* @brief VFS configuration header.
|
||||||
|
*
|
||||||
|
* @addtogroup VFS_CONF
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VFSCONF_H
|
||||||
|
#define VFSCONF_H
|
||||||
|
|
||||||
|
#define _CHIBIOS_VFS_CONF_
|
||||||
|
#define _CHIBIOS_VFS_CONF_VER_1_0_
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Maximum of drivers to be registered in VFS.
|
||||||
|
*/
|
||||||
|
#if !defined(VFS_CFG_MAX_DRIVERS) || defined(__DOXYGEN__)
|
||||||
|
#define VFS_CFG_MAX_DRIVERS 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* VFSCONF_H */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,9 @@
|
||||||
|
# List of all the ChibiOS/VFS files.
|
||||||
|
VFSSRC := #$(CHIBIOS)/os/vfs/src/vfs.c
|
||||||
|
|
||||||
|
# Required include directories
|
||||||
|
VFSINC := $(CHIBIOS)/os/vfs/include
|
||||||
|
|
||||||
|
# Shared variables
|
||||||
|
ALLCSRC += $(VFSSRC)
|
||||||
|
ALLINC += $(VFSINC)
|
Loading…
Reference in New Issue