This allow you to search for an 'instance' of a section within a series of FFS sections.
For example, we will split the MAINFV into a PEI and DXE FV, and then compress those two FV's together within a FFS FV file. The DXE FV will appear as the second section of the file, and therefore we will search for it using an Instance=1 value. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <[email protected]> --- OvmfPkg/Sec/SecMain.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index 8968357..902ac85 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -128,9 +128,13 @@ FindMainFv ( Locates a section within a series of sections with the specified section type. + The Instance parameter indicates which instance of the section + type to return. (0 is first instance, 1 is second...) + @param[in] Sections The sections to search @param[in] SizeOfSections Total size of all sections @param[in] SectionType The section type to locate + @param[in] Instance The section instance number @param[out] FoundSection The FFS section if found @retval EFI_SUCCESS The file and section was found @@ -139,10 +143,11 @@ FindMainFv ( **/ EFI_STATUS -FindFfsSectionInSections ( +FindFfsSectionInstance ( IN VOID *Sections, IN UINTN SizeOfSections, IN EFI_SECTION_TYPE SectionType, + IN UINTN Instance, OUT EFI_COMMON_SECTION_HEADER **FoundSection ) { @@ -182,8 +187,12 @@ FindFfsSectionInSections ( // Look for the requested section type // if (Section->Type == SectionType) { - *FoundSection = Section; - return EFI_SUCCESS; + if (Instance == 0) { + *FoundSection = Section; + return EFI_SUCCESS; + } else { + Instance--; + } } } @@ -191,6 +200,37 @@ FindFfsSectionInSections ( } /** + Locates a section within a series of sections + with the specified section type. + + @param[in] Sections The sections to search + @param[in] SizeOfSections Total size of all sections + @param[in] SectionType The section type to locate + @param[out] FoundSection The FFS section if found + + @retval EFI_SUCCESS The file and section was found + @retval EFI_NOT_FOUND The file and section was not found + @retval EFI_VOLUME_CORRUPTED The firmware volume was corrupted + +**/ +EFI_STATUS +FindFfsSectionInSections ( + IN VOID *Sections, + IN UINTN SizeOfSections, + IN EFI_SECTION_TYPE SectionType, + OUT EFI_COMMON_SECTION_HEADER **FoundSection + ) +{ + return FindFfsSectionInstance ( + Sections, + SizeOfSections, + SectionType, + 0, + FoundSection + ); +} + +/** Locates a FFS file with the specified file type and a section within that file with the specified section type. -- 1.8.5.2 ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
