Home | History | Annotate | Download | only in Include
      1 /*++
      2 
      3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
      4 This program and the accompanying materials
      5 are licensed and made available under the terms and conditions of the BSD License
      6 which accompanies this distribution.  The full text of the license may be found at
      7 http://opensource.org/licenses/bsd-license.php
      8 
      9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     11 
     12 Module Name:
     13 
     14   PeiApi.h
     15 
     16 Abstract:
     17 
     18   Tiano PEI intrinsic definitions. This includes all Pei Services APIs.
     19 
     20   Peims are passed in a pointer to a pointer to the PEI Services table.
     21   The PEI Services table contains pointers to the PEI services exported
     22   by the PEI Core.
     23 
     24 --*/
     25 
     26 #ifndef _PEI_API_H_
     27 #define _PEI_API_H_
     28 
     29 #include "PeiHob.h"
     30 #include "EfiFirmwareFileSystem.h"
     31 #include "EfiFirmwareVolumeHeader.h"
     32 #include EFI_PPI_DEFINITION (FirmwareVolumeInfo)
     33 #include EFI_PPI_DEFINITION (FirmwareVolume)
     34 #include EFI_PPI_DEFINITION (Decompress)
     35 
     36 
     37 //
     38 // Declare forward referenced data structures
     39 //
     40 EFI_FORWARD_DECLARATION (EFI_PEI_NOTIFY_DESCRIPTOR);
     41 EFI_FORWARD_DECLARATION (EFI_PEI_SERVICES);
     42 
     43 #include EFI_PPI_DEFINITION (CpuIo)
     44 #include EFI_PPI_DEFINITION (PciCfg)
     45 #include EFI_PPI_DEFINITION (PciCfg2)
     46 #include EFI_PPI_DEFINITION (EcpPciCfg)
     47 
     48 //
     49 // PEI Specification Revision information
     50 //
     51 #if (PI_SPECIFICATION_VERSION < 0x00010000)
     52 #define PEI_SPECIFICATION_MAJOR_REVISION  0
     53 #define PEI_SPECIFICATION_MINOR_REVISION  91
     54 #else
     55 #define PEI_SPECIFICATION_MAJOR_REVISION  1
     56 #define PEI_SPECIFICATION_MINOR_REVISION  00
     57 
     58 #endif
     59 
     60 typedef
     61 EFI_STATUS
     62 (EFIAPI *EFI_PEIM_ENTRY_POINT)(
     63   IN EFI_FFS_FILE_HEADER       * FfsHeader,
     64   IN EFI_PEI_SERVICES          **PeiServices
     65   );
     66 
     67 typedef
     68 EFI_STATUS
     69 (EFIAPI *EFI_PEIM_NOTIFY_ENTRY_POINT) (
     70   IN EFI_PEI_SERVICES           **PeiServices,
     71   IN EFI_PEI_NOTIFY_DESCRIPTOR  * NotifyDescriptor,
     72   IN VOID                       *Ppi
     73   );
     74 
     75 typedef
     76 EFI_STATUS
     77 (EFIAPI *EFI_PEI_VERIFICATION) (
     78   IN UINTN    SectionAddress
     79   );
     80 
     81 //
     82 // PEI Ppi Services List Descriptors
     83 //
     84 #define EFI_PEI_PPI_DESCRIPTOR_PIC              0x00000001
     85 #define EFI_PEI_PPI_DESCRIPTOR_PPI              0x00000010
     86 #define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK  0x00000020
     87 #define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH  0x00000040
     88 #define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES     0x00000060
     89 #define EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST   0x80000000
     90 
     91 typedef struct {
     92   UINTN     Flags;
     93   EFI_GUID  *Guid;
     94   VOID      *Ppi;
     95 } EFI_PEI_PPI_DESCRIPTOR;
     96 
     97 struct _EFI_PEI_NOTIFY_DESCRIPTOR {
     98   UINTN                       Flags;
     99   EFI_GUID                    *Guid;
    100   EFI_PEIM_NOTIFY_ENTRY_POINT Notify;
    101 };
    102 
    103 
    104 #if (PI_SPECIFICATION_VERSION < 0x00010000)
    105 
    106 //
    107 // PEI PPI Services
    108 //
    109 typedef
    110 EFI_STATUS
    111 (EFIAPI *EFI_PEI_INSTALL_PPI) (
    112   IN  EFI_PEI_SERVICES            **PeiServices,
    113   IN  EFI_PEI_PPI_DESCRIPTOR      * PpiList
    114   );
    115 
    116 typedef
    117 EFI_STATUS
    118 (EFIAPI *EFI_PEI_REINSTALL_PPI) (
    119   IN  EFI_PEI_SERVICES                **PeiServices,
    120   IN  EFI_PEI_PPI_DESCRIPTOR          * OldPpi,
    121   IN  EFI_PEI_PPI_DESCRIPTOR          * NewPpi
    122   );
    123 
    124 typedef
    125 EFI_STATUS
    126 (EFIAPI *EFI_PEI_LOCATE_PPI) (
    127   IN  EFI_PEI_SERVICES            **PeiServices,
    128   IN  EFI_GUID                    * Guid,
    129   IN UINTN                        Instance,
    130   IN OUT EFI_PEI_PPI_DESCRIPTOR   **PpiDescriptor,
    131   IN OUT VOID                     **Ppi
    132   );
    133 
    134 typedef
    135 EFI_STATUS
    136 (EFIAPI *EFI_PEI_NOTIFY_PPI) (
    137   IN  EFI_PEI_SERVICES                **PeiServices,
    138   IN  EFI_PEI_NOTIFY_DESCRIPTOR       * NotifyList
    139   );
    140 
    141 //
    142 // PEI Boot Mode Services
    143 //
    144 typedef
    145 EFI_STATUS
    146 (EFIAPI *EFI_PEI_GET_BOOT_MODE) (
    147   IN  EFI_PEI_SERVICES                 **PeiServices,
    148   IN OUT EFI_BOOT_MODE                 * BootMode
    149   );
    150 
    151 typedef
    152 EFI_STATUS
    153 (EFIAPI *EFI_PEI_SET_BOOT_MODE) (
    154   IN EFI_PEI_SERVICES                  **PeiServices,
    155   IN EFI_BOOT_MODE                     BootMode
    156   );
    157 
    158 //
    159 // PEI HOB Services
    160 //
    161 typedef
    162 EFI_STATUS
    163 (EFIAPI *EFI_PEI_GET_HOB_LIST) (
    164   IN EFI_PEI_SERVICES                  **PeiServices,
    165   IN OUT VOID                          **HobList
    166   );
    167 
    168 typedef
    169 EFI_STATUS
    170 (EFIAPI *EFI_PEI_CREATE_HOB) (
    171   IN EFI_PEI_SERVICES                  **PeiServices,
    172   IN UINT16                            Type,
    173   IN UINT16                            Length,
    174   IN OUT VOID                          **Hob
    175   );
    176 
    177  //
    178  // PEI Firmware Volume Services
    179  //
    180 
    181 typedef
    182 EFI_STATUS
    183 (EFIAPI *EFI_PEI_FFS_FIND_NEXT_VOLUME) (
    184   IN EFI_PEI_SERVICES                **PeiServices,
    185   IN UINTN                           Instance,
    186   IN OUT EFI_FIRMWARE_VOLUME_HEADER  **FwVolHeader
    187   );
    188 
    189 typedef
    190 EFI_STATUS
    191 (EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE) (
    192   IN EFI_PEI_SERVICES            **PeiServices,
    193   IN EFI_FV_FILETYPE             SearchType,
    194   IN EFI_FIRMWARE_VOLUME_HEADER  * FwVolHeader,
    195   IN OUT EFI_FFS_FILE_HEADER     **FileHeader
    196   );
    197 
    198 typedef
    199 EFI_STATUS
    200 (EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA) (
    201   IN EFI_PEI_SERVICES            **PeiServices,
    202   IN EFI_SECTION_TYPE            SectionType,
    203   IN EFI_FFS_FILE_HEADER         * FfsFileHeader,
    204   IN OUT VOID                    **SectionData
    205   );
    206 
    207 //
    208 // PEI Memory Services
    209 //
    210 typedef
    211 EFI_STATUS
    212 (EFIAPI *EFI_PEI_INSTALL_PEI_MEMORY) (
    213   IN EFI_PEI_SERVICES           **PeiServices,
    214   IN EFI_PHYSICAL_ADDRESS       MemoryBegin,
    215   IN UINT64                     MemoryLength
    216   );
    217 
    218 typedef
    219 EFI_STATUS
    220 (EFIAPI *EFI_PEI_ALLOCATE_PAGES) (
    221   IN EFI_PEI_SERVICES           **PeiServices,
    222   IN EFI_MEMORY_TYPE            MemoryType,
    223   IN UINTN                      Pages,
    224   IN OUT EFI_PHYSICAL_ADDRESS   * Memory
    225   );
    226 
    227 typedef
    228 EFI_STATUS
    229 (EFIAPI *EFI_PEI_ALLOCATE_POOL) (
    230   IN EFI_PEI_SERVICES                **PeiServices,
    231   IN UINTN                           Size,
    232   OUT VOID                           **Buffer
    233   );
    234 
    235 typedef
    236 VOID
    237 (EFIAPI *EFI_PEI_COPY_MEM) (
    238   IN VOID                       *Destination,
    239   IN VOID                       *Source,
    240   IN UINTN                      Length
    241   );
    242 
    243 typedef
    244 VOID
    245 (EFIAPI *EFI_PEI_SET_MEM) (
    246   IN VOID                       *Buffer,
    247   IN UINTN                      Size,
    248   IN UINT8                      Value
    249   );
    250 
    251 typedef
    252 EFI_STATUS
    253 (EFIAPI *EFI_PEI_REPORT_STATUS_CODE) (
    254   IN EFI_PEI_SERVICES         **PeiServices,
    255   IN EFI_STATUS_CODE_TYPE     Type,
    256   IN EFI_STATUS_CODE_VALUE    Value,
    257   IN UINT32                   Instance,
    258   IN EFI_GUID                 * CallerId OPTIONAL,
    259   IN EFI_STATUS_CODE_DATA     * Data OPTIONAL
    260   );
    261 
    262 //
    263 // PEI Reset
    264 //
    265 typedef
    266 EFI_STATUS
    267 (EFIAPI *EFI_PEI_RESET_SYSTEM) (
    268   IN EFI_PEI_SERVICES   **PeiServices
    269   );
    270 
    271 
    272 
    273 #else
    274 
    275 //
    276 // PEI PPI Services
    277 //
    278 typedef
    279 EFI_STATUS
    280 (EFIAPI *EFI_PEI_INSTALL_PPI) (
    281   IN CONST EFI_PEI_SERVICES            **PeiServices,
    282   IN CONST EFI_PEI_PPI_DESCRIPTOR      * PpiList
    283   );
    284 
    285 typedef
    286 EFI_STATUS
    287 (EFIAPI *EFI_PEI_REINSTALL_PPI) (
    288   IN CONST EFI_PEI_SERVICES                **PeiServices,
    289   IN CONST EFI_PEI_PPI_DESCRIPTOR          * OldPpi,
    290   IN CONST EFI_PEI_PPI_DESCRIPTOR          * NewPpi
    291   );
    292 
    293 typedef
    294 EFI_STATUS
    295 (EFIAPI *EFI_PEI_LOCATE_PPI) (
    296   IN CONST EFI_PEI_SERVICES            **PeiServices,
    297   IN CONST EFI_GUID                    * Guid,
    298   IN UINTN                             Instance,
    299   IN OUT EFI_PEI_PPI_DESCRIPTOR        **PpiDescriptor OPTIONAL,
    300   IN OUT VOID                          **Ppi
    301   );
    302 
    303 typedef
    304 EFI_STATUS
    305 (EFIAPI *EFI_PEI_NOTIFY_PPI) (
    306   IN CONST EFI_PEI_SERVICES                **PeiServices,
    307   IN CONST EFI_PEI_NOTIFY_DESCRIPTOR       * NotifyList
    308   );
    309 
    310 //
    311 // PEI Boot Mode Services
    312 //
    313 typedef
    314 EFI_STATUS
    315 (EFIAPI *EFI_PEI_GET_BOOT_MODE) (
    316   IN CONST EFI_PEI_SERVICES            **PeiServices,
    317   IN OUT EFI_BOOT_MODE                 * BootMode
    318   );
    319 
    320 typedef
    321 EFI_STATUS
    322 (EFIAPI *EFI_PEI_SET_BOOT_MODE) (
    323   IN CONST EFI_PEI_SERVICES            **PeiServices,
    324   IN EFI_BOOT_MODE                     BootMode
    325   );
    326 
    327 //
    328 // PEI HOB Services
    329 //
    330 typedef
    331 EFI_STATUS
    332 (EFIAPI *EFI_PEI_GET_HOB_LIST) (
    333   IN CONST EFI_PEI_SERVICES            **PeiServices,
    334   IN OUT VOID                          **HobList
    335   );
    336 
    337 typedef
    338 EFI_STATUS
    339 (EFIAPI *EFI_PEI_CREATE_HOB) (
    340   IN CONST EFI_PEI_SERVICES            **PeiServices,
    341   IN UINT16                            Type,
    342   IN UINT16                            Length,
    343   IN OUT VOID                          **Hob
    344   );
    345 
    346 
    347 
    348  //
    349  // PEI Firmware Volume Services
    350  //
    351 typedef
    352 EFI_STATUS
    353 (EFIAPI *EFI_PEI_FFS_FIND_NEXT_VOLUME2) (
    354   IN CONST  EFI_PEI_SERVICES  **PeiServices,
    355   IN UINTN                    Instance,
    356   IN OUT EFI_PEI_FV_HANDLE    *VolumeHandle
    357   );
    358 
    359 typedef
    360 EFI_STATUS
    361 (EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE2) (
    362   IN CONST  EFI_PEI_SERVICES        **PeiServices,
    363   IN EFI_FV_FILETYPE                SearchType,
    364   IN CONST EFI_PEI_FV_HANDLE        FvHandle,
    365   IN OUT EFI_PEI_FILE_HANDLE        *FileHandle
    366   );
    367 
    368 typedef
    369 EFI_STATUS
    370 (EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA2) (
    371   IN CONST  EFI_PEI_SERVICES    **PeiServices,
    372   IN EFI_SECTION_TYPE           SectionType,
    373   IN EFI_PEI_FILE_HANDLE        FileHandle,
    374   OUT VOID                      **SectionData
    375   );
    376 
    377 
    378   //
    379   // PEI Memory Services
    380   //
    381 typedef
    382 EFI_STATUS
    383 (EFIAPI *EFI_PEI_INSTALL_PEI_MEMORY) (
    384   IN CONST EFI_PEI_SERVICES     **PeiServices,
    385   IN EFI_PHYSICAL_ADDRESS       MemoryBegin,
    386   IN UINT64                     MemoryLength
    387   );
    388 
    389 typedef
    390 EFI_STATUS
    391 (EFIAPI *EFI_PEI_ALLOCATE_PAGES) (
    392 
    393   IN CONST EFI_PEI_SERVICES     **PeiServices,
    394   IN EFI_MEMORY_TYPE            MemoryType,
    395   IN UINTN                      Pages,
    396   IN OUT EFI_PHYSICAL_ADDRESS   * Memory
    397   );
    398 
    399 typedef
    400 EFI_STATUS
    401 (EFIAPI *EFI_PEI_ALLOCATE_POOL) (
    402   IN CONST EFI_PEI_SERVICES          **PeiServices,
    403   IN UINTN                           Size,
    404   OUT VOID                           **Buffer
    405   );
    406 
    407 typedef
    408 VOID
    409 (EFIAPI *EFI_PEI_COPY_MEM) (
    410   IN VOID                       *Destination,
    411   IN VOID                       *Source,
    412   IN UINTN                      Length
    413   );
    414 
    415 typedef
    416 VOID
    417 (EFIAPI *EFI_PEI_SET_MEM) (
    418   IN VOID                       *Buffer,
    419   IN UINTN                      Size,
    420   IN UINT8                      Value
    421   );
    422 
    423   //
    424   // New interfaceas added by the PI 1.0
    425   //
    426 typedef
    427 EFI_STATUS
    428 (EFIAPI *EFI_PEI_FFS_FIND_BY_NAME) (
    429   IN  CONST EFI_GUID        *FileName,
    430   IN  EFI_PEI_FV_HANDLE     VolumeHandle,
    431   OUT EFI_PEI_FILE_HANDLE   *FileHandle
    432   );
    433 
    434 
    435 typedef
    436 EFI_STATUS
    437 (EFIAPI *EFI_PEI_FFS_GET_FILE_INFO) (
    438   IN  EFI_PEI_FILE_HANDLE   FileHandle,
    439   OUT EFI_FV_FILE_INFO      *FileInfo
    440   );
    441 
    442 
    443 typedef
    444 EFI_STATUS
    445 (EFIAPI *EFI_PEI_FFS_GET_VOLUME_INFO) (
    446   IN  EFI_PEI_FV_HANDLE     VolumeHandle,
    447   OUT EFI_FV_INFO           *VolumeInfo
    448   );
    449 
    450 typedef
    451 EFI_STATUS
    452 (EFIAPI *EFI_PEI_REGISTER_FOR_SHADOW) (
    453   IN EFI_PEI_FILE_HANDLE       FileHandle
    454   );
    455 
    456 //
    457 // PEI Status Code Service
    458 //
    459 typedef
    460 EFI_STATUS
    461 (EFIAPI *EFI_PEI_REPORT_STATUS_CODE) (
    462   IN EFI_PEI_SERVICES               **PeiServices,
    463   IN EFI_STATUS_CODE_TYPE           Type,
    464   IN EFI_STATUS_CODE_VALUE          Value,
    465   IN UINT32                         Instance,
    466   IN EFI_GUID                       *CallerId OPTIONAL,
    467   IN EFI_STATUS_CODE_DATA           *Data OPTIONAL
    468   );
    469 
    470 //
    471 // PEI Reset Service
    472 //
    473 typedef
    474 EFI_STATUS
    475 (EFIAPI *EFI_PEI_RESET_SYSTEM) (
    476   IN EFI_PEI_SERVICES   **PeiServices
    477   );
    478 
    479 #endif
    480 
    481 
    482 //
    483 // EFI PEI Services Table
    484 //
    485 #define PEI_SERVICES_SIGNATURE  0x5652455320494550ULL
    486 #define PEI_SERVICES_REVISION   ((PEI_SPECIFICATION_MAJOR_REVISION << 16) | (PEI_SPECIFICATION_MINOR_REVISION))
    487 typedef PEI_CPU_IO_PPI          EFI_PEI_CPU_IO_PPI;
    488 
    489 
    490 struct _EFI_PEI_SERVICES {
    491   EFI_TABLE_HEADER              Hdr;
    492 
    493   //
    494   // PPI Functions
    495   //
    496   EFI_PEI_INSTALL_PPI           InstallPpi;
    497   EFI_PEI_REINSTALL_PPI         ReInstallPpi;
    498   EFI_PEI_LOCATE_PPI            LocatePpi;
    499   EFI_PEI_NOTIFY_PPI            NotifyPpi;
    500 
    501   //
    502   // Boot Mode Functions
    503   //
    504   EFI_PEI_GET_BOOT_MODE         GetBootMode;
    505   EFI_PEI_SET_BOOT_MODE         SetBootMode;
    506 
    507   //
    508   // HOB Functions
    509   //
    510   EFI_PEI_GET_HOB_LIST          GetHobList;
    511   EFI_PEI_CREATE_HOB            CreateHob;
    512 
    513   //
    514   // Firmware Volume Functions
    515   //
    516 #if (PI_SPECIFICATION_VERSION < 0x00010000)
    517   EFI_PEI_FFS_FIND_NEXT_VOLUME  FfsFindNextVolume;
    518   EFI_PEI_FFS_FIND_NEXT_FILE    FfsFindNextFile;
    519   EFI_PEI_FFS_FIND_SECTION_DATA FfsFindSectionData;
    520 #else
    521   EFI_PEI_FFS_FIND_NEXT_VOLUME2  FfsFindNextVolume;
    522   EFI_PEI_FFS_FIND_NEXT_FILE2    FfsFindNextFile;
    523   EFI_PEI_FFS_FIND_SECTION_DATA2 FfsFindSectionData;
    524 #endif
    525   //
    526   // PEI Memory Functions
    527   //
    528   EFI_PEI_INSTALL_PEI_MEMORY    InstallPeiMemory;
    529   EFI_PEI_ALLOCATE_PAGES        AllocatePages;
    530   EFI_PEI_ALLOCATE_POOL         AllocatePool;
    531   EFI_PEI_COPY_MEM              CopyMem;
    532   EFI_PEI_SET_MEM               SetMem;
    533 
    534   //
    535   // Status Code
    536   //
    537   EFI_PEI_REPORT_STATUS_CODE    PeiReportStatusCode;
    538 
    539   //
    540   // Reset
    541   //
    542   EFI_PEI_RESET_SYSTEM          PeiResetSystem;
    543 
    544   //
    545   // Pointer to PPI interface
    546   //
    547 #if (PI_SPECIFICATION_VERSION < 0x00010000)
    548 
    549   PEI_CPU_IO_PPI                 *CpuIo;
    550 #if defined (SUPPORT_DEPRECATED_PCI_CFG_PPI)
    551   PEI_PCI_CFG_PPI                *PciCfg;
    552 #else
    553   ECP_PEI_PCI_CFG_PPI            *PciCfg;
    554 #endif
    555 #else
    556   EFI_PEI_CPU_IO_PPI             *CpuIo;
    557   EFI_PEI_PCI_CFG2_PPI           *PciCfg;
    558 
    559   //
    560   // New interfaceas added by the PI 1.0
    561   //
    562   EFI_PEI_FFS_FIND_BY_NAME        FfsFindFileByName;
    563   EFI_PEI_FFS_GET_FILE_INFO       FfsGetFileInfo;
    564   EFI_PEI_FFS_GET_VOLUME_INFO     FfsGetVolumeInfo;
    565   EFI_PEI_REGISTER_FOR_SHADOW     RegisterForShadow;
    566 #endif
    567 
    568 };
    569 
    570 #if (PI_SPECIFICATION_VERSION < 0x00010000)
    571 
    572 typedef struct {
    573   UINTN                   BootFirmwareVolume;
    574   UINTN                   SizeOfCacheAsRam;
    575   EFI_PEI_PPI_DESCRIPTOR  *DispatchTable;
    576 } EFI_PEI_STARTUP_DESCRIPTOR;
    577 
    578 typedef
    579 EFI_STATUS
    580 (EFIAPI *PEI_MAIN_ENTRY_POINT) (
    581     IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor
    582   );
    583 
    584 #else
    585 
    586 typedef struct _EFI_SEC_PEI_HAND_OFF {
    587   UINT16  DataSize;
    588   VOID    *BootFirmwareVolumeBase;
    589   UINTN   BootFirmwareVolumeSize;
    590   VOID    *TemporaryRamBase;
    591   UINTN   TemporaryRamSize;
    592   VOID    *PeiTemporaryRamBase;
    593   UINTN   PeiTemporaryRamSize;
    594   VOID    *StackBase;
    595   UINTN   StackSize;
    596 } EFI_SEC_PEI_HAND_OFF;
    597 
    598 typedef
    599 EFI_STATUS
    600 (EFIAPI *PEI_MAIN_ENTRY_POINT) (
    601   IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData,
    602   IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList
    603   );
    604 
    605 #endif
    606 
    607 #endif
    608