1 /*
2  * Copyright (c) 2018-2021 Arm Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __BOOT_RECORD_H__
18 #define __BOOT_RECORD_H__
19 
20 #include <stdint.h>
21 #include <stddef.h>
22 #include "bootutil/image.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * @brief Add a data item to the shared data area between bootloader and
30  *        runtime SW
31  *
32  * @param[in] major_type  TLV major type, identify consumer
33  * @param[in] minor_type  TLV minor type, identify TLV type
34  * @param[in] size        length of added data
35  * @param[in] data        pointer to data
36  *
37  * @return                0 on success; nonzero on failure.
38  */
39 int boot_add_data_to_shared_area(uint8_t        major_type,
40                                  uint16_t       minor_type,
41                                  size_t         size,
42                                  const uint8_t *data);
43 
44 /**
45  * Add an image's all boot status information to the shared memory area
46  * between the bootloader and runtime SW.
47  *
48  * @param[in]  sw_module  Identifier of the SW component.
49  * @param[in]  hdr        Pointer to the image header stored in RAM.
50  * @param[in]  fap        Pointer to the flash area where image is stored.
51  *
52  * @return                0 on success; nonzero on failure.
53  */
54 int boot_save_boot_status(uint8_t sw_module,
55                           const struct image_header *hdr,
56                           const struct flash_area *fap);
57 
58 /**
59  * Add application specific data to the shared memory area between the
60  * bootloader and runtime SW.
61  *
62  * @param[in]  hdr        Pointer to the image header stored in RAM.
63  * @param[in]  fap        Pointer to the flash area where image is stored.
64  *
65  * @return                0 on success; nonzero on failure.
66  */
67 int boot_save_shared_data(const struct image_header *hdr,
68                           const struct flash_area *fap);
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif /* __BOOT_RECORD_H__ */
75