blob: 5cac3807f2414c69541f97d2f9a130e04e4e42ec [file] [log] [blame]
Julian Hall685ee962023-01-05 14:31:45 +00001/*
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>
15#include <protocols/common/osf/uuid.h>
16#include "metadata.h"
17
18/* Bank state definitions */
19#define FWU_METADATA_V2_NUM_BANK_STATES (4)
20#define FWU_METADATA_V2_BANK_STATE_INVALID (0xff)
21#define FWU_METADATA_V2_BANK_STATE_VALID (0xfe)
22#define FWU_METADATA_V2_BANK_STATE_ACCEPTED (0xfc)
23
24/*
25 * Version 2 FWU metadata data structure (mandatory)
26 *
27 * The metadata structure is variable length. The actual length is determined
28 * from the metadata_size member.
29 */
30struct __attribute__ ((__packed__)) fwu_metadata {
31
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];
52
53};
54
55/* Properties of image in a bank */
56struct __attribute__ ((__packed__)) fwu_img_bank_info {
57
58 /* UUID of the image in this bank */
59 uint8_t img_uuid[OSF_UUID_OCTET_LEN];
60
61 /* [0]: bit describing the image acceptance status –
62 * 1 means the image is accepted
63 * [31:1]: MBZ
64 */
65 uint32_t accepted;
66
67 /* reserved (MBZ) */
68 uint32_t reserved;
69
70};
71
72/* Image entry information */
73struct __attribute__ ((__packed__)) fwu_image_entry {
74
75 /* UUID identifying the image type */
76 uint8_t img_type_uuid[OSF_UUID_OCTET_LEN];
77
78 /* UUID of the storage volume where the image is located (e.g. a disk UUID) */
79 uint8_t location_uuid[OSF_UUID_OCTET_LEN];
80
81 /* Per-bank info related to the image */
82 struct fwu_img_bank_info img_bank_info[FWU_METADATA_NUM_BANKS];
83
84};
85
86/*
87 * Firmware store descriptor
88 *
89 * FWU metadata may optionally include a description of the firmware store
90 * to direct the bootloader during boot. If a bootloader uses an alternative
91 * method to determine where to boot from, the fw_store_desc structure is
92 * not required. The fw_store_desc is assumed to be present if metadata_size
93 * > header_size.
94 */
95struct __attribute__ ((__packed__)) fwu_fw_store_desc {
96
97 /* Number of banks */
98 uint8_t num_banks;
99
100 /* Number of images listed in the img_entry array */
101 uint16_t num_images;
102
103 /* The size of the img_entry data structure */
104 uint16_t img_entry_size;
105
106 /* The size of bytes of the bank_entry data structure */
107 uint16_t bank_entry_size;
108
109 /* Array of image_entry structures */
110 struct fwu_image_entry img_entry[];
111};
112
113#endif /* FWU_PROTO_METADATA_V2_H */