aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-06-09 09:29:03 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-06-09 09:29:03 +0000
commit562e6c0313a596f684e60bf589144590a14d8130 (patch)
treeb1913c1a59051f57a2b1a5c6a2fa2d6bc1381923
parent5a3cec6d006a0598e898476ee2abcf5a18d7a183 (diff)
downloadChibiOS-562e6c0313a596f684e60bf589144590a14d8130.tar.gz
ChibiOS-562e6c0313a596f684e60bf589144590a14d8130.tar.bz2
ChibiOS-562e6c0313a596f684e60bf589144590a14d8130.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9609 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/ex/subsystems/mfs/mfs.c87
-rw-r--r--os/ex/subsystems/mfs/mfs.h46
-rw-r--r--testhal/STM32/STM32L4xx/QSPI-N25Q128/Makefile4
3 files changed, 131 insertions, 6 deletions
diff --git a/os/ex/subsystems/mfs/mfs.c b/os/ex/subsystems/mfs/mfs.c
index 00488db1c..fe5960ad5 100644
--- a/os/ex/subsystems/mfs/mfs.c
+++ b/os/ex/subsystems/mfs/mfs.c
@@ -90,7 +90,7 @@ void mfsStart(MFSDriver *devp, const MFSConfig *config) {
/**
* @brief Deactivates a MFS driver.
*
- * @param[in] devp pointer to the @p MFSDriver object
+ * @param[in] devp pointer to the @p MFSDriver object
*
* @api
*/
@@ -105,4 +105,89 @@ void mfsStop(MFSDriver *devp) {
}
}
+/**
+ * @brief Mounts a managed flash storage.
+ * @details This functions checks the storage internal state and eventually
+ * performs the required initialization or repair operations.
+ *
+ * @param[in] devp pointer to the @p MFSDriver object
+ *
+ * @api
+ */
+mfs_error_t mfsMount(MFSDriver *devp) {
+
+ (void)devp;
+
+ return MFS_NOERROR;
+}
+
+/**
+ * @brief Unmounts a manage flash storage.
+ */
+mfs_error_t mfsUnmount(MFSDriver *devp) {
+
+ (void)devp;
+
+ return MFS_NOERROR;
+}
+
+/**
+ * @brief Retrieves and reads a data record.
+ *
+ * @param[in] devp pointer to the @p MFSDriver object
+ * @param[in] id record numeric identifier
+ * @param[in,out] np on input is the maximum buffer size, on return it is
+ * the size of the data copied into the buffer
+ * @param[in] buffer pointer to a buffer for record data
+ *
+ * @api
+ */
+mfs_error_t mfsReadRecord(MFSDriver *devp, uint32_t id,
+ uint32_t *np, uint8_t *buffer) {
+
+ (void)devp;
+ (void)id;
+ (void)np;
+ (void)buffer;
+
+ return MFS_NOERROR;
+}
+
+/**
+ * @brief Creates or updates a data record.
+ *
+ * @param[in] devp pointer to the @p MFSDriver object
+ * @param[in] id record numeric identifier
+ * @param[in] n size of data to be written, it cannot be zero
+ * @param[in] buffer pointer to a buffer for record data
+ *
+ * @api
+ */
+mfs_error_t mfsUpdateRecord(MFSDriver *devp, uint32_t id,
+ uint32_t n, const uint8_t *buffer) {
+
+ (void)devp;
+ (void)id;
+ (void)n;
+ (void)buffer;
+
+ return MFS_NOERROR;
+}
+
+/**
+ * @brief Erases a data record.
+ *
+ * @param[in] devp pointer to the @p MFSDriver object
+ * @param[in] id record numeric identifier
+ *
+ * @api
+ */
+mfs_error_t mfsEraseRecord(MFSDriver *devp, uint32_t id) {
+
+ (void)devp;
+ (void)id;
+
+ return MFS_NOERROR;
+}
+
/** @} */
diff --git a/os/ex/subsystems/mfs/mfs.h b/os/ex/subsystems/mfs/mfs.h
index 7abbde0da..61310f91d 100644
--- a/os/ex/subsystems/mfs/mfs.h
+++ b/os/ex/subsystems/mfs/mfs.h
@@ -52,17 +52,32 @@
/*===========================================================================*/
/**
- * @brief Driver state machine possible states.
+ * @brief Type of driver state machine states.
*/
typedef enum {
MFS_UNINIT = 0,
MFS_STOP = 1,
MFS_READY = 2,
- MFS_ACTIVE = 3
+ MFS_MOUNTED = 3,
+ MFS_ACTIVE = 4
} mfs_state_t;
/**
- * @brief Bank header.
+ * @brief Type of an MFS error code.
+ * @note Errors are negative integers, informative warnings are positive
+ * integers.
+ */
+typedef enum {
+ MFS_NOERROR = 0,
+ MFS_REPAIR_WARNING = 1,
+ MFS_GC_WARNING = 2,
+ MFS_ID_NOT_FOUND = -1,
+ MFS_CRC_ERROR = -2,
+ MFS_FLASH_FAILURE = -3
+} mfs_error_t;
+
+/**
+ * @brief Type of a bank header.
* @note The header resides in the first 16 bytes of a bank extending
* to the next page boundary.
*/
@@ -86,7 +101,7 @@ typedef struct {
} mfs_bank_header_t;
/**
- * @brief Data block header.
+ * @brief Type of a data block header.
*/
typedef union {
struct {
@@ -119,6 +134,22 @@ typedef struct {
* @brief Flash driver associated to this MFS instance.
*/
BaseFlash *flashp;
+ /**
+ * @brief Base sector index for bank 0.
+ */
+ flash_sector_t bank0_start;
+ /**
+ * #brief Number of sectors for bank 0.
+ */
+ flash_sector_t bank0_sectors;
+ /**
+ * @brief Base sector index for bank 1.
+ */
+ flash_sector_t bank1_start;
+ /**
+ * #brief Number of sectors for bank 1.
+ */
+ flash_sector_t bank1_sectors;
} MFSConfig;
/**
@@ -151,6 +182,13 @@ extern "C" {
void mfsObjectInit(MFSDriver *devp);
void mfsStart(MFSDriver *devp, const MFSConfig *config);
void mfsStop(MFSDriver *devp);
+ mfs_error_t mfsMount(MFSDriver *devp);
+ mfs_error_t mfsUnmount(MFSDriver *devp);
+ mfs_error_t mfsReadRecord(MFSDriver *devp, uint32_t id,
+ uint32_t *np, uint8_t *buffer);
+ mfs_error_t mfsUpdateRecord(MFSDriver *devp, uint32_t id,
+ uint32_t n, const uint8_t *buffer);
+ mfs_error_t mfsEraseRecord(MFSDriver *devp, uint32_t id);
#ifdef __cplusplus
}
#endif
diff --git a/testhal/STM32/STM32L4xx/QSPI-N25Q128/Makefile b/testhal/STM32/STM32L4xx/QSPI-N25Q128/Makefile
index 110783df6..0b9b33cdd 100644
--- a/testhal/STM32/STM32L4xx/QSPI-N25Q128/Makefile
+++ b/testhal/STM32/STM32L4xx/QSPI-N25Q128/Makefile
@@ -99,6 +99,7 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/os/ex/Micron/m25q.mk
+include $(CHIBIOS)/os/ex/subsystems/mfs/mfs.mk
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
# Define linker script file here
@@ -115,6 +116,7 @@ CSRC = $(STARTUPSRC) \
$(BOARDSRC) \
$(STREAMSSRC) \
$(M25QSRC) \
+ $(MFSSRC) \
main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -148,7 +150,7 @@ ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(CHIBIOS)/os/license \
$(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(M25QINC) \
- $(STREAMSINC) $(CHIBIOS)/os/various
+ $(MFSINC) $(STREAMSINC) $(CHIBIOS)/os/various
#
# Project, sources and paths