14#include <zephyr/types.h>
16#include <zephyr/toolchain.h>
17#include <zephyr/sys/util.h>
18#include <zephyr/sys/__assert.h>
19#include <zephyr/linker/sections.h>
21#if USE_PARTITION_MANAGER
33#define OFFSET_CHECK(type, member, value) \
34 BUILD_ASSERT(offsetof(type, member) == value, \
35 #member " has wrong offset")
50#define EXT_API(ext_api_name, type, name) \
51 Z_GENERIC_SECTION(.ext_apis) \
52 const uint8_t _CONCAT(name, _ext_api_counter) = 0xFF; \
53 BUILD_ASSERT((sizeof(type) % 4) == 0, \
54 "Size of EXT_API " #type " is not word-aligned"); \
55 struct __packed _CONCAT(name, _t) \
57 struct fw_info_ext_api header; \
60 Z_GENERIC_SECTION(.firmware_info.1) __attribute__((used)) \
61 const struct _CONCAT(name, _t) name = { \
63 .magic = {EXT_API_MAGIC}, \
64 .ext_api_id = CONFIG_ ## ext_api_name ## _EXT_API_ID, \
65 .ext_api_flags = CONFIG_ ## ext_api_name ## _EXT_API_FLAGS, \
66 .ext_api_version = CONFIG_ ## ext_api_name ## _EXT_API_VER, \
67 .ext_api_len = sizeof(struct __packed _CONCAT(name, _t)), \
88#define EXT_API_REQ(name, req, type, var_name) \
89 Z_GENERIC_SECTION(.ext_apis_req) \
90 const uint8_t _CONCAT(var_name, _ext_api_req_counter) = 0xFF; \
91 __noinit const struct __packed \
93 struct fw_info_ext_api header; \
96 Z_GENERIC_SECTION(.firmware_info.2) \
97 __attribute__((used)) \
98 const struct fw_info_ext_api_request _CONCAT(var_name, _req) = \
101 .magic = {EXT_API_MAGIC}, \
102 .ext_api_id = CONFIG_ ## name ## _EXT_API_ID, \
103 .ext_api_flags = CONFIG_ ## name ## _EXT_API_FLAGS, \
104 .ext_api_version = CONFIG_ ## name ## _EXT_API_VER, \
105 .ext_api_len = sizeof(struct fw_info_ext_api_request), \
107 .ext_api_max_version = CONFIG_ ## name ## _EXT_API_MAX_VER, \
109 .ext_api = (void *) &var_name, \
117OFFSET_CHECK(
struct fw_info, magic, 0);
118OFFSET_CHECK(
struct fw_info, total_size, 12);
119OFFSET_CHECK(
struct fw_info, size, 16);
120OFFSET_CHECK(
struct fw_info, version, 20);
121OFFSET_CHECK(
struct fw_info, address, 24);
122OFFSET_CHECK(
struct fw_info, boot_address, 28);
123OFFSET_CHECK(
struct fw_info, valid, 32);
124OFFSET_CHECK(
struct fw_info, reserved, 36);
125OFFSET_CHECK(
struct fw_info, ext_api_num, 52);
126OFFSET_CHECK(
struct fw_info, ext_api_request_num, 56);
127OFFSET_CHECK(
struct fw_info, ext_apis, 60);
128BUILD_ASSERT(
sizeof(
struct fw_info) == offsetof(
struct fw_info, ext_apis),
129 "Size of fw_info must assume ext_apis is empty.");
138#if defined(PM_S0_PAD_SIZE) && (PM_ADDRESS == PM_S0_IMAGE_ADDRESS)
139 #define FW_INFO_VECTOR_OFFSET PM_S0_PAD_SIZE
140#elif defined(PM_S1_PAD_SIZE) && (PM_ADDRESS == PM_S1_IMAGE_ADDRESS)
141 #define FW_INFO_VECTOR_OFFSET PM_S1_PAD_SIZE
142#elif defined(PM_MCUBOOT_PAD_SIZE) && \
143 (PM_ADDRESS == PM_MCUBOOT_PRIMARY_APP_ADDRESS)
144 #define FW_INFO_VECTOR_OFFSET PM_MCUBOOT_PAD_SIZE
146 #define FW_INFO_VECTOR_OFFSET 0
154 "Mismatch in the number of allowed offsets.");
159#if (FW_INFO_OFFSET_COUNT != 5) \
160 || ((FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET0) && \
161 (FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET1) && \
162 (FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET2) && \
163 (FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET3) && \
164 (FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET4))
165 #error FW_INFO_OFFSET not set to one of the allowed values.
static const uint32_t fw_info_allowed_offsets[]
Definition fw_info_bare.h:192
#define FW_INFO_OFFSET_COUNT
Definition fw_info_bare.h:29
bool fw_info_ext_api_provide(const struct fw_info *fwinfo, bool provide)
void fw_info_invalidate(const struct fw_info *fw_info)
Definition fw_info_bare.h:98
Definition fw_info_bare.h:42
Definition fw_info_bare.h:125