]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDriverEntryPoint/DriverEntryPoint.c
Comments synchronized
[mirror_edk2.git] / MdePkg / Library / UefiDriverEntryPoint / DriverEntryPoint.c
index 8e3b30ac1e585a1b44b4fde1c3541ea2eb86388b..8a5fc5b6949814b3121346e5d057f3c3bd65ad37 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Entry point to a EFI/DXE driver.\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
+Copyright (c) 2006 - 2008, 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
@@ -13,10 +13,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 \r
-//\r
-// Include common header file for this module.\r
-//\r
-#include "CommonHeader.h"\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/LoadedImage.h>\r
+\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
 \r
 \r
 /**\r
@@ -24,12 +28,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   protocols produced and deallocates pool used by the driver.  Called by the core\r
   when unloading the driver.\r
 \r
-  @param  ImageHandle\r
+  @param  ImageHandle ImageHandle of the loaded driver.\r
 \r
-  @retval EFI_SUCCESS\r
+  @return Status returned by all unload().\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 _DriverUnloadHandler (\r
@@ -49,7 +52,6 @@ _DriverUnloadHandler (
   // unloaded, and the library destructors should not be called\r
   //\r
   if (!EFI_ERROR (Status)) {\r
-\r
     ProcessLibraryDestructorList (ImageHandle, gST);\r
   }\r
 \r
@@ -61,38 +63,26 @@ _DriverUnloadHandler (
 \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
+  The entry point of PE/COFF Image for a DXE Driver, DXE Runtime Driver, DXE SMM Driver, or UEFI Driver. \r
 \r
-**/\r
-STATIC\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
+  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 value\r
+  from ProcessModuleEntryPointList() is returned. If _gDriverUnloadImageCount is greater\r
+  than zero, then an unload handler must be registered for this image and the unload handler\r
+  must invoke ProcessModuleUnloadList().\r
+  If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is less than _gUefiDriverRevison,\r
+  then return EFI_INCOMPATIBLE_VERSION.\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
+  @param  ImageHandle  The image handle of the DXE Driver, DXE Runtime Driver, DXE SMM Driver, or UEFI Driver.\r
+  @param  SystemTable  A 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
+  @retval  EFI_SUCCESS               The DXE Driver, DXE Runtime Driver, DXE SMM Driver,\r
+                                     or UEFI Driver exited normally.\r
+  @retval  EFI_INCOMPATIBLE_VERSION  _gUefiDriverRevision is greater than SystemTable->Hdr.Revision.\r
+  @retval  Other                     Return value from ProcessModuleEntryPointList().\r
 \r
 **/\r
 EFI_STATUS\r
@@ -114,6 +104,11 @@ _ModuleEntryPoint (
     }\r
   }\r
 \r
+  //\r
+  // Call constructor for all libraries\r
+  //\r
+  ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
+\r
   //\r
   //  Install unload handler...\r
   //\r
@@ -127,11 +122,6 @@ _ModuleEntryPoint (
     LoadedImage->Unload = _DriverUnloadHandler;\r
   }\r
 \r
-  //\r
-  // Call constructor for all libraries\r
-  //\r
-  ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
-\r
   //\r
   // Call the driver entry point\r
   //\r
@@ -152,14 +142,17 @@ _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, 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 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 Driver,\r
+                                     or UEFI Driver exited normally.\r
+  @retval  EFI_INCOMPATIBLE_VERSION  _gUefiDriverRevision is greater than SystemTable->Hdr.Revision.\r
+  @retval  Other                     Return value from ProcessModuleEntryPointList().\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r