StandaloneMmPkg/FvLib: Add a common FV Library for management mode.
[mirror_edk2.git] / StandaloneMmPkg / Include / Library / FvLib.h
1 /** @file
2
3 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
4 Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _FV_LIB_H_
17 #define _FV_LIB_H_
18
19 #include <Uefi.h>
20 #include <Pi/PiFirmwareVolume.h>
21 #include <Pi/PiFirmwareFile.h>
22
23 /**
24 Given the input file pointer, search for the next matching file in the
25 FFS volume as defined by SearchType. The search starts from FileHeader inside
26 the Firmware Volume defined by FwVolHeader.
27
28 @param SearchType Filter to find only files of this type.
29 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
30 @param FwVolHeader Pointer to the FV header of the volume to search.
31 This parameter must point to a valid FFS volume.
32 @param FileHeader Pointer to the current file from which to begin searching.
33 This pointer will be updated upon return to reflect the file found.
34
35 @retval EFI_NOT_FOUND No files matching the search criteria were found
36 @retval EFI_SUCCESS
37 **/
38 EFI_STATUS
39 EFIAPI
40 FfsFindNextFile (
41 IN EFI_FV_FILETYPE SearchType,
42 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
43 IN OUT EFI_FFS_FILE_HEADER **FileHeader
44 );
45
46 /**
47 Given the input file pointer, search for the next matching section in the
48 FFS volume.
49
50 @param SearchType Filter to find only sections of this type.
51 @param FfsFileHeader Pointer to the current file to search.
52 @param SectionHeader Pointer to the Section matching SectionType in FfsFileHeader.
53 NULL if section not found
54
55 @retval EFI_NOT_FOUND No files matching the search criteria were found
56 @retval EFI_SUCCESS
57 **/
58 EFI_STATUS
59 FfsFindSection (
60 IN EFI_SECTION_TYPE SectionType,
61 IN EFI_FFS_FILE_HEADER *FfsFileHeader,
62 IN OUT EFI_COMMON_SECTION_HEADER **SectionHeader
63 );
64
65 /**
66 Locates a section within a series of sections
67 with the specified section type.
68
69 @param[in] Sections The sections to search
70 @param[in] SizeOfSections Total size of all sections
71 @param[in] SectionType The section type to locate
72 @param[out] FoundSection The FFS section if found
73
74 @retval EFI_SUCCESS The file and section was found
75 @retval EFI_NOT_FOUND The file and section was not found
76 @retval EFI_VOLUME_CORRUPTED The firmware volume was corrupted
77 **/
78 EFI_STATUS
79 EFIAPI
80 FindFfsSectionInSections (
81 IN VOID *Sections,
82 IN UINTN SizeOfSections,
83 IN EFI_SECTION_TYPE SectionType,
84 OUT EFI_COMMON_SECTION_HEADER **FoundSection
85 );
86
87 /**
88 Given the input file pointer, search for the next matching section in the
89 FFS volume.
90
91 @param SearchType Filter to find only sections of this type.
92 @param FfsFileHeader Pointer to the current file to search.
93 @param SectionData Pointer to the Section matching SectionType in FfsFileHeader.
94 NULL if section not found
95 @param SectionDataSize The size of SectionData
96
97 @retval EFI_NOT_FOUND No files matching the search criteria were found
98 @retval EFI_SUCCESS
99 **/
100 EFI_STATUS
101 EFIAPI
102 FfsFindSectionData (
103 IN EFI_SECTION_TYPE SectionType,
104 IN EFI_FFS_FILE_HEADER *FfsFileHeader,
105 OUT VOID **SectionData,
106 OUT UINTN *SectionDataSize
107 );
108
109 #endif