]> git.sur5r.net Git - u-boot/commitdiff
efi_loader: initalize EFI object list only once
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Wed, 19 Jul 2017 17:37:22 +0000 (19:37 +0200)
committerAlexander Graf <agraf@suse.de>
Mon, 24 Jul 2017 12:53:32 +0000 (14:53 +0200)
If several EFI applications are executed in sequence we want
to keep the content of the EFI object list.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
cmd/bootefi.c

index b6dedec463b0f5b0412861682cca8a1e2bad2cb8..9526f6c60d72d1d193b50caf80496238042af34b 100644 (file)
@@ -20,6 +20,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static uint8_t efi_obj_list_initalized;
+
 /*
  * When booting using the "bootefi" command, we don't know which
  * physical device the file came from. So we create a pseudo-device
@@ -104,6 +106,38 @@ static struct efi_object bootefi_device_obj = {
        },
 };
 
+/* Initialize and populate EFI object list */
+static void efi_init_obj_list(void)
+{
+       efi_obj_list_initalized = 1;
+
+       list_add_tail(&loaded_image_info_obj.link, &efi_obj_list);
+       list_add_tail(&bootefi_device_obj.link, &efi_obj_list);
+       efi_console_register();
+#ifdef CONFIG_PARTITIONS
+       efi_disk_register();
+#endif
+#if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO)
+       efi_gop_register();
+#endif
+#ifdef CONFIG_NET
+       void *nethandle = loaded_image_info.device_handle;
+       efi_net_register(&nethandle);
+
+       if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6))
+               loaded_image_info.device_handle = nethandle;
+       else
+               loaded_image_info.device_handle = bootefi_device_path;
+#endif
+#ifdef CONFIG_GENERATE_SMBIOS_TABLE
+       efi_smbios_register();
+#endif
+
+       /* Initialize EFI runtime services */
+       efi_reset_system_init();
+       efi_get_time_init();
+}
+
 static void *copy_fdt(void *fdt)
 {
        u64 fdt_size = fdt_totalsize(fdt);
@@ -223,32 +257,8 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt)
                return -ENOENT;
 
        /* Initialize and populate EFI object list */
-       INIT_LIST_HEAD(&efi_obj_list);
-       list_add_tail(&loaded_image_info_obj.link, &efi_obj_list);
-       list_add_tail(&bootefi_device_obj.link, &efi_obj_list);
-       efi_console_register();
-#ifdef CONFIG_PARTITIONS
-       efi_disk_register();
-#endif
-#if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO)
-       efi_gop_register();
-#endif
-#ifdef CONFIG_NET
-       void *nethandle = loaded_image_info.device_handle;
-       efi_net_register(&nethandle);
-
-       if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6))
-               loaded_image_info.device_handle = nethandle;
-       else
-               loaded_image_info.device_handle = bootefi_device_path;
-#endif
-#ifdef CONFIG_GENERATE_SMBIOS_TABLE
-       efi_smbios_register();
-#endif
-
-       /* Initialize EFI runtime services */
-       efi_reset_system_init();
-       efi_get_time_init();
+       if (!efi_obj_list_initalized)
+               efi_init_obj_list();
 
        /* Call our payload! */
        debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);