8.7 Handler for EVT_SIGNAL_EXIT_BOOT_SERVICES

Some DXE drivers need to place their controllers in a quiescent state or perform other controller-specific actions at the time that an operating system is about to take full control of the platform. In this case, the DXE driver should create a signal type event that is notified when gBS->ExitBootServices() is called by the EFI OS Loader.

Note: The notification function for this event is not allowed to use the Memory Allocation Services, or call any functions that use the Memory Allocation Services, and should only call functions that are known not to use Memory Allocation Services, because these services modify the current memory map.

The template code for the notification function and event registration is as follows:

VOID
EFIAPI
NotifyExitBootServices (
IN EFI_EVENT Event,
IN VOID *Context
)
{
//
// Put driver-specific actions here.
// No UEFI Memory Service may be used directly or indirectly.
//
}
EFI_STATUS
EFIAPI
SampleDriverInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_EVENT ExitBootServicesEvent;
//
// TODO: Other initialization of entry point can be added here.
//
//
// Here is just the sample of registration of
// EVT_SIGNAL_EXIT_BOOT_SERVICES
//
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
NotifyExitBootServices,
NULL, // Parameter Context can be passed here
&gEfiEventExitBootServicesGuid,
&ExitBootServicesEvent
);
ASSERT_EFI_STATUS (Status);
}