zephyr/subsys/fs/fcb/fcb_priv.h

54 lines
1.2 KiB
C

/*
* Copyright (c) 2017 Nordic Semiconductor ASA
* Copyright (c) 2015 Runtime Inc
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __FCB_PRIV_H_
#define __FCB_PRIV_H_
#ifdef __cplusplus
extern "C" {
#endif
#define FCB_CRC_SZ sizeof(u8_t)
#define FCB_TMP_BUF_SZ 32
#define FCB_ID_GT(a, b) (((int16_t)(a) - (int16_t)(b)) > 0)
struct fcb_disk_area {
u32_t fd_magic;
u8_t fd_ver;
u8_t _pad;
u16_t fd_id;
};
int fcb_put_len(u8_t *buf, u16_t len);
int fcb_get_len(u8_t *buf, u16_t *len);
static inline int fcb_len_in_flash(struct fcb *fcb, u16_t len)
{
if (fcb->f_align <= 1) {
return len;
}
return (len + (fcb->f_align - 1)) & ~(fcb->f_align - 1);
}
int fcb_getnext_in_area(struct fcb *fcb, struct fcb_entry *loc);
struct flash_area *fcb_getnext_area(struct fcb *fcb, struct flash_area *fap);
int fcb_getnext_nolock(struct fcb *fcb, struct fcb_entry *loc);
int fcb_elem_info(struct fcb *fcb, struct fcb_entry *loc);
int fcb_elem_crc8(struct fcb *fcb, struct fcb_entry *loc, u8_t *crc8p);
int fcb_sector_hdr_init(struct fcb *fcb, struct flash_area *fap, u16_t id);
int fcb_sector_hdr_read(struct fcb *fcb, struct flash_area *fap,
struct fcb_disk_area *fdap);
#ifdef __cplusplus
}
#endif
#endif /* __FCB_PRIV_H_ */