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