]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/FwVol/FwVol.h
Add core FFS3 support, PeiCore and DxeIpl.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / FwVol / FwVol.h
CommitLineData
3b428ade 1/** @file\r
2 The internal header file for firmware volume related definitions.\r
3 \r
890e5417 4Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 5This program and the accompanying materials \r
3b428ade 6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14\r
15#ifndef _FWVOL_H_\r
16#define _FWVOL_H_\r
17\r
18#include "PeiMain.h"\r
19\r
20#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \\r
21 ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))\r
22\r
23\r
890e5417
SZ
24#define PEI_FW_VOL_SIGNATURE SIGNATURE_32('P','F','W','V')\r
25\r
26typedef struct {\r
27 UINTN Signature;\r
28 BOOLEAN IsFfs3Fv;\r
29 EFI_PEI_FIRMWARE_VOLUME_PPI Fv;\r
30} PEI_FW_VOL_INSTANCE;\r
31\r
32#define PEI_FW_VOL_INSTANCE_FROM_FV_THIS(a) \\r
33 CR(a, PEI_FW_VOL_INSTANCE, Fv, PEI_FW_VOL_SIGNATURE)\r
34\r
35\r
3b428ade 36/**\r
37 Process a firmware volume and create a volume handle.\r
38\r
39 Create a volume handle from the information in the buffer. For\r
40 memory-mapped firmware volumes, Buffer and BufferSize refer to\r
41 the start of the firmware volume and the firmware volume size.\r
42 For non memory-mapped firmware volumes, this points to a\r
43 buffer which contains the necessary information for creating\r
44 the firmware volume handle. Normally, these values are derived\r
45 from the EFI_FIRMWARE_VOLUME_INFO_PPI.\r
46 \r
47 \r
48 @param This Points to this instance of the\r
49 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
50 @param Buffer Points to the start of the buffer.\r
51 @param BufferSize Size of the buffer.\r
52 @param FvHandle Points to the returned firmware volume\r
53 handle. The firmware volume handle must\r
54 be unique within the system. \r
55\r
56 @retval EFI_SUCCESS Firmware volume handle created.\r
57 @retval EFI_VOLUME_CORRUPTED Volume was corrupt.\r
58\r
59**/\r
60EFI_STATUS\r
61EFIAPI\r
890e5417 62PeiFfsFvPpiProcessVolume (\r
3b428ade 63 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
64 IN VOID *Buffer,\r
65 IN UINTN BufferSize,\r
66 OUT EFI_PEI_FV_HANDLE *FvHandle\r
67 );\r
68 \r
69/**\r
70 Finds the next file of the specified type.\r
71\r
72 This service enables PEI modules to discover additional firmware files. \r
73 The FileHandle must be unique within the system.\r
74\r
75 @param This Points to this instance of the\r
76 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
77 @param SearchType A filter to find only files of this type. Type\r
78 EFI_FV_FILETYPE_ALL causes no filtering to be\r
79 done.\r
80 @param FvHandle Handle of firmware volume in which to\r
81 search.\r
82 @param FileHandle Points to the current handle from which to\r
83 begin searching or NULL to start at the\r
84 beginning of the firmware volume. Updated\r
85 upon return to reflect the file found.\r
86\r
87 @retval EFI_SUCCESS The file was found.\r
88 @retval EFI_NOT_FOUND The file was not found. FileHandle contains NULL.\r
89\r
90**/ \r
91EFI_STATUS\r
92EFIAPI\r
890e5417 93PeiFfsFvPpiFindFileByType (\r
3b428ade 94 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
95 IN EFI_FV_FILETYPE SearchType,\r
96 IN EFI_PEI_FV_HANDLE FvHandle,\r
97 IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r
98 );\r
99\r
100/**\r
101 Find a file within a volume by its name. \r
102 \r
103 This service searches for files with a specific name, within\r
104 either the specified firmware volume or all firmware volumes.\r
105\r
106 @param This Points to this instance of the\r
107 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
108 @param FileName A pointer to the name of the file to find\r
109 within the firmware volume.\r
110 @param FvHandle Upon entry, the pointer to the firmware\r
111 volume to search or NULL if all firmware\r
112 volumes should be searched. Upon exit, the\r
113 actual firmware volume in which the file was\r
114 found.\r
115 @param FileHandle Upon exit, points to the found file's\r
116 handle or NULL if it could not be found.\r
117\r
118 @retval EFI_SUCCESS File was found.\r
119 @retval EFI_NOT_FOUND File was not found.\r
120 @retval EFI_INVALID_PARAMETER FvHandle or FileHandle or\r
121 FileName was NULL.\r
122\r
123\r
124**/ \r
125EFI_STATUS\r
126EFIAPI\r
890e5417 127PeiFfsFvPpiFindFileByName (\r
3b428ade 128 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
129 IN CONST EFI_GUID *FileName,\r
130 IN EFI_PEI_FV_HANDLE *FvHandle,\r
131 OUT EFI_PEI_FILE_HANDLE *FileHandle \r
132 );\r
133\r
134/**\r
135 Find the next matching section in the firmware file.\r
136 \r
137 This service enables PEI modules to discover sections\r
138 of a given type within a valid file.\r
139 \r
140 @param This Points to this instance of the\r
141 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
142 @param SearchType A filter to find only sections of this\r
143 type.\r
144 @param FileHandle Handle of firmware file in which to\r
145 search.\r
146 @param SectionData Updated upon return to point to the\r
147 section found.\r
148 \r
149 @retval EFI_SUCCESS Section was found.\r
150 @retval EFI_NOT_FOUND Section of the specified type was not\r
151 found. SectionData contains NULL.\r
152**/ \r
153EFI_STATUS\r
154EFIAPI\r
890e5417 155PeiFfsFvPpiFindSectionByType (\r
3b428ade 156 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,\r
157 IN EFI_SECTION_TYPE SearchType,\r
158 IN EFI_PEI_FILE_HANDLE FileHandle,\r
159 OUT VOID **SectionData\r
160 );\r
161\r
162/**\r
163 Returns information about a specific file.\r
164\r
165 This function returns information about a specific\r
166 file, including its file name, type, attributes, starting\r
167 address and size. \r
168 \r
169 @param This Points to this instance of the\r
170 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
171 @param FileHandle Handle of the file.\r
172 @param FileInfo Upon exit, points to the file's\r
173 information.\r
174\r
175 @retval EFI_SUCCESS File information returned.\r
176 @retval EFI_INVALID_PARAMETER If FileHandle does not\r
177 represent a valid file.\r
178 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
179 \r
180**/ \r
181EFI_STATUS\r
182EFIAPI\r
890e5417 183PeiFfsFvPpiGetFileInfo (\r
3b428ade 184 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, \r
185 IN EFI_PEI_FILE_HANDLE FileHandle, \r
186 OUT EFI_FV_FILE_INFO *FileInfo\r
187 );\r
188\r
189/**\r
190 This function returns information about the firmware volume.\r
191 \r
192 @param This Points to this instance of the\r
193 EFI_PEI_FIRMWARE_VOLUME_PPI.\r
194 @param FvHandle Handle to the firmware handle.\r
195 @param VolumeInfo Points to the returned firmware volume\r
196 information.\r
197\r
198 @retval EFI_SUCCESS Information returned successfully.\r
199 @retval EFI_INVALID_PARAMETER FvHandle does not indicate a valid\r
200 firmware volume or VolumeInfo is NULL.\r
201\r
202**/ \r
203EFI_STATUS\r
204EFIAPI\r
890e5417 205PeiFfsFvPpiGetVolumeInfo (\r
3b428ade 206 IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This, \r
207 IN EFI_PEI_FV_HANDLE FvHandle, \r
208 OUT EFI_FV_INFO *VolumeInfo\r
209 );\r
210\r
211/**\r
212 Convert the handle of FV to pointer of corresponding PEI_CORE_FV_HANDLE.\r
213 \r
214 @param FvHandle The handle of a FV.\r
215 \r
216 @retval NULL if can not find.\r
217 @return Pointer of corresponding PEI_CORE_FV_HANDLE. \r
218**/\r
219PEI_CORE_FV_HANDLE *\r
220FvHandleToCoreHandle (\r
221 IN EFI_PEI_FV_HANDLE FvHandle\r
222 );\r
223 \r
224/**\r
225 Given the input file pointer, search for the next matching file in the\r
226 FFS volume as defined by SearchType. The search starts from FileHeader inside\r
227 the Firmware Volume defined by FwVolHeader.\r
228\r
229\r
230 @param FvHandle Pointer to the FV header of the volume to search\r
231 @param FileName File name\r
232 @param SearchType Filter to find only files of this type.\r
233 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
234 @param FileHandle This parameter must point to a valid FFS volume.\r
235 @param AprioriFile Pointer to AprioriFile image in this FV if has\r
236\r
237 @return EFI_NOT_FOUND No files matching the search criteria were found\r
238 @retval EFI_SUCCESS Success to search given file\r
239\r
240**/\r
241EFI_STATUS\r
242FindFileEx (\r
243 IN CONST EFI_PEI_FV_HANDLE FvHandle,\r
244 IN CONST EFI_GUID *FileName, OPTIONAL\r
245 IN EFI_FV_FILETYPE SearchType,\r
246 IN OUT EFI_PEI_FILE_HANDLE *FileHandle,\r
247 IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL\r
248 );\r
249\r
f3358329 250/**\r
251 Report the information for a new discoveried FV in unknown format.\r
252 \r
253 If the EFI_PEI_FIRMWARE_VOLUME_PPI has not been install for specifical FV format, but\r
254 the FV in this FV format has been discoveried, then the information of this FV\r
255 will be cached into PEI_CORE_INSTANCE's UnknownFvInfo array.\r
256 Also a notification would be installed for unknown FV format guid, if EFI_PEI_FIRMWARE_VOLUME_PPI\r
257 is installed later by platform's PEIM, the original unknown FV will be processed by\r
258 using new installed EFI_PEI_FIRMWARE_VOLUME_PPI.\r
259 \r
260 @param PrivateData Point to instance of PEI_CORE_INSTANCE\r
261 @param Format Point to the unknown FV format guid.\r
262 @param FvInfo Point to FvInfo buffer.\r
263 @param FvInfoSize The size of FvInfo buffer.\r
264 \r
265 @retval EFI_OUT_OF_RESOURCES The FV info array in PEI_CORE_INSTANCE has no more spaces.\r
266 @retval EFI_SUCCESS Success to add the information for unknown FV.\r
267**/\r
268EFI_STATUS\r
269AddUnknownFormatFvInfo (\r
270 IN PEI_CORE_INSTANCE *PrivateData,\r
271 IN EFI_GUID *Format,\r
272 IN VOID *FvInfo,\r
273 IN UINT32 FvInfoSize\r
274 );\r
275 \r
276/**\r
277 Find the FV information according to FV format guid.\r
278 \r
279 This routine also will remove the FV information found by given FV format guid from\r
280 PrivateData->UnknownFvInfo[].\r
281 \r
282 @param PrivateData Point to instance of PEI_CORE_INSTANCE\r
283 @param Format Point to given FV format guid\r
284 @param FvInfo On return, the pointer of FV information buffer in given FV format guid\r
285 @param FvInfoSize On return, the size of FV information buffer.\r
286 \r
287 @retval EFI_NOT_FOUND The FV is not found for new installed EFI_PEI_FIRMWARE_VOLUME_PPI\r
288 @retval EFI_SUCCESS Success to find a FV which could be processed by new installed EFI_PEI_FIRMWARE_VOLUME_PPI.\r
289**/\r
290EFI_STATUS\r
291FindUnknownFormatFvInfo (\r
292 IN PEI_CORE_INSTANCE *PrivateData,\r
293 IN EFI_GUID *Format,\r
294 OUT VOID **FvInfo,\r
295 OUT UINT32 *FvInfoSize\r
296 );\r
297 \r
298/**\r
299 Notification callback function for EFI_PEI_FIRMWARE_VOLUME_PPI.\r
300 \r
301 When a EFI_PEI_FIRMWARE_VOLUME_PPI is installed to support new FV format, this \r
302 routine is called to process all discoveried FVs in this format.\r
303 \r
304 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
305 @param NotifyDescriptor Address of the notification descriptor data structure.\r
306 @param Ppi Address of the PPI that was installed.\r
307 \r
308 @retval EFI_SUCCESS The notification callback is processed correctly.\r
309**/\r
310EFI_STATUS\r
311EFIAPI\r
312ThirdPartyFvPpiNotifyCallback (\r
313 IN EFI_PEI_SERVICES **PeiServices,\r
314 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
315 IN VOID *Ppi\r
316 ); \r
317 \r
3b428ade 318#endif \r