]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/PeiServicesLib.h
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Include / Library / PeiServicesLib.h
1 /** @file
2 Provides library functions for all PEI Services.
3
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef __PEI_SERVICES_LIB_H__
10 #define __PEI_SERVICES_LIB_H__
11
12 /**
13 This service enables a given PEIM to register an interface into the PEI Foundation.
14
15 @param PpiList A pointer to the list of interfaces that the caller shall install.
16
17 @retval EFI_SUCCESS The interface was successfully installed.
18 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
19 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
20 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
21 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
22
23 **/
24 EFI_STATUS
25 EFIAPI
26 PeiServicesInstallPpi (
27 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
28 );
29
30 /**
31 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
32
33 @param OldPpi Pointer to the old PEI PPI Descriptors.
34 @param NewPpi Pointer to the new PEI PPI Descriptors.
35
36 @retval EFI_SUCCESS The interface was successfully installed.
37 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
38 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
39 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
40 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
41 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
42 installed.
43
44 **/
45 EFI_STATUS
46 EFIAPI
47 PeiServicesReInstallPpi (
48 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
49 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
50 );
51
52 /**
53 This service enables PEIMs to discover a given instance of an interface.
54
55 @param Guid A pointer to the GUID whose corresponding interface needs to be
56 found.
57 @param Instance The N-th instance of the interface that is required.
58 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
59 @param Ppi A pointer to the instance of the interface.
60
61 @retval EFI_SUCCESS The interface was successfully returned.
62 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
63
64 **/
65 EFI_STATUS
66 EFIAPI
67 PeiServicesLocatePpi (
68 IN CONST EFI_GUID *Guid,
69 IN UINTN Instance,
70 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor OPTIONAL,
71 IN OUT VOID **Ppi
72 );
73
74 /**
75 This service enables PEIMs to register a given service to be invoked when another service is
76 installed or reinstalled.
77
78 @param NotifyList A pointer to the list of notification interfaces that the caller
79 shall install.
80
81 @retval EFI_SUCCESS The interface was successfully installed.
82 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
83 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the
84 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.
85 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
86
87 **/
88 EFI_STATUS
89 EFIAPI
90 PeiServicesNotifyPpi (
91 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
92 );
93
94 /**
95 This service enables PEIMs to ascertain the present value of the boot mode.
96
97 @param BootMode A pointer to contain the value of the boot mode.
98
99 @retval EFI_SUCCESS The boot mode was returned successfully.
100 @retval EFI_INVALID_PARAMETER BootMode is NULL.
101
102 **/
103 EFI_STATUS
104 EFIAPI
105 PeiServicesGetBootMode (
106 OUT EFI_BOOT_MODE *BootMode
107 );
108
109 /**
110 This service enables PEIMs to update the boot mode variable.
111
112 @param BootMode The value of the boot mode to set.
113
114 @retval EFI_SUCCESS The value was successfully updated
115
116 **/
117 EFI_STATUS
118 EFIAPI
119 PeiServicesSetBootMode (
120 IN EFI_BOOT_MODE BootMode
121 );
122
123 /**
124 This service enables a PEIM to ascertain the address of the list of HOBs in memory.
125
126 @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.
127
128 @retval EFI_SUCCESS The list was successfully returned.
129 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
130
131 **/
132 EFI_STATUS
133 EFIAPI
134 PeiServicesGetHobList (
135 OUT VOID **HobList
136 );
137
138 /**
139 This service enables PEIMs to create various types of HOBs.
140
141 @param Type The type of HOB to be installed.
142 @param Length The length of the HOB to be added.
143 @param Hob The address of a pointer that will contain the HOB header.
144
145 @retval EFI_SUCCESS The HOB was successfully created.
146 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
147
148 **/
149 EFI_STATUS
150 EFIAPI
151 PeiServicesCreateHob (
152 IN UINT16 Type,
153 IN UINT16 Length,
154 OUT VOID **Hob
155 );
156
157 /**
158 This service enables PEIMs to discover additional firmware volumes.
159
160 @param Instance This instance of the firmware volume to find. The value 0 is the
161 Boot Firmware Volume (BFV).
162 @param VolumeHandle Handle of the firmware volume header of the volume to return.
163
164 @retval EFI_SUCCESS The volume was found.
165 @retval EFI_NOT_FOUND The volume was not found.
166 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
167
168 **/
169 EFI_STATUS
170 EFIAPI
171 PeiServicesFfsFindNextVolume (
172 IN UINTN Instance,
173 IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
174 );
175
176 /**
177 This service enables PEIMs to discover additional firmware files.
178
179 @param SearchType A filter to find files only of this type.
180 @param VolumeHandle Pointer to the firmware volume header of the volume to search.
181 This parameter must point to a valid FFS volume.
182 @param FileHandle Handle of the current file from which to begin searching.
183
184 @retval EFI_SUCCESS The file was found.
185 @retval EFI_NOT_FOUND The file was not found.
186 @retval EFI_NOT_FOUND The header checksum was not zero.
187
188 **/
189 EFI_STATUS
190 EFIAPI
191 PeiServicesFfsFindNextFile (
192 IN EFI_FV_FILETYPE SearchType,
193 IN EFI_PEI_FV_HANDLE VolumeHandle,
194 IN OUT EFI_PEI_FILE_HANDLE *FileHandle
195 );
196
197 /**
198 This service enables PEIMs to discover sections of a given type within a valid FFS file.
199
200 @param SectionType The value of the section type to find.
201 @param FileHandle A pointer to the file header that contains the set of sections to
202 be searched.
203 @param SectionData A pointer to the discovered section, if successful.
204
205 @retval EFI_SUCCESS The section was found.
206 @retval EFI_NOT_FOUND The section was not found.
207
208 **/
209 EFI_STATUS
210 EFIAPI
211 PeiServicesFfsFindSectionData (
212 IN EFI_SECTION_TYPE SectionType,
213 IN EFI_PEI_FILE_HANDLE FileHandle,
214 OUT VOID **SectionData
215 );
216
217 /**
218 This service enables PEIMs to discover sections of a given instance and type within a valid FFS file.
219
220 @param SectionType The value of the section type to find.
221 @param SectionInstance Section instance to find.
222 @param FileHandle A pointer to the file header that contains the set
223 of sections to be searched.
224 @param SectionData A pointer to the discovered section, if successful.
225 @param AuthenticationStatus A pointer to the authentication status for this section.
226
227 @retval EFI_SUCCESS The section was found.
228 @retval EFI_NOT_FOUND The section was not found.
229
230 **/
231 EFI_STATUS
232 EFIAPI
233 PeiServicesFfsFindSectionData3 (
234 IN EFI_SECTION_TYPE SectionType,
235 IN UINTN SectionInstance,
236 IN EFI_PEI_FILE_HANDLE FileHandle,
237 OUT VOID **SectionData,
238 OUT UINT32 *AuthenticationStatus
239 );
240
241 /**
242 This service enables PEIMs to register the permanent memory configuration
243 that has been initialized with the PEI Foundation.
244
245 @param MemoryBegin The value of a region of installed memory.
246 @param MemoryLength The corresponding length of a region of installed memory.
247
248 @retval EFI_SUCCESS The region was successfully installed in a HOB.
249 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
250 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
251
252 **/
253 EFI_STATUS
254 EFIAPI
255 PeiServicesInstallPeiMemory (
256 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
257 IN UINT64 MemoryLength
258 );
259
260 /**
261 This service enables PEIMs to allocate memory.
262
263 @param MemoryType Type of memory to allocate.
264 @param Pages The number of pages to allocate.
265 @param Memory Pointer of memory allocated.
266
267 @retval EFI_SUCCESS The memory range was successfully allocated.
268 @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,
269 EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,
270 EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.
271 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
272
273 **/
274 EFI_STATUS
275 EFIAPI
276 PeiServicesAllocatePages (
277 IN EFI_MEMORY_TYPE MemoryType,
278 IN UINTN Pages,
279 OUT EFI_PHYSICAL_ADDRESS *Memory
280 );
281
282 /**
283 This service enables PEIMs to free memory.
284
285 @param Memory Memory to be freed.
286 @param Pages The number of pages to free.
287
288 @retval EFI_SUCCESS The requested pages were freed.
289 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.
290 @retval EFI_NOT_FOUND The requested memory pages were not allocated with
291 AllocatePages().
292
293 **/
294 EFI_STATUS
295 EFIAPI
296 PeiServicesFreePages (
297 IN EFI_PHYSICAL_ADDRESS Memory,
298 IN UINTN Pages
299 );
300
301 /**
302 This service allocates memory from the Hand-Off Block (HOB) heap.
303
304 @param Size The number of bytes to allocate from the pool.
305 @param Buffer If the call succeeds, a pointer to a pointer to the allocate
306 buffer; undefined otherwise.
307
308 @retval EFI_SUCCESS The allocation was successful
309 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
310
311 **/
312 EFI_STATUS
313 EFIAPI
314 PeiServicesAllocatePool (
315 IN UINTN Size,
316 OUT VOID **Buffer
317 );
318
319 /**
320 Resets the entire platform.
321
322 @retval EFI_SUCCESS The function completed successfully.
323 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
324
325 **/
326 EFI_STATUS
327 EFIAPI
328 PeiServicesResetSystem (
329 VOID
330 );
331
332 /**
333 This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
334 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
335 Specification for details.
336
337 @param FileName A pointer to the name of the file to
338 find within the firmware volume.
339
340 @param VolumeHandle The firmware volume to search FileHandle
341 Upon exit, points to the found file's
342 handle or NULL if it could not be found.
343 @param FileHandle Pointer to found file handle
344
345 @retval EFI_SUCCESS File was found.
346
347 @retval EFI_NOT_FOUND File was not found.
348
349 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
350 FileName was NULL.
351
352 **/
353 EFI_STATUS
354 EFIAPI
355 PeiServicesFfsFindFileByName (
356 IN CONST EFI_GUID *FileName,
357 IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
358 OUT EFI_PEI_FILE_HANDLE *FileHandle
359 );
360
361 /**
362 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services
363 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
364 Specification for details.
365
366 @param FileHandle Handle of the file.
367
368 @param FileInfo Upon exit, points to the file's
369 information.
370
371 @retval EFI_SUCCESS File information returned.
372
373 @retval EFI_INVALID_PARAMETER If FileHandle does not
374 represent a valid file.
375
376 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
377
378 **/
379 EFI_STATUS
380 EFIAPI
381 PeiServicesFfsGetFileInfo (
382 IN CONST EFI_PEI_FILE_HANDLE FileHandle,
383 OUT EFI_FV_FILE_INFO *FileInfo
384 );
385
386 /**
387 This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services
388 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
389 Specification for details.
390
391 @param FileHandle Handle of the file.
392
393 @param FileInfo Upon exit, points to the file's
394 information.
395
396 @retval EFI_SUCCESS File information returned.
397
398 @retval EFI_INVALID_PARAMETER If FileHandle does not
399 represent a valid file.
400
401 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
402
403 **/
404 EFI_STATUS
405 EFIAPI
406 PeiServicesFfsGetFileInfo2 (
407 IN CONST EFI_PEI_FILE_HANDLE FileHandle,
408 OUT EFI_FV_FILE_INFO2 *FileInfo
409 );
410
411 /**
412 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
413 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
414 Specification for details.
415
416 @param VolumeHandle Handle of the volume.
417
418 @param VolumeInfo Upon exit, points to the volume's
419 information.
420
421 @retval EFI_SUCCESS File information returned.
422
423 @retval EFI_INVALID_PARAMETER If FileHandle does not
424 represent a valid file.
425
426 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
427
428 **/
429 EFI_STATUS
430 EFIAPI
431 PeiServicesFfsGetVolumeInfo (
432 IN EFI_PEI_FV_HANDLE VolumeHandle,
433 OUT EFI_FV_INFO *VolumeInfo
434 );
435
436 /**
437 This service is a wrapper for the PEI Service RegisterForShadow(), except the pointer to the PEI Services
438 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
439 Specification for details.
440
441 @param FileHandle PEIM's file handle. Must be the currently
442 executing PEIM.
443
444 @retval EFI_SUCCESS The PEIM was successfully registered for
445 shadowing.
446
447 @retval EFI_ALREADY_STARTED The PEIM was previously
448 registered for shadowing.
449
450 @retval EFI_NOT_FOUND The FileHandle does not refer to a
451 valid file handle.
452 **/
453 EFI_STATUS
454 EFIAPI
455 PeiServicesRegisterForShadow (
456 IN EFI_PEI_FILE_HANDLE FileHandle
457 );
458
459 /**
460 Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
461
462 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
463 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
464 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
465 If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
466
467
468 @param FvFormat Unique identifier of the format of the memory-mapped firmware volume.
469 This parameter is optional and may be NULL.
470 If NULL is specified, the EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
471 @param FvInfo Points to a buffer which allows the EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
472 The format of this buffer is specific to the FvFormat. For memory-mapped firmware volumes,
473 this typically points to the first byte of the firmware volume.
474 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped firmware volumes,
475 this is typically the size of the firmware volume.
476 @param ParentFvName If the new firmware volume originated from a file in a different firmware volume,
477 then this parameter specifies the GUID name of the originating firmware volume.
478 Otherwise, this parameter must be NULL.
479 @param ParentFileName If the new firmware volume originated from a file in a different firmware volume,
480 then this parameter specifies the GUID file name of the originating firmware file.
481 Otherwise, this parameter must be NULL.
482 **/
483 VOID
484 EFIAPI
485 PeiServicesInstallFvInfoPpi (
486 IN CONST EFI_GUID *FvFormat OPTIONAL,
487 IN CONST VOID *FvInfo,
488 IN UINT32 FvInfoSize,
489 IN CONST EFI_GUID *ParentFvName OPTIONAL,
490 IN CONST EFI_GUID *ParentFileName OPTIONAL
491 );
492
493 /**
494 Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.
495
496 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using
497 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.
498 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().
499 If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().
500
501 @param FvFormat Unique identifier of the format of the memory-mapped
502 firmware volume. This parameter is optional and
503 may be NULL. If NULL is specified, the
504 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
505 @param FvInfo Points to a buffer which allows the
506 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
507 The format of this buffer is specific to the FvFormat.
508 For memory-mapped firmware volumes, this typically
509 points to the first byte of the firmware volume.
510 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
511 firmware volumes, this is typically the size of
512 the firmware volume.
513 @param ParentFvName If the new firmware volume originated from a file
514 in a different firmware volume, then this parameter
515 specifies the GUID name of the originating firmware
516 volume. Otherwise, this parameter must be NULL.
517 @param ParentFileName If the new firmware volume originated from a file
518 in a different firmware volume, then this parameter
519 specifies the GUID file name of the originating
520 firmware file. Otherwise, this parameter must be NULL.
521 @param AuthenticationStatus Authentication Status
522 **/
523 VOID
524 EFIAPI
525 PeiServicesInstallFvInfo2Ppi (
526 IN CONST EFI_GUID *FvFormat OPTIONAL,
527 IN CONST VOID *FvInfo,
528 IN UINT32 FvInfoSize,
529 IN CONST EFI_GUID *ParentFvName OPTIONAL,
530 IN CONST EFI_GUID *ParentFileName OPTIONAL,
531 IN UINT32 AuthenticationStatus
532 );
533
534 /**
535 Resets the entire platform.
536
537 @param[in] ResetType The type of reset to perform.
538 @param[in] ResetStatus The status code for the reset.
539 @param[in] DataSize The size, in bytes, of ResetData.
540 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
541 the data buffer starts with a Null-terminated string, optionally
542 followed by additional binary data. The string is a description
543 that the caller may use to further indicate the reason for the
544 system reset.
545
546 **/
547 VOID
548 EFIAPI
549 PeiServicesResetSystem2 (
550 IN EFI_RESET_TYPE ResetType,
551 IN EFI_STATUS ResetStatus,
552 IN UINTN DataSize,
553 IN VOID *ResetData OPTIONAL
554 );
555
556 #endif