37 #define MFS_BANK_MAGIC_1 0xEC705ADEU 38 #define MFS_BANK_MAGIC_2 0xF0339CC5U 39 #define MFS_HEADER_MAGIC 0x5FAE45F0U 53 #if !defined(MFS_CFG_MAX_RECORDS) || defined(__DOXYGEN__) 54 #define MFS_CFG_MAX_RECORDS 32 60 #if !defined(MFS_CFG_MAX_REPAIR_ATTEMPTS) || defined(__DOXYGEN__) 61 #define MFS_CFG_MAX_REPAIR_ATTEMPTS 3 67 #if !defined(MFS_CFG_WRITE_VERIFY) || defined(__DOXYGEN__) 68 #define MFS_CFG_WRITE_VERIFY TRUE 77 #if !defined(MFS_CFG_STRONG_CHECKING) || defined(__DOXYGEN__) 78 #define MFS_CFG_STRONG_CHECKING TRUE 88 #if !defined(MFS_CFG_BUFFER_SIZE) || defined(__DOXYGEN__) 89 #define MFS_CFG_BUFFER_SIZE 32 97 #if MFS_CFG_MAX_RECORDS < 0 98 #error "invalid MFS_CFG_MAX_RECORDS value" 101 #if (MFS_CFG_MAX_REPAIR_ATTEMPTS < 1) || (MFS_CFG_MAX_REPAIR_ATTEMPTS > 10) 102 #error "invalid MFS_MAX_REPAIR_ATTEMPTS value" 105 #if MFS_CFG_BUFFER_SIZE < 16 106 #error "invalid MFS_CFG_BUFFER_SIZE value" 109 #if (MFS_CFG_BUFFER_SIZE & (MFS_CFG_BUFFER_SIZE - 1)) != 0 110 #error "MFS_CFG_BUFFER_SIZE is not a power of two" 144 MFS_ERR_INV_STATE = -1,
145 MFS_ERR_INV_SIZE = -2,
146 MFS_ERR_NOT_FOUND = -3,
147 MFS_ERR_OUT_OF_MEM = -4,
148 MFS_ERR_NOT_ERASED = -5,
149 MFS_ERR_FLASH_FAILURE = -6,
150 MFS_ERR_INTERNAL = -7
159 MFS_BANK_PARTIAL = 2,
167 MFS_RECORD_ERASED = 0,
170 MFS_RECORD_GARBAGE = 3
247 } mfs_record_descriptor_t;
342 #define MFS_IS_ERROR(err) ((err) < MFS_NO_ERROR) 343 #define MFS_IS_WARNING(err) ((err) > MFS_NO_ERROR) 358 size_t *np, uint8_t *buffer);
360 size_t n,
const uint8_t *buffer);
uint32_t flash_sector_t
Type of a flash sector number.
uint32_t erased
Erased value.
mfs_state_t state
Driver state.
void mfsStop(MFSDriver *mfsp)
Deactivates a MFS driver.
Type of a MFS configuration structure.
flash_offset_t used_space
Used space in the current bank without considering erased records.
mfs_error_t mfsReadRecord(MFSDriver *mfsp, mfs_id_t id, size_t *np, uint8_t *buffer)
Retrieves and reads a data record.
flash_offset_t bank_size
Banks size.
mfs_bank_state_t
Type of a bank state assessment.
#define MFS_CFG_BUFFER_SIZE
Size of the buffer used for data copying.
mfs_error_t mfsWriteRecord(MFSDriver *mfsp, mfs_id_t id, size_t n, const uint8_t *buffer)
Creates or updates a data record.
mfs_error_t mfsStart(MFSDriver *mfsp, const MFSConfig *config)
Configures and activates a MFS driver.
mfs_bank_t
Type of a flash bank.
#define MFS_CFG_MAX_RECORDS
Maximum number of indexed records in the managed storage.
flash_sector_t bank1_start
Base sector index for bank 1.
mfs_error_t
Type of an MFS error code.
flash_sector_t bank0_sectors
Number of sectors for bank 0.
flash_sector_t bank1_sectors
Number of sectors for bank 1.
flash_offset_t next_offset
Pointer to the next free position in the current bank.
uint32_t flash_offset_t
Type of a flash offset.
mfs_error_t mfsErase(MFSDriver *mfsp)
Destroys the state of the managed storage by erasing the flash.
mfs_record_state_t
Type of a record state assessment.
mfs_error_t mfsEraseRecord(MFSDriver *mfsp, mfs_id_t id)
Erases a data record.
mfs_error_t mfsPerformGarbageCollection(MFSDriver *mfsp)
Enforces a garbage collection operation.
void mfsObjectInit(MFSDriver *mfsp)
Initializes an instance.
mfs_bank_t current_bank
Bank currently in use.
mfs_state_t
Type of driver state machine states.
uint32_t current_counter
Usage counter of the current bank.
Generic flash driver class header.
uint32_t mfs_id_t
Type of a record identifier.
flash_sector_t bank0_start
Base sector index for bank 0.
BaseFlash * flashp
Flash driver associated to this MFS instance.
const MFSConfig * config
Current configuration data.