summaryrefslogtreecommitdiff
path: root/MdePkg
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-14 05:49:44 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-14 05:49:44 +0000
commit53b85bcbf03ee7a03aacda8bd43206f25844996e (patch)
treea5b050f40b87f707e9c98d869d98169655d318b6 /MdePkg
parent112af4265f6aca7ac155e4522c75504cba1e4e6c (diff)
downloadedk2-platforms-53b85bcbf03ee7a03aacda8bd43206f25844996e.tar.xz
1) Remove dependency on the UEFI Boot Services Table Library so the gBS, gST, and gImageHandle symbols will not be automatically linked into an SMM Driver that uses this library.
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
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c37
-rw-r--r--MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf10
2 files changed, 18 insertions, 29 deletions
diff --git a/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c b/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
index f44dd6ef70..1efa79ce70 100644
--- a/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
+++ b/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
@@ -1,7 +1,7 @@
/** @file
SMM Services Table Library.
- Copyright (c) 2009, Intel Corporation<BR>
+ Copyright (c) 2009 - 2010, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -12,19 +12,16 @@
**/
-#include <PiDxe.h>
#include <PiSmm.h>
#include <Protocol/SmmBase2.h>
-#include <Library/UefiBootServicesTableLib.h>
#include <Library/SmmServicesTableLib.h>
#include <Library/DebugLib.h>
-EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL;
-EFI_SMM_BASE2_PROTOCOL *mInternalSmmBase2 = NULL;
-
+EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL;
+EFI_SMM_BASE2_PROTOCOL *mInternalSmmBase2 = NULL;
/**
- The constructor function caches the pointer of Smm Services Table.
+ The constructor function caches the pointer of SMM Services Table.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@@ -39,26 +36,25 @@ SmmServicesTableLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- BOOLEAN InSmm;
+ EFI_STATUS Status;
//
- // Retrieve SMM Base2 Protocol
+ // Retrieve SMM Base2 Protocol, Do not use gBS from UefiBootServicesTableLib on purpose
+ // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the
+ // SMM driver explicity declares that dependency.
//
- Status = gBS->LocateProtocol (
- &gEfiSmmBase2ProtocolGuid,
- NULL,
- (VOID **) &mInternalSmmBase2
- );
+ Status = SystemTable->BootServices->LocateProtocol (
+ &gEfiSmmBase2ProtocolGuid,
+ NULL,
+ (VOID **)&mInternalSmmBase2
+ );
ASSERT_EFI_ERROR (Status);
ASSERT (mInternalSmmBase2 != NULL);
//
// Check to see if we are already in SMM
//
- mInternalSmmBase2->InSmm (mInternalSmmBase2, &InSmm);
-
- if (!InSmm) {
+ if (!InSmm ()) {
//
// We are not in SMM, so SMST is not needed
//
@@ -69,13 +65,11 @@ SmmServicesTableLibConstructor (
// We are in SMM, retrieve the pointer to SMM System Table
//
mInternalSmmBase2->GetSmstLocation (mInternalSmmBase2, &gSmst);
-
ASSERT (gSmst != NULL);
return EFI_SUCCESS;
}
-
/**
This function allows the caller to determine if the driver is executing in
System Management Mode(SMM).
@@ -93,12 +87,11 @@ InSmm (
VOID
)
{
- BOOLEAN InSmm;
+ BOOLEAN InSmm;
//
// Check to see if we are already in SMM
//
mInternalSmmBase2->InSmm (mInternalSmmBase2, &InSmm);
-
return InSmm;
}
diff --git a/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf b/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
index e0e699b001..a13c80a786 100644
--- a/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
+++ b/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
@@ -1,7 +1,7 @@
#/** @file
# SMM Services Table Library.
#
-# Copyright (c) 2009, Intel Corporation.
+# Copyright (c) 2009 - 2010, Intel Corporation.
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -20,28 +20,24 @@
MODULE_TYPE = DXE_SMM_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = SmmServicesTableLib|SMM_CORE DXE_SMM_DRIVER
- EDK_RELEASE_VERSION = 0x00020000
- EFI_SPECIFICATION_VERSION = 0x00020000
PI_SPECIFICATION_VERSION = 0x0001000A
-
CONSTRUCTOR = SmmServicesTableLibConstructor
#
# VALID_ARCHITECTURES = IA32 X64
#
-[Sources.common]
+[Sources]
SmmServicesTableLib.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
- UefiBootServicesTableLib
DebugLib
[Protocols]
gEfiSmmBase2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
-[Depex.common.DXE_DRIVER]
+[Depex]
gEfiSmmBase2ProtocolGuid