EdkCompatibilityPkg: Fix GCC error to avoid the duplicated global variables

SmmBaseHelper uses the same name global variables to the one in
SmmMemoryAllocateLib. Update SmmBaseHelper to use SmmMemLib
SmmIsBufferOutsideSmmValid().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19337 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Liming Gao 2015-12-18 02:28:18 +00:00 committed by lgao4
parent 4858527b54
commit dd62310aaf
3 changed files with 5 additions and 83 deletions

View File

@ -34,6 +34,7 @@
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/SynchronizationLib.h> #include <Library/SynchronizationLib.h>
#include <Library/CpuLib.h> #include <Library/CpuLib.h>
#include <Library/SmmMemLib.h>
#include <Guid/SmmBaseThunkCommunication.h> #include <Guid/SmmBaseThunkCommunication.h>
#include <Protocol/SmmBaseHelperReady.h> #include <Protocol/SmmBaseHelperReady.h>
#include <Protocol/SmmCpu.h> #include <Protocol/SmmCpu.h>
@ -42,7 +43,6 @@
#include <Protocol/MpService.h> #include <Protocol/MpService.h>
#include <Protocol/LoadPe32Image.h> #include <Protocol/LoadPe32Image.h>
#include <Protocol/SmmReadyToLock.h> #include <Protocol/SmmReadyToLock.h>
#include <Protocol/SmmAccess2.h>
/** /**
Register SMM image to SMRAM profile. Register SMM image to SMRAM profile.
@ -122,8 +122,6 @@ SPIN_LOCK mPFLock;
UINT64 mPhyMask; UINT64 mPhyMask;
VOID *mOriginalHandler; VOID *mOriginalHandler;
EFI_SMM_CPU_SAVE_STATE *mShadowSaveState; EFI_SMM_CPU_SAVE_STATE *mShadowSaveState;
EFI_SMRAM_DESCRIPTOR *mSmramRanges;
UINTN mSmramRangeCount;
LIST_ENTRY mCallbackInfoListHead = INITIALIZE_LIST_HEAD_VARIABLE (mCallbackInfoListHead); LIST_ENTRY mCallbackInfoListHead = INITIALIZE_LIST_HEAD_VARIABLE (mCallbackInfoListHead);
@ -743,60 +741,6 @@ LoadImage (
return Status; return Status;
} }
/**
This function check if the address is in SMRAM.
@param Buffer the buffer address to be checked.
@param Length the buffer length to be checked.
@retval TRUE this address is in SMRAM.
@retval FALSE this address is NOT in SMRAM.
**/
BOOLEAN
IsAddressInSmram (
IN EFI_PHYSICAL_ADDRESS Buffer,
IN UINT64 Length
)
{
UINTN Index;
for (Index = 0; Index < mSmramRangeCount; Index ++) {
if (((Buffer >= mSmramRanges[Index].CpuStart) && (Buffer < mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize)) ||
((mSmramRanges[Index].CpuStart >= Buffer) && (mSmramRanges[Index].CpuStart < Buffer + Length))) {
return TRUE;
}
}
return FALSE;
}
/**
This function check if the address refered by Buffer and Length is valid.
@param Buffer the buffer address to be checked.
@param Length the buffer length to be checked.
@retval TRUE this address is valid.
@retval FALSE this address is NOT valid.
**/
BOOLEAN
IsAddressValid (
IN UINTN Buffer,
IN UINTN Length
)
{
if (Buffer > (MAX_ADDRESS - Length)) {
//
// Overflow happen
//
return FALSE;
}
if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {
return FALSE;
}
return TRUE;
}
/** /**
Thunk service of EFI_SMM_BASE_PROTOCOL.Register(). Thunk service of EFI_SMM_BASE_PROTOCOL.Register().
@ -1133,7 +1077,7 @@ SmmHandlerEntry (
ASSERT (CommBufferSize != NULL); ASSERT (CommBufferSize != NULL);
if (*CommBufferSize == sizeof (SMMBASE_FUNCTION_DATA) && if (*CommBufferSize == sizeof (SMMBASE_FUNCTION_DATA) &&
IsAddressValid ((UINTN)CommBuffer, *CommBufferSize)) { SmmIsBufferOutsideSmmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, (UINT64)*CommBufferSize)) {
FunctionData = (SMMBASE_FUNCTION_DATA *)CommBuffer; FunctionData = (SMMBASE_FUNCTION_DATA *)CommBuffer;
switch (FunctionData->Function) { switch (FunctionData->Function) {
@ -1207,8 +1151,6 @@ SmmBaseHelperMain (
EFI_HANDLE Handle; EFI_HANDLE Handle;
UINTN NumberOfEnabledProcessors; UINTN NumberOfEnabledProcessors;
VOID *Registration; VOID *Registration;
EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
UINTN Size;
Handle = NULL; Handle = NULL;
/// ///
@ -1253,28 +1195,6 @@ SmmBaseHelperMain (
mSmmBaseHelperReady->FrameworkSmst = mFrameworkSmst; mSmmBaseHelperReady->FrameworkSmst = mFrameworkSmst;
mSmmBaseHelperReady->ServiceEntry = SmmHandlerEntry; mSmmBaseHelperReady->ServiceEntry = SmmHandlerEntry;
//
// Get SMRAM information
//
Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);
ASSERT_EFI_ERROR (Status);
Size = 0;
Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
Status = gSmst->SmmAllocatePool (
EfiRuntimeServicesData,
Size,
(VOID **)&mSmramRanges
);
ASSERT_EFI_ERROR (Status);
Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges);
ASSERT_EFI_ERROR (Status);
mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
// //
// Register SMM Ready To Lock Protocol notification // Register SMM Ready To Lock Protocol notification
// //

View File

@ -60,6 +60,7 @@
SynchronizationLib SynchronizationLib
CpuLib CpuLib
PcdLib PcdLib
SmmMemLib
[Guids] [Guids]
gEfiSmmBaseThunkCommunicationGuid gEfiSmmBaseThunkCommunicationGuid
@ -75,7 +76,6 @@
gEfiSmmCpuIo2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiSmmCpuIo2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiLoadPeImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiLoadPeImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiSmmAccess2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiSmmCommunicationProtocolGuid gEfiSmmCommunicationProtocolGuid
[Pcd] [Pcd]

View File

@ -72,6 +72,7 @@ DEFINE GCC_MACRO = -DEFI_SPECIFICATION_VERSION=0x00020000 -DPI_S
LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
[LibraryClasses.common.PEIM] [LibraryClasses.common.PEIM]
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
@ -84,6 +85,7 @@ DEFINE GCC_MACRO = -DEFI_SPECIFICATION_VERSION=0x00020000 -DPI_S
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
[BuildOptions.Common.EDK] [BuildOptions.Common.EDK]
GCC:*_*_IA32_CC_FLAGS = -DEFI32 $(GCC_MACRO) GCC:*_*_IA32_CC_FLAGS = -DEFI32 $(GCC_MACRO)