Tamas Ban | a9de4a6 | 2018-09-18 08:09:45 +0100 | [diff] [blame] | 1 | /* |
Tamas Ban | 5b64747 | 2019-01-05 08:59:30 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Tamas Ban | a9de4a6 | 2018-09-18 08:09:45 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __BOOT_RECORD_H__ |
| 9 | #define __BOOT_RECORD_H__ |
| 10 | |
| 11 | #include <stdint.h> |
| 12 | #include <stddef.h> |
| 13 | #include <limits.h> |
Tamas Ban | 0e8ab30 | 2019-01-17 11:45:31 +0000 | [diff] [blame^] | 14 | #include "../ext/mcuboot/bootutil/include/bootutil/image.h" |
| 15 | #include "../ext/mcuboot/include/flash_map/flash_map.h" |
Tamas Ban | a9de4a6 | 2018-09-18 08:09:45 +0100 | [diff] [blame] | 16 | |
| 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
| 21 | /*! |
| 22 | * \enum shared_data_err_t |
| 23 | * |
| 24 | * \brief Return values for adding data entry to shared memory area |
| 25 | */ |
| 26 | enum shared_memory_err_t { |
| 27 | SHARED_MEMORY_OK = 0, |
| 28 | SHARED_MEMORY_OVERFLOW = 1, |
| 29 | SHARED_MEMORY_OVERWRITE = 2, |
| 30 | |
| 31 | /* This is used to force the maximum size */ |
| 32 | TLV_TYPE_MAX = INT_MAX |
| 33 | }; |
| 34 | |
| 35 | /*! |
Tamas Ban | 0e8ab30 | 2019-01-17 11:45:31 +0000 | [diff] [blame^] | 36 | * \enum boot_status_err_t |
| 37 | * |
| 38 | * \brief Return values for saving boot status information to shared memory are |
| 39 | */ |
| 40 | enum boot_status_err_t { |
| 41 | BOOT_STATUS_OK, |
| 42 | BOOT_STATUS_ERROR, |
| 43 | }; |
| 44 | |
| 45 | /*! |
Tamas Ban | a9de4a6 | 2018-09-18 08:09:45 +0100 | [diff] [blame] | 46 | * \brief Add a data item to the shared data area between bootloader and |
| 47 | * runtime SW |
| 48 | * |
| 49 | * \param[in] major_type TLV major type, identify consumer |
| 50 | * \param[in] minor_type TLV minor type, identify TLV type |
| 51 | * \param[in] size length of added data |
| 52 | * \param[in] data pointer to data |
| 53 | * |
| 54 | * \return Returns error code as specified in \ref shared_memory_err_t |
| 55 | */ |
| 56 | enum shared_memory_err_t |
| 57 | boot_add_data_to_shared_area(uint8_t major_type, |
Tamas Ban | 5b64747 | 2019-01-05 08:59:30 +0000 | [diff] [blame] | 58 | uint16_t minor_type, |
Tamas Ban | a9de4a6 | 2018-09-18 08:09:45 +0100 | [diff] [blame] | 59 | size_t size, |
| 60 | const uint8_t *data); |
| 61 | |
Tamas Ban | 0e8ab30 | 2019-01-17 11:45:31 +0000 | [diff] [blame^] | 62 | /*! |
| 63 | * \brief Add an image's all boot status information to the shared data area |
| 64 | * between bootloader and runtime SW |
| 65 | * |
| 66 | * \param[in] sw_module Identifier of the SW component |
| 67 | * \param[in] hdr Pointer to the image header stored in RAM |
| 68 | * \param[in] fap Pointer to the flash area where image is stored |
| 69 | * |
| 70 | * \return Returns error code as specified in \ref boot_status_err_t |
| 71 | */ |
| 72 | enum boot_status_err_t |
| 73 | boot_save_boot_status(uint8_t sw_module, |
| 74 | const struct image_header *hdr, |
| 75 | const struct flash_area *fap); |
| 76 | |
Tamas Ban | a9de4a6 | 2018-09-18 08:09:45 +0100 | [diff] [blame] | 77 | #ifdef __cplusplus |
| 78 | } |
| 79 | #endif |
| 80 | |
| 81 | #endif /* __BOOT_RECORD_H__ */ |