blob: d2521f39b42e33e2c2e61dc92c947176382d0d54 [file] [log] [blame]
Sughosh Ganu0f9399a2022-10-21 18:15:55 +05301/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright (c) 2022, Linaro Limited
4 */
5
6#if !defined _FWU_MDATA_H_
7#define _FWU_MDATA_H_
8
Rui Miguel Silva46b74412023-06-12 09:09:15 +01009#include <linux/compiler_attributes.h>
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053010#include <efi.h>
11
12/**
13 * struct fwu_image_bank_info - firmware image information
Sughosh Ganu55c17de2024-03-22 16:27:18 +053014 * @image_guid: Guid value of the image in this bank
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053015 * @accepted: Acceptance status of the image
16 * @reserved: Reserved
17 *
18 * The structure contains image specific fields which are
19 * used to identify the image and to specify the image's
20 * acceptance status
21 */
22struct fwu_image_bank_info {
Sughosh Ganu55c17de2024-03-22 16:27:18 +053023 efi_guid_t image_guid;
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053024 uint32_t accepted;
25 uint32_t reserved;
Rui Miguel Silva46b74412023-06-12 09:09:15 +010026} __packed;
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053027
28/**
29 * struct fwu_image_entry - information for a particular type of image
Sughosh Ganu55c17de2024-03-22 16:27:18 +053030 * @image_type_guid: Guid value for identifying the image type
31 * @location_guid: Guid of the storage volume where the image is located
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053032 * @img_bank_info: Array containing properties of images
33 *
34 * This structure contains information on various types of updatable
35 * firmware images. Each image type then contains an array of image
36 * information per bank.
37 */
38struct fwu_image_entry {
Sughosh Ganu55c17de2024-03-22 16:27:18 +053039 efi_guid_t image_type_guid;
40 efi_guid_t location_guid;
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053041 struct fwu_image_bank_info img_bank_info[CONFIG_FWU_NUM_BANKS];
Rui Miguel Silva46b74412023-06-12 09:09:15 +010042} __packed;
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053043
44/**
Sughosh Ganu55c17de2024-03-22 16:27:18 +053045 * struct fwu_fw_store_desc - FWU updatable image information
46 * @num_banks: Number of firmware banks
47 * @num_images: Number of images per bank
48 * @img_entry_size: The size of the img_entry array
49 * @bank_info_entry_size: The size of the img_bank_info array
50 * @img_entry: Array of image entries each giving information on a image
51 *
52 * This image descriptor structure contains information on the number of
53 * updatable banks and images per bank. It also gives the total sizes of
54 * the fwu_image_entry and fwu_image_bank_info arrays. This structure is
55 * only present in version 2 of the metadata structure.
56 */
57struct fwu_fw_store_desc {
58 uint8_t num_banks;
59 uint8_t reserved;
60 uint16_t num_images;
61 uint16_t img_entry_size;
62 uint16_t bank_info_entry_size;
63
64 struct fwu_image_entry img_entry[CONFIG_FWU_NUM_IMAGES_PER_BANK];
65} __packed;
66
67#if defined(CONFIG_FWU_MDATA_V1)
68/**
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053069 * struct fwu_mdata - FWU metadata structure for multi-bank updates
70 * @crc32: crc32 value for the FWU metadata
71 * @version: FWU metadata version
72 * @active_index: Index of the bank currently used for booting images
73 * @previous_active_inde: Index of the bank used before the current bank
74 * being used for booting
75 * @img_entry: Array of information on various firmware images that can
76 * be updated
77 *
78 * This structure is used to store all the needed information for performing
79 * multi bank updates on the platform. This contains info on the bank being
80 * used to boot along with the information needed for identification of
81 * individual images
82 */
83struct fwu_mdata {
84 uint32_t crc32;
85 uint32_t version;
86 uint32_t active_index;
87 uint32_t previous_active_index;
88
89 struct fwu_image_entry img_entry[CONFIG_FWU_NUM_IMAGES_PER_BANK];
Rui Miguel Silva46b74412023-06-12 09:09:15 +010090} __packed;
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053091
Sughosh Ganu55c17de2024-03-22 16:27:18 +053092#else /* CONFIG_FWU_MDATA_V1 */
93/**
94 * struct fwu_mdata - FWU metadata structure for multi-bank updates
95 * @crc32: crc32 value for the FWU metadata
96 * @version: FWU metadata version
97 * @active_index: Index of the bank currently used for booting images
98 * @previous_active_inde: Index of the bank used before the current bank
99 * being used for booting
100 * @metadata_size: Size of the entire metadata structure, including the
101 * image descriptors
102 * @desc_offset: The offset from the start of this structure where the
103 * image descriptor structure starts. 0 if absent
104 * @bank_state: State of each bank, valid, invalid or accepted
105 * @fw_desc: The structure describing the FWU updatable images
106 *
107 * This is the top level structure used to store all information for performing
108 * multi bank updates on the platform. This contains info on the bank being
109 * used to boot along with the information on state of individual banks.
110 */
111struct fwu_mdata {
112 uint32_t crc32;
113 uint32_t version;
114 uint32_t active_index;
115 uint32_t previous_active_index;
116 uint32_t metadata_size;
117 uint16_t desc_offset;
118 uint16_t reserved1;
119 uint8_t bank_state[4];
120 uint32_t reserved2;
121
122 // struct fwu_fw_store_desc fw_desc;
123} __packed;
124
125#endif /* CONFIG_FWU_MDATA_V1 */
126
Sughosh Ganu0f9399a2022-10-21 18:15:55 +0530127#endif /* _FWU_MDATA_H_ */