]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Pi/PiPeiCis.h
ebfe5981725d867e58f75b6a8a1b29eff8a854ab
[mirror_edk2.git] / MdePkg / Include / Pi / PiPeiCis.h
1 /** @file
2 PI PEI master include file. This file should match the PI spec.
3
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 @par Revision Reference:
8 PI Version 1.7.
9
10 **/
11
12 #ifndef __PI_PEICIS_H__
13 #define __PI_PEICIS_H__
14
15 #include <Uefi/UefiMultiPhase.h>
16 #include <Pi/PiMultiPhase.h>
17
18 ///
19 /// The handles of EFI FV.
20 ///
21 typedef VOID *EFI_PEI_FV_HANDLE;
22
23 ///
24 /// The handles of EFI FFS.
25 ///
26 typedef VOID *EFI_PEI_FILE_HANDLE;
27
28 ///
29 /// Declare the forward reference data structure for EFI_PEI_SERVICE.
30 ///
31 typedef struct _EFI_PEI_SERVICES EFI_PEI_SERVICES;
32
33 ///
34 /// Declare the forward reference data structure for EFI_PEI_NOTIFY_DESCRIPTOR.
35 ///
36 typedef struct _EFI_PEI_NOTIFY_DESCRIPTOR EFI_PEI_NOTIFY_DESCRIPTOR;
37
38
39 #include <Ppi/CpuIo.h>
40 #include <Ppi/PciCfg2.h>
41
42
43 /**
44 The PEI Dispatcher will invoke each PEIM one time. During this pass, the PEI
45 Dispatcher will pass control to the PEIM at the AddressOfEntryPoint in the PE Header.
46
47 @param FileHandle Pointer to the FFS file header.
48 @param PeiServices Describes the list of possible PEI Services.
49
50 @retval EFI_SUCCESS The PEI completed successfully.
51 @retval !EFI_SUCCESS There is error in PEIM.
52
53 **/
54 typedef
55 EFI_STATUS
56 (EFIAPI *EFI_PEIM_ENTRY_POINT2)(
57 IN EFI_PEI_FILE_HANDLE FileHandle,
58 IN CONST EFI_PEI_SERVICES **PeiServices
59 );
60
61 /**
62 Entry point of the notification callback function itself within the PEIM.
63
64 @param PeiServices Indirect reference to the PEI Services Table.
65 @param NotifyDescriptor Address of the notification descriptor data structure.
66 @param Ppi Address of the PPI that was installed.
67
68 @return Status of the notification.
69 The status code returned from this function is ignored.
70 **/
71 typedef
72 EFI_STATUS
73 (EFIAPI *EFI_PEIM_NOTIFY_ENTRY_POINT)(
74 IN EFI_PEI_SERVICES **PeiServices,
75 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
76 IN VOID *Ppi
77 );
78
79 //
80 // PEI Ppi Services List Descriptors
81 //
82 #define EFI_PEI_PPI_DESCRIPTOR_PIC 0x00000001
83 #define EFI_PEI_PPI_DESCRIPTOR_PPI 0x00000010
84 #define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK 0x00000020
85 #define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH 0x00000040
86 #define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES 0x00000060
87 #define EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST 0x80000000
88
89 ///
90 /// The data structure through which a PEIM describes available services to the PEI Foundation.
91 ///
92 typedef struct {
93 ///
94 /// This field is a set of flags describing the characteristics of this imported table entry.
95 /// All flags are defined as EFI_PEI_PPI_DESCRIPTOR_***, which can also be combined into one.
96 ///
97 UINTN Flags;
98 ///
99 /// The address of the EFI_GUID that names the interface.
100 ///
101 EFI_GUID *Guid;
102 ///
103 /// A pointer to the PPI. It contains the information necessary to install a service.
104 ///
105 VOID *Ppi;
106 } EFI_PEI_PPI_DESCRIPTOR;
107
108 ///
109 /// The data structure in a given PEIM that tells the PEI
110 /// Foundation where to invoke the notification service.
111 ///
112 struct _EFI_PEI_NOTIFY_DESCRIPTOR {
113 ///
114 /// Details if the type of notification are callback or dispatch.
115 ///
116 UINTN Flags;
117 ///
118 /// The address of the EFI_GUID that names the interface.
119 ///
120 EFI_GUID *Guid;
121 ///
122 /// Address of the notification callback function itself within the PEIM.
123 ///
124 EFI_PEIM_NOTIFY_ENTRY_POINT Notify;
125 };
126
127 ///
128 /// This data structure is the means by which callable services are installed and
129 /// notifications are registered in the PEI phase.
130 ///
131 typedef union {
132 ///
133 /// The typedef structure of the notification descriptor.
134 ///
135 EFI_PEI_NOTIFY_DESCRIPTOR Notify;
136 ///
137 /// The typedef structure of the PPI descriptor.
138 ///
139 EFI_PEI_PPI_DESCRIPTOR Ppi;
140 } EFI_PEI_DESCRIPTOR;
141
142 /**
143 This service is the first one provided by the PEI Foundation. This function
144 installs an interface in the PEI PPI database by GUID. The purpose of the
145 service is to publish an interface that other parties can use to call
146 additional PEIMs.
147
148 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table
149 published by the PEI Foundation.
150 @param PpiList A pointer to the list of interfaces that the caller shall install.
151
152 @retval EFI_SUCCESS The interface was successfully installed.
153 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL or Any of the PEI PPI
154 descriptors in the list do not have the
155 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
156 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
157
158 **/
159 typedef
160 EFI_STATUS
161 (EFIAPI *EFI_PEI_INSTALL_PPI)(
162 IN CONST EFI_PEI_SERVICES **PeiServices,
163 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
164 );
165
166 /**
167 This function reinstalls an interface in the PEI PPI database by GUID.
168 The purpose of the service is to publish an interface that other parties
169 can use to replace a same-named interface in the protocol database
170 with a different interface.
171
172 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table
173 published by the PEI Foundation.
174 @param OldPpi A pointer to the former PPI in the database.
175 @param NewPpi A pointer to the new interfaces that the caller shall install.
176
177 @retval EFI_SUCCESS The interface was successfully installed.
178 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL or Any of the PEI PPI descriptors in the
179 list do not have the EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
180 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
181 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been installed.
182
183 **/
184 typedef
185 EFI_STATUS
186 (EFIAPI *EFI_PEI_REINSTALL_PPI)(
187 IN CONST EFI_PEI_SERVICES **PeiServices,
188 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
189 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
190 );
191
192 /**
193 This function locates an interface in the PEI PPI database by GUID.
194
195 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation.
196 @param Guid A pointer to the GUID whose corresponding interface needs to be found.
197 @param Instance The N-th instance of the interface that is required.
198 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
199 @param Ppi A pointer to the instance of the interface.
200
201 @retval EFI_SUCCESS The interface was successfully returned.
202 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
203
204 **/
205 typedef
206 EFI_STATUS
207 (EFIAPI *EFI_PEI_LOCATE_PPI)(
208 IN CONST EFI_PEI_SERVICES **PeiServices,
209 IN CONST EFI_GUID *Guid,
210 IN UINTN Instance,
211 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor OPTIONAL,
212 IN OUT VOID **Ppi
213 );
214
215 /**
216 This function installs a notification service to be called back when a
217 given interface is installed or reinstalled. The purpose of the service
218 is to publish an interface that other parties can use to call additional PPIs
219 that may materialize later.
220
221 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
222 @param NotifyList A pointer to the list of notification interfaces that the caller shall install.
223
224 @retval EFI_SUCCESS The interface was successfully installed.
225 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL, or any of the PEI PPI descriptors in the
226 list do not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.
227 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
228
229 **/
230 typedef
231 EFI_STATUS
232 (EFIAPI *EFI_PEI_NOTIFY_PPI)(
233 IN CONST EFI_PEI_SERVICES **PeiServices,
234 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
235 );
236
237 /**
238 This function returns the present value of the boot mode.
239
240 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
241 @param BootMode A pointer to contain the value of the boot mode.
242
243 @retval EFI_SUCCESS The boot mode returned successfully.
244
245 **/
246 typedef
247 EFI_STATUS
248 (EFIAPI *EFI_PEI_GET_BOOT_MODE)(
249 IN CONST EFI_PEI_SERVICES **PeiServices,
250 OUT EFI_BOOT_MODE *BootMode
251 );
252
253 /**
254 This function sets the value of the boot mode.
255
256 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
257 @param BootMode The value of the boot mode to set.
258
259 @retval EFI_SUCCESS The boot mode returned successfully.
260
261 **/
262 typedef
263 EFI_STATUS
264 (EFIAPI *EFI_PEI_SET_BOOT_MODE)(
265 IN CONST EFI_PEI_SERVICES **PeiServices,
266 IN EFI_BOOT_MODE BootMode
267 );
268
269 /**
270 This function returns the pointer to the list of Hand-Off Blocks (HOBs) in memory.
271
272 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
273 @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize
274
275 @retval EFI_SUCCESS The list was successfully returned.
276 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
277
278 **/
279 typedef
280 EFI_STATUS
281 (EFIAPI *EFI_PEI_GET_HOB_LIST)(
282 IN CONST EFI_PEI_SERVICES **PeiServices,
283 OUT VOID **HobList
284 );
285
286 /**
287 This service, published by the PEI Foundation, abstracts the creation of a Hand-Off Block's (HOB's) headers.
288
289 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
290 @param Type The type of HOB to be installed.
291 @param Length The length of the HOB to be added.
292 @param Hob The address of a pointer that will contain the HOB header.
293
294 @retval EFI_SUCCESS The HOB was successfully created.
295 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
296
297 **/
298 typedef
299 EFI_STATUS
300 (EFIAPI *EFI_PEI_CREATE_HOB)(
301 IN CONST EFI_PEI_SERVICES **PeiServices,
302 IN UINT16 Type,
303 IN UINT16 Length,
304 IN OUT VOID **Hob
305 );
306
307 /**
308 The purpose of the service is to abstract the capability of the PEI
309 Foundation to discover instances of firmware volumes in the system.
310
311 This service enables PEIMs to discover additional firmware volumes. The PEI Foundation uses this
312 service to abstract the locations and formats of various firmware volumes. These volumes include
313 the Boot Firmware Volume and any other volumes exposed by EFI_PEI_FV_PPI. The service
314 returns a volume handle of type EFI_PEI_FV_HANDLE, which must be unique within the system.
315
316 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
317 @param Instance This instance of the firmware volume to find.
318 The value 0 is the Boot Firmware Volume (BFV).
319 @param VolumeHandle On exit, points to the next volumn handle or NULL if it does not exist.
320
321 @retval EFI_SUCCESS The volume was found.
322 @retval EFI_NOT_FOUND The volume was not found.
323 @retval EFI_INVALID_PARAMETER VolumeHandle is NULL.
324
325 **/
326 typedef
327 EFI_STATUS
328 (EFIAPI *EFI_PEI_FFS_FIND_NEXT_VOLUME2)(
329 IN CONST EFI_PEI_SERVICES **PeiServices,
330 IN UINTN Instance,
331 OUT EFI_PEI_FV_HANDLE *VolumeHandle
332 );
333
334 /**
335 Searches for the next matching file in the firmware volume.
336
337 This service enables PEIMs to discover firmware files within a specified volume.
338 To find the first instance of a firmware file, pass a FileHandle value of NULL into the service.
339 The service returns a file handle of type EFI_PEI_FILE_HANDLE, which must be unique within
340 the system.
341
342 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
343 @param SearchType A filter to find files only of this type.
344 @param FvHandle Handle of firmware volume in which to search.
345 @param FileHandle On entry, points to the current handle from which to begin searching
346 or NULL to start at the beginning of the firmware volume.
347 On exit, points the file handle of the next file in the volume or NULL
348 if there are no more files.
349
350 @retval EFI_SUCCESS The file was found.
351 @retval EFI_NOT_FOUND The file was not found.
352 @retval EFI_NOT_FOUND The header checksum was not zero.
353
354 **/
355 typedef
356 EFI_STATUS
357 (EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE2)(
358 IN CONST EFI_PEI_SERVICES **PeiServices,
359 IN EFI_FV_FILETYPE SearchType,
360 IN CONST EFI_PEI_FV_HANDLE FvHandle,
361 IN OUT EFI_PEI_FILE_HANDLE *FileHandle
362 );
363
364 /**
365 Searches for the next matching section within the specified file.
366
367 This service enables PEI modules to discover the first section of a given type within a valid file.
368 This service will search within encapsulation sections (compression and GUIDed) as well. It will
369 search inside of a GUIDed section or a compressed section, but may not, for example, search a
370 GUIDed section inside a GUIDes section.
371 This service will not search within compression sections or GUIDed sections that require
372 extraction if memory is not present.
373
374 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
375 @param SectionType The value of the section type to find.
376 @param FileHandle Handle of the firmware file to search.
377 @param SectionData A pointer to the discovered section, if successful.
378
379 @retval EFI_SUCCESS The section was found.
380 @retval EFI_NOT_FOUND The section was not found.
381
382 **/
383 typedef
384 EFI_STATUS
385 (EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA2)(
386 IN CONST EFI_PEI_SERVICES **PeiServices,
387 IN EFI_SECTION_TYPE SectionType,
388 IN EFI_PEI_FILE_HANDLE FileHandle,
389 OUT VOID **SectionData
390 );
391
392 /**
393 Searches for the next matching section within the specified file.
394
395 This service enables PEI modules to discover the section of a given type within a valid file.
396 This service will search within encapsulation sections (compression and GUIDed) as well. It will
397 search inside of a GUIDed section or a compressed section, but may not, for example, search a
398 GUIDed section inside a GUIDes section.
399 This service will not search within compression sections or GUIDed sections that require
400 extraction if memory is not present.
401
402 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
403 @param SectionType The value of the section type to find.
404 @param SectionInstance Section instance to find.
405 @param FileHandle Handle of the firmware file to search.
406 @param SectionData A pointer to the discovered section, if successful.
407 @param AuthenticationStatus A pointer to the authentication status for this section.
408
409 @retval EFI_SUCCESS The section was found.
410 @retval EFI_NOT_FOUND The section was not found.
411
412 **/
413 typedef
414 EFI_STATUS
415 (EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA3)(
416 IN CONST EFI_PEI_SERVICES **PeiServices,
417 IN EFI_SECTION_TYPE SectionType,
418 IN UINTN SectionInstance,
419 IN EFI_PEI_FILE_HANDLE FileHandle,
420 OUT VOID **SectionData,
421 OUT UINT32 *AuthenticationStatus
422 );
423
424 /**
425 This function registers the found memory configuration with the PEI Foundation.
426
427 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
428 @param MemoryBegin The value of a region of installed memory.
429 @param MemoryLength The corresponding length of a region of installed memory.
430
431 @retval EFI_SUCCESS The region was successfully installed in a HOB.
432 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
433 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
434
435 **/
436 typedef
437 EFI_STATUS
438 (EFIAPI *EFI_PEI_INSTALL_PEI_MEMORY)(
439 IN CONST EFI_PEI_SERVICES **PeiServices,
440 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
441 IN UINT64 MemoryLength
442 );
443
444 /**
445 The purpose of the service is to publish an interface that allows
446 PEIMs to allocate memory ranges that are managed by the PEI Foundation.
447
448 Prior to InstallPeiMemory() being called, PEI will allocate pages from the heap.
449 After InstallPeiMemory() is called, PEI will allocate pages within the region
450 of memory provided by InstallPeiMemory() service in a best-effort fashion.
451 Location-specific allocations are not managed by the PEI foundation code.
452
453 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
454 @param MemoryType The type of memory to allocate.
455 @param Pages The number of contiguous 4 KB pages to allocate.
456 @param Memory A pointer to a physical address. On output, the address is set to the base
457 of the page range that was allocated.
458
459 @retval EFI_SUCCESS The memory range was successfully allocated.
460 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
461 @retval EFI_INVALID_PARAMETER The type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,
462 EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,
463 EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.
464
465 **/
466 typedef
467 EFI_STATUS
468 (EFIAPI *EFI_PEI_ALLOCATE_PAGES)(
469 IN CONST EFI_PEI_SERVICES **PeiServices,
470 IN EFI_MEMORY_TYPE MemoryType,
471 IN UINTN Pages,
472 OUT EFI_PHYSICAL_ADDRESS *Memory
473 );
474
475 /**
476 Frees memory pages.
477
478 @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
479 @param[in] Memory The base physical address of the pages to be freed.
480 @param[in] Pages The number of contiguous 4 KB pages to free.
481
482 @retval EFI_SUCCESS The requested pages were freed.
483 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.
484 @retval EFI_NOT_FOUND The requested memory pages were not allocated with
485 AllocatePages().
486
487 **/
488 typedef
489 EFI_STATUS
490 (EFIAPI *EFI_PEI_FREE_PAGES) (
491 IN CONST EFI_PEI_SERVICES **PeiServices,
492 IN EFI_PHYSICAL_ADDRESS Memory,
493 IN UINTN Pages
494 );
495
496 /**
497 The purpose of this service is to publish an interface that
498 allows PEIMs to allocate memory ranges that are managed by the PEI Foundation.
499
500 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
501 @param Size The number of bytes to allocate from the pool.
502 @param Buffer If the call succeeds, a pointer to a pointer to the allocated buffer; undefined otherwise.
503
504 @retval EFI_SUCCESS The allocation was successful.
505 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
506
507 **/
508 typedef
509 EFI_STATUS
510 (EFIAPI *EFI_PEI_ALLOCATE_POOL)(
511 IN CONST EFI_PEI_SERVICES **PeiServices,
512 IN UINTN Size,
513 OUT VOID **Buffer
514 );
515
516 /**
517 This service copies the contents of one buffer to another buffer.
518
519 @param Destination The pointer to the destination buffer of the memory copy.
520 @param Source The pointer to the source buffer of the memory copy.
521 @param Length The number of bytes to copy from Source to Destination.
522
523 **/
524 typedef
525 VOID
526 (EFIAPI *EFI_PEI_COPY_MEM)(
527 IN VOID *Destination,
528 IN VOID *Source,
529 IN UINTN Length
530 );
531
532 /**
533 The service fills a buffer with a specified value.
534
535 @param Buffer The pointer to the buffer to fill.
536 @param Size The number of bytes in Buffer to fill.
537 @param Value The value to fill Buffer with.
538
539 **/
540 typedef
541 VOID
542 (EFIAPI *EFI_PEI_SET_MEM)(
543 IN VOID *Buffer,
544 IN UINTN Size,
545 IN UINT8 Value
546 );
547
548 /**
549 This service publishes an interface that allows PEIMs to report status codes.
550
551 ReportStatusCode() is called by PEIMs that wish to report status information on their
552 progress. The principal use model is for a PEIM to emit one of the standard 32-bit error codes. This
553 will allow a platform owner to ascertain the state of the system, especially under conditions where
554 the full consoles might not have been installed.
555
556 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
557 @param Type Indicates the type of status code being reported.
558 @param Value Describes the current status of a hardware or
559 software entity. This includes information about the class and
560 subclass that is used to classify the entity as well as an operation.
561 For progress codes, the operation is the current activity.
562 For error codes, it is the exception.For debug codes,it is not defined at this time.
563 @param Instance The enumeration of a hardware or software entity within
564 the system. A system may contain multiple entities that match a class/subclass
565 pairing. The instance differentiates between them. An instance of 0 indicates
566 that instance information is unavailable, not meaningful, or not relevant.
567 Valid instance numbers start with 1.
568 @param CallerId This optional parameter may be used to identify the caller.
569 This parameter allows the status code driver to apply different rules to
570 different callers.
571 @param Data This optional parameter may be used to pass additional data.
572
573 @retval EFI_SUCCESS The function completed successfully.
574 @retval EFI_NOT_AVAILABLE_YET No progress code provider has installed an interface in the system.
575
576 **/
577 typedef
578 EFI_STATUS
579 (EFIAPI *EFI_PEI_REPORT_STATUS_CODE)(
580 IN CONST EFI_PEI_SERVICES **PeiServices,
581 IN EFI_STATUS_CODE_TYPE Type,
582 IN EFI_STATUS_CODE_VALUE Value,
583 IN UINT32 Instance,
584 IN CONST EFI_GUID *CallerId OPTIONAL,
585 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
586 );
587
588 /**
589 Resets the entire platform.
590
591 This service resets the entire platform, including all processors
592 and devices, and reboots the system.
593 This service will never return EFI_SUCCESS.
594
595 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES
596 table published by the PEI Foundation.
597
598 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
599
600 **/
601 typedef
602 EFI_STATUS
603 (EFIAPI *EFI_PEI_RESET_SYSTEM)(
604 IN CONST EFI_PEI_SERVICES **PeiServices
605 );
606
607 /**
608 Resets the entire platform.
609
610 @param[in] ResetType The type of reset to perform.
611 @param[in] ResetStatus The status code for the reset.
612 @param[in] DataSize The size, in bytes, of ResetData.
613 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
614 the data buffer starts with a Null-terminated string, optionally
615 followed by additional binary data. The string is a description
616 that the caller may use to further indicate the reason for the
617 system reset.
618
619 **/
620 typedef
621 VOID
622 (EFIAPI *EFI_PEI_RESET2_SYSTEM) (
623 IN EFI_RESET_TYPE ResetType,
624 IN EFI_STATUS ResetStatus,
625 IN UINTN DataSize,
626 IN VOID *ResetData OPTIONAL
627 );
628
629 /**
630 Find a file within a volume by its name.
631
632 This service searches for files with a specific name, within
633 either the specified firmware volume or all firmware volumes.
634 The service returns a file handle of type EFI_PEI_FILE_HANDLE,
635 which must be unique within the system.
636
637 @param FileName A pointer to the name of the file to
638 find within the firmware volume.
639 @param VolumeHandle The firmware volume to search.
640 @param FileHandle Upon exit, points to the found file's
641 handle or NULL if it could not be found.
642
643 @retval EFI_SUCCESS The file was found.
644 @retval EFI_NOT_FOUND The file was not found.
645 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
646 FileName was NULL.
647
648 **/
649 typedef
650 EFI_STATUS
651 (EFIAPI *EFI_PEI_FFS_FIND_BY_NAME)(
652 IN CONST EFI_GUID *FileName,
653 IN EFI_PEI_FV_HANDLE VolumeHandle,
654 OUT EFI_PEI_FILE_HANDLE *FileHandle
655 );
656
657 ///
658 /// The information of the FV file.
659 ///
660 typedef struct {
661 ///
662 /// Name of the file.
663 ///
664 EFI_GUID FileName;
665 ///
666 /// File type.
667 ///
668 EFI_FV_FILETYPE FileType;
669 ///
670 /// Attributes of the file.
671 ///
672 EFI_FV_FILE_ATTRIBUTES FileAttributes;
673 ///
674 /// Points to the file's data (not the header).
675 /// Not valid if EFI_FV_FILE_ATTRIB_MEMORY_MAPPED
676 /// is zero.
677 ///
678 VOID *Buffer;
679 ///
680 /// Size of the file's data.
681 ///
682 UINT32 BufferSize;
683 } EFI_FV_FILE_INFO;
684
685 ///
686 /// The information with authentication status of the FV file.
687 ///
688 typedef struct {
689 ///
690 /// Name of the file.
691 ///
692 EFI_GUID FileName;
693 ///
694 /// File type.
695 ///
696 EFI_FV_FILETYPE FileType;
697 ///
698 /// Attributes of the file.
699 ///
700 EFI_FV_FILE_ATTRIBUTES FileAttributes;
701 ///
702 /// Points to the file's data (not the header).
703 /// Not valid if EFI_FV_FILE_ATTRIB_MEMORY_MAPPED
704 /// is zero.
705 ///
706 VOID *Buffer;
707 ///
708 /// Size of the file's data.
709 ///
710 UINT32 BufferSize;
711 ///
712 /// Authentication status for this file.
713 ///
714 UINT32 AuthenticationStatus;
715 } EFI_FV_FILE_INFO2;
716
717 /**
718 Returns information about a specific file.
719
720 This function returns information about a specific file,
721 including its file name, type, attributes, starting address and
722 size. If the firmware volume is not memory mapped, then the
723 Buffer member will be NULL.
724
725 @param FileHandle The handle of the file.
726 @param FileInfo Upon exit, points to the file's
727 information.
728
729 @retval EFI_SUCCESS File information was returned.
730 @retval EFI_INVALID_PARAMETER FileHandle does not
731 represent a valid file.
732 @retval EFI_INVALID_PARAMETER FileInfo is NULL.
733
734 **/
735 typedef
736 EFI_STATUS
737 (EFIAPI *EFI_PEI_FFS_GET_FILE_INFO)(
738 IN EFI_PEI_FILE_HANDLE FileHandle,
739 OUT EFI_FV_FILE_INFO *FileInfo
740 );
741
742 /**
743 Returns information about a specific file.
744
745 This function returns information about a specific file,
746 including its file name, type, attributes, starting address, size and authentication status.
747 If the firmware volume is not memory mapped, then the Buffer member will be NULL.
748
749 @param FileHandle The handle of the file.
750 @param FileInfo Upon exit, points to the file's
751 information.
752
753 @retval EFI_SUCCESS File information was returned.
754 @retval EFI_INVALID_PARAMETER FileHandle does not
755 represent a valid file.
756 @retval EFI_INVALID_PARAMETER FileInfo is NULL.
757
758 **/
759 typedef
760 EFI_STATUS
761 (EFIAPI *EFI_PEI_FFS_GET_FILE_INFO2)(
762 IN EFI_PEI_FILE_HANDLE FileHandle,
763 OUT EFI_FV_FILE_INFO2 *FileInfo
764 );
765
766 ///
767 /// The information of the FV volume.
768 ///
769 typedef struct {
770 ///
771 /// Attributes of the firmware volume.
772 ///
773 EFI_FVB_ATTRIBUTES_2 FvAttributes;
774 ///
775 /// Format of the firmware volume.
776 ///
777 EFI_GUID FvFormat;
778 ///
779 /// Name of the firmware volume.
780 ///
781 EFI_GUID FvName;
782 ///
783 /// Points to the first byte of the firmware
784 /// volume, if bit EFI_FVB_MEMORY_MAPPED is
785 /// set in FvAttributes.
786 ///
787 VOID *FvStart;
788 ///
789 /// Size of the firmware volume.
790 ///
791 UINT64 FvSize;
792 } EFI_FV_INFO;
793
794 /**
795 Returns information about the specified volume.
796
797 This function returns information about a specific firmware
798 volume, including its name, type, attributes, starting address
799 and size.
800
801 @param VolumeHandle Handle of the volume.
802 @param VolumeInfo Upon exit, points to the volume's information.
803
804 @retval EFI_SUCCESS The volume information returned.
805 @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.
806 @retval EFI_INVALID_PARAMETER If VolumeHandle is NULL.
807 @retval EFI_SUCCESS Information was successfully returned.
808 @retval EFI_INVALID_PARAMETER The volume designated by the VolumeHandle is not available.
809
810 **/
811 typedef
812 EFI_STATUS
813 (EFIAPI *EFI_PEI_FFS_GET_VOLUME_INFO)(
814 IN EFI_PEI_FV_HANDLE VolumeHandle,
815 OUT EFI_FV_INFO *VolumeInfo
816 );
817
818 /**
819 Register a PEIM so that it will be shadowed and called again.
820
821 This service registers a file handle so that after memory is
822 available, the PEIM will be re-loaded into permanent memory and
823 re-initialized. The PEIM registered this way will always be
824 initialized twice. The first time, this function call will
825 return EFI_SUCCESS. The second time, this function call will
826 return EFI_ALREADY_STARTED. Depending on the order in which
827 PEIMs are dispatched, the PEIM making this call may be
828 initialized after permanent memory is installed, even the first
829 time.
830
831 @param FileHandle PEIM's file handle. Must be the currently
832 executing PEIM.
833
834 @retval EFI_SUCCESS The PEIM was successfully registered for
835 shadowing.
836 @retval EFI_ALREADY_STARTED The PEIM was previously
837 registered for shadowing.
838 @retval EFI_NOT_FOUND The FileHandle does not refer to a
839 valid file handle.
840
841 **/
842 typedef
843 EFI_STATUS
844 (EFIAPI *EFI_PEI_REGISTER_FOR_SHADOW)(
845 IN EFI_PEI_FILE_HANDLE FileHandle
846 );
847
848
849 //
850 // PEI Specification Revision information
851 //
852 #define PEI_SPECIFICATION_MAJOR_REVISION 1
853 #define PEI_SPECIFICATION_MINOR_REVISION 70
854 ///
855 /// Specification inconsistency here:
856 /// In the PI1.0 spec, PEI_SERVICES_SIGNATURE is defined as 0x5652455320494550. But
857 /// to pass a multiple tool chain, it appends an ULL.
858 ///
859 //
860 // PEI Services Table
861 //
862 #define PEI_SERVICES_SIGNATURE 0x5652455320494550ULL
863 ///
864 /// Specification inconsistency here:
865 /// In the PI1.0 specification, there is a typo error in PEI_SERVICES_REVISION. In the specification the defintion is
866 /// #define ((PEI_SPECIFICATION_MAJOR_REVISION<<16) |(PEI_SPECIFICATION_MINOR_REVISION))
867 /// and it should be as follows:
868 ///
869 #define PEI_SERVICES_REVISION ((PEI_SPECIFICATION_MAJOR_REVISION<<16) | (PEI_SPECIFICATION_MINOR_REVISION))
870
871 ///
872 /// EFI_PEI_SERVICES is a collection of functions whose implementation is provided by the PEI
873 /// Foundation. These services fall into various classes, including the following:
874 /// - Managing the boot mode
875 /// - Allocating both early and permanent memory
876 /// - Supporting the Firmware File System (FFS)
877 /// - Abstracting the PPI database abstraction
878 /// - Creating Hand-Off Blocks (HOBs).
879 ///
880 struct _EFI_PEI_SERVICES {
881 ///
882 /// The table header for the PEI Services Table.
883 ///
884 EFI_TABLE_HEADER Hdr;
885
886 //
887 // PPI Functions
888 //
889 EFI_PEI_INSTALL_PPI InstallPpi;
890 EFI_PEI_REINSTALL_PPI ReInstallPpi;
891 EFI_PEI_LOCATE_PPI LocatePpi;
892 EFI_PEI_NOTIFY_PPI NotifyPpi;
893
894 //
895 // Boot Mode Functions
896 //
897 EFI_PEI_GET_BOOT_MODE GetBootMode;
898 EFI_PEI_SET_BOOT_MODE SetBootMode;
899
900 //
901 // HOB Functions
902 //
903 EFI_PEI_GET_HOB_LIST GetHobList;
904 EFI_PEI_CREATE_HOB CreateHob;
905
906 //
907 // Firmware Volume Functions
908 //
909 EFI_PEI_FFS_FIND_NEXT_VOLUME2 FfsFindNextVolume;
910 EFI_PEI_FFS_FIND_NEXT_FILE2 FfsFindNextFile;
911 EFI_PEI_FFS_FIND_SECTION_DATA2 FfsFindSectionData;
912
913 //
914 // PEI Memory Functions
915 //
916 EFI_PEI_INSTALL_PEI_MEMORY InstallPeiMemory;
917 EFI_PEI_ALLOCATE_PAGES AllocatePages;
918 EFI_PEI_ALLOCATE_POOL AllocatePool;
919 EFI_PEI_COPY_MEM CopyMem;
920 EFI_PEI_SET_MEM SetMem;
921
922 //
923 // Status Code
924 //
925 EFI_PEI_REPORT_STATUS_CODE ReportStatusCode;
926
927 //
928 // Reset
929 //
930 EFI_PEI_RESET_SYSTEM ResetSystem;
931
932 //
933 // (the following interfaces are installed by publishing PEIM)
934 // I/O Abstractions
935 //
936 EFI_PEI_CPU_IO_PPI *CpuIo;
937 EFI_PEI_PCI_CFG2_PPI *PciCfg;
938
939 //
940 // Future Installed Services
941 //
942 EFI_PEI_FFS_FIND_BY_NAME FfsFindFileByName;
943 EFI_PEI_FFS_GET_FILE_INFO FfsGetFileInfo;
944 EFI_PEI_FFS_GET_VOLUME_INFO FfsGetVolumeInfo;
945 EFI_PEI_REGISTER_FOR_SHADOW RegisterForShadow;
946 EFI_PEI_FFS_FIND_SECTION_DATA3 FindSectionData3;
947 EFI_PEI_FFS_GET_FILE_INFO2 FfsGetFileInfo2;
948 EFI_PEI_RESET2_SYSTEM ResetSystem2;
949 EFI_PEI_FREE_PAGES FreePages;
950 };
951
952
953 ///
954 /// EFI_SEC_PEI_HAND_OFF structure holds information about
955 /// PEI core's operating environment, such as the size of location of
956 /// temporary RAM, the stack location and BFV location.
957 ///
958 typedef struct _EFI_SEC_PEI_HAND_OFF {
959 ///
960 /// Size of the data structure.
961 ///
962 UINT16 DataSize;
963
964 ///
965 /// Points to the first byte of the boot firmware volume,
966 /// which the PEI Dispatcher should search for
967 /// PEI modules.
968 ///
969 VOID *BootFirmwareVolumeBase;
970
971 ///
972 /// Size of the boot firmware volume, in bytes.
973 ///
974 UINTN BootFirmwareVolumeSize;
975
976 ///
977 /// Points to the first byte of the temporary RAM.
978 ///
979 VOID *TemporaryRamBase;
980
981 ///
982 /// Size of the temporary RAM, in bytes.
983 ///
984 UINTN TemporaryRamSize;
985
986 ///
987 /// Points to the first byte of the temporary RAM
988 /// available for use by the PEI Foundation. The area
989 /// described by PeiTemporaryRamBase and PeiTemporaryRamSize
990 /// must not extend outside beyond the area described by
991 /// TemporaryRamBase & TemporaryRamSize. This area should not
992 /// overlap with the area reported by StackBase and
993 /// StackSize.
994 ///
995 VOID *PeiTemporaryRamBase;
996
997 ///
998 /// The size of the available temporary RAM available for
999 /// use by the PEI Foundation, in bytes.
1000 ///
1001 UINTN PeiTemporaryRamSize;
1002
1003 ///
1004 /// Points to the first byte of the stack.
1005 /// This are may be part of the memory described by
1006 /// TemporaryRamBase and TemporaryRamSize
1007 /// or may be an entirely separate area.
1008 ///
1009 VOID *StackBase;
1010
1011 ///
1012 /// Size of the stack, in bytes.
1013 ///
1014 UINTN StackSize;
1015 } EFI_SEC_PEI_HAND_OFF;
1016
1017
1018 /**
1019 The entry point of PEI Foundation.
1020
1021 This function is the entry point for the PEI Foundation, which
1022 allows the SEC phase to pass information about the stack,
1023 temporary RAM and the Boot Firmware Volume. In addition, it also
1024 allows the SEC phase to pass services and data forward for use
1025 during the PEI phase in the form of one or more PPIs. These PPI's
1026 will be installed and/or immediately signaled if they are
1027 notification type. There is no limit to the number of additional
1028 PPIs that can be passed from SEC into the PEI Foundation. As part
1029 of its initialization phase, the PEI Foundation will add these
1030 SEC-hosted PPIs to its PPI database such that both the PEI
1031 Foundation and any modules can leverage the associated service
1032 calls and/or code in these early PPIs.
1033
1034 @param SecCoreData Points to a data structure containing
1035 information about the PEI core's
1036 operating environment, such as the size
1037 and location of temporary RAM, the stack
1038 location and the BFV location.
1039
1040 @param PpiList Points to a list of one or more PPI
1041 descriptors to be installed initially by
1042 the PEI core. An empty PPI list consists
1043 of a single descriptor with the end-tag
1044 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST.
1045 As part of its initialization phase, the
1046 PEI Foundation will add these SEC-hosted
1047 PPIs to its PPI database such that both
1048 the PEI Foundation and any modules can
1049 leverage the associated service calls
1050 and/or code in these early PPIs.
1051
1052
1053 **/
1054 typedef
1055 VOID
1056 (EFIAPI *EFI_PEI_CORE_ENTRY_POINT)(
1057 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
1058 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
1059 );
1060
1061 #endif