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