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