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