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