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