]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Pei/PeiMain.h
remove a redefinition to pass ICC build
[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 Fixup The address difference between\r
329 the new Hob list and old Hob list.\r
330\r
331**/\r
332VOID\r
333ConvertPpiPointers (\r
334 IN CONST EFI_PEI_SERVICES **PeiServices,\r
335 IN UINTN OldCheckingBottom,\r
336 IN UINTN OldCheckingTop,\r
337 IN UINTN Fixup\r
338 )\r
339;\r
340\r
341/**\r
342\r
343 Install PPI services.\r
344\r
345 @param PeiServices - Pointer to the PEI Service Table\r
346 @param PpiList - Pointer to a list of PEI PPI Descriptors.\r
347\r
348 @retval EFI_SUCCESS - if all PPIs in PpiList are successfully installed.\r
349 @retval EFI_INVALID_PARAMETER - if PpiList is NULL pointer\r
350 @retval EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid\r
351 @retval EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI\r
352\r
353**/\r
354EFI_STATUS\r
355EFIAPI\r
356PeiInstallPpi (\r
357 IN CONST EFI_PEI_SERVICES **PeiServices,\r
358 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
359 )\r
360;\r
361\r
362/**\r
363\r
364 Re-Install PPI services.\r
365\r
366 @param PeiServices - Pointer to the PEI Service Table\r
367 @param OldPpi - Pointer to the old PEI PPI Descriptors.\r
368 @param NewPpi - Pointer to the new PEI PPI Descriptors.\r
369\r
370 @retval EFI_SUCCESS - if the operation was successful\r
371 @retval EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL\r
372 @retval EFI_INVALID_PARAMETER - if NewPpi is not valid\r
373 @retval EFI_NOT_FOUND - if the PPI was not in the database\r
374\r
375**/\r
376EFI_STATUS\r
377EFIAPI\r
378PeiReInstallPpi (\r
379 IN CONST EFI_PEI_SERVICES **PeiServices,\r
380 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
381 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
382 )\r
383;\r
384\r
385/**\r
386\r
387 Locate a given named PPI.\r
388\r
389\r
390 @param PeiServices - Pointer to the PEI Service Table\r
391 @param Guid - Pointer to GUID of the PPI.\r
392 @param Instance - Instance Number to discover.\r
393 @param PpiDescriptor - Pointer to reference the found descriptor. If not NULL,\r
394 returns a pointer to the descriptor (includes flags, etc)\r
395 @param Ppi - Pointer to reference the found PPI\r
396\r
397 @retval EFI_SUCCESS if the PPI is in the database\r
398 @retval EFI_NOT_FOUND if the PPI is not in the database\r
399\r
400**/\r
401EFI_STATUS\r
402EFIAPI\r
403PeiLocatePpi (\r
404 IN CONST EFI_PEI_SERVICES **PeiServices,\r
405 IN CONST EFI_GUID *Guid,\r
406 IN UINTN Instance,\r
407 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
408 IN OUT VOID **Ppi\r
409 )\r
410;\r
411\r
412/**\r
413\r
414 Install a notification for a given PPI.\r
415\r
416\r
417 @param PeiServices - Pointer to the PEI Service Table\r
418 @param NotifyList - Pointer to list of Descriptors to notify upon.\r
419\r
420 @retval EFI_SUCCESS if successful\r
421 @retval EFI_OUT_OF_RESOURCES if no space in the database\r
422 @retval EFI_INVALID_PARAMETER if not a good decriptor\r
423\r
424**/\r
425EFI_STATUS\r
426EFIAPI\r
427PeiNotifyPpi (\r
428 IN CONST EFI_PEI_SERVICES **PeiServices,\r
429 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
430 )\r
431;\r
432\r
433/**\r
434\r
435 Process the Notify List at dispatch level.\r
436\r
437 @param PrivateData PeiCore's private data structure.\r
438\r
439**/\r
440VOID\r
441ProcessNotifyList (\r
442 IN PEI_CORE_INSTANCE *PrivateData\r
443 )\r
444;\r
445\r
446/**\r
447\r
448 Dispatch notifications.\r
449\r
450 @param PrivateData PeiCore's private data structure\r
451 @param NotifyType Type of notify to fire.\r
452 @param InstallStartIndex Install Beginning index.\r
453 @param InstallStopIndex Install Ending index.\r
454 @param NotifyStartIndex Notify Beginning index.\r
455 @param NotifyStopIndex Notify Ending index.\r
456\r
457**/\r
458VOID\r
459DispatchNotify (\r
460 IN PEI_CORE_INSTANCE *PrivateData,\r
461 IN UINTN NotifyType,\r
462 IN INTN InstallStartIndex,\r
463 IN INTN InstallStopIndex,\r
464 IN INTN NotifyStartIndex,\r
465 IN INTN NotifyStopIndex\r
466 )\r
467;\r
468\r
469//\r
470// Boot mode support functions\r
471//\r
472/**\r
473 This service enables PEIMs to ascertain the present value of the boot mode.\r
474\r
475 @param PeiServices The PEI core services table.\r
476 @param BootMode A pointer to contain the value of the boot mode.\r
477\r
478 @retval EFI_SUCCESS The boot mode was returned successfully.\r
479 @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
480\r
481**/\r
482EFI_STATUS\r
483EFIAPI\r
484PeiGetBootMode (\r
485 IN CONST EFI_PEI_SERVICES **PeiServices,\r
486 IN OUT EFI_BOOT_MODE *BootMode\r
487 )\r
488;\r
489\r
490/**\r
491 This service enables PEIMs to update the boot mode variable.\r
492\r
493\r
494 @param PeiServices - The PEI core services table.\r
495 @param BootMode - The value of the boot mode to set.\r
496\r
497 @return EFI_SUCCESS - The value was successfully updated\r
498\r
499**/\r
500EFI_STATUS\r
501EFIAPI\r
502PeiSetBootMode (\r
503 IN CONST EFI_PEI_SERVICES **PeiServices,\r
504 IN EFI_BOOT_MODE BootMode\r
505 )\r
506;\r
507\r
508//\r
509// Security support functions\r
510//\r
511/**\r
512\r
513 Initialize the security services.\r
514\r
515\r
516 @param PeiServices - The PEI core services table.\r
517 @param OldCoreData - Pointer to the old core data.\r
518 NULL if being run in non-permament memory mode.\r
519\r
520**/\r
521VOID\r
522InitializeSecurityServices (\r
523 IN EFI_PEI_SERVICES **PeiServices,\r
524 IN PEI_CORE_INSTANCE *OldCoreData\r
525 )\r
526;\r
527\r
528/**\r
529 Verify a Firmware volume\r
530\r
531 @param CurrentFvAddress - Pointer to the current Firmware Volume under consideration\r
532\r
533 @retval EFI_SUCCESS - Firmware Volume is legal\r
534 @retval EFI_SECURITY_VIOLATION - Firmware Volume fails integrity test\r
535\r
536**/\r
537EFI_STATUS\r
538VerifyFv (\r
539 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
540 )\r
541;\r
542\r
543/**\r
544\r
545 Provide a callout to the security verification service.\r
546\r
547\r
548 @param PrivateData PeiCore's private data structure\r
549 @param VolumeHandle Handle of FV\r
550 @param FileHandle Handle of PEIM's ffs\r
551\r
552 @retval EFI_SUCCESS Image is OK\r
553 @retval EFI_SECURITY_VIOLATION Image is illegal\r
554\r
555**/\r
556EFI_STATUS\r
557VerifyPeim (\r
558 IN PEI_CORE_INSTANCE *PrivateData,\r
559 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
560 IN EFI_PEI_FILE_HANDLE FileHandle\r
561 )\r
562;\r
563\r
564/**\r
565\r
566 Gets the pointer to the HOB List.\r
567\r
568\r
569 @param PeiServices The PEI core services table.\r
570 @param HobList Pointer to the HOB List.\r
571\r
572 @retval EFI_SUCCESS Get the pointer of HOB List\r
573 @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published\r
574 @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode)\r
575\r
576**/\r
577EFI_STATUS\r
578EFIAPI\r
579PeiGetHobList (\r
580 IN CONST EFI_PEI_SERVICES **PeiServices,\r
581 IN OUT VOID **HobList\r
582 )\r
583;\r
584\r
585/**\r
586 Add a new HOB to the HOB List.\r
587\r
588 @param PeiServices - The PEI core services table.\r
589 @param Type - Type of the new HOB.\r
590 @param Length - Length of the new HOB to allocate.\r
591 @param Hob - Pointer to the new HOB.\r
592\r
593 @return EFI_SUCCESS Success to create hob.\r
594 @retval EFI_INVALID_PARAMETER if Hob is NULL\r
595 @retval EFI_NOT_AVAILABLE_YET if HobList is still not available.\r
596 @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.\r
597\r
598**/\r
599EFI_STATUS\r
600EFIAPI\r
601PeiCreateHob (\r
602 IN CONST EFI_PEI_SERVICES **PeiServices,\r
603 IN UINT16 Type,\r
604 IN UINT16 Length,\r
605 IN OUT VOID **Hob\r
606 )\r
607;\r
608\r
609/**\r
610\r
611 Builds a Handoff Information Table HOB\r
612\r
613 @param BootMode - Current Bootmode\r
614 @param MemoryBegin - Start Memory Address.\r
615 @param MemoryLength - Length of Memory.\r
616\r
617 @return EFI_SUCCESS Always success to initialize HOB.\r
618\r
619**/\r
620EFI_STATUS\r
621PeiCoreBuildHobHandoffInfoTable (\r
622 IN EFI_BOOT_MODE BootMode,\r
623 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
624 IN UINT64 MemoryLength\r
625 )\r
626;\r
627\r
628\r
629//\r
630// FFS Fw Volume support functions\r
631//\r
632/**\r
633 Given the input file pointer, search for the next matching file in the\r
634 FFS volume as defined by SearchType. The search starts from FileHeader inside\r
635 the Firmware Volume defined by FwVolHeader.\r
636\r
637\r
638 @param PeiServices Pointer to the PEI Core Services Table.\r
639 @param SearchType Filter to find only files of this type.\r
640 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
641 @param VolumeHandle Pointer to the FV header of the volume to search.\r
642 @param FileHandle Pointer to the current file from which to begin searching.\r
643 This pointer will be updated upon return to reflect the file found.\r
644 @retval EFI_NOT_FOUND No files matching the search criteria were found\r
645 @retval EFI_SUCCESS Success to find next file in given volume\r
646\r
647**/\r
648EFI_STATUS\r
649EFIAPI\r
650PeiFfsFindNextFile (\r
651 IN CONST EFI_PEI_SERVICES **PeiServices,\r
652 IN UINT8 SearchType,\r
653 IN EFI_PEI_FV_HANDLE FwVolHeader,\r
654 IN OUT EFI_PEI_FILE_HANDLE *FileHeader\r
655 )\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\r
663 @param PeiServices Pointer to the PEI Core Services Table.\r
664 @param SectionType Filter to find only sections of this type.\r
665 @param FileHandle Pointer to the current file to search.\r
666 @param SectionData Pointer to the Section matching SectionType in FfsFileHeader.\r
667 NULL if section not found\r
668\r
669 @retval EFI_NOT_FOUND No files matching the search criteria were found\r
670 @retval EFI_SUCCESS Success to find section data in given file\r
671\r
672**/\r
673EFI_STATUS\r
674EFIAPI\r
675PeiFfsFindSectionData (\r
676 IN CONST EFI_PEI_SERVICES **PeiServices,\r
677 IN EFI_SECTION_TYPE SectionType,\r
678 IN EFI_PEI_FILE_HANDLE FfsFileHeader,\r
679 IN OUT VOID **SectionData\r
680 )\r
681;\r
682\r
683/**\r
684 search the firmware volumes by index\r
685\r
686 @param PeiServices The PEI core services table.\r
687 @param Instance Instance of FV to find\r
688 @param VolumeHandle Pointer to found Volume.\r
689\r
690 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL\r
691 @retval EFI_SUCCESS Firmware volume instance successfully found.\r
692\r
693**/\r
694EFI_STATUS\r
695EFIAPI\r
696PeiFvFindNextVolume (\r
697 IN CONST EFI_PEI_SERVICES **PeiServices,\r
698 IN UINTN Instance,\r
699 IN OUT EFI_PEI_FV_HANDLE *FwVolHeader\r
700 )\r
701;\r
702\r
703//\r
704// Memory support functions\r
705//\r
706/**\r
707\r
708 Initialize the memory services.\r
709\r
710\r
711 @param PrivateData Add parameter description\r
712 @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
713 environment, such as the size and location of temporary RAM, the stack location and\r
714 the BFV location.\r
715 @param OldCoreData Pointer to the PEI Core data.\r
716 NULL if being run in non-permament memory mode.\r
717\r
718**/\r
719VOID\r
720InitializeMemoryServices (\r
721 IN PEI_CORE_INSTANCE *PrivateData,\r
722 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
723 IN PEI_CORE_INSTANCE *OldCoreData\r
724 )\r
725;\r
726\r
727/**\r
728\r
729 Install the permanent memory is now available.\r
730 Creates HOB (PHIT and Stack).\r
731\r
732 @param PeiServices - The PEI core services table.\r
733 @param MemoryBegin - Start of memory address.\r
734 @param MemoryLength - Length of memory.\r
735\r
736 @return EFI_SUCCESS Always success.\r
737\r
738**/\r
739EFI_STATUS\r
740EFIAPI\r
741PeiInstallPeiMemory (\r
742 IN CONST EFI_PEI_SERVICES **PeiServices,\r
743 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
744 IN UINT64 MemoryLength\r
745 )\r
746;\r
747\r
748/**\r
749\r
750 Memory allocation service on permanent memory,\r
751 not usable prior to the memory installation.\r
752\r
753\r
754 @param PeiServices - The PEI core services table.\r
755 @param MemoryType - Type of memory to allocate.\r
756 @param Pages - Number of pages to allocate.\r
757 @param Memory - Pointer of memory allocated.\r
758\r
759 @retval EFI_SUCCESS The allocation was successful\r
760 @retval EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.\r
761 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available\r
762 @retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement\r
763 to allocate the number of pages.\r
764\r
765**/\r
766EFI_STATUS\r
767EFIAPI\r
768PeiAllocatePages (\r
769 IN CONST EFI_PEI_SERVICES **PeiServices,\r
770 IN EFI_MEMORY_TYPE MemoryType,\r
771 IN UINTN Pages,\r
772 OUT EFI_PHYSICAL_ADDRESS *Memory\r
773 )\r
774;\r
775\r
776/**\r
777\r
778 Memory allocation service on the CAR.\r
779\r
780\r
781 @param PeiServices - The PEI core services table.\r
782 @param Size - Amount of memory required\r
783 @param Buffer - Address of pointer to the buffer\r
784\r
785 @retval EFI_SUCCESS The allocation was successful\r
786 @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement\r
787 to allocate the requested size.\r
788\r
789**/\r
790EFI_STATUS\r
791EFIAPI\r
792PeiAllocatePool (\r
793 IN CONST EFI_PEI_SERVICES **PeiServices,\r
794 IN UINTN Size,\r
795 OUT VOID **Buffer\r
796 )\r
797;\r
798\r
799/**\r
800\r
801 Routine for load image file.\r
802\r
803\r
804 @param PeiServices - The PEI core services table.\r
805 @param FileHandle - Pointer to the FFS file header of the image.\r
806 @param EntryPoint - Pointer to entry point of specified image file for output.\r
807 @param AuthenticationState - Pointer to attestation authentication state of image.\r
808\r
809 @retval EFI_SUCCESS - Image is successfully loaded.\r
810 @retval EFI_NOT_FOUND - Fail to locate necessary PPI\r
811 @retval Others - Fail to load file.\r
812\r
813**/\r
814EFI_STATUS\r
815PeiLoadImage (\r
816 IN EFI_PEI_SERVICES **PeiServices,\r
817 IN EFI_PEI_FILE_HANDLE FileHandle,\r
818 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
819 OUT UINT32 *AuthenticationState\r
820 )\r
821;\r
822\r
823/**\r
824\r
825 Core version of the Status Code reporter\r
826\r
827\r
828 @param PeiServices The PEI core services table.\r
829 @param CodeType Type of Status Code.\r
830 @param Value Value to output for Status Code.\r
831 @param Instance Instance Number of this status code.\r
832 @param CallerId ID of the caller of this status code.\r
833 @param Data Optional data associated with this status code.\r
834\r
835 @retval EFI_SUCCESS if status code is successfully reported\r
836 @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed\r
837\r
838**/\r
839EFI_STATUS\r
840EFIAPI\r
841PeiReportStatusCode (\r
842 IN CONST EFI_PEI_SERVICES **PeiServices,\r
843 IN EFI_STATUS_CODE_TYPE CodeType,\r
844 IN EFI_STATUS_CODE_VALUE Value,\r
845 IN UINT32 Instance,\r
846 IN CONST EFI_GUID *CallerId,\r
847 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
848 )\r
849;\r
850\r
851/**\r
852\r
853 Core version of the Reset System\r
854\r
855\r
856 @param PeiServices - The PEI core services table.\r
857\r
858 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.\r
859 @retval EFI_DEVICE_ERROR Did not reset system.\r
860 Otherwise, resets the system.\r
861\r
862**/\r
863EFI_STATUS\r
864EFIAPI\r
865PeiResetSystem (\r
866 IN CONST EFI_PEI_SERVICES **PeiServices\r
867 )\r
868;\r
869\r
870/**\r
871\r
872 Initialize PeiCore Fv List.\r
873\r
874\r
875 @param PrivateData - Pointer to PEI_CORE_INSTANCE.\r
876 @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.\r
877\r
878 @return NONE\r
879\r
880**/\r
881VOID\r
882PeiInitializeFv (\r
883 IN PEI_CORE_INSTANCE *PrivateData,\r
884 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
885 )\r
886;\r
887\r
888/**\r
889 Process Firmware Volum Information once FvInfoPPI install.\r
890\r
891\r
892 @param PeiServices - General purpose services available to every PEIM.\r
893 @param NotifyDescriptor EDES_TODO: Add parameter description\r
894 @param Ppi EDES_TODO: Add parameter description\r
895\r
896 @retval EFI_SUCCESS if the interface could be successfully installed\r
897\r
898**/\r
899EFI_STATUS\r
900EFIAPI\r
901FirmwareVolmeInfoPpiNotifyCallback (\r
902 IN EFI_PEI_SERVICES **PeiServices,\r
903 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
904 IN VOID *Ppi\r
905 )\r
906;\r
907\r
908/**\r
909\r
910 Given the input VolumeHandle, search for the next matching name file.\r
911\r
912\r
913 @param FileName - File name to search.\r
914 @param VolumeHandle - The current FV to search.\r
915 @param FileHandle - Pointer to the file matching name in VolumeHandle.\r
916 - NULL if file not found\r
917\r
918 @return EFI_STATUS\r
919\r
920**/\r
921EFI_STATUS\r
922EFIAPI\r
923PeiFfsFindFileByName (\r
924 IN CONST EFI_GUID *FileName,\r
925 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
926 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
927 )\r
928;\r
929\r
930/**\r
931\r
932 Returns information about a specific file.\r
933\r
934\r
935 @param FileHandle - The handle to file.\r
936 @param FileInfo - Pointer to the file information.\r
937\r
938 @retval EFI_INVALID_PARAMETER Invalid FileHandle or FileInfo.\r
939 @retval EFI_SUCCESS Success to collect file info.\r
940\r
941**/\r
942EFI_STATUS\r
943EFIAPI\r
944PeiFfsGetFileInfo (\r
945 IN EFI_PEI_FILE_HANDLE FileHandle,\r
946 OUT EFI_FV_FILE_INFO *FileInfo\r
947 )\r
948;\r
949\r
950/**\r
951\r
952 Collect information of given Fv Volume.\r
953\r
954 @param VolumeHandle - The handle to Fv Volume.\r
955 @param VolumeInfo - The pointer to volume information.\r
956\r
957 @retval EFI_INVALID_PARAMETER VolumeInfo is NULL\r
958 @retval EFI_SUCCESS Success to collect fv info.\r
959**/\r
960EFI_STATUS\r
961EFIAPI\r
962PeiFfsGetVolumeInfo (\r
963 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
964 OUT EFI_FV_INFO *VolumeInfo\r
965 )\r
966;\r
967\r
968/**\r
969 This routine enable a PEIM to register itself to shadow when PEI Foundation\r
970 discovery permanent memory.\r
971\r
972 @param FileHandle File handle of a PEIM.\r
973\r
974 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.\r
975 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.\r
976 @retval EFI_SUCCESS Successfully to register itself.\r
977\r
978**/\r
979EFI_STATUS\r
980EFIAPI\r
981PeiRegisterForShadow (\r
982 IN EFI_PEI_FILE_HANDLE FileHandle\r
983 )\r
984;\r
985\r
986/**\r
987 Given the input file pointer, search for the next matching file in the\r
988 FFS volume as defined by SearchType. The search starts from FileHeader inside\r
989 the Firmware Volume defined by FwVolHeader.\r
990\r
991\r
992 @param FvHandle Pointer to the FV header of the volume to search\r
993 @param FileName File name\r
994 @param SearchType Filter to find only files of this type.\r
995 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
996 @param FileHandle This parameter must point to a valid FFS volume.\r
997 @param AprioriFile Pointer to AprioriFile image in this FV if has\r
998\r
999 @return EFI_NOT_FOUND No files matching the search criteria were found\r
1000 @retval EFI_SUCCESS Success to search given file\r
1001\r
1002**/\r
1003EFI_STATUS\r
1004PeiFindFileEx (\r
1005 IN CONST EFI_PEI_FV_HANDLE FvHandle,\r
1006 IN CONST EFI_GUID *FileName, OPTIONAL\r
1007 IN EFI_FV_FILETYPE SearchType,\r
1008 IN OUT EFI_PEI_FILE_HANDLE *FileHandle,\r
1009 IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL\r
1010 )\r
1011;\r
1012\r
1013/**\r
1014\r
1015 Install Pei Load File PPI.\r
1016\r
1017\r
1018 @param PrivateData - Pointer to PEI_CORE_INSTANCE.\r
1019 @param OldCoreData - Pointer to PEI_CORE_INSTANCE.\r
1020\r
1021**/\r
1022VOID\r
1023InitializeImageServices (\r
1024 IN PEI_CORE_INSTANCE *PrivateData,\r
1025 IN PEI_CORE_INSTANCE *OldCoreData\r
1026 )\r
1027;\r
1028\r
1029/**\r
1030 Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
1031\r
1032 @param PeiServices Pointer to the PEI Core Services Table.\r
1033 @param FileHandle File handle of a Fv type file.\r
1034 @param AuthenticationState Pointer to attestation authentication state of image.\r
1035\r
1036\r
1037 @retval EFI_NOT_FOUND FV image can't be found.\r
1038 @retval EFI_SUCCESS Successfully to process it.\r
1039\r
1040**/\r
1041EFI_STATUS\r
1042ProcessFvFile (\r
1043 IN EFI_PEI_SERVICES **PeiServices,\r
1044 IN EFI_PEI_FILE_HANDLE FvFileHandle,\r
1045 OUT UINT32 *AuthenticationState\r
1046 );\r
1047\r
1048#endif\r