• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2 These functions assist in parsing and manipulating a Firmware Volume.
3 
4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution.  The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9 
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #ifndef _EFI_FV_LIB_H
16 #define _EFI_FV_LIB_H
17 
18 //
19 // Include files
20 //
21 #include <string.h>
22 
23 #include <Common/UefiBaseTypes.h>
24 #include <Common/PiFirmwareFile.h>
25 #include <Common/PiFirmwareVolume.h>
26 
27 EFI_STATUS
28 InitializeFvLib (
29   IN VOID                         *Fv,
30   IN UINT32                       FvLength
31   )
32 ;
33 
34 EFI_STATUS
35 GetFvHeader (
36   OUT EFI_FIRMWARE_VOLUME_HEADER  **FvHeader,
37   OUT UINT32                      *FvLength
38   )
39 ;
40 
41 EFI_STATUS
42 GetNextFile (
43   IN EFI_FFS_FILE_HEADER          *CurrentFile,
44   OUT EFI_FFS_FILE_HEADER         **NextFile
45   )
46 ;
47 
48 EFI_STATUS
49 GetFileByName (
50   IN EFI_GUID                     *FileName,
51   OUT EFI_FFS_FILE_HEADER         **File
52   )
53 ;
54 
55 EFI_STATUS
56 GetFileByType (
57   IN EFI_FV_FILETYPE              FileType,
58   IN UINTN                        Instance,
59   OUT EFI_FFS_FILE_HEADER         **File
60   )
61 ;
62 
63 EFI_STATUS
64 GetSectionByType (
65   IN EFI_FFS_FILE_HEADER          *File,
66   IN EFI_SECTION_TYPE             SectionType,
67   IN UINTN                        Instance,
68   OUT EFI_FILE_SECTION_POINTER    *Section
69   )
70 ;
71 //
72 // will not parse compressed sections
73 //
74 EFI_STATUS
75 VerifyFv (
76   IN EFI_FIRMWARE_VOLUME_HEADER   *FvHeader
77   )
78 ;
79 
80 EFI_STATUS
81 VerifyFfsFile (
82   IN EFI_FFS_FILE_HEADER          *FfsHeader
83   )
84 ;
85 
86 UINT32
87 GetFfsFileLength (
88   EFI_FFS_FILE_HEADER *FfsHeader
89   )
90 ;
91 
92 UINT32
93 GetSectionFileLength (
94   EFI_COMMON_SECTION_HEADER *SectionHeader
95   )
96 ;
97 
98 UINT32
99 GetFfsHeaderLength(
100    IN EFI_FFS_FILE_HEADER *FfsHeader
101    )
102 ;
103 
104 UINT32
105 GetSectionHeaderLength(
106    IN EFI_COMMON_SECTION_HEADER *SectionHeader
107    )
108 ;
109 
110 /*++
111 
112 Routine Description:
113 
114   Verify the current pointer points to a FFS file header.
115 
116 Arguments:
117 
118   FfsHeader     Pointer to an alleged FFS file.
119 
120 Returns:
121 
122   EFI_SUCCESS           The Ffs header is valid.
123   EFI_NOT_FOUND         This "file" is the beginning of free space.
124   EFI_VOLUME_CORRUPTED  The Ffs header is not valid.
125 
126 --*/
127 UINT32
128 GetLength (
129   UINT8                           *ThreeByteLength
130   )
131 ;
132 
133 /*++
134 
135 Routine Description:
136 
137   Converts a three byte length value into a UINT32.
138 
139 Arguments:
140 
141   ThreeByteLength   Pointer to the first of the 3 byte length.
142 
143 Returns:
144 
145   UINT32      Size of the section
146 
147 --*/
148 EFI_STATUS
149 GetErasePolarity (
150   OUT BOOLEAN   *ErasePolarity
151   )
152 ;
153 
154 /*++
155 
156 Routine Description:
157 
158   This function returns with the FV erase polarity.  If the erase polarity
159   for a bit is 1, the function return TRUE.
160 
161 Arguments:
162 
163   ErasePolarity   A pointer to the erase polarity.
164 
165 Returns:
166 
167   EFI_SUCCESS              The function completed successfully.
168   EFI_INVALID_PARAMETER    One of the input parameters was invalid.
169 
170 --*/
171 UINT8
172 GetFileState (
173   IN BOOLEAN              ErasePolarity,
174   IN EFI_FFS_FILE_HEADER  *FfsHeader
175   )
176 ;
177 
178 /*++
179 
180 Routine Description:
181 
182   This function returns a the highest state bit in the FFS that is set.
183   It in no way validate the FFS file.
184 
185 Arguments:
186 
187   ErasePolarity The erase polarity for the file state bits.
188   FfsHeader     Pointer to a FFS file.
189 
190 Returns:
191 
192   UINT8   The hightest set state of the file.
193 
194 --*/
195 #endif
196