]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkPkg/Library/DxeSmmDriverEntryPoint/DriverEntryPoint.c
MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
[mirror_edk2.git] / IntelFrameworkPkg / Library / DxeSmmDriverEntryPoint / DriverEntryPoint.c
index ed3d2c667a0ef9174d4a5ebf88760842785f2119..d1491655fe629a7a63806653ea71b49657c22b97 100644 (file)
@@ -3,8 +3,8 @@
   EfiMain() is common driver entry point for all SMM driver who uses DxeSmmDriverEntryPoint\r
   library class.\r
 \r
-Copyright (c) 2006, Intel Corporation<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+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
@@ -136,9 +136,9 @@ _DriverUnloadHandler (
 {\r
   //\r
   // Call the unload handlers for all the modules.\r
-  // \r
-  // Note: All libraries were constructed in SMM space, \r
-  // therefore we can not destruct them in Unload \r
+  //\r
+  // Note: All libraries were constructed in SMM space,\r
+  // therefore we can not destruct them in Unload\r
   // handler.\r
   //\r
   return ProcessModuleUnloadList (ImageHandle);\r
@@ -174,16 +174,6 @@ _ModuleEntryPoint (
   //\r
   gBS = SystemTable->BootServices;\r
 \r
-  //\r
-  // Retrieve the Loaded Image Protocol\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  ImageHandle,\r
-                  &gEfiLoadedImageProtocolGuid,\r
-                  (VOID*)&LoadedImage\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
   //\r
   // Retrieve SMM Base Protocol\r
   //\r
@@ -203,6 +193,15 @@ _ModuleEntryPoint (
   //\r
   //\r
   if (!InSmm) {\r
+    //\r
+    // Retrieve the Loaded Image Protocol\r
+    //\r
+    Status = gBS->HandleProtocol (\r
+                  ImageHandle,\r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID*)&LoadedImage\r
+                  );\r
+    ASSERT_EFI_ERROR (Status);\r
     //\r
     // Retrieve the Device Path Protocol from the DeviceHandle from which this driver was loaded\r
     //\r
@@ -222,8 +221,21 @@ _ModuleEntryPoint (
     // Load the image in memory to SMRAM; it will automatically generate the\r
     // SMI.\r
     //\r
-    Status = SmmBase->Register (SmmBase, CompleteFilePath, NULL, 0, &Handle, FALSE);\r
+    Status = SmmBase->Register (SmmBase, CompleteFilePath, LoadedImage->ImageBase, 0, &Handle, FALSE);\r
     ASSERT_EFI_ERROR (Status);\r
+    //\r
+    // Optionally install the unload handler\r
+    //\r
+    if (_gDriverUnloadImageCount > 0) {\r
+      Status = gBS->HandleProtocol (\r
+                      ImageHandle,\r
+                      &gEfiLoadedImageProtocolGuid,\r
+                      (VOID **)&LoadedImage\r
+                      );\r
+      ASSERT_EFI_ERROR (Status);\r
+      LoadedImage->Unload = _DriverUnloadHandler;\r
+    }\r
+\r
     return Status;\r
   }\r
 \r
@@ -232,19 +244,6 @@ _ModuleEntryPoint (
   //\r
   ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
 \r
-  //\r
-  // Optionally install the unload handler\r
-  //\r
-  if (_gDriverUnloadImageCount > 0) {\r
-    Status = gBS->HandleProtocol (\r
-                    ImageHandle,\r
-                    &gEfiLoadedImageProtocolGuid,\r
-                    (VOID **)&LoadedImage\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-    LoadedImage->Unload = _DriverUnloadHandler;\r
-  }\r
-\r
   //\r
   // Call the list of driver entry points\r
   //\r