ChibiOS/HAL
6.1.0
|
Managed Flash Storage module code. More...
Go to the source code of this file.
Macros | |
#define | RET_ON_ERROR(err) |
Error check helper. More... | |
Functions | |
static mfs_error_t | mfs_flash_read (MFSDriver *mfsp, flash_offset_t offset, size_t n, uint8_t *rp) |
Flash read. More... | |
static mfs_error_t | mfs_flash_write (MFSDriver *mfsp, flash_offset_t offset, size_t n, const uint8_t *wp) |
Flash write. More... | |
static mfs_error_t | mfs_flash_copy (MFSDriver *mfsp, flash_offset_t doffset, flash_offset_t soffset, uint32_t n) |
Flash copy. More... | |
static mfs_error_t | mfs_record_check (MFSDriver *mfsp, mfs_data_header_t *dhdrp, flash_offset_t offset, flash_offset_t limit, mfs_record_state_t *sts) |
Verifies integrity of a record. More... | |
static mfs_error_t | mfs_bank_erase (MFSDriver *mfsp, mfs_bank_t bank) |
Erases and verifies all sectors belonging to a bank. More... | |
static mfs_error_t | mfs_bank_verify_erase (MFSDriver *mfsp, mfs_bank_t bank) |
Erases and verifies all sectors belonging to a bank. More... | |
static mfs_error_t | mfs_bank_write_header (MFSDriver *mfsp, mfs_bank_t bank, uint32_t cnt) |
Writes the validation header in a bank. More... | |
static mfs_error_t | mfs_bank_scan_records (MFSDriver *mfsp, mfs_bank_t bank, mfs_bank_state_t *statep) |
Scans blocks searching for records. More... | |
static mfs_error_t | mfs_bank_get_state (MFSDriver *mfsp, mfs_bank_t bank, mfs_bank_state_t *statep, uint32_t *cntp) |
Determines the state of a bank. More... | |
static mfs_error_t | mfs_bank_mount (MFSDriver *mfsp, mfs_bank_t bank, mfs_bank_state_t *statep) |
Selects a bank as current. More... | |
static mfs_error_t | mfs_garbage_collect (MFSDriver *mfsp) |
Enforces a garbage collection. More... | |
static mfs_error_t | mfs_try_mount (MFSDriver *mfsp) |
Performs a flash partition mount attempt. More... | |
mfs_error_t | mfs_mount (MFSDriver *mfsp) |
Configures and activates a MFS driver. More... | |
void | mfsObjectInit (MFSDriver *mfsp) |
Initializes an instance. More... | |
mfs_error_t | mfsStart (MFSDriver *mfsp, const MFSConfig *config) |
Configures and activates a MFS driver. More... | |
void | mfsStop (MFSDriver *mfsp) |
Deactivates a MFS driver. More... | |
mfs_error_t | mfsErase (MFSDriver *mfsp) |
Destroys the state of the managed storage by erasing the flash. More... | |
mfs_error_t | mfsReadRecord (MFSDriver *mfsp, mfs_id_t id, size_t *np, uint8_t *buffer) |
Retrieves and reads a data record. More... | |
mfs_error_t | mfsWriteRecord (MFSDriver *mfsp, mfs_id_t id, size_t n, const uint8_t *buffer) |
Creates or updates a data record. More... | |
mfs_error_t | mfsEraseRecord (MFSDriver *mfsp, mfs_id_t id) |
Erases a data record. More... | |
mfs_error_t | mfsPerformGarbageCollection (MFSDriver *mfsp) |
Enforces a garbage collection operation. More... | |
Managed Flash Storage module code.
This module manages a flash partition as a generic storage where arbitrary data records can be created, updated, deleted and retrieved.
A managed partition is composed of two banks of equal size, a bank is composed of one or more erasable sectors, a sector is divided in writable pages.
The module handles flash wear leveling and recovery of damaged banks (where possible) caused by power loss during operations. Both operations are transparent to the user.
Definition in file mfs.c.