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