1) Move the structure definitions related GUID EFI_STATUS_CODE_SPECIFIC_DATA_GUID...
[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/FindFv.h>
33 #include <Ppi/StatusCode.h>
34 #include <Ppi/Security.h>
35 #include <Ppi/Reset.h>
36 #include <Ppi/FvLoadFile.h>
37 #include <Library/DebugLib.h>
38 #include <Library/PeiCoreEntryPoint.h>
39 #include <Library/BaseLib.h>
40 #include <Library/HobLib.h>
41 #include <Library/PerformanceLib.h>
42 #include <Library/PeiServicesLib.h>
43 #include <Library/ReportStatusCodeLib.h>
44 #include <Library/PeCoffGetEntryPointLib.h>
45 #include <Library/BaseMemoryLib.h>
46 #include <Library/TimerLib.h>
47 #include <IndustryStandard/PeImage.h>
48
49 extern EFI_GUID gEfiPeiCorePrivateGuid;
50
51 //
52 // Pei Core private data structures
53 //
54 typedef union {
55 EFI_PEI_PPI_DESCRIPTOR *Ppi;
56 EFI_PEI_NOTIFY_DESCRIPTOR *Notify;
57 VOID *Raw;
58 } PEI_PPI_LIST_POINTERS;
59
60 #define PEI_STACK_SIZE 0x20000
61
62 #define MAX_PPI_DESCRIPTORS 64
63
64 typedef struct {
65 INTN PpiListEnd;
66 INTN NotifyListEnd;
67 INTN DispatchListEnd;
68 INTN LastDispatchedInstall;
69 INTN LastDispatchedNotify;
70 PEI_PPI_LIST_POINTERS PpiListPtrs[MAX_PPI_DESCRIPTORS];
71 } PEI_PPI_DATABASE;
72
73 typedef struct {
74 UINT8 CurrentPeim;
75 UINT8 CurrentFv;
76 UINT32 DispatchedPeimBitMap;
77 UINT32 PreviousPeimBitMap;
78 EFI_FFS_FILE_HEADER *CurrentPeimAddress;
79 EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress;
80 EFI_FIRMWARE_VOLUME_HEADER *BootFvAddress;
81 EFI_PEI_FIND_FV_PPI *FindFv;
82 } PEI_CORE_DISPATCH_DATA;
83
84
85 //
86 // Pei Core private data structure instance
87 //
88
89 #define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C')
90
91 typedef struct{
92 UINTN Signature;
93 EFI_PEI_SERVICES *PS; // Point to ServiceTableShadow
94 PEI_PPI_DATABASE PpiData;
95 PEI_CORE_DISPATCH_DATA DispatchData;
96 EFI_PEI_HOB_POINTERS HobList;
97 BOOLEAN SwitchStackSignal;
98 BOOLEAN PeiMemoryInstalled;
99 EFI_PHYSICAL_ADDRESS StackBase;
100 UINT64 StackSize;
101 VOID *BottomOfCarHeap;
102 VOID *TopOfCarHeap;
103 VOID *CpuIo;
104 EFI_PEI_SECURITY_PPI *PrivateSecurityPpi;
105 EFI_PEI_SERVICES ServiceTableShadow;
106 UINTN SizeOfCacheAsRam;
107 VOID *MaxTopOfCarHeap;
108 } PEI_CORE_INSTANCE;
109
110 //
111 // Pei Core Instance Data Macros
112 //
113
114 #define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \
115 CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)
116
117 //
118 // BUGBUG: Where does this go really?
119 //
120 typedef
121 EFI_STATUS
122 (EFIAPI *PEI_CORE_ENTRY_POINT)(
123 IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
124 IN PEI_CORE_INSTANCE *OldCoreData
125 );
126
127 //
128 // Union of temporarily used function pointers (to save stack space)
129 //
130 typedef union {
131 PEI_CORE_ENTRY_POINT PeiCore;
132 EFI_PEIM_ENTRY_POINT PeimEntry;
133 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;
134 EFI_DXE_IPL_PPI *DxeIpl;
135 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
136 EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
137 VOID *Raw;
138 } PEI_CORE_TEMP_POINTERS;
139
140
141 //
142 // PeiCore function
143 //
144 EFI_STATUS
145 EFIAPI
146 PeiCore (
147 IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
148 IN VOID *Data
149 )
150 /*++
151
152 Routine Description:
153
154 The entry routine to Pei Core, invoked by PeiMain during transition
155 from SEC to PEI. After switching stack in the PEI core, it will restart
156 with the old core data.
157
158 Arguments:
159
160 PeiStartupDescriptor - Information and services provided by SEC phase.
161 OldCoreData - Pointer to old core data that is used to initialize the
162 core's data areas.
163
164 Returns:
165
166 This function never returns
167 EFI_NOT_FOUND - Never reach
168
169 --*/
170 ;
171
172 //
173 // Dispatcher support functions
174 //
175
176 EFI_STATUS
177 PeimDispatchReadiness (
178 IN EFI_PEI_SERVICES **PeiServices,
179 IN VOID *DependencyExpression,
180 IN OUT BOOLEAN *Runnable
181 )
182 /*++
183
184 Routine Description:
185
186 This is the POSTFIX version of the dependency evaluator. When a
187 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on
188 the evaluation stack. When that entry is poped from the evaluation
189 stack, the PPI is checked if it is installed. This method allows
190 some time savings as not all PPIs must be checked for certain
191 operation types (AND, OR).
192
193 Arguments:
194
195 PeiServices - Calling context.
196
197 DependencyExpression - Pointer to a dependency expression. The Grammar adheres to
198 the BNF described above and is stored in postfix notation.
199 Runnable - is True if the driver can be scheduled and False if the driver
200 cannot be scheduled. This is the value that the schedulers
201 should use for deciding the state of the driver.
202
203 Returns:
204
205 Status = EFI_SUCCESS if it is a well-formed Grammar
206 EFI_INVALID_PARAMETER if the dependency expression overflows
207 the evaluation stack
208 EFI_INVALID_PARAMETER if the dependency expression underflows
209 the evaluation stack
210 EFI_INVALID_PARAMETER if the dependency expression is not a
211 well-formed Grammar.
212 --*/
213 ;
214
215
216 EFI_STATUS
217 PeiDispatcher (
218 IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
219 IN PEI_CORE_INSTANCE *PrivateData,
220 IN PEI_CORE_DISPATCH_DATA *DispatchData
221 )
222
223 /*++
224
225 Routine Description:
226
227 Conduct PEIM dispatch.
228
229 Arguments:
230
231 PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR
232 PrivateData - Pointer to the private data passed in from caller
233 DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.
234
235 Returns:
236
237 EFI_SUCCESS - Successfully dispatched PEIM.
238 EFI_NOT_FOUND - The dispatch failed.
239
240 --*/
241 ;
242
243
244 VOID
245 InitializeDispatcherData (
246 IN EFI_PEI_SERVICES **PeiServices,
247 IN PEI_CORE_INSTANCE *OldCoreData,
248 IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor
249 )
250 /*++
251
252 Routine Description:
253
254 Initialize the Dispatcher's data members
255
256 Arguments:
257
258 PeiServices - The PEI core services table.
259 OldCoreData - Pointer to old core data (before switching stack).
260 NULL if being run in non-permament memory mode.
261 PeiStartupDescriptor - Information and services provided by SEC phase.
262
263
264 Returns:
265
266 None
267
268 --*/
269 ;
270
271
272 EFI_STATUS
273 FindNextPeim (
274 IN EFI_PEI_SERVICES **PeiServices,
275 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
276 IN OUT EFI_FFS_FILE_HEADER **PeimFileHeader
277 )
278 /*++
279
280 Routine Description:
281 Given the input file pointer, search for the next matching file in the
282 FFS volume. The search starts from FileHeader inside
283 the Firmware Volume defined by FwVolHeader.
284
285 Arguments:
286 PeiServices - Pointer to the PEI Core Services Table.
287
288 FwVolHeader - Pointer to the FV header of the volume to search.
289 This parameter must point to a valid FFS volume.
290
291 PeimFileHeader - Pointer to the current file from which to begin searching.
292 This pointer will be updated upon return to reflect the file found.
293
294 Returns:
295 EFI_NOT_FOUND - No files matching the search criteria were found
296 EFI_SUCCESS
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 EFI_PEI_SERVICES **PeiServices,
352 IN VOID *CurrentPeimAddress
353 )
354 /*++
355
356 Routine Description:
357
358 This routine parses the Dependency Expression, if available, and
359 decides if the module can be executed.
360
361 Arguments:
362 PeiServices - The PEI Service Table
363 CurrentPeimAddress - Address of the PEIM Firmware File under investigation
364
365 Returns:
366 TRUE - Can be dispatched
367 FALSE - Cannot be dispatched
368
369 --*/
370 ;
371
372 #if defined (MDE_CPU_IPF)
373 //
374 // In Ipf we should make special changes for the PHIT pointers to support
375 // recovery boot in cache mode.
376 //
377 #define SWITCH_TO_CACHE_MODE(CoreData) SwitchToCacheMode(CoreData)
378 #define CACHE_MODE_ADDRESS_MASK 0x7FFFFFFFFFFFFFFFULL
379 VOID
380 SwitchToCacheMode (
381 IN PEI_CORE_INSTANCE *CoreData
382 )
383 /*++
384
385 Routine Description:
386
387 Switch the PHIT pointers to cache mode after InstallPeiMemory in CAR.
388
389 Arguments:
390
391 CoreData - The PEI core Private Data
392
393 Returns:
394
395 --*/
396 ;
397
398 #else
399
400 #define SWITCH_TO_CACHE_MODE(CoreData)
401
402 #endif
403
404 //
405 // PPI support functions
406 //
407 VOID
408 InitializePpiServices (
409 IN EFI_PEI_SERVICES **PeiServices,
410 IN PEI_CORE_INSTANCE *OldCoreData
411 )
412 /*++
413
414 Routine Description:
415
416 Initialize PPI services.
417
418 Arguments:
419
420 PeiServices - The PEI core services table.
421 OldCoreData - Pointer to the PEI Core data.
422 NULL if being run in non-permament memory mode.
423
424 Returns:
425 Nothing
426
427 --*/
428 ;
429
430 VOID
431 ConvertPpiPointers (
432 IN EFI_PEI_SERVICES **PeiServices,
433 IN EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffHob,
434 IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob
435 )
436 /*++
437
438 Routine Description:
439
440 Migrate the Hob list from the CAR stack to PEI installed memory.
441
442 Arguments:
443
444 PeiServices - The PEI core services table.
445 OldHandOffHob - The old handoff HOB list.
446 NewHandOffHob - The new handoff HOB list.
447
448 Returns:
449
450 --*/
451 ;
452
453 EFI_STATUS
454 EFIAPI
455 PeiInstallPpi (
456 IN EFI_PEI_SERVICES **PeiServices,
457 IN EFI_PEI_PPI_DESCRIPTOR *PpiList
458 )
459 /*++
460
461 Routine Description:
462
463 Install PPI services.
464
465 Arguments:
466
467 PeiServices - Pointer to the PEI Service Table
468 PpiList - Pointer to a list of PEI PPI Descriptors.
469
470 Returns:
471
472 EFI_SUCCESS - if all PPIs in PpiList are successfully installed.
473 EFI_INVALID_PARAMETER - if PpiList is NULL pointer
474 EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid
475 EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI
476
477 --*/
478 ;
479
480 EFI_STATUS
481 EFIAPI
482 PeiReInstallPpi (
483 IN EFI_PEI_SERVICES **PeiServices,
484 IN EFI_PEI_PPI_DESCRIPTOR *OldPpi,
485 IN EFI_PEI_PPI_DESCRIPTOR *NewPpi
486 )
487 /*++
488
489 Routine Description:
490
491 Re-Install PPI services.
492
493 Arguments:
494
495 PeiServices - Pointer to the PEI Service Table
496 OldPpi - Pointer to the old PEI PPI Descriptors.
497 NewPpi - Pointer to the new PEI PPI Descriptors.
498
499 Returns:
500
501 EFI_SUCCESS - if the operation was successful
502 EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL
503 EFI_INVALID_PARAMETER - if NewPpi is not valid
504 EFI_NOT_FOUND - if the PPI was not in the database
505
506 --*/
507 ;
508
509 EFI_STATUS
510 EFIAPI
511 PeiLocatePpi (
512 IN EFI_PEI_SERVICES **PeiServices,
513 IN EFI_GUID *Guid,
514 IN UINTN Instance,
515 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
516 IN OUT VOID **Ppi
517 )
518 /*++
519
520 Routine Description:
521
522 Locate a given named PPI.
523
524 Arguments:
525
526 PeiServices - Pointer to the PEI Service Table
527 Guid - Pointer to GUID of the PPI.
528 Instance - Instance Number to discover.
529 PpiDescriptor - Pointer to reference the found descriptor. If not NULL,
530 returns a pointer to the descriptor (includes flags, etc)
531 Ppi - Pointer to reference the found PPI
532
533 Returns:
534
535 Status - EFI_SUCCESS if the PPI is in the database
536 EFI_NOT_FOUND if the PPI is not in the database
537 --*/
538 ;
539
540 EFI_STATUS
541 EFIAPI
542 PeiNotifyPpi (
543 IN EFI_PEI_SERVICES **PeiServices,
544 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
545 )
546 /*++
547
548 Routine Description:
549
550 Install a notification for a given PPI.
551
552 Arguments:
553
554 PeiServices - Pointer to the PEI Service Table
555 NotifyList - Pointer to list of Descriptors to notify upon.
556
557 Returns:
558
559 Status - EFI_SUCCESS if successful
560 EFI_OUT_OF_RESOURCES if no space in the database
561 EFI_INVALID_PARAMETER if not a good decriptor
562
563 --*/
564 ;
565
566 VOID
567 ProcessNotifyList (
568 IN EFI_PEI_SERVICES **PeiServices
569 )
570 /*++
571
572 Routine Description:
573
574 Process the Notify List at dispatch level.
575
576 Arguments:
577
578 PeiServices - Pointer to the PEI Service Table
579
580 Returns:
581
582 --*/
583 ;
584
585 VOID
586 DispatchNotify (
587 IN EFI_PEI_SERVICES **PeiServices,
588 IN UINTN NotifyType,
589 IN INTN InstallStartIndex,
590 IN INTN InstallStopIndex,
591 IN INTN NotifyStartIndex,
592 IN INTN NotifyStopIndex
593 )
594 /*++
595
596 Routine Description:
597
598 Dispatch notifications.
599
600 Arguments:
601
602 PeiServices - Pointer to the PEI Service Table
603 NotifyType - Type of notify to fire.
604 InstallStartIndex - Install Beginning index.
605 InstallStopIndex - Install Ending index.
606 NotifyStartIndex - Notify Beginning index.
607 NotifyStopIndex - Notify Ending index.
608
609 Returns: None
610
611 --*/
612 ;
613
614 //
615 // Boot mode support functions
616 //
617 EFI_STATUS
618 EFIAPI
619 PeiGetBootMode (
620 IN EFI_PEI_SERVICES **PeiServices,
621 IN OUT EFI_BOOT_MODE *BootMode
622 )
623 /*++
624
625 Routine Description:
626
627 This service enables PEIMs to ascertain the present value of the boot mode.
628
629 Arguments:
630
631 PeiServices - The PEI core services table.
632 BootMode - A pointer to contain the value of the boot mode.
633
634 Returns:
635
636 EFI_SUCCESS - The boot mode was returned successfully.
637 EFI_INVALID_PARAMETER - BootMode is NULL.
638
639 --*/
640 ;
641
642 EFI_STATUS
643 EFIAPI
644 PeiSetBootMode (
645 IN EFI_PEI_SERVICES **PeiServices,
646 IN EFI_BOOT_MODE BootMode
647 )
648 /*++
649
650 Routine Description:
651
652 This service enables PEIMs to update the boot mode variable.
653
654 Arguments:
655
656 PeiServices - The PEI core services table.
657 BootMode - The value of the boot mode to set.
658
659 Returns:
660
661 EFI_SUCCESS - The value was successfully updated
662
663 --*/
664 ;
665
666 //
667 // Security support functions
668 //
669 VOID
670 InitializeSecurityServices (
671 IN EFI_PEI_SERVICES **PeiServices,
672 IN PEI_CORE_INSTANCE *OldCoreData
673 )
674 /*++
675
676 Routine Description:
677
678 Initialize the security services.
679
680 Arguments:
681
682 PeiServices - The PEI core services table.
683 OldCoreData - Pointer to the old core data.
684 NULL if being run in non-permament memory mode.
685 Returns:
686
687 None
688
689 --*/
690 ;
691
692 EFI_STATUS
693 VerifyFv (
694 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress
695 )
696 /*++
697
698 Routine Description:
699
700 Provide a callout to the OEM FV verification service.
701
702 Arguments:
703
704 CurrentFvAddress - Pointer to the FV under investigation.
705
706 Returns:
707
708 Status - EFI_SUCCESS
709
710 --*/
711 ;
712
713
714 EFI_STATUS
715 VerifyPeim (
716 IN EFI_PEI_SERVICES **PeiServices,
717 IN EFI_FFS_FILE_HEADER *CurrentPeimAddress
718 )
719 /*++
720
721 Routine Description:
722
723 Provide a callout to the security verification service.
724
725 Arguments:
726
727 PeiServices - The PEI core services table.
728 CurrentPeimAddress - Pointer to the Firmware File under investigation.
729
730 Returns:
731
732 EFI_SUCCESS - Image is OK
733 EFI_SECURITY_VIOLATION - Image is illegal
734
735 --*/
736 ;
737
738
739 EFI_STATUS
740 EFIAPI
741 PeiGetHobList (
742 IN EFI_PEI_SERVICES **PeiServices,
743 IN OUT VOID **HobList
744 )
745 /*++
746
747 Routine Description:
748
749 Gets the pointer to the HOB List.
750
751 Arguments:
752
753 PeiServices - The PEI core services table.
754 HobList - Pointer to the HOB List.
755
756 Returns:
757
758 EFI_SUCCESS - Get the pointer of HOB List
759 EFI_NOT_AVAILABLE_YET - the HOB List is not yet published
760 EFI_INVALID_PARAMETER - HobList is NULL (in debug mode)
761
762 --*/
763 ;
764
765 EFI_STATUS
766 EFIAPI
767 PeiCreateHob (
768 IN EFI_PEI_SERVICES **PeiServices,
769 IN UINT16 Type,
770 IN UINT16 Length,
771 IN OUT VOID **Hob
772 )
773 /*++
774
775 Routine Description:
776
777 Add a new HOB to the HOB List.
778
779 Arguments:
780
781 PeiServices - The PEI core services table.
782 Type - Type of the new HOB.
783 Length - Length of the new HOB to allocate.
784 Hob - Pointer to the new HOB.
785
786 Returns:
787
788 Status - EFI_SUCCESS
789 - EFI_INVALID_PARAMETER if Hob is NULL
790 - EFI_NOT_AVAILABLE_YET if HobList is still not available.
791 - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
792
793 --*/
794 ;
795
796 EFI_STATUS
797 PeiCoreBuildHobHandoffInfoTable (
798 IN EFI_BOOT_MODE BootMode,
799 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
800 IN UINT64 MemoryLength
801 )
802 /*++
803
804 Routine Description:
805
806 Builds a Handoff Information Table HOB
807
808 Arguments:
809
810 BootMode - Current Bootmode
811 MemoryBegin - Start Memory Address.
812 MemoryLength - Length of Memory.
813
814 Returns:
815
816 EFI_SUCCESS
817
818 --*/
819 ;
820
821
822 //
823 // FFS Fw Volume support functions
824 //
825 EFI_STATUS
826 EFIAPI
827 PeiFfsFindNextFile (
828 IN EFI_PEI_SERVICES **PeiServices,
829 IN UINT8 SearchType,
830 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
831 IN OUT EFI_FFS_FILE_HEADER **FileHeader
832 )
833 /*++
834
835 Routine Description:
836 Given the input file pointer, search for the next matching file in the
837 FFS volume as defined by SearchType. The search starts from FileHeader inside
838 the Firmware Volume defined by FwVolHeader.
839
840 Arguments:
841 PeiServices - Pointer to the PEI Core Services Table.
842
843 SearchType - Filter to find only files of this type.
844 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
845
846 FwVolHeader - Pointer to the FV header of the volume to search.
847 This parameter must point to a valid FFS volume.
848
849 FileHeader - Pointer to the current file from which to begin searching.
850 This pointer will be updated upon return to reflect the file found.
851
852 Returns:
853 EFI_NOT_FOUND - No files matching the search criteria were found
854 EFI_SUCCESS
855
856 --*/
857 ;
858
859 EFI_STATUS
860 EFIAPI
861 PeiFfsFindSectionData (
862 IN EFI_PEI_SERVICES **PeiServices,
863 IN EFI_SECTION_TYPE SectionType,
864 IN EFI_FFS_FILE_HEADER *FfsFileHeader,
865 IN OUT VOID **SectionData
866 )
867 /*++
868
869 Routine Description:
870 Given the input file pointer, search for the next matching section in the
871 FFS volume.
872
873 Arguments:
874 PeiServices - Pointer to the PEI Core Services Table.
875 SearchType - Filter to find only sections of this type.
876 FfsFileHeader - Pointer to the current file to search.
877 SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
878 - NULL if section not found
879
880 Returns:
881 EFI_NOT_FOUND - No files matching the search criteria were found
882 EFI_SUCCESS
883
884 --*/
885 ;
886
887 EFI_STATUS
888 EFIAPI
889 PeiFvFindNextVolume (
890 IN EFI_PEI_SERVICES **PeiServices,
891 IN UINTN Instance,
892 IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
893 )
894 /*++
895
896 Routine Description:
897
898 Return the BFV location
899
900 BugBug -- Move this to the location of this code to where the
901 other FV and FFS support code lives.
902 Also, update to use FindFV for instances #'s >= 1.
903
904 Arguments:
905
906 PeiServices - The PEI core services table.
907 Instance - Instance of FV to find
908 FwVolHeader - Pointer to contain the data to return
909
910 Returns:
911 Pointer to the Firmware Volume instance requested
912
913 EFI_INVALID_PARAMETER - FwVolHeader is NULL
914
915 EFI_SUCCESS - Firmware volume instance successfully found.
916
917 --*/
918 ;
919
920 //
921 // Memory support functions
922 //
923 VOID
924 InitializeMemoryServices (
925 IN EFI_PEI_SERVICES **PeiServices,
926 IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
927 IN PEI_CORE_INSTANCE *OldCoreData
928 )
929 /*++
930
931 Routine Description:
932
933 Initialize the memory services.
934
935 Arguments:
936
937 PeiServices - The PEI core services table.
938 PeiStartupDescriptor - Information and services provided by SEC phase.
939 OldCoreData - Pointer to the PEI Core data.
940 NULL if being run in non-permament memory mode.
941
942 Returns:
943
944 None
945
946 --*/
947 ;
948
949 EFI_STATUS
950 EFIAPI
951 PeiInstallPeiMemory (
952 IN EFI_PEI_SERVICES **PeiServices,
953 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
954 IN UINT64 MemoryLength
955 )
956 /*++
957
958 Routine Description:
959
960 Install the permanent memory is now available.
961 Creates HOB (PHIT and Stack).
962
963 Arguments:
964
965 PeiServices - The PEI core services table.
966 MemoryBegin - Start of memory address.
967 MemoryLength - Length of memory.
968
969 Returns:
970
971 Status - EFI_SUCCESS
972
973 --*/
974 ;
975
976 EFI_STATUS
977 EFIAPI
978 PeiAllocatePages (
979 IN EFI_PEI_SERVICES **PeiServices,
980 IN EFI_MEMORY_TYPE MemoryType,
981 IN UINTN Pages,
982 OUT EFI_PHYSICAL_ADDRESS *Memory
983 )
984 /*++
985
986 Routine Description:
987
988 Memory allocation service on permanent memory,
989 not usable prior to the memory installation.
990
991 Arguments:
992
993 PeiServices - The PEI core services table.
994 Type - Type of allocation.
995 MemoryType - Type of memory to allocate.
996 Pages - Number of pages to allocate.
997 Memory - Pointer of memory allocated.
998
999 Returns:
1000
1001 Status - EFI_SUCCESS The allocation was successful
1002 EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.
1003 EFI_NOT_AVAILABLE_YET Called with permanent memory not available
1004 EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
1005 to allocate the number of pages.
1006
1007 --*/
1008 ;
1009
1010 EFI_STATUS
1011 EFIAPI
1012 PeiAllocatePool (
1013 IN EFI_PEI_SERVICES **PeiServices,
1014 IN UINTN Size,
1015 OUT VOID **Buffer
1016 )
1017 /*++
1018
1019 Routine Description:
1020
1021 Memory allocation service on the CAR.
1022
1023 Arguments:
1024
1025 PeiServices - The PEI core services table.
1026
1027 Size - Amount of memory required
1028
1029 Buffer - Address of pointer to the buffer
1030
1031 Returns:
1032
1033 Status - EFI_SUCCESS The allocation was successful
1034 EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
1035 to allocate the requested size.
1036
1037 --*/
1038 ;
1039
1040 EFI_STATUS
1041 PeiLoadImage (
1042 IN EFI_PEI_SERVICES **PeiServices,
1043 IN EFI_FFS_FILE_HEADER *PeimFileHeader,
1044 OUT VOID **EntryPoint
1045 )
1046 /*++
1047
1048 Routine Description:
1049
1050 Get entry point of a Peim file.
1051
1052 Arguments:
1053
1054 PeiServices - Calling context.
1055
1056 PeimFileHeader - Peim file's header.
1057
1058 EntryPoint - Entry point of that Peim file.
1059
1060 Returns:
1061
1062 Status code.
1063
1064 --*/
1065 ;
1066
1067
1068 EFI_STATUS
1069 EFIAPI
1070 PeiReportStatusCode (
1071 IN EFI_PEI_SERVICES **PeiServices,
1072 IN EFI_STATUS_CODE_TYPE CodeType,
1073 IN EFI_STATUS_CODE_VALUE Value,
1074 IN UINT32 Instance,
1075 IN EFI_GUID *CallerId,
1076 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
1077 )
1078 /*++
1079
1080 Routine Description:
1081
1082 Core version of the Status Code reporter
1083
1084 Arguments:
1085
1086 PeiServices - The PEI core services table.
1087
1088 CodeType - Type of Status Code.
1089
1090 Value - Value to output for Status Code.
1091
1092 Instance - Instance Number of this status code.
1093
1094 CallerId - ID of the caller of this status code.
1095
1096 Data - Optional data associated with this status code.
1097
1098 Returns:
1099
1100 Status - EFI_SUCCESS if status code is successfully reported
1101 - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed
1102
1103 --*/
1104 ;
1105
1106
1107 EFI_STATUS
1108 EFIAPI
1109 PeiResetSystem (
1110 IN EFI_PEI_SERVICES **PeiServices
1111 )
1112 /*++
1113
1114 Routine Description:
1115
1116 Core version of the Reset System
1117
1118 Arguments:
1119
1120 PeiServices - The PEI core services table.
1121
1122 Returns:
1123
1124 Status - EFI_NOT_AVAILABLE_YET. PPI not available yet.
1125 - EFI_DEVICE_ERROR. Did not reset system.
1126
1127 Otherwise, resets the system.
1128
1129 --*/
1130 ;
1131
1132 /**
1133 Transfers control to a function starting with a new stack.
1134
1135 Transfers control to the function specified by EntryPoint using the new stack
1136 specified by NewStack and passing in the parameters specified by Context1 and
1137 Context2. Context1 and Context2 are optional and may be NULL. The function
1138 EntryPoint must never return.
1139
1140 If EntryPoint is NULL, then ASSERT().
1141 If NewStack is NULL, then ASSERT().
1142
1143 @param EntryPoint A pointer to function to call with the new stack.
1144 @param Context1 A pointer to the context to pass into the EntryPoint
1145 function.
1146 @param Context2 A pointer to the context to pass into the EntryPoint
1147 function.
1148 @param NewStack A pointer to the new stack to use for the EntryPoint
1149 function.
1150 @param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's
1151 Reserved on other architectures.
1152
1153 **/
1154 VOID
1155 EFIAPI
1156 PeiSwitchStacks (
1157 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
1158 IN VOID *Context1, OPTIONAL
1159 IN VOID *Context2, OPTIONAL
1160 IN VOID *NewStack,
1161 IN VOID *NewBsp
1162 );
1163
1164 #endif