Lines Matching refs:fcb
15 fcb_new_sector(struct fcb *fcb, int cnt) in fcb_new_sector() argument
23 cur = fcb->f_active.fe_sector; in fcb_new_sector()
25 cur = fcb_getnext_sector(fcb, cur); in fcb_new_sector()
29 if (cur == fcb->f_oldest) { in fcb_new_sector()
40 fcb_append_to_scratch(struct fcb *fcb) in fcb_append_to_scratch() argument
45 sector = fcb_new_sector(fcb, 0); in fcb_append_to_scratch()
49 rc = fcb_sector_hdr_init(fcb, sector, fcb->f_active_id + 1); in fcb_append_to_scratch()
53 fcb->f_active.fe_sector = sector; in fcb_append_to_scratch()
54 fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)); in fcb_append_to_scratch()
55 fcb->f_active_id++; in fcb_append_to_scratch()
60 fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *append_loc) in fcb_append() argument
66 uint8_t tmp_str[MAX(8, fcb->f_align)]; in fcb_append()
69 memset(tmp_str, fcb->f_erase_value, sizeof(tmp_str)); in fcb_append()
71 cnt = fcb_put_len(fcb, tmp_str, len); in fcb_append()
75 cnt = fcb_len_in_flash(fcb, cnt); in fcb_append()
76 len = fcb_len_in_flash(fcb, len) + fcb_len_in_flash(fcb, FCB_CRC_SZ); in fcb_append()
80 rc = k_mutex_lock(&fcb->f_mtx, K_FOREVER); in fcb_append()
84 active = &fcb->f_active; in fcb_append()
86 sector = fcb_new_sector(fcb, fcb->f_scratch_cnt); in fcb_append()
88 fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)) + len + cnt)) { in fcb_append()
92 rc = fcb_sector_hdr_init(fcb, sector, fcb->f_active_id + 1); in fcb_append()
96 fcb->f_active.fe_sector = sector; in fcb_append()
97 fcb->f_active.fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area)); in fcb_append()
98 fcb->f_active_id++; in fcb_append()
101 rc = fcb_flash_write(fcb, active->fe_sector, active->fe_elem_off, tmp_str, cnt); in fcb_append()
112 k_mutex_unlock(&fcb->f_mtx); in fcb_append()
116 k_mutex_unlock(&fcb->f_mtx); in fcb_append()
121 fcb_append_finish(struct fcb *fcb, struct fcb_entry *loc) in fcb_append_finish() argument
124 uint8_t em[fcb->f_align]; in fcb_append_finish()
129 rc = fcb_elem_endmarker(fcb, loc, &em[0]); in fcb_append_finish()
133 off = loc->fe_data_off + fcb_len_in_flash(fcb, loc->fe_data_len); in fcb_append_finish()
135 rc = fcb_flash_write(fcb, loc->fe_sector, off, em, fcb->f_align); in fcb_append_finish()