]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Implementation for PEI Services Library.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php.\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | \r | |
16 | #include <PiPei.h>\r | |
17 | \r | |
18 | #include <Ppi/FirmwareVolumeInfo.h>\r | |
19 | #include <Ppi/FirmwareVolumeInfo2.h>\r | |
20 | #include <Guid/FirmwareFileSystem2.h>\r | |
21 | \r | |
22 | #include <Library/PeiServicesLib.h>\r | |
23 | #include <Library/PeiServicesTablePointerLib.h>\r | |
24 | #include <Library/DebugLib.h>\r | |
25 | #include <Library/MemoryAllocationLib.h>\r | |
26 | #include <Library/BaseMemoryLib.h>\r | |
27 | \r | |
28 | /**\r | |
29 | This service enables a given PEIM to register an interface into the PEI Foundation.\r | |
30 | \r | |
31 | @param PpiList A pointer to the list of interfaces that the caller shall install.\r | |
32 | \r | |
33 | @retval EFI_SUCCESS The interface was successfully installed.\r | |
34 | @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r | |
35 | @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r | |
36 | EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r | |
37 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r | |
38 | \r | |
39 | **/\r | |
40 | EFI_STATUS\r | |
41 | EFIAPI\r | |
42 | PeiServicesInstallPpi (\r | |
43 | IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r | |
44 | )\r | |
45 | {\r | |
46 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
47 | \r | |
48 | PeiServices = GetPeiServicesTablePointer ();\r | |
49 | return (*PeiServices)->InstallPpi (PeiServices, PpiList);\r | |
50 | }\r | |
51 | \r | |
52 | /**\r | |
53 | This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r | |
54 | \r | |
55 | @param OldPpi The pointer to the old PEI PPI Descriptors.\r | |
56 | @param NewPpi The pointer to the new PEI PPI Descriptors.\r | |
57 | \r | |
58 | @retval EFI_SUCCESS The interface was successfully installed.\r | |
59 | @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r | |
60 | @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r | |
61 | EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r | |
62 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r | |
63 | @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been\r | |
64 | installed.\r | |
65 | \r | |
66 | **/\r | |
67 | EFI_STATUS\r | |
68 | EFIAPI\r | |
69 | PeiServicesReInstallPpi (\r | |
70 | IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r | |
71 | IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r | |
72 | )\r | |
73 | {\r | |
74 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
75 | \r | |
76 | PeiServices = GetPeiServicesTablePointer ();\r | |
77 | return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi);\r | |
78 | }\r | |
79 | \r | |
80 | /**\r | |
81 | This service enables PEIMs to discover a given instance of an interface.\r | |
82 | \r | |
83 | @param Guid A pointer to the GUID whose corresponding interface needs to be\r | |
84 | found.\r | |
85 | @param Instance The N-th instance of the interface that is required.\r | |
86 | @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r | |
87 | @param Ppi A pointer to the instance of the interface.\r | |
88 | \r | |
89 | @retval EFI_SUCCESS The interface was successfully returned.\r | |
90 | @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.\r | |
91 | \r | |
92 | **/\r | |
93 | EFI_STATUS\r | |
94 | EFIAPI\r | |
95 | PeiServicesLocatePpi (\r | |
96 | IN CONST EFI_GUID *Guid,\r | |
97 | IN UINTN Instance,\r | |
98 | IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r | |
99 | IN OUT VOID **Ppi\r | |
100 | )\r | |
101 | {\r | |
102 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
103 | \r | |
104 | PeiServices = GetPeiServicesTablePointer ();\r | |
105 | return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);\r | |
106 | }\r | |
107 | \r | |
108 | /**\r | |
109 | This service enables PEIMs to register a given service to be invoked when another service is\r | |
110 | installed or reinstalled.\r | |
111 | \r | |
112 | @param NotifyList A pointer to the list of notification interfaces \r | |
113 | that the caller shall install.\r | |
114 | \r | |
115 | @retval EFI_SUCCESS The interface was successfully installed.\r | |
116 | @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r | |
117 | @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do\r | |
118 | not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES\r | |
119 | bit set in the Flags field.\r | |
120 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r | |
121 | \r | |
122 | **/\r | |
123 | EFI_STATUS\r | |
124 | EFIAPI\r | |
125 | PeiServicesNotifyPpi (\r | |
126 | IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r | |
127 | )\r | |
128 | {\r | |
129 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
130 | \r | |
131 | PeiServices = GetPeiServicesTablePointer ();\r | |
132 | return (*PeiServices)->NotifyPpi (PeiServices, NotifyList);\r | |
133 | }\r | |
134 | \r | |
135 | /**\r | |
136 | This service enables PEIMs to ascertain the present value of the boot mode.\r | |
137 | \r | |
138 | @param BootMode A pointer to contain the value of the boot mode.\r | |
139 | \r | |
140 | @retval EFI_SUCCESS The boot mode was returned successfully.\r | |
141 | @retval EFI_INVALID_PARAMETER BootMode is NULL.\r | |
142 | \r | |
143 | **/\r | |
144 | EFI_STATUS\r | |
145 | EFIAPI\r | |
146 | PeiServicesGetBootMode (\r | |
147 | OUT EFI_BOOT_MODE *BootMode\r | |
148 | )\r | |
149 | {\r | |
150 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
151 | \r | |
152 | PeiServices = GetPeiServicesTablePointer ();\r | |
153 | return (*PeiServices)->GetBootMode (PeiServices, BootMode);\r | |
154 | }\r | |
155 | \r | |
156 | /**\r | |
157 | This service enables PEIMs to update the boot mode variable.\r | |
158 | \r | |
159 | @param BootMode The value of the boot mode to set.\r | |
160 | \r | |
161 | @retval EFI_SUCCESS The value was successfully updated\r | |
162 | \r | |
163 | **/\r | |
164 | EFI_STATUS\r | |
165 | EFIAPI\r | |
166 | PeiServicesSetBootMode (\r | |
167 | IN EFI_BOOT_MODE BootMode\r | |
168 | )\r | |
169 | {\r | |
170 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
171 | \r | |
172 | PeiServices = GetPeiServicesTablePointer ();\r | |
173 | return (*PeiServices)->SetBootMode (PeiServices, BootMode);\r | |
174 | }\r | |
175 | \r | |
176 | /**\r | |
177 | This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r | |
178 | \r | |
179 | @param HobList A pointer to the list of HOBs that the PEI Foundation \r | |
180 | will initialize.\r | |
181 | \r | |
182 | @retval EFI_SUCCESS The list was successfully returned.\r | |
183 | @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r | |
184 | \r | |
185 | **/\r | |
186 | EFI_STATUS\r | |
187 | EFIAPI\r | |
188 | PeiServicesGetHobList (\r | |
189 | OUT VOID **HobList\r | |
190 | )\r | |
191 | {\r | |
192 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
193 | \r | |
194 | PeiServices = GetPeiServicesTablePointer ();\r | |
195 | return (*PeiServices)->GetHobList (PeiServices, HobList);\r | |
196 | }\r | |
197 | \r | |
198 | /**\r | |
199 | This service enables PEIMs to create various types of HOBs.\r | |
200 | \r | |
201 | @param Type The type of HOB to be installed.\r | |
202 | @param Length The length of the HOB to be added.\r | |
203 | @param Hob The address of a pointer that will contain the \r | |
204 | HOB header.\r | |
205 | \r | |
206 | @retval EFI_SUCCESS The HOB was successfully created.\r | |
207 | @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r | |
208 | \r | |
209 | **/\r | |
210 | EFI_STATUS\r | |
211 | EFIAPI\r | |
212 | PeiServicesCreateHob (\r | |
213 | IN UINT16 Type,\r | |
214 | IN UINT16 Length,\r | |
215 | OUT VOID **Hob\r | |
216 | )\r | |
217 | {\r | |
218 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
219 | \r | |
220 | PeiServices = GetPeiServicesTablePointer ();\r | |
221 | return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob);\r | |
222 | }\r | |
223 | \r | |
224 | /**\r | |
225 | This service enables PEIMs to discover additional firmware volumes.\r | |
226 | \r | |
227 | @param Instance This instance of the firmware volume to find. The \r | |
228 | value 0 is the Boot Firmware Volume (BFV).\r | |
229 | @param VolumeHandle Handle of the firmware volume header of the volume\r | |
230 | to return.\r | |
231 | \r | |
232 | @retval EFI_SUCCESS The volume was found.\r | |
233 | @retval EFI_NOT_FOUND The volume was not found.\r | |
234 | @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r | |
235 | \r | |
236 | **/\r | |
237 | EFI_STATUS\r | |
238 | EFIAPI\r | |
239 | PeiServicesFfsFindNextVolume (\r | |
240 | IN UINTN Instance,\r | |
241 | IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r | |
242 | )\r | |
243 | {\r | |
244 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
245 | \r | |
246 | PeiServices = GetPeiServicesTablePointer ();\r | |
247 | return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, VolumeHandle);\r | |
248 | }\r | |
249 | \r | |
250 | /**\r | |
251 | This service enables PEIMs to discover additional firmware files.\r | |
252 | \r | |
253 | @param SearchType A filter to find files only of this type.\r | |
254 | @param VolumeHandle The pointer to the firmware volume header of the \r | |
255 | volume to search. This parameter must point to a \r | |
256 | valid FFS volume. \r | |
257 | @param FileHandle Handle of the current file from which to begin searching.\r | |
258 | \r | |
259 | @retval EFI_SUCCESS The file was found.\r | |
260 | @retval EFI_NOT_FOUND The file was not found.\r | |
261 | @retval EFI_NOT_FOUND The header checksum was not zero.\r | |
262 | \r | |
263 | **/\r | |
264 | EFI_STATUS\r | |
265 | EFIAPI\r | |
266 | PeiServicesFfsFindNextFile (\r | |
267 | IN EFI_FV_FILETYPE SearchType,\r | |
268 | IN EFI_PEI_FV_HANDLE VolumeHandle,\r | |
269 | IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r | |
270 | )\r | |
271 | {\r | |
272 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
273 | \r | |
274 | PeiServices = GetPeiServicesTablePointer ();\r | |
275 | return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, VolumeHandle, FileHandle);\r | |
276 | }\r | |
277 | \r | |
278 | /**\r | |
279 | This service enables PEIMs to discover sections of a given type within a valid FFS file.\r | |
280 | \r | |
281 | @param SectionType The value of the section type to find.\r | |
282 | @param FileHandle A pointer to the file header that contains the set \r | |
283 | of sections to be searched.\r | |
284 | @param SectionData A pointer to the discovered section, if successful.\r | |
285 | \r | |
286 | @retval EFI_SUCCESS The section was found.\r | |
287 | @retval EFI_NOT_FOUND The section was not found.\r | |
288 | \r | |
289 | **/\r | |
290 | EFI_STATUS\r | |
291 | EFIAPI\r | |
292 | PeiServicesFfsFindSectionData (\r | |
293 | IN EFI_SECTION_TYPE SectionType,\r | |
294 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
295 | OUT VOID **SectionData\r | |
296 | )\r | |
297 | {\r | |
298 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
299 | \r | |
300 | PeiServices = GetPeiServicesTablePointer ();\r | |
301 | return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FileHandle, SectionData);\r | |
302 | }\r | |
303 | \r | |
304 | /**\r | |
305 | This service enables PEIMs to discover sections of a given instance and type within a valid FFS file.\r | |
306 | \r | |
307 | @param SectionType The value of the section type to find.\r | |
308 | @param SectionInstance Section instance to find.\r | |
309 | @param FileHandle A pointer to the file header that contains the set \r | |
310 | of sections to be searched.\r | |
311 | @param SectionData A pointer to the discovered section, if successful.\r | |
312 | @param AuthenticationStatus A pointer to the authentication status for this section.\r | |
313 | \r | |
314 | @retval EFI_SUCCESS The section was found.\r | |
315 | @retval EFI_NOT_FOUND The section was not found.\r | |
316 | \r | |
317 | **/\r | |
318 | EFI_STATUS\r | |
319 | EFIAPI\r | |
320 | PeiServicesFfsFindSectionData3 (\r | |
321 | IN EFI_SECTION_TYPE SectionType,\r | |
322 | IN UINTN SectionInstance,\r | |
323 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
324 | OUT VOID **SectionData,\r | |
325 | OUT UINT32 *AuthenticationStatus\r | |
326 | )\r | |
327 | {\r | |
328 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
329 | \r | |
330 | PeiServices = GetPeiServicesTablePointer ();\r | |
331 | return (*PeiServices)->FindSectionData3 (PeiServices, SectionType, SectionInstance, FileHandle, SectionData, AuthenticationStatus);\r | |
332 | }\r | |
333 | \r | |
334 | /**\r | |
335 | This service enables PEIMs to register the permanent memory configuration\r | |
336 | that has been initialized with the PEI Foundation.\r | |
337 | \r | |
338 | @param MemoryBegin The value of a region of installed memory.\r | |
339 | @param MemoryLength The corresponding length of a region of installed memory.\r | |
340 | \r | |
341 | @retval EFI_SUCCESS The region was successfully installed in a HOB.\r | |
342 | @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r | |
343 | @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r | |
344 | \r | |
345 | **/\r | |
346 | EFI_STATUS\r | |
347 | EFIAPI\r | |
348 | PeiServicesInstallPeiMemory (\r | |
349 | IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r | |
350 | IN UINT64 MemoryLength\r | |
351 | )\r | |
352 | {\r | |
353 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
354 | \r | |
355 | PeiServices = GetPeiServicesTablePointer ();\r | |
356 | return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength);\r | |
357 | }\r | |
358 | \r | |
359 | /**\r | |
360 | This service enables PEIMs to allocate memory.\r | |
361 | \r | |
362 | @param MemoryType Type of memory to allocate.\r | |
363 | @param Pages The number of pages to allocate.\r | |
364 | @param Memory Pointer of memory allocated.\r | |
365 | \r | |
366 | @retval EFI_SUCCESS The memory range was successfully allocated.\r | |
367 | @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,\r | |
368 | EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,\r | |
369 | EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.\r | |
370 | @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.\r | |
371 | \r | |
372 | **/\r | |
373 | EFI_STATUS\r | |
374 | EFIAPI\r | |
375 | PeiServicesAllocatePages (\r | |
376 | IN EFI_MEMORY_TYPE MemoryType,\r | |
377 | IN UINTN Pages,\r | |
378 | OUT EFI_PHYSICAL_ADDRESS *Memory\r | |
379 | )\r | |
380 | {\r | |
381 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
382 | \r | |
383 | PeiServices = GetPeiServicesTablePointer ();\r | |
384 | return (*PeiServices)->AllocatePages (PeiServices, MemoryType, Pages, Memory);\r | |
385 | }\r | |
386 | \r | |
387 | /**\r | |
388 | This service enables PEIMs to free memory.\r | |
389 | \r | |
390 | @param Memory Memory to be freed.\r | |
391 | @param Pages The number of pages to free.\r | |
392 | \r | |
393 | @retval EFI_SUCCESS The requested pages were freed.\r | |
394 | @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.\r | |
395 | @retval EFI_NOT_FOUND The requested memory pages were not allocated with\r | |
396 | AllocatePages().\r | |
397 | \r | |
398 | **/\r | |
399 | EFI_STATUS\r | |
400 | EFIAPI\r | |
401 | PeiServicesFreePages (\r | |
402 | IN EFI_PHYSICAL_ADDRESS Memory,\r | |
403 | IN UINTN Pages\r | |
404 | )\r | |
405 | {\r | |
406 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
407 | \r | |
408 | PeiServices = GetPeiServicesTablePointer ();\r | |
409 | return (*PeiServices)->FreePages (PeiServices, Memory, Pages);\r | |
410 | }\r | |
411 | \r | |
412 | /**\r | |
413 | This service allocates memory from the Hand-Off Block (HOB) heap.\r | |
414 | \r | |
415 | @param Size The number of bytes to allocate from the pool.\r | |
416 | @param Buffer If the call succeeds, a pointer to a pointer to \r | |
417 | the allocate buffer; otherwise, undefined.\r | |
418 | \r | |
419 | @retval EFI_SUCCESS The allocation was successful\r | |
420 | @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.\r | |
421 | \r | |
422 | **/\r | |
423 | EFI_STATUS\r | |
424 | EFIAPI\r | |
425 | PeiServicesAllocatePool (\r | |
426 | IN UINTN Size,\r | |
427 | OUT VOID **Buffer\r | |
428 | )\r | |
429 | {\r | |
430 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
431 | \r | |
432 | PeiServices = GetPeiServicesTablePointer ();\r | |
433 | return (*PeiServices)->AllocatePool (PeiServices, Size, Buffer);\r | |
434 | }\r | |
435 | \r | |
436 | /**\r | |
437 | Resets the entire platform.\r | |
438 | \r | |
439 | @retval EFI_SUCCESS The function completed successfully.\r | |
440 | @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r | |
441 | \r | |
442 | **/\r | |
443 | EFI_STATUS\r | |
444 | EFIAPI\r | |
445 | PeiServicesResetSystem (\r | |
446 | VOID\r | |
447 | )\r | |
448 | {\r | |
449 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
450 | \r | |
451 | PeiServices = GetPeiServicesTablePointer ();\r | |
452 | return (*PeiServices)->ResetSystem (PeiServices);\r | |
453 | }\r | |
454 | \r | |
455 | /**\r | |
456 | This service is a wrapper for the PEI Service RegisterForShadow(), except the \r | |
457 | pointer to the PEI Services Table has been removed. See the Platform \r | |
458 | Initialization Pre-EFI Initialization Core Interface Specification for details. \r | |
459 | \r | |
460 | @param FileHandle PEIM's file handle. Must be the currently\r | |
461 | executing PEIM.\r | |
462 | \r | |
463 | @retval EFI_SUCCESS The PEIM was successfully registered for\r | |
464 | shadowing.\r | |
465 | \r | |
466 | @retval EFI_ALREADY_STARTED The PEIM was previously\r | |
467 | registered for shadowing.\r | |
468 | \r | |
469 | @retval EFI_NOT_FOUND The FileHandle does not refer to a\r | |
470 | valid file handle.\r | |
471 | **/\r | |
472 | EFI_STATUS\r | |
473 | EFIAPI\r | |
474 | PeiServicesRegisterForShadow (\r | |
475 | IN EFI_PEI_FILE_HANDLE FileHandle\r | |
476 | )\r | |
477 | {\r | |
478 | return (*GetPeiServicesTablePointer())->RegisterForShadow (FileHandle);\r | |
479 | }\r | |
480 | \r | |
481 | /**\r | |
482 | This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services \r | |
483 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface \r | |
484 | Specification for details. \r | |
485 | \r | |
486 | @param FileHandle The handle of the file.\r | |
487 | \r | |
488 | @param FileInfo Upon exit, points to the file's\r | |
489 | information.\r | |
490 | \r | |
491 | @retval EFI_SUCCESS File information returned.\r | |
492 | \r | |
493 | @retval EFI_INVALID_PARAMETER If FileHandle does not\r | |
494 | represent a valid file.\r | |
495 | \r | |
496 | @retval EFI_INVALID_PARAMETER FileInfo is NULL.\r | |
497 | \r | |
498 | **/\r | |
499 | EFI_STATUS\r | |
500 | EFIAPI \r | |
501 | PeiServicesFfsGetFileInfo (\r | |
502 | IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r | |
503 | OUT EFI_FV_FILE_INFO *FileInfo\r | |
504 | )\r | |
505 | {\r | |
506 | return (*GetPeiServicesTablePointer())->FfsGetFileInfo (FileHandle, FileInfo);\r | |
507 | }\r | |
508 | \r | |
509 | /**\r | |
510 | This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services\r | |
511 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r | |
512 | Specification for details.\r | |
513 | \r | |
514 | @param FileHandle The handle of the file.\r | |
515 | @param FileInfo Upon exit, points to the file's\r | |
516 | information.\r | |
517 | \r | |
518 | @retval EFI_SUCCESS File information returned.\r | |
519 | @retval EFI_INVALID_PARAMETER If FileHandle does not\r | |
520 | represent a valid file.\r | |
521 | @retval EFI_INVALID_PARAMETER FileInfo is NULL.\r | |
522 | \r | |
523 | **/\r | |
524 | EFI_STATUS\r | |
525 | EFIAPI\r | |
526 | PeiServicesFfsGetFileInfo2 (\r | |
527 | IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r | |
528 | OUT EFI_FV_FILE_INFO2 *FileInfo\r | |
529 | )\r | |
530 | {\r | |
531 | return (*GetPeiServicesTablePointer())->FfsGetFileInfo2 (FileHandle, FileInfo);\r | |
532 | }\r | |
533 | \r | |
534 | /**\r | |
535 | This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services \r | |
536 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface \r | |
537 | Specification for details. \r | |
538 | \r | |
539 | @param FileName A pointer to the name of the file to\r | |
540 | find within the firmware volume.\r | |
541 | \r | |
542 | @param VolumeHandle The firmware volume to search FileHandle\r | |
543 | Upon exit, points to the found file's\r | |
544 | handle or NULL if it could not be found.\r | |
545 | @param FileHandle The pointer to found file handle \r | |
546 | \r | |
547 | @retval EFI_SUCCESS File was found.\r | |
548 | \r | |
549 | @retval EFI_NOT_FOUND File was not found.\r | |
550 | \r | |
551 | @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or\r | |
552 | FileName was NULL.\r | |
553 | \r | |
554 | **/\r | |
555 | EFI_STATUS\r | |
556 | EFIAPI\r | |
557 | PeiServicesFfsFindFileByName (\r | |
558 | IN CONST EFI_GUID *FileName,\r | |
559 | IN CONST EFI_PEI_FV_HANDLE VolumeHandle,\r | |
560 | OUT EFI_PEI_FILE_HANDLE *FileHandle\r | |
561 | )\r | |
562 | {\r | |
563 | return (*GetPeiServicesTablePointer())->FfsFindFileByName (FileName, VolumeHandle, FileHandle);\r | |
564 | }\r | |
565 | \r | |
566 | \r | |
567 | /**\r | |
568 | This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services \r | |
569 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface \r | |
570 | Specification for details. \r | |
571 | \r | |
572 | @param VolumeHandle Handle of the volume.\r | |
573 | \r | |
574 | @param VolumeInfo Upon exit, points to the volume's\r | |
575 | information.\r | |
576 | \r | |
577 | @retval EFI_SUCCESS File information returned.\r | |
578 | \r | |
579 | @retval EFI_INVALID_PARAMETER If FileHandle does not\r | |
580 | represent a valid file.\r | |
581 | \r | |
582 | @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r | |
583 | \r | |
584 | **/\r | |
585 | EFI_STATUS\r | |
586 | EFIAPI\r | |
587 | PeiServicesFfsGetVolumeInfo (\r | |
588 | IN EFI_PEI_FV_HANDLE VolumeHandle,\r | |
589 | OUT EFI_FV_INFO *VolumeInfo\r | |
590 | )\r | |
591 | {\r | |
592 | return (*GetPeiServicesTablePointer())->FfsGetVolumeInfo (VolumeHandle, VolumeInfo);\r | |
593 | }\r | |
594 | \r | |
595 | /**\r | |
596 | Install a EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance so the PEI Core will be notified about a new firmware volume.\r | |
597 | \r | |
598 | This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI using\r | |
599 | the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance.\r | |
600 | If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI, then ASSERT().\r | |
601 | If the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI can not be installed, then ASSERT().\r | |
602 | If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r | |
603 | \r | |
604 | @param InstallFvInfoPpi Install FvInfo Ppi if it is TRUE. Otherwise, install FvInfo2 Ppi.\r | |
605 | @param FvFormat Unique identifier of the format of the memory-mapped\r | |
606 | firmware volume. This parameter is optional and\r | |
607 | may be NULL. If NULL is specified, the\r | |
608 | EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r | |
609 | @param FvInfo Points to a buffer which allows the\r | |
610 | EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r | |
611 | The format of this buffer is specific to the FvFormat.\r | |
612 | For memory-mapped firmware volumes, this typically\r | |
613 | points to the first byte of the firmware volume.\r | |
614 | @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r | |
615 | firmware volumes, this is typically the size of\r | |
616 | the firmware volume.\r | |
617 | @param ParentFvName If the new firmware volume originated from a file\r | |
618 | in a different firmware volume, then this parameter\r | |
619 | specifies the GUID name of the originating firmware\r | |
620 | volume. Otherwise, this parameter must be NULL.\r | |
621 | @param ParentFileName If the new firmware volume originated from a file\r | |
622 | in a different firmware volume, then this parameter\r | |
623 | specifies the GUID file name of the originating\r | |
624 | firmware file. Otherwise, this parameter must be NULL.\r | |
625 | @param AuthenticationStatus Authentication Status, it will be ignored if InstallFvInfoPpi is TRUE.\r | |
626 | **/\r | |
627 | VOID\r | |
628 | EFIAPI\r | |
629 | InternalPeiServicesInstallFvInfoPpi (\r | |
630 | IN BOOLEAN InstallFvInfoPpi,\r | |
631 | IN CONST EFI_GUID *FvFormat, OPTIONAL\r | |
632 | IN CONST VOID *FvInfo,\r | |
633 | IN UINT32 FvInfoSize,\r | |
634 | IN CONST EFI_GUID *ParentFvName, OPTIONAL\r | |
635 | IN CONST EFI_GUID *ParentFileName, OPTIONAL\r | |
636 | IN UINT32 AuthenticationStatus\r | |
637 | )\r | |
638 | {\r | |
639 | EFI_STATUS Status; \r | |
640 | EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi;\r | |
641 | EFI_PEI_PPI_DESCRIPTOR *FvInfoPpiDescriptor;\r | |
642 | EFI_GUID *ParentFvNameValue;\r | |
643 | EFI_GUID *ParentFileNameValue;\r | |
644 | EFI_GUID *PpiGuid;\r | |
645 | \r | |
646 | ParentFvNameValue = NULL;\r | |
647 | ParentFileNameValue = NULL;\r | |
648 | if (InstallFvInfoPpi) {\r | |
649 | //\r | |
650 | // To install FvInfo Ppi.\r | |
651 | //\r | |
652 | FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));\r | |
653 | ASSERT (FvInfoPpi != NULL);\r | |
654 | PpiGuid = &gEfiPeiFirmwareVolumeInfoPpiGuid;\r | |
655 | } else {\r | |
656 | //\r | |
657 | // To install FvInfo2 Ppi.\r | |
658 | //\r | |
659 | FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI));\r | |
660 | ASSERT (FvInfoPpi != NULL);\r | |
661 | ((EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *) FvInfoPpi)->AuthenticationStatus = AuthenticationStatus;\r | |
662 | PpiGuid = &gEfiPeiFirmwareVolumeInfo2PpiGuid;\r | |
663 | }\r | |
664 | \r | |
665 | if (FvFormat != NULL) {\r | |
666 | CopyGuid (&FvInfoPpi->FvFormat, FvFormat);\r | |
667 | } else {\r | |
668 | CopyGuid (&FvInfoPpi->FvFormat, &gEfiFirmwareFileSystem2Guid);\r | |
669 | //\r | |
670 | // Since the EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed if NULL is specified for FvFormat,\r | |
671 | // check the FileSystemGuid pointed by FvInfo against EFI_FIRMWARE_FILE_SYSTEM2_GUID to make sure\r | |
672 | // FvInfo has the firmware file system 2 format.\r | |
673 | // If the ASSERT really appears, FvFormat needs to be specified correctly, for example,\r | |
674 | // EFI_FIRMWARE_FILE_SYSTEM3_GUID can be used for firmware file system 3 format, or\r | |
675 | // ((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo)->FileSystemGuid can be just used for both\r | |
676 | // firmware file system 2 and 3 format.\r | |
677 | //\r | |
678 | ASSERT (CompareGuid (&(((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo)->FileSystemGuid), &gEfiFirmwareFileSystem2Guid));\r | |
679 | }\r | |
680 | FvInfoPpi->FvInfo = (VOID *) FvInfo;\r | |
681 | FvInfoPpi->FvInfoSize = FvInfoSize;\r | |
682 | if (ParentFvName != NULL) {\r | |
683 | ParentFvNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFvName);\r | |
684 | ASSERT (ParentFvNameValue != NULL);\r | |
685 | FvInfoPpi->ParentFvName = ParentFvNameValue;\r | |
686 | }\r | |
687 | if (ParentFileName != NULL) {\r | |
688 | ParentFileNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFileName);\r | |
689 | ASSERT (ParentFileNameValue != NULL);\r | |
690 | FvInfoPpi->ParentFileName = ParentFileNameValue;\r | |
691 | }\r | |
692 | \r | |
693 | FvInfoPpiDescriptor = AllocatePool (sizeof (EFI_PEI_PPI_DESCRIPTOR));\r | |
694 | ASSERT (FvInfoPpiDescriptor != NULL);\r | |
695 | \r | |
696 | FvInfoPpiDescriptor->Guid = PpiGuid;\r | |
697 | FvInfoPpiDescriptor->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r | |
698 | FvInfoPpiDescriptor->Ppi = (VOID *) FvInfoPpi;\r | |
699 | Status = PeiServicesInstallPpi (FvInfoPpiDescriptor);\r | |
700 | ASSERT_EFI_ERROR (Status);\r | |
701 | \r | |
702 | }\r | |
703 | \r | |
704 | /**\r | |
705 | Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.\r | |
706 | \r | |
707 | This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using\r | |
708 | the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.\r | |
709 | If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().\r | |
710 | If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().\r | |
711 | If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r | |
712 | \r | |
713 | @param FvFormat Unique identifier of the format of the memory-mapped\r | |
714 | firmware volume. This parameter is optional and\r | |
715 | may be NULL. If NULL is specified, the\r | |
716 | EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r | |
717 | @param FvInfo Points to a buffer which allows the\r | |
718 | EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r | |
719 | The format of this buffer is specific to the FvFormat.\r | |
720 | For memory-mapped firmware volumes, this typically\r | |
721 | points to the first byte of the firmware volume.\r | |
722 | @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r | |
723 | firmware volumes, this is typically the size of\r | |
724 | the firmware volume.\r | |
725 | @param ParentFvName If the new firmware volume originated from a file\r | |
726 | in a different firmware volume, then this parameter\r | |
727 | specifies the GUID name of the originating firmware\r | |
728 | volume. Otherwise, this parameter must be NULL.\r | |
729 | @param ParentFileName If the new firmware volume originated from a file\r | |
730 | in a different firmware volume, then this parameter\r | |
731 | specifies the GUID file name of the originating\r | |
732 | firmware file. Otherwise, this parameter must be NULL.\r | |
733 | **/\r | |
734 | VOID\r | |
735 | EFIAPI\r | |
736 | PeiServicesInstallFvInfoPpi (\r | |
737 | IN CONST EFI_GUID *FvFormat, OPTIONAL\r | |
738 | IN CONST VOID *FvInfo,\r | |
739 | IN UINT32 FvInfoSize,\r | |
740 | IN CONST EFI_GUID *ParentFvName, OPTIONAL\r | |
741 | IN CONST EFI_GUID *ParentFileName OPTIONAL\r | |
742 | )\r | |
743 | {\r | |
744 | InternalPeiServicesInstallFvInfoPpi (TRUE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, 0);\r | |
745 | }\r | |
746 | \r | |
747 | /**\r | |
748 | Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.\r | |
749 | \r | |
750 | This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using\r | |
751 | the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.\r | |
752 | If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().\r | |
753 | If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().\r | |
754 | If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r | |
755 | \r | |
756 | @param FvFormat Unique identifier of the format of the memory-mapped\r | |
757 | firmware volume. This parameter is optional and\r | |
758 | may be NULL. If NULL is specified, the\r | |
759 | EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r | |
760 | @param FvInfo Points to a buffer which allows the\r | |
761 | EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r | |
762 | The format of this buffer is specific to the FvFormat.\r | |
763 | For memory-mapped firmware volumes, this typically\r | |
764 | points to the first byte of the firmware volume.\r | |
765 | @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r | |
766 | firmware volumes, this is typically the size of\r | |
767 | the firmware volume.\r | |
768 | @param ParentFvName If the new firmware volume originated from a file\r | |
769 | in a different firmware volume, then this parameter\r | |
770 | specifies the GUID name of the originating firmware\r | |
771 | volume. Otherwise, this parameter must be NULL.\r | |
772 | @param ParentFileName If the new firmware volume originated from a file\r | |
773 | in a different firmware volume, then this parameter\r | |
774 | specifies the GUID file name of the originating\r | |
775 | firmware file. Otherwise, this parameter must be NULL.\r | |
776 | @param AuthenticationStatus Authentication Status\r | |
777 | **/\r | |
778 | VOID\r | |
779 | EFIAPI\r | |
780 | PeiServicesInstallFvInfo2Ppi (\r | |
781 | IN CONST EFI_GUID *FvFormat, OPTIONAL\r | |
782 | IN CONST VOID *FvInfo,\r | |
783 | IN UINT32 FvInfoSize,\r | |
784 | IN CONST EFI_GUID *ParentFvName, OPTIONAL\r | |
785 | IN CONST EFI_GUID *ParentFileName, OPTIONAL\r | |
786 | IN UINT32 AuthenticationStatus\r | |
787 | )\r | |
788 | {\r | |
789 | InternalPeiServicesInstallFvInfoPpi (FALSE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, AuthenticationStatus);\r | |
790 | }\r | |
791 | \r |