]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/Sec: Add FindFfsSectionInstance
authorJordan Justen <jordan.l.justen@intel.com>
Tue, 21 Jan 2014 19:39:04 +0000 (19:39 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 21 Jan 2014 19:39:04 +0000 (19:39 +0000)
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

OvmfPkg/Sec/SecMain.c

index e25825e51a6bfa4f5a880712e8623db656180e5b..6e238fe3370160e95a6ce65405025905767fd348 100644 (file)
@@ -128,9 +128,13 @@ FindMainFv (
   Locates a section within a series of sections\r
   with the specified section type.\r
 \r
+  The Instance parameter indicates which instance of the section\r
+  type to return. (0 is first instance, 1 is second...)\r
+\r
   @param[in]   Sections        The sections to search\r
   @param[in]   SizeOfSections  Total size of all sections\r
   @param[in]   SectionType     The section type to locate\r
+  @param[in]   Instance        The section instance number\r
   @param[out]  FoundSection    The FFS section if found\r
 \r
   @retval EFI_SUCCESS           The file and section was found\r
@@ -139,10 +143,11 @@ FindMainFv (
 \r
 **/\r
 EFI_STATUS\r
-FindFfsSectionInSections (\r
+FindFfsSectionInstance (\r
   IN  VOID                             *Sections,\r
   IN  UINTN                            SizeOfSections,\r
   IN  EFI_SECTION_TYPE                 SectionType,\r
+  IN  UINTN                            Instance,\r
   OUT EFI_COMMON_SECTION_HEADER        **FoundSection\r
   )\r
 {\r
@@ -182,14 +187,49 @@ FindFfsSectionInSections (
     // Look for the requested section type\r
     //\r
     if (Section->Type == SectionType) {\r
-      *FoundSection = Section;\r
-      return EFI_SUCCESS;\r
+      if (Instance == 0) {\r
+        *FoundSection = Section;\r
+        return EFI_SUCCESS;\r
+      } else {\r
+        Instance--;\r
+      }\r
     }\r
   }\r
 \r
   return EFI_NOT_FOUND;\r
 }\r
 \r
+/**\r
+  Locates a section within a series of sections\r
+  with the specified section type.\r
+\r
+  @param[in]   Sections        The sections to search\r
+  @param[in]   SizeOfSections  Total size of all sections\r
+  @param[in]   SectionType     The section type to locate\r
+  @param[out]  FoundSection    The FFS section if found\r
+\r
+  @retval EFI_SUCCESS           The file and section was found\r
+  @retval EFI_NOT_FOUND         The file and section was not found\r
+  @retval EFI_VOLUME_CORRUPTED  The firmware volume was corrupted\r
+\r
+**/\r
+EFI_STATUS\r
+FindFfsSectionInSections (\r
+  IN  VOID                             *Sections,\r
+  IN  UINTN                            SizeOfSections,\r
+  IN  EFI_SECTION_TYPE                 SectionType,\r
+  OUT EFI_COMMON_SECTION_HEADER        **FoundSection\r
+  )\r
+{\r
+  return FindFfsSectionInstance (\r
+           Sections,\r
+           SizeOfSections,\r
+           SectionType,\r
+           0,\r
+           FoundSection\r
+           );\r
+}\r
+\r
 /**\r
   Locates a FFS file with the specified file type and a section\r
   within that file with the specified section type.\r