dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_flashfs_logfs.c File Reference
#include "pios.h"
#include "pios_flash.h"
#include "pios_flashfs_logfs_priv.h"
#include <stdbool.h>
#include <stddef.h>
#include "pios_flashfs.h"

Go to the source code of this file.

Data Structures

struct  logfs_state
 
struct  arena_header
 
struct  slot_header
 

Macros

#define MIN(x, y)   ((x) < (y) ? (x) : (y))
 
#define RAW_COPY_BLOCK_SIZE   16
 

Enumerations

enum  pios_flashfs_logfs_dev_magic { PIOS_FLASHFS_LOGFS_DEV_MAGIC = 0x94938201 }
 
enum  arena_state
 
enum  slot_state
 

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_statePIOS_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...
 

Variables

 ARENA_STATE_ERASED = 0xFFFFFFFF
 
 ARENA_STATE_RESERVED = 0xE6E6FFFF
 
 ARENA_STATE_ACTIVE = 0xE6E66666
 
 ARENA_STATE_OBSOLETE = 0x00000000
 
uint32_t magic
 
enum arena_state state
 
 SLOT_STATE_EMPTY = 0xFFFFFFFF
 
 SLOT_STATE_RESERVED = 0xFAFAFFFF
 
 SLOT_STATE_ACTIVE = 0xFAFAAAAA
 
 SLOT_STATE_OBSOLETE = 0x00000000
 
uint32_t obj_id
 
uint16_t obj_inst_id
 
uint16_t obj_size
 

Detailed Description

Author
Tau Labs, http://taulabs.org, Copyright (C) 2012-2013

Definition in file pios_flashfs_logfs.c.

Macro Definition Documentation

#define RAW_COPY_BLOCK_SIZE   16

Variable Documentation

ARENA_STATE_ACTIVE = 0xE6E66666

Definition at line 83 of file pios_flashfs_logfs.c.

ARENA_STATE_ERASED = 0xFFFFFFFF

Definition at line 81 of file pios_flashfs_logfs.c.

ARENA_STATE_OBSOLETE = 0x00000000

Definition at line 84 of file pios_flashfs_logfs.c.

ARENA_STATE_RESERVED = 0xE6E6FFFF

Definition at line 82 of file pios_flashfs_logfs.c.

uint32_t magic

Definition at line 72 of file pios_flashfs_logfs.c.

uint32_t obj_id

Definition at line 285 of file pios_flashfs_logfs.c.

uint16_t obj_inst_id

Definition at line 286 of file pios_flashfs_logfs.c.

uint16_t obj_size

Definition at line 287 of file pios_flashfs_logfs.c.

SLOT_STATE_ACTIVE = 0xFAFAAAAA

Definition at line 295 of file pios_flashfs_logfs.c.

SLOT_STATE_EMPTY = 0xFFFFFFFF

Definition at line 293 of file pios_flashfs_logfs.c.

SLOT_STATE_OBSOLETE = 0x00000000

Definition at line 296 of file pios_flashfs_logfs.c.

SLOT_STATE_RESERVED = 0xFAFAFFFF

Definition at line 294 of file pios_flashfs_logfs.c.

enum slot_state state

Definition at line 73 of file pios_flashfs_logfs.c.