Skip to content

Commit 6d25ec9

Browse files
oyvindronningstadhakonfam
authored andcommitted
b0: bl_validation: Add RST docs for bl_validation
Also fix doxygen text and tagging inside bl_validation.h Signed-off-by: Øyvind Rønningstad <[email protected]>
1 parent 2c65295 commit 6d25ec9

File tree

2 files changed

+59
-18
lines changed

2 files changed

+59
-18
lines changed

include/bl_validation.h

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,22 @@
77
#ifndef BL_VALIDATION_H__
88
#define BL_VALIDATION_H__
99

10-
/*
11-
* The FW package will consist of (firmware | (padding) | validation_info),
12-
* where the firmware contains the firmware_info at a predefined location. The
13-
* padding is present if the validation_info needs alignment. The
14-
* validation_info is not directly referenced from the firmware_info since the
15-
* validation_info doesn't actually have to be placed after the firmware.
16-
*/
10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
1713

1814
#include <stdbool.h>
1915
#include <fw_info.h>
2016

17+
/** @defgroup bl_validation Bootloader firmware validation
18+
* @{
19+
*/
20+
2121
/* EXT_API ID for the bl_validate_firmware EXT_API. */
2222
#define BL_VALIDATE_FW_EXT_API_ID 0x1101
2323

24-
EXT_API_FUNCTION(bool, bl_validate_firmware, u32_t fw_dst_address,
25-
u32_t fw_src_address);
26-
27-
struct bl_validate_fw_ext_api {
28-
struct fw_info_ext_api header;
29-
struct {
30-
bl_validate_firmware_t bl_validate_firmware;
31-
} ext_api;
32-
};
33-
3424

35-
/** Function for validating firmware in place.
25+
/** Function for validating firmware.
3626
*
3727
* @details This will run a series of checks on the fw_info contents, then
3828
* locate the validation info and check the signature of the image.
@@ -54,7 +44,30 @@ typedef
5444
bool (*bl_validate_firmware_t)(u32_t fw_dst_address, u32_t fw_src_address);
5545

5646

47+
/** Function for validating firmware in place.
48+
*
49+
* @note This function is only available to the bootloader.
50+
*
51+
* @details See @ref bl_validate_firmware for more details.
52+
*/
5753
bool bl_validate_firmware_local(u32_t fw_address,
5854
const struct fw_info *fwinfo);
5955

56+
57+
/**
58+
* @brief Structure describing the BL_VALIDATE_FW EXT_API.
59+
*/
60+
struct bl_validate_fw_ext_api {
61+
struct fw_info_ext_api header;
62+
struct {
63+
bl_validate_firmware_t bl_validate_firmware;
64+
} ext_api;
65+
};
66+
67+
/** @} */
68+
69+
#ifdef __cplusplus
70+
}
71+
#endif
72+
6073
#endif /* BL_VALIDATION_H__ */

include/bl_validation.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.. _doc_bl_validation:
2+
3+
Bootloader firmware validation
4+
##############################
5+
6+
The bootloader firmware validation library provides the function that the :ref:`bootloader` uses to validate a firmware image before booting it.
7+
8+
The API is public because applications that are booted by the immutable bootloader can call the function from this library via the bootloader's code, through external APIs.
9+
See :ref:`doc_fw_info_ext_api` for more information.
10+
Using this mechanism can be useful when the application receives a DFU package and wants to determine whether it will be accepted by the bootloader.
11+
12+
Validation
13+
**********
14+
15+
The :cpp:func:`bl_validate_firmware` function validates the following information:
16+
17+
* The digest and the signature of the whole image (see :cpp:func:`bl_root_of_trust_verify`)
18+
* The fields of the ``fw_info`` struct that is part of the firmware image (see :ref:`doc_fw_info`)
19+
20+
API documentation
21+
*****************
22+
23+
| Header file: :file:`include/bl_validation.h`
24+
| Source files: :file:`subsys/bootloader/bl_validation/`
25+
26+
.. doxygengroup:: bl_validation
27+
:project: nrf
28+
:members:

0 commit comments

Comments
 (0)