efi_loader: EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tue, 16 Nov 2021 17:46:27 +0000 (18:46 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 20 Nov 2021 09:53:00 +0000 (10:53 +0100)
Implement the EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES event group
handling.

Add the definition of EFI_EVENT_GROUP_AFTER_READY_TO_BOOT.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
include/efi_api.h
lib/efi_loader/efi_boottime.c

index 41516cc..1e95656 100644 (file)
@@ -360,10 +360,15 @@ struct efi_runtime_services {
 };
 
 /* EFI event group GUID definitions */
+
 #define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \
        EFI_GUID(0x27abf055, 0xb1b8, 0x4c26, 0x80, 0x48, \
                 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf)
 
+#define EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES \
+       EFI_GUID(0x8be0e274, 0x3970, 0x4b44, 0x80, 0xc5, \
+                0x1a, 0xb9, 0x50, 0x2f, 0x3b, 0xfc)
+
 #define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \
        EFI_GUID(0x13fa7698, 0xc831, 0x49c7, 0x87, 0xea, \
                 0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96)
@@ -376,6 +381,10 @@ struct efi_runtime_services {
        EFI_GUID(0x7ce88fb3, 0x4bd7, 0x4679, 0x87, 0xa8, \
                 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b)
 
+#define EFI_EVENT_GROUP_AFTER_READY_TO_BOOT \
+       EFI_GUID(0x3a2a00ad, 0x98b9, 0x4cdf, 0xa4, 0x78, \
+                0x70, 0x27, 0x77, 0xf1, 0xc1, 0xb)
+
 #define EFI_EVENT_GROUP_RESET_SYSTEM \
        EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \
                 0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b)
index 1823990..6fdd0ef 100644 (file)
@@ -71,6 +71,9 @@ const efi_guid_t efi_guid_driver_binding_protocol =
 /* event group ExitBootServices() invoked */
 const efi_guid_t efi_guid_event_group_exit_boot_services =
                        EFI_EVENT_GROUP_EXIT_BOOT_SERVICES;
+/* event group before ExitBootServices() invoked */
+const efi_guid_t efi_guid_event_group_before_exit_boot_services =
+                       EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES;
 /* event group SetVirtualAddressMap() invoked */
 const efi_guid_t efi_guid_event_group_virtual_address_change =
                        EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE;
@@ -2123,6 +2126,16 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
        if (!systab.boottime)
                goto out;
 
+       /* Notify EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES event group. */
+       list_for_each_entry(evt, &efi_events, link) {
+               if (evt->group &&
+                   !guidcmp(evt->group,
+                            &efi_guid_event_group_before_exit_boot_services)) {
+                       efi_signal_event(evt);
+                       break;
+               }
+       }
+
        /* Stop all timer related activities */
        timers_enabled = false;