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