]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: add return to efibootmgr event group
authorMasahisa Kojima <masahisa.kojima@linaro.org>
Fri, 10 Nov 2023 04:25:39 +0000 (13:25 +0900)
committerIlias Apalodimas <ilias.apalodimas@linaro.org>
Sat, 18 Nov 2023 08:08:09 +0000 (10:08 +0200)
When the image loaded by efibootmgr returns, efibootmgr
needs to clean the resources. Adding the event of returning
to efibootmgr is useful to simplify the implementation.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
cmd/bootefi.c
include/efi_api.h
include/efi_loader.h
lib/efi_loader/efi_boottime.c

index 20e5c94a33a428cac5be0bbadd4e90d080128d85..4d74969ad6211fa9d6e2b2e3a1358db0750b9b5b 100644 (file)
@@ -356,6 +356,7 @@ static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options)
        efi_status_t ret;
        efi_uintn_t exit_data_size = 0;
        u16 *exit_data = NULL;
+       struct efi_event *evt;
 
        /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */
        switch_to_non_secure_mode();
@@ -394,6 +395,17 @@ out:
                        log_err("Failed to remove loadfile2 for initrd\n");
        }
 
+       /* Notify EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR event group. */
+       list_for_each_entry(evt, &efi_events, link) {
+               if (evt->group &&
+                   !guidcmp(evt->group,
+                            &efi_guid_event_group_return_to_efibootmgr)) {
+                       efi_signal_event(evt);
+                       EFI_CALL(systab.boottime->close_event(evt));
+                       break;
+               }
+       }
+
        /* Control is returned to U-Boot, disable EFI watchdog */
        efi_set_watchdog(0);
 
index c2d69644679c27c72018442b3a6f1c514d5c8966..0e92cb8a7f69f7b77f2ae3492949f2bb86e008e2 100644 (file)
@@ -404,6 +404,9 @@ struct efi_runtime_services {
 #define EFI_EVENT_GROUP_RESET_SYSTEM \
        EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \
                 0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b)
+#define EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR \
+       EFI_GUID(0xb4a40fe6, 0x9149, 0x4f29, 0x94, 0x47, \
+                0x49, 0x38, 0x7a, 0x7f, 0xab, 0x87)
 
 /* EFI Configuration Table and GUID definitions */
 #define NULL_GUID \
index 1fd7b0b73c9541b337382bf324d0488640526410..664dae28f882fc5e8f84ba2da4ac45f6e2683cf7 100644 (file)
@@ -289,6 +289,8 @@ extern const efi_guid_t efi_guid_event_group_memory_map_change;
 extern const efi_guid_t efi_guid_event_group_ready_to_boot;
 /* event group ResetSystem() invoked (before ExitBootServices) */
 extern const efi_guid_t efi_guid_event_group_reset_system;
+/* event group return to efibootmgr */
+extern const efi_guid_t efi_guid_event_group_return_to_efibootmgr;
 /* GUID of the device tree table */
 extern const efi_guid_t efi_guid_fdt;
 extern const efi_guid_t efi_guid_loaded_image;
index f9b10a9763b849502d15d4ac53bdf5a71782c846..3767fa2db429a5cf3f53ebc74511ed7980e50b5b 100644 (file)
@@ -90,6 +90,9 @@ const efi_guid_t efi_guid_event_group_ready_to_boot =
 /* event group ResetSystem() invoked (before ExitBootServices) */
 const efi_guid_t efi_guid_event_group_reset_system =
                        EFI_EVENT_GROUP_RESET_SYSTEM;
+/* event group return to efibootmgr */
+const efi_guid_t efi_guid_event_group_return_to_efibootmgr =
+                       EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR;
 /* GUIDs of the Load File and Load File2 protocols */
 const efi_guid_t efi_guid_load_file_protocol = EFI_LOAD_FILE_PROTOCOL_GUID;
 const efi_guid_t efi_guid_load_file2_protocol = EFI_LOAD_FILE2_PROTOCOL_GUID;