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