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