1 /** @file
2   The Include file for definitions in the Intel Platform Innovation Framework for EFI
3   Pre-EFI Initialization Core Interface Specification (PEI CIS) Version 0.91.
4 
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7 
8 **/
9 
10 #ifndef __PEICIS_H__
11 #define __PEICIS_H__
12 
13 #include <Ppi/PciCfg.h>
14 //
15 // Framework PEI Specification Revision information
16 //
17 #define FRAMEWORK_PEI_SPECIFICATION_MAJOR_REVISION    0
18 #define FRAMEWORK_PEI_SPECIFICATION_MINOR_REVISION    91
19 
20 
21 //
22 // PEI services signature and Revision defined in Framework PEI spec
23 //
24 #define FRAMEWORK_PEI_SERVICES_SIGNATURE               0x5652455320494550ULL
25 #define FRAMEWORK_PEI_SERVICES_REVISION               ((FRAMEWORK_PEI_SPECIFICATION_MAJOR_REVISION<<16) | (FRAMEWORK_PEI_SPECIFICATION_MINOR_REVISION))
26 
27 
28 
29 typedef struct _FRAMEWORK_EFI_PEI_SERVICES FRAMEWORK_EFI_PEI_SERVICES;
30 
31 /**
32   The PEI Dispatcher will invoke each PEIM one time.  During this pass, the PEI
33   Dispatcher will pass control to the PEIM at the AddressOfEntryPoint in the PE Header.
34 
35   @param  FfsHeader        The pointer to the FFS file header.
36   @param  PeiServices      Describes the list of possible PEI Services.
37 
38   @return Status code
39 
40 **/
41 typedef
42 EFI_STATUS
43 (EFIAPI *EFI_PEIM_ENTRY_POINT)(
44   IN EFI_FFS_FILE_HEADER            *FfsHeader,
45   IN EFI_PEI_SERVICES               **PeiServices
46   );
47 
48 /**
49   This service abstracts the capability of the PEI
50   Foundation to discover instances of firmware volumes in the system.
51   Given the input file pointer, this service searches for the next
52   matching file in the Firmware File System (FFS) volume.
53 
54   @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
55   @param  Instance         This instance of the firmware volume to find. The value 0 is the Boot Firmware Volume (BFV).
56   @param  FwVolHeader      The pointer to the firmware volume header of the volume to return.
57 
58   @retval EFI_SUCCESS           The volume was found.
59   @retval EFI_NOT_FOUND         The volume was not found.
60   @retval EFI_INVALID_PARAMETER FwVolHeader is NULL
61 
62 **/
63 typedef
64 EFI_STATUS
65 (EFIAPI *EFI_PEI_FFS_FIND_NEXT_VOLUME)(
66   IN FRAMEWORK_EFI_PEI_SERVICES     **PeiServices,
67   IN UINTN                          Instance,
68   IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
69   );
70 
71 /**
72   This service abstracts the capability of the PEI
73   Foundation to discover instances of firmware files in the system.
74   Given the input file pointer, this service searches for the next matching
75   file in the Firmware File System (FFS) volume.
76 
77   @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
78   @param  SearchType       A filter to find files only of this type.
79   @param  FwVolHeader      The pointer to the firmware volume header of the volume to search. This parameter
80                            must point to a valid FFS volume.
81   @param  FileHeader       The pointer to the current file from which to begin searching. Upon return this pointer will be
82                            updated to reflect the file found.
83 
84   @retval EFI_SUCCESS      The file was found.
85   @retval EFI_NOT_FOUND    The file was not found.
86   @retval EFI_NOT_FOUND    The header checksum was not zero.
87 
88 **/
89 typedef
90 EFI_STATUS
91 (EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE)(
92   IN FRAMEWORK_EFI_PEI_SERVICES     **PeiServices,
93   IN EFI_FV_FILETYPE                SearchType,
94   IN EFI_FIRMWARE_VOLUME_HEADER     *FwVolHeader,
95   IN OUT EFI_FFS_FILE_HEADER        **FileHeader
96   );
97 
98 /**
99   Given the input file pointer, this service searches for the next
100   matching file in the Firmware File System (FFS) volume.
101 
102   @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
103   @param  SectionType      The value of the section type to find.
104   @param  FfsFileHeader    A pointer to the file header that contains the set of sections to be searched.
105   @param  SectionData      A pointer to the discovered section, if successful.
106 
107   @retval EFI_SUCCESS      The section was found.
108   @retval EFI_NOT_FOUND    The section was not found.
109 
110 **/
111 typedef
112 EFI_STATUS
113 (EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA)(
114   IN FRAMEWORK_EFI_PEI_SERVICES     **PeiServices,
115   IN EFI_SECTION_TYPE               SectionType,
116   IN EFI_FFS_FILE_HEADER            *FfsFileHeader,
117   IN OUT VOID                       **SectionData
118   );
119 
120 ///
121 ///  FRAMEWORK_EFI_PEI_SERVICES is a collection of functions whose implementation is provided by the PEI
122 ///  Foundation. The table may be located in the temporary or permanent memory, depending upon the capabilities
123 ///  and phase of execution of PEI.
124 ///
125 ///  These services fall into various classes, including the following:
126 ///  - Managing the boot mode.
127 ///  - Allocating both early and permanent memory.
128 ///  - Supporting the Firmware File System (FFS).
129 ///  - Abstracting the PPI database abstraction.
130 ///  - Creating Hand-Off Blocks (HOBs).
131 ///
132 struct _FRAMEWORK_EFI_PEI_SERVICES {
133   EFI_TABLE_HEADER                  Hdr;
134   //
135   // PPI Functions
136   //
137   EFI_PEI_INSTALL_PPI               InstallPpi;
138   EFI_PEI_REINSTALL_PPI             ReInstallPpi;
139   EFI_PEI_LOCATE_PPI                LocatePpi;
140   EFI_PEI_NOTIFY_PPI                NotifyPpi;
141   //
142   // Boot Mode Functions
143   //
144   EFI_PEI_GET_BOOT_MODE             GetBootMode;
145   EFI_PEI_SET_BOOT_MODE             SetBootMode;
146   //
147   // HOB Functions
148   //
149   EFI_PEI_GET_HOB_LIST              GetHobList;
150   EFI_PEI_CREATE_HOB                CreateHob;
151   //
152   // Firmware Volume Functions
153   //
154   EFI_PEI_FFS_FIND_NEXT_VOLUME      FfsFindNextVolume;
155   EFI_PEI_FFS_FIND_NEXT_FILE        FfsFindNextFile;
156   EFI_PEI_FFS_FIND_SECTION_DATA     FfsFindSectionData;
157   //
158   // PEI Memory Functions
159   //
160   EFI_PEI_INSTALL_PEI_MEMORY        InstallPeiMemory;
161   EFI_PEI_ALLOCATE_PAGES            AllocatePages;
162   EFI_PEI_ALLOCATE_POOL             AllocatePool;
163   EFI_PEI_COPY_MEM                  CopyMem;
164   EFI_PEI_SET_MEM                   SetMem;
165   //
166   // (the following interfaces are installed by publishing PEIM)
167   // Status Code
168   //
169   EFI_PEI_REPORT_STATUS_CODE        ReportStatusCode;
170   //
171   // Reset
172   //
173   EFI_PEI_RESET_SYSTEM              ResetSystem;
174   ///
175   /// Inconsistent with specification here:
176   /// In Framework Spec, PeiCis0.91, CpuIo and PciCfg are NOT pointers.
177   ///
178 
179   //
180   // I/O Abstractions
181   //
182   EFI_PEI_CPU_IO_PPI                *CpuIo;
183   EFI_PEI_PCI_CFG_PPI               *PciCfg;
184 };
185 ///
186 /// Enumeration of reset types defined in the Framework Specification PeiCis.
187 ///
188 typedef enum {
189   ///
190   /// Used to induce a system-wide reset. This sets all circuitry within the
191   /// system to its initial state.  This type of reset is asynchronous to system
192   /// operation and operates withgout regard to cycle boundaries.  EfiColdReset
193   /// is tantamount to a system power cycle.
194   ///
195   EfiPeiResetCold,
196   ///
197   /// Used to induce a system-wide initialization. The processors are set to their
198   /// initial state, and pending cycles are not corrupted.  If the system does
199   /// not support this reset type, then an EfiResetCold must be performed.
200   ///
201   EfiPeiResetWarm,
202 } EFI_PEI_RESET_TYPE;
203 
204 #endif
205 
206