summaryrefslogtreecommitdiff
path: root/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c')
-rw-r--r--MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c37
1 files changed, 15 insertions, 22 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;
}