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