UEFI specification 2.9 introduced a new event group
EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES. Serve the events.

Signed-off-by: Heinrich Schuchardt <xypron.g...@gmx.de>
---
 include/efi_api.h             |  4 ++++
 lib/efi_loader/efi_boottime.c | 17 ++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index e854a8b3a1..d1abc6df11 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -364,6 +364,10 @@ struct efi_runtime_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)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index f0283b539e..bdf787b25a 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -71,6 +71,11 @@ 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,7 +2128,17 @@ static efi_status_t EFIAPI 
efi_exit_boot_services(efi_handle_t image_handle,
        /* Stop all timer related activities */
        timers_enabled = false;

-       /* Add related events to the event group */
+       /* Notify EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES. */
+       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;
+               }
+       }
+
+       /* Add related events to EFI_EVENT_GROUP_EXIT_BOOT_SERVICES */
        list_for_each_entry(evt, &efi_events, link) {
                if (evt->type == EVT_SIGNAL_EXIT_BOOT_SERVICES)
                        evt->group = &efi_guid_event_group_exit_boot_services;
--
2.30.2

Reply via email to