]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/PeiServicesLib.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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 /**
334 This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
335 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
336 Specification for details.
337
338 @param FileName A pointer to the name of the file to
339 find within the firmware volume.
340
341 @param VolumeHandle The firmware volume to search FileHandle
342 Upon exit, points to the found file's
343 handle or NULL if it could not be found.
344 @param FileHandle Pointer to found file handle
345
346 @retval EFI_SUCCESS File was found.
347
348 @retval EFI_NOT_FOUND File was not found.
349
350 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
351 FileName was NULL.
352
353 **/
354 EFI_STATUS
355 EFIAPI
356 PeiServicesFfsFindFileByName (
357 IN CONST EFI_GUID *FileName,
358 IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
359 OUT EFI_PEI_FILE_HANDLE *FileHandle
360 );
361
362
363 /**
364 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services
365 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
366 Specification for details.
367
368 @param FileHandle Handle of the file.
369
370 @param FileInfo Upon exit, points to the file's
371 information.
372
373 @retval EFI_SUCCESS File information returned.
374
375 @retval EFI_INVALID_PARAMETER If FileHandle does not
376 represent a valid file.
377
378 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
379
380 **/
381 EFI_STATUS
382 EFIAPI
383 PeiServicesFfsGetFileInfo (
384 IN CONST EFI_PEI_FILE_HANDLE FileHandle,
385 OUT EFI_FV_FILE_INFO *FileInfo
386 );
387
388 /**
389 This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services
390 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
391 Specification for details.
392
393 @param FileHandle Handle of the file.
394
395 @param FileInfo Upon exit, points to the file's
396 information.
397
398 @retval EFI_SUCCESS File information returned.
399
400 @retval EFI_INVALID_PARAMETER If FileHandle does not
401 represent a valid file.
402
403 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
404
405 **/
406 EFI_STATUS
407 EFIAPI
408 PeiServicesFfsGetFileInfo2 (
409 IN CONST EFI_PEI_FILE_HANDLE FileHandle,
410 OUT EFI_FV_FILE_INFO2 *FileInfo
411 );
412
413 /**
414 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
415 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
416 Specification for details.
417
418 @param VolumeHandle Handle of the volume.
419
420 @param VolumeInfo Upon exit, points to the volume's
421 information.
422
423 @retval EFI_SUCCESS File information returned.
424
425 @retval EFI_INVALID_PARAMETER If FileHandle does not
426 represent a valid file.
427
428 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
429
430 **/
431 EFI_STATUS
432 EFIAPI
433 PeiServicesFfsGetVolumeInfo (
434 IN EFI_PEI_FV_HANDLE VolumeHandle,
435 OUT EFI_FV_INFO *VolumeInfo
436 );
437
438
439 /**
440 This service is a wrapper for the PEI Service RegisterForShadow(), except the pointer to the PEI Services
441 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
442 Specification for details.
443
444 @param FileHandle PEIM's file handle. Must be the currently
445 executing PEIM.
446
447 @retval EFI_SUCCESS The PEIM was successfully registered for
448 shadowing.
449
450 @retval EFI_ALREADY_STARTED The PEIM was previously
451 registered for shadowing.
452
453 @retval EFI_NOT_FOUND The FileHandle does not refer to a
454 valid file handle.
455 **/
456 EFI_STATUS
457 EFIAPI
458 PeiServicesRegisterForShadow (
459 IN EFI_PEI_FILE_HANDLE FileHandle
460 );
461
462 /**
463 Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
464
465 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
466 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
467 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
468 If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
469
470
471 @param FvFormat Unique identifier of the format of the memory-mapped firmware volume.
472 This parameter is optional and may be NULL.
473 If NULL is specified, the EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
474 @param FvInfo Points to a buffer which allows the EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
475 The format of this buffer is specific to the FvFormat. For memory-mapped firmware volumes,
476 this typically points to the first byte of the firmware volume.
477 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped firmware volumes,
478 this is typically the size of the firmware volume.
479 @param ParentFvName If the new firmware volume originated from a file in a different firmware volume,
480 then this parameter specifies the GUID name of the originating firmware volume.
481 Otherwise, this parameter must be NULL.
482 @param ParentFileName If the new firmware volume originated from a file in a different firmware volume,
483 then this parameter specifies the GUID file name of the originating firmware file.
484 Otherwise, this parameter must be NULL.
485 **/
486 VOID
487 EFIAPI
488 PeiServicesInstallFvInfoPpi (
489 IN CONST EFI_GUID *FvFormat, OPTIONAL
490 IN CONST VOID *FvInfo,
491 IN UINT32 FvInfoSize,
492 IN CONST EFI_GUID *ParentFvName, OPTIONAL
493 IN CONST EFI_GUID *ParentFileName OPTIONAL
494 );
495
496 /**
497 Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.
498
499 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using
500 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.
501 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().
502 If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().
503
504 @param FvFormat Unique identifier of the format of the memory-mapped
505 firmware volume. This parameter is optional and
506 may be NULL. If NULL is specified, the
507 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
508 @param FvInfo Points to a buffer which allows the
509 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
510 The format of this buffer is specific to the FvFormat.
511 For memory-mapped firmware volumes, this typically
512 points to the first byte of the firmware volume.
513 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
514 firmware volumes, this is typically the size of
515 the firmware volume.
516 @param ParentFvName If the new firmware volume originated from a file
517 in a different firmware volume, then this parameter
518 specifies the GUID name of the originating firmware
519 volume. Otherwise, this parameter must be NULL.
520 @param ParentFileName If the new firmware volume originated from a file
521 in a different firmware volume, then this parameter
522 specifies the GUID file name of the originating
523 firmware file. Otherwise, this parameter must be NULL.
524 @param AuthenticationStatus Authentication Status
525 **/
526 VOID
527 EFIAPI
528 PeiServicesInstallFvInfo2Ppi (
529 IN CONST EFI_GUID *FvFormat, OPTIONAL
530 IN CONST VOID *FvInfo,
531 IN UINT32 FvInfoSize,
532 IN CONST EFI_GUID *ParentFvName, OPTIONAL
533 IN CONST EFI_GUID *ParentFileName, OPTIONAL
534 IN UINT32 AuthenticationStatus
535 );
536
537 /**
538 Resets the entire platform.
539
540 @param[in] ResetType The type of reset to perform.
541 @param[in] ResetStatus The status code for the reset.
542 @param[in] DataSize The size, in bytes, of ResetData.
543 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
544 the data buffer starts with a Null-terminated string, optionally
545 followed by additional binary data. The string is a description
546 that the caller may use to further indicate the reason for the
547 system reset.
548
549 **/
550 VOID
551 EFIAPI
552 PeiServicesResetSystem2 (
553 IN EFI_RESET_TYPE ResetType,
554 IN EFI_STATUS ResetStatus,
555 IN UINTN DataSize,
556 IN VOID *ResetData OPTIONAL
557 );
558
559 #endif