blob: 7993681962c1a479e355596ef93513a9e9cb4bbe [file] [log] [blame]
Julian Hall685ee962023-01-05 14:31:45 +00001/*
Imre Kis630afa32024-07-15 12:01:55 +02002 * Copyright (c) 2023-2024, Arm Limited. All rights reserved.
Julian Hall685ee962023-01-05 14:31:45 +00003 *
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 Szing3c446242023-03-31 01:53:15 +020015
Julian Hall685ee962023-01-05 14:31:45 +000016#include "metadata.h"
Gyorgy Szing3c446242023-03-31 01:53:15 +020017#include "protocols/common/osf/uuid.h"
Julian Hall685ee962023-01-05 14:31:45 +000018
19/* Bank state definitions */
Gyorgy Szing3c446242023-03-31 01:53:15 +020020#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 Hall685ee962023-01-05 14:31:45 +000024
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 Szing3c446242023-03-31 01:53:15 +020031struct __attribute__((__packed__)) fwu_metadata {
Julian Hall685ee962023-01-05 14:31:45 +000032 /* Metadata CRC value */
33 uint32_t crc_32;
34
35 /* Metadata version */
36 uint32_t version;
37
Imre Kis630afa32024-07-15 12:01:55 +020038 /* Active bank index as directed by update agent [0..n] */
39 uint32_t active_index;
40
41 /* Previous active bank index [0..n] */
42 uint32_t previous_active_index;
43
Julian Hall685ee962023-01-05 14:31:45 +000044 /* The overall metadata size */
45 uint32_t metadata_size;
46
47 /* The size in bytes of the fixed size header */
Imre Kis630afa32024-07-15 12:01:55 +020048 uint16_t descriptor_offset;
Julian Hall685ee962023-01-05 14:31:45 +000049
Imre Kis630afa32024-07-15 12:01:55 +020050 uint16_t reserved_16;
Julian Hall685ee962023-01-05 14:31:45 +000051
52 /* Bank state bitmaps */
53 uint8_t bank_state[FWU_METADATA_V2_NUM_BANK_STATES];
Imre Kis630afa32024-07-15 12:01:55 +020054
55 uint32_t reserved_1c;
Julian Hall685ee962023-01-05 14:31:45 +000056};
57
58/* Properties of image in a bank */
Gyorgy Szing3c446242023-03-31 01:53:15 +020059struct __attribute__((__packed__)) fwu_img_bank_info {
Julian Hall685ee962023-01-05 14:31:45 +000060 /* UUID of the image in this bank */
61 uint8_t img_uuid[OSF_UUID_OCTET_LEN];
62
63 /* [0]: bit describing the image acceptance status –
64 * 1 means the image is accepted
65 * [31:1]: MBZ
66 */
67 uint32_t accepted;
68
69 /* reserved (MBZ) */
70 uint32_t reserved;
Julian Hall685ee962023-01-05 14:31:45 +000071};
72
73/* Image entry information */
Gyorgy Szing3c446242023-03-31 01:53:15 +020074struct __attribute__((__packed__)) fwu_image_entry {
Julian Hall685ee962023-01-05 14:31:45 +000075 /* 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];
Julian Hall685ee962023-01-05 14:31:45 +000083};
84
85/*
86 * Firmware store descriptor
87 *
88 * FWU metadata may optionally include a description of the firmware store
89 * to direct the bootloader during boot. If a bootloader uses an alternative
90 * method to determine where to boot from, the fw_store_desc structure is
91 * not required. The fw_store_desc is assumed to be present if metadata_size
92 * > header_size.
93 */
Gyorgy Szing3c446242023-03-31 01:53:15 +020094struct __attribute__((__packed__)) fwu_fw_store_desc {
Julian Hall685ee962023-01-05 14:31:45 +000095 /* Number of banks */
96 uint8_t num_banks;
97
Imre Kis630afa32024-07-15 12:01:55 +020098 uint8_t reserved_01;
99
Julian Hall685ee962023-01-05 14:31:45 +0000100 /* 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 */
Imre Kis630afa32024-07-15 12:01:55 +0200107 uint16_t bank_info_entry_size;
Julian Hall685ee962023-01-05 14:31:45 +0000108
109 /* Array of image_entry structures */
110 struct fwu_image_entry img_entry[];
111};
112
113#endif /* FWU_PROTO_METADATA_V2_H */