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