4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
6
6
7
+ /**
8
+ * @file
9
+ * @brief Header file for binary descriptors
10
+ * @ingroup bindesc
11
+ */
12
+
7
13
#ifndef ZEPHYR_INCLUDE_ZEPHYR_BINDESC_H_
8
14
#define ZEPHYR_INCLUDE_ZEPHYR_BINDESC_H_
9
15
16
+ /**
17
+ * @defgroup bindesc Binary Descriptors
18
+ * @ingroup os_services
19
+ * @{
20
+ */
21
+
10
22
#include <zephyr/sys/util_macro.h>
11
23
12
24
#ifdef __cplusplus
@@ -17,19 +29,28 @@ extern "C" {
17
29
* Corresponds to the definitions in scripts/west_commands/bindesc.py.
18
30
* Do not change without syncing the definitions in both files!
19
31
*/
32
+
33
+ /** Magic number used to identify binary descriptor sections in firmware images */
20
34
#define BINDESC_MAGIC 0xb9863e5a7ea46046
35
+ /** Required memory alignment for binary descriptor entries */
21
36
#define BINDESC_ALIGNMENT 4
22
- #define BINDESC_TYPE_UINT 0x0
23
- #define BINDESC_TYPE_STR 0x1
24
- #define BINDESC_TYPE_BYTES 0x2
25
- #define BINDESC_TYPE_DESCRIPTORS_END 0xf
26
- /* sizeof ignores the data as it's a flexible array */
37
+
38
+ /** @name Binary Descriptor Types */
39
+ /** @{ */
40
+ #define BINDESC_TYPE_UINT 0x0 /**< Unsigned integer data */
41
+ #define BINDESC_TYPE_STR 0x1 /**< String data */
42
+ #define BINDESC_TYPE_BYTES 0x2 /**< Byte array data */
43
+ #define BINDESC_TYPE_DESCRIPTORS_END 0xf /**< Marks the end of binary descriptor section */
44
+ /** @} */
45
+
46
+ /** Size of the header of a binary descriptor entry */
47
+ /* Needed as sizeof ignores the data as it's a flexible array */
27
48
#define BINDESC_ENTRY_HEADER_SIZE (sizeof(struct bindesc_entry))
28
49
29
50
/**
30
- * @brief Binary Descriptor Definition
31
- * @defgroup bindesc_define Bindesc Define
32
- * @ingroup os_services
51
+ * @brief Macros for defining binary descriptors in firmware images
52
+ * @defgroup bindesc_define Binary Descriptor Definition
53
+ * @ingroup bindesc
33
54
* @{
34
55
*/
35
56
@@ -119,6 +140,7 @@ extern "C" {
119
140
/** The C++ compiler version */
120
141
#define BINDESC_ID_CXX_COMPILER_VERSION 0xb04
121
142
143
+ /** The end of binary descriptor section */
122
144
#define BINDESC_TAG_DESCRIPTORS_END BINDESC_TAG(DESCRIPTORS_END, 0x0fff)
123
145
124
146
/**
@@ -292,9 +314,15 @@ extern "C" {
292
314
* @}
293
315
*/
294
316
295
- /*
296
- * An entry of the binary descriptor header. Each descriptor is
297
- * described by one of these entries.
317
+ /**
318
+ * @brief Functions for reading binary descriptors from firmware images
319
+ * @defgroup bindesc_read Binary Descriptor Reading
320
+ * @ingroup bindesc
321
+ * @{
322
+ */
323
+
324
+ /**
325
+ * @brief Structure for a binary descriptor entry
298
326
*/
299
327
struct bindesc_entry {
300
328
/** Tag of the entry */
@@ -305,6 +333,7 @@ struct bindesc_entry {
305
333
uint8_t data [];
306
334
} __packed ;
307
335
336
+ /** @cond INTERNAL_HIDDEN */
308
337
/*
309
338
* We're assuming that `struct bindesc_entry` has a specific layout in
310
339
* memory, so it's worth making sure that the layout is really what we
@@ -314,8 +343,13 @@ struct bindesc_entry {
314
343
BUILD_ASSERT (offsetof(struct bindesc_entry , tag ) == 0 , "Incorrect memory layout" );
315
344
BUILD_ASSERT (offsetof(struct bindesc_entry , len ) == 2 , "Incorrect memory layout" );
316
345
BUILD_ASSERT (offsetof(struct bindesc_entry , data ) == 4 , "Incorrect memory layout" );
346
+ /** @endcond */
317
347
348
+ /**
349
+ * @brief Handle for reading binary descriptors from firmware images
350
+ */
318
351
struct bindesc_handle {
352
+ /** @cond INTERNAL_HIDDEN */
319
353
const uint8_t * address ;
320
354
enum {
321
355
BINDESC_HANDLE_TYPE_RAM ,
@@ -328,15 +362,9 @@ struct bindesc_handle {
328
362
uint8_t buffer [sizeof (struct bindesc_entry ) +
329
363
CONFIG_BINDESC_READ_FLASH_MAX_DATA_SIZE ] __aligned (BINDESC_ALIGNMENT );
330
364
#endif /* IS_ENABLED(CONFIG_BINDESC_READ_FLASH) */
365
+ /** @endcond */
331
366
};
332
367
333
- /**
334
- * @brief Reading Binary Descriptors of other images.
335
- * @defgroup bindesc_read Bindesc Read
336
- * @ingroup os_services
337
- * @{
338
- */
339
-
340
368
/**
341
369
* @brief Callback type to be called on descriptors found during a walk
342
370
*
@@ -355,7 +383,7 @@ typedef int (*bindesc_callback_t)(const struct bindesc_entry *entry, void *user_
355
383
* Memory mapped flash is any flash that can be directly accessed by the CPU,
356
384
* without needing to use the flash API for copying the data to RAM.
357
385
*
358
- * @param handle Bindesc handle to be given to subsequent calls
386
+ * @param[out] handle Bindesc handle to be given to subsequent calls
359
387
* @param offset The offset from the beginning of the flash that the bindesc magic can be found at
360
388
*
361
389
* @retval 0 On success
@@ -371,9 +399,9 @@ int bindesc_open_memory_mapped_flash(struct bindesc_handle *handle, size_t offse
371
399
* It's assumed that the whole bindesc context was copied to RAM prior to calling
372
400
* this function, either by the user or by a bootloader.
373
401
*
374
- * @note The given address must be aligned to BINDESC_ALIGNMENT
402
+ * @note The given address must be aligned to @ref BINDESC_ALIGNMENT
375
403
*
376
- * @param handle Bindesc handle to be given to subsequent calls
404
+ * @param[out] handle Bindesc handle to be given to subsequent calls
377
405
* @param address The address that the bindesc magic can be found at
378
406
* @param max_size Maximum size of the given buffer
379
407
*
@@ -392,10 +420,12 @@ int bindesc_open_ram(struct bindesc_handle *handle, const uint8_t *address, size
392
420
* backend requires reading the data from flash to an internal buffer
393
421
* using the flash API
394
422
*
395
- * @param handle Bindesc handle to be given to subsequent calls
423
+ * @param[out] handle Bindesc handle to be given to subsequent calls
396
424
* @param offset The offset from the beginning of the flash that the bindesc magic can be found at
397
425
* @param flash_device Flash device to read descriptors from
398
426
*
427
+ * @kconfig_dep{CONFIG_BINDESC_READ_FLASH}
428
+ *
399
429
* @retval 0 On success
400
430
* @retval -ENOENT If no bindesc magic was found at the given offset
401
431
*/
@@ -599,4 +629,8 @@ extern const struct bindesc_entry BINDESC_NAME(cxx_compiler_version);
599
629
}
600
630
#endif
601
631
632
+ /**
633
+ * @}
634
+ */
635
+
602
636
#endif /* ZEPHYR_INCLUDE_ZEPHYR_BINDESC_H_ */
0 commit comments