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