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