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