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