]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: add the number of image entries in efi_capsule_update_info
authorMasahisa Kojima <masahisa.kojima@linaro.org>
Wed, 7 Jun 2023 05:41:51 +0000 (14:41 +0900)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 8 Jun 2023 07:20:36 +0000 (09:20 +0200)
The number of image array entries global variable is required
to support EFI capsule update. This information is exposed as a
num_image_type_guids variable, but this information
should be included in the efi_capsule_update_info structure.

This commit adds the num_images member in the
efi_capsule_update_info structure. All board files supporting
EFI capsule update are updated.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
15 files changed:
arch/arm/mach-rockchip/board.c
board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c
board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
board/emulation/qemu-arm/qemu-arm.c
board/kontron/pitx_imx8m/pitx_imx8m.c
board/kontron/sl-mx8mm/sl-mx8mm.c
board/kontron/sl28/sl28.c
board/rockchip/evb_rk3399/evb-rk3399.c
board/sandbox/sandbox.c
board/socionext/developerbox/developerbox.c
board/st/stm32mp1/stm32mp1.c
board/xilinx/common/board.c
include/efi_loader.h
lib/efi_loader/efi_firmware.c
lib/fwu_updates/fwu.c

index f1f70c81d0ca6585f43425ce4131994c5e194288..8daa74b3eb76485b10b12d6f2277e85bc2b91fd2 100644 (file)
@@ -41,7 +41,7 @@ static bool updatable_image(struct disk_partition *info)
        uuid_str_to_bin(info->type_guid, image_type_guid.b,
                        UUID_STR_FORMAT_GUID);
 
-       for (i = 0; i < num_image_type_guids; i++) {
+       for (i = 0; i < update_info.num_images; i++) {
                if (!guidcmp(&fw_images[i].image_type_id, &image_type_guid)) {
                        ret = true;
                        break;
@@ -59,7 +59,7 @@ static void set_image_index(struct disk_partition *info, int index)
        uuid_str_to_bin(info->type_guid, image_type_guid.b,
                        UUID_STR_FORMAT_GUID);
 
-       for (i = 0; i < num_image_type_guids; i++) {
+       for (i = 0; i < update_info.num_images; i++) {
                if (!guidcmp(&fw_images[i].image_type_id, &image_type_guid)) {
                        fw_images[i].image_index = index;
                        break;
index 466174679e8d5d73d15eea3d3e58fcf668c01e5d..b79a2380aa5b63cf38cde3ff24a3a43d450472d1 100644 (file)
@@ -54,10 +54,10 @@ struct efi_fw_image fw_images[] = {
 
 struct efi_capsule_update_info update_info = {
        .dfu_string = "mmc 2=flash-bin raw 0 0x1B00 mmcpart 1",
+       .num_images = ARRAY_SIZE(fw_images),
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ARRAY_SIZE(fw_images);
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
 
index b373e45df951f7905ab2fed832f8c4b8d835df2e..af070ec315c4d1a342e99fa2bfda7b251aed8fcc 100644 (file)
@@ -50,10 +50,10 @@ struct efi_fw_image fw_images[] = {
 
 struct efi_capsule_update_info update_info = {
        .dfu_string = "mmc 2=flash-bin raw 0x42 0x1D00 mmcpart 1",
+       .num_images = ARRAY_SIZE(fw_images),
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ARRAY_SIZE(fw_images);
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
 int board_phys_sdram_size(phys_size_t *size)
index 34ed3e8ae63030ea6d012c5c811f1729db92a6a0..dfea0d92a3c8d434261c8e204f256cc0e8b1d32c 100644 (file)
@@ -47,10 +47,10 @@ struct efi_fw_image fw_images[] = {
 };
 
 struct efi_capsule_update_info update_info = {
+       .num_images = ARRAY_SIZE(fw_images)
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ARRAY_SIZE(fw_images);
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
 static struct mm_region qemu_arm64_mem_map[] = {
index fcda86bc1b1c1e207e32423971629aab699713b7..4548e7c1dff90d63ba120b0dedbe7e9ee21cfdf7 100644 (file)
@@ -43,10 +43,10 @@ struct efi_fw_image fw_images[] = {
 
 struct efi_capsule_update_info update_info = {
        .dfu_string = "mmc 0=flash-bin raw 0x42 0x1000 mmcpart 1",
+       .num_images = ARRAY_SIZE(fw_images),
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ARRAY_SIZE(fw_images);
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
 int board_early_init_f(void)
index 250195694ba5aae938f53c775b514946a7c53d6c..ddb509eb66bfadf0d28606b89ea6aa0f6c261f94 100644 (file)
@@ -29,10 +29,10 @@ struct efi_fw_image fw_images[] = {
 
 struct efi_capsule_update_info update_info = {
        .dfu_string = "sf 0:0=flash-bin raw 0x400 0x1f0000",
+       .num_images = ARRAY_SIZE(fw_images),
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ARRAY_SIZE(fw_images);
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
 int board_phys_sdram_size(phys_size_t *size)
index 89948e087f1024817ad2e15d3a12194e3e82faaf..4ab221c12bf6ef777ee13417d2978c9778284195 100644 (file)
@@ -40,10 +40,10 @@ struct efi_fw_image fw_images[] = {
 struct efi_capsule_update_info update_info = {
        .dfu_string = "sf 0:0=u-boot-bin raw 0x210000 0x1d0000;"
                        "u-boot-env raw 0x3e0000 0x20000",
+       .num_images = ARRAY_SIZE(fw_images),
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ARRAY_SIZE(fw_images);
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
 int board_early_init_f(void)
index c99ffdd75e803f11c8b299493004fa315476353d..3c773d0930cc2b1bf8b1a0dedcb951e72392b56a 100644 (file)
 static struct efi_fw_image fw_images[ROCKPI4_UPDATABLE_IMAGES] = {0};
 
 struct efi_capsule_update_info update_info = {
+       .num_images = ROCKPI4_UPDATABLE_IMAGES,
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ROCKPI4_UPDATABLE_IMAGES;
 #endif
 
 #ifndef CONFIG_SPL_BUILD
index 2e44bdf0df3e392c12f5260ae0deeddf63c0d098..c7b6cb78fff58895bb9f9c8e0aa5b0414ff38dfc 100644 (file)
@@ -67,10 +67,10 @@ struct efi_fw_image fw_images[] = {
 struct efi_capsule_update_info update_info = {
        .dfu_string = "sf 0:0=u-boot-bin raw 0x100000 0x50000;"
                "u-boot-env raw 0x150000 0x200000",
+       .num_images = ARRAY_SIZE(fw_images),
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ARRAY_SIZE(fw_images);
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
index 16e14d4f7f56db2a982358cce8876830c084b5fb..d92e1d09627165100f5018755a1329eb5b579b9b 100644 (file)
@@ -41,10 +41,10 @@ struct efi_capsule_update_info update_info = {
        .dfu_string = "mtd nor1=u-boot.bin raw 200000 100000;"
                        "fip.bin raw 180000 78000;"
                        "optee.bin raw 500000 100000",
+       .num_images = ARRAY_SIZE(fw_images),
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ARRAY_SIZE(fw_images);
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
 static struct mm_region sc2a11_mem_map[] = {
index 1a1b1844c8c08040ade76d9b01c3fcd2caa153c2..5b28ccd32e60fd408034898139e8b2e292419f78 100644 (file)
 struct efi_fw_image fw_images[1];
 
 struct efi_capsule_update_info update_info = {
+       .num_images = ARRAY_SIZE(fw_images),
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ARRAY_SIZE(fw_images);
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
 int board_early_init_f(void)
index d071ebfb9cc2a14c33e3cafb57e8cb6fafdac252..0328d68e751223d8c0fbb2d2eeb7d6b97c6ded74 100644 (file)
@@ -52,10 +52,10 @@ struct efi_fw_image fw_images[] = {
 };
 
 struct efi_capsule_update_info update_info = {
+       .num_images = ARRAY_SIZE(fw_images),
        .images = fw_images,
 };
 
-u8 num_image_type_guids = ARRAY_SIZE(fw_images);
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
 #define EEPROM_HEADER_MAGIC            0xdaaddeed
index b395eef9e790a984ef1d51c437d5064560269713..941d63467ce2eeaf7b1b465085ec9460afe3f064 100644 (file)
@@ -1078,15 +1078,16 @@ struct efi_fw_image {
  * platforms which enable capsule updates
  *
  * @dfu_string:                String used to populate dfu_alt_info
+ * @num_images:                The number of images array entries
  * @images:            Pointer to an array of updatable images
  */
 struct efi_capsule_update_info {
        const char *dfu_string;
+       int num_images;
        struct efi_fw_image *images;
 };
 
 extern struct efi_capsule_update_info update_info;
-extern u8 num_image_type_guids;
 
 /**
  * Install the ESRT system table.
index 93e2b01c07a6c62c1ad6877febeb5cc120228f7e..cc650e1443d96e30d5556d568647f06c2ea8a72e 100644 (file)
@@ -131,7 +131,7 @@ static efi_status_t efi_fill_image_desc_array(
        struct efi_fw_image *fw_array;
        int i;
 
-       total_size = sizeof(*image_info) * num_image_type_guids;
+       total_size = sizeof(*image_info) * update_info.num_images;
 
        if (*image_info_size < total_size) {
                *image_info_size = total_size;
@@ -141,13 +141,13 @@ static efi_status_t efi_fill_image_desc_array(
        *image_info_size = total_size;
 
        fw_array = update_info.images;
-       *descriptor_count = num_image_type_guids;
+       *descriptor_count = update_info.num_images;
        *descriptor_version = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
        *descriptor_size = sizeof(*image_info);
        *package_version = 0xffffffff; /* not supported */
        *package_version_name = NULL; /* not supported */
 
-       for (i = 0; i < num_image_type_guids; i++) {
+       for (i = 0; i < update_info.num_images; i++) {
                image_info[i].image_index = fw_array[i].image_index;
                image_info[i].image_type_id = fw_array[i].image_type_id;
                image_info[i].image_id = fw_array[i].image_index;
index 5313d0730202af37564e5779bb57c958cd9a96c9..3b1785e7b1e8d64a4481215bb3c4558c8b3ce158 100644 (file)
@@ -151,7 +151,7 @@ static int fwu_get_image_type_id(u8 *image_index, efi_guid_t *image_type_id)
 
        index = *image_index;
        image = update_info.images;
-       for (i = 0; i < num_image_type_guids; i++) {
+       for (i = 0; i < update_info.num_images; i++) {
                if (index == image[i].image_index) {
                        guidcpy(image_type_id, &image[i].image_type_id);
                        return 0;