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