Julian Hall | 685ee96 | 2023-01-05 14:31:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 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_V2_H |
| 12 | #define FWU_PROTO_METADATA_V2_H |
| 13 | |
| 14 | #include <stdint.h> |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 15 | |
Julian Hall | 685ee96 | 2023-01-05 14:31:45 +0000 | [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 | 685ee96 | 2023-01-05 14:31:45 +0000 | [diff] [blame] | 18 | |
| 19 | /* Bank state definitions */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 20 | #define FWU_METADATA_V2_NUM_BANK_STATES (4) |
| 21 | #define FWU_METADATA_V2_BANK_STATE_INVALID (0xff) |
| 22 | #define FWU_METADATA_V2_BANK_STATE_VALID (0xfe) |
| 23 | #define FWU_METADATA_V2_BANK_STATE_ACCEPTED (0xfc) |
Julian Hall | 685ee96 | 2023-01-05 14:31:45 +0000 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Version 2 FWU metadata data structure (mandatory) |
| 27 | * |
| 28 | * The metadata structure is variable length. The actual length is determined |
| 29 | * from the metadata_size member. |
| 30 | */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 31 | struct __attribute__((__packed__)) fwu_metadata { |
Julian Hall | 685ee96 | 2023-01-05 14:31:45 +0000 | [diff] [blame] | 32 | /* Metadata CRC value */ |
| 33 | uint32_t crc_32; |
| 34 | |
| 35 | /* Metadata version */ |
| 36 | uint32_t version; |
| 37 | |
| 38 | /* The overall metadata size */ |
| 39 | uint32_t metadata_size; |
| 40 | |
| 41 | /* The size in bytes of the fixed size header */ |
| 42 | uint16_t header_size; |
| 43 | |
| 44 | /* Active bank index as directed by update agent [0..n] */ |
| 45 | uint8_t active_index; |
| 46 | |
| 47 | /* Previous active bank index [0..n] */ |
| 48 | uint8_t previous_active_index; |
| 49 | |
| 50 | /* Bank state bitmaps */ |
| 51 | uint8_t bank_state[FWU_METADATA_V2_NUM_BANK_STATES]; |
Julian Hall | 685ee96 | 2023-01-05 14:31:45 +0000 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | /* Properties of image in a bank */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 55 | struct __attribute__((__packed__)) fwu_img_bank_info { |
Julian Hall | 685ee96 | 2023-01-05 14:31:45 +0000 | [diff] [blame] | 56 | /* UUID of the image in this bank */ |
| 57 | uint8_t img_uuid[OSF_UUID_OCTET_LEN]; |
| 58 | |
| 59 | /* [0]: bit describing the image acceptance status – |
| 60 | * 1 means the image is accepted |
| 61 | * [31:1]: MBZ |
| 62 | */ |
| 63 | uint32_t accepted; |
| 64 | |
| 65 | /* reserved (MBZ) */ |
| 66 | uint32_t reserved; |
Julian Hall | 685ee96 | 2023-01-05 14:31:45 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | /* Image entry information */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 70 | struct __attribute__((__packed__)) fwu_image_entry { |
Julian Hall | 685ee96 | 2023-01-05 14:31:45 +0000 | [diff] [blame] | 71 | /* UUID identifying the image type */ |
| 72 | uint8_t img_type_uuid[OSF_UUID_OCTET_LEN]; |
| 73 | |
| 74 | /* UUID of the storage volume where the image is located (e.g. a disk UUID) */ |
| 75 | uint8_t location_uuid[OSF_UUID_OCTET_LEN]; |
| 76 | |
| 77 | /* Per-bank info related to the image */ |
| 78 | struct fwu_img_bank_info img_bank_info[FWU_METADATA_NUM_BANKS]; |
Julian Hall | 685ee96 | 2023-01-05 14:31:45 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | /* |
| 82 | * Firmware store descriptor |
| 83 | * |
| 84 | * FWU metadata may optionally include a description of the firmware store |
| 85 | * to direct the bootloader during boot. If a bootloader uses an alternative |
| 86 | * method to determine where to boot from, the fw_store_desc structure is |
| 87 | * not required. The fw_store_desc is assumed to be present if metadata_size |
| 88 | * > header_size. |
| 89 | */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 90 | struct __attribute__((__packed__)) fwu_fw_store_desc { |
Julian Hall | 685ee96 | 2023-01-05 14:31:45 +0000 | [diff] [blame] | 91 | /* Number of banks */ |
| 92 | uint8_t num_banks; |
| 93 | |
| 94 | /* Number of images listed in the img_entry array */ |
| 95 | uint16_t num_images; |
| 96 | |
| 97 | /* The size of the img_entry data structure */ |
| 98 | uint16_t img_entry_size; |
| 99 | |
| 100 | /* The size of bytes of the bank_entry data structure */ |
| 101 | uint16_t bank_entry_size; |
| 102 | |
| 103 | /* Array of image_entry structures */ |
| 104 | struct fwu_image_entry img_entry[]; |
| 105 | }; |
| 106 | |
| 107 | #endif /* FWU_PROTO_METADATA_V2_H */ |