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