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