IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r
);\r
\r
+/**\r
+ * This is a hook which is used to check if the section is the target one.\r
+ *\r
+ */\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *FFS_CHECK_SECTION_HOOK)(\r
+ IN EFI_COMMON_SECTION_HEADER *Section\r
+ );\r
+\r
/**\r
This service enables discovery sections of a given type within a valid FFS file.\r
+ Caller also can provide a SectionCheckHook to do additional checking.\r
\r
- @param SearchType The value of the section type to find.\r
- @param FfsFileHeader A pointer to the file header that contains the set of sections to\r
+ @param SectionType The value of the section type to find.\r
+ @param SectionCheckHook A hook which can check if the section is the target one.\r
+ @param FileHeader A pointer to the file header that contains the set of sections to\r
be searched.\r
@param SectionData A pointer to the discovered section, if successful.\r
\r
EFI_STATUS\r
EFIAPI\r
FfsFindSectionData (\r
- IN EFI_SECTION_TYPE SectionType,\r
- IN EFI_PEI_FILE_HANDLE FileHandle,\r
- OUT VOID **SectionData\r
+ IN EFI_SECTION_TYPE SectionType,\r
+ IN FFS_CHECK_SECTION_HOOK SectionCheckHook,\r
+ IN EFI_PEI_FILE_HANDLE FileHandle,\r
+ OUT VOID **SectionData\r
);\r
\r
/**\r
Go through the file to search SectionType section,\r
when meeting an encapsuled section.\r
\r
- @param SectionType - Filter to find only section of this type.\r
- @param Section - From where to search.\r
- @param SectionSize - The file size to search.\r
- @param OutputBuffer - Pointer to the section to search.\r
+ @param SectionType - Filter to find only section of this type.\r
+ @param SectionCheckHook - A hook which can check if the section is the target one.\r
+ @param Section - From where to search.\r
+ @param SectionSize - The file size to search.\r
+ @param OutputBuffer - Pointer to the section to search.\r
\r
@retval EFI_SUCCESS\r
**/\r
EFI_STATUS\r
FfsProcessSection (\r
IN EFI_SECTION_TYPE SectionType,\r
+ IN FFS_CHECK_SECTION_HOOK SectionCheckHook,\r
IN EFI_COMMON_SECTION_HEADER *Section,\r
IN UINTN SectionSize,\r
OUT VOID **OutputBuffer\r
UINT32 AuthenticationStatus;\r
CHAR8 *CompressedData;\r
UINT32 CompressedDataLength;\r
+ BOOLEAN Found;\r
\r
+ Found = FALSE;\r
*OutputBuffer = NULL;\r
ParsedLength = 0;\r
Status = EFI_NOT_FOUND;\r
}\r
\r
if (Section->Type == SectionType) {\r
- if (IS_SECTION2 (Section)) {\r
- *OutputBuffer = (VOID *)((UINT8 *)Section + sizeof (EFI_COMMON_SECTION_HEADER2));\r
+ if (SectionCheckHook != NULL) {\r
+ Found = SectionCheckHook (Section) == EFI_SUCCESS;\r
} else {\r
- *OutputBuffer = (VOID *)((UINT8 *)Section + sizeof (EFI_COMMON_SECTION_HEADER));\r
+ Found = TRUE;\r
}\r
\r
- return EFI_SUCCESS;\r
+ if (Found) {\r
+ if (IS_SECTION2 (Section)) {\r
+ *OutputBuffer = (VOID *)((UINT8 *)Section + sizeof (EFI_COMMON_SECTION_HEADER2));\r
+ } else {\r
+ *OutputBuffer = (VOID *)((UINT8 *)Section + sizeof (EFI_COMMON_SECTION_HEADER));\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+ } else {\r
+ goto CheckNextSection;\r
+ }\r
} else if ((Section->Type == EFI_SECTION_COMPRESSION) || (Section->Type == EFI_SECTION_GUID_DEFINED)) {\r
if (Section->Type == EFI_SECTION_COMPRESSION) {\r
if (IS_SECTION2 (Section)) {\r
} else {\r
return FfsProcessSection (\r
SectionType,\r
+ SectionCheckHook,\r
DstBuffer,\r
DstBufferSize,\r
OutputBuffer\r
}\r
}\r
\r
+CheckNextSection:\r
if (IS_SECTION2 (Section)) {\r
SectionLength = SECTION2_SIZE (Section);\r
} else {\r
EFI_STATUS\r
EFIAPI\r
FfsFindSectionData (\r
- IN EFI_SECTION_TYPE SectionType,\r
- IN EFI_PEI_FILE_HANDLE FileHandle,\r
- OUT VOID **SectionData\r
+ IN EFI_SECTION_TYPE SectionType,\r
+ IN FFS_CHECK_SECTION_HOOK SectionCheckHook,\r
+ IN EFI_PEI_FILE_HANDLE FileHandle,\r
+ OUT VOID **SectionData\r
)\r
{\r
EFI_FFS_FILE_HEADER *FfsFileHeader;\r
\r
return FfsProcessSection (\r
SectionType,\r
+ SectionCheckHook,\r
Section,\r
FileSize,\r
SectionData\r
//\r
// Find FvImage in FvFile\r
//\r
- Status = FfsFindSectionData (EFI_SECTION_FIRMWARE_VOLUME_IMAGE, FvFileHandle, (VOID **)&FvImageHandle);\r
+ Status = FfsFindSectionData (EFI_SECTION_FIRMWARE_VOLUME_IMAGE, NULL, FvFileHandle, (VOID **)&FvImageHandle);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r