]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1) Remove dependency on the UEFI Boot Services Table Library so the gBS, gST, and...
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 14 Feb 2010 05:49:44 +0000 (05:49 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 14 Feb 2010 05:49:44 +0000 (05:49 +0000)
2) Remove redundant include of <PiDxe.h>
3) Clean up constructor to use InSmm() library function instead of duplicating logic.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10000 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf

index f44dd6ef700557134d3efa9571d2741c20e1bb29..1efa79ce70990d2dda69412789d36184b2bb6902 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SMM Services Table Library.\r
 \r
-  Copyright (c) 2009, Intel Corporation<BR>\r
+  Copyright (c) 2009 - 2010, 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
 \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
index e0e699b001c3edf5ff8b81b71e70c4f2c11d73b2..a13c80a786518fa7238d50702e30f0e1dffefbda 100644 (file)
@@ -1,7 +1,7 @@
 #/** @file\r
 # SMM Services Table Library.\r
 #\r
-# Copyright (c) 2009, Intel Corporation.\r
+# Copyright (c) 2009 - 2010, Intel Corporation.\r
 #\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
   MODULE_TYPE                    = DXE_SMM_DRIVER\r
   VERSION_STRING                 = 1.0\r
   LIBRARY_CLASS                  = SmmServicesTableLib|SMM_CORE DXE_SMM_DRIVER\r
-  EDK_RELEASE_VERSION            = 0x00020000\r
-  EFI_SPECIFICATION_VERSION      = 0x00020000\r
   PI_SPECIFICATION_VERSION       = 0x0001000A\r
-\r
   CONSTRUCTOR                    = SmmServicesTableLibConstructor\r
 \r
 #\r
 #  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
-[Sources.common]\r
+[Sources]\r
   SmmServicesTableLib.c\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
 [LibraryClasses]\r
-  UefiBootServicesTableLib\r
   DebugLib\r
 \r
 [Protocols]\r
   gEfiSmmBase2ProtocolGuid                      # PROTOCOL ALWAYS_CONSUMED\r
 \r
-[Depex.common.DXE_DRIVER]\r
+[Depex]\r
   gEfiSmmBase2ProtocolGuid\r