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