From d7aaf1dcb5a459955e2a57948732fc64acc66216 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Wed, 5 May 2010 01:58:36 +0000 Subject: [PATCH] Use new API GetSectionFromAnyFvByFileType() of MdePkg DxeServicesLib library to get PE data of SMM_CORE driver. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10457 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 90 +++--------------------- MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf | 2 +- 2 files changed, 12 insertions(+), 80 deletions(-) diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c index 6f84a855ad..61ed062d27 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -34,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -683,81 +683,6 @@ SmmIplSetVirtualAddressNotify ( EfiConvertPointer (0x0, (VOID **)&mSmmControl2); } -/** - Searches all Firmware Volumes for the first file matching FileType and SectionType and returns the section data. - - @param FileType FileType to search for within any of the firmware volumes in the platform. - @param SectionType SectionType to search for within any of the matching FileTypes in the firmware volumes in the platform. - @param SourceSize Return the size of the returned section data.. - - @retval != NULL Pointer to the allocated buffer containing the section data. - @retval NULL Section data was not found. - -**/ -VOID * -GetSectionInAnyFv ( - IN EFI_FV_FILETYPE FileType, - IN EFI_SECTION_TYPE SectionType, - OUT UINTN *SourceSize - ) -{ - EFI_STATUS Status; - UINTN HandleCount; - EFI_HANDLE *HandleBuffer; - UINTN Index; - EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; - UINTN Key; - EFI_GUID NameGuid; - EFI_FV_FILE_ATTRIBUTES Attributes; - VOID *SourceBuffer; - UINT32 AuthenticationStatus; - - HandleBuffer = NULL; - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiFirmwareVolume2ProtocolGuid, - NULL, - &HandleCount, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return NULL; - } - - for (Index = 0; Index < HandleCount; Index++) { - Status = gBS->HandleProtocol ( - HandleBuffer[Index], - &gEfiFirmwareVolume2ProtocolGuid, - (VOID **)&Fv - ); - if (EFI_ERROR (Status)) { - continue; - } - - // - // Use Firmware Volume 2 Protocol to search for a file of type FileType - // - Key = 0; - Status = Fv->GetNextFile (Fv, &Key, &FileType, &NameGuid, &Attributes, SourceSize); - if (EFI_ERROR (Status)) { - continue; - } - - // - // Use Firmware Volume 2 Protocol to read a section of type SectionType - // - SourceBuffer = NULL; - Status = Fv->ReadSection (Fv, &NameGuid, SectionType, 0, &SourceBuffer, SourceSize, &AuthenticationStatus); - if (!EFI_ERROR (Status)) { - FreePool (HandleBuffer); - return SourceBuffer; - } - } - - FreePool(HandleBuffer); - - return NULL; -} /** Get the fixed loadding address from image header assigned by build tool. This function only be called when Loading module at Fixed address feature enabled. @@ -880,9 +805,16 @@ ExecuteSmmCoreFromSmram ( // // Search all Firmware Volumes for a PE/COFF image in a file of type SMM_CORE // - SourceBuffer = GetSectionInAnyFv (EFI_FV_FILETYPE_SMM_CORE, EFI_SECTION_PE32, &SourceSize); - if (SourceBuffer == NULL) { - return EFI_NOT_FOUND; + Status = GetSectionFromAnyFvByFileType ( + EFI_FV_FILETYPE_SMM_CORE, + 0, + EFI_SECTION_PE32, + 0, + &SourceBuffer, + &SourceSize + ); + if (EFI_ERROR (Status)) { + return Status; } // diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf index a7e0c962d4..8cbaf8d5d3 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf @@ -47,6 +47,7 @@ DxeServicesTableLib UefiLib UefiRuntimeLib + DxeServicesLib [Protocols] gEfiSmmBase2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED @@ -55,7 +56,6 @@ gEfiSmmConfigurationProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiSmmControl2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiFirmwareVolume2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_CONSUMED [Guids] -- 2.39.2