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