Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
zms_priv.h
Go to the documentation of this file.
1/* Copyright (c) 2018 Laczen
2 * Copyright (c) 2024 BayLibre SAS
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * ZMS: Zephyr Memory Storage
7 */
8
9#ifndef __ZMS_PRIV_H_
10#define __ZMS_PRIV_H_
11
12/*
13 * MASKS AND SHIFT FOR ADDRESSES.
14 * An address in zms is an uint64_t where:
15 * - high 4 bytes represent the sector number
16 * - low 4 bytes represent the offset in a sector
17 */
18#define ADDR_SECT_MASK GENMASK64(63, 32)
19#define ADDR_SECT_SHIFT 32
20#define ADDR_OFFS_MASK GENMASK64(31, 0)
21#define SECTOR_NUM(x) FIELD_GET(ADDR_SECT_MASK, x)
22#define SECTOR_OFFSET(x) FIELD_GET(ADDR_OFFS_MASK, x)
23
24#if defined(CONFIG_ZMS_CUSTOMIZE_BLOCK_SIZE)
25#define ZMS_BLOCK_SIZE CONFIG_ZMS_CUSTOM_BLOCK_SIZE
26#else
27#define ZMS_BLOCK_SIZE 32
28#endif
29
30#define ZMS_LOOKUP_CACHE_NO_ADDR GENMASK64(63, 0)
31#define ZMS_HEAD_ID GENMASK(31, 0)
32
33#define ZMS_VERSION_MASK GENMASK(7, 0)
34#define ZMS_GET_VERSION(x) FIELD_GET(ZMS_VERSION_MASK, x)
35#define ZMS_DEFAULT_VERSION 1
36#define ZMS_MAGIC_NUMBER 0x42 /* murmur3a hash of "ZMS" (MSB) */
37#define ZMS_MAGIC_NUMBER_MASK GENMASK(15, 8)
38#define ZMS_GET_MAGIC_NUMBER(x) FIELD_GET(ZMS_MAGIC_NUMBER_MASK, x)
39#define ZMS_MIN_ATE_NUM 5
40
41#define ZMS_INVALID_SECTOR_NUM -1
42#define ZMS_DATA_IN_ATE_SIZE 8
43
48struct zms_ate {
57 union {
60 struct {
63 union {
75 };
76 };
77 };
78} __packed;
79
80#endif /* __ZMS_PRIV_H_ */
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
ZMS Allocation Table Entry (ATE) structure.
Definition zms_priv.h:48
uint32_t metadata
Used to store metadata information such as storage version.
Definition zms_priv.h:74
uint8_t data[8]
data field used to store small sized data
Definition zms_priv.h:59
uint32_t offset
data offset within sector
Definition zms_priv.h:62
uint32_t data_crc
crc for data: The data CRC is checked only when the whole data of the element is read.
Definition zms_priv.h:70
uint8_t cycle_cnt
cycle counter for non erasable devices
Definition zms_priv.h:52
uint16_t len
data len within sector
Definition zms_priv.h:54
uint8_t crc8
crc8 check of the entry
Definition zms_priv.h:50
uint32_t id
data id
Definition zms_priv.h:56