]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDriverEntryPoint/DriverEntryPoint.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / UefiDriverEntryPoint / DriverEntryPoint.c
index cd096c59b5edca493bd483f7f263ca11c919b18a..c3ccf0fe9e5808336f00e01053a0ad14a3974a2f 100644 (file)
@@ -1,30 +1,34 @@
 /** @file\r
   Entry point to a EFI/DXE driver.\r
 \r
-Copyright (c) 2006, Intel Corporation<BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\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
-  when unloading the driver.\r
 \r
-  @param  ImageHandle\r
 \r
-  @retval EFI_SUCCESS\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/LoadedImage.h>\r
+\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
 \r
-**/\r
 \r
-EFI_EVENT  _mDriverExitBootServicesNotifyEvent;\r
+/**\r
+  Unloads an image from memory.\r
+\r
+  This function is a callback that a driver registers to do cleanup\r
+  when the UnloadImage boot service function is called.\r
+\r
+  @param  ImageHandle The handle to the image to unload.\r
 \r
+  @return Status returned by all unload().\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 _DriverUnloadHandler (\r
@@ -44,14 +48,6 @@ _DriverUnloadHandler (
   // 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
@@ -61,47 +57,31 @@ _DriverUnloadHandler (
   return Status;\r
 }\r
 \r
-VOID\r
-EFIAPI\r
-_DriverExitBootServices (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Set AtRuntime flag as TRUE after ExitBootServices\r
-\r
-Arguments:\r
-\r
-  Event   - The Event that is being processed\r
-  \r
-  Context - Event Context\r
-\r
-Returns: \r
-\r
-  None\r
-\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
-  @param  ImageHandle ImageHandle of the loaded driver.\r
-  @param  SystemTable Pointer to the EFI System Table.\r
-\r
-  @retval  EFI_SUCCESS One or more of the drivers returned a success code.\r
-  @retval  !EFI_SUCESS The return status from the last driver entry point in the list.\r
+  The entry point of PE/COFF Image for a DXE Driver, DXE Runtime Driver, DXE SMM\r
+  Driver, or UEFI Driver.\r
+\r
+  This function is the entry point for a DXE Driver, DXE Runtime Driver, DXE SMM Driver,\r
+  or UEFI Driver.  This function must call ProcessLibraryConstructorList() and\r
+  ProcessModuleEntryPointList(). If the return status from ProcessModuleEntryPointList()\r
+  is an error status, then ProcessLibraryDestructorList() must be called. The return\r
+  value from ProcessModuleEntryPointList() is returned. If _gDriverUnloadImageCount\r
+  is greater than zero, then an unload handler must be registered for this image\r
+  and the unload handler must invoke ProcessModuleUnloadList().\r
+  If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is less than\r
+  _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.\r
+\r
+\r
+  @param  ImageHandle  The image handle of the DXE Driver, DXE Runtime Driver,\r
+                       DXE SMM Driver, or UEFI Driver.\r
+  @param  SystemTable  A pointer to the EFI System Table.\r
+\r
+  @retval  EFI_SUCCESS               The DXE Driver, DXE Runtime Driver, DXE SMM\r
+                                     Driver, or UEFI Driver exited normally.\r
+  @retval  EFI_INCOMPATIBLE_VERSION  _gUefiDriverRevision is greater than\r
+                                    SystemTable->Hdr.Revision.\r
+  @retval  Other                     Return value from ProcessModuleEntryPointList().\r
 \r
 **/\r
 EFI_STATUS\r
@@ -128,21 +108,6 @@ _ModuleEntryPoint (
   //\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
@@ -165,14 +130,6 @@ _ModuleEntryPoint (
   // 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
@@ -184,14 +141,20 @@ _ModuleEntryPoint (
 \r
 \r
 /**\r
-  Enrty point wrapper of DXE Driver.\r
+  Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().\r
 \r
-  @param  ImageHandle ImageHandle of the loaded driver.\r
-  @param  SystemTable Pointer to the EFI System Table.\r
+  This function is required to call _ModuleEntryPoint() passing in ImageHandle,\r
+  and SystemTable.\r
 \r
-  @retval  EFI_SUCCESS One or more of the drivers returned a success code.\r
-  @retval  !EFI_SUCESS The return status from the last driver entry point in the list.\r
+  @param  ImageHandle  The image handle of the DXE Driver, DXE Runtime Driver, DXE\r
+                       SMM Driver, or UEFI Driver.\r
+  @param  SystemTable  A pointer to the EFI System Table.\r
 \r
+  @retval  EFI_SUCCESS               The DXE Driver, DXE Runtime Driver, DXE SMM\r
+                                     Driver, or UEFI Driver exited normally.\r
+  @retval  EFI_INCOMPATIBLE_VERSION  _gUefiDriverRevision is greater than\r
+                                     SystemTable->Hdr.Revision.\r
+  @retval  Other                     Return value from ProcessModuleEntryPointList().\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r