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