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