Skip to content

Commit c9a20e5

Browse files
oyvindronningstadhakonfam
authored andcommitted
fw_info: Remove EXT_API_FUNCTION()
To make docs work. Also to remove a level of indirection that could be confusing. Signed-off-by: Øyvind Rønningstad <[email protected]>
1 parent 521a2ff commit c9a20e5

File tree

4 files changed

+58
-32
lines changed

4 files changed

+58
-32
lines changed

include/bl_crypto.h

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,20 @@ int bl_crypto_init(void);
7070
*
7171
* @remark No parameter can be NULL.
7272
*/
73-
EXT_API_FUNCTION(int, bl_root_of_trust_verify, const u8_t *public_key,
74-
const u8_t *public_key_hash,
75-
const u8_t *signature,
76-
const u8_t *firmware,
77-
const u32_t firmware_len);
73+
int bl_root_of_trust_verify(const u8_t *public_key,
74+
const u8_t *public_key_hash,
75+
const u8_t *signature,
76+
const u8_t *firmware,
77+
const u32_t firmware_len);
78+
79+
/* Typedef for use in EXT_API declaration */
80+
typedef int (*bl_root_of_trust_verify_t)(
81+
const u8_t *public_key,
82+
const u8_t *public_key_hash,
83+
const u8_t *signature,
84+
const u8_t *firmware,
85+
const u32_t firmware_len);
86+
7887

7988
/**
8089
* @brief Implementation of rot_verify that is safe to be called from EXT_API.
@@ -87,6 +96,7 @@ int bl_root_of_trust_verify_external(const u8_t *public_key,
8796
const u8_t *firmware,
8897
const u32_t firmware_len);
8998

99+
90100
/**
91101
* @brief Initialize a sha256 operation context variable.
92102
*
@@ -95,7 +105,11 @@ int bl_root_of_trust_verify_external(const u8_t *public_key,
95105
* @retval 0 On success.
96106
* @retval -EINVAL If @p ctx was NULL.
97107
*/
98-
EXT_API_FUNCTION(int, bl_sha256_init, bl_sha256_ctx_t *ctx);
108+
int bl_sha256_init(bl_sha256_ctx_t *ctx);
109+
110+
/* Typedef for use in EXT_API declaration */
111+
typedef int (*bl_sha256_init_t)(bl_sha256_ctx_t *ctx);
112+
99113

100114
/**
101115
* @brief Hash a portion of data.
@@ -113,9 +127,12 @@ EXT_API_FUNCTION(int, bl_sha256_init, bl_sha256_ctx_t *ctx);
113127
* @retval -EINVAL If @p ctx was NULL, uninitialized, or corrupted.
114128
* @retval -ENOSYS If the context has already been finalized.
115129
*/
116-
EXT_API_FUNCTION(int, bl_sha256_update, bl_sha256_ctx_t *ctx,
117-
const u8_t *data,
118-
u32_t data_len);
130+
int bl_sha256_update(bl_sha256_ctx_t *ctx, const u8_t *data, u32_t data_len);
131+
132+
/* Typedef for use in EXT_API declaration */
133+
typedef int (*bl_sha256_update_t)(bl_sha256_ctx_t *ctx, const u8_t *data,
134+
u32_t data_len);
135+
119136

120137
/**
121138
* @brief Finalize a hash result.
@@ -127,8 +144,11 @@ EXT_API_FUNCTION(int, bl_sha256_update, bl_sha256_ctx_t *ctx,
127144
* @retval 0 On success.
128145
* @retval -EINVAL If @p ctx was NULL or corrupted, or @p output was NULL.
129146
*/
130-
EXT_API_FUNCTION(int, bl_sha256_finalize, bl_sha256_ctx_t *ctx,
131-
u8_t *output);
147+
int bl_sha256_finalize(bl_sha256_ctx_t *ctx, u8_t *output);
148+
149+
/* Typedef for use in EXT_API declaration */
150+
typedef int (*bl_sha256_finalize_t)(bl_sha256_ctx_t *ctx, u8_t *output);
151+
132152

133153
/**
134154
* @brief Calculate a digest and verify it directly.
@@ -143,9 +163,12 @@ EXT_API_FUNCTION(int, bl_sha256_finalize, bl_sha256_ctx_t *ctx,
143163
* @return Any error code from @ref bl_sha256_init, @ref bl_sha256_update, or
144164
* @ref bl_sha256_finalize if something else went wrong.
145165
*/
146-
EXT_API_FUNCTION(int, bl_sha256_verify, const u8_t *data,
147-
u32_t data_len,
148-
const u8_t *expected);
166+
int bl_sha256_verify(const u8_t *data, u32_t data_len, const u8_t *expected);
167+
168+
/* Typedef for use in EXT_API declaration */
169+
typedef int (*bl_sha256_verify_t)(const u8_t *data, u32_t data_len,
170+
const u8_t *expected);
171+
149172

150173
/**
151174
* @brief Validate a secp256r1 signature.
@@ -160,10 +183,18 @@ EXT_API_FUNCTION(int, bl_sha256_verify, const u8_t *data,
160183
* @retval -EINVAL A parameter was NULL, or the @hash_len was not 32 bytes.
161184
* @retval -ESIGINV The signature validation failed.
162185
*/
163-
EXT_API_FUNCTION(int, bl_secp256r1_validate, const u8_t *hash,
164-
u32_t hash_len,
165-
const u8_t *signature,
166-
const u8_t *public_key);
186+
int bl_secp256r1_validate(const u8_t *hash,
187+
u32_t hash_len,
188+
const u8_t *signature,
189+
const u8_t *public_key);
190+
191+
/* Typedef for use in EXT_API declaration */
192+
typedef int (*bl_secp256r1_validate_t)(
193+
const u8_t *hash,
194+
u32_t hash_len,
195+
const u8_t *signature,
196+
const u8_t *public_key);
197+
167198

168199
struct bl_rot_verify_ext_api {
169200
struct fw_info_ext_api header;

include/bl_validation.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ struct bl_validate_fw_ext_api {
4747
* @retval true if the image is valid
4848
* @retval false if the image is invalid
4949
*/
50+
bool bl_validate_firmware(u32_t fw_dst_address, u32_t fw_src_address);
51+
52+
/* Typedef for use in EXT_API declaration */
53+
typedef
54+
bool (*bl_validate_firmware_t)(u32_t fw_dst_address, u32_t fw_src_address);
55+
56+
5057
bool bl_validate_firmware_local(u32_t fw_address,
5158
const struct fw_info *fwinfo);
5259

include/fw_info.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,6 @@ static inline const struct fw_info_ext_api *fw_info_ext_api_check(
120120
}
121121

122122

123-
/* Shorthand for declaring function that will be exposed through an EXT_API.
124-
* This will define a function pointer type as well as declare the function.
125-
*/
126-
#define EXT_API_FUNCTION(retval, name, ...) \
127-
typedef retval(*name ## _t)(__VA_ARGS__); \
128-
retval name(__VA_ARGS__)
129-
130-
131123
/**
132124
* A struct that is used to request an EXT_API.
133125
*

include/fw_info.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ To create an EXT_API, complete the following steps:
126126

127127
.. code-block:: c
128128
129+
typedef int (*my_ext_api_foo_t)(bool arg1, int *arg2);
130+
129131
struct my_ext_api {
130132
struct fw_info_ext_api header;
131133
struct {
@@ -152,12 +154,6 @@ To create an EXT_API, complete the following steps:
152154
};
153155
#endif
154156
155-
#. To include function pointers in your EXT_API, call the :c:macro:`EXT_API_FUNCTION` macro to forward-declare the function and create a typedef for the function pointer:
156-
157-
.. code-block:: c
158-
159-
EXT_API_FUNCTION(int, my_ext_api_foo, bool arg1, int *arg2);
160-
161157
#. Enable the EXT_API in Kconfig:
162158

163159
.. code-block:: none

0 commit comments

Comments
 (0)