summaryrefslogtreecommitdiff
path: root/OvmfPkg/Sec/SecMain.c
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2014-01-21 19:39:04 +0000
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>2014-01-21 19:39:04 +0000
commit4b4b783dbe49102e5acaa9852e737820a645a559 (patch)
tree596c36c732c20977a11370a102aab9f1f0af1952 /OvmfPkg/Sec/SecMain.c
parentb6f564a7633224b04e297b7a36af751fecd7641f (diff)
downloadedk2-platforms-4b4b783dbe49102e5acaa9852e737820a645a559.tar.xz
OvmfPkg/Sec: Add FindFfsSectionInstance
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 <jordan.l.justen@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15150 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/Sec/SecMain.c')
-rw-r--r--OvmfPkg/Sec/SecMain.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c
index e25825e51a..6e238fe337 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.