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