SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fs/spiffs_cache.c
  2. // reads from spi flash or the cache
  3. s32_t spiffs_phys_rd      // this will never happen, last resort for sake of symmetry
  4.       s32_t res2 = SPIFFS_HAL_READ(fs, addr, len, dst);
  5. // writes to spi flash and/or the cache
  6. s32_t spiffs_phys_wr
  7. fs/spiffs_check.c
  8. // Scans all object look up. For each entry, corresponding page header is checked for validity.
  9. // If an object index header page is found, this is also checked
  10. s32_t spiffs_lookup_consistency_check(spiffs *fs, u8_t check_all_objects) // Checks consistency amongst all pages and fixes irregularities
  11. s32_t spiffs_page_consistency_check(spiffs *fs) // Removes orphaned and partially deleted index pages.
  12. // Scans for index pages. When an index page is found, corresponding index header is searched for.
  13. // If no such page exists, the index page cannot be reached as no index header exists and must be
  14. // deleted.
  15. s32_t spiffs_object_index_consistency_check(spiffs *fs)
  16. fs/spiffs_hydrogen.c
  17. #endif // SPIFFS_USE_MAGIC && SPIFFS_USE_MAGIC_LENGTH && SPIFFS_SINGLETON==0
  18.  
  19. s32_t SPIFFS_mount(spiffs *fs, spiffs_config *config, u8_t *work,
  20. #endif // SPIFFS_READ_ONLY
  21.  
  22.   s32_t res = spiffs_fd_find_new(fs, &fd, path);
  23. #endif // !SPIFFS_READ_ONLY
  24.  
  25. s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len)
  26. fs/spiffs_nucleus.h
  27. // ---------------
  28.  
  29. s32_t spiffs_phys_rd// ---------------
  30.  
  31. s32_t spiffs_obj_lu_scan// ---------------
  32.  
  33. s32_t spiffs_page_allocate_data// ---------------
  34.  
  35. s32_t spiffs_object_create// ---------------
  36.  
  37. s32_t spiffs_gc_check// ---------------
  38.  
  39. s32_t spiffs_fd_find_new
  40. fs/spiffs_gc.c
  41. // Searches for blocks where all entries are deleted - if one is found,
  42. // the block is erased. Compared to the non-quick gc, the quick one ensures
  43. // that no updates are needed on existing objects on pages that are erased.
  44. s32_t spiffs_gc_quick// Checks if garbage collecting is necessary. If so a candidate block is found,
  45. // cleansed and erased
  46. s32_t spiffs_gc_check// Updates page statistics for a block that is about to be erased
  47. s32_t spiffs_gc_erase_page_stats// Finds block candidates to erase
  48. s32_t spiffs_gc_find_candidate// Empties given block by moving all data into free pages of another block
  49. // Strategy:
  50. //   loop:
  51. //   scan object lookup for object data pages
  52. //   for first found id, check spix and load corresponding object index page to memory
  53. //   push object scan lookup entry index
  54. //     rescan object lookup, find data pages with same id and referenced by same object index
  55. //     move data page, update object index in memory
  56. //     when reached end of lookup, store updated object index
  57. //   pop object scan lookup entry index
  58. //   repeat loop until end of object lookup
  59. //   scan object lookup again for remaining object index pages, move to new page in other block
  60. //
  61. s32_t spiffs_gc_clean(spiffs *fs, spiffs_block_ix bix)
  62. fs/spiffs_nucleus.c
  63. // Find object lookup entry containing given id with visitor.
  64. // Iterate over object lookup pages in each block until a given object id entry is found.
  65. // When found, the visitor function is called with block index, entry index and user data.
  66. // If visitor returns SPIFFS_VIS_CONTINUE, the search goes on. Otherwise, the search will be
  67. // ended and visitor's return code is returned to caller.
  68. // If no visitor is given (0) the search returns on first entry with matching object id.
  69. // If no match is found in all look up, SPIFFS_VIS_END is returned.
  70. // @param fs                    the file system
  71. // @param starting_block        the starting block to start search in
  72. // @param starting_lu_entry     the look up index entry to start search in
  73. // @param flags                 ored combination of SPIFFS_VIS_CHECK_ID, SPIFFS_VIS_CHECK_PH,
  74. //                              SPIFFS_VIS_NO_WRAP
  75. // @param obj_id                argument object id
  76. // @param v                     visitor callback function
  77. // @param user_const_p          any const pointer, passed to the callback visitor function
  78. // @param user_var_p            any pointer, passed to the callback visitor function
  79. // @param block_ix              reported block index where match was found
  80. // @param lu_entry              reported look up index where match was found
  81. s32_t spiffs_obj_lu_find_entry_visitor// Scans thru all obj lu and counts free, deleted and used pages
  82. // Find the maximum block erase count
  83. // Checks magic if enabled
  84. s32_t spiffs_obj_lu_scan// Find free object lookup entry
  85. // Iterate over object lookup pages in each block until a free object id entry is found
  86. s32_t spiffs_obj_lu_find_free// Find object lookup entry containing given id
  87. // Iterate over object lookup pages in each block until a given object id entry is found
  88. s32_t spiffs_obj_lu_find_id// Find object lookup entry containing given id and span index
  89. // Iterate over object lookup pages in each block until a given object id entry is found
  90. s32_t spiffs_obj_lu_find_id_and_span// Find object lookup entry containing given id and span index in page headers only
  91. // Iterate over object lookup pages in each block until a given object id entry is found
  92. s32_t spiffs_obj_lu_find_id_and_span_by_phdr// populates index map, from vector entry start to vector entry end, inclusive
  93. 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
  94. // Occupies object lookup entry and page
  95. // data may be NULL; where only page header is stored, len and page_offs is ignored
  96. 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.
  97. // If page data is null, provided header is used for metainfo and page data is physically copied.
  98. s32_t spiffs_page_move// Deletes a page and removes it from object lookup.
  99. s32_t spiffs_page_delete// Create an object index header page with empty index and undefined length
  100. s32_t spiffs_object_create// update object index header with any combination of name/size/index
  101. // new_objix_hdr_data may be null, if so the object index header page is loaded
  102. // name may be null, if so name is not changed
  103. // size may be null, if so size is not changed
  104. s32_t spiffs_object_update_index_hdr// Open object by id
  105. s32_t spiffs_object_open_by_id// Open object by page index
  106. s32_t spiffs_object_open_by_page// Append to object
  107. // keep current object index (header) page in fs->work buffer
  108. s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) // Modify object
  109. // keep current object index (header) page in fs->work buffer
  110. s32_t spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) // Finds object index header page by name
  111. 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
  112. s32_t spiffs_object_truncate#endif // !SPIFFS_READ_ONLY
  113.  
  114. s32_t spiffs_object_read// Scans thru all object lookup for object index header pages. If total possible number of
  115. // object ids cannot fit into a work buffer, these are grouped. When a group containing free
  116. // object ids is found, the object lu is again scanned for object ids within group and bitmasked.
  117. // Finally, the bitmask is searched for a free id
  118. s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id, const u8_t *conflicting_name)
  119.  
  120. fs/spiffs_nucleus.h
  121.     /* For GCC, clang and TI compilers */
  122. #define SPIFFS_PACKED __attribute__((packed))
  123.     /* For IAR ARM and Keil MDK-ARM compilers */
  124. #define SPIFFS_PACKED
  125.     /* Unknown compiler */
  126. #define SPIFFS_PACKED
  127. #endif /* SPIFFS_NUCLEUS_H_ */
  128.  
  129.  
  130. fs/include/spiffs.h
  131. /* spi read call function type */
  132. typedef s32_t (*spiffs_read)(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *dst);
  133. /* spi write call function type */
  134. typedef s32_t (*spiffs_write)(struct spiffs_t *fs, u32_t addr, u32_t size, u8_t *src);
  135. /* spi erase call function type */
  136. typedef s32_t (*spiffs_erase)(struct spiffs_t *fs, u32_t addr, u32_t size);
  137. /* spi read call function type */
  138. typedef s32_t (*spiffs_read)(u32_t addr, u32_t size, u8_t *dst);
  139. /* spi write call function type */
  140. typedef s32_t (*spiffs_write)(u32_t addr, u32_t size, u8_t *src);
  141. /* spi erase call function type */
  142. typedef s32_t (*spiffs_erase)(u32_t addr, u32_t size);
  143. /* file system check callback report operation */
  144. typedef enum
  145. /* file system check callback report type */
  146. typedef enum
  147. /* file system check callback function */
  148. #if SPIFFS_HAL_CALLBACK_EXTRA
  149. /* file system listener callback operation */
  150. typedef enum
  151.   /* the file has been created */
  152.   SPIFFS_CB_CREATED = 0,
  153.   /* the file has been updated or moved to another page */
  154.   SPIFFS_CB_UPDATED,
  155.   /* the file has been deleted */
  156.   SPIFFS_CB_DELETED
  157. /* file system listener callback function */
  158. typedef void (*spiffs_file_callback)(struct spiffs_t *fs, spiffs_fileop_type op, spiffs_obj_id obj_id, spiffs_page_ix pix);
  159. /* Any write to the filehandle is appended to end of the file */
  160. #define SPIFFS_APPEND                   (1<<0)
  161. /* If the opened file exists, it will be truncated to zero length before opened */
  162. #define SPIFFS_TRUNC                    (1<<1)
  163. /* If the opened file does not exist, it will be created before opened */
  164. #define SPIFFS_CREAT                    (1<<2)
  165. /* The opened file may only be read */
  166. #define SPIFFS_RDONLY                   (1<<3)
  167. /* The opened file may only be written */
  168. #define SPIFFS_WRONLY                   (1<<4)
  169. /* The opened file may be both read and written */
  170. #define SPIFFS_RDWR                     (SPIFFS_RDONLY | SPIFFS_WRONLY)
  171. /* Any writes to the filehandle will never be cached but flushed directly */
  172. #define SPIFFS_DIRECT                   (1<<5)
  173. /* If SPIFFS_O_CREAT and SPIFFS_O_EXCL are set, SPIFFS_open() shall fail if the file exists */
  174. #define SPIFFS_EXCL                     (1<<6)
  175. /* spiffs file status struct */
  176. typedef struct
  177. #endif /* SPIFFS_H_ */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top