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
This commit is contained in:
lgao4 2010-05-05 01:58:36 +00:00
parent 682cee4c06
commit d7aaf1dcb5
2 changed files with 12 additions and 80 deletions

View File

@ -20,7 +20,6 @@
#include <Protocol/SmmConfiguration.h> #include <Protocol/SmmConfiguration.h>
#include <Protocol/SmmControl2.h> #include <Protocol/SmmControl2.h>
#include <Protocol/DxeSmmReadyToLock.h> #include <Protocol/DxeSmmReadyToLock.h>
#include <Protocol/FirmwareVolume2.h>
#include <Guid/EventGroup.h> #include <Guid/EventGroup.h>
#include <Guid/EventLegacyBios.h> #include <Guid/EventLegacyBios.h>
@ -34,6 +33,7 @@
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/DxeServicesTableLib.h> #include <Library/DxeServicesTableLib.h>
#include <Library/DxeServicesLib.h>
#include <Library/UefiLib.h> #include <Library/UefiLib.h>
#include <Library/UefiRuntimeLib.h> #include <Library/UefiRuntimeLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
@ -683,81 +683,6 @@ SmmIplSetVirtualAddressNotify (
EfiConvertPointer (0x0, (VOID **)&mSmmControl2); 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 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. 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 // 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); Status = GetSectionFromAnyFvByFileType (
if (SourceBuffer == NULL) { EFI_FV_FILETYPE_SMM_CORE,
return EFI_NOT_FOUND; 0,
EFI_SECTION_PE32,
0,
&SourceBuffer,
&SourceSize
);
if (EFI_ERROR (Status)) {
return Status;
} }
// //

View File

@ -47,6 +47,7 @@
DxeServicesTableLib DxeServicesTableLib
UefiLib UefiLib
UefiRuntimeLib UefiRuntimeLib
DxeServicesLib
[Protocols] [Protocols]
gEfiSmmBase2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED gEfiSmmBase2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED
@ -55,7 +56,6 @@
gEfiSmmConfigurationProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiSmmConfigurationProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiSmmControl2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiSmmControl2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiFirmwareVolume2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_CONSUMED
[Guids] [Guids]