dRonin
adbada4
dRonin firmware
|
Log Structured Filesystem for internal or external NOR Flash. More...
Data Structures | |
struct | logfs_state |
struct | arena_header |
struct | slot_header |
struct | streamfs_state |
struct | streamfs_footer |
struct | flashfs_logfs_cfg |
struct | streamfs_cfg |
Macros | |
#define | MIN(x, y) ((x) < (y) ? (x) : (y)) |
#define | MIN(x, y) ((x) < (y) ? (x) : (y)) |
#define | PIOS_STREAMFS_TASK_PRIORITY PIOS_THREAD_PRIO_LOW |
#define | PIOS_STREAMFS_TASK_STACK_BYTES 1000 |
Enumerations | |
enum | pios_flashfs_logfs_dev_magic { PIOS_FLASHFS_LOGFS_DEV_MAGIC = 0x94938201 } |
enum | arena_state |
enum | slot_state |
enum | pios_flashfs_streamfs_dev_magic { PIOS_FLASHFS_STREAMFS_DEV_MAGIC = 0x93A40F82 } |
Functions | |
static uintptr_t | logfs_get_addr (const struct logfs_state *logfs, uint8_t arena_id, uint16_t slot_id) |
Return the offset in flash of a particular slot within an arena. More... | |
enum arena_state | __attribute__ ((packed)) |
static int32_t | logfs_erase_arena (const struct logfs_state *logfs, uint8_t arena_id) |
Erases all sectors within the given arena and sets arena to erased state. More... | |
static int32_t | logfs_reserve_arena (const struct logfs_state *logfs, uint8_t arena_id) |
Marks the given arena as reserved so it can be filled. More... | |
static int32_t | logfs_erase_all_arenas (const struct logfs_state *logfs) |
Erases all arenas available to this filesystem instance. More... | |
static int32_t | logfs_activate_arena (const struct logfs_state *logfs, uint8_t arena_id) |
Marks the given arena as active so it can be mounted. More... | |
static int32_t | logfs_obsolete_arena (const struct logfs_state *logfs, uint8_t arena_id) |
Marks the given arena as obsolete. More... | |
static int32_t | logfs_find_active_arena (const struct logfs_state *logfs) |
Find the first active arena in flash. More... | |
static int32_t | logfs_raw_copy_bytes (const struct logfs_state *logfs, uintptr_t src_addr, uint16_t src_size, uintptr_t dst_addr) |
static bool | logfs_fs_is_full (const struct logfs_state *logfs) |
static bool | logfs_log_is_full (const struct logfs_state *logfs) |
static int32_t | logfs_unmount_log (struct logfs_state *logfs) |
static int32_t | logfs_mount_log (struct logfs_state *logfs, uint8_t arena_id) |
static bool | PIOS_FLASHFS_Logfs_validate (const struct logfs_state *logfs) |
static struct logfs_state * | PIOS_FLASHFS_Logfs_alloc (void) |
static void | PIOS_FLASHFS_Logfs_free (struct logfs_state *logfs) |
int32_t | PIOS_FLASHFS_Logfs_Init (uintptr_t *fs_id, const struct flashfs_logfs_cfg *cfg, enum pios_flash_partition_labels partition_label) |
Initialize the flash object setting FS. More... | |
int32_t | PIOS_FLASHFS_Logfs_Destroy (uintptr_t fs_id) |
static int32_t | logfs_garbage_collect (struct logfs_state *logfs) |
static int16_t | logfs_object_find_next (const struct logfs_state *logfs, struct slot_header *slot_hdr, uint16_t *curr_slot, uint32_t obj_id, uint16_t obj_inst_id) |
static int8_t | logfs_delete_object (struct logfs_state *logfs, uint32_t obj_id, uint16_t obj_inst_id) |
static int8_t | logfs_reserve_free_slot (struct logfs_state *logfs, uint16_t *slot_id, struct slot_header *slot_hdr, uint32_t obj_id, uint16_t obj_inst_id, uint16_t obj_size) |
static int8_t | logfs_append_to_log (struct logfs_state *logfs, uint32_t obj_id, uint16_t obj_inst_id, uint8_t *obj_data, uint16_t obj_size) |
int32_t | PIOS_FLASHFS_ObjSave (uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id, uint8_t *obj_data, uint16_t obj_size) |
Saves one object instance to the filesystem. More... | |
int32_t | PIOS_FLASHFS_ObjLoad (uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id, uint8_t *obj_data, uint16_t obj_size) |
Load one object instance from the filesystem. More... | |
int32_t | PIOS_FLASHFS_ObjDelete (uintptr_t fs_id, uint32_t obj_id, uint16_t obj_inst_id) |
Delete one instance of an object from the filesystem. More... | |
int32_t | PIOS_FLASHFS_Format (uintptr_t fs_id) |
Erases all filesystem arenas and activate the first arena. More... | |
static void | PIOS_STREAMFS_RegisterTxCallback (uintptr_t fs_id, pios_com_callback tx_out_cb, uintptr_t context) |
static void | PIOS_STREAMFS_TxStart (uintptr_t fs_id, uint16_t tx_bytes_avail) |
static uintptr_t | streamfs_get_addr (const struct streamfs_state *streamfs, uint32_t arena_id, uint16_t arena_offset) |
Return the offset in flash of a particular slot within an arena. More... | |
static int32_t | streamfs_erase_arena (const struct streamfs_state *streamfs, uint32_t arena_id) |
Erases all sectors within the given arena and sets arena to erased state. More... | |
static int32_t | streamfs_erase_all_arenas (const struct streamfs_state *streamfs) |
Erases all arenas available to this filesystem instance. More... | |
static bool | streamfs_validate (const struct streamfs_state *streamfs) |
static struct streamfs_state * | streamfs_alloc (void) |
static int32_t | streamfs_new_sector (struct streamfs_state *streamfs) |
static int32_t | streamfs_close_sector (struct streamfs_state *streamfs) |
static int32_t | streamfs_find_first_arena (struct streamfs_state *streamfs, int32_t file_id) |
static int32_t | streamfs_find_last_arena (struct streamfs_state *streamfs, int32_t file_id) |
static int32_t | streamfs_find_new_sector (struct streamfs_state *streamfs) |
static int32_t | streamfs_append_to_file (struct streamfs_state *streamfs, uint8_t *data, uint32_t len) |
static int32_t | streamfs_read_from_file (struct streamfs_state *streamfs, uint8_t *data, uint32_t len) |
static int32_t | streamfs_scan_filesystem (struct streamfs_state *streamfs) |
static void | PIOS_STREAMFS_Task (void *parameters) |
int32_t | PIOS_STREAMFS_Init (uintptr_t *fs_id, const struct streamfs_cfg *cfg, enum pios_flash_partition_labels partition_label) |
Initialize the flash object setting FS. More... | |
int32_t | PIOS_STREAMFS_Format (uintptr_t fs_id) |
Erases all filesystem arenas and activate the first arena. More... | |
int32_t | PIOS_STREAMFS_OpenWrite (uintptr_t fs_id) |
int32_t | PIOS_STREAMFS_OpenRead (uintptr_t fs_id, uint32_t file_id) |
int32_t | PIOS_STREAMFS_MinFileId (uintptr_t fs_id) |
int32_t | PIOS_STREAMFS_MaxFileId (uintptr_t fs_id) |
int32_t | PIOS_STREAMFS_Close (uintptr_t fs_id) |
int32_t | PIOS_STREAMFS_Read (uintptr_t fs_id, uint8_t *data, uint32_t len) |
int32_t | PIOS_STREAMFS_Testing_Write (uintptr_t fs_id, uint8_t *data, uint32_t len) |
Variables | |
const struct pios_com_driver | pios_streamfs_com_driver |
uint32_t | flashfs_logfs_cfg::fs_magic |
uint32_t | flashfs_logfs_cfg::arena_size |
uint32_t | flashfs_logfs_cfg::slot_size |
uint32_t | streamfs_cfg::fs_magic |
uint32_t | streamfs_cfg::arena_size |
uint32_t | streamfs_cfg::write_size |
const struct pios_com_driver | pios_streamfs_com_driver |
Log Structured Filesystem for internal or external NOR Flash.
Flash Filesystem API Definition.
Streaming circular buffer for external NOR Flash.
#define MIN | ( | x, | |
y | |||
) | ((x) < (y) ? (x) : (y)) |
Definition at line 35 of file pios_flashfs_logfs.c.
#define MIN | ( | x, | |
y | |||
) | ((x) < (y) ? (x) : (y)) |
Definition at line 39 of file pios_streamfs.c.
#define PIOS_STREAMFS_TASK_PRIORITY PIOS_THREAD_PRIO_LOW |
This file system provides the ability to create numbered files and stream to flash. These buffers will wrap around the available flash partition and the file system makes no attempt to prevent that happening. It is intended for applications of storing large files or logging information
Files are written into continuous sectors of the flash chip. Each sector has a footer to indicate the file id and the sector id.
Arenas map onto sectors.
Definition at line 57 of file pios_streamfs.c.
#define PIOS_STREAMFS_TASK_STACK_BYTES 1000 |
Definition at line 58 of file pios_streamfs.c.
enum arena_state |
Definition at line 85 of file pios_flashfs_logfs.c.
Enumerator | |
---|---|
PIOS_FLASHFS_LOGFS_DEV_MAGIC |
Definition at line 41 of file pios_flashfs_logfs.c.
Enumerator | |
---|---|
PIOS_FLASHFS_STREAMFS_DEV_MAGIC |
Definition at line 73 of file pios_streamfs.c.
enum slot_state |
Definition at line 314 of file pios_flashfs_logfs.c.
enum arena_state __attribute__ | ( | (packed) | ) |
Definition at line 38 of file serial_4way.h.
|
static |
Marks the given arena as active so it can be mounted.
Definition at line 203 of file pios_flashfs_logfs.c.
|
static |
Definition at line 796 of file pios_flashfs_logfs.c.
|
static |
Definition at line 699 of file pios_flashfs_logfs.c.
|
static |
Erases all arenas available to this filesystem instance.
Definition at line 185 of file pios_flashfs_logfs.c.
|
static |
Erases all sectors within the given arena and sets arena to erased state.
Definition at line 116 of file pios_flashfs_logfs.c.
|
static |
Find the first active arena in flash.
Definition at line 283 of file pios_flashfs_logfs.c.
|
static |
Definition at line 385 of file pios_flashfs_logfs.c.
|
static |
Definition at line 590 of file pios_flashfs_logfs.c.
|
static |
Return the offset in flash of a particular slot within an arena.
Definition at line 71 of file pios_flashfs_logfs.c.
|
static |
Definition at line 395 of file pios_flashfs_logfs.c.
|
static |
Definition at line 411 of file pios_flashfs_logfs.c.
|
static |
Definition at line 661 of file pios_flashfs_logfs.c.
|
static |
Marks the given arena as obsolete.
Definition at line 241 of file pios_flashfs_logfs.c.
|
static |
Definition at line 338 of file pios_flashfs_logfs.c.
|
static |
Marks the given arena as reserved so it can be filled.
Definition at line 148 of file pios_flashfs_logfs.c.
|
static |
Definition at line 740 of file pios_flashfs_logfs.c.
|
static |
Definition at line 400 of file pios_flashfs_logfs.c.
int32_t PIOS_FLASHFS_Format | ( | uintptr_t | fs_id | ) |
Erases all filesystem arenas and activate the first arena.
[in] | fs_id | The filesystem to use for this action |
-1 | if fs_id is not a valid filesystem instance |
-2 | if failed to start transaction |
-3 | if failed to erase all arenas |
-4 | if failed to activate arena 0 |
-5 | if failed to mount arena 0 |
Definition at line 1055 of file pios_flashfs_logfs.c.
|
static |
Definition at line 464 of file pios_flashfs_logfs.c.
int32_t PIOS_FLASHFS_Logfs_Destroy | ( | uintptr_t | fs_id | ) |
Definition at line 571 of file pios_flashfs_logfs.c.
|
static |
Definition at line 474 of file pios_flashfs_logfs.c.
int32_t PIOS_FLASHFS_Logfs_Init | ( | uintptr_t * | fs_id, |
const struct flashfs_logfs_cfg * | cfg, | ||
enum pios_flash_partition_labels | partition_label | ||
) |
Initialize the flash object setting FS.
Definition at line 485 of file pios_flashfs_logfs.c.
|
static |
Definition at line 459 of file pios_flashfs_logfs.c.
int32_t PIOS_FLASHFS_ObjDelete | ( | uintptr_t | fs_id, |
uint32_t | obj_id, | ||
uint16_t | obj_inst_id | ||
) |
Delete one instance of an object from the filesystem.
[in] | fs_id | The filesystem to use for this action |
[in] | obj | UAVObject ID of the object to delete |
[in] | obj_inst_id | The instance of the object to delete |
-1 | if fs_id is not a valid filesystem instance |
-2 | if failed to start transaction |
-3 | if failed to delete the object from the filesystem |
Definition at line 1014 of file pios_flashfs_logfs.c.
int32_t PIOS_FLASHFS_ObjLoad | ( | uintptr_t | fs_id, |
uint32_t | obj_id, | ||
uint16_t | obj_inst_id, | ||
uint8_t * | obj_data, | ||
uint16_t | obj_size | ||
) |
Load one object instance from the filesystem.
[in] | fs_id | The filesystem to use for this action |
[in] | obj | UAVObject ID of the object to load |
[in] | obj_inst_id | The instance of the object to load |
[in] | obj_data | Buffer to hold the contents of the loaded object |
[in] | obj_size | Size of the object to be loaded |
-1 | if fs_id is not a valid filesystem instance |
-2 | if failed to start transaction |
-3 | if object not found in filesystem |
-4 | if object size in filesystem does not exactly match buffer size |
-5 | if reading the object data from flash fails |
Definition at line 947 of file pios_flashfs_logfs.c.
int32_t PIOS_FLASHFS_ObjSave | ( | uintptr_t | fs_id, |
uint32_t | obj_id, | ||
uint16_t | obj_inst_id, | ||
uint8_t * | obj_data, | ||
uint16_t | obj_size | ||
) |
Saves one object instance to the filesystem.
[in] | fs_id | The filesystem to use for this action |
[in] | obj | UAVObject ID of the object to save |
[in] | obj_inst_id | The instance number of the object being saved |
[in] | obj_data | Contents of the object being saved |
[in] | obj_size | Size of the object being saved |
-1 | if fs_id is not a valid filesystem instance |
-2 | if failed to start transaction |
-3 | if failure to delete any previous versions of the object |
-4 | if filesystem is entirely full and garbage collection won't help |
-5 | if garbage collection failed |
-6 | if filesystem is full even after garbage collection should have freed space |
-7 | if writing the new object to the filesystem failed |
Definition at line 861 of file pios_flashfs_logfs.c.
int32_t PIOS_STREAMFS_Close | ( | uintptr_t | fs_id | ) |
Definition at line 871 of file pios_streamfs.c.
int32_t PIOS_STREAMFS_Format | ( | uintptr_t | fs_id | ) |
Erases all filesystem arenas and activate the first arena.
[in] | fs_id | The filesystem to use for this action |
-1 | if fs_id is not a valid filesystem instance |
-2 | if failed to start transaction |
-3 | if failed to erase all arenas |
-4 | if failed to activate arena 0 |
-5 | if failed to mount arena 0 |
Definition at line 681 of file pios_streamfs.c.
int32_t PIOS_STREAMFS_Init | ( | uintptr_t * | fs_id, |
const struct streamfs_cfg * | cfg, | ||
enum pios_flash_partition_labels | partition_label | ||
) |
Initialize the flash object setting FS.
Definition at line 581 of file pios_streamfs.c.
int32_t PIOS_STREAMFS_MaxFileId | ( | uintptr_t | fs_id | ) |
Definition at line 859 of file pios_streamfs.c.
int32_t PIOS_STREAMFS_MinFileId | ( | uintptr_t | fs_id | ) |
Definition at line 847 of file pios_streamfs.c.
int32_t PIOS_STREAMFS_OpenRead | ( | uintptr_t | fs_id, |
uint32_t | file_id | ||
) |
Definition at line 786 of file pios_streamfs.c.
int32_t PIOS_STREAMFS_OpenWrite | ( | uintptr_t | fs_id | ) |
Create a new file for streaming to
[in] | fs_id | the streaming device handle |
Definition at line 724 of file pios_streamfs.c.
int32_t PIOS_STREAMFS_Read | ( | uintptr_t | fs_id, |
uint8_t * | data, | ||
uint32_t | len | ||
) |
Definition at line 941 of file pios_streamfs.c.
|
static |
Definition at line 1021 of file pios_streamfs.c.
|
static |
Definition at line 513 of file pios_streamfs.c.
int32_t PIOS_STREAMFS_Testing_Write | ( | uintptr_t | fs_id, |
uint8_t * | data, | ||
uint32_t | len | ||
) |
Definition at line 975 of file pios_streamfs.c.
|
static |
Definition at line 1011 of file pios_streamfs.c.
|
static |
Definition at line 178 of file pios_streamfs.c.
|
static |
Definition at line 360 of file pios_streamfs.c.
|
static |
Close this sector by writing footer. Does not prepare next sector.
Definition at line 237 of file pios_streamfs.c.
|
static |
Erases all arenas available to this filesystem instance.
Definition at line 161 of file pios_streamfs.c.
|
static |
Erases all sectors within the given arena and sets arena to erased state.
Definition at line 143 of file pios_streamfs.c.
|
static |
Find the first arena for a file
[in] | streamfs | the file system handle |
[in] | file_id | the file to find |
: Must be called while holding the flash transaction lock
Definition at line 264 of file pios_streamfs.c.
|
static |
Find the last arena for a file
[in] | streamfs | the file system handle |
[in] | file_id | the file to find |
: Must be called while holding the flash transaction lock
Definition at line 305 of file pios_streamfs.c.
|
static |
Find the first sector for a file
[in] | streamfs | the file system handle |
: Must be called while holding the flash transaction lock
Definition at line 345 of file pios_streamfs.c.
|
static |
Return the offset in flash of a particular slot within an arena.
Definition at line 118 of file pios_streamfs.c.
|
static |
Write footer to current sector and reset pointers for writing to next sector
Definition at line 194 of file pios_streamfs.c.
|
static |
Definition at line 402 of file pios_streamfs.c.
|
static |
Definition at line 473 of file pios_streamfs.c.
|
static |
Definition at line 173 of file pios_streamfs.c.
uint32_t streamfs_cfg::arena_size |
Definition at line 37 of file pios_streamfs_priv.h.
uint32_t flashfs_logfs_cfg::arena_size |
Definition at line 40 of file pios_flashfs_logfs_priv.h.
uint32_t streamfs_cfg::fs_magic |
Definition at line 36 of file pios_streamfs_priv.h.
uint32_t flashfs_logfs_cfg::fs_magic |
Definition at line 39 of file pios_flashfs_logfs_priv.h.
const struct pios_com_driver pios_streamfs_com_driver |
Definition at line 64 of file pios_streamfs.c.
const struct pios_com_driver pios_streamfs_com_driver |
Definition at line 64 of file pios_streamfs.c.
uint32_t flashfs_logfs_cfg::slot_size |
Definition at line 41 of file pios_flashfs_logfs_priv.h.
uint32_t streamfs_cfg::write_size |
Definition at line 38 of file pios_streamfs_priv.h.