Zephyr Project API  3.2.0
A Scalable Open Source RTOS
fcb.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017-2020 Nordic Semiconductor ASA
3 * Copyright (c) 2015 Runtime Inc
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7#ifndef ZEPHYR_INCLUDE_FS_FCB_H_
8#define ZEPHYR_INCLUDE_FS_FCB_H_
9
10/*
11 * Flash circular buffer.
12 */
13#include <inttypes.h>
14#include <limits.h>
15
17
18#include <zephyr/kernel.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
37#define FCB_MAX_LEN (CHAR_MAX | CHAR_MAX << 7)
48struct fcb_entry {
59};
60
67#define FCB_ENTRY_FA_DATA_OFF(entry) (entry.fe_sector->fs_off +\
68 entry.fe_data_off)
74 struct fcb_entry loc;
75 const struct flash_area *fap;
77};
78
86struct fcb {
87 /* Caller of fcb_init fills this in */
107 /* Flash circular buffer internal state */
123 const struct flash_area *fap;
132};
133
153int fcb_init(int f_area_id, struct fcb *fcb);
154
170int fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *loc);
171
180int fcb_append_finish(struct fcb *fcb, struct fcb_entry *append_loc);
181
197typedef int (*fcb_walk_cb)(struct fcb_entry_ctx *loc_ctx, void *arg);
198
214int fcb_walk(struct fcb *fcb, struct flash_sector *sector, fcb_walk_cb cb,
215 void *cb_arg);
216
233int fcb_getnext(struct fcb *fcb, struct fcb_entry *loc);
234
243int fcb_rotate(struct fcb *fcb);
244
256
265
273int fcb_is_empty(struct fcb *fcb);
274
284int fcb_offset_last_n(struct fcb *fcb, uint8_t entries,
285 struct fcb_entry *last_n_entry);
286
294int fcb_clear(struct fcb *fcb);
295
318int fcb_flash_read(const struct fcb *fcb, const struct flash_sector *sector,
319 off_t off, void *dst, size_t len);
320
332int fcb_flash_write(const struct fcb *fcb, const struct flash_sector *sector,
333 off_t off, const void *src, size_t len);
334
339#ifdef __cplusplus
340}
341#endif
342
343#endif /* ZEPHYR_INCLUDE_FS_FCB_H_ */
irp nz macro MOVR cc s mov cc s endm endr irp aw macro LDR aa off
Definition: asm-macro-32-bit-gnu.h:17
Public API for flash map.
int fcb_append_finish(struct fcb *fcb, struct fcb_entry *append_loc)
int fcb_free_sector_cnt(struct fcb *fcb)
int fcb_walk(struct fcb *fcb, struct flash_sector *sector, fcb_walk_cb cb, void *cb_arg)
int fcb_init(int f_area_id, struct fcb *fcb)
int fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry *loc)
int fcb_is_empty(struct fcb *fcb)
int fcb_clear(struct fcb *fcb)
int fcb_rotate(struct fcb *fcb)
int fcb_offset_last_n(struct fcb *fcb, uint8_t entries, struct fcb_entry *last_n_entry)
int(* fcb_walk_cb)(struct fcb_entry_ctx *loc_ctx, void *arg)
Definition: fcb.h:197
int fcb_getnext(struct fcb *fcb, struct fcb_entry *loc)
int fcb_append_to_scratch(struct fcb *fcb)
int fcb_flash_write(const struct fcb *fcb, const struct flash_sector *sector, off_t off, const void *src, size_t len)
int fcb_flash_read(const struct fcb *fcb, const struct flash_sector *sector, off_t off, void *dst, size_t len)
Public kernel APIs.
__INTPTR_TYPE__ off_t
Definition: types.h:36
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Structure for transferring complete information about FCB entry location within flash memory.
Definition: fcb.h:73
struct fcb_entry loc
Definition: fcb.h:74
const struct flash_area * fap
Definition: fcb.h:75
FCB entry info structure. This data structure describes the element location in the flash.
Definition: fcb.h:48
uint32_t fe_elem_off
Definition: fcb.h:52
uint32_t fe_data_off
Definition: fcb.h:55
uint16_t fe_data_len
Definition: fcb.h:58
struct flash_sector * fe_sector
Definition: fcb.h:49
FCB instance structure.
Definition: fcb.h:86
uint8_t f_version
Definition: fcb.h:97
const struct flash_area * fap
Definition: fcb.h:123
struct k_mutex f_mtx
Definition: fcb.h:108
struct fcb_entry f_active
Definition: fcb.h:116
uint32_t f_magic
Definition: fcb.h:88
uint8_t f_erase_value
Definition: fcb.h:128
uint16_t f_active_id
Definition: fcb.h:117
uint8_t f_sector_cnt
Definition: fcb.h:98
uint8_t f_align
Definition: fcb.h:120
uint8_t f_scratch_cnt
Definition: fcb.h:99
struct flash_sector * f_oldest
Definition: fcb.h:111
struct flash_sector * f_sectors
Definition: fcb.h:104
Flash partition.
Definition: flash_map.h:56
Structure for transfer flash sector boundaries.
Definition: flash_map.h:76
Definition: kernel.h:2721