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