\r
**/\r
\r
+\r
+EFI_EVENT _mDriverExitBootServicesNotifyEvent;\r
+\r
/**\r
Unload function that is registered in the LoadImage protocol. It un-installs\r
protocols produced and deallocates pool used by the driver. Called by the core\r
// unloaded, and the library destructors should not be called\r
//\r
if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Close our ExitBootServices () notify function\r
+ //\r
+ if (_gDriverExitBootServicesEvent[0] != NULL) {\r
+ Status = gBS->CloseEvent (_mDriverExitBootServicesNotifyEvent);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
ProcessLibraryDestructorList (ImageHandle, gST);\r
}\r
\r
return Status;\r
}\r
\r
+\r
+/**\r
+ Notification Entry of ExitBootService event. In the entry, all notifications in _gDriverExitBootServicesEvent[] \r
+ would be invoked.\r
+\r
+ @param Event The Event that is being processed.\r
+ @param Context Event Context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+_DriverExitBootServices (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_EVENT_NOTIFY ChildNotifyEventHandler;\r
+ UINTN Index;\r
+\r
+ for (Index = 0; _gDriverExitBootServicesEvent[Index] != NULL; Index++) {\r
+ ChildNotifyEventHandler = _gDriverExitBootServicesEvent[Index];\r
+ ChildNotifyEventHandler (Event, NULL);\r
+ }\r
+}\r
+\r
/**\r
Enrty point to DXE Driver.\r
\r
//\r
ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
\r
+ //\r
+ // Register our ExitBootServices () notify function\r
+ //\r
+ if (_gDriverExitBootServicesEvent[0] != NULL) {\r
+ Status = gBS->CreateEvent (\r
+ EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r
+ EFI_TPL_NOTIFY,\r
+ _DriverExitBootServices,\r
+ NULL,\r
+ &_mDriverExitBootServicesNotifyEvent\r
+ );\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
//\r
// Install unload handler...\r
//\r
// If all of the drivers returned errors, then invoke all of the library destructors\r
//\r
if (EFI_ERROR (Status)) {\r
+ //\r
+ // Close our ExitBootServices () notify function\r
+ //\r
+ if (_gDriverExitBootServicesEvent[0] != NULL) {\r
+ Status = gBS->CloseEvent (_mDriverExitBootServicesNotifyEvent);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
ProcessLibraryDestructorList (ImageHandle, SystemTable);\r
}\r
\r