37 #ifndef FLASH_MANAGER_H__ 38 #define FLASH_MANAGER_H__ 43 #include "packet_buffer.h" 44 #include "nrf_mesh_config_core.h" 46 #include "toolchain.h" 47 #include "bearer_event.h" 66 #define FLASH_MANAGER_DATA_PER_PAGE (PAGE_SIZE - sizeof(flash_manager_metadata_t)) 74 #define FLASH_MANAGER_PAGE_COUNT_MINIMUM(DATA_SIZE, LARGEST_ENTRY_SIZE) (1 + ((DATA_SIZE) / (FLASH_MANAGER_DATA_PER_PAGE - LARGEST_ENTRY_SIZE))) 76 #define FLASH_MANAGER_HANDLE_MAX (0x7EFF) 77 #define FLASH_MANAGER_HANDLE_INVALID (0x0000) 79 #define FLASH_MANAGER_ENTRY_LEN_OVERHEAD (sizeof(fm_header_t) / WORD_SIZE) 90 typedef uint16_t fm_handle_t; 119 FM_STATE_UNINITIALIZED,
143 uint8_t raw[PAGE_SIZE];
347 uint32_t * p_length);
422 uint32_t data_length);
513 if (bearer_event_handler())
void(* flash_manager_queue_empty_cb_t)(void)
Action queue empty callback, indicating that the flash manager is finished processing all its ongoing...
void flash_manager_action_queue_empty_cb_set(flash_manager_queue_empty_cb_t queue_empty_cb)
Sets a function to call when the flash manager's action queue is empty.
void flash_manager_entry_release(fm_entry_t *p_entry)
Release an allocated entry buffer that won't be committed after all.
flash_manager_write_complete_cb_t write_complete_cb
Callback called after every completed write action, or NULL.
The action completed successfully.
void(* flash_manager_write_complete_cb_t)(const flash_manager_t *p_manager, const fm_entry_t *p_entry, fm_result_t result)
Write complete callback, to give the user the result of an entry write action.
The managed flash area is full, and cannot accept any new entries.
fm_entry_t * flash_manager_entry_alloc(flash_manager_t *p_manager, fm_handle_t handle, uint32_t data_length)
Allocate a buffer for a flash entry write.
void flash_manager_init(void)
Initialize the flash manager.
flash_manager_invalidate_complete_cb_t invalidate_complete_cb
Callback called after every completed entry invalidation, or NULL.
uint32_t flash_manager_entry_read(const flash_manager_t *p_manager, fm_handle_t handle, void *p_data, uint32_t *p_length)
Read out the contents of the entry with the given handle.
flash_manager_config_t config
Manager configuration, as set by the user.
bool flash_manager_is_removing(flash_manager_t *p_manager)
Checks whether given flash manager is removing the file area.
void(* flash_manager_invalidate_complete_cb_t)(const flash_manager_t *p_manager, fm_handle_t handle, fm_result_t result)
Invalidate complete callback, to give the user the result of an entry invalidation action...
flash_manager_metadata_t metadata
Metadata at the start of every managed page.
void flash_manager_mem_listener_register(fm_mem_listener_t *p_listener)
Register a call back to be notified once memory has been made available in the internal buffer...
bool flash_manager_is_building(flash_manager_t *p_manager)
Checks whether given flash manager is building the file area.
static void flash_manager_wait(void)
Waits for the flash manager to complete all its operations.
fm_result_t
Flash action result, returned in complete-callback.
uint16_t fm_handle_t
Flash manager handle type, used to identify entries in a flash manager area.
_DEPRECATED const fm_entry_t * flash_manager_entry_get(const flash_manager_t *p_manager, fm_handle_t handle)
Get a pointer to the entry with the given index.
const void * flash_manager_recovery_page_get(void)
Get the address of the recovery page.
fm_handle_t match
Value that the masked portion of the handle has to match.
uint32_t min_available_space
Number of bytes that should always be left available during normal operation.
fm_handle_t mask
Mask to apply to the match value when comparing with a handle.
uint32_t page_count
Number of pages in the area.
_DEPRECATED const fm_entry_t * flash_manager_entry_next_get(const flash_manager_t *p_manager, const fm_handle_filter_t *p_filter, const fm_entry_t *p_start)
Get the next entry matching the given filter.
Flash manager configuration structure, defines the user-configurable parts of the flash manager...
Internal flash manager state, managed and used internally.
The flash HW malfunctioned, and the operation did not finish correctly.
uint32_t flash_manager_entry_invalidate(flash_manager_t *p_manager, fm_handle_t handle)
Invalidate the entry with the given handle.
fm_state_t
Valid state of a flash manager instance.
uint32_t flash_manager_remove(flash_manager_t *p_manager)
Remove the given flash manager, and erase all of its contents.
fm_iterate_action_t(* flash_manager_read_cb_t)(const fm_entry_t *p_entry, void *p_args)
Entry read callback type.
void(* flash_manager_remove_complete_cb_t)(const flash_manager_t *p_manager)
Remove complete callback, indicating that the requested remove operation has been completed...
uint32_t flash_manager_entries_read(const flash_manager_t *p_manager, const fm_handle_filter_t *p_filter, flash_manager_read_cb_t read_cb, void *p_args)
Read out flash manager entries.
flash_manager_remove_complete_cb_t remove_complete_cb
Callback called after the manager has been successfully removed.
uint32_t flash_manager_entry_count_get(const flash_manager_t *p_manager, const fm_handle_filter_t *p_filter)
Get the number of entries matching the given filter.
uint32_t invalid_bytes
Bytes invalidated in the area.
Single flash manager page.
fm_state_t state
State of the manager.
Continue iterating through the entries.
Stop iterating through the entries.
bool flash_manager_is_stable(void)
Checks whether the module is in the progress of flashing anything.
const flash_manager_page_t * p_area
Start of area owned by this flash manager.
The entry wasn't present in the manager.
Handle filter, used to search through all handles to find matches.
void(* flash_manager_mem_listener_cb_t)(void *p_args)
Memory listener callback, that will be called once the flash manager has some memory available...
fm_iterate_action_t
Action returned from the read callback, determining whether to continue the iteration.
void flash_manager_entry_commit(const fm_entry_t *p_entry)
Commit the given write buffer for flashing.
uint32_t flash_manager_add(flash_manager_t *p_manager, const flash_manager_config_t *p_config)
Add a flash manager instance.
flash_manager_mem_listener_cb_t callback
Callback to call when there's memory available.
const fm_entry_t * p_seal
Pointer to the seal entry.
queue_elem_t queue_elem
Used for linked list operation, should not be altered by the user.
void * p_args
Arguments pointer, set by the user and returned in the callback.
Single flash manager entry.