]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Pei/PeiMain.h
Enabling EFI_PEI_FIRMWARE_VOLUME_PPI introduced by PI1.2.
[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 - 2009, Intel Corporation\r
5All rights reserved. This 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/Decompress.h>\r
26#include <Ppi/GuidedSectionExtraction.h>\r
27#include <Ppi/LoadFile.h>\r
28#include <Ppi/Security2.h>\r
29#include <Ppi/TemporaryRamSupport.h>\r
30#include <Library/DebugLib.h>\r
31#include <Library/PeiCoreEntryPoint.h>\r
32#include <Library/BaseLib.h>\r
33#include <Library/HobLib.h>\r
34#include <Library/PerformanceLib.h>\r
35#include <Library/PeiServicesLib.h>\r
36#include <Library/ReportStatusCodeLib.h>\r
37#include <Library/PeCoffLib.h>\r
38#include <Library/PeCoffGetEntryPointLib.h>\r
39#include <Library/BaseMemoryLib.h>\r
40#include <Library/CacheMaintenanceLib.h>\r
41#include <Library/TimerLib.h>\r
42#include <Library/PcdLib.h>\r
43#include <IndustryStandard/PeImage.h>\r
44#include <Library/PeiServicesTablePointerLib.h>\r
45#include <Library/MemoryAllocationLib.h>\r
46#include <Guid/FirmwareFileSystem2.h>\r
47#include <Guid/AprioriFileName.h>\r
48\r
49///\r
50/// It is an FFS type extension used for PeiFindFileEx. It indicates current\r
51/// Ffs searching is for all PEIMs can be dispatched by PeiCore.\r
52///\r
53#define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE 0xff\r
54\r
55///\r
56/// Pei Core private data structures\r
57///\r
58typedef union {\r
59 EFI_PEI_PPI_DESCRIPTOR *Ppi;\r
60 EFI_PEI_NOTIFY_DESCRIPTOR *Notify;\r
61 VOID *Raw;\r
62} PEI_PPI_LIST_POINTERS;\r
63\r
64///\r
65/// PPI database structure which contains two link: PpiList and NotifyList. PpiList\r
66/// is in head of PpiListPtrs array and notify is in end of PpiListPtrs.\r
67///\r
68typedef struct {\r
69 ///\r
70 /// index of end of PpiList link list.\r
71 ///\r
72 INTN PpiListEnd;\r
73 ///\r
74 /// index of end of notify link list.\r
75 ///\r
76 INTN NotifyListEnd;\r
77 ///\r
78 /// index of the dispatched notify list.\r
79 ///\r
80 INTN DispatchListEnd;\r
81 ///\r
82 /// index of last installed Ppi description in PpiList link list.\r
83 ///\r
84 INTN LastDispatchedInstall;\r
85 ///\r
86 /// index of last dispatched notify in Notify link list.\r
87 /// \r
88 INTN LastDispatchedNotify;\r
89 ///\r
90 /// Ppi database.\r
91 ///\r
92 PEI_PPI_LIST_POINTERS PpiListPtrs[FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)];\r
93} PEI_PPI_DATABASE;\r
94\r
95\r
96//\r
97// PEI_CORE_FV_HANDE.PeimState\r
98// Do not change these values as there is code doing math to change states.\r
99// Look for Private->Fv[FvCount].PeimState[PeimCount]++;\r
100//\r
101#define PEIM_STATE_NOT_DISPATCHED 0x00\r
102#define PEIM_STATE_DISPATCHED 0x01\r
103#define PEIM_STATE_REGISITER_FOR_SHADOW 0x02\r
104#define PEIM_STATE_DONE 0x03\r
105\r
106typedef struct {\r
107 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
108 EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;\r
109 EFI_PEI_FV_HANDLE FvHandle;\r
110 UINT8 PeimState[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
111 EFI_PEI_FILE_HANDLE FvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
112 BOOLEAN ScanFv;\r
113} PEI_CORE_FV_HANDLE;\r
114\r
115#define CACHE_SETION_MAX_NUMBER 0x10\r
116typedef struct {\r
117 EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];\r
118 VOID* SectionData[CACHE_SETION_MAX_NUMBER];\r
119 UINTN SectionSize[CACHE_SETION_MAX_NUMBER];\r
120 UINTN AllSectionCount;\r
121 UINTN SectionIndex;\r
122} CACHE_SECTION_DATA;\r
123\r
124\r
125#define PEI_CORE_HANDLE_SIGNATURE SIGNATURE_32('P','e','i','C')\r
126\r
127///\r
128/// Pei Core private data structure instance\r
129///\r
130typedef struct{\r
131 UINTN Signature;\r
132 \r
133 ///\r
134 /// Point to ServiceTableShadow\r
135 ///\r
136 EFI_PEI_SERVICES *PS;\r
137 PEI_PPI_DATABASE PpiData;\r
138 \r
139 ///\r
140 /// The count of FVs which contains FFS and could be dispatched by PeiCore.\r
141 ///\r
142 UINTN FvCount;\r
143 \r
144 ///\r
145 /// The instance arrary for FVs which contains FFS and could be dispatched by PeiCore.\r
146 ///\r
147 PEI_CORE_FV_HANDLE Fv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
148\r
149 EFI_PEI_FILE_HANDLE CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
150 UINTN AprioriCount;\r
151 UINTN CurrentPeimFvCount;\r
152 UINTN CurrentPeimCount;\r
153 EFI_PEI_FILE_HANDLE CurrentFileHandle;\r
154 BOOLEAN PeimNeedingDispatch;\r
155 BOOLEAN PeimDispatchOnThisPass;\r
156 BOOLEAN PeimDispatcherReenter;\r
157 EFI_PEI_HOB_POINTERS HobList;\r
158 BOOLEAN SwitchStackSignal;\r
159 BOOLEAN PeiMemoryInstalled;\r
160 EFI_PHYSICAL_ADDRESS StackBase;\r
161 UINT64 StackSize;\r
162 VOID *CpuIo;\r
163 EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi;\r
164 EFI_PEI_SERVICES ServiceTableShadow;\r
165 EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;\r
166 EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin;\r
167 UINT64 PhysicalMemoryLength;\r
168 EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop;\r
169 VOID* ShadowedPeiCore;\r
170 CACHE_SECTION_DATA CacheSection;\r
171} PEI_CORE_INSTANCE;\r
172\r
173///\r
174/// Pei Core Instance Data Macros\r
175///\r
176#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \\r
177 CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)\r
178\r
179/**\r
180 Function Pointer type for PeiCore function.\r
181 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
182 and location of temporary RAM, the stack location and the BFV location.\r
183 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
184 An empty PPI list consists of a single descriptor with the end-tag\r
185 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
186 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
187 that both the PEI Foundation and any modules can leverage the associated service\r
188 calls and/or code in these early PPIs\r
189 @param OldCoreData Pointer to old core data that is used to initialize the\r
190 core's data areas.\r
191**/\r
192typedef\r
193EFI_STATUS\r
194(EFIAPI *PEICORE_FUNCTION_POINTER)(\r
195 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
196 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
197 IN PEI_CORE_INSTANCE *OldCoreData\r
198 );\r
199\r
200///\r
201/// Union of temporarily used function pointers (to save stack space)\r
202///\r
203typedef union {\r
204 PEICORE_FUNCTION_POINTER PeiCore;\r
205 EFI_PEIM_ENTRY_POINT2 PeimEntry;\r
206 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;\r
207 EFI_DXE_IPL_PPI *DxeIpl;\r
208 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
209 EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;\r
210 VOID *Raw;\r
211} PEI_CORE_TEMP_POINTERS;\r
212\r
213typedef struct {\r
214 CONST EFI_SEC_PEI_HAND_OFF *SecCoreData;\r
215 EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
216 VOID *Data;\r
217} PEI_CORE_PARAMETERS;\r
218\r
219//\r
220// PeiCore function\r
221//\r
222/**\r
223\r
224 The entry routine to Pei Core, invoked by PeiMain during transition\r
225 from SEC to PEI. After switching stack in the PEI core, it will restart\r
226 with the old core data.\r
227\r
228\r
229 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
230 and location of temporary RAM, the stack location and the BFV location.\r
231 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
232 An empty PPI list consists of a single descriptor with the end-tag\r
233 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
234 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
235 that both the PEI Foundation and any modules can leverage the associated service\r
236 calls and/or code in these early PPIs\r
237 @param Data Pointer to old core data that is used to initialize the\r
238 core's data areas.\r
239\r
240**/\r
241VOID\r
242EFIAPI\r
243PeiCore (\r
244 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
245 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
246 IN VOID *Data\r
247 );\r
248\r
249//\r
250// Dispatcher support functions\r
251//\r
252\r
253/**\r
254\r
255 This is the POSTFIX version of the dependency evaluator. When a\r
256 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on\r
257 the evaluation stack. When that entry is poped from the evaluation\r
258 stack, the PPI is checked if it is installed. This method allows\r
259 some time savings as not all PPIs must be checked for certain\r
260 operation types (AND, OR).\r
261\r
262\r
263 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
264 @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to\r
265 the BNF described above and is stored in postfix notation.\r
266\r
267 @retval TRUE if it is a well-formed Grammar\r
268 @retval FALSE if the dependency expression overflows the evaluation stack\r
269 if the dependency expression underflows the evaluation stack\r
270 if the dependency expression is not a well-formed Grammar.\r
271\r
272**/\r
273BOOLEAN\r
274PeimDispatchReadiness (\r
275 IN EFI_PEI_SERVICES **PeiServices,\r
276 IN VOID *DependencyExpression\r
277 );\r
278\r
279/**\r
280 Conduct PEIM dispatch.\r
281\r
282 @param SecCoreData Pointer to the data structure containing SEC to PEI handoff data\r
283 @param PrivateData Pointer to the private data passed in from caller\r
284\r
285**/\r
286VOID\r
287PeiDispatcher (\r
288 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
289 IN PEI_CORE_INSTANCE *PrivateData\r
290 );\r
291\r
292/**\r
293 Initialize the Dispatcher's data members\r
294\r
295 @param PrivateData PeiCore's private data structure\r
296 @param OldCoreData Old data from SecCore\r
297 NULL if being run in non-permament memory mode.\r
298 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
299 and location of temporary RAM, the stack location and the BFV location.\r
300\r
301**/\r
302VOID\r
303InitializeDispatcherData (\r
304 IN PEI_CORE_INSTANCE *PrivateData,\r
305 IN PEI_CORE_INSTANCE *OldCoreData,\r
306 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
307 );\r
308\r
309/**\r
310 This routine parses the Dependency Expression, if available, and\r
311 decides if the module can be executed.\r
312\r
313\r
314 @param Private PeiCore's private data structure\r
315 @param FileHandle PEIM's file handle\r
316 @param PeimCount The index of last dispatched PEIM.\r
317\r
318 @retval TRUE Can be dispatched\r
319 @retval FALSE Cannot be dispatched\r
320\r
321**/\r
322BOOLEAN\r
323DepexSatisfied (\r
324 IN PEI_CORE_INSTANCE *Private,\r
325 IN EFI_PEI_FILE_HANDLE FileHandle,\r
326 IN UINTN PeimCount\r
327 );\r
328\r
329//\r
330// PPI support functions\r
331//\r
332/**\r
333\r
334 Initialize PPI services.\r
335\r
336 @param PrivateData Pointer to the PEI Core data.\r
337 @param OldCoreData Pointer to old PEI Core data. \r
338 NULL if being run in non-permament memory mode.\r
339\r
340**/\r
341VOID\r
342InitializePpiServices (\r
343 IN PEI_CORE_INSTANCE *PrivateData,\r
344 IN PEI_CORE_INSTANCE *OldCoreData\r
345 );\r
346\r
347/**\r
348\r
349 Migrate the Hob list from the temporary memory stack to PEI installed memory.\r
350\r
351 @param PrivateData Pointer to PeiCore's private data structure.\r
352 @param OldCheckingBottom Bottom of temporary memory range. All Ppi in this range\r
353 will be fixup for PpiData and PpiDescriptor pointer.\r
354 @param OldCheckingTop Top of temporary memory range. All Ppi in this range\r
355 will be fixup for PpiData and PpiDescriptor.\r
356 @param Fixup The address difference between\r
357 the new Hob list and old Hob list.\r
358\r
359**/\r
360VOID\r
361ConvertPpiPointers (\r
362 IN PEI_CORE_INSTANCE *PrivateData,\r
363 IN UINTN OldCheckingBottom,\r
364 IN UINTN OldCheckingTop,\r
365 IN INTN Fixup\r
366 );\r
367\r
368/**\r
369\r
370 Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.\r
371\r
372 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
373 @param PpiList Pointer to ppi array that want to be installed.\r
374\r
375 @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.\r
376 @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer\r
377 if any PPI in PpiList is not valid\r
378 @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI\r
379\r
380**/\r
381EFI_STATUS\r
382EFIAPI\r
383PeiInstallPpi (\r
384 IN CONST EFI_PEI_SERVICES **PeiServices,\r
385 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
386 );\r
387\r
388/**\r
389\r
390 Re-Install PPI services.\r
391\r
392 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
393 @param OldPpi Pointer to the old PEI PPI Descriptors.\r
394 @param NewPpi Pointer to the new PEI PPI Descriptors.\r
395\r
396 @retval EFI_SUCCESS if the operation was successful\r
397 @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL\r
398 if NewPpi is not valid\r
399 @retval EFI_NOT_FOUND if the PPI was not in the database\r
400\r
401**/\r
402EFI_STATUS\r
403EFIAPI\r
404PeiReInstallPpi (\r
405 IN CONST EFI_PEI_SERVICES **PeiServices,\r
406 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
407 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
408 );\r
409\r
410/**\r
411\r
412 Locate a given named PPI.\r
413\r
414\r
415 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
416 @param Guid Pointer to GUID of the PPI.\r
417 @param Instance Instance Number to discover.\r
418 @param PpiDescriptor Pointer to reference the found descriptor. If not NULL,\r
419 returns a pointer to the descriptor (includes flags, etc)\r
420 @param Ppi Pointer to reference the found PPI\r
421\r
422 @retval EFI_SUCCESS if the PPI is in the database\r
423 @retval EFI_NOT_FOUND if the PPI is not in the database\r
424\r
425**/\r
426EFI_STATUS\r
427EFIAPI\r
428PeiLocatePpi (\r
429 IN CONST EFI_PEI_SERVICES **PeiServices,\r
430 IN CONST EFI_GUID *Guid,\r
431 IN UINTN Instance,\r
432 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
433 IN OUT VOID **Ppi\r
434 );\r
435\r
436/**\r
437\r
438 Install a notification for a given PPI.\r
439\r
440\r
441 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
442 @param NotifyList Pointer to list of Descriptors to notify upon.\r
443\r
444 @retval EFI_SUCCESS if successful\r
445 @retval EFI_OUT_OF_RESOURCES if no space in the database\r
446 @retval EFI_INVALID_PARAMETER if not a good decriptor\r
447\r
448**/\r
449EFI_STATUS\r
450EFIAPI\r
451PeiNotifyPpi (\r
452 IN CONST EFI_PEI_SERVICES **PeiServices,\r
453 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
454 );\r
455\r
456/**\r
457\r
458 Process the Notify List at dispatch level.\r
459\r
460 @param PrivateData PeiCore's private data structure.\r
461\r
462**/\r
463VOID\r
464ProcessNotifyList (\r
465 IN PEI_CORE_INSTANCE *PrivateData\r
466 );\r
467\r
468/**\r
469\r
470 Dispatch notifications.\r
471\r
472 @param PrivateData PeiCore's private data structure\r
473 @param NotifyType Type of notify to fire.\r
474 @param InstallStartIndex Install Beginning index.\r
475 @param InstallStopIndex Install Ending index.\r
476 @param NotifyStartIndex Notify Beginning index.\r
477 @param NotifyStopIndex Notify Ending index.\r
478\r
479**/\r
480VOID\r
481DispatchNotify (\r
482 IN PEI_CORE_INSTANCE *PrivateData,\r
483 IN UINTN NotifyType,\r
484 IN INTN InstallStartIndex,\r
485 IN INTN InstallStopIndex,\r
486 IN INTN NotifyStartIndex,\r
487 IN INTN NotifyStopIndex\r
488 );\r
489\r
490//\r
491// Boot mode support functions\r
492//\r
493/**\r
494 This service enables PEIMs to ascertain the present value of the boot mode.\r
495\r
496 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
497 @param BootMode A pointer to contain the value of the boot mode.\r
498\r
499 @retval EFI_SUCCESS The boot mode was returned successfully.\r
500 @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
501\r
502**/\r
503EFI_STATUS\r
504EFIAPI\r
505PeiGetBootMode (\r
506 IN CONST EFI_PEI_SERVICES **PeiServices,\r
507 IN OUT EFI_BOOT_MODE *BootMode\r
508 );\r
509\r
510/**\r
511 This service enables PEIMs to update the boot mode variable.\r
512\r
513\r
514 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
515 @param BootMode The value of the boot mode to set.\r
516\r
517 @return EFI_SUCCESS The value was successfully updated\r
518\r
519**/\r
520EFI_STATUS\r
521EFIAPI\r
522PeiSetBootMode (\r
523 IN CONST EFI_PEI_SERVICES **PeiServices,\r
524 IN EFI_BOOT_MODE BootMode\r
525 );\r
526\r
527//\r
528// Security support functions\r
529//\r
530/**\r
531\r
532 Initialize the security services.\r
533\r
534 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
535 @param OldCoreData Pointer to the old core data.\r
536 NULL if being run in non-permament memory mode.\r
537\r
538**/\r
539VOID\r
540InitializeSecurityServices (\r
541 IN EFI_PEI_SERVICES **PeiServices,\r
542 IN PEI_CORE_INSTANCE *OldCoreData\r
543 );\r
544\r
545/**\r
546 Verify a Firmware volume.\r
547\r
548 @param CurrentFvAddress Pointer to the current Firmware Volume under consideration\r
549\r
550 @retval EFI_SUCCESS Firmware Volume is legal\r
551 @retval EFI_SECURITY_VIOLATION Firmware Volume fails integrity test\r
552\r
553**/\r
554EFI_STATUS\r
555VerifyFv (\r
556 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
557 );\r
558\r
559/**\r
560\r
561 Provide a callout to the security verification service.\r
562\r
563\r
564 @param PrivateData PeiCore's private data structure\r
565 @param VolumeHandle Handle of FV\r
566 @param FileHandle Handle of PEIM's ffs\r
567\r
568 @retval EFI_SUCCESS Image is OK\r
569 @retval EFI_SECURITY_VIOLATION Image is illegal\r
570\r
571**/\r
572EFI_STATUS\r
573VerifyPeim (\r
574 IN PEI_CORE_INSTANCE *PrivateData,\r
575 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
576 IN EFI_PEI_FILE_HANDLE FileHandle\r
577 );\r
578\r
579/**\r
580\r
581 Gets the pointer to the HOB List.\r
582\r
583\r
584 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
585 @param HobList Pointer to the HOB List.\r
586\r
587 @retval EFI_SUCCESS Get the pointer of HOB List\r
588 @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published\r
589 @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode)\r
590\r
591**/\r
592EFI_STATUS\r
593EFIAPI\r
594PeiGetHobList (\r
595 IN CONST EFI_PEI_SERVICES **PeiServices,\r
596 IN OUT VOID **HobList\r
597 );\r
598\r
599/**\r
600 Add a new HOB to the HOB List.\r
601\r
602 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
603 @param Type Type of the new HOB.\r
604 @param Length Length of the new HOB to allocate.\r
605 @param Hob Pointer to the new HOB.\r
606\r
607 @return EFI_SUCCESS Success to create hob.\r
608 @retval EFI_INVALID_PARAMETER if Hob is NULL\r
609 @retval EFI_NOT_AVAILABLE_YET if HobList is still not available.\r
610 @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.\r
611\r
612**/\r
613EFI_STATUS\r
614EFIAPI\r
615PeiCreateHob (\r
616 IN CONST EFI_PEI_SERVICES **PeiServices,\r
617 IN UINT16 Type,\r
618 IN UINT16 Length,\r
619 IN OUT VOID **Hob\r
620 );\r
621\r
622/**\r
623\r
624 Builds a Handoff Information Table HOB\r
625\r
626 @param BootMode - Current Bootmode\r
627 @param MemoryBegin - Start Memory Address.\r
628 @param MemoryLength - Length of Memory.\r
629\r
630 @return EFI_SUCCESS Always success to initialize HOB.\r
631\r
632**/\r
633EFI_STATUS\r
634PeiCoreBuildHobHandoffInfoTable (\r
635 IN EFI_BOOT_MODE BootMode,\r
636 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
637 IN UINT64 MemoryLength\r
638 );\r
639\r
640\r
641//\r
642// FFS Fw Volume support functions\r
643//\r
644/**\r
645 Searches for the next matching file in the firmware volume.\r
646\r
647 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
648 @param SearchType Filter to find only files of this type.\r
649 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
650 @param VolumeHandle Handle of firmware volume in which to search.\r
651 @param FileHandle On entry, points to the current handle from which to begin searching or NULL to start\r
652 at the beginning of the firmware volume. On exit, points the file handle of the next file\r
653 in the volume or NULL if there are no more files.\r
654\r
655 @retval EFI_NOT_FOUND The file was not found.\r
656 @retval EFI_NOT_FOUND The header checksum was not zero.\r
657 @retval EFI_SUCCESS The file was found.\r
658\r
659**/\r
660EFI_STATUS\r
661EFIAPI\r
662PeiFfsFindNextFile (\r
663 IN CONST EFI_PEI_SERVICES **PeiServices,\r
664 IN UINT8 SearchType,\r
665 IN EFI_PEI_FV_HANDLE FvHandle,\r
666 IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r
667 );\r
668\r
669/**\r
670 Searches for the next matching section within the specified file.\r
671\r
672 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
673 @param SectionType Filter to find only sections of this type.\r
674 @param FileHandle Pointer to the current file to search.\r
675 @param SectionData A pointer to the discovered section, if successful.\r
676 NULL if section not found\r
677\r
678 @retval EFI_NOT_FOUND The section was not found.\r
679 @retval EFI_SUCCESS The section was found.\r
680\r
681**/\r
682EFI_STATUS\r
683EFIAPI\r
684PeiFfsFindSectionData (\r
685 IN CONST EFI_PEI_SERVICES **PeiServices,\r
686 IN EFI_SECTION_TYPE SectionType,\r
687 IN EFI_PEI_FILE_HANDLE FileHandle,\r
688 OUT VOID **SectionData\r
689 );\r
690\r
691/**\r
692 Search the firmware volumes by index\r
693\r
694 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
695 @param Instance This instance of the firmware volume to find. The value 0 is the Boot Firmware\r
696 Volume (BFV).\r
697 @param VolumeHandle On exit, points to the next volume handle or NULL if it does not exist.\r
698\r
699 @retval EFI_INVALID_PARAMETER VolumeHandle is NULL\r
700 @retval EFI_NOT_FOUND The volume was not found.\r
701 @retval EFI_SUCCESS The volume was found.\r
702\r
703**/\r
704EFI_STATUS\r
705EFIAPI\r
706PeiFfsFindNextVolume (\r
707 IN CONST EFI_PEI_SERVICES **PeiServices,\r
708 IN UINTN Instance,\r
709 IN OUT EFI_PEI_FV_HANDLE *FwVolHeader\r
710 );\r
711\r
712//\r
713// Memory support functions\r
714//\r
715/**\r
716\r
717 Initialize the memory services.\r
718\r
719 @param PrivateData PeiCore's private data structure\r
720 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
721 and location of temporary RAM, the stack location and the BFV location.\r
722 @param OldCoreData Pointer to the PEI Core data.\r
723 NULL if being run in non-permament memory mode.\r
724\r
725**/\r
726VOID\r
727InitializeMemoryServices (\r
728 IN PEI_CORE_INSTANCE *PrivateData,\r
729 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
730 IN PEI_CORE_INSTANCE *OldCoreData\r
731 );\r
732\r
733/**\r
734\r
735 Install the permanent memory is now available.\r
736 Creates HOB (PHIT and Stack).\r
737\r
738 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
739 @param MemoryBegin Start of memory address.\r
740 @param MemoryLength Length of memory.\r
741\r
742 @return EFI_SUCCESS Always success.\r
743\r
744**/\r
745EFI_STATUS\r
746EFIAPI\r
747PeiInstallPeiMemory (\r
748 IN CONST EFI_PEI_SERVICES **PeiServices,\r
749 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
750 IN UINT64 MemoryLength\r
751 );\r
752\r
753/**\r
754\r
755 Memory allocation service on permanent memory,\r
756 not usable prior to the memory installation.\r
757\r
758\r
759 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
760 @param MemoryType Type of memory to allocate.\r
761 @param Pages Number of pages to allocate.\r
762 @param Memory Pointer of memory allocated.\r
763\r
764 @retval EFI_SUCCESS The allocation was successful\r
765 @retval EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.\r
766 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available\r
767 @retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement\r
768 to allocate the number of pages.\r
769\r
770**/\r
771EFI_STATUS\r
772EFIAPI\r
773PeiAllocatePages (\r
774 IN CONST EFI_PEI_SERVICES **PeiServices,\r
775 IN EFI_MEMORY_TYPE MemoryType,\r
776 IN UINTN Pages,\r
777 OUT EFI_PHYSICAL_ADDRESS *Memory\r
778 );\r
779\r
780/**\r
781\r
782 Memory allocation service on the temporary memory.\r
783\r
784\r
785 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
786 @param Size Amount of memory required\r
787 @param Buffer Address of pointer to the buffer\r
788\r
789 @retval EFI_SUCCESS The allocation was successful\r
790 @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement\r
791 to allocate the requested size.\r
792\r
793**/\r
794EFI_STATUS\r
795EFIAPI\r
796PeiAllocatePool (\r
797 IN CONST EFI_PEI_SERVICES **PeiServices,\r
798 IN UINTN Size,\r
799 OUT VOID **Buffer\r
800 );\r
801\r
802/**\r
803\r
804 Routine for load image file.\r
805\r
806\r
807 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
808 @param FileHandle Pointer to the FFS file header of the image.\r
809 @param EntryPoint Pointer to entry point of specified image file for output.\r
810 @param AuthenticationState Pointer to attestation authentication state of image.\r
811\r
812 @retval EFI_SUCCESS Image is successfully loaded.\r
813 @retval EFI_NOT_FOUND Fail to locate necessary PPI\r
814 @retval Others Fail to load file.\r
815\r
816**/\r
817EFI_STATUS\r
818PeiLoadImage (\r
819 IN CONST EFI_PEI_SERVICES **PeiServices,\r
820 IN EFI_PEI_FILE_HANDLE FileHandle,\r
821 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
822 OUT UINT32 *AuthenticationState\r
823 );\r
824\r
825/**\r
826\r
827 Core version of the Status Code reporter\r
828\r
829\r
830 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
831 @param CodeType Type of Status Code.\r
832 @param Value Value to output for Status Code.\r
833 @param Instance Instance Number of this status code.\r
834 @param CallerId ID of the caller of this status code.\r
835 @param Data Optional data associated with this status code.\r
836\r
837 @retval EFI_SUCCESS if status code is successfully reported\r
838 @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed\r
839\r
840**/\r
841EFI_STATUS\r
842EFIAPI\r
843PeiReportStatusCode (\r
844 IN CONST EFI_PEI_SERVICES **PeiServices,\r
845 IN EFI_STATUS_CODE_TYPE CodeType,\r
846 IN EFI_STATUS_CODE_VALUE Value,\r
847 IN UINT32 Instance,\r
848 IN CONST EFI_GUID *CallerId,\r
849 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
850 );\r
851\r
852/**\r
853\r
854 Core version of the Reset System\r
855\r
856\r
857 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
858\r
859 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.\r
860 @retval EFI_DEVICE_ERROR Did not reset system.\r
861 Otherwise, resets the system.\r
862\r
863**/\r
864EFI_STATUS\r
865EFIAPI\r
866PeiResetSystem (\r
867 IN CONST EFI_PEI_SERVICES **PeiServices\r
868 );\r
869\r
870/**\r
871\r
872 Initialize PeiCore Fv List.\r
873\r
874\r
875 @param PrivateData - Pointer to PEI_CORE_INSTANCE.\r
876 @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.\r
877\r
878**/\r
879VOID\r
880PeiInitializeFv (\r
881 IN PEI_CORE_INSTANCE *PrivateData,\r
882 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
883 );\r
884\r
885/**\r
886 Process Firmware Volum Information once FvInfoPPI install.\r
887\r
888 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
889 @param NotifyDescriptor Address of the notification descriptor data structure.\r
890 @param Ppi Address of the PPI that was installed.\r
891\r
892 @retval EFI_SUCCESS if the interface could be successfully installed\r
893\r
894**/\r
895EFI_STATUS\r
896EFIAPI\r
897FirmwareVolmeInfoPpiNotifyCallback (\r
898 IN EFI_PEI_SERVICES **PeiServices,\r
899 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
900 IN VOID *Ppi\r
901 );\r
902\r
903/**\r
904\r
905 Given the input VolumeHandle, search for the next matching name file.\r
906\r
907 @param FileName File name to search.\r
908 @param VolumeHandle The current FV to search.\r
909 @param FileHandle Pointer to the file matching name in VolumeHandle.\r
910 NULL if file not found\r
911\r
912 @retval EFI_NOT_FOUND No files matching the search criteria were found\r
913 @retval EFI_SUCCESS Success to search given file\r
914\r
915**/\r
916EFI_STATUS\r
917EFIAPI\r
918PeiFfsFindFileByName (\r
919 IN CONST EFI_GUID *FileName,\r
920 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
921 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
922 );\r
923\r
924/**\r
925 Returns information about a specific file.\r
926\r
927 @param FileHandle Handle of the file.\r
928 @param FileInfo Upon exit, points to the file’s information.\r
929\r
930 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
931 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
932 @retval EFI_SUCCESS File information returned.\r
933\r
934**/\r
935EFI_STATUS\r
936EFIAPI\r
937PeiFfsGetFileInfo (\r
938 IN EFI_PEI_FILE_HANDLE FileHandle,\r
939 OUT EFI_FV_FILE_INFO *FileInfo\r
940 );\r
941\r
942/**\r
943 Returns information about the specified volume.\r
944\r
945 @param VolumeHandle Handle of the volume.\r
946 @param VolumeInfo Upon exit, points to the volume’s information.\r
947\r
948 @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.\r
949 @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.\r
950 @retval EFI_SUCCESS Volume information returned.\r
951**/\r
952EFI_STATUS\r
953EFIAPI\r
954PeiFfsGetVolumeInfo (\r
955 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
956 OUT EFI_FV_INFO *VolumeInfo\r
957 );\r
958\r
959/**\r
960 This routine enable a PEIM to register itself to shadow when PEI Foundation\r
961 discovery permanent memory.\r
962\r
963 @param FileHandle File handle of a PEIM.\r
964\r
965 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.\r
966 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.\r
967 @retval EFI_SUCCESS Successfully to register itself.\r
968\r
969**/\r
970EFI_STATUS\r
971EFIAPI\r
972PeiRegisterForShadow (\r
973 IN EFI_PEI_FILE_HANDLE FileHandle\r
974 );\r
975\r
976/**\r
977 Initialize image service that install PeiLoadFilePpi.\r
978\r
979 @param PrivateData Pointer to PeiCore's private data structure PEI_CORE_INSTANCE.\r
980 @param OldCoreData Pointer to Old PeiCore's private data.\r
981 If NULL, PeiCore is entered at first time, stack/heap in temporary memory.\r
982 If not NULL, PeiCore is entered at second time, stack/heap has been moved\r
983 to permenent memory.\r
984\r
985**/\r
986VOID\r
987InitializeImageServices (\r
988 IN PEI_CORE_INSTANCE *PrivateData,\r
989 IN PEI_CORE_INSTANCE *OldCoreData\r
990 );\r
991\r
992/**\r
993 The wrapper function of PeiLoadImageLoadImage().\r
994\r
995 @param This Pointer to EFI_PEI_LOAD_FILE_PPI.\r
996 @param FileHandle Pointer to the FFS file header of the image.\r
997 @param ImageAddressArg Pointer to PE/TE image.\r
998 @param ImageSizeArg Size of PE/TE image.\r
999 @param EntryPoint Pointer to entry point of specified image file for output.\r
1000 @param AuthenticationState Pointer to attestation authentication state of image.\r
1001\r
1002 @return Status of PeiLoadImageLoadImage().\r
1003\r
1004**/\r
1005EFI_STATUS\r
1006EFIAPI\r
1007PeiLoadImageLoadImageWrapper (\r
1008 IN CONST EFI_PEI_LOAD_FILE_PPI *This,\r
1009 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1010 OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL\r
1011 OUT UINT64 *ImageSizeArg, OPTIONAL\r
1012 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
1013 OUT UINT32 *AuthenticationState\r
1014 );\r
1015\r
1016/**\r
1017\r
1018 Provide a callback for when the security PPI is installed.\r
1019\r
1020 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1021 @param NotifyDescriptor The descriptor for the notification event.\r
1022 @param Ppi Pointer to the PPI in question.\r
1023\r
1024 @return Always success\r
1025\r
1026**/\r
1027EFI_STATUS\r
1028EFIAPI\r
1029SecurityPpiNotifyCallback (\r
1030 IN EFI_PEI_SERVICES **PeiServices,\r
1031 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
1032 IN VOID *Ppi\r
1033 );\r
1034\r
1035/**\r
1036 Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
1037\r
1038 @param ParentFvCoreHandle Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.\r
1039 @param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.\r
1040\r
1041 @retval EFI_NOT_FOUND FV image can't be found.\r
1042 @retval EFI_SUCCESS Successfully to process it.\r
1043 @retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image\r
1044 @retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
1045 \r
1046**/\r
1047EFI_STATUS\r
1048ProcessFvFile (\r
1049 IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle,\r
1050 IN EFI_PEI_FILE_HANDLE ParentFvFileHandle\r
1051 );\r
1052 \r
1053/**\r
1054 Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.\r
1055 \r
1056 This routine also will install FvInfo ppi for FV hob in PI ways.\r
1057 \r
1058 @param Private Pointer of PEI_CORE_INSTANCE\r
1059 @param Instance The index of FV want to be searched.\r
1060 \r
1061 @return Instance of PEI_CORE_FV_HANDLE.\r
1062**/\r
1063PEI_CORE_FV_HANDLE *\r
1064FindNextCoreFvHandle (\r
1065 IN PEI_CORE_INSTANCE *Private,\r
1066 IN UINTN Instance\r
1067 );\r
1068 \r
1069#endif\r