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