Skip to content

Commit 6191f13

Browse files
committed
include: bindesc: doc: doxygen clean-ups
Re-organize groups, including addition of a top level "Binary Descriptors" group that becomes the main entry in OS Services Add missing documentation to some API (bindesc_entry, with public fields, and bindesc_handle, opaque) Signed-off-by: Benjamin Cabé <[email protected]>
1 parent 2a17181 commit 6191f13

File tree

1 file changed

+56
-22
lines changed

1 file changed

+56
-22
lines changed

include/zephyr/bindesc.h

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
/**
8+
* @file
9+
* @brief Header file for binary descriptors
10+
* @ingroup bindesc
11+
*/
12+
713
#ifndef ZEPHYR_INCLUDE_ZEPHYR_BINDESC_H_
814
#define ZEPHYR_INCLUDE_ZEPHYR_BINDESC_H_
915

16+
/**
17+
* @defgroup bindesc Binary Descriptors
18+
* @ingroup os_services
19+
* @{
20+
*/
21+
1022
#include <zephyr/sys/util_macro.h>
1123

1224
#ifdef __cplusplus
@@ -17,19 +29,28 @@ extern "C" {
1729
* Corresponds to the definitions in scripts/west_commands/bindesc.py.
1830
* Do not change without syncing the definitions in both files!
1931
*/
32+
33+
/** Magic number used to identify binary descriptor sections in firmware images */
2034
#define BINDESC_MAGIC 0xb9863e5a7ea46046
35+
/** Required memory alignment for binary descriptor entries */
2136
#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 */
2748
#define BINDESC_ENTRY_HEADER_SIZE (sizeof(struct bindesc_entry))
2849

2950
/**
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
3354
* @{
3455
*/
3556

@@ -119,6 +140,7 @@ extern "C" {
119140
/** The C++ compiler version */
120141
#define BINDESC_ID_CXX_COMPILER_VERSION 0xb04
121142

143+
/** The end of binary descriptor section */
122144
#define BINDESC_TAG_DESCRIPTORS_END BINDESC_TAG(DESCRIPTORS_END, 0x0fff)
123145

124146
/**
@@ -292,9 +314,15 @@ extern "C" {
292314
* @}
293315
*/
294316

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
298326
*/
299327
struct bindesc_entry {
300328
/** Tag of the entry */
@@ -305,6 +333,7 @@ struct bindesc_entry {
305333
uint8_t data[];
306334
} __packed;
307335

336+
/** @cond INTERNAL_HIDDEN */
308337
/*
309338
* We're assuming that `struct bindesc_entry` has a specific layout in
310339
* memory, so it's worth making sure that the layout is really what we
@@ -314,8 +343,13 @@ struct bindesc_entry {
314343
BUILD_ASSERT(offsetof(struct bindesc_entry, tag) == 0, "Incorrect memory layout");
315344
BUILD_ASSERT(offsetof(struct bindesc_entry, len) == 2, "Incorrect memory layout");
316345
BUILD_ASSERT(offsetof(struct bindesc_entry, data) == 4, "Incorrect memory layout");
346+
/** @endcond */
317347

348+
/**
349+
* @brief Handle for reading binary descriptors from firmware images
350+
*/
318351
struct bindesc_handle {
352+
/** @cond INTERNAL_HIDDEN */
319353
const uint8_t *address;
320354
enum {
321355
BINDESC_HANDLE_TYPE_RAM,
@@ -328,15 +362,9 @@ struct bindesc_handle {
328362
uint8_t buffer[sizeof(struct bindesc_entry) +
329363
CONFIG_BINDESC_READ_FLASH_MAX_DATA_SIZE] __aligned(BINDESC_ALIGNMENT);
330364
#endif /* IS_ENABLED(CONFIG_BINDESC_READ_FLASH) */
365+
/** @endcond */
331366
};
332367

333-
/**
334-
* @brief Reading Binary Descriptors of other images.
335-
* @defgroup bindesc_read Bindesc Read
336-
* @ingroup os_services
337-
* @{
338-
*/
339-
340368
/**
341369
* @brief Callback type to be called on descriptors found during a walk
342370
*
@@ -355,7 +383,7 @@ typedef int (*bindesc_callback_t)(const struct bindesc_entry *entry, void *user_
355383
* Memory mapped flash is any flash that can be directly accessed by the CPU,
356384
* without needing to use the flash API for copying the data to RAM.
357385
*
358-
* @param handle Bindesc handle to be given to subsequent calls
386+
* @param[out] handle Bindesc handle to be given to subsequent calls
359387
* @param offset The offset from the beginning of the flash that the bindesc magic can be found at
360388
*
361389
* @retval 0 On success
@@ -371,9 +399,9 @@ int bindesc_open_memory_mapped_flash(struct bindesc_handle *handle, size_t offse
371399
* It's assumed that the whole bindesc context was copied to RAM prior to calling
372400
* this function, either by the user or by a bootloader.
373401
*
374-
* @note The given address must be aligned to BINDESC_ALIGNMENT
402+
* @note The given address must be aligned to @ref BINDESC_ALIGNMENT
375403
*
376-
* @param handle Bindesc handle to be given to subsequent calls
404+
* @param[out] handle Bindesc handle to be given to subsequent calls
377405
* @param address The address that the bindesc magic can be found at
378406
* @param max_size Maximum size of the given buffer
379407
*
@@ -392,10 +420,12 @@ int bindesc_open_ram(struct bindesc_handle *handle, const uint8_t *address, size
392420
* backend requires reading the data from flash to an internal buffer
393421
* using the flash API
394422
*
395-
* @param handle Bindesc handle to be given to subsequent calls
423+
* @param[out] handle Bindesc handle to be given to subsequent calls
396424
* @param offset The offset from the beginning of the flash that the bindesc magic can be found at
397425
* @param flash_device Flash device to read descriptors from
398426
*
427+
* @kconfig_dep{CONFIG_BINDESC_READ_FLASH}
428+
*
399429
* @retval 0 On success
400430
* @retval -ENOENT If no bindesc magic was found at the given offset
401431
*/
@@ -599,4 +629,8 @@ extern const struct bindesc_entry BINDESC_NAME(cxx_compiler_version);
599629
}
600630
#endif
601631

632+
/**
633+
* @}
634+
*/
635+
602636
#endif /* ZEPHYR_INCLUDE_ZEPHYR_BINDESC_H_ */

0 commit comments

Comments
 (0)