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