]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg/PeiMain: Support EFI_PEI_CORE_FV_LOCATION_PPI
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
CommitLineData
615c6dd0 1/** @file\r
b1f6a7c6 2 Definition of Pei Core Structures and Services\r
d1102dba 3\r
9b23c7ba 4Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 5This program and the accompanying materials\r
192f6d4c 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
615c6dd0 13**/\r
192f6d4c 14\r
15#ifndef _PEI_MAIN_H_\r
16#define _PEI_MAIN_H_\r
17\r
859b72fa 18#include <PiPei.h>\r
859b72fa
A
19#include <Ppi/DxeIpl.h>\r
20#include <Ppi/MemoryDiscovered.h>\r
859b72fa 21#include <Ppi/StatusCode.h>\r
859b72fa 22#include <Ppi/Reset.h>\r
672473ea 23#include <Ppi/Reset2.h>\r
b0d803fe 24#include <Ppi/FirmwareVolume.h>\r
25#include <Ppi/FirmwareVolumeInfo.h>\r
c7935105 26#include <Ppi/FirmwareVolumeInfo2.h>\r
b0d803fe 27#include <Ppi/Decompress.h>\r
28#include <Ppi/GuidedSectionExtraction.h>\r
29#include <Ppi/LoadFile.h>\r
30#include <Ppi/Security2.h>\r
58dcdada 31#include <Ppi/TemporaryRamSupport.h>\r
0f9ebb32 32#include <Ppi/TemporaryRamDone.h>\r
483e2cdd 33#include <Ppi/SecHobData.h>\r
9b23c7ba 34#include <Ppi/PeiCoreFvLocation.h>\r
859b72fa
A
35#include <Library/DebugLib.h>\r
36#include <Library/PeiCoreEntryPoint.h>\r
37#include <Library/BaseLib.h>\r
38#include <Library/HobLib.h>\r
39#include <Library/PerformanceLib.h>\r
40#include <Library/PeiServicesLib.h>\r
41#include <Library/ReportStatusCodeLib.h>\r
c58cf83d 42#include <Library/PeCoffLib.h>\r
859b72fa
A
43#include <Library/PeCoffGetEntryPointLib.h>\r
44#include <Library/BaseMemoryLib.h>\r
b0d803fe 45#include <Library/CacheMaintenanceLib.h>\r
177aabe6 46#include <Library/PcdLib.h>\r
28dc3c67 47#include <IndustryStandard/PeImage.h>\r
14e8823a 48#include <Library/PeiServicesTablePointerLib.h>\r
b0d803fe 49#include <Library/MemoryAllocationLib.h>\r
50#include <Guid/FirmwareFileSystem2.h>\r
890e5417 51#include <Guid/FirmwareFileSystem3.h>\r
b0d803fe 52#include <Guid/AprioriFileName.h>\r
192f6d4c 53\r
15273993 54///\r
55/// It is an FFS type extension used for PeiFindFileEx. It indicates current\r
56/// Ffs searching is for all PEIMs can be dispatched by PeiCore.\r
57///\r
3a63377f 58#define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE 0xff\r
59\r
b1f6a7c6 60///\r
61/// Pei Core private data structures\r
62///\r
192f6d4c 63typedef union {\r
64 EFI_PEI_PPI_DESCRIPTOR *Ppi;\r
65 EFI_PEI_NOTIFY_DESCRIPTOR *Notify;\r
66 VOID *Raw;\r
67} PEI_PPI_LIST_POINTERS;\r
68\r
40f26b8f 69///\r
f2bc359c 70/// Number of PEI_PPI_LIST_POINTERS to grow by each time we run out of room\r
40f26b8f 71///\r
f2bc359c
SZ
72#define PPI_GROWTH_STEP 64\r
73#define CALLBACK_NOTIFY_GROWTH_STEP 32\r
74#define DISPATCH_NOTIFY_GROWTH_STEP 8\r
75\r
192f6d4c 76typedef struct {\r
f2bc359c
SZ
77 UINTN CurrentCount;\r
78 UINTN MaxCount;\r
79 UINTN LastDispatchedCount;\r
1cc76977 80 ///\r
f2bc359c 81 /// MaxCount number of entries.\r
1cc76977 82 ///\r
f2bc359c
SZ
83 PEI_PPI_LIST_POINTERS *PpiPtrs;\r
84} PEI_PPI_LIST;\r
85\r
86typedef struct {\r
87 UINTN CurrentCount;\r
88 UINTN MaxCount;\r
1cc76977 89 ///\r
f2bc359c 90 /// MaxCount number of entries.\r
1cc76977 91 ///\r
f2bc359c
SZ
92 PEI_PPI_LIST_POINTERS *NotifyPtrs;\r
93} PEI_CALLBACK_NOTIFY_LIST;\r
94\r
95typedef struct {\r
96 UINTN CurrentCount;\r
97 UINTN MaxCount;\r
98 UINTN LastDispatchedCount;\r
1cc76977 99 ///\r
f2bc359c 100 /// MaxCount number of entries.\r
1cc76977 101 ///\r
f2bc359c
SZ
102 PEI_PPI_LIST_POINTERS *NotifyPtrs;\r
103} PEI_DISPATCH_NOTIFY_LIST;\r
104\r
105///\r
106/// PPI database structure which contains three links:\r
107/// PpiList, CallbackNotifyList and DispatchNotifyList.\r
108///\r
109typedef struct {\r
1cc76977 110 ///\r
f2bc359c 111 /// PPI List.\r
1cc76977 112 ///\r
f2bc359c 113 PEI_PPI_LIST PpiList;\r
1cc76977 114 ///\r
f2bc359c 115 /// Notify List at dispatch level.\r
d1102dba 116 ///\r
f2bc359c 117 PEI_CALLBACK_NOTIFY_LIST CallbackNotifyList;\r
1cc76977 118 ///\r
f2bc359c 119 /// Notify List at callback level.\r
1cc76977 120 ///\r
f2bc359c 121 PEI_DISPATCH_NOTIFY_LIST DispatchNotifyList;\r
192f6d4c 122} PEI_PPI_DATABASE;\r
123\r
3a63377f 124//\r
125// PEI_CORE_FV_HANDE.PeimState\r
126// Do not change these values as there is code doing math to change states.\r
127// Look for Private->Fv[FvCount].PeimState[PeimCount]++;\r
128//\r
129#define PEIM_STATE_NOT_DISPATCHED 0x00\r
130#define PEIM_STATE_DISPATCHED 0x01\r
c2c4199b 131#define PEIM_STATE_REGISTER_FOR_SHADOW 0x02\r
3a63377f 132#define PEIM_STATE_DONE 0x03\r
133\r
111e6c92
SZ
134//\r
135// Number of FV instances to grow by each time we run out of room\r
136//\r
137#define FV_GROWTH_STEP 8\r
138\r
3a63377f 139typedef struct {\r
140 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
3b428ade 141 EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;\r
142 EFI_PEI_FV_HANDLE FvHandle;\r
b62fe570 143 UINTN PeimCount;\r
fe781940 144 //\r
b62fe570 145 // Ponter to the buffer with the PeimCount number of Entries.\r
fe781940
SZ
146 //\r
147 UINT8 *PeimState;\r
148 //\r
b62fe570 149 // Ponter to the buffer with the PeimCount number of Entries.\r
fe781940
SZ
150 //\r
151 EFI_PEI_FILE_HANDLE *FvFileHandles;\r
3a63377f 152 BOOLEAN ScanFv;\r
c7935105 153 UINT32 AuthenticationStatus;\r
3a63377f 154} PEI_CORE_FV_HANDLE;\r
155\r
f3358329 156typedef struct {\r
157 EFI_GUID FvFormat;\r
158 VOID *FvInfo;\r
159 UINT32 FvInfoSize;\r
c7935105 160 UINT32 AuthenticationStatus;\r
f3358329 161 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;\r
162} PEI_CORE_UNKNOW_FORMAT_FV_INFO;\r
163\r
288f9b38
LG
164#define CACHE_SETION_MAX_NUMBER 0x10\r
165typedef struct {\r
166 EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];\r
167 VOID* SectionData[CACHE_SETION_MAX_NUMBER];\r
168 UINTN SectionSize[CACHE_SETION_MAX_NUMBER];\r
c7935105 169 UINT32 AuthenticationStatus[CACHE_SETION_MAX_NUMBER];\r
288f9b38
LG
170 UINTN AllSectionCount;\r
171 UINTN SectionIndex;\r
172} CACHE_SECTION_DATA;\r
173\r
0f9ebb32
LG
174#define HOLE_MAX_NUMBER 0x3\r
175typedef struct {\r
176 EFI_PHYSICAL_ADDRESS Base;\r
177 UINTN Size;\r
178 UINTN Offset;\r
179 BOOLEAN OffsetPositive;\r
180} HOLE_MEMORY_DATA;\r
181\r
ef05e063 182///\r
183/// Forward declaration for PEI_CORE_INSTANCE\r
184///\r
185typedef struct _PEI_CORE_INSTANCE PEI_CORE_INSTANCE;\r
186\r
187\r
188/**\r
189 Function Pointer type for PeiCore function.\r
d1102dba 190 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
ef05e063 191 and location of temporary RAM, the stack location and the BFV location.\r
192 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
193 An empty PPI list consists of a single descriptor with the end-tag\r
194 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
195 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
196 that both the PEI Foundation and any modules can leverage the associated service\r
197 calls and/or code in these early PPIs\r
198 @param OldCoreData Pointer to old core data that is used to initialize the\r
199 core's data areas.\r
200**/\r
201typedef\r
202EFI_STATUS\r
203(EFIAPI *PEICORE_FUNCTION_POINTER)(\r
204 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
205 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
206 IN PEI_CORE_INSTANCE *OldCoreData\r
207 );\r
192f6d4c 208\r
b62fe570
SZ
209//\r
210// Number of files to grow by each time we run out of room\r
211//\r
212#define TEMP_FILE_GROWTH_STEP 32\r
213\r
f3f2e05d 214#define PEI_CORE_HANDLE_SIGNATURE SIGNATURE_32('P','e','i','C')\r
192f6d4c 215\r
40f26b8f 216///\r
217/// Pei Core private data structure instance\r
218///\r
ef05e063 219struct _PEI_CORE_INSTANCE {\r
192f6d4c 220 UINTN Signature;\r
d1102dba 221\r
3b428ade 222 ///\r
223 /// Point to ServiceTableShadow\r
224 ///\r
4140a663 225 EFI_PEI_SERVICES *Ps;\r
192f6d4c 226 PEI_PPI_DATABASE PpiData;\r
d1102dba 227\r
3b428ade 228 ///\r
229 /// The count of FVs which contains FFS and could be dispatched by PeiCore.\r
230 ///\r
3a63377f 231 UINTN FvCount;\r
d1102dba 232\r
3b428ade 233 ///\r
111e6c92
SZ
234 /// The max count of FVs which contains FFS and could be dispatched by PeiCore.\r
235 ///\r
236 UINTN MaxFvCount;\r
237\r
238 ///\r
239 /// Pointer to the buffer with the MaxFvCount number of entries.\r
fe781940 240 /// Each entry is for one FV which contains FFS and could be dispatched by PeiCore.\r
3b428ade 241 ///\r
fe781940
SZ
242 PEI_CORE_FV_HANDLE *Fv;\r
243\r
244 ///\r
111e6c92 245 /// Pointer to the buffer with the MaxUnknownFvInfoCount number of entries.\r
fe781940
SZ
246 /// Each entry is for one FV which could not be dispatched by PeiCore.\r
247 ///\r
248 PEI_CORE_UNKNOW_FORMAT_FV_INFO *UnknownFvInfo;\r
111e6c92 249 UINTN MaxUnknownFvInfoCount;\r
f3358329 250 UINTN UnknownFvInfoCount;\r
d1102dba 251\r
fe781940 252 ///\r
b62fe570 253 /// Pointer to the buffer FvFileHandlers in PEI_CORE_FV_HANDLE specified by CurrentPeimFvCount.\r
fe781940
SZ
254 ///\r
255 EFI_PEI_FILE_HANDLE *CurrentFvFileHandles;\r
3a63377f 256 UINTN AprioriCount;\r
50cb16d9 257 UINTN CurrentPeimFvCount;\r
3a63377f 258 UINTN CurrentPeimCount;\r
259 EFI_PEI_FILE_HANDLE CurrentFileHandle;\r
82b8c8df 260 BOOLEAN PeimNeedingDispatch;\r
261 BOOLEAN PeimDispatchOnThisPass;\r
262 BOOLEAN PeimDispatcherReenter;\r
192f6d4c 263 EFI_PEI_HOB_POINTERS HobList;\r
264 BOOLEAN SwitchStackSignal;\r
265 BOOLEAN PeiMemoryInstalled;\r
192f6d4c 266 VOID *CpuIo;\r
b0d803fe 267 EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi;\r
192f6d4c 268 EFI_PEI_SERVICES ServiceTableShadow;\r
b0d803fe 269 EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;\r
58dcdada 270 EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin;\r
271 UINT64 PhysicalMemoryLength;\r
272 EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop;\r
ef05e063 273 UINTN HeapOffset;\r
274 BOOLEAN HeapOffsetPositive;\r
424b7c9f 275 UINTN StackOffset;\r
276 BOOLEAN StackOffsetPositive;\r
b2374cec
SZ
277 //\r
278 // Information for migrating memory pages allocated in pre-memory phase.\r
279 //\r
280 HOLE_MEMORY_DATA MemoryPages;\r
ef05e063 281 PEICORE_FUNCTION_POINTER ShadowedPeiCore;\r
288f9b38 282 CACHE_SECTION_DATA CacheSection;\r
54ea99a7 283 //\r
d1102dba
LG
284 // For Loading modules at fixed address feature to cache the top address below which the\r
285 // Runtime code, boot time code and PEI memory will be placed. Please note that the offset between this field\r
286 // and Ps should not be changed since maybe user could get this top address by using the offet to Ps.\r
54ea99a7 287 //\r
288 EFI_PHYSICAL_ADDRESS LoadModuleAtFixAddressTopAddress;\r
289 //\r
290 // The field is define for Loading modules at fixed address feature to tracker the PEI code\r
291 // memory range usage. It is a bit mapped array in which every bit indicates the correspoding memory page\r
d1102dba 292 // available or not.\r
54ea99a7 293 //\r
294 UINT64 *PeiCodeMemoryRangeUsageBitMap;\r
25973fc3 295 //\r
296 // This field points to the shadowed image read function\r
297 //\r
298 PE_COFF_LOADER_READ_FILE ShadowedImageRead;\r
fe781940 299\r
b62fe570
SZ
300 UINTN TempPeimCount;\r
301\r
fe781940 302 //\r
b62fe570 303 // Pointer to the temp buffer with the TempPeimCount number of entries.\r
fe781940 304 //\r
b62fe570 305 EFI_PEI_FILE_HANDLE *TempFileHandles;\r
fe781940 306 //\r
b62fe570 307 // Pointer to the temp buffer with the TempPeimCount number of entries.\r
fe781940 308 //\r
b62fe570 309 EFI_GUID *TempFileGuid;\r
fe781940 310\r
0f9ebb32
LG
311 //\r
312 // Temp Memory Range is not covered by PeiTempMem and Stack.\r
b2374cec 313 // Those Memory Range will be migrated into physical memory.\r
0f9ebb32
LG
314 //\r
315 HOLE_MEMORY_DATA HoleData[HOLE_MAX_NUMBER];\r
ef05e063 316};\r
192f6d4c 317\r
40f26b8f 318///\r
319/// Pei Core Instance Data Macros\r
320///\r
192f6d4c 321#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \\r
4140a663 322 CR(a, PEI_CORE_INSTANCE, Ps, PEI_CORE_HANDLE_SIGNATURE)\r
192f6d4c 323\r
b1f6a7c6 324///\r
325/// Union of temporarily used function pointers (to save stack space)\r
326///\r
192f6d4c 327typedef union {\r
15273993 328 PEICORE_FUNCTION_POINTER PeiCore;\r
1c9d209f 329 EFI_PEIM_ENTRY_POINT2 PeimEntry;\r
192f6d4c 330 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;\r
331 EFI_DXE_IPL_PPI *DxeIpl;\r
332 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
333 EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;\r
334 VOID *Raw;\r
335} PEI_CORE_TEMP_POINTERS;\r
336\r
b98c2ab7 337typedef struct {\r
338 CONST EFI_SEC_PEI_HAND_OFF *SecCoreData;\r
339 EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
340 VOID *Data;\r
341} PEI_CORE_PARAMETERS;\r
342\r
192f6d4c 343//\r
344// PeiCore function\r
345//\r
b1f6a7c6 346/**\r
192f6d4c 347\r
348 The entry routine to Pei Core, invoked by PeiMain during transition\r
349 from SEC to PEI. After switching stack in the PEI core, it will restart\r
350 with the old core data.\r
351\r
192f6d4c 352\r
d1102dba 353 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
f34aec3b 354 and location of temporary RAM, the stack location and the BFV location.\r
b1f6a7c6 355 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
356 An empty PPI list consists of a single descriptor with the end-tag\r
357 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
358 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
359 that both the PEI Foundation and any modules can leverage the associated service\r
360 calls and/or code in these early PPIs\r
361 @param Data Pointer to old core data that is used to initialize the\r
192f6d4c 362 core's data areas.\r
363\r
b1f6a7c6 364**/\r
0308e20d 365VOID\r
b1f6a7c6 366EFIAPI\r
367PeiCore (\r
368 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
d976bf31 369 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
b1f6a7c6 370 IN VOID *Data\r
ed66e1bc 371 );\r
192f6d4c 372\r
373//\r
374// Dispatcher support functions\r
375//\r
376\r
b1f6a7c6 377/**\r
192f6d4c 378\r
379 This is the POSTFIX version of the dependency evaluator. When a\r
380 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on\r
381 the evaluation stack. When that entry is poped from the evaluation\r
382 stack, the PPI is checked if it is installed. This method allows\r
383 some time savings as not all PPIs must be checked for certain\r
384 operation types (AND, OR).\r
385\r
192f6d4c 386\r
1cc76977 387 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
b1f6a7c6 388 @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to\r
389 the BNF described above and is stored in postfix notation.\r
192f6d4c 390\r
b1f6a7c6 391 @retval TRUE if it is a well-formed Grammar\r
392 @retval FALSE if the dependency expression overflows the evaluation stack\r
393 if the dependency expression underflows the evaluation stack\r
394 if the dependency expression is not a well-formed Grammar.\r
192f6d4c 395\r
b1f6a7c6 396**/\r
397BOOLEAN\r
398PeimDispatchReadiness (\r
399 IN EFI_PEI_SERVICES **PeiServices,\r
400 IN VOID *DependencyExpression\r
ed66e1bc 401 );\r
192f6d4c 402\r
b1f6a7c6 403/**\r
404 Conduct PEIM dispatch.\r
405\r
731bd38e 406 @param SecCoreData Pointer to the data structure containing SEC to PEI handoff data\r
1cc76977 407 @param PrivateData Pointer to the private data passed in from caller\r
192f6d4c 408\r
b1f6a7c6 409**/\r
b0d803fe 410VOID\r
192f6d4c 411PeiDispatcher (\r
5aae0aa7 412 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
b0d803fe 413 IN PEI_CORE_INSTANCE *PrivateData\r
ed66e1bc 414 );\r
192f6d4c 415\r
b1f6a7c6 416/**\r
417 Initialize the Dispatcher's data members\r
192f6d4c 418\r
b1f6a7c6 419 @param PrivateData PeiCore's private data structure\r
420 @param OldCoreData Old data from SecCore\r
421 NULL if being run in non-permament memory mode.\r
aa79b0b3 422 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
423 and location of temporary RAM, the stack location and the BFV location.\r
192f6d4c 424\r
b1f6a7c6 425**/\r
192f6d4c 426VOID\r
427InitializeDispatcherData (\r
b0d803fe 428 IN PEI_CORE_INSTANCE *PrivateData,\r
192f6d4c 429 IN PEI_CORE_INSTANCE *OldCoreData,\r
5aae0aa7 430 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
ed66e1bc 431 );\r
192f6d4c 432\r
b1f6a7c6 433/**\r
434 This routine parses the Dependency Expression, if available, and\r
435 decides if the module can be executed.\r
192f6d4c 436\r
192f6d4c 437\r
b1f6a7c6 438 @param Private PeiCore's private data structure\r
439 @param FileHandle PEIM's file handle\r
731bd38e 440 @param PeimCount The index of last dispatched PEIM.\r
192f6d4c 441\r
731bd38e 442 @retval TRUE Can be dispatched\r
443 @retval FALSE Cannot be dispatched\r
192f6d4c 444\r
b1f6a7c6 445**/\r
192f6d4c 446BOOLEAN\r
447DepexSatisfied (\r
b0d803fe 448 IN PEI_CORE_INSTANCE *Private,\r
449 IN EFI_PEI_FILE_HANDLE FileHandle,\r
450 IN UINTN PeimCount\r
ed66e1bc 451 );\r
192f6d4c 452\r
192f6d4c 453//\r
454// PPI support functions\r
455//\r
b1f6a7c6 456/**\r
457\r
458 Initialize PPI services.\r
459\r
b1f6a7c6 460 @param PrivateData Pointer to the PEI Core data.\r
d1102dba 461 @param OldCoreData Pointer to old PEI Core data.\r
b1f6a7c6 462 NULL if being run in non-permament memory mode.\r
463\r
464**/\r
192f6d4c 465VOID\r
466InitializePpiServices (\r
b0d803fe 467 IN PEI_CORE_INSTANCE *PrivateData,\r
192f6d4c 468 IN PEI_CORE_INSTANCE *OldCoreData\r
ed66e1bc 469 );\r
192f6d4c 470\r
b1f6a7c6 471/**\r
192f6d4c 472\r
b2374cec 473 Migrate the Hob list from the temporary memory to PEI installed memory.\r
731bd38e 474\r
d1102dba 475 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
424b7c9f 476 and location of temporary RAM, the stack location and the BFV location.\r
477 @param PrivateData Pointer to PeiCore's private data structure.\r
192f6d4c 478\r
b1f6a7c6 479**/\r
192f6d4c 480VOID\r
481ConvertPpiPointers (\r
424b7c9f 482 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
483 IN PEI_CORE_INSTANCE *PrivateData\r
ed66e1bc 484 );\r
192f6d4c 485\r
b1f6a7c6 486/**\r
192f6d4c 487\r
731bd38e 488 Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.\r
192f6d4c 489\r
15273993 490 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
491 @param PpiList Pointer to ppi array that want to be installed.\r
192f6d4c 492\r
15273993 493 @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.\r
494 @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer\r
731bd38e 495 if any PPI in PpiList is not valid\r
15273993 496 @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI\r
192f6d4c 497\r
b1f6a7c6 498**/\r
192f6d4c 499EFI_STATUS\r
500EFIAPI\r
501PeiInstallPpi (\r
0c2b5da8 502 IN CONST EFI_PEI_SERVICES **PeiServices,\r
503 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
ed66e1bc 504 );\r
192f6d4c 505\r
b1f6a7c6 506/**\r
192f6d4c 507\r
b1f6a7c6 508 Re-Install PPI services.\r
192f6d4c 509\r
1cc76977 510 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
511 @param OldPpi Pointer to the old PEI PPI Descriptors.\r
512 @param NewPpi Pointer to the new PEI PPI Descriptors.\r
192f6d4c 513\r
1cc76977 514 @retval EFI_SUCCESS if the operation was successful\r
515 @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL\r
731bd38e 516 if NewPpi is not valid\r
1cc76977 517 @retval EFI_NOT_FOUND if the PPI was not in the database\r
192f6d4c 518\r
b1f6a7c6 519**/\r
192f6d4c 520EFI_STATUS\r
521EFIAPI\r
522PeiReInstallPpi (\r
0c2b5da8 523 IN CONST EFI_PEI_SERVICES **PeiServices,\r
524 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
525 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
ed66e1bc 526 );\r
192f6d4c 527\r
b1f6a7c6 528/**\r
192f6d4c 529\r
b1f6a7c6 530 Locate a given named PPI.\r
192f6d4c 531\r
192f6d4c 532\r
1cc76977 533 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
534 @param Guid Pointer to GUID of the PPI.\r
535 @param Instance Instance Number to discover.\r
536 @param PpiDescriptor Pointer to reference the found descriptor. If not NULL,\r
b1f6a7c6 537 returns a pointer to the descriptor (includes flags, etc)\r
1cc76977 538 @param Ppi Pointer to reference the found PPI\r
192f6d4c 539\r
b1f6a7c6 540 @retval EFI_SUCCESS if the PPI is in the database\r
541 @retval EFI_NOT_FOUND if the PPI is not in the database\r
192f6d4c 542\r
b1f6a7c6 543**/\r
192f6d4c 544EFI_STATUS\r
545EFIAPI\r
546PeiLocatePpi (\r
1cc76977 547 IN CONST EFI_PEI_SERVICES **PeiServices,\r
548 IN CONST EFI_GUID *Guid,\r
192f6d4c 549 IN UINTN Instance,\r
550 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
551 IN OUT VOID **Ppi\r
ed66e1bc 552 );\r
192f6d4c 553\r
b1f6a7c6 554/**\r
192f6d4c 555\r
b1f6a7c6 556 Install a notification for a given PPI.\r
192f6d4c 557\r
192f6d4c 558\r
1cc76977 559 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
560 @param NotifyList Pointer to list of Descriptors to notify upon.\r
192f6d4c 561\r
b1f6a7c6 562 @retval EFI_SUCCESS if successful\r
563 @retval EFI_OUT_OF_RESOURCES if no space in the database\r
564 @retval EFI_INVALID_PARAMETER if not a good decriptor\r
192f6d4c 565\r
b1f6a7c6 566**/\r
192f6d4c 567EFI_STATUS\r
568EFIAPI\r
569PeiNotifyPpi (\r
0c2b5da8 570 IN CONST EFI_PEI_SERVICES **PeiServices,\r
571 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
ed66e1bc 572 );\r
192f6d4c 573\r
b1f6a7c6 574/**\r
192f6d4c 575\r
b1f6a7c6 576 Process the Notify List at dispatch level.\r
192f6d4c 577\r
b1f6a7c6 578 @param PrivateData PeiCore's private data structure.\r
192f6d4c 579\r
b1f6a7c6 580**/\r
192f6d4c 581VOID\r
f2bc359c 582ProcessDispatchNotifyList (\r
b0d803fe 583 IN PEI_CORE_INSTANCE *PrivateData\r
ed66e1bc 584 );\r
192f6d4c 585\r
b1f6a7c6 586/**\r
192f6d4c 587\r
f2bc359c 588 Process notifications.\r
192f6d4c 589\r
b1f6a7c6 590 @param PrivateData PeiCore's private data structure\r
591 @param NotifyType Type of notify to fire.\r
592 @param InstallStartIndex Install Beginning index.\r
593 @param InstallStopIndex Install Ending index.\r
594 @param NotifyStartIndex Notify Beginning index.\r
595 @param NotifyStopIndex Notify Ending index.\r
192f6d4c 596\r
b1f6a7c6 597**/\r
192f6d4c 598VOID\r
f2bc359c 599ProcessNotify (\r
b0d803fe 600 IN PEI_CORE_INSTANCE *PrivateData,\r
192f6d4c 601 IN UINTN NotifyType,\r
602 IN INTN InstallStartIndex,\r
603 IN INTN InstallStopIndex,\r
604 IN INTN NotifyStartIndex,\r
605 IN INTN NotifyStopIndex\r
ed66e1bc 606 );\r
192f6d4c 607\r
884200f9
SZ
608/**\r
609 Process PpiList from SEC phase.\r
610\r
611 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
612 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
613 These PPI's will be installed and/or immediately signaled if they are notification type.\r
614\r
615**/\r
616VOID\r
617ProcessPpiListFromSec (\r
618 IN CONST EFI_PEI_SERVICES **PeiServices,\r
619 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
620 );\r
621\r
192f6d4c 622//\r
623// Boot mode support functions\r
624//\r
b1f6a7c6 625/**\r
626 This service enables PEIMs to ascertain the present value of the boot mode.\r
627\r
1cc76977 628 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
b1f6a7c6 629 @param BootMode A pointer to contain the value of the boot mode.\r
630\r
631 @retval EFI_SUCCESS The boot mode was returned successfully.\r
632 @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
633\r
634**/\r
192f6d4c 635EFI_STATUS\r
636EFIAPI\r
637PeiGetBootMode (\r
0c2b5da8 638 IN CONST EFI_PEI_SERVICES **PeiServices,\r
d976bf31 639 IN OUT EFI_BOOT_MODE *BootMode\r
ed66e1bc 640 );\r
192f6d4c 641\r
b1f6a7c6 642/**\r
643 This service enables PEIMs to update the boot mode variable.\r
192f6d4c 644\r
192f6d4c 645\r
1cc76977 646 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
647 @param BootMode The value of the boot mode to set.\r
192f6d4c 648\r
1cc76977 649 @return EFI_SUCCESS The value was successfully updated\r
192f6d4c 650\r
b1f6a7c6 651**/\r
192f6d4c 652EFI_STATUS\r
653EFIAPI\r
654PeiSetBootMode (\r
0c2b5da8 655 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 656 IN EFI_BOOT_MODE BootMode\r
ed66e1bc 657 );\r
192f6d4c 658\r
659//\r
660// Security support functions\r
661//\r
b1f6a7c6 662/**\r
663\r
664 Initialize the security services.\r
665\r
1cc76977 666 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
40f26b8f 667 @param OldCoreData Pointer to the old core data.\r
b1f6a7c6 668 NULL if being run in non-permament memory mode.\r
669\r
670**/\r
192f6d4c 671VOID\r
672InitializeSecurityServices (\r
673 IN EFI_PEI_SERVICES **PeiServices,\r
674 IN PEI_CORE_INSTANCE *OldCoreData\r
ed66e1bc 675 );\r
192f6d4c 676\r
b1f6a7c6 677/**\r
d976bf31 678 Verify a Firmware volume.\r
192f6d4c 679\r
40f26b8f 680 @param CurrentFvAddress Pointer to the current Firmware Volume under consideration\r
192f6d4c 681\r
40f26b8f 682 @retval EFI_SUCCESS Firmware Volume is legal\r
683 @retval EFI_SECURITY_VIOLATION Firmware Volume fails integrity test\r
192f6d4c 684\r
b1f6a7c6 685**/\r
192f6d4c 686EFI_STATUS\r
687VerifyFv (\r
688 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
ed66e1bc 689 );\r
192f6d4c 690\r
b1f6a7c6 691/**\r
b1f6a7c6 692 Provide a callout to the security verification service.\r
192f6d4c 693\r
b1f6a7c6 694 @param PrivateData PeiCore's private data structure\r
695 @param VolumeHandle Handle of FV\r
696 @param FileHandle Handle of PEIM's ffs\r
c7935105 697 @param AuthenticationStatus Authentication status\r
192f6d4c 698\r
b1f6a7c6 699 @retval EFI_SUCCESS Image is OK\r
700 @retval EFI_SECURITY_VIOLATION Image is illegal\r
c7935105 701 @retval EFI_NOT_FOUND If security PPI is not installed.\r
b1f6a7c6 702**/\r
192f6d4c 703EFI_STATUS\r
704VerifyPeim (\r
b0d803fe 705 IN PEI_CORE_INSTANCE *PrivateData,\r
706 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
c7935105
SZ
707 IN EFI_PEI_FILE_HANDLE FileHandle,\r
708 IN UINT32 AuthenticationStatus\r
ed66e1bc 709 );\r
192f6d4c 710\r
b1f6a7c6 711/**\r
192f6d4c 712\r
b1f6a7c6 713 Gets the pointer to the HOB List.\r
192f6d4c 714\r
192f6d4c 715\r
1cc76977 716 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
b1f6a7c6 717 @param HobList Pointer to the HOB List.\r
192f6d4c 718\r
b1f6a7c6 719 @retval EFI_SUCCESS Get the pointer of HOB List\r
720 @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published\r
721 @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode)\r
192f6d4c 722\r
b1f6a7c6 723**/\r
192f6d4c 724EFI_STATUS\r
725EFIAPI\r
726PeiGetHobList (\r
0c2b5da8 727 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 728 IN OUT VOID **HobList\r
ed66e1bc 729 );\r
192f6d4c 730\r
b1f6a7c6 731/**\r
732 Add a new HOB to the HOB List.\r
192f6d4c 733\r
1cc76977 734 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
735 @param Type Type of the new HOB.\r
736 @param Length Length of the new HOB to allocate.\r
737 @param Hob Pointer to the new HOB.\r
192f6d4c 738\r
b1f6a7c6 739 @return EFI_SUCCESS Success to create hob.\r
740 @retval EFI_INVALID_PARAMETER if Hob is NULL\r
741 @retval EFI_NOT_AVAILABLE_YET if HobList is still not available.\r
742 @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.\r
192f6d4c 743\r
b1f6a7c6 744**/\r
192f6d4c 745EFI_STATUS\r
746EFIAPI\r
747PeiCreateHob (\r
0c2b5da8 748 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 749 IN UINT16 Type,\r
750 IN UINT16 Length,\r
751 IN OUT VOID **Hob\r
ed66e1bc 752 );\r
192f6d4c 753\r
b1f6a7c6 754/**\r
192f6d4c 755\r
b1f6a7c6 756 Builds a Handoff Information Table HOB\r
192f6d4c 757\r
b1f6a7c6 758 @param BootMode - Current Bootmode\r
759 @param MemoryBegin - Start Memory Address.\r
760 @param MemoryLength - Length of Memory.\r
192f6d4c 761\r
b1f6a7c6 762 @return EFI_SUCCESS Always success to initialize HOB.\r
192f6d4c 763\r
b1f6a7c6 764**/\r
192f6d4c 765EFI_STATUS\r
766PeiCoreBuildHobHandoffInfoTable (\r
767 IN EFI_BOOT_MODE BootMode,\r
768 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
769 IN UINT64 MemoryLength\r
ed66e1bc 770 );\r
192f6d4c 771\r
483e2cdd
SZ
772/**\r
773 Install SEC HOB data to the HOB List.\r
774\r
775 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
776 @param SecHobList Pointer to SEC HOB List.\r
777\r
778 @return EFI_SUCCESS Success to install SEC HOB data.\r
779 @retval EFI_OUT_OF_RESOURCES If there is no more memory to grow the Hoblist.\r
780\r
781**/\r
782EFI_STATUS\r
783PeiInstallSecHobData (\r
784 IN CONST EFI_PEI_SERVICES **PeiServices,\r
785 IN EFI_HOB_GENERIC_HEADER *SecHobList\r
786 );\r
787\r
192f6d4c 788\r
789//\r
790// FFS Fw Volume support functions\r
791//\r
b1f6a7c6 792/**\r
3b428ade 793 Searches for the next matching file in the firmware volume.\r
b1f6a7c6 794\r
1cc76977 795 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
b1f6a7c6 796 @param SearchType Filter to find only files of this type.\r
797 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
aa75dfec 798 @param FvHandle Handle of firmware volume in which to search.\r
3b428ade 799 @param FileHandle On entry, points to the current handle from which to begin searching or NULL to start\r
800 at the beginning of the firmware volume. On exit, points the file handle of the next file\r
801 in the volume or NULL if there are no more files.\r
802\r
803 @retval EFI_NOT_FOUND The file was not found.\r
804 @retval EFI_NOT_FOUND The header checksum was not zero.\r
805 @retval EFI_SUCCESS The file was found.\r
b1f6a7c6 806\r
807**/\r
192f6d4c 808EFI_STATUS\r
809EFIAPI\r
810PeiFfsFindNextFile (\r
0c2b5da8 811 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 812 IN UINT8 SearchType,\r
3b428ade 813 IN EFI_PEI_FV_HANDLE FvHandle,\r
814 IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r
ed66e1bc 815 );\r
192f6d4c 816\r
b1f6a7c6 817/**\r
3b428ade 818 Searches for the next matching section within the specified file.\r
192f6d4c 819\r
3b428ade 820 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
b1f6a7c6 821 @param SectionType Filter to find only sections of this type.\r
3b428ade 822 @param FileHandle Pointer to the current file to search.\r
823 @param SectionData A pointer to the discovered section, if successful.\r
b1f6a7c6 824 NULL if section not found\r
192f6d4c 825\r
3b428ade 826 @retval EFI_NOT_FOUND The section was not found.\r
827 @retval EFI_SUCCESS The section was found.\r
192f6d4c 828\r
b1f6a7c6 829**/\r
192f6d4c 830EFI_STATUS\r
831EFIAPI\r
832PeiFfsFindSectionData (\r
3b428ade 833 IN CONST EFI_PEI_SERVICES **PeiServices,\r
834 IN EFI_SECTION_TYPE SectionType,\r
835 IN EFI_PEI_FILE_HANDLE FileHandle,\r
836 OUT VOID **SectionData\r
ed66e1bc 837 );\r
192f6d4c 838\r
c7935105
SZ
839/**\r
840 Searches for the next matching section within the specified file.\r
841\r
842 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
843 @param SectionType The value of the section type to find.\r
844 @param SectionInstance Section instance to find.\r
845 @param FileHandle Handle of the firmware file to search.\r
846 @param SectionData A pointer to the discovered section, if successful.\r
847 @param AuthenticationStatus A pointer to the authentication status for this section.\r
848\r
849 @retval EFI_SUCCESS The section was found.\r
850 @retval EFI_NOT_FOUND The section was not found.\r
851\r
852**/\r
853EFI_STATUS\r
854EFIAPI\r
855PeiFfsFindSectionData3 (\r
856 IN CONST EFI_PEI_SERVICES **PeiServices,\r
857 IN EFI_SECTION_TYPE SectionType,\r
858 IN UINTN SectionInstance,\r
859 IN EFI_PEI_FILE_HANDLE FileHandle,\r
860 OUT VOID **SectionData,\r
861 OUT UINT32 *AuthenticationStatus\r
862 );\r
863\r
b1f6a7c6 864/**\r
3b428ade 865 Search the firmware volumes by index\r
192f6d4c 866\r
3b428ade 867 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
868 @param Instance This instance of the firmware volume to find. The value 0 is the Boot Firmware\r
869 Volume (BFV).\r
870 @param VolumeHandle On exit, points to the next volume handle or NULL if it does not exist.\r
192f6d4c 871\r
3b428ade 872 @retval EFI_INVALID_PARAMETER VolumeHandle is NULL\r
873 @retval EFI_NOT_FOUND The volume was not found.\r
874 @retval EFI_SUCCESS The volume was found.\r
192f6d4c 875\r
b1f6a7c6 876**/\r
192f6d4c 877EFI_STATUS\r
878EFIAPI\r
3b428ade 879PeiFfsFindNextVolume (\r
15273993 880 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 881 IN UINTN Instance,\r
aa75dfec 882 IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r
ed66e1bc 883 );\r
192f6d4c 884\r
885//\r
886// Memory support functions\r
887//\r
b1f6a7c6 888/**\r
889\r
890 Initialize the memory services.\r
891\r
1cc76977 892 @param PrivateData PeiCore's private data structure\r
d1102dba 893 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
f34aec3b 894 and location of temporary RAM, the stack location and the BFV location.\r
b1f6a7c6 895 @param OldCoreData Pointer to the PEI Core data.\r
896 NULL if being run in non-permament memory mode.\r
897\r
898**/\r
192f6d4c 899VOID\r
900InitializeMemoryServices (\r
b0d803fe 901 IN PEI_CORE_INSTANCE *PrivateData,\r
5aae0aa7 902 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
192f6d4c 903 IN PEI_CORE_INSTANCE *OldCoreData\r
ed66e1bc 904 );\r
192f6d4c 905\r
b1f6a7c6 906/**\r
192f6d4c 907\r
b1f6a7c6 908 Install the permanent memory is now available.\r
909 Creates HOB (PHIT and Stack).\r
192f6d4c 910\r
1cc76977 911 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
912 @param MemoryBegin Start of memory address.\r
913 @param MemoryLength Length of memory.\r
192f6d4c 914\r
b1f6a7c6 915 @return EFI_SUCCESS Always success.\r
192f6d4c 916\r
b1f6a7c6 917**/\r
192f6d4c 918EFI_STATUS\r
919EFIAPI\r
920PeiInstallPeiMemory (\r
0c2b5da8 921 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 922 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
923 IN UINT64 MemoryLength\r
ed66e1bc 924 );\r
192f6d4c 925\r
b1f6a7c6 926/**\r
b2374cec
SZ
927 Migrate memory pages allocated in pre-memory phase.\r
928 Copy memory pages at temporary heap top to permanent heap top.\r
192f6d4c 929\r
b2374cec
SZ
930 @param[in] Private Pointer to the private data passed in from caller.\r
931 @param[in] TemporaryRamMigrated Temporary memory has been migrated to permanent memory.\r
192f6d4c 932\r
b2374cec
SZ
933**/\r
934VOID\r
935MigrateMemoryPages (\r
936 IN PEI_CORE_INSTANCE *Private,\r
937 IN BOOLEAN TemporaryRamMigrated\r
938 );\r
192f6d4c 939\r
b2374cec
SZ
940/**\r
941 Migrate MemoryBaseAddress in memory allocation HOBs\r
942 from the temporary memory to PEI installed memory.\r
192f6d4c 943\r
b2374cec
SZ
944 @param[in] PrivateData Pointer to PeiCore's private data structure.\r
945\r
946**/\r
947VOID\r
948ConvertMemoryAllocationHobs (\r
949 IN PEI_CORE_INSTANCE *PrivateData\r
950 );\r
951\r
952/**\r
953 The purpose of the service is to publish an interface that allows\r
954 PEIMs to allocate memory ranges that are managed by the PEI Foundation.\r
955\r
956 Prior to InstallPeiMemory() being called, PEI will allocate pages from the heap.\r
957 After InstallPeiMemory() is called, PEI will allocate pages within the region\r
958 of memory provided by InstallPeiMemory() service in a best-effort fashion.\r
959 Location-specific allocations are not managed by the PEI foundation code.\r
960\r
961 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
962 @param MemoryType The type of memory to allocate.\r
963 @param Pages The number of contiguous 4 KB pages to allocate.\r
964 @param Memory Pointer to a physical address. On output, the address is set to the base\r
965 of the page range that was allocated.\r
966\r
967 @retval EFI_SUCCESS The memory range was successfully allocated.\r
968 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.\r
969 @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,\r
970 EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,\r
971 EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.\r
192f6d4c 972\r
b1f6a7c6 973**/\r
192f6d4c 974EFI_STATUS\r
975EFIAPI\r
976PeiAllocatePages (\r
b2374cec
SZ
977 IN CONST EFI_PEI_SERVICES **PeiServices,\r
978 IN EFI_MEMORY_TYPE MemoryType,\r
979 IN UINTN Pages,\r
980 OUT EFI_PHYSICAL_ADDRESS *Memory\r
981 );\r
982\r
983/**\r
984 Frees memory pages.\r
985\r
986 @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
987 @param[in] Memory The base physical address of the pages to be freed.\r
988 @param[in] Pages The number of contiguous 4 KB pages to free.\r
989\r
990 @retval EFI_SUCCESS The requested pages were freed.\r
991 @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.\r
992 @retval EFI_NOT_FOUND The requested memory pages were not allocated with\r
993 AllocatePages().\r
994\r
995**/\r
996EFI_STATUS\r
997EFIAPI\r
998PeiFreePages (\r
999 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1000 IN EFI_PHYSICAL_ADDRESS Memory,\r
1001 IN UINTN Pages\r
ed66e1bc 1002 );\r
192f6d4c 1003\r
b1f6a7c6 1004/**\r
192f6d4c 1005\r
3d4d0c34 1006 Memory allocation service on the temporary memory.\r
192f6d4c 1007\r
192f6d4c 1008\r
1cc76977 1009 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1010 @param Size Amount of memory required\r
1011 @param Buffer Address of pointer to the buffer\r
192f6d4c 1012\r
b1f6a7c6 1013 @retval EFI_SUCCESS The allocation was successful\r
1014 @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement\r
1015 to allocate the requested size.\r
192f6d4c 1016\r
b1f6a7c6 1017**/\r
192f6d4c 1018EFI_STATUS\r
1019EFIAPI\r
1020PeiAllocatePool (\r
0c2b5da8 1021 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 1022 IN UINTN Size,\r
1023 OUT VOID **Buffer\r
ed66e1bc 1024 );\r
192f6d4c 1025\r
b1f6a7c6 1026/**\r
192f6d4c 1027\r
b1f6a7c6 1028 Routine for load image file.\r
192f6d4c 1029\r
192f6d4c 1030\r
1cc76977 1031 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1032 @param FileHandle Pointer to the FFS file header of the image.\r
341a658f 1033 @param PeimState The dispatch state of the input PEIM handle.\r
1cc76977 1034 @param EntryPoint Pointer to entry point of specified image file for output.\r
1035 @param AuthenticationState Pointer to attestation authentication state of image.\r
192f6d4c 1036\r
1cc76977 1037 @retval EFI_SUCCESS Image is successfully loaded.\r
1038 @retval EFI_NOT_FOUND Fail to locate necessary PPI\r
1039 @retval Others Fail to load file.\r
192f6d4c 1040\r
b1f6a7c6 1041**/\r
192f6d4c 1042EFI_STATUS\r
1043PeiLoadImage (\r
6c7a807a 1044 IN CONST EFI_PEI_SERVICES **PeiServices,\r
b0d803fe 1045 IN EFI_PEI_FILE_HANDLE FileHandle,\r
341a658f 1046 IN UINT8 PeimState,\r
b0d803fe 1047 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
1048 OUT UINT32 *AuthenticationState\r
ed66e1bc 1049 );\r
192f6d4c 1050\r
b1f6a7c6 1051/**\r
192f6d4c 1052\r
b1f6a7c6 1053 Core version of the Status Code reporter\r
192f6d4c 1054\r
192f6d4c 1055\r
1cc76977 1056 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1057 @param CodeType Type of Status Code.\r
1058 @param Value Value to output for Status Code.\r
1059 @param Instance Instance Number of this status code.\r
1060 @param CallerId ID of the caller of this status code.\r
1061 @param Data Optional data associated with this status code.\r
192f6d4c 1062\r
b1f6a7c6 1063 @retval EFI_SUCCESS if status code is successfully reported\r
1064 @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed\r
192f6d4c 1065\r
b1f6a7c6 1066**/\r
192f6d4c 1067EFI_STATUS\r
1068EFIAPI\r
1069PeiReportStatusCode (\r
0c2b5da8 1070 IN CONST EFI_PEI_SERVICES **PeiServices,\r
192f6d4c 1071 IN EFI_STATUS_CODE_TYPE CodeType,\r
1072 IN EFI_STATUS_CODE_VALUE Value,\r
1073 IN UINT32 Instance,\r
0c2b5da8 1074 IN CONST EFI_GUID *CallerId,\r
1075 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
ed66e1bc 1076 );\r
192f6d4c 1077\r
b1f6a7c6 1078/**\r
192f6d4c 1079\r
b1f6a7c6 1080 Core version of the Reset System\r
192f6d4c 1081\r
192f6d4c 1082\r
1cc76977 1083 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
192f6d4c 1084\r
b1f6a7c6 1085 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.\r
1086 @retval EFI_DEVICE_ERROR Did not reset system.\r
1087 Otherwise, resets the system.\r
192f6d4c 1088\r
b1f6a7c6 1089**/\r
192f6d4c 1090EFI_STATUS\r
1091EFIAPI\r
1092PeiResetSystem (\r
b0d803fe 1093 IN CONST EFI_PEI_SERVICES **PeiServices\r
ed66e1bc 1094 );\r
192f6d4c 1095\r
672473ea
SZ
1096/**\r
1097 Resets the entire platform.\r
1098\r
1099 @param[in] ResetType The type of reset to perform.\r
1100 @param[in] ResetStatus The status code for the reset.\r
c8721bb2 1101 @param[in] DataSize The size, in bytes, of ResetData.\r
672473ea
SZ
1102 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r
1103 the data buffer starts with a Null-terminated string, optionally\r
1104 followed by additional binary data. The string is a description\r
1105 that the caller may use to further indicate the reason for the\r
1106 system reset. ResetData is only valid if ResetStatus is something\r
1107 other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific\r
1108 where a minimum amount of ResetData is always required.\r
1109\r
1110**/\r
1111VOID\r
1112EFIAPI\r
1113PeiResetSystem2 (\r
1114 IN EFI_RESET_TYPE ResetType,\r
1115 IN EFI_STATUS ResetStatus,\r
1116 IN UINTN DataSize,\r
1117 IN VOID *ResetData OPTIONAL\r
1118 );\r
1119\r
b1f6a7c6 1120/**\r
192f6d4c 1121\r
b1f6a7c6 1122 Initialize PeiCore Fv List.\r
192f6d4c 1123\r
192f6d4c 1124\r
b1f6a7c6 1125 @param PrivateData - Pointer to PEI_CORE_INSTANCE.\r
1126 @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.\r
192f6d4c 1127\r
b1f6a7c6 1128**/\r
50cb16d9 1129VOID\r
b0d803fe 1130PeiInitializeFv (\r
1131 IN PEI_CORE_INSTANCE *PrivateData,\r
1132 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
ed66e1bc 1133 );\r
b0d803fe 1134\r
b1f6a7c6 1135/**\r
1136 Process Firmware Volum Information once FvInfoPPI install.\r
b0d803fe 1137\r
1cc76977 1138 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1139 @param NotifyDescriptor Address of the notification descriptor data structure.\r
1140 @param Ppi Address of the PPI that was installed.\r
50cb16d9 1141\r
b1f6a7c6 1142 @retval EFI_SUCCESS if the interface could be successfully installed\r
b0d803fe 1143\r
b1f6a7c6 1144**/\r
b0d803fe 1145EFI_STATUS\r
1146EFIAPI\r
1147FirmwareVolmeInfoPpiNotifyCallback (\r
1148 IN EFI_PEI_SERVICES **PeiServices,\r
1149 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
1150 IN VOID *Ppi\r
ed66e1bc 1151 );\r
b0d803fe 1152\r
b1f6a7c6 1153/**\r
50cb16d9 1154\r
b1f6a7c6 1155 Given the input VolumeHandle, search for the next matching name file.\r
b0d803fe 1156\r
1cc76977 1157 @param FileName File name to search.\r
1158 @param VolumeHandle The current FV to search.\r
1159 @param FileHandle Pointer to the file matching name in VolumeHandle.\r
1160 NULL if file not found\r
b0d803fe 1161\r
15273993 1162 @retval EFI_NOT_FOUND No files matching the search criteria were found\r
1163 @retval EFI_SUCCESS Success to search given file\r
b0d803fe 1164\r
b1f6a7c6 1165**/\r
b0d803fe 1166EFI_STATUS\r
50cb16d9 1167EFIAPI\r
b0d803fe 1168PeiFfsFindFileByName (\r
1169 IN CONST EFI_GUID *FileName,\r
1170 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
1171 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
ed66e1bc 1172 );\r
b0d803fe 1173\r
b1f6a7c6 1174/**\r
b1f6a7c6 1175 Returns information about a specific file.\r
b0d803fe 1176\r
3b428ade 1177 @param FileHandle Handle of the file.\r
aa75dfec 1178 @param FileInfo Upon exit, points to the file's information.\r
b0d803fe 1179\r
3b428ade 1180 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
1181 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
1182 @retval EFI_SUCCESS File information returned.\r
b0d803fe 1183\r
b1f6a7c6 1184**/\r
b0d803fe 1185EFI_STATUS\r
50cb16d9 1186EFIAPI\r
b0d803fe 1187PeiFfsGetFileInfo (\r
1188 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1189 OUT EFI_FV_FILE_INFO *FileInfo\r
ed66e1bc 1190 );\r
b0d803fe 1191\r
c7935105
SZ
1192/**\r
1193 Returns information about a specific file.\r
1194\r
1195 @param FileHandle Handle of the file.\r
1196 @param FileInfo Upon exit, points to the file's information.\r
1197\r
1198 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
1199 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
1200 @retval EFI_SUCCESS File information returned.\r
1201\r
1202**/\r
1203EFI_STATUS\r
d1102dba 1204EFIAPI\r
c7935105
SZ
1205PeiFfsGetFileInfo2 (\r
1206 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1207 OUT EFI_FV_FILE_INFO2 *FileInfo\r
1208 );\r
1209\r
b1f6a7c6 1210/**\r
3b428ade 1211 Returns information about the specified volume.\r
b0d803fe 1212\r
3b428ade 1213 @param VolumeHandle Handle of the volume.\r
aa75dfec 1214 @param VolumeInfo Upon exit, points to the volume's information.\r
b0d803fe 1215\r
3b428ade 1216 @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.\r
1217 @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.\r
1218 @retval EFI_SUCCESS Volume information returned.\r
b1f6a7c6 1219**/\r
b0d803fe 1220EFI_STATUS\r
50cb16d9 1221EFIAPI\r
b0d803fe 1222PeiFfsGetVolumeInfo (\r
1223 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
1224 OUT EFI_FV_INFO *VolumeInfo\r
ed66e1bc 1225 );\r
b0d803fe 1226\r
14e8823a 1227/**\r
1228 This routine enable a PEIM to register itself to shadow when PEI Foundation\r
1229 discovery permanent memory.\r
1230\r
b1f6a7c6 1231 @param FileHandle File handle of a PEIM.\r
50cb16d9 1232\r
b1f6a7c6 1233 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.\r
1234 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.\r
1235 @retval EFI_SUCCESS Successfully to register itself.\r
14e8823a 1236\r
50cb16d9 1237**/\r
14e8823a 1238EFI_STATUS\r
1239EFIAPI\r
1240PeiRegisterForShadow (\r
1241 IN EFI_PEI_FILE_HANDLE FileHandle\r
ed66e1bc 1242 );\r
14e8823a 1243\r
b1f6a7c6 1244/**\r
15273993 1245 Initialize image service that install PeiLoadFilePpi.\r
b0d803fe 1246\r
15273993 1247 @param PrivateData Pointer to PeiCore's private data structure PEI_CORE_INSTANCE.\r
1248 @param OldCoreData Pointer to Old PeiCore's private data.\r
1249 If NULL, PeiCore is entered at first time, stack/heap in temporary memory.\r
1250 If not NULL, PeiCore is entered at second time, stack/heap has been moved\r
6393d9c8 1251 to permanent memory.\r
b0d803fe 1252\r
b1f6a7c6 1253**/\r
1254VOID\r
1255InitializeImageServices (\r
1256 IN PEI_CORE_INSTANCE *PrivateData,\r
1257 IN PEI_CORE_INSTANCE *OldCoreData\r
ed66e1bc 1258 );\r
b0d803fe 1259\r
aa79b0b3 1260/**\r
1261 The wrapper function of PeiLoadImageLoadImage().\r
1262\r
f34aec3b 1263 @param This Pointer to EFI_PEI_LOAD_FILE_PPI.\r
1264 @param FileHandle Pointer to the FFS file header of the image.\r
1265 @param ImageAddressArg Pointer to PE/TE image.\r
1266 @param ImageSizeArg Size of PE/TE image.\r
1267 @param EntryPoint Pointer to entry point of specified image file for output.\r
1268 @param AuthenticationState Pointer to attestation authentication state of image.\r
aa79b0b3 1269\r
1270 @return Status of PeiLoadImageLoadImage().\r
1271\r
1272**/\r
1273EFI_STATUS\r
1274EFIAPI\r
1275PeiLoadImageLoadImageWrapper (\r
1276 IN CONST EFI_PEI_LOAD_FILE_PPI *This,\r
1277 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1278 OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL\r
1279 OUT UINT64 *ImageSizeArg, OPTIONAL\r
1280 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
1281 OUT UINT32 *AuthenticationState\r
1282 );\r
1283\r
1284/**\r
1285\r
1286 Provide a callback for when the security PPI is installed.\r
1287\r
1288 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1289 @param NotifyDescriptor The descriptor for the notification event.\r
1290 @param Ppi Pointer to the PPI in question.\r
1291\r
1292 @return Always success\r
1293\r
1294**/\r
1295EFI_STATUS\r
1296EFIAPI\r
1297SecurityPpiNotifyCallback (\r
1298 IN EFI_PEI_SERVICES **PeiServices,\r
1299 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
1300 IN VOID *Ppi\r
1301 );\r
1302\r
3b428ade 1303/**\r
0e042d0a 1304 Get Fv image(s) from the FV type file, then install FV INFO(2) ppi, Build FV(2, 3) hob.\r
3b428ade 1305\r
c7935105 1306 @param PrivateData PeiCore's private data structure\r
3b428ade 1307 @param ParentFvCoreHandle Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.\r
1308 @param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.\r
1309\r
1310 @retval EFI_NOT_FOUND FV image can't be found.\r
1311 @retval EFI_SUCCESS Successfully to process it.\r
1312 @retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image\r
c7935105 1313 @retval EFI_SECURITY_VIOLATION Image is illegal\r
3b428ade 1314 @retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
d1102dba 1315\r
3b428ade 1316**/\r
1317EFI_STATUS\r
1318ProcessFvFile (\r
c7935105 1319 IN PEI_CORE_INSTANCE *PrivateData,\r
3b428ade 1320 IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle,\r
1321 IN EFI_PEI_FILE_HANDLE ParentFvFileHandle\r
1322 );\r
d1102dba 1323\r
3b428ade 1324/**\r
1325 Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.\r
d1102dba 1326\r
3b428ade 1327 This routine also will install FvInfo ppi for FV hob in PI ways.\r
d1102dba 1328\r
3b428ade 1329 @param Private Pointer of PEI_CORE_INSTANCE\r
1330 @param Instance The index of FV want to be searched.\r
d1102dba 1331\r
3b428ade 1332 @return Instance of PEI_CORE_FV_HANDLE.\r
1333**/\r
1334PEI_CORE_FV_HANDLE *\r
1335FindNextCoreFvHandle (\r
1336 IN PEI_CORE_INSTANCE *Private,\r
1337 IN UINTN Instance\r
1338 );\r
d1102dba 1339\r
8d415937 1340//\r
1341// Default EFI_PEI_CPU_IO_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.\r
d1102dba 1342//\r
8d415937 1343\r
1344/**\r
1345 Memory-based read services.\r
d1102dba
LG
1346\r
1347 This function is to perform the Memory Access Read service based on installed\r
1348 instance of the EFI_PEI_CPU_IO_PPI.\r
1349 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
1350 return EFI_NOT_YET_AVAILABLE.\r
1351\r
8d415937 1352 @param PeiServices An indirect pointer to the PEI Services Table\r
1353 published by the PEI Foundation.\r
1354 @param This Pointer to local data for the interface.\r
1355 @param Width The width of the access. Enumerated in bytes.\r
1356 @param Address The physical address of the access.\r
1357 @param Count The number of accesses to perform.\r
1358 @param Buffer A pointer to the buffer of data.\r
1359\r
1360 @retval EFI_SUCCESS The function completed successfully.\r
d1102dba 1361 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
8d415937 1362**/\r
1363EFI_STATUS\r
1364EFIAPI\r
1365PeiDefaultMemRead (\r
1366 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1367 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1368 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1369 IN UINT64 Address,\r
1370 IN UINTN Count,\r
1371 IN OUT VOID *Buffer\r
1372 );\r
d1102dba 1373\r
8d415937 1374/**\r
1375 Memory-based write services.\r
d1102dba
LG
1376\r
1377 This function is to perform the Memory Access Write service based on installed\r
1378 instance of the EFI_PEI_CPU_IO_PPI.\r
1379 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
1380 return EFI_NOT_YET_AVAILABLE.\r
1381\r
8d415937 1382 @param PeiServices An indirect pointer to the PEI Services Table\r
1383 published by the PEI Foundation.\r
1384 @param This Pointer to local data for the interface.\r
1385 @param Width The width of the access. Enumerated in bytes.\r
1386 @param Address The physical address of the access.\r
1387 @param Count The number of accesses to perform.\r
1388 @param Buffer A pointer to the buffer of data.\r
1389\r
1390 @retval EFI_SUCCESS The function completed successfully.\r
d1102dba 1391 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
8d415937 1392**/\r
1393EFI_STATUS\r
1394EFIAPI\r
1395PeiDefaultMemWrite (\r
1396 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1397 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1398 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1399 IN UINT64 Address,\r
1400 IN UINTN Count,\r
1401 IN OUT VOID *Buffer\r
1402 );\r
d1102dba 1403\r
8d415937 1404/**\r
1405 IO-based read services.\r
d1102dba 1406\r
8d415937 1407 This function is to perform the IO-base read service for the EFI_PEI_CPU_IO_PPI.\r
d1102dba
LG
1408 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
1409 return EFI_NOT_YET_AVAILABLE.\r
1410\r
8d415937 1411 @param PeiServices An indirect pointer to the PEI Services Table\r
1412 published by the PEI Foundation.\r
1413 @param This Pointer to local data for the interface.\r
1414 @param Width The width of the access. Enumerated in bytes.\r
1415 @param Address The physical address of the access.\r
1416 @param Count The number of accesses to perform.\r
1417 @param Buffer A pointer to the buffer of data.\r
1418\r
1419 @retval EFI_SUCCESS The function completed successfully.\r
1420 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
1421**/\r
1422EFI_STATUS\r
1423EFIAPI\r
1424PeiDefaultIoRead (\r
1425 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1426 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1427 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1428 IN UINT64 Address,\r
1429 IN UINTN Count,\r
1430 IN OUT VOID *Buffer\r
1431 );\r
d1102dba 1432\r
8d415937 1433/**\r
1434 IO-based write services.\r
d1102dba 1435\r
8d415937 1436 This function is to perform the IO-base write service for the EFI_PEI_CPU_IO_PPI.\r
d1102dba
LG
1437 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
1438 return EFI_NOT_YET_AVAILABLE.\r
1439\r
8d415937 1440 @param PeiServices An indirect pointer to the PEI Services Table\r
1441 published by the PEI Foundation.\r
1442 @param This Pointer to local data for the interface.\r
1443 @param Width The width of the access. Enumerated in bytes.\r
1444 @param Address The physical address of the access.\r
1445 @param Count The number of accesses to perform.\r
1446 @param Buffer A pointer to the buffer of data.\r
1447\r
1448 @retval EFI_SUCCESS The function completed successfully.\r
1449 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
1450**/\r
1451EFI_STATUS\r
1452EFIAPI\r
1453PeiDefaultIoWrite (\r
1454 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1455 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1456 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1457 IN UINT64 Address,\r
1458 IN UINTN Count,\r
1459 IN OUT VOID *Buffer\r
1460 );\r
d1102dba 1461\r
8d415937 1462/**\r
1463 8-bit I/O read operations.\r
d1102dba
LG
1464\r
1465 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1466 return 0.\r
d1102dba 1467\r
8d415937 1468 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1469 @param This Pointer to local data for the interface.\r
1470 @param Address The physical address of the access.\r
1471\r
1472 @return An 8-bit value returned from the I/O space.\r
1473**/\r
1474UINT8\r
1475EFIAPI\r
1476PeiDefaultIoRead8 (\r
1477 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1478 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1479 IN UINT64 Address\r
1480 );\r
d1102dba 1481\r
8d415937 1482/**\r
1483 Reads an 16-bit I/O port.\r
d1102dba
LG
1484\r
1485 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1486 return 0.\r
d1102dba 1487\r
8d415937 1488 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1489 @param This Pointer to local data for the interface.\r
1490 @param Address The physical address of the access.\r
1491\r
1492 @return A 16-bit value returned from the I/O space.\r
1493**/\r
1494UINT16\r
1495EFIAPI\r
1496PeiDefaultIoRead16 (\r
1497 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1498 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1499 IN UINT64 Address\r
1500 );\r
d1102dba 1501\r
8d415937 1502/**\r
1503 Reads an 32-bit I/O port.\r
d1102dba
LG
1504\r
1505 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1506 return 0.\r
d1102dba 1507\r
8d415937 1508 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1509 @param This Pointer to local data for the interface.\r
1510 @param Address The physical address of the access.\r
1511\r
1512 @return A 32-bit value returned from the I/O space.\r
1513**/\r
1514UINT32\r
1515EFIAPI\r
1516PeiDefaultIoRead32 (\r
1517 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1518 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1519 IN UINT64 Address\r
1520 );\r
d1102dba 1521\r
8d415937 1522/**\r
1523 Reads an 64-bit I/O port.\r
d1102dba
LG
1524\r
1525 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1526 return 0.\r
d1102dba 1527\r
8d415937 1528 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1529 @param This Pointer to local data for the interface.\r
1530 @param Address The physical address of the access.\r
1531\r
1532 @return A 64-bit value returned from the I/O space.\r
1533**/\r
1534UINT64\r
1535EFIAPI\r
1536PeiDefaultIoRead64 (\r
1537 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1538 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1539 IN UINT64 Address\r
1540 );\r
d1102dba 1541\r
8d415937 1542/**\r
1543 8-bit I/O write operations.\r
1544\r
1545 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1546 @param This Pointer to local data for the interface.\r
1547 @param Address The physical address of the access.\r
1548 @param Data The data to write.\r
1549**/\r
1550VOID\r
1551EFIAPI\r
1552PeiDefaultIoWrite8 (\r
1553 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1554 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1555 IN UINT64 Address,\r
1556 IN UINT8 Data\r
1557 );\r
d1102dba 1558\r
8d415937 1559/**\r
1560 16-bit I/O write operations.\r
1561\r
1562 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1563 @param This Pointer to local data for the interface.\r
1564 @param Address The physical address of the access.\r
1565 @param Data The data to write.\r
1566**/\r
1567VOID\r
1568EFIAPI\r
1569PeiDefaultIoWrite16 (\r
1570 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1571 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1572 IN UINT64 Address,\r
1573 IN UINT16 Data\r
1574 );\r
d1102dba 1575\r
8d415937 1576/**\r
1577 32-bit I/O write operations.\r
1578\r
1579 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1580 @param This Pointer to local data for the interface.\r
1581 @param Address The physical address of the access.\r
1582 @param Data The data to write.\r
1583**/\r
1584VOID\r
1585EFIAPI\r
1586PeiDefaultIoWrite32 (\r
1587 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1588 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1589 IN UINT64 Address,\r
1590 IN UINT32 Data\r
1591 );\r
d1102dba 1592\r
8d415937 1593/**\r
1594 64-bit I/O write operations.\r
1595\r
1596 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1597 @param This Pointer to local data for the interface.\r
1598 @param Address The physical address of the access.\r
1599 @param Data The data to write.\r
1600**/\r
1601VOID\r
1602EFIAPI\r
1603PeiDefaultIoWrite64 (\r
1604 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1605 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1606 IN UINT64 Address,\r
1607 IN UINT64 Data\r
1608 );\r
d1102dba 1609\r
8d415937 1610/**\r
1611 8-bit memory read operations.\r
1612\r
d1102dba 1613 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1614 return 0.\r
d1102dba 1615\r
8d415937 1616 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1617 @param This Pointer to local data for the interface.\r
1618 @param Address The physical address of the access.\r
1619\r
1620 @return An 8-bit value returned from the memory space.\r
1621\r
1622**/\r
1623UINT8\r
1624EFIAPI\r
1625PeiDefaultMemRead8 (\r
1626 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1627 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1628 IN UINT64 Address\r
1629 );\r
d1102dba 1630\r
8d415937 1631/**\r
1632 16-bit memory read operations.\r
1633\r
d1102dba 1634 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1635 return 0.\r
d1102dba 1636\r
8d415937 1637 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1638 @param This Pointer to local data for the interface.\r
1639 @param Address The physical address of the access.\r
1640\r
1641 @return An 16-bit value returned from the memory space.\r
1642\r
1643**/\r
1644UINT16\r
1645EFIAPI\r
1646PeiDefaultMemRead16 (\r
1647 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1648 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1649 IN UINT64 Address\r
1650 );\r
d1102dba 1651\r
8d415937 1652/**\r
1653 32-bit memory read operations.\r
1654\r
d1102dba 1655 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1656 return 0.\r
d1102dba 1657\r
8d415937 1658 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1659 @param This Pointer to local data for the interface.\r
1660 @param Address The physical address of the access.\r
1661\r
1662 @return An 32-bit value returned from the memory space.\r
1663\r
1664**/\r
1665UINT32\r
1666EFIAPI\r
1667PeiDefaultMemRead32 (\r
1668 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1669 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1670 IN UINT64 Address\r
1671 );\r
d1102dba 1672\r
8d415937 1673/**\r
1674 64-bit memory read operations.\r
1675\r
d1102dba 1676 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
8d415937 1677 return 0.\r
d1102dba 1678\r
8d415937 1679 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1680 @param This Pointer to local data for the interface.\r
1681 @param Address The physical address of the access.\r
1682\r
1683 @return An 64-bit value returned from the memory space.\r
1684\r
1685**/\r
1686UINT64\r
1687EFIAPI\r
1688PeiDefaultMemRead64 (\r
1689 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1690 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1691 IN UINT64 Address\r
1692 );\r
d1102dba 1693\r
8d415937 1694/**\r
1695 8-bit memory write operations.\r
1696\r
1697 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1698 @param This Pointer to local data for the interface.\r
1699 @param Address The physical address of the access.\r
1700 @param Data The data to write.\r
1701\r
1702**/\r
1703VOID\r
1704EFIAPI\r
1705PeiDefaultMemWrite8 (\r
1706 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1707 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1708 IN UINT64 Address,\r
1709 IN UINT8 Data\r
1710 );\r
d1102dba 1711\r
8d415937 1712/**\r
1713 16-bit memory write operations.\r
1714\r
1715 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1716 @param This Pointer to local data for the interface.\r
1717 @param Address The physical address of the access.\r
1718 @param Data The data to write.\r
1719\r
1720**/\r
1721VOID\r
1722EFIAPI\r
1723PeiDefaultMemWrite16 (\r
1724 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1725 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1726 IN UINT64 Address,\r
1727 IN UINT16 Data\r
1728 );\r
1729\r
1730/**\r
1731 32-bit memory write operations.\r
1732\r
1733 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1734 @param This Pointer to local data for the interface.\r
1735 @param Address The physical address of the access.\r
1736 @param Data The data to write.\r
1737\r
1738**/\r
1739VOID\r
1740EFIAPI\r
1741PeiDefaultMemWrite32 (\r
1742 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1743 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1744 IN UINT64 Address,\r
1745 IN UINT32 Data\r
1746 );\r
d1102dba 1747\r
8d415937 1748/**\r
1749 64-bit memory write operations.\r
1750\r
1751 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1752 @param This Pointer to local data for the interface.\r
1753 @param Address The physical address of the access.\r
1754 @param Data The data to write.\r
1755\r
1756**/\r
1757VOID\r
1758EFIAPI\r
1759PeiDefaultMemWrite64 (\r
1760 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1761 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1762 IN UINT64 Address,\r
1763 IN UINT64 Data\r
1764 );\r
d1102dba
LG
1765\r
1766extern EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi;\r
8d415937 1767\r
1768//\r
1769// Default EFI_PEI_PCI_CFG2_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.\r
d1102dba 1770//\r
8d415937 1771\r
1772/**\r
1773 Reads from a given location in the PCI configuration space.\r
1774\r
d1102dba
LG
1775 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then\r
1776 return EFI_NOT_YET_AVAILABLE.\r
1777\r
8d415937 1778 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1779 @param This Pointer to local data for the interface.\r
1780 @param Width The width of the access. Enumerated in bytes.\r
1781 See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
1782 @param Address The physical address of the access. The format of\r
1783 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
1784 @param Buffer A pointer to the buffer of data.\r
1785\r
1786 @retval EFI_SUCCESS The function completed successfully.\r
1787 @retval EFI_INVALID_PARAMETER The invalid access width.\r
1788 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
d1102dba 1789\r
8d415937 1790**/\r
1791EFI_STATUS\r
1792EFIAPI\r
1793PeiDefaultPciCfg2Read (\r
1794 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1795 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
1796 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
1797 IN UINT64 Address,\r
1798 IN OUT VOID *Buffer\r
1799 );\r
d1102dba 1800\r
8d415937 1801/**\r
1802 Write to a given location in the PCI configuration space.\r
1803\r
d1102dba
LG
1804 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then\r
1805 return EFI_NOT_YET_AVAILABLE.\r
1806\r
8d415937 1807 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1808 @param This Pointer to local data for the interface.\r
1809 @param Width The width of the access. Enumerated in bytes.\r
1810 See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
1811 @param Address The physical address of the access. The format of\r
1812 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
1813 @param Buffer A pointer to the buffer of data.\r
1814\r
1815 @retval EFI_SUCCESS The function completed successfully.\r
1816 @retval EFI_INVALID_PARAMETER The invalid access width.\r
1817 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
1818**/\r
1819EFI_STATUS\r
1820EFIAPI\r
1821PeiDefaultPciCfg2Write (\r
1822 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1823 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
1824 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
1825 IN UINT64 Address,\r
1826 IN OUT VOID *Buffer\r
1827 );\r
d1102dba 1828\r
8d415937 1829/**\r
1830 This function performs a read-modify-write operation on the contents from a given\r
1831 location in the PCI configuration space.\r
1832\r
1833 @param PeiServices An indirect pointer to the PEI Services Table\r
1834 published by the PEI Foundation.\r
1835 @param This Pointer to local data for the interface.\r
1836 @param Width The width of the access. Enumerated in bytes. Type\r
1837 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().\r
1838 @param Address The physical address of the access.\r
1839 @param SetBits Points to value to bitwise-OR with the read configuration value.\r
1840 The size of the value is determined by Width.\r
1841 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.\r
1842 The size of the value is determined by Width.\r
1843\r
1844 @retval EFI_SUCCESS The function completed successfully.\r
1845 @retval EFI_INVALID_PARAMETER The invalid access width.\r
1846 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
1847**/\r
1848EFI_STATUS\r
1849EFIAPI\r
1850PeiDefaultPciCfg2Modify (\r
1851 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1852 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
1853 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
1854 IN UINT64 Address,\r
1855 IN VOID *SetBits,\r
1856 IN VOID *ClearBits\r
d1102dba
LG
1857 );\r
1858\r
8d415937 1859extern EFI_PEI_PCI_CFG2_PPI gPeiDefaultPciCfg2Ppi;\r
1860\r
8e0e40ed 1861/**\r
1862 After PeiCore image is shadowed into permanent memory, all build-in FvPpi should\r
d1102dba 1863 be re-installed with the instance in permanent memory and all cached FvPpi pointers in\r
6393d9c8 1864 PrivateData->Fv[] array should be fixed up to be pointed to the one in permanent\r
8e0e40ed 1865 memory.\r
d1102dba 1866\r
8e0e40ed 1867 @param PrivateData Pointer to PEI_CORE_INSTANCE.\r
d1102dba 1868**/\r
8e0e40ed 1869VOID\r
1870PeiReinitializeFv (\r
1871 IN PEI_CORE_INSTANCE *PrivateData\r
1872 );\r
d1102dba 1873\r
192f6d4c 1874#endif\r