#include <Protocol/SmmConfiguration.h>\r
#include <Protocol/SmmControl2.h>\r
#include <Protocol/DxeSmmReadyToLock.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
\r
#include <Guid/EventGroup.h>\r
#include <Guid/EventLegacyBios.h>\r
#include <Library/DebugLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/DxeServicesTableLib.h>\r
+#include <Library/DxeServicesLib.h>\r
#include <Library/UefiLib.h>\r
#include <Library/UefiRuntimeLib.h>\r
#include <Library/PcdLib.h>\r
EfiConvertPointer (0x0, (VOID **)&mSmmControl2);\r
}\r
\r
-/**\r
- Searches all Firmware Volumes for the first file matching FileType and SectionType and returns the section data.\r
-\r
- @param FileType FileType to search for within any of the firmware volumes in the platform.\r
- @param SectionType SectionType to search for within any of the matching FileTypes in the firmware volumes in the platform.\r
- @param SourceSize Return the size of the returned section data..\r
-\r
- @retval != NULL Pointer to the allocated buffer containing the section data.\r
- @retval NULL Section data was not found.\r
-\r
-**/\r
-VOID *\r
-GetSectionInAnyFv (\r
- IN EFI_FV_FILETYPE FileType,\r
- IN EFI_SECTION_TYPE SectionType,\r
- OUT UINTN *SourceSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN HandleCount;\r
- EFI_HANDLE *HandleBuffer;\r
- UINTN Index;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
- UINTN Key;\r
- EFI_GUID NameGuid;\r
- EFI_FV_FILE_ATTRIBUTES Attributes;\r
- VOID *SourceBuffer;\r
- UINT32 AuthenticationStatus;\r
-\r
- HandleBuffer = NULL;\r
- Status = gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiFirmwareVolume2ProtocolGuid,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuffer\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return NULL;\r
- }\r
-\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- Status = gBS->HandleProtocol (\r
- HandleBuffer[Index],\r
- &gEfiFirmwareVolume2ProtocolGuid,\r
- (VOID **)&Fv\r
- );\r
- if (EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- //\r
- // Use Firmware Volume 2 Protocol to search for a file of type FileType\r
- //\r
- Key = 0; \r
- Status = Fv->GetNextFile (Fv, &Key, &FileType, &NameGuid, &Attributes, SourceSize);\r
- if (EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- //\r
- // Use Firmware Volume 2 Protocol to read a section of type SectionType\r
- //\r
- SourceBuffer = NULL;\r
- Status = Fv->ReadSection (Fv, &NameGuid, SectionType, 0, &SourceBuffer, SourceSize, &AuthenticationStatus);\r
- if (!EFI_ERROR (Status)) {\r
- FreePool (HandleBuffer);\r
- return SourceBuffer;\r
- }\r
- } \r
-\r
- FreePool(HandleBuffer);\r
- \r
- return NULL;\r
-}\r
/**\r
Get the fixed loadding address from image header assigned by build tool. This function only be called\r
when Loading module at Fixed address feature enabled.\r
//\r
// Search all Firmware Volumes for a PE/COFF image in a file of type SMM_CORE\r
// \r
- SourceBuffer = GetSectionInAnyFv (EFI_FV_FILETYPE_SMM_CORE, EFI_SECTION_PE32, &SourceSize);\r
- if (SourceBuffer == NULL) {\r
- return EFI_NOT_FOUND;\r
+ Status = GetSectionFromAnyFvByFileType (\r
+ EFI_FV_FILETYPE_SMM_CORE, \r
+ 0,\r
+ EFI_SECTION_PE32, \r
+ 0,\r
+ &SourceBuffer, \r
+ &SourceSize\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
}\r
\r
//\r