Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fs/spiffs_cache.c
- // reads from spi flash or the cache
- s32_t spiffs_phys_rd // this will never happen, last resort for sake of symmetry
- s32_t res2 = SPIFFS_HAL_READ(fs, addr, len, dst);
- // writes to spi flash and/or the cache
- s32_t spiffs_phys_wr
- fs/spiffs_check.c
- // Scans all object look up. For each entry, corresponding page header is checked for validity.
- // If an object index header page is found, this is also checked
- s32_t spiffs_lookup_consistency_check(spiffs *fs, u8_t check_all_objects) // Checks consistency amongst all pages and fixes irregularities
- s32_t spiffs_page_consistency_check(spiffs *fs) // Removes orphaned and partially deleted index pages.
- // Scans for index pages. When an index page is found, corresponding index header is searched for.
- // If no such page exists, the index page cannot be reached as no index header exists and must be
- // deleted.
- s32_t spiffs_object_index_consistency_check(spiffs *fs)
- fs/spiffs_hydrogen.c
- #endif // SPIFFS_USE_MAGIC && SPIFFS_USE_MAGIC_LENGTH && SPIFFS_SINGLETON==0
- s32_t SPIFFS_mount(spiffs *fs, spiffs_config *config, u8_t *work,
- #endif // SPIFFS_READ_ONLY
- s32_t res = spiffs_fd_find_new(fs, &fd, path);
- #endif // !SPIFFS_READ_ONLY
- s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len)
- fs/spiffs_nucleus.h
- // ---------------
- s32_t spiffs_phys_rd// ---------------
- s32_t spiffs_obj_lu_scan// ---------------
- s32_t spiffs_page_allocate_data// ---------------
- s32_t spiffs_object_create// ---------------
- s32_t spiffs_gc_check// ---------------
- s32_t spiffs_fd_find_new
- fs/spiffs_gc.c
- // Searches for blocks where all entries are deleted - if one is found,
- // the block is erased. Compared to the non-quick gc, the quick one ensures
- // that no updates are needed on existing objects on pages that are erased.
- s32_t spiffs_gc_quick// Checks if garbage collecting is necessary. If so a candidate block is found,
- // cleansed and erased
- s32_t spiffs_gc_check// Updates page statistics for a block that is about to be erased
- s32_t spiffs_gc_erase_page_stats// Finds block candidates to erase
- s32_t spiffs_gc_find_candidate// Empties given block by moving all data into free pages of another block
- // Strategy:
- // loop:
- // scan object lookup for object data pages
- // for first found id, check spix and load corresponding object index page to memory
- // push object scan lookup entry index
- // rescan object lookup, find data pages with same id and referenced by same object index
- // move data page, update object index in memory
- // when reached end of lookup, store updated object index
- // pop object scan lookup entry index
- // repeat loop until end of object lookup
- // scan object lookup again for remaining object index pages, move to new page in other block
- //
- s32_t spiffs_gc_clean(spiffs *fs, spiffs_block_ix bix)
- fs/spiffs_nucleus.c
- // Find object lookup entry containing given id with visitor.
- // Iterate over object lookup pages in each block until a given object id entry is found.
- // When found, the visitor function is called with block index, entry index and user data.
- // If visitor returns SPIFFS_VIS_CONTINUE, the search goes on. Otherwise, the search will be
- // ended and visitor's return code is returned to caller.
- // If no visitor is given (0) the search returns on first entry with matching object id.
- // If no match is found in all look up, SPIFFS_VIS_END is returned.
- // @param fs the file system
- // @param starting_block the starting block to start search in
- // @param starting_lu_entry the look up index entry to start search in
- // @param flags ored combination of SPIFFS_VIS_CHECK_ID, SPIFFS_VIS_CHECK_PH,
- // SPIFFS_VIS_NO_WRAP
- // @param obj_id argument object id
- // @param v visitor callback function
- // @param user_const_p any const pointer, passed to the callback visitor function
- // @param user_var_p any pointer, passed to the callback visitor function
- // @param block_ix reported block index where match was found
- // @param lu_entry reported look up index where match was found
- s32_t spiffs_obj_lu_find_entry_visitor// Scans thru all obj lu and counts free, deleted and used pages
- // Find the maximum block erase count
- // Checks magic if enabled
- s32_t spiffs_obj_lu_scan// Find free object lookup entry
- // Iterate over object lookup pages in each block until a free object id entry is found
- s32_t spiffs_obj_lu_find_free// Find object lookup entry containing given id
- // Iterate over object lookup pages in each block until a given object id entry is found
- s32_t spiffs_obj_lu_find_id// Find object lookup entry containing given id and span index
- // Iterate over object lookup pages in each block until a given object id entry is found
- s32_t spiffs_obj_lu_find_id_and_span// Find object lookup entry containing given id and span index in page headers only
- // Iterate over object lookup pages in each block until a given object id entry is found
- s32_t spiffs_obj_lu_find_id_and_span_by_phdr// populates index map, from vector entry start to vector entry end, inclusive
- s32_t spiffs_populate_ix_map(spiffs *fs, spiffs_fd *fd, u32_t vec_entry_start, u32_t vec_entry_end) // Allocates a free defined page with given obj_id
- // Occupies object lookup entry and page
- // data may be NULL; where only page header is stored, len and page_offs is ignored
- s32_t spiffs_page_allocate_data// Moves a page from src to a free page and finalizes it. Updates page index. Page data is given in param page.
- // If page data is null, provided header is used for metainfo and page data is physically copied.
- s32_t spiffs_page_move// Deletes a page and removes it from object lookup.
- s32_t spiffs_page_delete// Create an object index header page with empty index and undefined length
- s32_t spiffs_object_create// update object index header with any combination of name/size/index
- // new_objix_hdr_data may be null, if so the object index header page is loaded
- // name may be null, if so name is not changed
- // size may be null, if so size is not changed
- s32_t spiffs_object_update_index_hdr// Open object by id
- s32_t spiffs_object_open_by_id// Open object by page index
- s32_t spiffs_object_open_by_page// Append to object
- // keep current object index (header) page in fs->work buffer
- s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) // Modify object
- // keep current object index (header) page in fs->work buffer
- s32_t spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) // Finds object index header page by name
- s32_t spiffs_object_find_object_index_header_by_name// Truncates object to new size. If new size is null, object may be removed totally
- s32_t spiffs_object_truncate#endif // !SPIFFS_READ_ONLY
- s32_t spiffs_object_read// Scans thru all object lookup for object index header pages. If total possible number of
- // object ids cannot fit into a work buffer, these are grouped. When a group containing free
- // object ids is found, the object lu is again scanned for object ids within group and bitmasked.
- // Finally, the bitmask is searched for a free id
- s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id, const u8_t *conflicting_name)
- fs/spiffs_nucleus.h
- /* For GCC, clang and TI compilers */
- #define SPIFFS_PACKED __attribute__((packed))
- /* For IAR ARM and Keil MDK-ARM compilers */
- #define SPIFFS_PACKED
- /* Unknown compiler */
- #define SPIFFS_PACKED
- #endif /* SPIFFS_NUCLEUS_H_ */
- fs/include/spiffs.h
- /* spi read call function type */
- typedef s32_t (*spiffs_read)(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *dst);
- /* spi write call function type */
- typedef s32_t (*spiffs_write)(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *src);
- /* spi erase call function type */
- typedef s32_t (*spiffs_erase)(struct spiffs_t *fs, u32_t addr, u32_t size);
- /* spi read call function type */
- typedef s32_t (*spiffs_read)(u32_t addr, u32_t size, u8_t *dst);
- /* spi write call function type */
- typedef s32_t (*spiffs_write)(u32_t addr, u32_t size, u8_t *src);
- /* spi erase call function type */
- typedef s32_t (*spiffs_erase)(u32_t addr, u32_t size);
- /* file system check callback report operation */
- typedef enum
- /* file system check callback report type */
- typedef enum
- /* file system check callback function */
- #if SPIFFS_HAL_CALLBACK_EXTRA
- /* file system listener callback operation */
- typedef enum
- /* the file has been created */
- SPIFFS_CB_CREATED = 0,
- /* the file has been updated or moved to another page */
- SPIFFS_CB_UPDATED,
- /* the file has been deleted */
- SPIFFS_CB_DELETED
- /* file system listener callback function */
- typedef void (*spiffs_file_callback)(struct spiffs_t *fs, spiffs_fileop_type op, spiffs_obj_id obj_id, spiffs_page_ix pix);
- /* Any write to the filehandle is appended to end of the file */
- #define SPIFFS_APPEND (1<<0)
- /* If the opened file exists, it will be truncated to zero length before opened */
- #define SPIFFS_TRUNC (1<<1)
- /* If the opened file does not exist, it will be created before opened */
- #define SPIFFS_CREAT (1<<2)
- /* The opened file may only be read */
- #define SPIFFS_RDONLY (1<<3)
- /* The opened file may only be written */
- #define SPIFFS_WRONLY (1<<4)
- /* The opened file may be both read and written */
- #define SPIFFS_RDWR (SPIFFS_RDONLY | SPIFFS_WRONLY)
- /* Any writes to the filehandle will never be cached but flushed directly */
- #define SPIFFS_DIRECT (1<<5)
- /* If SPIFFS_O_CREAT and SPIFFS_O_EXCL are set, SPIFFS_open() shall fail if the file exists */
- #define SPIFFS_EXCL (1<<6)
- /* spiffs file status struct */
- typedef struct
- #endif /* SPIFFS_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement