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