summaryrefslogtreecommitdiff
path: root/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-efi_firmware-add-get_image_info-for-corstone1000.patch
blob: 7087315e45b87be6824be71b4bf46f40d260aee9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
From d8f79ab37bae283599e40018055ff9d5648fb647 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 17 Dec 2021 19:50:25 +0000
Subject: [PATCH 17/42] efi_firmware: add get_image_info for corstone1000

This change is to populate get_image_info which eventually
will be populated in ESRT table

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Pending [Not submitted to upstream yet]
---
 lib/efi_loader/efi_firmware.c | 72 ++++++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index 93e2b01c07..0a38a96351 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -18,11 +18,69 @@
 
 #define FMP_PAYLOAD_HDR_SIGNATURE	SIGNATURE_32('M', 'S', 'S', '1')
 
+#if CONFIG_IS_ENABLED(TARGET_CORSTONE1000)
+#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \
+	EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \
+		 0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f)
+
+ const efi_guid_t efi_firmware_image_type_uboot_raw =
+				EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;
+
+static efi_status_t efi_corstone1000_img_info_get (
+	efi_uintn_t *image_info_size,
+	struct efi_firmware_image_descriptor *image_info,
+	u32 *descriptor_version,
+	u8 *descriptor_count,
+	efi_uintn_t *descriptor_size,
+	u32 *package_version,
+	u16 **package_version_name,
+	const efi_guid_t *image_type)
+{
+	int i = 0;
+
+	*image_info_size = sizeof(*image_info);
+	*descriptor_version = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
+	*descriptor_count = 1;//dfu_num;
+	*descriptor_size = sizeof(*image_info);
+	if (package_version)
+		*package_version = 0xffffffff; /* not supported */
+	if(package_version_name)
+		*package_version_name = NULL; /* not supported */
+
+	if(image_info == NULL) {
+		log_warning("image_info is null\n");
+		return EFI_BUFFER_TOO_SMALL;
+	}
+
+	image_info[i].image_index = i;
+	image_info[i].image_type_id = *image_type;
+	image_info[i].image_id = 0;
+	image_info[i].image_id_name = "wic";
+	image_info[i].version = 1;
+	image_info[i].version_name = NULL;
+	image_info[i].size = 0x1000;
+	image_info[i].attributes_supported = IMAGE_ATTRIBUTE_IMAGE_UPDATABLE |
+					     IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED;
+	image_info[i].attributes_setting = IMAGE_ATTRIBUTE_IMAGE_UPDATABLE;
+	/* Check if the capsule authentication is enabled */
+	if (IS_ENABLED(CONFIG_EFI_CAPSULE_AUTHENTICATE))
+		image_info[0].attributes_setting |=
+			IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED;
+	image_info[i].lowest_supported_image_version = 0;
+	image_info[i].last_attempt_version = 0;
+	image_info[i].last_attempt_status = LAST_ATTEMPT_STATUS_SUCCESS;
+	image_info[i].hardware_instance = 1;
+	image_info[i].dependencies = NULL;
+
+	return EFI_SUCCESS;
+}
+#endif
+
 /**
  * struct fmp_payload_header - EDK2 header for the FMP payload
  *
  * This structure describes the header which is preprended to the
- * FMP payload by the edk2 capsule generation scripts.
+ * FMP payload by the edk1 capsule generation scripts.
  *
  * @signature:			Header signature used to identify the header
  * @header_size:		Size of the structure
@@ -286,10 +344,18 @@ efi_status_t EFIAPI efi_firmware_get_image_info(
 	     !descriptor_size || !package_version || !package_version_name))
 		return EFI_EXIT(EFI_INVALID_PARAMETER);
 
+#if CONFIG_IS_ENABLED(TARGET_CORSTONE1000)
+	ret = efi_corstone1000_img_info_get(image_info_size, image_info,
+			       descriptor_version, descriptor_count,
+			       descriptor_size,
+			       package_version, package_version_name,
+			       &efi_firmware_image_type_uboot_raw);
+#else
 	ret = efi_fill_image_desc_array(image_info_size, image_info,
 					descriptor_version, descriptor_count,
 					descriptor_size, package_version,
 					package_version_name);
+#endif
 
 	return EFI_EXIT(ret);
 }
@@ -415,6 +481,10 @@ efi_status_t EFIAPI efi_firmware_raw_set_image(
 		}
 	}
 
+#if CONFIG_IS_ENABLED(TARGET_CORSTONE1000)
+	return EFI_EXIT(EFI_SUCCESS);
+#endif
+
 	if (dfu_write_by_alt(image_index - 1, (void *)image, image_size,
 			     NULL, NULL))
 		return EFI_EXIT(EFI_DEVICE_ERROR);
-- 
2.25.1