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