]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / MdePkg / Library / SmmServicesTableLib / SmmServicesTableLib.c
index f44dd6ef700557134d3efa9571d2741c20e1bb29..23a85a0c68e5e1f437f68fa5a1ac7d3c1c68dc2f 100644 (file)
@@ -1,30 +1,27 @@
 /** @file\r
   SMM Services Table Library.\r
 \r
-  Copyright (c) 2009, Intel Corporation<BR>\r
-  All rights reserved. This program and the accompanying materials\r
+  Copyright (c) 2009 - 2010, 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
+  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
 \r
 **/\r
 \r
-#include <PiDxe.h>\r
 #include <PiSmm.h>\r
 #include <Protocol/SmmBase2.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/SmmServicesTableLib.h>\r
 #include <Library/DebugLib.h>\r
 \r
-EFI_SMM_SYSTEM_TABLE2        *gSmst              = NULL;\r
-EFI_SMM_BASE2_PROTOCOL       *mInternalSmmBase2  = NULL;\r
-\r
+EFI_SMM_SYSTEM_TABLE2   *gSmst             = NULL;\r
+EFI_SMM_BASE2_PROTOCOL  *mInternalSmmBase2 = NULL;\r
 \r
 /**\r
-  The constructor function caches the pointer of Smm Services Table.\r
+  The constructor function caches the pointer of SMM Services Table.\r
 \r
   @param  ImageHandle   The firmware allocated handle for the EFI image.\r
   @param  SystemTable   A pointer to the EFI System Table.\r
@@ -39,26 +36,25 @@ SmmServicesTableLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
-  EFI_STATUS                   Status;\r
-  BOOLEAN                      InSmm;\r
+  EFI_STATUS  Status;\r
 \r
   //\r
-  // Retrieve SMM Base2 Protocol\r
+  // Retrieve SMM Base2 Protocol,  Do not use gBS from UefiBootServicesTableLib on purpose\r
+  // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the \r
+  // SMM driver explicity declares that dependency. \r
   //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiSmmBase2ProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &mInternalSmmBase2\r
-                  );\r
+  Status = SystemTable->BootServices->LocateProtocol (\r
+                                        &gEfiSmmBase2ProtocolGuid,\r
+                                        NULL,\r
+                                        (VOID **)&mInternalSmmBase2\r
+                                        );\r
   ASSERT_EFI_ERROR (Status);\r
   ASSERT (mInternalSmmBase2 != NULL);\r
 \r
   //\r
   // Check to see if we are already in SMM\r
   //\r
-  mInternalSmmBase2->InSmm (mInternalSmmBase2, &InSmm);\r
-\r
-  if (!InSmm) {\r
+  if (!InSmm ()) {\r
     //\r
     // We are not in SMM, so SMST is not needed\r
     //\r
@@ -69,13 +65,11 @@ SmmServicesTableLibConstructor (
   // We are in SMM, retrieve the pointer to SMM System Table\r
   //\r
   mInternalSmmBase2->GetSmstLocation (mInternalSmmBase2, &gSmst);\r
-\r
   ASSERT (gSmst != NULL);\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   This function allows the caller to determine if the driver is executing in \r
   System Management Mode(SMM).\r
@@ -93,12 +87,11 @@ InSmm (
   VOID\r
   )\r
 {\r
-  BOOLEAN                      InSmm;\r
+  BOOLEAN  InSmm;\r
 \r
   //\r
   // Check to see if we are already in SMM\r
   //\r
   mInternalSmmBase2->InSmm (mInternalSmmBase2, &InSmm);\r
-\r
   return InSmm;\r
 }\r