Commit c04f2578 authored by HuangRui's avatar HuangRui
Browse files

Updated SDK to v0.9.5 and optimized memory.

parent 0420b6d7
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#if SPIFFS_CACHE #if SPIFFS_CACHE
// returns cached page for give page index, or null if no such cached page // returns cached page for give page index, or null if no such cached page
static spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_get(spiffs *fs, spiffs_page_ix pix) { static spiffs_cache_page *spiffs_cache_page_get(spiffs *fs, spiffs_page_ix pix) {
spiffs_cache *cache = spiffs_get_cache(fs); spiffs_cache *cache = spiffs_get_cache(fs);
if ((cache->cpage_use_map & cache->cpage_use_mask) == 0) return 0; if ((cache->cpage_use_map & cache->cpage_use_mask) == 0) return 0;
int i; int i;
...@@ -30,7 +30,7 @@ static spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_get(spiffs *fs, sp ...@@ -30,7 +30,7 @@ static spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_get(spiffs *fs, sp
} }
// frees cached page // frees cached page
static s32_t ICACHE_FLASH_ATTR spiffs_cache_page_free(spiffs *fs, int ix, u8_t write_back) { static s32_t spiffs_cache_page_free(spiffs *fs, int ix, u8_t write_back) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
spiffs_cache *cache = spiffs_get_cache(fs); spiffs_cache *cache = spiffs_get_cache(fs);
spiffs_cache_page *cp = spiffs_get_cache_page_hdr(fs, cache, ix); spiffs_cache_page *cp = spiffs_get_cache_page_hdr(fs, cache, ix);
...@@ -56,7 +56,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_cache_page_free(spiffs *fs, int ix, u8_t w ...@@ -56,7 +56,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_cache_page_free(spiffs *fs, int ix, u8_t w
} }
// removes the oldest accessed cached page // removes the oldest accessed cached page
static s32_t ICACHE_FLASH_ATTR spiffs_cache_page_remove_oldest(spiffs *fs, u8_t flag_mask, u8_t flags) { static s32_t spiffs_cache_page_remove_oldest(spiffs *fs, u8_t flag_mask, u8_t flags) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
spiffs_cache *cache = spiffs_get_cache(fs); spiffs_cache *cache = spiffs_get_cache(fs);
...@@ -86,7 +86,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_cache_page_remove_oldest(spiffs *fs, u8_t ...@@ -86,7 +86,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_cache_page_remove_oldest(spiffs *fs, u8_t
} }
// allocates a new cached page and returns it, or null if all cache pages are busy // allocates a new cached page and returns it, or null if all cache pages are busy
static spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_allocate(spiffs *fs) { static spiffs_cache_page *spiffs_cache_page_allocate(spiffs *fs) {
spiffs_cache *cache = spiffs_get_cache(fs); spiffs_cache *cache = spiffs_get_cache(fs);
if (cache->cpage_use_map == 0xffffffff) { if (cache->cpage_use_map == 0xffffffff) {
// out of cache memory // out of cache memory
...@@ -107,7 +107,7 @@ static spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_allocate(spiffs *f ...@@ -107,7 +107,7 @@ static spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_allocate(spiffs *f
} }
// drops the cache page for give page index // drops the cache page for give page index
void ICACHE_FLASH_ATTR spiffs_cache_drop_page(spiffs *fs, spiffs_page_ix pix) { void spiffs_cache_drop_page(spiffs *fs, spiffs_page_ix pix) {
spiffs_cache_page *cp = spiffs_cache_page_get(fs, pix); spiffs_cache_page *cp = spiffs_cache_page_get(fs, pix);
if (cp) { if (cp) {
spiffs_cache_page_free(fs, cp->ix, 0); spiffs_cache_page_free(fs, cp->ix, 0);
...@@ -117,7 +117,7 @@ void ICACHE_FLASH_ATTR spiffs_cache_drop_page(spiffs *fs, spiffs_page_ix pix) { ...@@ -117,7 +117,7 @@ void ICACHE_FLASH_ATTR spiffs_cache_drop_page(spiffs *fs, spiffs_page_ix pix) {
// ------------------------------ // ------------------------------
// reads from spi flash or the cache // reads from spi flash or the cache
s32_t ICACHE_FLASH_ATTR spiffs_phys_rd( s32_t spiffs_phys_rd(
spiffs *fs, spiffs *fs,
u8_t op, u8_t op,
spiffs_file fh, spiffs_file fh,
...@@ -165,7 +165,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_rd( ...@@ -165,7 +165,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_rd(
} }
// writes to spi flash and/or the cache // writes to spi flash and/or the cache
s32_t ICACHE_FLASH_ATTR spiffs_phys_wr( s32_t spiffs_phys_wr(
spiffs *fs, spiffs *fs,
u8_t op, u8_t op,
spiffs_file fh, spiffs_file fh,
...@@ -207,7 +207,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_wr( ...@@ -207,7 +207,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_wr(
#if SPIFFS_CACHE_WR #if SPIFFS_CACHE_WR
// returns the cache page that this fd refers, or null if no cache page // returns the cache page that this fd refers, or null if no cache page
spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_get_by_fd(spiffs *fs, spiffs_fd *fd) { spiffs_cache_page *spiffs_cache_page_get_by_fd(spiffs *fs, spiffs_fd *fd) {
spiffs_cache *cache = spiffs_get_cache(fs); spiffs_cache *cache = spiffs_get_cache(fs);
if ((cache->cpage_use_map & cache->cpage_use_mask) == 0) { if ((cache->cpage_use_map & cache->cpage_use_mask) == 0) {
...@@ -230,7 +230,7 @@ spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_get_by_fd(spiffs *fs, spi ...@@ -230,7 +230,7 @@ spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_get_by_fd(spiffs *fs, spi
// allocates a new cache page and refers this to given fd - flushes an old cache // allocates a new cache page and refers this to given fd - flushes an old cache
// page if all cache is busy // page if all cache is busy
spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_allocate_by_fd(spiffs *fs, spiffs_fd *fd) { spiffs_cache_page *spiffs_cache_page_allocate_by_fd(spiffs *fs, spiffs_fd *fd) {
// before this function is called, it is ensured that there is no already existing // before this function is called, it is ensured that there is no already existing
// cache page with same object id // cache page with same object id
spiffs_cache_page_remove_oldest(fs, SPIFFS_CACHE_FLAG_TYPE_WR, 0); spiffs_cache_page_remove_oldest(fs, SPIFFS_CACHE_FLAG_TYPE_WR, 0);
...@@ -247,7 +247,7 @@ spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_allocate_by_fd(spiffs *fs ...@@ -247,7 +247,7 @@ spiffs_cache_page *ICACHE_FLASH_ATTR spiffs_cache_page_allocate_by_fd(spiffs *fs
} }
// unrefers all fds that this cache page refers to and releases the cache page // unrefers all fds that this cache page refers to and releases the cache page
void ICACHE_FLASH_ATTR spiffs_cache_fd_release(spiffs *fs, spiffs_cache_page *cp) { void spiffs_cache_fd_release(spiffs *fs, spiffs_cache_page *cp) {
if (cp == 0) return; if (cp == 0) return;
int i; int i;
spiffs_fd *fds = (spiffs_fd *)fs->fd_space; spiffs_fd *fds = (spiffs_fd *)fs->fd_space;
...@@ -265,7 +265,7 @@ void ICACHE_FLASH_ATTR spiffs_cache_fd_release(spiffs *fs, spiffs_cache_page *cp ...@@ -265,7 +265,7 @@ void ICACHE_FLASH_ATTR spiffs_cache_fd_release(spiffs *fs, spiffs_cache_page *cp
#endif #endif
// initializes the cache // initializes the cache
void ICACHE_FLASH_ATTR spiffs_cache_init(spiffs *fs) { void spiffs_cache_init(spiffs *fs) {
if (fs->cache == 0) return; if (fs->cache == 0) return;
u32_t sz = fs->cache_size; u32_t sz = fs->cache_size;
u32_t cache_mask = 0; u32_t cache_mask = 0;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
// searches in the object indices and returns the referenced page index given // searches in the object indices and returns the referenced page index given
// the object id and the data span index // the object id and the data span index
// destroys fs->lu_work // destroys fs->lu_work
static s32_t ICACHE_FLASH_ATTR spiffs_object_get_data_page_index_reference( static s32_t spiffs_object_get_data_page_index_reference(
spiffs *fs, spiffs *fs,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
spiffs_span_ix data_spix, spiffs_span_ix data_spix,
...@@ -59,7 +59,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_object_get_data_page_index_reference( ...@@ -59,7 +59,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_object_get_data_page_index_reference(
} }
// copies page contents to a new page // copies page contents to a new page
static s32_t ICACHE_FLASH_ATTR spiffs_rewrite_page(spiffs *fs, spiffs_page_ix cur_pix, spiffs_page_header *p_hdr, spiffs_page_ix *new_pix) { static s32_t spiffs_rewrite_page(spiffs *fs, spiffs_page_ix cur_pix, spiffs_page_header *p_hdr, spiffs_page_ix *new_pix) {
s32_t res; s32_t res;
res = spiffs_page_allocate_data(fs, p_hdr->obj_id, p_hdr, 0,0,0,0, new_pix); res = spiffs_page_allocate_data(fs, p_hdr->obj_id, p_hdr, 0,0,0,0, new_pix);
SPIFFS_CHECK_RES(res); SPIFFS_CHECK_RES(res);
...@@ -73,7 +73,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_rewrite_page(spiffs *fs, spiffs_page_ix cu ...@@ -73,7 +73,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_rewrite_page(spiffs *fs, spiffs_page_ix cu
// rewrites the object index for given object id and replaces the // rewrites the object index for given object id and replaces the
// data page index to a new page index // data page index to a new page index
static s32_t ICACHE_FLASH_ATTR spiffs_rewrite_index(spiffs *fs, spiffs_obj_id obj_id, spiffs_span_ix data_spix, spiffs_page_ix new_data_pix, spiffs_page_ix objix_pix) { static s32_t spiffs_rewrite_index(spiffs *fs, spiffs_obj_id obj_id, spiffs_span_ix data_spix, spiffs_page_ix new_data_pix, spiffs_page_ix objix_pix) {
s32_t res; s32_t res;
spiffs_block_ix bix; spiffs_block_ix bix;
int entry; int entry;
...@@ -137,7 +137,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_rewrite_index(spiffs *fs, spiffs_obj_id ob ...@@ -137,7 +137,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_rewrite_index(spiffs *fs, spiffs_obj_id ob
} }
// deletes an object just by marking object index header as deleted // deletes an object just by marking object index header as deleted
static s32_t ICACHE_FLASH_ATTR spiffs_delete_obj_lazy(spiffs *fs, spiffs_obj_id obj_id) { static s32_t spiffs_delete_obj_lazy(spiffs *fs, spiffs_obj_id obj_id) {
spiffs_page_ix objix_hdr_pix; spiffs_page_ix objix_hdr_pix;
s32_t res; s32_t res;
res = spiffs_obj_lu_find_id_and_span(fs, obj_id, 0, 0, &objix_hdr_pix); res = spiffs_obj_lu_find_id_and_span(fs, obj_id, 0, 0, &objix_hdr_pix);
...@@ -154,7 +154,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_delete_obj_lazy(spiffs *fs, spiffs_obj_id ...@@ -154,7 +154,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_delete_obj_lazy(spiffs *fs, spiffs_obj_id
} }
// validates the given look up entry // validates the given look up entry
static s32_t ICACHE_FLASH_ATTR spiffs_lookup_check_validate(spiffs *fs, spiffs_obj_id lu_obj_id, spiffs_page_header *p_hdr, static s32_t spiffs_lookup_check_validate(spiffs *fs, spiffs_obj_id lu_obj_id, spiffs_page_header *p_hdr,
spiffs_page_ix cur_pix, spiffs_block_ix cur_block, int cur_entry, int *reload_lu) { spiffs_page_ix cur_pix, spiffs_block_ix cur_block, int cur_entry, int *reload_lu) {
u8_t delete_page = 0; u8_t delete_page = 0;
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
...@@ -424,7 +424,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_lookup_check_validate(spiffs *fs, spiffs_o ...@@ -424,7 +424,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_lookup_check_validate(spiffs *fs, spiffs_o
return res; return res;
} }
static s32_t ICACHE_FLASH_ATTR spiffs_lookup_check_v(spiffs *fs, spiffs_obj_id obj_id, spiffs_block_ix cur_block, int cur_entry, static s32_t spiffs_lookup_check_v(spiffs *fs, spiffs_obj_id obj_id, spiffs_block_ix cur_block, int cur_entry,
u32_t user_data, void *user_p) { u32_t user_data, void *user_p) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
spiffs_page_header p_hdr; spiffs_page_header p_hdr;
...@@ -452,7 +452,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_lookup_check_v(spiffs *fs, spiffs_obj_id o ...@@ -452,7 +452,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_lookup_check_v(spiffs *fs, spiffs_obj_id o
// Scans all object look up. For each entry, corresponding page header is checked for validity. // 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 // If an object index header page is found, this is also checked
s32_t ICACHE_FLASH_ATTR spiffs_lookup_consistency_check(spiffs *fs, u8_t check_all_objects) { s32_t spiffs_lookup_consistency_check(spiffs *fs, u8_t check_all_objects) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
if (fs->check_cb_f) fs->check_cb_f(SPIFFS_CHECK_LOOKUP, SPIFFS_CHECK_PROGRESS, 0, 0); if (fs->check_cb_f) fs->check_cb_f(SPIFFS_CHECK_LOOKUP, SPIFFS_CHECK_PROGRESS, 0, 0);
...@@ -485,7 +485,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_lookup_consistency_check(spiffs *fs, u8_t check_a ...@@ -485,7 +485,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_lookup_consistency_check(spiffs *fs, u8_t check_a
// * x011 used, referenced only once, not index // * x011 used, referenced only once, not index
// * x101 used, unreferenced, index // * x101 used, unreferenced, index
// The working memory might not fit all pages so several scans might be needed // The working memory might not fit all pages so several scans might be needed
static s32_t ICACHE_FLASH_ATTR spiffs_page_consistency_check_i(spiffs *fs) { static s32_t spiffs_page_consistency_check_i(spiffs *fs) {
const u32_t bits = 4; const u32_t bits = 4;
const spiffs_page_ix pages_per_scan = SPIFFS_CFG_LOG_PAGE_SZ(fs) * 8 / bits; const spiffs_page_ix pages_per_scan = SPIFFS_CFG_LOG_PAGE_SZ(fs) * 8 / bits;
...@@ -822,7 +822,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_page_consistency_check_i(spiffs *fs) { ...@@ -822,7 +822,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_page_consistency_check_i(spiffs *fs) {
} }
// Checks consistency amongst all pages and fixes irregularities // Checks consistency amongst all pages and fixes irregularities
s32_t ICACHE_FLASH_ATTR spiffs_page_consistency_check(spiffs *fs) { s32_t spiffs_page_consistency_check(spiffs *fs) {
if (fs->check_cb_f) fs->check_cb_f(SPIFFS_CHECK_PAGE, SPIFFS_CHECK_PROGRESS, 0, 0); if (fs->check_cb_f) fs->check_cb_f(SPIFFS_CHECK_PAGE, SPIFFS_CHECK_PROGRESS, 0, 0);
s32_t res = spiffs_page_consistency_check_i(fs); s32_t res = spiffs_page_consistency_check_i(fs);
if (res != SPIFFS_OK) { if (res != SPIFFS_OK) {
...@@ -837,7 +837,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_consistency_check(spiffs *fs) { ...@@ -837,7 +837,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_consistency_check(spiffs *fs) {
// searches for given object id in temporary object id index, // searches for given object id in temporary object id index,
// returns the index or -1 // returns the index or -1
static int ICACHE_FLASH_ATTR spiffs_object_index_search(spiffs *fs, spiffs_obj_id obj_id) { static int spiffs_object_index_search(spiffs *fs, spiffs_obj_id obj_id) {
int i; int i;
spiffs_obj_id *obj_table = (spiffs_obj_id *)fs->work; spiffs_obj_id *obj_table = (spiffs_obj_id *)fs->work;
obj_id &= ~SPIFFS_OBJ_ID_IX_FLAG; obj_id &= ~SPIFFS_OBJ_ID_IX_FLAG;
...@@ -849,7 +849,7 @@ static int ICACHE_FLASH_ATTR spiffs_object_index_search(spiffs *fs, spiffs_obj_i ...@@ -849,7 +849,7 @@ static int ICACHE_FLASH_ATTR spiffs_object_index_search(spiffs *fs, spiffs_obj_i
return -1; return -1;
} }
s32_t ICACHE_FLASH_ATTR spiffs_object_index_consistency_check_v(spiffs *fs, spiffs_obj_id obj_id, spiffs_block_ix cur_block, s32_t spiffs_object_index_consistency_check_v(spiffs *fs, spiffs_obj_id obj_id, spiffs_block_ix cur_block,
int cur_entry, u32_t user_data, void *user_p) { int cur_entry, u32_t user_data, void *user_p) {
s32_t res_c = SPIFFS_VIS_COUNTINUE; s32_t res_c = SPIFFS_VIS_COUNTINUE;
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
...@@ -943,7 +943,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_index_consistency_check_v(spiffs *fs, spif ...@@ -943,7 +943,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_index_consistency_check_v(spiffs *fs, spif
// Scans for index pages. When an index page is found, corresponding index header is searched for. // 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 // If no such page exists, the index page cannot be reached as no index header exists and must be
// deleted. // deleted.
s32_t ICACHE_FLASH_ATTR spiffs_object_index_consistency_check(spiffs *fs) { s32_t spiffs_object_index_consistency_check(spiffs *fs) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
// impl note: // impl note:
// fs->work is used for a temporary object index memory, listing found object ids and // fs->work is used for a temporary object index memory, listing found object ids and
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// Erases a logical block and updates the erase counter. // Erases a logical block and updates the erase counter.
// If cache is enabled, all pages that might be cached in this block // If cache is enabled, all pages that might be cached in this block
// is dropped. // is dropped.
static s32_t ICACHE_FLASH_ATTR spiffs_gc_erase_block( static s32_t spiffs_gc_erase_block(
spiffs *fs, spiffs *fs,
spiffs_block_ix bix) { spiffs_block_ix bix) {
s32_t res; s32_t res;
...@@ -47,7 +47,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_gc_erase_block( ...@@ -47,7 +47,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_gc_erase_block(
// Searches for blocks where all entries are deleted - if one is found, // 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 // 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. // that no updates are needed on existing objects on pages that are erased.
s32_t ICACHE_FLASH_ATTR spiffs_gc_quick( s32_t spiffs_gc_quick(
spiffs *fs) { spiffs *fs) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
u32_t blocks = fs->block_count; u32_t blocks = fs->block_count;
...@@ -111,7 +111,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_gc_quick( ...@@ -111,7 +111,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_gc_quick(
// Checks if garbaga collecting is necessary. If so a candidate block is found, // Checks if garbaga collecting is necessary. If so a candidate block is found,
// cleansed and erased // cleansed and erased
s32_t ICACHE_FLASH_ATTR spiffs_gc_check( s32_t spiffs_gc_check(
spiffs *fs, spiffs *fs,
u32_t len) { u32_t len) {
s32_t res; s32_t res;
...@@ -179,7 +179,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_gc_check( ...@@ -179,7 +179,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_gc_check(
} }
// Updates page statistics for a block that is about to be erased // Updates page statistics for a block that is about to be erased
s32_t ICACHE_FLASH_ATTR spiffs_gc_erase_page_stats( s32_t spiffs_gc_erase_page_stats(
spiffs *fs, spiffs *fs,
spiffs_block_ix bix) { spiffs_block_ix bix) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
...@@ -216,7 +216,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_gc_erase_page_stats( ...@@ -216,7 +216,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_gc_erase_page_stats(
} }
// Finds block candidates to erase // Finds block candidates to erase
s32_t ICACHE_FLASH_ATTR spiffs_gc_find_candidate( s32_t spiffs_gc_find_candidate(
spiffs *fs, spiffs *fs,
spiffs_block_ix **block_candidates, spiffs_block_ix **block_candidates,
int *candidate_count) { int *candidate_count) {
...@@ -350,7 +350,7 @@ typedef struct { ...@@ -350,7 +350,7 @@ typedef struct {
// repeat loop until end of object lookup // repeat loop until end of object lookup
// scan object lookup again for remaining object index pages, move to new page in other block // scan object lookup again for remaining object index pages, move to new page in other block
// //
s32_t ICACHE_FLASH_ATTR spiffs_gc_clean(spiffs *fs, spiffs_block_ix bix) { s32_t spiffs_gc_clean(spiffs *fs, spiffs_block_ix bix) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
u32_t entries_per_page = (SPIFFS_CFG_LOG_PAGE_SZ(fs) / sizeof(spiffs_obj_id)); u32_t entries_per_page = (SPIFFS_CFG_LOG_PAGE_SZ(fs) / sizeof(spiffs_obj_id));
int cur_entry = 0; int cur_entry = 0;
......
...@@ -11,17 +11,17 @@ ...@@ -11,17 +11,17 @@
static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh); static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh);
#if SPIFFS_BUFFER_HELP #if SPIFFS_BUFFER_HELP
u32_t ICACHE_FLASH_ATTR SPIFFS_buffer_bytes_for_filedescs(spiffs *fs, u32_t num_descs) { u32_t SPIFFS_buffer_bytes_for_filedescs(spiffs *fs, u32_t num_descs) {
return num_descs * sizeof(spiffs_fd); return num_descs * sizeof(spiffs_fd);
} }
#if SPIFFS_CACHE #if SPIFFS_CACHE
u32_t ICACHE_FLASH_ATTR SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages) { u32_t SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages) {
return sizeof(spiffs_cache) + num_pages * (sizeof(spiffs_cache_page) + SPIFFS_CFG_LOG_PAGE_SZ(fs)); return sizeof(spiffs_cache) + num_pages * (sizeof(spiffs_cache_page) + SPIFFS_CFG_LOG_PAGE_SZ(fs));
} }
#endif #endif
#endif #endif
s32_t ICACHE_FLASH_ATTR SPIFFS_mount(spiffs *fs, spiffs_config *config, u8_t *work, s32_t SPIFFS_mount(spiffs *fs, spiffs_config *config, u8_t *work,
u8_t *fd_space, u32_t fd_space_size, u8_t *fd_space, u32_t fd_space_size,
void *cache, u32_t cache_size, void *cache, u32_t cache_size,
spiffs_check_callback check_cb_f) { spiffs_check_callback check_cb_f) {
...@@ -82,7 +82,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_mount(spiffs *fs, spiffs_config *config, u8_t *wo ...@@ -82,7 +82,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_mount(spiffs *fs, spiffs_config *config, u8_t *wo
return 0; return 0;
} }
void ICACHE_FLASH_ATTR SPIFFS_unmount(spiffs *fs) { void SPIFFS_unmount(spiffs *fs) {
if (!SPIFFS_CHECK_MOUNT(fs)) return; if (!SPIFFS_CHECK_MOUNT(fs)) return;
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
int i; int i;
...@@ -100,11 +100,11 @@ void ICACHE_FLASH_ATTR SPIFFS_unmount(spiffs *fs) { ...@@ -100,11 +100,11 @@ void ICACHE_FLASH_ATTR SPIFFS_unmount(spiffs *fs) {
SPIFFS_UNLOCK(fs); SPIFFS_UNLOCK(fs);
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_errno(spiffs *fs) { s32_t SPIFFS_errno(spiffs *fs) {
return fs->errno; return fs->errno;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode mode) { s32_t SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode mode) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
spiffs_obj_id obj_id; spiffs_obj_id obj_id;
...@@ -118,7 +118,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode m ...@@ -118,7 +118,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode m
return 0; return 0;
} }
spiffs_file ICACHE_FLASH_ATTR SPIFFS_open(spiffs *fs, const char *path, spiffs_flags flags, spiffs_mode mode) { spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_flags flags, spiffs_mode mode) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -175,7 +175,7 @@ spiffs_file ICACHE_FLASH_ATTR SPIFFS_open(spiffs *fs, const char *path, spiffs_f ...@@ -175,7 +175,7 @@ spiffs_file ICACHE_FLASH_ATTR SPIFFS_open(spiffs *fs, const char *path, spiffs_f
return fd->file_nbr; return fd->file_nbr;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, u32_t len) { s32_t SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, u32_t len) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -220,7 +220,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, u32_t ...@@ -220,7 +220,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, u32_t
return len; return len;
} }
static s32_t ICACHE_FLASH_ATTR spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, void *buf, u32_t offset, s32_t len) { static s32_t spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, void *buf, u32_t offset, s32_t len) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
s32_t remaining = len; s32_t remaining = len;
if (fd->size != SPIFFS_UNDEFINED_LEN && offset < fd->size) { if (fd->size != SPIFFS_UNDEFINED_LEN && offset < fd->size) {
...@@ -239,7 +239,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, voi ...@@ -239,7 +239,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_hydro_write(spiffs *fs, spiffs_fd *fd, voi
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, u32_t len) { s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, u32_t len) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -357,7 +357,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, u32_ ...@@ -357,7 +357,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, u32_
return res; return res;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_lseek(spiffs *fs, spiffs_file fh, s32_t offs, int whence) { s32_t SPIFFS_lseek(spiffs *fs, spiffs_file fh, s32_t offs, int whence) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -401,7 +401,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_lseek(spiffs *fs, spiffs_file fh, s32_t offs, int ...@@ -401,7 +401,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_lseek(spiffs *fs, spiffs_file fh, s32_t offs, int
return 0; return 0;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_remove(spiffs *fs, const char *path) { s32_t SPIFFS_remove(spiffs *fs, const char *path) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -434,7 +434,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_remove(spiffs *fs, const char *path) { ...@@ -434,7 +434,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_remove(spiffs *fs, const char *path) {
return 0; return 0;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_fremove(spiffs *fs, spiffs_file fh) { s32_t SPIFFS_fremove(spiffs *fs, spiffs_file fh) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -461,7 +461,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_fremove(spiffs *fs, spiffs_file fh) { ...@@ -461,7 +461,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_fremove(spiffs *fs, spiffs_file fh) {
return 0; return 0;
} }
static s32_t ICACHE_FLASH_ATTR spiffs_stat_pix(spiffs *fs, spiffs_page_ix pix, spiffs_file fh, spiffs_stat *s) { static s32_t spiffs_stat_pix(spiffs *fs, spiffs_page_ix pix, spiffs_file fh, spiffs_stat *s) {
spiffs_page_object_ix_header objix_hdr; spiffs_page_object_ix_header objix_hdr;
spiffs_obj_id obj_id; spiffs_obj_id obj_id;
s32_t res =_spiffs_rd(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ, fh, s32_t res =_spiffs_rd(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ, fh,
...@@ -482,7 +482,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_stat_pix(spiffs *fs, spiffs_page_ix pix, s ...@@ -482,7 +482,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_stat_pix(spiffs *fs, spiffs_page_ix pix, s
return res; return res;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_stat(spiffs *fs, const char *path, spiffs_stat *s) { s32_t SPIFFS_stat(spiffs *fs, const char *path, spiffs_stat *s) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -499,7 +499,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_stat(spiffs *fs, const char *path, spiffs_stat *s ...@@ -499,7 +499,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_stat(spiffs *fs, const char *path, spiffs_stat *s
return res; return res;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_fstat(spiffs *fs, spiffs_file fh, spiffs_stat *s) { s32_t SPIFFS_fstat(spiffs *fs, spiffs_file fh, spiffs_stat *s) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -522,7 +522,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_fstat(spiffs *fs, spiffs_file fh, spiffs_stat *s) ...@@ -522,7 +522,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_fstat(spiffs *fs, spiffs_file fh, spiffs_stat *s)
// Checks if there are any cached writes for the object id associated with // Checks if there are any cached writes for the object id associated with
// given filehandle. If so, these writes are flushed. // given filehandle. If so, these writes are flushed.
static s32_t ICACHE_FLASH_ATTR spiffs_fflush_cache(spiffs *fs, spiffs_file fh) { static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
#if SPIFFS_CACHE_WR #if SPIFFS_CACHE_WR
...@@ -552,7 +552,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_fflush_cache(spiffs *fs, spiffs_file fh) { ...@@ -552,7 +552,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_fflush_cache(spiffs *fs, spiffs_file fh) {
return res; return res;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_fflush(spiffs *fs, spiffs_file fh) { s32_t SPIFFS_fflush(spiffs *fs, spiffs_file fh) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
#if SPIFFS_CACHE_WR #if SPIFFS_CACHE_WR
...@@ -565,7 +565,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_fflush(spiffs *fs, spiffs_file fh) { ...@@ -565,7 +565,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_fflush(spiffs *fs, spiffs_file fh) {
return res; return res;
} }
void ICACHE_FLASH_ATTR SPIFFS_close(spiffs *fs, spiffs_file fh) { void SPIFFS_close(spiffs *fs, spiffs_file fh) {
if (!SPIFFS_CHECK_MOUNT(fs)) { if (!SPIFFS_CHECK_MOUNT(fs)) {
fs->errno = SPIFFS_ERR_NOT_MOUNTED; fs->errno = SPIFFS_ERR_NOT_MOUNTED;
return; return;
...@@ -580,7 +580,7 @@ void ICACHE_FLASH_ATTR SPIFFS_close(spiffs *fs, spiffs_file fh) { ...@@ -580,7 +580,7 @@ void ICACHE_FLASH_ATTR SPIFFS_close(spiffs *fs, spiffs_file fh) {
SPIFFS_UNLOCK(fs); SPIFFS_UNLOCK(fs);
} }
spiffs_DIR *ICACHE_FLASH_ATTR SPIFFS_opendir(spiffs *fs, const char *name, spiffs_DIR *d) { spiffs_DIR *SPIFFS_opendir(spiffs *fs, const char *name, spiffs_DIR *d) {
if (!SPIFFS_CHECK_MOUNT(fs)) { if (!SPIFFS_CHECK_MOUNT(fs)) {
fs->errno = SPIFFS_ERR_NOT_MOUNTED; fs->errno = SPIFFS_ERR_NOT_MOUNTED;
return 0; return 0;
...@@ -591,7 +591,7 @@ spiffs_DIR *ICACHE_FLASH_ATTR SPIFFS_opendir(spiffs *fs, const char *name, spiff ...@@ -591,7 +591,7 @@ spiffs_DIR *ICACHE_FLASH_ATTR SPIFFS_opendir(spiffs *fs, const char *name, spiff
return d; return d;
} }
static s32_t ICACHE_FLASH_ATTR spiffs_read_dir_v( static s32_t spiffs_read_dir_v(
spiffs *fs, spiffs *fs,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
spiffs_block_ix bix, spiffs_block_ix bix,
...@@ -624,7 +624,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_read_dir_v( ...@@ -624,7 +624,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_read_dir_v(
return SPIFFS_VIS_COUNTINUE; return SPIFFS_VIS_COUNTINUE;
} }
struct spiffs_dirent *ICACHE_FLASH_ATTR SPIFFS_readdir(spiffs_DIR *d, struct spiffs_dirent *e) { struct spiffs_dirent *SPIFFS_readdir(spiffs_DIR *d, struct spiffs_dirent *e) {
if (!SPIFFS_CHECK_MOUNT(d->fs)) { if (!SPIFFS_CHECK_MOUNT(d->fs)) {
d->fs->errno = SPIFFS_ERR_NOT_MOUNTED; d->fs->errno = SPIFFS_ERR_NOT_MOUNTED;
return 0; return 0;
...@@ -657,12 +657,12 @@ struct spiffs_dirent *ICACHE_FLASH_ATTR SPIFFS_readdir(spiffs_DIR *d, struct spi ...@@ -657,12 +657,12 @@ struct spiffs_dirent *ICACHE_FLASH_ATTR SPIFFS_readdir(spiffs_DIR *d, struct spi
return ret; return ret;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_closedir(spiffs_DIR *d) { s32_t SPIFFS_closedir(spiffs_DIR *d) {
SPIFFS_API_CHECK_MOUNT(d->fs); SPIFFS_API_CHECK_MOUNT(d->fs);
return 0; return 0;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_check(spiffs *fs) { s32_t SPIFFS_check(spiffs *fs) {
s32_t res; s32_t res;
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -679,7 +679,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_check(spiffs *fs) { ...@@ -679,7 +679,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_check(spiffs *fs) {
return res; return res;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_eof(spiffs *fs, spiffs_file fh) { s32_t SPIFFS_eof(spiffs *fs, spiffs_file fh) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -698,7 +698,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_eof(spiffs *fs, spiffs_file fh) { ...@@ -698,7 +698,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_eof(spiffs *fs, spiffs_file fh) {
return res; return res;
} }
s32_t ICACHE_FLASH_ATTR SPIFFS_tell(spiffs *fs, spiffs_file fh) { s32_t SPIFFS_tell(spiffs *fs, spiffs_file fh) {
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
...@@ -718,7 +718,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_tell(spiffs *fs, spiffs_file fh) { ...@@ -718,7 +718,7 @@ s32_t ICACHE_FLASH_ATTR SPIFFS_tell(spiffs *fs, spiffs_file fh) {
} }
#if SPIFFS_TEST_VISUALISATION #if SPIFFS_TEST_VISUALISATION
s32_t ICACHE_FLASH_ATTR SPIFFS_vis(spiffs *fs) { s32_t SPIFFS_vis(spiffs *fs) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
SPIFFS_API_CHECK_MOUNT(fs); SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs); SPIFFS_LOCK(fs);
......
#include "spiffs.h" #include "spiffs.h"
#include "spiffs_nucleus.h" #include "spiffs_nucleus.h"
static s32_t ICACHE_FLASH_ATTR spiffs_page_data_check(spiffs *fs, spiffs_fd *fd, spiffs_page_ix pix, spiffs_span_ix spix) { static s32_t spiffs_page_data_check(spiffs *fs, spiffs_fd *fd, spiffs_page_ix pix, spiffs_span_ix spix) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
if (pix == (spiffs_page_ix)-1) { if (pix == (spiffs_page_ix)-1) {
// referring to page 0xffff...., bad object index // referring to page 0xffff...., bad object index
...@@ -29,7 +29,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_page_data_check(spiffs *fs, spiffs_fd *fd, ...@@ -29,7 +29,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_page_data_check(spiffs *fs, spiffs_fd *fd,
return res; return res;
} }
static s32_t ICACHE_FLASH_ATTR spiffs_page_index_check(spiffs *fs, spiffs_fd *fd, spiffs_page_ix pix, spiffs_span_ix spix) { static s32_t spiffs_page_index_check(spiffs *fs, spiffs_fd *fd, spiffs_page_ix pix, spiffs_span_ix spix) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
if (pix == (spiffs_page_ix)-1) { if (pix == (spiffs_page_ix)-1) {
// referring to page 0xffff...., bad object index // referring to page 0xffff...., bad object index
...@@ -59,7 +59,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_page_index_check(spiffs *fs, spiffs_fd *fd ...@@ -59,7 +59,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_page_index_check(spiffs *fs, spiffs_fd *fd
#if !SPIFFS_CACHE #if !SPIFFS_CACHE
s32_t ICACHE_FLASH_ATTR spiffs_phys_rd( s32_t spiffs_phys_rd(
spiffs *fs, spiffs *fs,
u32_t addr, u32_t addr,
u32_t len, u32_t len,
...@@ -67,7 +67,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_rd( ...@@ -67,7 +67,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_rd(
return fs->cfg.hal_read_f(addr, len, dst); return fs->cfg.hal_read_f(addr, len, dst);
} }
s32_t ICACHE_FLASH_ATTR spiffs_phys_wr( s32_t spiffs_phys_wr(
spiffs *fs, spiffs *fs,
u32_t addr, u32_t addr,
u32_t len, u32_t len,
...@@ -77,7 +77,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_wr( ...@@ -77,7 +77,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_wr(
#endif #endif
s32_t ICACHE_FLASH_ATTR spiffs_phys_cpy( s32_t spiffs_phys_cpy(
spiffs *fs, spiffs *fs,
spiffs_file fh, spiffs_file fh,
u32_t dst, u32_t dst,
...@@ -116,7 +116,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_cpy( ...@@ -116,7 +116,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_phys_cpy(
// @param user_p any pointer, passed to the callback visitor function // @param user_p any pointer, passed to the callback visitor function
// @param block_ix reported block index where match was found // @param block_ix reported block index where match was found
// @param lu_entry reported look up index where match was found // @param lu_entry reported look up index where match was found
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_entry_visitor( s32_t spiffs_obj_lu_find_entry_visitor(
spiffs *fs, spiffs *fs,
spiffs_block_ix starting_block, spiffs_block_ix starting_block,
int starting_lu_entry, int starting_lu_entry,
...@@ -214,7 +214,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_entry_visitor( ...@@ -214,7 +214,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_entry_visitor(
} }
static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_scan_v( static s32_t spiffs_obj_lu_scan_v(
spiffs *fs, spiffs *fs,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
spiffs_block_ix bix, spiffs_block_ix bix,
...@@ -237,7 +237,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_scan_v( ...@@ -237,7 +237,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_scan_v(
// Scans thru all obj lu and counts free, deleted and used pages // Scans thru all obj lu and counts free, deleted and used pages
// Find the maximum block erase count // Find the maximum block erase count
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_scan( s32_t spiffs_obj_lu_scan(
spiffs *fs) { spiffs *fs) {
s32_t res; s32_t res;
spiffs_block_ix bix; spiffs_block_ix bix;
...@@ -299,7 +299,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_scan( ...@@ -299,7 +299,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_scan(
// Find free object lookup entry // Find free object lookup entry
// Iterate over object lookup pages in each block until a free object id entry is found // Iterate over object lookup pages in each block until a free object id entry is found
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free( s32_t spiffs_obj_lu_find_free(
spiffs *fs, spiffs *fs,
spiffs_block_ix starting_block, spiffs_block_ix starting_block,
int starting_lu_entry, int starting_lu_entry,
...@@ -331,7 +331,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free( ...@@ -331,7 +331,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free(
// Find object lookup entry containing given id // Find object lookup entry containing given id
// Iterate over object lookup pages in each block until a given object id entry is found // Iterate over object lookup pages in each block until a given object id entry is found
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id( s32_t spiffs_obj_lu_find_id(
spiffs *fs, spiffs *fs,
spiffs_block_ix starting_block, spiffs_block_ix starting_block,
int starting_lu_entry, int starting_lu_entry,
...@@ -347,7 +347,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id( ...@@ -347,7 +347,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id(
} }
static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span_v( static s32_t spiffs_obj_lu_find_id_and_span_v(
spiffs *fs, spiffs *fs,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
spiffs_block_ix bix, spiffs_block_ix bix,
...@@ -373,7 +373,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span_v( ...@@ -373,7 +373,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span_v(
// Find object lookup entry containing given id and span index // 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 // Iterate over object lookup pages in each block until a given object id entry is found
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span( s32_t spiffs_obj_lu_find_id_and_span(
spiffs *fs, spiffs *fs,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
spiffs_span_ix spix, spiffs_span_ix spix,
...@@ -412,7 +412,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span( ...@@ -412,7 +412,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span(
// Find object lookup entry containing given id and span index in page headers only // 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 // Iterate over object lookup pages in each block until a given object id entry is found
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span_by_phdr( s32_t spiffs_obj_lu_find_id_and_span_by_phdr(
spiffs *fs, spiffs *fs,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
spiffs_span_ix spix, spiffs_span_ix spix,
...@@ -452,7 +452,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span_by_phdr( ...@@ -452,7 +452,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_id_and_span_by_phdr(
// Allocates a free defined page with given obj_id // Allocates a free defined page with given obj_id
// Occupies object lookup entry and page // Occupies object lookup entry and page
// data may be NULL; where only page header is stored, len and page_offs is ignored // data may be NULL; where only page header is stored, len and page_offs is ignored
s32_t ICACHE_FLASH_ATTR spiffs_page_allocate_data( s32_t spiffs_page_allocate_data(
spiffs *fs, spiffs *fs,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
spiffs_page_header *ph, spiffs_page_header *ph,
...@@ -509,7 +509,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_allocate_data( ...@@ -509,7 +509,7 @@ s32_t ICACHE_FLASH_ATTR 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. // 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. // If page data is null, provided header is used for metainfo and page data is physically copied.
s32_t ICACHE_FLASH_ATTR spiffs_page_move( s32_t spiffs_page_move(
spiffs *fs, spiffs *fs,
spiffs_file fh, spiffs_file fh,
u8_t *page_data, u8_t *page_data,
...@@ -571,7 +571,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_move( ...@@ -571,7 +571,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_move(
} }
// Deletes a page and removes it from object lookup. // Deletes a page and removes it from object lookup.
s32_t ICACHE_FLASH_ATTR spiffs_page_delete( s32_t spiffs_page_delete(
spiffs *fs, spiffs *fs,
spiffs_page_ix pix) { spiffs_page_ix pix) {
s32_t res; s32_t res;
...@@ -600,7 +600,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_delete( ...@@ -600,7 +600,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_page_delete(
} }
// Create an object index header page with empty index and undefined length // Create an object index header page with empty index and undefined length
s32_t ICACHE_FLASH_ATTR spiffs_object_create( s32_t spiffs_object_create(
spiffs *fs, spiffs *fs,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
u8_t name[SPIFFS_OBJ_NAME_LEN], u8_t name[SPIFFS_OBJ_NAME_LEN],
...@@ -655,7 +655,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_create( ...@@ -655,7 +655,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_create(
// new_objix_hdr_data may be null, if so the object index header page is loaded // 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 // name may be null, if so name is not changed
// size may be null, if so size is not changed // size may be null, if so size is not changed
s32_t ICACHE_FLASH_ATTR spiffs_object_update_index_hdr( s32_t spiffs_object_update_index_hdr(
spiffs *fs, spiffs *fs,
spiffs_fd *fd, spiffs_fd *fd,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
...@@ -706,7 +706,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_update_index_hdr( ...@@ -706,7 +706,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_update_index_hdr(
return res; return res;
} }
void ICACHE_FLASH_ATTR spiffs_cb_object_event( void spiffs_cb_object_event(
spiffs *fs, spiffs *fs,
spiffs_fd *fd, spiffs_fd *fd,
int ev, int ev,
...@@ -745,7 +745,7 @@ void ICACHE_FLASH_ATTR spiffs_cb_object_event( ...@@ -745,7 +745,7 @@ void ICACHE_FLASH_ATTR spiffs_cb_object_event(
} }
// Open object by id // Open object by id
s32_t ICACHE_FLASH_ATTR spiffs_object_open_by_id( s32_t spiffs_object_open_by_id(
spiffs *fs, spiffs *fs,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
spiffs_fd *fd, spiffs_fd *fd,
...@@ -763,7 +763,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_open_by_id( ...@@ -763,7 +763,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_open_by_id(
} }
// Open object by page index // Open object by page index
s32_t ICACHE_FLASH_ATTR spiffs_object_open_by_page( s32_t spiffs_object_open_by_page(
spiffs *fs, spiffs *fs,
spiffs_page_ix pix, spiffs_page_ix pix,
spiffs_fd *fd, spiffs_fd *fd,
...@@ -801,7 +801,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_open_by_page( ...@@ -801,7 +801,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_open_by_page(
// Append to object // Append to object
// keep current object index (header) page in fs->work buffer // keep current object index (header) page in fs->work buffer
s32_t ICACHE_FLASH_ATTR spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) { s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) {
spiffs *fs = fd->fs; spiffs *fs = fd->fs;
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
u32_t written = 0; u32_t written = 0;
...@@ -1032,7 +1032,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t * ...@@ -1032,7 +1032,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *
// Modify object // Modify object
// keep current object index (header) page in fs->work buffer // keep current object index (header) page in fs->work buffer
s32_t ICACHE_FLASH_ATTR spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) { s32_t spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) {
spiffs *fs = fd->fs; spiffs *fs = fd->fs;
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
u32_t written = 0; u32_t written = 0;
...@@ -1231,7 +1231,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t * ...@@ -1231,7 +1231,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *
return res; return res;
} }
static s32_t ICACHE_FLASH_ATTR spiffs_object_find_object_index_header_by_name_v( static s32_t spiffs_object_find_object_index_header_by_name_v(
spiffs *fs, spiffs *fs,
spiffs_obj_id obj_id, spiffs_obj_id obj_id,
spiffs_block_ix bix, spiffs_block_ix bix,
...@@ -1260,7 +1260,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_object_find_object_index_header_by_name_v( ...@@ -1260,7 +1260,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_object_find_object_index_header_by_name_v(
} }
// Finds object index header page by name // Finds object index header page by name
s32_t ICACHE_FLASH_ATTR spiffs_object_find_object_index_header_by_name( s32_t spiffs_object_find_object_index_header_by_name(
spiffs *fs, spiffs *fs,
u8_t name[SPIFFS_OBJ_NAME_LEN], u8_t name[SPIFFS_OBJ_NAME_LEN],
spiffs_page_ix *pix) { spiffs_page_ix *pix) {
...@@ -1295,7 +1295,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_find_object_index_header_by_name( ...@@ -1295,7 +1295,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_find_object_index_header_by_name(
} }
// Truncates object to new size. If new size is null, object may be removed totally // Truncates object to new size. If new size is null, object may be removed totally
s32_t ICACHE_FLASH_ATTR spiffs_object_truncate( s32_t spiffs_object_truncate(
spiffs_fd *fd, spiffs_fd *fd,
u32_t new_size, u32_t new_size,
u8_t remove) { u8_t remove) {
...@@ -1502,7 +1502,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_truncate( ...@@ -1502,7 +1502,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_object_truncate(
return res; return res;
} }
s32_t ICACHE_FLASH_ATTR spiffs_object_read( s32_t spiffs_object_read(
spiffs_fd *fd, spiffs_fd *fd,
u32_t offset, u32_t offset,
u32_t len, u32_t len,
...@@ -1586,7 +1586,7 @@ typedef struct { ...@@ -1586,7 +1586,7 @@ typedef struct {
u32_t compaction; u32_t compaction;
} spiffs_free_obj_id_state; } spiffs_free_obj_id_state;
static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id_bitmap_v(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry, static s32_t spiffs_obj_lu_find_free_obj_id_bitmap_v(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry,
u32_t user_data, void *user_p) { u32_t user_data, void *user_p) {
if (id != SPIFFS_OBJ_ID_FREE && id != SPIFFS_OBJ_ID_DELETED) { if (id != SPIFFS_OBJ_ID_FREE && id != SPIFFS_OBJ_ID_DELETED) {
spiffs_obj_id min_obj_id = user_data; spiffs_obj_id min_obj_id = user_data;
...@@ -1600,7 +1600,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id_bitmap_v(spiffs *f ...@@ -1600,7 +1600,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id_bitmap_v(spiffs *f
return SPIFFS_VIS_COUNTINUE; return SPIFFS_VIS_COUNTINUE;
} }
static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id_compact_v(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry, static s32_t spiffs_obj_lu_find_free_obj_id_compact_v(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry,
u32_t user_data, void *user_p) { u32_t user_data, void *user_p) {
if (id != SPIFFS_OBJ_ID_FREE && id != SPIFFS_OBJ_ID_DELETED && (id & SPIFFS_OBJ_ID_IX_FLAG)) { if (id != SPIFFS_OBJ_ID_FREE && id != SPIFFS_OBJ_ID_DELETED && (id & SPIFFS_OBJ_ID_IX_FLAG)) {
s32_t res; s32_t res;
...@@ -1629,7 +1629,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id_compact_v(spiffs * ...@@ -1629,7 +1629,7 @@ static s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id_compact_v(spiffs *
// object ids cannot fit into a work buffer, these are grouped. When a group containing free // 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. // object ids is found, the object lu is again scanned for object ids within group and bitmasked.
// Finally, the bitmasked is searched for a free id // Finally, the bitmasked is searched for a free id
s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id) { s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id) {
s32_t res = SPIFFS_OK; s32_t res = SPIFFS_OK;
u32_t max_objects = (SPIFFS_CFG_PHYS_SZ(fs) / (u32_t)SPIFFS_CFG_LOG_PAGE_SZ(fs)) / 2; u32_t max_objects = (SPIFFS_CFG_PHYS_SZ(fs) / (u32_t)SPIFFS_CFG_LOG_PAGE_SZ(fs)) / 2;
spiffs_free_obj_id_state state; spiffs_free_obj_id_state state;
...@@ -1720,7 +1720,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id ...@@ -1720,7 +1720,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id
return res; return res;
} }
s32_t ICACHE_FLASH_ATTR spiffs_fd_find_new(spiffs *fs, spiffs_fd **fd) { s32_t spiffs_fd_find_new(spiffs *fs, spiffs_fd **fd) {
int i; int i;
spiffs_fd *fds = (spiffs_fd *)fs->fd_space; spiffs_fd *fds = (spiffs_fd *)fs->fd_space;
for (i = 0; i < fs->fd_count; i++) { for (i = 0; i < fs->fd_count; i++) {
...@@ -1734,7 +1734,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_fd_find_new(spiffs *fs, spiffs_fd **fd) { ...@@ -1734,7 +1734,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_fd_find_new(spiffs *fs, spiffs_fd **fd) {
return SPIFFS_ERR_OUT_OF_FILE_DESCS; return SPIFFS_ERR_OUT_OF_FILE_DESCS;
} }
s32_t ICACHE_FLASH_ATTR spiffs_fd_return(spiffs *fs, spiffs_file f) { s32_t spiffs_fd_return(spiffs *fs, spiffs_file f) {
if (f <= 0 || f > fs->fd_count) { if (f <= 0 || f > fs->fd_count) {
return SPIFFS_ERR_BAD_DESCRIPTOR; return SPIFFS_ERR_BAD_DESCRIPTOR;
} }
...@@ -1747,7 +1747,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_fd_return(spiffs *fs, spiffs_file f) { ...@@ -1747,7 +1747,7 @@ s32_t ICACHE_FLASH_ATTR spiffs_fd_return(spiffs *fs, spiffs_file f) {
return SPIFFS_OK; return SPIFFS_OK;
} }
s32_t ICACHE_FLASH_ATTR spiffs_fd_get(spiffs *fs, spiffs_file f, spiffs_fd **fd) { s32_t spiffs_fd_get(spiffs *fs, spiffs_file f, spiffs_fd **fd) {
if (f <= 0 || f > fs->fd_count) { if (f <= 0 || f > fs->fd_count) {
return SPIFFS_ERR_BAD_DESCRIPTOR; return SPIFFS_ERR_BAD_DESCRIPTOR;
} }
......
...@@ -28,7 +28,7 @@ static int romfs_num_fd; ...@@ -28,7 +28,7 @@ static int romfs_num_fd;
// Length of the 'file size' field for both ROMFS/WOFS // Length of the 'file size' field for both ROMFS/WOFS
#define ROMFS_SIZE_LEN 4 #define ROMFS_SIZE_LEN 4
static int ICACHE_FLASH_ATTR romfs_find_empty_fd(void) static int romfs_find_empty_fd(void)
{ {
int i; int i;
...@@ -40,7 +40,7 @@ static int ICACHE_FLASH_ATTR romfs_find_empty_fd(void) ...@@ -40,7 +40,7 @@ static int ICACHE_FLASH_ATTR romfs_find_empty_fd(void)
return -1; return -1;
} }
static void ICACHE_FLASH_ATTR romfs_close_fd( int fd ) static void romfs_close_fd( int fd )
{ {
if(fd<0 || fd>=TOTAL_MAX_FDS) if(fd<0 || fd>=TOTAL_MAX_FDS)
return; return;
...@@ -49,7 +49,7 @@ static void ICACHE_FLASH_ATTR romfs_close_fd( int fd ) ...@@ -49,7 +49,7 @@ static void ICACHE_FLASH_ATTR romfs_close_fd( int fd )
} }
// Helper function: read a byte from the FS // Helper function: read a byte from the FS
static uint8_t ICACHE_FLASH_ATTR romfsh_read8( uint32_t addr, const FSDATA *pfs ) static uint8_t romfsh_read8( uint32_t addr, const FSDATA *pfs )
{ {
uint8_t temp; uint8_t temp;
if( pfs->flags & ROMFS_FS_FLAG_DIRECT ) if( pfs->flags & ROMFS_FS_FLAG_DIRECT )
...@@ -59,13 +59,13 @@ static uint8_t ICACHE_FLASH_ATTR romfsh_read8( uint32_t addr, const FSDATA *pfs ...@@ -59,13 +59,13 @@ static uint8_t ICACHE_FLASH_ATTR romfsh_read8( uint32_t addr, const FSDATA *pfs
} }
// Helper function: return 1 if PFS reffers to a WOFS, 0 otherwise // Helper function: return 1 if PFS reffers to a WOFS, 0 otherwise
static int ICACHE_FLASH_ATTR romfsh_is_wofs( const FSDATA* pfs ) static int romfsh_is_wofs( const FSDATA* pfs )
{ {
return ( pfs->flags & ROMFS_FS_FLAG_WO ) != 0; return ( pfs->flags & ROMFS_FS_FLAG_WO ) != 0;
} }
// Find the next file, returning FS_FILE_OK or FS_FILE_NOT_FOUND if there no file left. // Find the next file, returning FS_FILE_OK or FS_FILE_NOT_FOUND if there no file left.
static uint8_t ICACHE_FLASH_ATTR romfs_next_file( uint32_t *start, char* fname, size_t len, size_t *act_len, FSDATA *pfs ) static uint8_t romfs_next_file( uint32_t *start, char* fname, size_t len, size_t *act_len, FSDATA *pfs )
{ {
uint32_t i, j, n; uint32_t i, j, n;
uint32_t fsize; uint32_t fsize;
...@@ -120,7 +120,7 @@ static uint8_t ICACHE_FLASH_ATTR romfs_next_file( uint32_t *start, char* fname, ...@@ -120,7 +120,7 @@ static uint8_t ICACHE_FLASH_ATTR romfs_next_file( uint32_t *start, char* fname,
// Open the given file, returning one of FS_FILE_NOT_FOUND, FS_FILE_ALREADY_OPENED // Open the given file, returning one of FS_FILE_NOT_FOUND, FS_FILE_ALREADY_OPENED
// or FS_FILE_OK // or FS_FILE_OK
static uint8_t ICACHE_FLASH_ATTR romfs_open_file( const char* fname, FD* pfd, FSDATA *pfs, uint32_t *plast, uint32_t *pnameaddr ) static uint8_t romfs_open_file( const char* fname, FD* pfd, FSDATA *pfs, uint32_t *plast, uint32_t *pnameaddr )
{ {
uint32_t i, j, n; uint32_t i, j, n;
char fsname[ MAX_FNAME_LENGTH + 1 ]; char fsname[ MAX_FNAME_LENGTH + 1 ];
...@@ -184,7 +184,7 @@ static uint8_t ICACHE_FLASH_ATTR romfs_open_file( const char* fname, FD* pfd, FS ...@@ -184,7 +184,7 @@ static uint8_t ICACHE_FLASH_ATTR romfs_open_file( const char* fname, FD* pfd, FS
return FS_FILE_NOT_FOUND; return FS_FILE_NOT_FOUND;
} }
static int ICACHE_FLASH_ATTR romfs_open( const char *path, int flags, int mode, void *pdata ) static int romfs_open( const char *path, int flags, int mode, void *pdata )
{ {
FD tempfs; FD tempfs;
int i; int i;
...@@ -295,7 +295,7 @@ static int ICACHE_FLASH_ATTR romfs_open( const char *path, int flags, int mode, ...@@ -295,7 +295,7 @@ static int ICACHE_FLASH_ATTR romfs_open( const char *path, int flags, int mode,
return i; return i;
} }
static int ICACHE_FLASH_ATTR romfs_close( int fd, void *pdata ) static int romfs_close( int fd, void *pdata )
{ {
if(fd<0 || fd>=TOTAL_MAX_FDS) if(fd<0 || fd>=TOTAL_MAX_FDS)
return 0; return 0;
...@@ -320,7 +320,7 @@ static int ICACHE_FLASH_ATTR romfs_close( int fd, void *pdata ) ...@@ -320,7 +320,7 @@ static int ICACHE_FLASH_ATTR romfs_close( int fd, void *pdata )
return 0; return 0;
} }
static _ssize_t ICACHE_FLASH_ATTR romfs_write( int fd, const void* ptr, size_t len, void *pdata ) static _ssize_t romfs_write( int fd, const void* ptr, size_t len, void *pdata )
{ {
if(fd<0 || fd>=TOTAL_MAX_FDS) if(fd<0 || fd>=TOTAL_MAX_FDS)
return -1; return -1;
...@@ -350,7 +350,7 @@ static _ssize_t ICACHE_FLASH_ATTR romfs_write( int fd, const void* ptr, size_t l ...@@ -350,7 +350,7 @@ static _ssize_t ICACHE_FLASH_ATTR romfs_write( int fd, const void* ptr, size_t l
return len; return len;
} }
static _ssize_t ICACHE_FLASH_ATTR romfs_read( int fd, void* ptr, size_t len, void *pdata ) static _ssize_t romfs_read( int fd, void* ptr, size_t len, void *pdata )
{ {
if(fd<0 || fd>=TOTAL_MAX_FDS) if(fd<0 || fd>=TOTAL_MAX_FDS)
return -1; return -1;
...@@ -374,7 +374,7 @@ static _ssize_t ICACHE_FLASH_ATTR romfs_read( int fd, void* ptr, size_t len, voi ...@@ -374,7 +374,7 @@ static _ssize_t ICACHE_FLASH_ATTR romfs_read( int fd, void* ptr, size_t len, voi
} }
// lseek // lseek
static int ICACHE_FLASH_ATTR romfs_lseek( int fd, int off, int whence, void *pdata ) static int romfs_lseek( int fd, int off, int whence, void *pdata )
{ {
if(fd<0 || fd>=TOTAL_MAX_FDS) if(fd<0 || fd>=TOTAL_MAX_FDS)
return -1; return -1;
...@@ -409,7 +409,7 @@ static int ICACHE_FLASH_ATTR romfs_lseek( int fd, int off, int whence, void *pda ...@@ -409,7 +409,7 @@ static int ICACHE_FLASH_ATTR romfs_lseek( int fd, int off, int whence, void *pda
// WOFS functions and instance descriptor for real hardware // WOFS functions and instance descriptor for real hardware
#if defined( BUILD_WOFS ) #if defined( BUILD_WOFS )
static uint32_t ICACHE_FLASH_ATTR sim_wofs_write( const void *from, uint32_t toaddr, uint32_t size, const void *pdata ) static uint32_t sim_wofs_write( const void *from, uint32_t toaddr, uint32_t size, const void *pdata )
{ {
const FSDATA *pfsdata = ( const FSDATA* )pdata; const FSDATA *pfsdata = ( const FSDATA* )pdata;
if(toaddr>=INTERNAL_FLASH_SIZE) if(toaddr>=INTERNAL_FLASH_SIZE)
...@@ -421,7 +421,7 @@ static uint32_t ICACHE_FLASH_ATTR sim_wofs_write( const void *from, uint32_t toa ...@@ -421,7 +421,7 @@ static uint32_t ICACHE_FLASH_ATTR sim_wofs_write( const void *from, uint32_t toa
return platform_flash_write( from, toaddr, size ); return platform_flash_write( from, toaddr, size );
} }
static uint32_t ICACHE_FLASH_ATTR sim_wofs_read( void *to, uint32_t fromaddr, uint32_t size, const void *pdata ) static uint32_t sim_wofs_read( void *to, uint32_t fromaddr, uint32_t size, const void *pdata )
{ {
const FSDATA *pfsdata = ( const FSDATA* )pdata; const FSDATA *pfsdata = ( const FSDATA* )pdata;
if(fromaddr>=INTERNAL_FLASH_SIZE) if(fromaddr>=INTERNAL_FLASH_SIZE)
...@@ -445,7 +445,7 @@ static FSDATA wofs_fsdata = ...@@ -445,7 +445,7 @@ static FSDATA wofs_fsdata =
// WOFS formatting function // WOFS formatting function
// Returns 1 if OK, 0 for error // Returns 1 if OK, 0 for error
int ICACHE_FLASH_ATTR wofs_format( void ) int wofs_format( void )
{ {
uint32_t sect_first, sect_last; uint32_t sect_first, sect_last;
FD tempfd; FD tempfd;
...@@ -460,27 +460,27 @@ int ICACHE_FLASH_ATTR wofs_format( void ) ...@@ -460,27 +460,27 @@ int ICACHE_FLASH_ATTR wofs_format( void )
return 1; return 1;
} }
int ICACHE_FLASH_ATTR wofs_open(const char *_name, int flags){ int wofs_open(const char *_name, int flags){
return romfs_open( _name, flags, 0, &wofs_fsdata ); return romfs_open( _name, flags, 0, &wofs_fsdata );
} }
int ICACHE_FLASH_ATTR wofs_close( int fd ){ int wofs_close( int fd ){
return romfs_close( fd, &wofs_fsdata ); return romfs_close( fd, &wofs_fsdata );
} }
size_t ICACHE_FLASH_ATTR wofs_write( int fd, const void* ptr, size_t len ){ size_t wofs_write( int fd, const void* ptr, size_t len ){
return romfs_write( fd, ptr, len, &wofs_fsdata ); return romfs_write( fd, ptr, len, &wofs_fsdata );
} }
size_t ICACHE_FLASH_ATTR wofs_read( int fd, void* ptr, size_t len){ size_t wofs_read( int fd, void* ptr, size_t len){
return romfs_read( fd, ptr, len, &wofs_fsdata ); return romfs_read( fd, ptr, len, &wofs_fsdata );
} }
int ICACHE_FLASH_ATTR wofs_lseek( int fd, int off, int whence ){ int wofs_lseek( int fd, int off, int whence ){
return romfs_lseek( fd, off, whence, &wofs_fsdata ); return romfs_lseek( fd, off, whence, &wofs_fsdata );
} }
int ICACHE_FLASH_ATTR wofs_eof( int fd ){ int wofs_eof( int fd ){
if(fd<0 || fd>=TOTAL_MAX_FDS) if(fd<0 || fd>=TOTAL_MAX_FDS)
return -1; return -1;
FD* pfd = fd_table + fd; FD* pfd = fd_table + fd;
...@@ -488,7 +488,7 @@ int ICACHE_FLASH_ATTR wofs_eof( int fd ){ ...@@ -488,7 +488,7 @@ int ICACHE_FLASH_ATTR wofs_eof( int fd ){
return pfd->offset == pfd->size; return pfd->offset == pfd->size;
} }
int ICACHE_FLASH_ATTR wofs_getc( int fd ){ int wofs_getc( int fd ){
char c = EOF; char c = EOF;
if(!wofs_eof(fd)){ if(!wofs_eof(fd)){
romfs_read( fd, &c, 1, &wofs_fsdata ); romfs_read( fd, &c, 1, &wofs_fsdata );
...@@ -497,19 +497,19 @@ int ICACHE_FLASH_ATTR wofs_getc( int fd ){ ...@@ -497,19 +497,19 @@ int ICACHE_FLASH_ATTR wofs_getc( int fd ){
return (int)c; return (int)c;
} }
int ICACHE_FLASH_ATTR wofs_ungetc( int c, int fd ){ int wofs_ungetc( int c, int fd ){
return romfs_lseek( fd, -1, SEEK_CUR, &wofs_fsdata ); return romfs_lseek( fd, -1, SEEK_CUR, &wofs_fsdata );
} }
// Find the next file, returning FS_FILE_OK or FS_FILE_NOT_FOUND if there no file left. // Find the next file, returning FS_FILE_OK or FS_FILE_NOT_FOUND if there no file left.
uint8_t ICACHE_FLASH_ATTR wofs_next( uint32_t *start, char* fname, size_t len, size_t *act_len ){ uint8_t wofs_next( uint32_t *start, char* fname, size_t len, size_t *act_len ){
return romfs_next_file( start, fname, len, act_len, &wofs_fsdata ); return romfs_next_file( start, fname, len, act_len, &wofs_fsdata );
} }
#endif // #ifdef BUILD_WOFS #endif // #ifdef BUILD_WOFS
// Initialize both ROMFS and WOFS as needed // Initialize both ROMFS and WOFS as needed
int ICACHE_FLASH_ATTR romfs_init( void ) int romfs_init( void )
{ {
unsigned i; unsigned i;
...@@ -529,13 +529,13 @@ int ICACHE_FLASH_ATTR romfs_init( void ) ...@@ -529,13 +529,13 @@ int ICACHE_FLASH_ATTR romfs_init( void )
#else // #if defined( BUILD_ROMFS ) || defined( BUILD_WOFS ) #else // #if defined( BUILD_ROMFS ) || defined( BUILD_WOFS )
int ICACHE_FLASH_ATTR romfs_init( void ) int romfs_init( void )
{ {
} }
#endif // #if defined( BUILD_ROMFS ) || defined( BUILD_WOFS ) #endif // #if defined( BUILD_ROMFS ) || defined( BUILD_WOFS )
int ICACHE_FLASH_ATTR test_romfs() int test_romfs()
{ {
int fd; int fd;
int i, size; int i, size;
......
...@@ -24,6 +24,8 @@ typedef struct{ ...@@ -24,6 +24,8 @@ typedef struct{
#define SPI_FLASH_SEC_SIZE 4096 #define SPI_FLASH_SEC_SIZE 4096
uint32 spi_flash_get_id(void); uint32 spi_flash_get_id(void);
SpiFlashOpResult spi_flash_read_status(uint32 *status);
SpiFlashOpResult spi_flash_write_status(uint32 status_value);
SpiFlashOpResult spi_flash_erase_sector(uint16 sec); SpiFlashOpResult spi_flash_erase_sector(uint16 sec);
SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size); SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size); SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);
......
...@@ -151,9 +151,9 @@ enum { ...@@ -151,9 +151,9 @@ enum {
STATION_GOT_IP STATION_GOT_IP
}; };
enum dhcp_status{ enum dhcp_status {
DHCP_ENABLE, DHCP_STOPPED,
DHCP_DISABLE DHCP_STARTED
}; };
uint8 wifi_station_get_connect_status(void); uint8 wifi_station_get_connect_status(void);
...@@ -201,7 +201,7 @@ struct dhcps_lease { ...@@ -201,7 +201,7 @@ struct dhcps_lease {
struct station_info * wifi_softap_get_station_info(void); struct station_info * wifi_softap_get_station_info(void);
void wifi_softap_free_station_info(void); void wifi_softap_free_station_info(void);
bool wifi_station_get_ap_info(struct station_config config[]); uint8 wifi_station_get_ap_info(struct station_config config[]);
bool wifi_softap_dhcps_start(void); bool wifi_softap_dhcps_start(void);
bool wifi_softap_dhcps_stop(void); bool wifi_softap_dhcps_stop(void);
......
...@@ -66,6 +66,40 @@ SECTIONS ...@@ -66,6 +66,40 @@ SECTIONS
_dport0_data_end = ABSOLUTE(.); _dport0_data_end = ABSOLUTE(.);
} >dport0_0_seg :dport0_0_phdr } >dport0_0_seg :dport0_0_phdr
.irom0.text : ALIGN(4)
{
_irom0_text_start = ABSOLUTE(.);
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
*(.literal.* .text.*)
_irom0_text_end = ABSOLUTE(.);
_flash_used_end = ABSOLUTE(.);
} >irom0_0_seg :irom0_0_phdr
.text : ALIGN(4)
{
_stext = .;
_text_start = ABSOLUTE(.);
*(.entry.text)
*(.init.literal)
*(.init)
/* *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) */
*(.literal .text .iram0.text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
*(.fini.literal)
*(.fini)
*(.gnu.version)
_text_end = ABSOLUTE(.);
_etext = .;
} >iram1_0_seg :iram1_0_phdr
.lit4 : ALIGN(4)
{
_lit4_start = ABSOLUTE(.);
*(*.lit4)
*(.lit4.*)
*(.gnu.linkonce.lit4.*)
_lit4_end = ABSOLUTE(.);
} >iram1_0_seg :iram1_0_phdr
.data : ALIGN(4) .data : ALIGN(4)
{ {
_data_start = ABSOLUTE(.); _data_start = ABSOLUTE(.);
...@@ -145,40 +179,6 @@ SECTIONS ...@@ -145,40 +179,6 @@ SECTIONS
} >dram0_0_seg :dram0_0_bss_phdr } >dram0_0_seg :dram0_0_bss_phdr
/* __stack = 0x3ffc8000; */ /* __stack = 0x3ffc8000; */
.text : ALIGN(4)
{
_stext = .;
_text_start = ABSOLUTE(.);
*(.entry.text)
*(.init.literal)
*(.init)
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
*(.fini.literal)
*(.fini)
*(.gnu.version)
_text_end = ABSOLUTE(.);
_etext = .;
} >iram1_0_seg :iram1_0_phdr
.lit4 : ALIGN(4)
{
_lit4_start = ABSOLUTE(.);
*(*.lit4)
*(.lit4.*)
*(.gnu.linkonce.lit4.*)
_lit4_end = ABSOLUTE(.);
} >iram1_0_seg :iram1_0_phdr
.irom0.text : ALIGN(4)
{
_crypt_fixed_start = ABSOLUTE(.);
*(.crypt_fixed)
_crypt_fixed_end = ABSOLUTE(.);
_irom0_text_start = ABSOLUTE(.);
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
_irom0_text_end = ABSOLUTE(.);
_flash_used_end = ABSOLUTE(.);
} >irom0_0_seg :irom0_0_phdr
} }
/* get ROM code address */ /* get ROM code address */
......
...@@ -16,6 +16,8 @@ PROVIDE ( SHA1Final = 0x4000b648 ); ...@@ -16,6 +16,8 @@ PROVIDE ( SHA1Final = 0x4000b648 );
PROVIDE ( SHA1Init = 0x4000b584 ); PROVIDE ( SHA1Init = 0x4000b584 );
PROVIDE ( SHA1Transform = 0x4000a364 ); PROVIDE ( SHA1Transform = 0x4000a364 );
PROVIDE ( SHA1Update = 0x4000b5a8 ); PROVIDE ( SHA1Update = 0x4000b5a8 );
PROVIDE ( SPI_read_status = 0x400043c8 );
PROVIDE ( SPI_write_status = 0x40004400 );
PROVIDE ( Wait_SPI_Idle = 0x4000448c ); PROVIDE ( Wait_SPI_Idle = 0x4000448c );
PROVIDE ( SPIEraseArea = 0x40004b44 ); PROVIDE ( SPIEraseArea = 0x40004b44 );
PROVIDE ( SPIEraseBlock = 0x400049b4 ); PROVIDE ( SPIEraseBlock = 0x400049b4 );
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment