Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021, 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: |
Sughosh Ganu | f01e1e7 | 2024-02-01 12:25:09 +0530 | [diff] [blame] | 7 | * https://developer.arm.com/documentation/den0118/latest/ |
Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 8 | * |
| 9 | */ |
| 10 | |
| 11 | #ifndef FWU_METADATA_H |
| 12 | #define FWU_METADATA_H |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | #include <tools_share/uuid.h> |
| 16 | |
Sughosh Ganu | 9a480a3 | 2024-02-01 12:47:13 +0530 | [diff] [blame] | 17 | #define NR_OF_MAX_FW_BANKS 4 |
| 18 | |
Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 19 | /* Properties of image in a bank */ |
Sughosh Ganu | 52794a3 | 2024-02-02 15:35:18 +0530 | [diff] [blame] | 20 | struct fwu_image_bank_info { |
Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 21 | |
Sughosh Ganu | 52794a3 | 2024-02-02 15:35:18 +0530 | [diff] [blame] | 22 | /* GUID of the image in this bank */ |
| 23 | struct efi_guid img_guid; |
Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 24 | |
| 25 | /* [0]: bit describing the image acceptance status – |
| 26 | * 1 means the image is accepted |
| 27 | * [31:1]: MBZ |
| 28 | */ |
| 29 | uint32_t accepted; |
| 30 | |
| 31 | /* reserved (MBZ) */ |
| 32 | uint32_t reserved; |
| 33 | |
| 34 | } __packed; |
| 35 | |
| 36 | /* Image entry information */ |
| 37 | struct fwu_image_entry { |
| 38 | |
Sughosh Ganu | 52794a3 | 2024-02-02 15:35:18 +0530 | [diff] [blame] | 39 | /* GUID identifying the image type */ |
| 40 | struct efi_guid img_type_guid; |
Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 41 | |
Sughosh Ganu | 52794a3 | 2024-02-02 15:35:18 +0530 | [diff] [blame] | 42 | /* GUID of the storage volume where the image is located */ |
| 43 | struct efi_guid location_guid; |
Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 44 | |
Sughosh Ganu | 52794a3 | 2024-02-02 15:35:18 +0530 | [diff] [blame] | 45 | /* Properties of images with img_type_guid in the different FW banks */ |
| 46 | struct fwu_image_bank_info img_bank_info[NR_OF_FW_BANKS]; |
Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 47 | |
| 48 | } __packed; |
| 49 | |
Sughosh Ganu | 9a480a3 | 2024-02-01 12:47:13 +0530 | [diff] [blame] | 50 | /* Firmware Image descriptor */ |
| 51 | struct fwu_fw_store_descriptor { |
| 52 | |
| 53 | /* Number of Banks */ |
| 54 | uint8_t num_banks; |
| 55 | |
| 56 | /* Reserved */ |
| 57 | uint8_t reserved; |
| 58 | |
| 59 | /* Number of images per bank */ |
| 60 | uint16_t num_images; |
| 61 | |
| 62 | /* Size of image_entry(all banks) in bytes */ |
| 63 | uint16_t img_entry_size; |
| 64 | |
| 65 | /* Size of image bank info structure in bytes */ |
| 66 | uint16_t bank_info_entry_size; |
| 67 | |
| 68 | /* Array of fwu_image_entry structs */ |
| 69 | struct fwu_image_entry img_entry[NR_OF_IMAGES_IN_FW_BANK]; |
| 70 | |
| 71 | } __packed; |
| 72 | |
Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 73 | /* |
| 74 | * FWU metadata filled by the updater and consumed by TF-A for |
| 75 | * various purposes as below: |
| 76 | * 1. Get active FW bank. |
| 77 | * 2. Rollback to previous working FW bank. |
| 78 | * 3. Get properties of all images present in all banks. |
| 79 | */ |
| 80 | struct fwu_metadata { |
| 81 | |
| 82 | /* Metadata CRC value */ |
| 83 | uint32_t crc_32; |
| 84 | |
| 85 | /* Metadata version */ |
| 86 | uint32_t version; |
| 87 | |
| 88 | /* Bank index with which device boots */ |
| 89 | uint32_t active_index; |
| 90 | |
| 91 | /* Previous bank index with which device booted successfully */ |
| 92 | uint32_t previous_active_index; |
| 93 | |
Sughosh Ganu | 9a480a3 | 2024-02-01 12:47:13 +0530 | [diff] [blame] | 94 | /* Size of the entire metadata in bytes */ |
| 95 | uint32_t metadata_size; |
| 96 | |
| 97 | /* Offset of the image descriptor structure */ |
| 98 | uint16_t desc_offset; |
| 99 | |
| 100 | /* Reserved */ |
| 101 | uint16_t reserved1; |
| 102 | |
| 103 | /* Bank state */ |
| 104 | uint8_t bank_state[NR_OF_MAX_FW_BANKS]; |
| 105 | |
| 106 | /* Reserved */ |
| 107 | uint32_t reserved2; |
| 108 | |
| 109 | #if PSA_FWU_METADATA_FW_STORE_DESC |
Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 110 | /* Image entry information */ |
Sughosh Ganu | 9a480a3 | 2024-02-01 12:47:13 +0530 | [diff] [blame] | 111 | struct fwu_fw_store_descriptor fw_desc; |
| 112 | #endif |
Manish V Badarkhe | 2bb45ff | 2021-03-16 10:01:27 +0000 | [diff] [blame] | 113 | |
| 114 | } __packed; |
| 115 | |
| 116 | #endif /* FWU_METADATA_H */ |