]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Pei/PeiMain.h
Change MAX_PPI_DESCRIPTORS to FixedPcd PcdPeiCoreMaxPpiSupported, the default value...
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
1 /** @file
2
3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 PeiMain.h
15
16 Abstract:
17
18 Definition of Pei Core Structures and Services
19
20 Revision History
21
22 **/
23
24 #ifndef _PEI_MAIN_H_
25 #define _PEI_MAIN_H_
26
27 #include <PiPei.h>
28 #include <Ppi/DxeIpl.h>
29 #include <Ppi/MemoryDiscovered.h>
30 #include <Ppi/StatusCode.h>
31 #include <Ppi/Reset.h>
32 #include <Ppi/FirmwareVolume.h>
33 #include <Ppi/FirmwareVolumeInfo.h>
34 #include <Ppi/Decompress.h>
35 #include <Ppi/GuidedSectionExtraction.h>
36 #include <Ppi/LoadFile.h>
37 #include <Ppi/Security2.h>
38 #include <Ppi/TemporaryRamSupport.h>
39 #include <Library/DebugLib.h>
40 #include <Library/PeiCoreEntryPoint.h>
41 #include <Library/BaseLib.h>
42 #include <Library/HobLib.h>
43 #include <Library/PerformanceLib.h>
44 #include <Library/PeiServicesLib.h>
45 #include <Library/ReportStatusCodeLib.h>
46 #include <Library/PeCoffLib.h>
47 #include <Library/PeCoffGetEntryPointLib.h>
48 #include <Library/BaseMemoryLib.h>
49 #include <Library/CacheMaintenanceLib.h>
50 #include <Library/TimerLib.h>
51 #include <Library/PcdLib.h>
52 #include <IndustryStandard/PeImage.h>
53 #include <Library/PeiServicesTablePointerLib.h>
54 #include <Library/MemoryAllocationLib.h>
55 #include <Library/PeiPiLib.h>
56 #include <Guid/FirmwareFileSystem2.h>
57 #include <Guid/AprioriFileName.h>
58
59 #define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE 0xff
60
61 //
62 // Pei Core private data structures
63 //
64 typedef union {
65 EFI_PEI_PPI_DESCRIPTOR *Ppi;
66 EFI_PEI_NOTIFY_DESCRIPTOR *Notify;
67 VOID *Raw;
68 } PEI_PPI_LIST_POINTERS;
69
70 typedef struct {
71 INTN PpiListEnd;
72 INTN NotifyListEnd;
73 INTN DispatchListEnd;
74 INTN LastDispatchedInstall;
75 INTN LastDispatchedNotify;
76 PEI_PPI_LIST_POINTERS PpiListPtrs[FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)];
77 } PEI_PPI_DATABASE;
78
79
80 //
81 // PEI_CORE_FV_HANDE.PeimState
82 // Do not change these values as there is code doing math to change states.
83 // Look for Private->Fv[FvCount].PeimState[PeimCount]++;
84 //
85 #define PEIM_STATE_NOT_DISPATCHED 0x00
86 #define PEIM_STATE_DISPATCHED 0x01
87 #define PEIM_STATE_REGISITER_FOR_SHADOW 0x02
88 #define PEIM_STATE_DONE 0x03
89
90 typedef struct {
91 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
92 UINT8 PeimState[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];
93 EFI_PEI_FILE_HANDLE FvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];
94 BOOLEAN ScanFv;
95 } PEI_CORE_FV_HANDLE;
96
97 #define CACHE_SETION_MAX_NUMBER 0x10
98 typedef struct {
99 EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];
100 VOID* SectionData[CACHE_SETION_MAX_NUMBER];
101 UINTN SectionSize[CACHE_SETION_MAX_NUMBER];
102 UINTN AllSectionCount;
103 UINTN SectionIndex;
104 } CACHE_SECTION_DATA;
105
106 //
107 // Pei Core private data structure instance
108 //
109
110 #define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C')
111
112 typedef struct{
113 UINTN Signature;
114 EFI_PEI_SERVICES *PS; // Point to ServiceTableShadow
115 PEI_PPI_DATABASE PpiData;
116 UINTN FvCount;
117 PEI_CORE_FV_HANDLE Fv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];
118 EFI_PEI_FILE_HANDLE CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];
119 UINTN AprioriCount;
120 UINTN CurrentPeimFvCount;
121 UINTN CurrentPeimCount;
122 EFI_PEI_FILE_HANDLE CurrentFileHandle;
123 UINTN AllFvCount;
124 EFI_PEI_FV_HANDLE AllFv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];
125 EFI_PEI_HOB_POINTERS HobList;
126 BOOLEAN SwitchStackSignal;
127 BOOLEAN PeiMemoryInstalled;
128 EFI_PHYSICAL_ADDRESS StackBase;
129 UINT64 StackSize;
130 VOID *BottomOfCarHeap;
131 VOID *TopOfCarHeap;
132 VOID *CpuIo;
133 EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi;
134 EFI_PEI_SERVICES ServiceTableShadow;
135 UINTN SizeOfTemporaryMemory;
136 UINTN SizeOfCacheAsRam;
137 VOID *MaxTopOfCarHeap;
138 EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;
139 EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin;
140 UINT64 PhysicalMemoryLength;
141 EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop;
142 VOID* ShadowedPeiCore;
143 CACHE_SECTION_DATA CacheSection;
144 } PEI_CORE_INSTANCE;
145
146 //
147 // Pei Core Instance Data Macros
148 //
149
150 #define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \
151 CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)
152
153 //
154 // BUGBUG: Where does this go really?
155 //
156 typedef
157 EFI_STATUS
158 (EFIAPI *PEI_CORE_ENTRY_POINT)(
159 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
160 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,
161 IN PEI_CORE_INSTANCE *OldCoreData
162 );
163
164 //
165 // Union of temporarily used function pointers (to save stack space)
166 //
167 typedef union {
168 PEI_CORE_ENTRY_POINT PeiCore;
169 EFI_PEIM_ENTRY_POINT2 PeimEntry;
170 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;
171 EFI_DXE_IPL_PPI *DxeIpl;
172 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
173 EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
174 VOID *Raw;
175 } PEI_CORE_TEMP_POINTERS;
176
177
178
179 typedef struct {
180 CONST EFI_SEC_PEI_HAND_OFF *SecCoreData;
181 EFI_PEI_PPI_DESCRIPTOR *PpiList;
182 VOID *Data;
183 } PEI_CORE_PARAMETERS;
184
185 //
186 // PeiCore function
187 //
188 EFI_STATUS
189 EFIAPI
190 PeiCore (
191 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
192 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList,
193 IN VOID *Data
194 )
195 /*++
196
197 Routine Description:
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 Arguments:
204
205 PeiStartupDescriptor - Information and services provided by SEC phase.
206 OldCoreData - Pointer to old core data that is used to initialize the
207 core's data areas.
208
209 Returns:
210
211 This function never returns
212 EFI_NOT_FOUND - Never reach
213
214 --*/
215 ;
216
217 //
218 // Dispatcher support functions
219 //
220
221 BOOLEAN
222 PeimDispatchReadiness (
223 IN EFI_PEI_SERVICES **PeiServices,
224 IN VOID *DependencyExpression
225 )
226 /*++
227
228 Routine Description:
229
230 This is the POSTFIX version of the dependency evaluator. When a
231 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on
232 the evaluation stack. When that entry is poped from the evaluation
233 stack, the PPI is checked if it is installed. This method allows
234 some time savings as not all PPIs must be checked for certain
235 operation types (AND, OR).
236
237 Arguments:
238
239 PeiServices - Calling context.
240
241 DependencyExpression - Pointer to a dependency expression. The Grammar adheres to
242 the BNF described above and is stored in postfix notation.
243
244 Returns:
245
246 Status = EFI_SUCCESS if it is a well-formed Grammar
247 EFI_INVALID_PARAMETER if the dependency expression overflows
248 the evaluation stack
249 EFI_INVALID_PARAMETER if the dependency expression underflows
250 the evaluation stack
251 EFI_INVALID_PARAMETER if the dependency expression is not a
252 well-formed Grammar.
253 --*/
254 ;
255
256
257 VOID
258 PeiDispatcher (
259 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
260 IN PEI_CORE_INSTANCE *PrivateData
261 )
262
263 /*++
264
265 Routine Description:
266
267 Conduct PEIM dispatch.
268
269 Arguments:
270
271 PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR
272 PrivateData - Pointer to the private data passed in from caller
273 DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.
274
275 Returns:
276
277 EFI_SUCCESS - Successfully dispatched PEIM.
278 EFI_NOT_FOUND - The dispatch failed.
279
280 --*/
281 ;
282
283
284 VOID
285 InitializeDispatcherData (
286 IN PEI_CORE_INSTANCE *PrivateData,
287 IN PEI_CORE_INSTANCE *OldCoreData,
288 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
289 )
290 /*++
291
292 Routine Description:
293
294 Initialize the Dispatcher's data members
295
296 Arguments:
297
298 PeiServices - The PEI core services table.
299 OldCoreData - Pointer to old core data (before switching stack).
300 NULL if being run in non-permament memory mode.
301 PeiStartupDescriptor - Information and services provided by SEC phase.
302
303
304 Returns:
305
306 None
307
308 --*/
309 ;
310
311
312 EFI_STATUS
313 FindNextPeim (
314 IN EFI_PEI_SERVICES **PeiServices,
315 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
316 IN OUT EFI_FFS_FILE_HEADER **PeimFileHeader
317 )
318 /*++
319
320 Routine Description:
321 Given the input file pointer, search for the next matching file in the
322 FFS volume. The search starts from FileHeader inside
323 the Firmware Volume defined by FwVolHeader.
324
325 Arguments:
326 PeiServices - Pointer to the PEI Core Services Table.
327
328 FwVolHeader - Pointer to the FV header of the volume to search.
329 This parameter must point to a valid FFS volume.
330
331 PeimFileHeader - Pointer to the current file from which to begin searching.
332 This pointer will be updated upon return to reflect the file found.
333
334 Returns:
335 EFI_NOT_FOUND - No files matching the search criteria were found
336 EFI_SUCCESS
337
338 --*/
339 ;
340
341 BOOLEAN
342 Dispatched (
343 IN UINT8 CurrentPeim,
344 IN UINT32 DispatchedPeimBitMap
345 )
346 /*++
347
348 Routine Description:
349
350 This routine checks to see if a particular PEIM has been dispatched during
351 the PEI core dispatch.
352
353 Arguments:
354 CurrentPeim - The PEIM/FV in the bit array to check.
355 DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
356
357 Returns:
358 TRUE if PEIM already dispatched
359 FALSE if not
360
361 --*/
362 ;
363
364 VOID
365 SetDispatched (
366 IN EFI_PEI_SERVICES **PeiServices,
367 IN UINT8 CurrentPeim,
368 OUT UINT32 *DispatchedPeimBitMap
369 )
370 /*++
371
372 Routine Description:
373
374 This routine sets a PEIM as having been dispatched once its entry
375 point has been invoked.
376
377 Arguments:
378
379 PeiServices - The PEI core services table.
380 CurrentPeim - The PEIM/FV in the bit array to check.
381 DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
382
383 Returns:
384 None
385
386 --*/
387 ;
388
389 BOOLEAN
390 DepexSatisfied (
391 IN PEI_CORE_INSTANCE *Private,
392 IN EFI_PEI_FILE_HANDLE FileHandle,
393 IN UINTN PeimCount
394 )
395 /*++
396
397 Routine Description:
398
399 This routine parses the Dependency Expression, if available, and
400 decides if the module can be executed.
401
402 Arguments:
403 PeiServices - The PEI Service Table
404 CurrentPeimAddress - Address of the PEIM Firmware File under investigation
405
406 Returns:
407 TRUE - Can be dispatched
408 FALSE - Cannot be dispatched
409
410 --*/
411 ;
412
413 //
414 // PPI support functions
415 //
416 VOID
417 InitializePpiServices (
418 IN PEI_CORE_INSTANCE *PrivateData,
419 IN PEI_CORE_INSTANCE *OldCoreData
420 )
421 /*++
422
423 Routine Description:
424
425 Initialize PPI services.
426
427 Arguments:
428
429 PeiServices - The PEI core services table.
430 OldCoreData - Pointer to the PEI Core data.
431 NULL if being run in non-permament memory mode.
432
433 Returns:
434 Nothing
435
436 --*/
437 ;
438
439 VOID
440 ConvertPpiPointers (
441 IN CONST EFI_PEI_SERVICES **PeiServices,
442 IN UINTN OldCheckingBottom,
443 IN UINTN OldCheckingTop,
444 IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob
445 )
446 /*++
447
448 Routine Description:
449
450 Migrate the Hob list from the CAR stack to PEI installed memory.
451
452 Arguments:
453
454 PeiServices - The PEI core services table.
455 OldCheckingBottom - The old checking bottom.
456 OldCheckingTop - The old checking top.
457 NewHandOffHob - The new handoff HOB list.
458
459 Returns:
460
461 --*/
462 ;
463
464 EFI_STATUS
465 EFIAPI
466 PeiInstallPpi (
467 IN CONST EFI_PEI_SERVICES **PeiServices,
468 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
469 )
470 /*++
471
472 Routine Description:
473
474 Install PPI services.
475
476 Arguments:
477
478 PeiServices - Pointer to the PEI Service Table
479 PpiList - Pointer to a list of PEI PPI Descriptors.
480
481 Returns:
482
483 EFI_SUCCESS - if all PPIs in PpiList are successfully installed.
484 EFI_INVALID_PARAMETER - if PpiList is NULL pointer
485 EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid
486 EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI
487
488 --*/
489 ;
490
491 EFI_STATUS
492 EFIAPI
493 PeiReInstallPpi (
494 IN CONST EFI_PEI_SERVICES **PeiServices,
495 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
496 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
497 )
498 /*++
499
500 Routine Description:
501
502 Re-Install PPI services.
503
504 Arguments:
505
506 PeiServices - Pointer to the PEI Service Table
507 OldPpi - Pointer to the old PEI PPI Descriptors.
508 NewPpi - Pointer to the new PEI PPI Descriptors.
509
510 Returns:
511
512 EFI_SUCCESS - if the operation was successful
513 EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL
514 EFI_INVALID_PARAMETER - if NewPpi is not valid
515 EFI_NOT_FOUND - if the PPI was not in the database
516
517 --*/
518 ;
519
520 EFI_STATUS
521 EFIAPI
522 PeiLocatePpi (
523 IN CONST EFI_PEI_SERVICES **PeiServices,
524 IN CONST EFI_GUID *Guid,
525 IN UINTN Instance,
526 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
527 IN OUT VOID **Ppi
528 )
529 /*++
530
531 Routine Description:
532
533 Locate a given named PPI.
534
535 Arguments:
536
537 PeiServices - Pointer to the PEI Service Table
538 Guid - Pointer to GUID of the PPI.
539 Instance - Instance Number to discover.
540 PpiDescriptor - Pointer to reference the found descriptor. If not NULL,
541 returns a pointer to the descriptor (includes flags, etc)
542 Ppi - Pointer to reference the found PPI
543
544 Returns:
545
546 Status - EFI_SUCCESS if the PPI is in the database
547 EFI_NOT_FOUND if the PPI is not in the database
548 --*/
549 ;
550
551 EFI_STATUS
552 EFIAPI
553 PeiNotifyPpi (
554 IN CONST EFI_PEI_SERVICES **PeiServices,
555 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
556 )
557 /*++
558
559 Routine Description:
560
561 Install a notification for a given PPI.
562
563 Arguments:
564
565 PeiServices - Pointer to the PEI Service Table
566 NotifyList - Pointer to list of Descriptors to notify upon.
567
568 Returns:
569
570 Status - EFI_SUCCESS if successful
571 EFI_OUT_OF_RESOURCES if no space in the database
572 EFI_INVALID_PARAMETER if not a good decriptor
573
574 --*/
575 ;
576
577 VOID
578 ProcessNotifyList (
579 IN PEI_CORE_INSTANCE *PrivateData
580 )
581 /*++
582
583 Routine Description:
584
585 Process the Notify List at dispatch level.
586
587 Arguments:
588
589 PeiServices - Pointer to the PEI Service Table
590
591 Returns:
592
593 --*/
594 ;
595
596 VOID
597 DispatchNotify (
598 IN PEI_CORE_INSTANCE *PrivateData,
599 IN UINTN NotifyType,
600 IN INTN InstallStartIndex,
601 IN INTN InstallStopIndex,
602 IN INTN NotifyStartIndex,
603 IN INTN NotifyStopIndex
604 )
605 /*++
606
607 Routine Description:
608
609 Dispatch notifications.
610
611 Arguments:
612
613 PeiServices - Pointer to the PEI Service Table
614 NotifyType - Type of notify to fire.
615 InstallStartIndex - Install Beginning index.
616 InstallStopIndex - Install Ending index.
617 NotifyStartIndex - Notify Beginning index.
618 NotifyStopIndex - Notify Ending index.
619
620 Returns: None
621
622 --*/
623 ;
624
625 //
626 // Boot mode support functions
627 //
628 EFI_STATUS
629 EFIAPI
630 PeiGetBootMode (
631 IN CONST EFI_PEI_SERVICES **PeiServices,
632 IN OUT EFI_BOOT_MODE *BootMode
633 )
634 /*++
635
636 Routine Description:
637
638 This service enables PEIMs to ascertain the present value of the boot mode.
639
640 Arguments:
641
642 PeiServices - The PEI core services table.
643 BootMode - A pointer to contain the value of the boot mode.
644
645 Returns:
646
647 EFI_SUCCESS - The boot mode was returned successfully.
648 EFI_INVALID_PARAMETER - BootMode is NULL.
649
650 --*/
651 ;
652
653 EFI_STATUS
654 EFIAPI
655 PeiSetBootMode (
656 IN CONST EFI_PEI_SERVICES **PeiServices,
657 IN EFI_BOOT_MODE BootMode
658 )
659 /*++
660
661 Routine Description:
662
663 This service enables PEIMs to update the boot mode variable.
664
665 Arguments:
666
667 PeiServices - The PEI core services table.
668 BootMode - The value of the boot mode to set.
669
670 Returns:
671
672 EFI_SUCCESS - The value was successfully updated
673
674 --*/
675 ;
676
677 //
678 // Security support functions
679 //
680 VOID
681 InitializeSecurityServices (
682 IN EFI_PEI_SERVICES **PeiServices,
683 IN PEI_CORE_INSTANCE *OldCoreData
684 )
685 /*++
686
687 Routine Description:
688
689 Initialize the security services.
690
691 Arguments:
692
693 PeiServices - The PEI core services table.
694 OldCoreData - Pointer to the old core data.
695 NULL if being run in non-permament memory mode.
696 Returns:
697
698 None
699
700 --*/
701 ;
702
703 EFI_STATUS
704 VerifyFv (
705 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress
706 )
707 /*++
708
709 Routine Description:
710
711 Provide a callout to the OEM FV verification service.
712
713 Arguments:
714
715 CurrentFvAddress - Pointer to the FV under investigation.
716
717 Returns:
718
719 Status - EFI_SUCCESS
720
721 --*/
722 ;
723
724
725 EFI_STATUS
726 VerifyPeim (
727 IN PEI_CORE_INSTANCE *PrivateData,
728 IN EFI_PEI_FV_HANDLE VolumeHandle,
729 IN EFI_PEI_FILE_HANDLE FileHandle
730 )
731 /*++
732
733 Routine Description:
734
735 Provide a callout to the security verification service.
736
737 Arguments:
738
739 PeiServices - The PEI core services table.
740 CurrentPeimAddress - Pointer to the Firmware File under investigation.
741
742 Returns:
743
744 EFI_SUCCESS - Image is OK
745 EFI_SECURITY_VIOLATION - Image is illegal
746
747 --*/
748 ;
749
750
751 EFI_STATUS
752 EFIAPI
753 PeiGetHobList (
754 IN CONST EFI_PEI_SERVICES **PeiServices,
755 IN OUT VOID **HobList
756 )
757 /*++
758
759 Routine Description:
760
761 Gets the pointer to the HOB List.
762
763 Arguments:
764
765 PeiServices - The PEI core services table.
766 HobList - Pointer to the HOB List.
767
768 Returns:
769
770 EFI_SUCCESS - Get the pointer of HOB List
771 EFI_NOT_AVAILABLE_YET - the HOB List is not yet published
772 EFI_INVALID_PARAMETER - HobList is NULL (in debug mode)
773
774 --*/
775 ;
776
777 EFI_STATUS
778 EFIAPI
779 PeiCreateHob (
780 IN CONST EFI_PEI_SERVICES **PeiServices,
781 IN UINT16 Type,
782 IN UINT16 Length,
783 IN OUT VOID **Hob
784 )
785 /*++
786
787 Routine Description:
788
789 Add a new HOB to the HOB List.
790
791 Arguments:
792
793 PeiServices - The PEI core services table.
794 Type - Type of the new HOB.
795 Length - Length of the new HOB to allocate.
796 Hob - Pointer to the new HOB.
797
798 Returns:
799
800 Status - EFI_SUCCESS
801 - EFI_INVALID_PARAMETER if Hob is NULL
802 - EFI_NOT_AVAILABLE_YET if HobList is still not available.
803 - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
804
805 --*/
806 ;
807
808 EFI_STATUS
809 PeiCoreBuildHobHandoffInfoTable (
810 IN EFI_BOOT_MODE BootMode,
811 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
812 IN UINT64 MemoryLength
813 )
814 /*++
815
816 Routine Description:
817
818 Builds a Handoff Information Table HOB
819
820 Arguments:
821
822 BootMode - Current Bootmode
823 MemoryBegin - Start Memory Address.
824 MemoryLength - Length of Memory.
825
826 Returns:
827
828 EFI_SUCCESS
829
830 --*/
831 ;
832
833
834 //
835 // FFS Fw Volume support functions
836 //
837 EFI_STATUS
838 EFIAPI
839 PeiFfsFindNextFile (
840 IN CONST EFI_PEI_SERVICES **PeiServices,
841 IN UINT8 SearchType,
842 IN EFI_PEI_FV_HANDLE FwVolHeader,
843 IN OUT EFI_PEI_FILE_HANDLE *FileHeader
844 )
845 /*++
846
847 Routine Description:
848 Given the input file pointer, search for the next matching file in the
849 FFS volume as defined by SearchType. The search starts from FileHeader inside
850 the Firmware Volume defined by FwVolHeader.
851
852 Arguments:
853 PeiServices - Pointer to the PEI Core Services Table.
854
855 SearchType - Filter to find only files of this type.
856 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
857
858 FwVolHeader - Pointer to the FV header of the volume to search.
859 This parameter must point to a valid FFS volume.
860
861 FileHeader - Pointer to the current file from which to begin searching.
862 This pointer will be updated upon return to reflect the file found.
863
864 Returns:
865 EFI_NOT_FOUND - No files matching the search criteria were found
866 EFI_SUCCESS
867
868 --*/
869 ;
870
871 EFI_STATUS
872 EFIAPI
873 PeiFfsFindSectionData (
874 IN CONST EFI_PEI_SERVICES **PeiServices,
875 IN EFI_SECTION_TYPE SectionType,
876 IN EFI_PEI_FILE_HANDLE FfsFileHeader,
877 IN OUT VOID **SectionData
878 )
879 /*++
880
881 Routine Description:
882 Given the input file pointer, search for the next matching section in the
883 FFS volume.
884
885 Arguments:
886 PeiServices - Pointer to the PEI Core Services Table.
887 SearchType - Filter to find only sections of this type.
888 FfsFileHeader - Pointer to the current file to search.
889 SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
890 - NULL if section not found
891
892 Returns:
893 EFI_NOT_FOUND - No files matching the search criteria were found
894 EFI_SUCCESS
895
896 --*/
897 ;
898
899 EFI_STATUS
900 EFIAPI
901 PeiFvFindNextVolume (
902 IN CONST EFI_PEI_SERVICES **PeiServices,
903 IN UINTN Instance,
904 IN OUT EFI_PEI_FV_HANDLE *FwVolHeader
905 )
906 /*++
907
908 Routine Description:
909
910 Return the BFV location
911
912 BugBug -- Move this to the location of this code to where the
913 other FV and FFS support code lives.
914 Also, update to use FindFV for instances #'s >= 1.
915
916 Arguments:
917
918 PeiServices - The PEI core services table.
919 Instance - Instance of FV to find
920 FwVolHeader - Pointer to contain the data to return
921
922 Returns:
923 Pointer to the Firmware Volume instance requested
924
925 EFI_INVALID_PARAMETER - FwVolHeader is NULL
926
927 EFI_SUCCESS - Firmware volume instance successfully found.
928
929 --*/
930 ;
931
932 //
933 // Memory support functions
934 //
935 VOID
936 InitializeMemoryServices (
937 IN PEI_CORE_INSTANCE *PrivateData,
938 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
939 IN PEI_CORE_INSTANCE *OldCoreData
940 )
941 /*++
942
943 Routine Description:
944
945 Initialize the memory services.
946
947 Arguments:
948
949 PeiServices - The PEI core services table.
950 PeiStartupDescriptor - Information and services provided by SEC phase.
951 OldCoreData - Pointer to the PEI Core data.
952 NULL if being run in non-permament memory mode.
953
954 Returns:
955
956 None
957
958 --*/
959 ;
960
961 EFI_STATUS
962 EFIAPI
963 PeiInstallPeiMemory (
964 IN CONST EFI_PEI_SERVICES **PeiServices,
965 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
966 IN UINT64 MemoryLength
967 )
968 /*++
969
970 Routine Description:
971
972 Install the permanent memory is now available.
973 Creates HOB (PHIT and Stack).
974
975 Arguments:
976
977 PeiServices - The PEI core services table.
978 MemoryBegin - Start of memory address.
979 MemoryLength - Length of memory.
980
981 Returns:
982
983 Status - EFI_SUCCESS
984
985 --*/
986 ;
987
988 EFI_STATUS
989 EFIAPI
990 PeiAllocatePages (
991 IN CONST EFI_PEI_SERVICES **PeiServices,
992 IN EFI_MEMORY_TYPE MemoryType,
993 IN UINTN Pages,
994 OUT EFI_PHYSICAL_ADDRESS *Memory
995 )
996 /*++
997
998 Routine Description:
999
1000 Memory allocation service on permanent memory,
1001 not usable prior to the memory installation.
1002
1003 Arguments:
1004
1005 PeiServices - The PEI core services table.
1006 Type - Type of allocation.
1007 MemoryType - Type of memory to allocate.
1008 Pages - Number of pages to allocate.
1009 Memory - Pointer of memory allocated.
1010
1011 Returns:
1012
1013 Status - EFI_SUCCESS The allocation was successful
1014 EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.
1015 EFI_NOT_AVAILABLE_YET Called with permanent memory not available
1016 EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
1017 to allocate the number of pages.
1018
1019 --*/
1020 ;
1021
1022 EFI_STATUS
1023 EFIAPI
1024 PeiAllocatePool (
1025 IN CONST EFI_PEI_SERVICES **PeiServices,
1026 IN UINTN Size,
1027 OUT VOID **Buffer
1028 )
1029 /*++
1030
1031 Routine Description:
1032
1033 Memory allocation service on the CAR.
1034
1035 Arguments:
1036
1037 PeiServices - The PEI core services table.
1038
1039 Size - Amount of memory required
1040
1041 Buffer - Address of pointer to the buffer
1042
1043 Returns:
1044
1045 Status - EFI_SUCCESS The allocation was successful
1046 EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
1047 to allocate the requested size.
1048
1049 --*/
1050 ;
1051
1052 EFI_STATUS
1053 PeiLoadImage (
1054 IN EFI_PEI_SERVICES **PeiServices,
1055 IN EFI_PEI_FILE_HANDLE FileHandle,
1056 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
1057 OUT UINT32 *AuthenticationState
1058 )
1059 /*++
1060
1061 Routine Description:
1062
1063 Get entry point of a Peim file.
1064
1065 Arguments:
1066
1067 PeiServices - Calling context.
1068
1069 PeimFileHeader - Peim file's header.
1070
1071 EntryPoint - Entry point of that Peim file.
1072
1073 Returns:
1074
1075 Status code.
1076
1077 --*/
1078 ;
1079
1080
1081 EFI_STATUS
1082 EFIAPI
1083 PeiReportStatusCode (
1084 IN CONST EFI_PEI_SERVICES **PeiServices,
1085 IN EFI_STATUS_CODE_TYPE CodeType,
1086 IN EFI_STATUS_CODE_VALUE Value,
1087 IN UINT32 Instance,
1088 IN CONST EFI_GUID *CallerId,
1089 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
1090 )
1091 /*++
1092
1093 Routine Description:
1094
1095 Core version of the Status Code reporter
1096
1097 Arguments:
1098
1099 PeiServices - The PEI core services table.
1100
1101 CodeType - Type of Status Code.
1102
1103 Value - Value to output for Status Code.
1104
1105 Instance - Instance Number of this status code.
1106
1107 CallerId - ID of the caller of this status code.
1108
1109 Data - Optional data associated with this status code.
1110
1111 Returns:
1112
1113 Status - EFI_SUCCESS if status code is successfully reported
1114 - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed
1115
1116 --*/
1117 ;
1118
1119
1120 EFI_STATUS
1121 EFIAPI
1122 PeiResetSystem (
1123 IN CONST EFI_PEI_SERVICES **PeiServices
1124 )
1125 /*++
1126
1127 Routine Description:
1128
1129 Core version of the Reset System
1130
1131 Arguments:
1132
1133 PeiServices - The PEI core services table.
1134
1135 Returns:
1136
1137 Status - EFI_NOT_AVAILABLE_YET. PPI not available yet.
1138 - EFI_DEVICE_ERROR. Did not reset system.
1139
1140 Otherwise, resets the system.
1141
1142 --*/
1143 ;
1144
1145 VOID
1146 PeiInitializeFv (
1147 IN PEI_CORE_INSTANCE *PrivateData,
1148 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
1149 )
1150 /*++
1151
1152 Routine Description:
1153
1154 Initialize PeiCore Fv List.
1155
1156 Arguments:
1157 PrivateData - Pointer to PEI_CORE_INSTANCE.
1158 SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.
1159
1160 Returns:
1161 NONE
1162
1163 --*/
1164 ;
1165
1166 EFI_STATUS
1167 EFIAPI
1168 FirmwareVolmeInfoPpiNotifyCallback (
1169 IN EFI_PEI_SERVICES **PeiServices,
1170 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
1171 IN VOID *Ppi
1172 )
1173 /*++
1174
1175 Routine Description:
1176
1177 Process Firmware Volum Information once FvInfoPPI install.
1178
1179 Arguments:
1180
1181 PeiServices - General purpose services available to every PEIM.
1182
1183 Returns:
1184
1185 Status - EFI_SUCCESS if the interface could be successfully
1186 installed
1187
1188 --*/
1189 ;
1190
1191
1192 EFI_STATUS
1193 EFIAPI
1194 PeiFfsFindFileByName (
1195 IN CONST EFI_GUID *FileName,
1196 IN EFI_PEI_FV_HANDLE VolumeHandle,
1197 OUT EFI_PEI_FILE_HANDLE *FileHandle
1198 )
1199 /*++
1200
1201 Routine Description:
1202
1203 Given the input VolumeHandle, search for the next matching name file.
1204
1205 Arguments:
1206
1207 FileName - File name to search.
1208 VolumeHandle - The current FV to search.
1209 FileHandle - Pointer to the file matching name in VolumeHandle.
1210 - NULL if file not found
1211 Returns:
1212 EFI_STATUS
1213
1214 --*/
1215 ;
1216
1217
1218 EFI_STATUS
1219 EFIAPI
1220 PeiFfsGetFileInfo (
1221 IN EFI_PEI_FILE_HANDLE FileHandle,
1222 OUT EFI_FV_FILE_INFO *FileInfo
1223 )
1224 /*++
1225
1226 Routine Description:
1227
1228 Collect information of given file.
1229
1230 Arguments:
1231 FileHandle - The handle to file.
1232 FileInfo - Pointer to the file information.
1233
1234 Returns:
1235 EFI_STATUS
1236
1237 --*/
1238 ;
1239
1240 EFI_STATUS
1241 EFIAPI
1242 PeiFfsGetVolumeInfo (
1243 IN EFI_PEI_FV_HANDLE VolumeHandle,
1244 OUT EFI_FV_INFO *VolumeInfo
1245 )
1246 /*++
1247
1248 Routine Description:
1249
1250 Collect information of given Fv Volume.
1251
1252 Arguments:
1253 VolumeHandle - The handle to Fv Volume.
1254 VolumeInfo - The pointer to volume information.
1255
1256 Returns:
1257 EFI_STATUS
1258
1259 --*/
1260 ;
1261
1262
1263 EFI_STATUS
1264 EFIAPI
1265 PeiRegisterForShadow (
1266 IN EFI_PEI_FILE_HANDLE FileHandle
1267 )
1268 /*++
1269
1270 Routine Description:
1271
1272 This routine enable a PEIM to register itself to shadow when PEI Foundation
1273 discovery permanent memory.
1274
1275 Arguments:
1276 FileHandle - File handle of a PEIM.
1277
1278 Returns:
1279 EFI_NOT_FOUND - The file handle doesn't point to PEIM itself.
1280 EFI_ALREADY_STARTED - Indicate that the PEIM has been registered itself.
1281 EFI_SUCCESS - Successfully to register itself.
1282
1283 --*/
1284 ;
1285
1286
1287 /**
1288 This routine enable a PEIM to register itself to shadow when PEI Foundation
1289 discovery permanent memory.
1290
1291 @param FileHandle File handle of a PEIM.
1292
1293 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.
1294 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.
1295 @retval EFI_SUCCESS Successfully to register itself.
1296
1297 **/
1298 EFI_STATUS
1299 EFIAPI
1300 PeiRegisterForShadow (
1301 IN EFI_PEI_FILE_HANDLE FileHandle
1302 )
1303 ;
1304
1305 EFI_STATUS
1306 PeiFindFileEx (
1307 IN CONST EFI_PEI_FV_HANDLE FvHandle,
1308 IN CONST EFI_GUID *FileName, OPTIONAL
1309 IN EFI_FV_FILETYPE SearchType,
1310 IN OUT EFI_PEI_FILE_HANDLE *FileHandle,
1311 IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL
1312 )
1313 /*++
1314
1315 Routine Description:
1316 Given the input file pointer, search for the next matching file in the
1317 FFS volume as defined by SearchType. The search starts from FileHeader inside
1318 the Firmware Volume defined by FwVolHeader.
1319
1320 Arguments:
1321 PeiServices - Pointer to the PEI Core Services Table.
1322 SearchType - Filter to find only files of this type.
1323 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
1324 FwVolHeader - Pointer to the FV header of the volume to search.
1325 This parameter must point to a valid FFS volume.
1326 FileHeader - Pointer to the current file from which to begin searching.
1327 This pointer will be updated upon return to reflect the file found.
1328 Flag - Indicator for if this is for PEI Dispath search
1329
1330 Returns:
1331 EFI_NOT_FOUND - No files matching the search criteria were found
1332 EFI_SUCCESS
1333
1334 --*/
1335 ;
1336
1337 VOID
1338 InitializeImageServices (
1339 IN PEI_CORE_INSTANCE *PrivateData,
1340 IN PEI_CORE_INSTANCE *OldCoreData
1341 )
1342 /*++
1343
1344 Routine Description:
1345
1346 Install Pei Load File PPI.
1347
1348 Arguments:
1349
1350 PrivateData - Pointer to PEI_CORE_INSTANCE.
1351 OldCoreData - Pointer to PEI_CORE_INSTANCE.
1352
1353 Returns:
1354
1355 NONE.
1356
1357 --*/
1358 ;
1359
1360 /**
1361 Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.
1362
1363 @param PeiServices Pointer to the PEI Core Services Table.
1364 @param FileHandle File handle of a Fv type file.
1365 @param AuthenticationState Pointer to attestation authentication state of image.
1366
1367
1368 @retval EFI_NOT_FOUND FV image can't be found.
1369 @retval EFI_SUCCESS Successfully to process it.
1370
1371 **/
1372 EFI_STATUS
1373 ProcessFvFile (
1374 IN EFI_PEI_SERVICES **PeiServices,
1375 IN EFI_PEI_FILE_HANDLE FvFileHandle,
1376 OUT UINT32 *AuthenticationState
1377 );
1378
1379 #endif