]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Pei/PeiMain.h
Fix the ICC waring for unreachable code.
[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
61typedef struct {\r
62 INTN PpiListEnd;\r
63 INTN NotifyListEnd;\r
64 INTN DispatchListEnd;\r
65 INTN LastDispatchedInstall;\r
66 INTN LastDispatchedNotify;\r
67 PEI_PPI_LIST_POINTERS PpiListPtrs[FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)];\r
68} PEI_PPI_DATABASE;\r
69\r
70\r
71//\r
72// PEI_CORE_FV_HANDE.PeimState\r
73// Do not change these values as there is code doing math to change states.\r
74// Look for Private->Fv[FvCount].PeimState[PeimCount]++;\r
75//\r
76#define PEIM_STATE_NOT_DISPATCHED 0x00\r
77#define PEIM_STATE_DISPATCHED 0x01\r
78#define PEIM_STATE_REGISITER_FOR_SHADOW 0x02\r
79#define PEIM_STATE_DONE 0x03\r
80\r
81typedef struct {\r
82 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
83 UINT8 PeimState[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
84 EFI_PEI_FILE_HANDLE FvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
85 BOOLEAN ScanFv;\r
86} PEI_CORE_FV_HANDLE;\r
87\r
88#define CACHE_SETION_MAX_NUMBER 0x10\r
89typedef struct {\r
90 EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];\r
91 VOID* SectionData[CACHE_SETION_MAX_NUMBER];\r
92 UINTN SectionSize[CACHE_SETION_MAX_NUMBER];\r
93 UINTN AllSectionCount;\r
94 UINTN SectionIndex;\r
95} CACHE_SECTION_DATA;\r
96\r
97//\r
98// Pei Core private data structure instance\r
99//\r
100\r
101#define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C')\r
102\r
103typedef struct{\r
104 UINTN Signature;\r
105 EFI_PEI_SERVICES *PS; // Point to ServiceTableShadow\r
106 PEI_PPI_DATABASE PpiData;\r
107 UINTN FvCount;\r
108 PEI_CORE_FV_HANDLE Fv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
109 EFI_PEI_FILE_HANDLE CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
110 UINTN AprioriCount;\r
111 UINTN CurrentPeimFvCount;\r
112 UINTN CurrentPeimCount;\r
113 EFI_PEI_FILE_HANDLE CurrentFileHandle;\r
114 UINTN AllFvCount;\r
115 EFI_PEI_FV_HANDLE AllFv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
116 EFI_PEI_HOB_POINTERS HobList;\r
117 BOOLEAN SwitchStackSignal;\r
118 BOOLEAN PeiMemoryInstalled;\r
119 EFI_PHYSICAL_ADDRESS StackBase;\r
120 UINT64 StackSize;\r
121 VOID *BottomOfCarHeap;\r
122 VOID *TopOfCarHeap;\r
123 VOID *CpuIo;\r
124 EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi;\r
125 EFI_PEI_SERVICES ServiceTableShadow;\r
126 UINTN SizeOfTemporaryMemory;\r
127 UINTN SizeOfCacheAsRam;\r
128 VOID *MaxTopOfCarHeap;\r
129 EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;\r
130 EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin;\r
131 UINT64 PhysicalMemoryLength;\r
132 EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop;\r
133 VOID* ShadowedPeiCore;\r
134 CACHE_SECTION_DATA CacheSection;\r
135} PEI_CORE_INSTANCE;\r
136\r
137//\r
138// Pei Core Instance Data Macros\r
139//\r
140\r
141#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \\r
142 CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)\r
143\r
144typedef\r
145EFI_STATUS\r
146(EFIAPI *PEI_CORE_ENTRY_POINT)(\r
147 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
148 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
149 IN PEI_CORE_INSTANCE *OldCoreData\r
150 );\r
151\r
152///\r
153/// Union of temporarily used function pointers (to save stack space)\r
154///\r
155typedef union {\r
156 PEI_CORE_ENTRY_POINT PeiCore;\r
157 EFI_PEIM_ENTRY_POINT2 PeimEntry;\r
158 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;\r
159 EFI_DXE_IPL_PPI *DxeIpl;\r
160 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
161 EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;\r
162 VOID *Raw;\r
163} PEI_CORE_TEMP_POINTERS;\r
164\r
165\r
166\r
167typedef struct {\r
168 CONST EFI_SEC_PEI_HAND_OFF *SecCoreData;\r
169 EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
170 VOID *Data;\r
171} PEI_CORE_PARAMETERS;\r
172\r
173//\r
174// PeiCore function\r
175//\r
176/**\r
177\r
178 The entry routine to Pei Core, invoked by PeiMain during transition\r
179 from SEC to PEI. After switching stack in the PEI core, it will restart\r
180 with the old core data.\r
181\r
182\r
183 @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
184 environment, such as the size and location of temporary RAM, the stack location and\r
185 the BFV location.\r
186 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
187 An empty PPI list consists of a single descriptor with the end-tag\r
188 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
189 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
190 that both the PEI Foundation and any modules can leverage the associated service\r
191 calls and/or code in these early PPIs\r
192 @param Data Pointer to old core data that is used to initialize the\r
193 core's data areas.\r
194\r
195 @retval EFI_NOT_FOUND Never reach\r
196\r
197**/\r
198EFI_STATUS\r
199EFIAPI\r
200PeiCore (\r
201 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
202 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList,\r
203 IN VOID *Data\r
204 )\r
205;\r
206\r
207//\r
208// Dispatcher support functions\r
209//\r
210\r
211/**\r
212\r
213 This is the POSTFIX version of the dependency evaluator. When a\r
214 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on\r
215 the evaluation stack. When that entry is poped from the evaluation\r
216 stack, the PPI is checked if it is installed. This method allows\r
217 some time savings as not all PPIs must be checked for certain\r
218 operation types (AND, OR).\r
219\r
220\r
221 @param PeiServices Calling context.\r
222 @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to\r
223 the BNF described above and is stored in postfix notation.\r
224\r
225 @retval TRUE if it is a well-formed Grammar\r
226 @retval FALSE if the dependency expression overflows the evaluation stack\r
227 if the dependency expression underflows the evaluation stack\r
228 if the dependency expression is not a well-formed Grammar.\r
229\r
230**/\r
231BOOLEAN\r
232PeimDispatchReadiness (\r
233 IN EFI_PEI_SERVICES **PeiServices,\r
234 IN VOID *DependencyExpression\r
235 )\r
236;\r
237\r
238/**\r
239 Conduct PEIM dispatch.\r
240\r
241 @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
242 environment, such as the size and location of temporary RAM, the stack location and\r
243 the BFV location.\r
244 PrivateData - Pointer to the private data passed in from caller\r
245 DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.\r
246 @param Private EDES_TODO: Add parameter description\r
247\r
248 @retval EFI_SUCCESS Successfully dispatched PEIM.\r
249 @retval EFI_NOT_FOUND The dispatch failed.\r
250\r
251**/\r
252VOID\r
253PeiDispatcher (\r
254 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
255 IN PEI_CORE_INSTANCE *PrivateData\r
256 )\r
257;\r
258\r
259/**\r
260 Initialize the Dispatcher's data members\r
261\r
262 @param PrivateData PeiCore's private data structure\r
263 @param OldCoreData Old data from SecCore\r
264 NULL if being run in non-permament memory mode.\r
265 @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
266 environment, such as the size and location of temporary RAM, the stack location and\r
267 the BFV location.\r
268\r
269 @return None.\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\r
309 @param PrivateData Pointer to the PEI Core data.\r
310 @param OldCoreData Pointer to old PEI Core data. \r
311 NULL if being run in non-permament memory mode.\r
312\r
313**/\r
314VOID\r
315InitializePpiServices (\r
316 IN PEI_CORE_INSTANCE *PrivateData,\r
317 IN PEI_CORE_INSTANCE *OldCoreData\r
318 )\r
319;\r
320\r
321/**\r
322\r
323 Migrate the Hob list from the CAR stack to PEI installed memory.\r
324\r
325 @param PeiServices The PEI core services table.\r
326 @param OldCheckingBottom The old checking bottom.\r
327 @param OldCheckingTop The old checking top.\r
328 @param NewHandOffHob The new handoff HOB list.\r
329\r
330**/\r
331VOID\r
332ConvertPpiPointers (\r
333 IN CONST EFI_PEI_SERVICES **PeiServices,\r
334 IN UINTN OldCheckingBottom,\r
335 IN UINTN OldCheckingTop,\r
336 IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob\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\r
515 @param PeiServices - The PEI core services table.\r
516 @param OldCoreData - Pointer to the old core data.\r
517 NULL if being run in non-permament memory mode.\r
518\r
519**/\r
520VOID\r
521InitializeSecurityServices (\r
522 IN EFI_PEI_SERVICES **PeiServices,\r
523 IN PEI_CORE_INSTANCE *OldCoreData\r
524 )\r
525;\r
526\r
527/**\r
528 Verify a Firmware volume\r
529\r
530 @param CurrentFvAddress - Pointer to the current Firmware Volume under consideration\r
531\r
532 @retval EFI_SUCCESS - Firmware Volume is legal\r
533 @retval EFI_SECURITY_VIOLATION - Firmware Volume fails integrity test\r
534\r
535**/\r
536EFI_STATUS\r
537VerifyFv (\r
538 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
539 )\r
540;\r
541\r
542/**\r
543\r
544 Provide a callout to the security verification service.\r
545\r
546\r
547 @param PrivateData PeiCore's private data structure\r
548 @param VolumeHandle Handle of FV\r
549 @param FileHandle Handle of PEIM's ffs\r
550\r
551 @retval EFI_SUCCESS Image is OK\r
552 @retval EFI_SECURITY_VIOLATION Image is illegal\r
553\r
554**/\r
555EFI_STATUS\r
556VerifyPeim (\r
557 IN PEI_CORE_INSTANCE *PrivateData,\r
558 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
559 IN EFI_PEI_FILE_HANDLE FileHandle\r
560 )\r
561;\r
562\r
563/**\r
564\r
565 Gets the pointer to the HOB List.\r
566\r
567\r
568 @param PeiServices The PEI core services table.\r
569 @param HobList Pointer to the HOB List.\r
570\r
571 @retval EFI_SUCCESS Get the pointer of HOB List\r
572 @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published\r
573 @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode)\r
574\r
575**/\r
576EFI_STATUS\r
577EFIAPI\r
578PeiGetHobList (\r
579 IN CONST EFI_PEI_SERVICES **PeiServices,\r
580 IN OUT VOID **HobList\r
581 )\r
582;\r
583\r
584/**\r
585 Add a new HOB to the HOB List.\r
586\r
587 @param PeiServices - The PEI core services table.\r
588 @param Type - Type of the new HOB.\r
589 @param Length - Length of the new HOB to allocate.\r
590 @param Hob - Pointer to the new HOB.\r
591\r
592 @return EFI_SUCCESS Success to create hob.\r
593 @retval EFI_INVALID_PARAMETER if Hob is NULL\r
594 @retval EFI_NOT_AVAILABLE_YET if HobList is still not available.\r
595 @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.\r
596\r
597**/\r
598EFI_STATUS\r
599EFIAPI\r
600PeiCreateHob (\r
601 IN CONST EFI_PEI_SERVICES **PeiServices,\r
602 IN UINT16 Type,\r
603 IN UINT16 Length,\r
604 IN OUT VOID **Hob\r
605 )\r
606;\r
607\r
608/**\r
609\r
610 Builds a Handoff Information Table HOB\r
611\r
612 @param BootMode - Current Bootmode\r
613 @param MemoryBegin - Start Memory Address.\r
614 @param MemoryLength - Length of Memory.\r
615\r
616 @return EFI_SUCCESS Always success to initialize HOB.\r
617\r
618**/\r
619EFI_STATUS\r
620PeiCoreBuildHobHandoffInfoTable (\r
621 IN EFI_BOOT_MODE BootMode,\r
622 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
623 IN UINT64 MemoryLength\r
624 )\r
625;\r
626\r
627\r
628//\r
629// FFS Fw Volume support functions\r
630//\r
631/**\r
632 Given the input file pointer, search for the next matching file in the\r
633 FFS volume as defined by SearchType. The search starts from FileHeader inside\r
634 the Firmware Volume defined by FwVolHeader.\r
635\r
636\r
637 @param PeiServices Pointer to the PEI Core Services Table.\r
638 @param SearchType Filter to find only files of this type.\r
639 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
640 @param VolumeHandle Pointer to the FV header of the volume to search.\r
641 @param FileHandle Pointer to the current file from which to begin searching.\r
642 This pointer will be updated upon return to reflect the file found.\r
643 @retval EFI_NOT_FOUND No files matching the search criteria were found\r
644 @retval EFI_SUCCESS Success to find next file in given volume\r
645\r
646**/\r
647EFI_STATUS\r
648EFIAPI\r
649PeiFfsFindNextFile (\r
650 IN CONST EFI_PEI_SERVICES **PeiServices,\r
651 IN UINT8 SearchType,\r
652 IN EFI_PEI_FV_HANDLE FwVolHeader,\r
653 IN OUT EFI_PEI_FILE_HANDLE *FileHeader\r
654 )\r
655;\r
656\r
657/**\r
658 Given the input file pointer, search for the next matching section in the\r
659 FFS volume.\r
660\r
661\r
662 @param PeiServices Pointer to the PEI Core Services Table.\r
663 @param SectionType Filter to find only sections of this type.\r
664 @param FileHandle 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/**\r
683 search the firmware volumes by index\r
684\r
685 @param PeiServices The PEI core services table.\r
686 @param Instance Instance of FV to find\r
687 @param VolumeHandle Pointer to found Volume.\r
688\r
689 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL\r
690 @retval EFI_SUCCESS Firmware volume instance successfully found.\r
691\r
692**/\r
693EFI_STATUS\r
694EFIAPI\r
695PeiFvFindNextVolume (\r
696 IN CONST EFI_PEI_SERVICES **PeiServices,\r
697 IN UINTN Instance,\r
698 IN OUT EFI_PEI_FV_HANDLE *FwVolHeader\r
699 )\r
700;\r
701\r
702//\r
703// Memory support functions\r
704//\r
705/**\r
706\r
707 Initialize the memory services.\r
708\r
709\r
710 @param PrivateData Add parameter description\r
711 @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
712 environment, such as the size and location of temporary RAM, the stack location and\r
713 the BFV location.\r
714 @param OldCoreData Pointer to the PEI Core data.\r
715 NULL if being run in non-permament memory mode.\r
716\r
717**/\r
718VOID\r
719InitializeMemoryServices (\r
720 IN PEI_CORE_INSTANCE *PrivateData,\r
721 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
722 IN PEI_CORE_INSTANCE *OldCoreData\r
723 )\r
724;\r
725\r
726/**\r
727\r
728 Install the permanent memory is now available.\r
729 Creates HOB (PHIT and Stack).\r
730\r
731 @param PeiServices - The PEI core services table.\r
732 @param MemoryBegin - Start of memory address.\r
733 @param MemoryLength - Length of memory.\r
734\r
735 @return EFI_SUCCESS Always success.\r
736\r
737**/\r
738EFI_STATUS\r
739EFIAPI\r
740PeiInstallPeiMemory (\r
741 IN CONST EFI_PEI_SERVICES **PeiServices,\r
742 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
743 IN UINT64 MemoryLength\r
744 )\r
745;\r
746\r
747/**\r
748\r
749 Memory allocation service on permanent memory,\r
750 not usable prior to the memory installation.\r
751\r
752\r
753 @param PeiServices - The PEI core services table.\r
754 @param MemoryType - Type of memory to allocate.\r
755 @param Pages - Number of pages to allocate.\r
756 @param Memory - Pointer of memory allocated.\r
757\r
758 @retval EFI_SUCCESS The allocation was successful\r
759 @retval EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.\r
760 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available\r
761 @retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement\r
762 to allocate the number of pages.\r
763\r
764**/\r
765EFI_STATUS\r
766EFIAPI\r
767PeiAllocatePages (\r
768 IN CONST EFI_PEI_SERVICES **PeiServices,\r
769 IN EFI_MEMORY_TYPE MemoryType,\r
770 IN UINTN Pages,\r
771 OUT EFI_PHYSICAL_ADDRESS *Memory\r
772 )\r
773;\r
774\r
775/**\r
776\r
777 Memory allocation service on the CAR.\r
778\r
779\r
780 @param PeiServices - The PEI core services table.\r
781 @param Size - Amount of memory required\r
782 @param Buffer - Address of pointer to the buffer\r
783\r
784 @retval EFI_SUCCESS The allocation was successful\r
785 @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement\r
786 to allocate the requested size.\r
787\r
788**/\r
789EFI_STATUS\r
790EFIAPI\r
791PeiAllocatePool (\r
792 IN CONST EFI_PEI_SERVICES **PeiServices,\r
793 IN UINTN Size,\r
794 OUT VOID **Buffer\r
795 )\r
796;\r
797\r
798/**\r
799\r
800 Routine for load image file.\r
801\r
802\r
803 @param PeiServices - The PEI core services table.\r
804 @param FileHandle - Pointer to the FFS file header of the image.\r
805 @param EntryPoint - Pointer to entry point of specified image file for output.\r
806 @param AuthenticationState - Pointer to attestation authentication state of image.\r
807\r
808 @retval EFI_SUCCESS - Image is successfully loaded.\r
809 @retval EFI_NOT_FOUND - Fail to locate necessary PPI\r
810 @retval Others - Fail to load file.\r
811\r
812**/\r
813EFI_STATUS\r
814PeiLoadImage (\r
815 IN EFI_PEI_SERVICES **PeiServices,\r
816 IN EFI_PEI_FILE_HANDLE FileHandle,\r
817 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
818 OUT UINT32 *AuthenticationState\r
819 )\r
820;\r
821\r
822/**\r
823\r
824 Core version of the Status Code reporter\r
825\r
826\r
827 @param PeiServices The PEI core services table.\r
828 @param CodeType Type of Status Code.\r
829 @param Value Value to output for Status Code.\r
830 @param Instance Instance Number of this status code.\r
831 @param CallerId ID of the caller of this status code.\r
832 @param Data Optional data associated with this status code.\r
833\r
834 @retval EFI_SUCCESS if status code is successfully reported\r
835 @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed\r
836\r
837**/\r
838EFI_STATUS\r
839EFIAPI\r
840PeiReportStatusCode (\r
841 IN CONST EFI_PEI_SERVICES **PeiServices,\r
842 IN EFI_STATUS_CODE_TYPE CodeType,\r
843 IN EFI_STATUS_CODE_VALUE Value,\r
844 IN UINT32 Instance,\r
845 IN CONST EFI_GUID *CallerId,\r
846 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
847 )\r
848;\r
849\r
850/**\r
851\r
852 Core version of the Reset System\r
853\r
854\r
855 @param PeiServices - The PEI core services table.\r
856\r
857 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.\r
858 @retval EFI_DEVICE_ERROR Did not reset system.\r
859 Otherwise, resets the system.\r
860\r
861**/\r
862EFI_STATUS\r
863EFIAPI\r
864PeiResetSystem (\r
865 IN CONST EFI_PEI_SERVICES **PeiServices\r
866 )\r
867;\r
868\r
869/**\r
870\r
871 Initialize PeiCore Fv List.\r
872\r
873\r
874 @param PrivateData - Pointer to PEI_CORE_INSTANCE.\r
875 @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.\r
876\r
877 @return NONE\r
878\r
879**/\r
880VOID\r
881PeiInitializeFv (\r
882 IN PEI_CORE_INSTANCE *PrivateData,\r
883 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
884 )\r
885;\r
886\r
887/**\r
888 Process Firmware Volum Information once FvInfoPPI install.\r
889\r
890\r
891 @param PeiServices - General purpose services available to every PEIM.\r
892 @param NotifyDescriptor EDES_TODO: Add parameter description\r
893 @param Ppi EDES_TODO: Add parameter description\r
894\r
895 @retval EFI_SUCCESS if the interface could be successfully installed\r
896\r
897**/\r
898EFI_STATUS\r
899EFIAPI\r
900FirmwareVolmeInfoPpiNotifyCallback (\r
901 IN EFI_PEI_SERVICES **PeiServices,\r
902 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
903 IN VOID *Ppi\r
904 )\r
905;\r
906\r
907/**\r
908\r
909 Given the input VolumeHandle, search for the next matching name file.\r
910\r
911\r
912 @param FileName - File name to search.\r
913 @param VolumeHandle - The current FV to search.\r
914 @param FileHandle - Pointer to the file matching name in VolumeHandle.\r
915 - NULL if file not found\r
916\r
917 @return EFI_STATUS\r
918\r
919**/\r
920EFI_STATUS\r
921EFIAPI\r
922PeiFfsFindFileByName (\r
923 IN CONST EFI_GUID *FileName,\r
924 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
925 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
926 )\r
927;\r
928\r
929/**\r
930\r
931 Returns information about a specific file.\r
932\r
933\r
934 @param FileHandle - The handle to file.\r
935 @param FileInfo - Pointer to the file information.\r
936\r
937 @retval EFI_INVALID_PARAMETER Invalid FileHandle or FileInfo.\r
938 @retval EFI_SUCCESS Success to collect file info.\r
939\r
940**/\r
941EFI_STATUS\r
942EFIAPI\r
943PeiFfsGetFileInfo (\r
944 IN EFI_PEI_FILE_HANDLE FileHandle,\r
945 OUT EFI_FV_FILE_INFO *FileInfo\r
946 )\r
947;\r
948\r
949/**\r
950\r
951 Collect information of given Fv Volume.\r
952\r
953 @param VolumeHandle - The handle to Fv Volume.\r
954 @param VolumeInfo - The pointer to volume information.\r
955\r
956 @retval EFI_INVALID_PARAMETER VolumeInfo is NULL\r
957 @retval EFI_SUCCESS Success to collect fv info.\r
958**/\r
959EFI_STATUS\r
960EFIAPI\r
961PeiFfsGetVolumeInfo (\r
962 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
963 OUT EFI_FV_INFO *VolumeInfo\r
964 )\r
965;\r
966\r
967/**\r
968 This routine enable a PEIM to register itself to shadow when PEI Foundation\r
969 discovery permanent memory.\r
970\r
971 @param FileHandle File handle of a PEIM.\r
972\r
973 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.\r
974 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.\r
975 @retval EFI_SUCCESS Successfully to register itself.\r
976\r
977**/\r
978EFI_STATUS\r
979EFIAPI\r
980PeiRegisterForShadow (\r
981 IN EFI_PEI_FILE_HANDLE FileHandle\r
982 )\r
983;\r
984\r
985/**\r
986 Given the input file pointer, search for the next matching file in the\r
987 FFS volume as defined by SearchType. The search starts from FileHeader inside\r
988 the Firmware Volume defined by FwVolHeader.\r
989\r
990\r
991 @param FvHandle Pointer to the FV header of the volume to search\r
992 @param FileName File name\r
993 @param SearchType Filter to find only files of this type.\r
994 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
995 @param FileHandle This parameter must point to a valid FFS volume.\r
996 @param AprioriFile Pointer to AprioriFile image in this FV if has\r
997\r
998 @return EFI_NOT_FOUND No files matching the search criteria were found\r
999 @retval EFI_SUCCESS Success to search given file\r
1000\r
1001**/\r
1002EFI_STATUS\r
1003PeiFindFileEx (\r
1004 IN CONST EFI_PEI_FV_HANDLE FvHandle,\r
1005 IN CONST EFI_GUID *FileName, OPTIONAL\r
1006 IN EFI_FV_FILETYPE SearchType,\r
1007 IN OUT EFI_PEI_FILE_HANDLE *FileHandle,\r
1008 IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL\r
1009 )\r
1010;\r
1011\r
1012/**\r
1013\r
1014 Install Pei Load File PPI.\r
1015\r
1016\r
1017 @param PrivateData - Pointer to PEI_CORE_INSTANCE.\r
1018 @param OldCoreData - Pointer to PEI_CORE_INSTANCE.\r
1019\r
1020**/\r
1021VOID\r
1022InitializeImageServices (\r
1023 IN PEI_CORE_INSTANCE *PrivateData,\r
1024 IN PEI_CORE_INSTANCE *OldCoreData\r
1025 )\r
1026;\r
1027\r
1028/**\r
1029 Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
1030\r
1031 @param PeiServices Pointer to the PEI Core Services Table.\r
1032 @param FileHandle File handle of a Fv type file.\r
1033 @param AuthenticationState Pointer to attestation authentication state of image.\r
1034\r
1035\r
1036 @retval EFI_NOT_FOUND FV image can't be found.\r
1037 @retval EFI_SUCCESS Successfully to process it.\r
1038\r
1039**/\r
1040EFI_STATUS\r
1041ProcessFvFile (\r
1042 IN EFI_PEI_SERVICES **PeiServices,\r
1043 IN EFI_PEI_FILE_HANDLE FvFileHandle,\r
1044 OUT UINT32 *AuthenticationState\r
1045 );\r
1046\r
1047#endif\r