Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022-2023, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | * FWU metadata information as per the specification section 4.1: |
| 7 | * https://developer.arm.com/documentation/den0118/a/ |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | #ifndef FWU_PROTO_METADATA_V1_H |
| 12 | #define FWU_PROTO_METADATA_V1_H |
| 13 | |
| 14 | #include <stdint.h> |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 15 | |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 16 | #include "metadata.h" |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 17 | #include "protocols/common/osf/uuid.h" |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * FWU metadata version corresponding to these structure definitions. |
| 21 | */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 22 | #define FWU_METADATA_VERSION (1) |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * The number of image entries in the metadata structure. |
| 26 | */ |
| 27 | #ifndef FWU_METADATA_NUM_IMAGE_ENTRIES |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 28 | #define FWU_METADATA_NUM_IMAGE_ENTRIES (1) |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 29 | #endif |
| 30 | |
| 31 | /* Properties of image in a bank */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 32 | struct __attribute__((__packed__)) fwu_image_properties { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 33 | /* UUID of the image in this bank */ |
| 34 | uint8_t img_uuid[OSF_UUID_OCTET_LEN]; |
| 35 | |
| 36 | /* [0]: bit describing the image acceptance status – |
| 37 | * 1 means the image is accepted |
| 38 | * [31:1]: MBZ |
| 39 | */ |
| 40 | uint32_t accepted; |
| 41 | |
| 42 | /* reserved (MBZ) */ |
| 43 | uint32_t reserved; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | /* Image entry information */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 47 | struct __attribute__((__packed__)) fwu_image_entry { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 48 | /* UUID identifying the image type */ |
| 49 | uint8_t img_type_uuid[OSF_UUID_OCTET_LEN]; |
| 50 | |
| 51 | /* UUID of the storage volume where the image is located */ |
| 52 | uint8_t location_uuid[OSF_UUID_OCTET_LEN]; |
| 53 | |
| 54 | /* Properties of images with img_type_uuid in the different FW banks */ |
| 55 | struct fwu_image_properties img_props[FWU_METADATA_NUM_BANKS]; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | /* |
| 59 | * FWU metadata filled by the updater and consumed by TF-A for |
| 60 | * various purposes as below: |
| 61 | * 1. Get active FW bank. |
| 62 | * 2. Rollback to previous working FW bank. |
| 63 | * 3. Get properties of all images present in all banks. |
| 64 | */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 65 | struct __attribute__((__packed__)) fwu_metadata { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 66 | /* Metadata CRC value */ |
| 67 | uint32_t crc_32; |
| 68 | |
| 69 | /* Metadata version */ |
| 70 | uint32_t version; |
| 71 | |
| 72 | /* Bank index with which device boots */ |
| 73 | uint32_t active_index; |
| 74 | |
| 75 | /* Previous bank index with which device booted successfully */ |
| 76 | uint32_t previous_active_index; |
| 77 | |
| 78 | /* Image entry information */ |
| 79 | struct fwu_image_entry img_entry[FWU_METADATA_NUM_IMAGE_ENTRIES]; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | #endif /* FWU_PROTO_METADATA_V1_H */ |