]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Pei/PeiMain.h
Fix a bug:
[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 EFI_STATUS
303 FindNextPeim (
304 IN EFI_PEI_SERVICES **PeiServices,
305 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
306 IN OUT EFI_FFS_FILE_HEADER **PeimFileHeader
307 )
308 /*++
309
310 Routine Description:
311 Given the input file pointer, search for the next matching file in the
312 FFS volume. The search starts from FileHeader inside
313 the Firmware Volume defined by FwVolHeader.
314
315 Arguments:
316 PeiServices - Pointer to the PEI Core Services Table.
317
318 FwVolHeader - Pointer to the FV header of the volume to search.
319 This parameter must point to a valid FFS volume.
320
321 PeimFileHeader - Pointer to the current file from which to begin searching.
322 This pointer will be updated upon return to reflect the file found.
323
324 Returns:
325 EFI_NOT_FOUND - No files matching the search criteria were found
326 EFI_SUCCESS
327
328 --*/
329 ;
330
331 BOOLEAN
332 Dispatched (
333 IN UINT8 CurrentPeim,
334 IN UINT32 DispatchedPeimBitMap
335 )
336 /*++
337
338 Routine Description:
339
340 This routine checks to see if a particular PEIM has been dispatched during
341 the PEI core dispatch.
342
343 Arguments:
344 CurrentPeim - The PEIM/FV in the bit array to check.
345 DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
346
347 Returns:
348 TRUE if PEIM already dispatched
349 FALSE if not
350
351 --*/
352 ;
353
354 VOID
355 SetDispatched (
356 IN EFI_PEI_SERVICES **PeiServices,
357 IN UINT8 CurrentPeim,
358 OUT UINT32 *DispatchedPeimBitMap
359 )
360 /*++
361
362 Routine Description:
363
364 This routine sets a PEIM as having been dispatched once its entry
365 point has been invoked.
366
367 Arguments:
368
369 PeiServices - The PEI core services table.
370 CurrentPeim - The PEIM/FV in the bit array to check.
371 DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
372
373 Returns:
374 None
375
376 --*/
377 ;
378
379 BOOLEAN
380 DepexSatisfied (
381 IN PEI_CORE_INSTANCE *Private,
382 IN EFI_PEI_FILE_HANDLE FileHandle,
383 IN UINTN PeimCount
384 )
385 /*++
386
387 Routine Description:
388
389 This routine parses the Dependency Expression, if available, and
390 decides if the module can be executed.
391
392 Arguments:
393 PeiServices - The PEI Service Table
394 CurrentPeimAddress - Address of the PEIM Firmware File under investigation
395
396 Returns:
397 TRUE - Can be dispatched
398 FALSE - Cannot be dispatched
399
400 --*/
401 ;
402
403 #if defined (MDE_CPU_IPF)
404 //
405 // In Ipf we should make special changes for the PHIT pointers to support
406 // recovery boot in cache mode.
407 //
408 #define SWITCH_TO_CACHE_MODE(CoreData) SwitchToCacheMode(CoreData)
409 #define CACHE_MODE_ADDRESS_MASK 0x7FFFFFFFFFFFFFFFULL
410 VOID
411 SwitchToCacheMode (
412 IN PEI_CORE_INSTANCE *CoreData
413 )
414 /*++
415
416 Routine Description:
417
418 Switch the PHIT pointers to cache mode after InstallPeiMemory in CAR.
419
420 Arguments:
421
422 CoreData - The PEI core Private Data
423
424 Returns:
425
426 --*/
427 ;
428
429 #else
430
431 #define SWITCH_TO_CACHE_MODE(CoreData)
432
433 #endif
434
435 //
436 // PPI support functions
437 //
438 VOID
439 InitializePpiServices (
440 IN PEI_CORE_INSTANCE *PrivateData,
441 IN PEI_CORE_INSTANCE *OldCoreData
442 )
443 /*++
444
445 Routine Description:
446
447 Initialize PPI services.
448
449 Arguments:
450
451 PeiServices - The PEI core services table.
452 OldCoreData - Pointer to the PEI Core data.
453 NULL if being run in non-permament memory mode.
454
455 Returns:
456 Nothing
457
458 --*/
459 ;
460
461 VOID
462 ConvertPpiPointers (
463 IN CONST EFI_PEI_SERVICES **PeiServices,
464 IN EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffHob,
465 IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob
466 )
467 /*++
468
469 Routine Description:
470
471 Migrate the Hob list from the CAR stack to PEI installed memory.
472
473 Arguments:
474
475 PeiServices - The PEI core services table.
476 OldHandOffHob - The old handoff HOB list.
477 NewHandOffHob - The new handoff HOB list.
478
479 Returns:
480
481 --*/
482 ;
483
484 EFI_STATUS
485 EFIAPI
486 PeiInstallPpi (
487 IN CONST EFI_PEI_SERVICES **PeiServices,
488 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
489 )
490 /*++
491
492 Routine Description:
493
494 Install PPI services.
495
496 Arguments:
497
498 PeiServices - Pointer to the PEI Service Table
499 PpiList - Pointer to a list of PEI PPI Descriptors.
500
501 Returns:
502
503 EFI_SUCCESS - if all PPIs in PpiList are successfully installed.
504 EFI_INVALID_PARAMETER - if PpiList is NULL pointer
505 EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid
506 EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI
507
508 --*/
509 ;
510
511 EFI_STATUS
512 EFIAPI
513 PeiReInstallPpi (
514 IN CONST EFI_PEI_SERVICES **PeiServices,
515 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
516 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
517 )
518 /*++
519
520 Routine Description:
521
522 Re-Install PPI services.
523
524 Arguments:
525
526 PeiServices - Pointer to the PEI Service Table
527 OldPpi - Pointer to the old PEI PPI Descriptors.
528 NewPpi - Pointer to the new PEI PPI Descriptors.
529
530 Returns:
531
532 EFI_SUCCESS - if the operation was successful
533 EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL
534 EFI_INVALID_PARAMETER - if NewPpi is not valid
535 EFI_NOT_FOUND - if the PPI was not in the database
536
537 --*/
538 ;
539
540 EFI_STATUS
541 EFIAPI
542 PeiLocatePpi (
543 IN CONST EFI_PEI_SERVICES **PeiServices,
544 IN CONST EFI_GUID *Guid,
545 IN UINTN Instance,
546 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
547 IN OUT VOID **Ppi
548 )
549 /*++
550
551 Routine Description:
552
553 Locate a given named PPI.
554
555 Arguments:
556
557 PeiServices - Pointer to the PEI Service Table
558 Guid - Pointer to GUID of the PPI.
559 Instance - Instance Number to discover.
560 PpiDescriptor - Pointer to reference the found descriptor. If not NULL,
561 returns a pointer to the descriptor (includes flags, etc)
562 Ppi - Pointer to reference the found PPI
563
564 Returns:
565
566 Status - EFI_SUCCESS if the PPI is in the database
567 EFI_NOT_FOUND if the PPI is not in the database
568 --*/
569 ;
570
571 EFI_STATUS
572 EFIAPI
573 PeiNotifyPpi (
574 IN CONST EFI_PEI_SERVICES **PeiServices,
575 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
576 )
577 /*++
578
579 Routine Description:
580
581 Install a notification for a given PPI.
582
583 Arguments:
584
585 PeiServices - Pointer to the PEI Service Table
586 NotifyList - Pointer to list of Descriptors to notify upon.
587
588 Returns:
589
590 Status - EFI_SUCCESS if successful
591 EFI_OUT_OF_RESOURCES if no space in the database
592 EFI_INVALID_PARAMETER if not a good decriptor
593
594 --*/
595 ;
596
597 VOID
598 ProcessNotifyList (
599 IN PEI_CORE_INSTANCE *PrivateData
600 )
601 /*++
602
603 Routine Description:
604
605 Process the Notify List at dispatch level.
606
607 Arguments:
608
609 PeiServices - Pointer to the PEI Service Table
610
611 Returns:
612
613 --*/
614 ;
615
616 VOID
617 DispatchNotify (
618 IN PEI_CORE_INSTANCE *PrivateData,
619 IN UINTN NotifyType,
620 IN INTN InstallStartIndex,
621 IN INTN InstallStopIndex,
622 IN INTN NotifyStartIndex,
623 IN INTN NotifyStopIndex
624 )
625 /*++
626
627 Routine Description:
628
629 Dispatch notifications.
630
631 Arguments:
632
633 PeiServices - Pointer to the PEI Service Table
634 NotifyType - Type of notify to fire.
635 InstallStartIndex - Install Beginning index.
636 InstallStopIndex - Install Ending index.
637 NotifyStartIndex - Notify Beginning index.
638 NotifyStopIndex - Notify Ending index.
639
640 Returns: None
641
642 --*/
643 ;
644
645 //
646 // Boot mode support functions
647 //
648 EFI_STATUS
649 EFIAPI
650 PeiGetBootMode (
651 IN CONST EFI_PEI_SERVICES **PeiServices,
652 IN OUT EFI_BOOT_MODE *BootMode
653 )
654 /*++
655
656 Routine Description:
657
658 This service enables PEIMs to ascertain the present value of the boot mode.
659
660 Arguments:
661
662 PeiServices - The PEI core services table.
663 BootMode - A pointer to contain the value of the boot mode.
664
665 Returns:
666
667 EFI_SUCCESS - The boot mode was returned successfully.
668 EFI_INVALID_PARAMETER - BootMode is NULL.
669
670 --*/
671 ;
672
673 EFI_STATUS
674 EFIAPI
675 PeiSetBootMode (
676 IN CONST EFI_PEI_SERVICES **PeiServices,
677 IN EFI_BOOT_MODE BootMode
678 )
679 /*++
680
681 Routine Description:
682
683 This service enables PEIMs to update the boot mode variable.
684
685 Arguments:
686
687 PeiServices - The PEI core services table.
688 BootMode - The value of the boot mode to set.
689
690 Returns:
691
692 EFI_SUCCESS - The value was successfully updated
693
694 --*/
695 ;
696
697 //
698 // Security support functions
699 //
700 VOID
701 InitializeSecurityServices (
702 IN EFI_PEI_SERVICES **PeiServices,
703 IN PEI_CORE_INSTANCE *OldCoreData
704 )
705 /*++
706
707 Routine Description:
708
709 Initialize the security services.
710
711 Arguments:
712
713 PeiServices - The PEI core services table.
714 OldCoreData - Pointer to the old core data.
715 NULL if being run in non-permament memory mode.
716 Returns:
717
718 None
719
720 --*/
721 ;
722
723 EFI_STATUS
724 VerifyFv (
725 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress
726 )
727 /*++
728
729 Routine Description:
730
731 Provide a callout to the OEM FV verification service.
732
733 Arguments:
734
735 CurrentFvAddress - Pointer to the FV under investigation.
736
737 Returns:
738
739 Status - EFI_SUCCESS
740
741 --*/
742 ;
743
744
745 EFI_STATUS
746 VerifyPeim (
747 IN PEI_CORE_INSTANCE *PrivateData,
748 IN EFI_PEI_FV_HANDLE VolumeHandle,
749 IN EFI_PEI_FILE_HANDLE FileHandle
750 )
751 /*++
752
753 Routine Description:
754
755 Provide a callout to the security verification service.
756
757 Arguments:
758
759 PeiServices - The PEI core services table.
760 CurrentPeimAddress - Pointer to the Firmware File under investigation.
761
762 Returns:
763
764 EFI_SUCCESS - Image is OK
765 EFI_SECURITY_VIOLATION - Image is illegal
766
767 --*/
768 ;
769
770
771 EFI_STATUS
772 EFIAPI
773 PeiGetHobList (
774 IN CONST EFI_PEI_SERVICES **PeiServices,
775 IN OUT VOID **HobList
776 )
777 /*++
778
779 Routine Description:
780
781 Gets the pointer to the HOB List.
782
783 Arguments:
784
785 PeiServices - The PEI core services table.
786 HobList - Pointer to the HOB List.
787
788 Returns:
789
790 EFI_SUCCESS - Get the pointer of HOB List
791 EFI_NOT_AVAILABLE_YET - the HOB List is not yet published
792 EFI_INVALID_PARAMETER - HobList is NULL (in debug mode)
793
794 --*/
795 ;
796
797 EFI_STATUS
798 EFIAPI
799 PeiCreateHob (
800 IN CONST EFI_PEI_SERVICES **PeiServices,
801 IN UINT16 Type,
802 IN UINT16 Length,
803 IN OUT VOID **Hob
804 )
805 /*++
806
807 Routine Description:
808
809 Add a new HOB to the HOB List.
810
811 Arguments:
812
813 PeiServices - The PEI core services table.
814 Type - Type of the new HOB.
815 Length - Length of the new HOB to allocate.
816 Hob - Pointer to the new HOB.
817
818 Returns:
819
820 Status - EFI_SUCCESS
821 - EFI_INVALID_PARAMETER if Hob is NULL
822 - EFI_NOT_AVAILABLE_YET if HobList is still not available.
823 - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
824
825 --*/
826 ;
827
828 EFI_STATUS
829 PeiCoreBuildHobHandoffInfoTable (
830 IN EFI_BOOT_MODE BootMode,
831 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
832 IN UINT64 MemoryLength
833 )
834 /*++
835
836 Routine Description:
837
838 Builds a Handoff Information Table HOB
839
840 Arguments:
841
842 BootMode - Current Bootmode
843 MemoryBegin - Start Memory Address.
844 MemoryLength - Length of Memory.
845
846 Returns:
847
848 EFI_SUCCESS
849
850 --*/
851 ;
852
853
854 //
855 // FFS Fw Volume support functions
856 //
857 EFI_STATUS
858 EFIAPI
859 PeiFfsFindNextFile (
860 IN CONST EFI_PEI_SERVICES **PeiServices,
861 IN UINT8 SearchType,
862 IN EFI_PEI_FV_HANDLE FwVolHeader,
863 IN OUT EFI_PEI_FILE_HANDLE *FileHeader
864 )
865 /*++
866
867 Routine Description:
868 Given the input file pointer, search for the next matching file in the
869 FFS volume as defined by SearchType. The search starts from FileHeader inside
870 the Firmware Volume defined by FwVolHeader.
871
872 Arguments:
873 PeiServices - Pointer to the PEI Core Services Table.
874
875 SearchType - Filter to find only files of this type.
876 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
877
878 FwVolHeader - Pointer to the FV header of the volume to search.
879 This parameter must point to a valid FFS volume.
880
881 FileHeader - Pointer to the current file from which to begin searching.
882 This pointer will be updated upon return to reflect the file found.
883
884 Returns:
885 EFI_NOT_FOUND - No files matching the search criteria were found
886 EFI_SUCCESS
887
888 --*/
889 ;
890
891 EFI_STATUS
892 EFIAPI
893 PeiFfsFindSectionData (
894 IN CONST EFI_PEI_SERVICES **PeiServices,
895 IN EFI_SECTION_TYPE SectionType,
896 IN EFI_PEI_FILE_HANDLE FfsFileHeader,
897 IN OUT VOID **SectionData
898 )
899 /*++
900
901 Routine Description:
902 Given the input file pointer, search for the next matching section in the
903 FFS volume.
904
905 Arguments:
906 PeiServices - Pointer to the PEI Core Services Table.
907 SearchType - Filter to find only sections of this type.
908 FfsFileHeader - Pointer to the current file to search.
909 SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
910 - NULL if section not found
911
912 Returns:
913 EFI_NOT_FOUND - No files matching the search criteria were found
914 EFI_SUCCESS
915
916 --*/
917 ;
918
919 EFI_STATUS
920 EFIAPI
921 PeiFvFindNextVolume (
922 IN CONST EFI_PEI_SERVICES **PeiServices,
923 IN UINTN Instance,
924 IN OUT EFI_PEI_FV_HANDLE *FwVolHeader
925 )
926 /*++
927
928 Routine Description:
929
930 Return the BFV location
931
932 BugBug -- Move this to the location of this code to where the
933 other FV and FFS support code lives.
934 Also, update to use FindFV for instances #'s >= 1.
935
936 Arguments:
937
938 PeiServices - The PEI core services table.
939 Instance - Instance of FV to find
940 FwVolHeader - Pointer to contain the data to return
941
942 Returns:
943 Pointer to the Firmware Volume instance requested
944
945 EFI_INVALID_PARAMETER - FwVolHeader is NULL
946
947 EFI_SUCCESS - Firmware volume instance successfully found.
948
949 --*/
950 ;
951
952 //
953 // Memory support functions
954 //
955 VOID
956 InitializeMemoryServices (
957 IN PEI_CORE_INSTANCE *PrivateData,
958 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
959 IN PEI_CORE_INSTANCE *OldCoreData
960 )
961 /*++
962
963 Routine Description:
964
965 Initialize the memory services.
966
967 Arguments:
968
969 PeiServices - The PEI core services table.
970 PeiStartupDescriptor - Information and services provided by SEC phase.
971 OldCoreData - Pointer to the PEI Core data.
972 NULL if being run in non-permament memory mode.
973
974 Returns:
975
976 None
977
978 --*/
979 ;
980
981 EFI_STATUS
982 EFIAPI
983 PeiInstallPeiMemory (
984 IN CONST EFI_PEI_SERVICES **PeiServices,
985 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
986 IN UINT64 MemoryLength
987 )
988 /*++
989
990 Routine Description:
991
992 Install the permanent memory is now available.
993 Creates HOB (PHIT and Stack).
994
995 Arguments:
996
997 PeiServices - The PEI core services table.
998 MemoryBegin - Start of memory address.
999 MemoryLength - Length of memory.
1000
1001 Returns:
1002
1003 Status - EFI_SUCCESS
1004
1005 --*/
1006 ;
1007
1008 EFI_STATUS
1009 EFIAPI
1010 PeiAllocatePages (
1011 IN CONST EFI_PEI_SERVICES **PeiServices,
1012 IN EFI_MEMORY_TYPE MemoryType,
1013 IN UINTN Pages,
1014 OUT EFI_PHYSICAL_ADDRESS *Memory
1015 )
1016 /*++
1017
1018 Routine Description:
1019
1020 Memory allocation service on permanent memory,
1021 not usable prior to the memory installation.
1022
1023 Arguments:
1024
1025 PeiServices - The PEI core services table.
1026 Type - Type of allocation.
1027 MemoryType - Type of memory to allocate.
1028 Pages - Number of pages to allocate.
1029 Memory - Pointer of memory allocated.
1030
1031 Returns:
1032
1033 Status - EFI_SUCCESS The allocation was successful
1034 EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.
1035 EFI_NOT_AVAILABLE_YET Called with permanent memory not available
1036 EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
1037 to allocate the number of pages.
1038
1039 --*/
1040 ;
1041
1042 EFI_STATUS
1043 EFIAPI
1044 PeiAllocatePool (
1045 IN CONST EFI_PEI_SERVICES **PeiServices,
1046 IN UINTN Size,
1047 OUT VOID **Buffer
1048 )
1049 /*++
1050
1051 Routine Description:
1052
1053 Memory allocation service on the CAR.
1054
1055 Arguments:
1056
1057 PeiServices - The PEI core services table.
1058
1059 Size - Amount of memory required
1060
1061 Buffer - Address of pointer to the buffer
1062
1063 Returns:
1064
1065 Status - EFI_SUCCESS The allocation was successful
1066 EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
1067 to allocate the requested size.
1068
1069 --*/
1070 ;
1071
1072 EFI_STATUS
1073 PeiLoadImage (
1074 IN EFI_PEI_SERVICES **PeiServices,
1075 IN EFI_PEI_FILE_HANDLE FileHandle,
1076 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
1077 OUT UINT32 *AuthenticationState
1078 )
1079 /*++
1080
1081 Routine Description:
1082
1083 Get entry point of a Peim file.
1084
1085 Arguments:
1086
1087 PeiServices - Calling context.
1088
1089 PeimFileHeader - Peim file's header.
1090
1091 EntryPoint - Entry point of that Peim file.
1092
1093 Returns:
1094
1095 Status code.
1096
1097 --*/
1098 ;
1099
1100
1101 EFI_STATUS
1102 EFIAPI
1103 PeiReportStatusCode (
1104 IN CONST EFI_PEI_SERVICES **PeiServices,
1105 IN EFI_STATUS_CODE_TYPE CodeType,
1106 IN EFI_STATUS_CODE_VALUE Value,
1107 IN UINT32 Instance,
1108 IN CONST EFI_GUID *CallerId,
1109 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
1110 )
1111 /*++
1112
1113 Routine Description:
1114
1115 Core version of the Status Code reporter
1116
1117 Arguments:
1118
1119 PeiServices - The PEI core services table.
1120
1121 CodeType - Type of Status Code.
1122
1123 Value - Value to output for Status Code.
1124
1125 Instance - Instance Number of this status code.
1126
1127 CallerId - ID of the caller of this status code.
1128
1129 Data - Optional data associated with this status code.
1130
1131 Returns:
1132
1133 Status - EFI_SUCCESS if status code is successfully reported
1134 - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed
1135
1136 --*/
1137 ;
1138
1139
1140 EFI_STATUS
1141 EFIAPI
1142 PeiResetSystem (
1143 IN CONST EFI_PEI_SERVICES **PeiServices
1144 )
1145 /*++
1146
1147 Routine Description:
1148
1149 Core version of the Reset System
1150
1151 Arguments:
1152
1153 PeiServices - The PEI core services table.
1154
1155 Returns:
1156
1157 Status - EFI_NOT_AVAILABLE_YET. PPI not available yet.
1158 - EFI_DEVICE_ERROR. Did not reset system.
1159
1160 Otherwise, resets the system.
1161
1162 --*/
1163 ;
1164
1165 VOID
1166 PeiInitializeFv (
1167 IN PEI_CORE_INSTANCE *PrivateData,
1168 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData
1169 )
1170 /*++
1171
1172 Routine Description:
1173
1174 Initialize PeiCore Fv List.
1175
1176 Arguments:
1177 PrivateData - Pointer to PEI_CORE_INSTANCE.
1178 SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.
1179
1180 Returns:
1181 NONE
1182
1183 --*/
1184 ;
1185
1186 EFI_STATUS
1187 EFIAPI
1188 FirmwareVolmeInfoPpiNotifyCallback (
1189 IN EFI_PEI_SERVICES **PeiServices,
1190 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
1191 IN VOID *Ppi
1192 )
1193 /*++
1194
1195 Routine Description:
1196
1197 Process Firmware Volum Information once FvInfoPPI install.
1198
1199 Arguments:
1200
1201 PeiServices - General purpose services available to every PEIM.
1202
1203 Returns:
1204
1205 Status - EFI_SUCCESS if the interface could be successfully
1206 installed
1207
1208 --*/
1209 ;
1210
1211
1212 EFI_STATUS
1213 EFIAPI
1214 PeiFfsFindFileByName (
1215 IN CONST EFI_GUID *FileName,
1216 IN EFI_PEI_FV_HANDLE VolumeHandle,
1217 OUT EFI_PEI_FILE_HANDLE *FileHandle
1218 )
1219 /*++
1220
1221 Routine Description:
1222
1223 Given the input VolumeHandle, search for the next matching name file.
1224
1225 Arguments:
1226
1227 FileName - File name to search.
1228 VolumeHandle - The current FV to search.
1229 FileHandle - Pointer to the file matching name in VolumeHandle.
1230 - NULL if file not found
1231 Returns:
1232 EFI_STATUS
1233
1234 --*/
1235 ;
1236
1237
1238 EFI_STATUS
1239 EFIAPI
1240 PeiFfsGetFileInfo (
1241 IN EFI_PEI_FILE_HANDLE FileHandle,
1242 OUT EFI_FV_FILE_INFO *FileInfo
1243 )
1244 /*++
1245
1246 Routine Description:
1247
1248 Collect information of given file.
1249
1250 Arguments:
1251 FileHandle - The handle to file.
1252 FileInfo - Pointer to the file information.
1253
1254 Returns:
1255 EFI_STATUS
1256
1257 --*/
1258 ;
1259
1260 EFI_STATUS
1261 EFIAPI
1262 PeiFfsGetVolumeInfo (
1263 IN EFI_PEI_FV_HANDLE VolumeHandle,
1264 OUT EFI_FV_INFO *VolumeInfo
1265 )
1266 /*++
1267
1268 Routine Description:
1269
1270 Collect information of given Fv Volume.
1271
1272 Arguments:
1273 VolumeHandle - The handle to Fv Volume.
1274 VolumeInfo - The pointer to volume information.
1275
1276 Returns:
1277 EFI_STATUS
1278
1279 --*/
1280 ;
1281
1282
1283 EFI_STATUS
1284 EFIAPI
1285 PeiRegisterForShadow (
1286 IN EFI_PEI_FILE_HANDLE FileHandle
1287 )
1288 /*++
1289
1290 Routine Description:
1291
1292 This routine enable a PEIM to register itself to shadow when PEI Foundation
1293 discovery permanent memory.
1294
1295 Arguments:
1296 FileHandle - File handle of a PEIM.
1297
1298 Returns:
1299 EFI_NOT_FOUND - The file handle doesn't point to PEIM itself.
1300 EFI_ALREADY_STARTED - Indicate that the PEIM has been registered itself.
1301 EFI_SUCCESS - Successfully to register itself.
1302
1303 --*/
1304 ;
1305
1306
1307 /**
1308 This routine enable a PEIM to register itself to shadow when PEI Foundation
1309 discovery permanent memory.
1310
1311 @param FileHandle File handle of a PEIM.
1312
1313 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.
1314 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.
1315 @retval EFI_SUCCESS Successfully to register itself.
1316
1317 **/
1318 EFI_STATUS
1319 EFIAPI
1320 PeiRegisterForShadow (
1321 IN EFI_PEI_FILE_HANDLE FileHandle
1322 )
1323 ;
1324
1325 /**
1326 Transfers control to a function starting with a new stack.
1327
1328 Transfers control to the function specified by EntryPoint using the new stack
1329 specified by NewStack and passing in the parameters specified by Context1 and
1330 Context2. Context1 and Context2 are optional and may be NULL. The function
1331 EntryPoint must never return.
1332
1333 If EntryPoint is NULL, then ASSERT().
1334 If NewStack is NULL, then ASSERT().
1335
1336 @param EntryPoint A pointer to function to call with the new stack.
1337 @param Context1 A pointer to the context to pass into the EntryPoint
1338 function.
1339 @param Context2 A pointer to the context to pass into the EntryPoint
1340 function.
1341 @param NewStack A pointer to the new stack to use for the EntryPoint
1342 function.
1343 @param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's
1344 Reserved on other architectures.
1345
1346 **/
1347 VOID
1348 EFIAPI
1349 PeiSwitchStacks (
1350 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
1351 IN VOID *Context1, OPTIONAL
1352 IN VOID *Context2, OPTIONAL
1353 IN VOID *NewStack,
1354 IN VOID *NewBsp
1355 );
1356
1357 EFI_STATUS
1358 PeiFindFileEx (
1359 IN CONST EFI_PEI_FV_HANDLE FvHandle,
1360 IN CONST EFI_GUID *FileName, OPTIONAL
1361 IN EFI_FV_FILETYPE SearchType,
1362 IN OUT EFI_PEI_FILE_HANDLE *FileHandle,
1363 IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL
1364 )
1365 /*++
1366
1367 Routine Description:
1368 Given the input file pointer, search for the next matching file in the
1369 FFS volume as defined by SearchType. The search starts from FileHeader inside
1370 the Firmware Volume defined by FwVolHeader.
1371
1372 Arguments:
1373 PeiServices - Pointer to the PEI Core Services Table.
1374 SearchType - Filter to find only files of this type.
1375 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
1376 FwVolHeader - Pointer to the FV header of the volume to search.
1377 This parameter must point to a valid FFS volume.
1378 FileHeader - Pointer to the current file from which to begin searching.
1379 This pointer will be updated upon return to reflect the file found.
1380 Flag - Indicator for if this is for PEI Dispath search
1381
1382 Returns:
1383 EFI_NOT_FOUND - No files matching the search criteria were found
1384 EFI_SUCCESS
1385
1386 --*/
1387 ;
1388
1389 VOID
1390 InitializeImageServices (
1391 IN PEI_CORE_INSTANCE *PrivateData,
1392 IN PEI_CORE_INSTANCE *OldCoreData
1393 )
1394 /*++
1395
1396 Routine Description:
1397
1398 Install Pei Load File PPI.
1399
1400 Arguments:
1401
1402 PrivateData - Pointer to PEI_CORE_INSTANCE.
1403 OldCoreData - Pointer to PEI_CORE_INSTANCE.
1404
1405 Returns:
1406
1407 NONE.
1408
1409 --*/
1410 ;
1411
1412 #endif