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
This commit is contained in:
mdkinney 2010-02-14 05:49:44 +00:00
parent 112af4265f
commit 53b85bcbf0
2 changed files with 18 additions and 29 deletions

View File

@ -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;
}

View File

@ -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