]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Pei/PeiMain.h
Merge branch of PI tree to main trunk
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
... / ...
CommitLineData
1/*++\r
2\r
3Copyright (c) 2006 - 2007, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 PeiMain.h\r
15\r
16Abstract:\r
17\r
18 Definition of Pei Core Structures and Services\r
19\r
20Revision History\r
21\r
22--*/\r
23\r
24#ifndef _PEI_MAIN_H_\r
25#define _PEI_MAIN_H_\r
26\r
27#include <PiPei.h>\r
28#include <FrameworkPei.h>\r
29#include <Guid/StatusCodeDataTypeId.h>\r
30#include <Ppi/DxeIpl.h>\r
31#include <Ppi/MemoryDiscovered.h>\r
32#include <Ppi/StatusCode.h>\r
33#include <Ppi/Reset.h>\r
34#include <Ppi/FirmwareVolume.h>\r
35#include <Ppi/FirmwareVolumeInfo.h>\r
36#include <Ppi/Decompress.h>\r
37#include <Ppi/GuidedSectionExtraction.h>\r
38#include <Ppi/LoadFile.h>\r
39#include <Ppi/Security2.h>\r
40#include <Library/DebugLib.h>\r
41#include <Library/PeiCoreEntryPoint.h>\r
42#include <Library/BaseLib.h>\r
43#include <Library/HobLib.h>\r
44#include <Library/PerformanceLib.h>\r
45#include <Library/PeiServicesLib.h>\r
46#include <Library/ReportStatusCodeLib.h>\r
47#include <Library/PeCoffGetEntryPointLib.h>\r
48#include <Library/BaseMemoryLib.h>\r
49#include <Library/CacheMaintenanceLib.h>\r
50#include <Library/TimerLib.h>\r
51#include <Library/PeCoffLoaderLib.h>\r
52#include <IndustryStandard/PeImage.h>\r
53#include <Library/PeiServicesTablePointerLib.h>\r
54#include <Library/MemoryAllocationLib.h>\r
55#include <Guid/FirmwareFileSystem2.h>\r
56#include <Guid/AprioriFileName.h>\r
57#include <Guid/PeiPeCoffLoader.h>\r
58\r
59#define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE 0xff\r
60\r
61//\r
62// Pei Core private data structures\r
63//\r
64typedef union {\r
65 EFI_PEI_PPI_DESCRIPTOR *Ppi;\r
66 EFI_PEI_NOTIFY_DESCRIPTOR *Notify;\r
67 VOID *Raw;\r
68} PEI_PPI_LIST_POINTERS;\r
69\r
70#define PEI_STACK_SIZE 0x20000\r
71\r
72#define MAX_PPI_DESCRIPTORS 64\r
73\r
74typedef struct {\r
75 INTN PpiListEnd;\r
76 INTN NotifyListEnd;\r
77 INTN DispatchListEnd;\r
78 INTN LastDispatchedInstall;\r
79 INTN LastDispatchedNotify;\r
80 PEI_PPI_LIST_POINTERS PpiListPtrs[MAX_PPI_DESCRIPTORS];\r
81} PEI_PPI_DATABASE;\r
82\r
83\r
84#define PEI_CORE_MAX_FV_SUPPORTED 4\r
85#define PEI_CORE_MAX_PEIM_PER_FV 32\r
86\r
87//\r
88// PEI_CORE_FV_HANDE.PeimState\r
89// Do not change these values as there is code doing math to change states.\r
90// Look for Private->Fv[FvCount].PeimState[PeimCount]++;\r
91//\r
92#define PEIM_STATE_NOT_DISPATCHED 0x00\r
93#define PEIM_STATE_DISPATCHED 0x01\r
94#define PEIM_STATE_REGISITER_FOR_SHADOW 0x02\r
95#define PEIM_STATE_DONE 0x03\r
96\r
97typedef struct {\r
98 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
99 UINT8 PeimState[PEI_CORE_MAX_PEIM_PER_FV]; \r
100 EFI_PEI_FILE_HANDLE FvFileHandles[PEI_CORE_MAX_PEIM_PER_FV];\r
101 BOOLEAN ScanFv;\r
102} PEI_CORE_FV_HANDLE;\r
103\r
104//\r
105// Pei Core private data structure instance\r
106//\r
107\r
108#define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C')\r
109\r
110typedef struct{\r
111 UINTN Signature;\r
112 EFI_PEI_SERVICES *PS; // Point to ServiceTableShadow\r
113 PEI_PPI_DATABASE PpiData;\r
114 UINTN FvCount;\r
115 PEI_CORE_FV_HANDLE Fv[PEI_CORE_MAX_FV_SUPPORTED];\r
116 EFI_PEI_FILE_HANDLE CurrentFvFileHandles[PEI_CORE_MAX_PEIM_PER_FV];\r
117 UINTN AprioriCount;\r
118 UINTN CurrentPeimFvCount; \r
119 UINTN CurrentPeimCount;\r
120 EFI_PEI_FILE_HANDLE CurrentFileHandle;\r
121 UINTN AllFvCount;\r
122 EFI_PEI_FV_HANDLE AllFv[PEI_CORE_MAX_FV_SUPPORTED];\r
123 EFI_PEI_HOB_POINTERS HobList;\r
124 BOOLEAN SwitchStackSignal;\r
125 BOOLEAN PeiMemoryInstalled;\r
126 EFI_PHYSICAL_ADDRESS StackBase;\r
127 UINT64 StackSize;\r
128 VOID *BottomOfCarHeap;\r
129 VOID *TopOfCarHeap;\r
130 VOID *CpuIo;\r
131 EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi;\r
132 EFI_PEI_SERVICES ServiceTableShadow;\r
133 UINTN SizeOfCacheAsRam;\r
134 VOID *MaxTopOfCarHeap;\r
135 EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;\r
136 EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeCoffLoader; \r
137} PEI_CORE_INSTANCE;\r
138\r
139//\r
140// Pei Core Instance Data Macros\r
141//\r
142\r
143#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \\r
144 CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)\r
145\r
146//\r
147// BUGBUG: Where does this go really?\r
148//\r
149typedef\r
150EFI_STATUS\r
151(EFIAPI *PEI_CORE_ENTRY_POINT)(\r
152 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
153 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
154 IN PEI_CORE_INSTANCE *OldCoreData\r
155 );\r
156\r
157//\r
158// Union of temporarily used function pointers (to save stack space)\r
159//\r
160typedef union {\r
161 PEI_CORE_ENTRY_POINT PeiCore;\r
162 EFI_PEIM_ENTRY_POINT2 PeimEntry;\r
163 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;\r
164 EFI_DXE_IPL_PPI *DxeIpl;\r
165 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
166 EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;\r
167 VOID *Raw;\r
168} PEI_CORE_TEMP_POINTERS;\r
169\r
170\r
171\r
172typedef struct {\r
173 CONST EFI_SEC_PEI_HAND_OFF *SecCoreData;\r
174 EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
175 VOID *Data;\r
176} PEI_CORE_PARAMETERS;\r
177\r
178//\r
179// PeiCore function\r
180//\r
181EFI_STATUS\r
182EFIAPI\r
183PeiCore (\r
184 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
185 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList,\r
186 IN VOID *Data\r
187 )\r
188/*++\r
189\r
190Routine Description:\r
191\r
192 The entry routine to Pei Core, invoked by PeiMain during transition\r
193 from SEC to PEI. After switching stack in the PEI core, it will restart\r
194 with the old core data.\r
195\r
196Arguments:\r
197\r
198 PeiStartupDescriptor - Information and services provided by SEC phase.\r
199 OldCoreData - Pointer to old core data that is used to initialize the\r
200 core's data areas.\r
201\r
202Returns:\r
203\r
204 This function never returns\r
205 EFI_NOT_FOUND - Never reach\r
206\r
207--*/\r
208;\r
209\r
210//\r
211// Dispatcher support functions\r
212//\r
213\r
214BOOLEAN\r
215PeimDispatchReadiness (\r
216 IN EFI_PEI_SERVICES **PeiServices,\r
217 IN VOID *DependencyExpression\r
218 )\r
219/*++\r
220\r
221Routine Description:\r
222\r
223 This is the POSTFIX version of the dependency evaluator. When a\r
224 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on\r
225 the evaluation stack. When that entry is poped from the evaluation\r
226 stack, the PPI is checked if it is installed. This method allows\r
227 some time savings as not all PPIs must be checked for certain\r
228 operation types (AND, OR).\r
229\r
230Arguments:\r
231\r
232 PeiServices - Calling context.\r
233\r
234 DependencyExpression - Pointer to a dependency expression. The Grammar adheres to\r
235 the BNF described above and is stored in postfix notation.\r
236 Runnable - is True if the driver can be scheduled and False if the driver\r
237 cannot be scheduled. This is the value that the schedulers\r
238 should use for deciding the state of the driver.\r
239\r
240Returns:\r
241\r
242 Status = EFI_SUCCESS if it is a well-formed Grammar\r
243 EFI_INVALID_PARAMETER if the dependency expression overflows\r
244 the evaluation stack\r
245 EFI_INVALID_PARAMETER if the dependency expression underflows\r
246 the evaluation stack\r
247 EFI_INVALID_PARAMETER if the dependency expression is not a\r
248 well-formed Grammar.\r
249--*/\r
250;\r
251\r
252\r
253VOID\r
254PeiDispatcher (\r
255 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
256 IN PEI_CORE_INSTANCE *PrivateData\r
257 )\r
258\r
259/*++\r
260\r
261Routine Description:\r
262\r
263 Conduct PEIM dispatch.\r
264\r
265Arguments:\r
266\r
267 PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR\r
268 PrivateData - Pointer to the private data passed in from caller\r
269 DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.\r
270\r
271Returns:\r
272\r
273 EFI_SUCCESS - Successfully dispatched PEIM.\r
274 EFI_NOT_FOUND - The dispatch failed.\r
275\r
276--*/\r
277;\r
278\r
279\r
280VOID\r
281InitializeDispatcherData (\r
282 IN PEI_CORE_INSTANCE *PrivateData,\r
283 IN PEI_CORE_INSTANCE *OldCoreData,\r
284 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
285 )\r
286/*++\r
287\r
288Routine Description:\r
289\r
290 Initialize the Dispatcher's data members\r
291\r
292Arguments:\r
293\r
294 PeiServices - The PEI core services table.\r
295 OldCoreData - Pointer to old core data (before switching stack).\r
296 NULL if being run in non-permament memory mode.\r
297 PeiStartupDescriptor - Information and services provided by SEC phase.\r
298\r
299\r
300Returns:\r
301\r
302 None\r
303\r
304--*/\r
305;\r
306\r
307\r
308EFI_STATUS\r
309FindNextPeim (\r
310 IN EFI_PEI_SERVICES **PeiServices,\r
311 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,\r
312 IN OUT EFI_FFS_FILE_HEADER **PeimFileHeader\r
313 )\r
314/*++\r
315\r
316Routine Description:\r
317 Given the input file pointer, search for the next matching file in the\r
318 FFS volume. The search starts from FileHeader inside\r
319 the Firmware Volume defined by FwVolHeader.\r
320\r
321Arguments:\r
322 PeiServices - Pointer to the PEI Core Services Table.\r
323\r
324 FwVolHeader - Pointer to the FV header of the volume to search.\r
325 This parameter must point to a valid FFS volume.\r
326\r
327 PeimFileHeader - Pointer to the current file from which to begin searching.\r
328 This pointer will be updated upon return to reflect the file found.\r
329\r
330Returns:\r
331 EFI_NOT_FOUND - No files matching the search criteria were found\r
332 EFI_SUCCESS\r
333\r
334--*/\r
335;\r
336\r
337BOOLEAN\r
338Dispatched (\r
339 IN UINT8 CurrentPeim,\r
340 IN UINT32 DispatchedPeimBitMap\r
341 )\r
342/*++\r
343\r
344Routine Description:\r
345\r
346 This routine checks to see if a particular PEIM has been dispatched during\r
347 the PEI core dispatch.\r
348\r
349Arguments:\r
350 CurrentPeim - The PEIM/FV in the bit array to check.\r
351 DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.\r
352\r
353Returns:\r
354 TRUE if PEIM already dispatched\r
355 FALSE if not\r
356\r
357--*/\r
358;\r
359\r
360VOID\r
361SetDispatched (\r
362 IN EFI_PEI_SERVICES **PeiServices,\r
363 IN UINT8 CurrentPeim,\r
364 OUT UINT32 *DispatchedPeimBitMap\r
365 )\r
366/*++\r
367\r
368Routine Description:\r
369\r
370 This routine sets a PEIM as having been dispatched once its entry\r
371 point has been invoked.\r
372\r
373Arguments:\r
374\r
375 PeiServices - The PEI core services table.\r
376 CurrentPeim - The PEIM/FV in the bit array to check.\r
377 DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.\r
378\r
379Returns:\r
380 None\r
381\r
382--*/\r
383;\r
384\r
385BOOLEAN\r
386DepexSatisfied (\r
387 IN PEI_CORE_INSTANCE *Private,\r
388 IN EFI_PEI_FILE_HANDLE FileHandle,\r
389 IN UINTN PeimCount\r
390 )\r
391/*++\r
392\r
393Routine Description:\r
394\r
395 This routine parses the Dependency Expression, if available, and\r
396 decides if the module can be executed.\r
397\r
398Arguments:\r
399 PeiServices - The PEI Service Table\r
400 CurrentPeimAddress - Address of the PEIM Firmware File under investigation\r
401\r
402Returns:\r
403 TRUE - Can be dispatched\r
404 FALSE - Cannot be dispatched\r
405\r
406--*/\r
407;\r
408\r
409#if defined (MDE_CPU_IPF)\r
410 //\r
411 // In Ipf we should make special changes for the PHIT pointers to support\r
412 // recovery boot in cache mode.\r
413 //\r
414#define SWITCH_TO_CACHE_MODE(CoreData) SwitchToCacheMode(CoreData)\r
415#define CACHE_MODE_ADDRESS_MASK 0x7FFFFFFFFFFFFFFFULL\r
416VOID\r
417SwitchToCacheMode (\r
418 IN PEI_CORE_INSTANCE *CoreData\r
419)\r
420/*++\r
421\r
422Routine Description:\r
423\r
424 Switch the PHIT pointers to cache mode after InstallPeiMemory in CAR.\r
425\r
426Arguments:\r
427\r
428 CoreData - The PEI core Private Data\r
429\r
430Returns:\r
431\r
432--*/\r
433;\r
434\r
435#else\r
436\r
437#define SWITCH_TO_CACHE_MODE(CoreData)\r
438\r
439#endif\r
440\r
441//\r
442// PPI support functions\r
443//\r
444VOID\r
445InitializePpiServices (\r
446 IN PEI_CORE_INSTANCE *PrivateData,\r
447 IN PEI_CORE_INSTANCE *OldCoreData\r
448 )\r
449/*++\r
450\r
451Routine Description:\r
452\r
453 Initialize PPI services.\r
454\r
455Arguments:\r
456\r
457 PeiServices - The PEI core services table.\r
458 OldCoreData - Pointer to the PEI Core data.\r
459 NULL if being run in non-permament memory mode.\r
460\r
461Returns:\r
462 Nothing\r
463\r
464--*/\r
465;\r
466\r
467VOID\r
468ConvertPpiPointers (\r
469 IN CONST EFI_PEI_SERVICES **PeiServices,\r
470 IN EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffHob,\r
471 IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob\r
472 )\r
473/*++\r
474\r
475Routine Description:\r
476\r
477 Migrate the Hob list from the CAR stack to PEI installed memory.\r
478\r
479Arguments:\r
480\r
481 PeiServices - The PEI core services table.\r
482 OldHandOffHob - The old handoff HOB list.\r
483 NewHandOffHob - The new handoff HOB list.\r
484\r
485Returns:\r
486\r
487--*/\r
488;\r
489\r
490EFI_STATUS\r
491EFIAPI\r
492PeiInstallPpi (\r
493 IN CONST EFI_PEI_SERVICES **PeiServices,\r
494 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
495 )\r
496/*++\r
497\r
498Routine Description:\r
499\r
500 Install PPI services.\r
501\r
502Arguments:\r
503\r
504 PeiServices - Pointer to the PEI Service Table\r
505 PpiList - Pointer to a list of PEI PPI Descriptors.\r
506\r
507Returns:\r
508\r
509 EFI_SUCCESS - if all PPIs in PpiList are successfully installed.\r
510 EFI_INVALID_PARAMETER - if PpiList is NULL pointer\r
511 EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid\r
512 EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI\r
513\r
514--*/\r
515;\r
516\r
517EFI_STATUS\r
518EFIAPI\r
519PeiReInstallPpi (\r
520 IN CONST EFI_PEI_SERVICES **PeiServices,\r
521 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
522 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
523 )\r
524/*++\r
525\r
526Routine Description:\r
527\r
528 Re-Install PPI services.\r
529\r
530Arguments:\r
531\r
532 PeiServices - Pointer to the PEI Service Table\r
533 OldPpi - Pointer to the old PEI PPI Descriptors.\r
534 NewPpi - Pointer to the new PEI PPI Descriptors.\r
535\r
536Returns:\r
537\r
538 EFI_SUCCESS - if the operation was successful\r
539 EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL\r
540 EFI_INVALID_PARAMETER - if NewPpi is not valid\r
541 EFI_NOT_FOUND - if the PPI was not in the database\r
542\r
543--*/\r
544;\r
545\r
546EFI_STATUS\r
547EFIAPI\r
548PeiLocatePpi (\r
549 IN CONST EFI_PEI_SERVICES **PeiServices,\r
550 IN CONST EFI_GUID *Guid,\r
551 IN UINTN Instance,\r
552 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
553 IN OUT VOID **Ppi\r
554 )\r
555/*++\r
556\r
557Routine Description:\r
558\r
559 Locate a given named PPI.\r
560\r
561Arguments:\r
562\r
563 PeiServices - Pointer to the PEI Service Table\r
564 Guid - Pointer to GUID of the PPI.\r
565 Instance - Instance Number to discover.\r
566 PpiDescriptor - Pointer to reference the found descriptor. If not NULL,\r
567 returns a pointer to the descriptor (includes flags, etc)\r
568 Ppi - Pointer to reference the found PPI\r
569\r
570Returns:\r
571\r
572 Status - EFI_SUCCESS if the PPI is in the database\r
573 EFI_NOT_FOUND if the PPI is not in the database\r
574--*/\r
575;\r
576\r
577EFI_STATUS\r
578EFIAPI\r
579PeiNotifyPpi (\r
580 IN CONST EFI_PEI_SERVICES **PeiServices,\r
581 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
582 )\r
583/*++\r
584\r
585Routine Description:\r
586\r
587 Install a notification for a given PPI.\r
588\r
589Arguments:\r
590\r
591 PeiServices - Pointer to the PEI Service Table\r
592 NotifyList - Pointer to list of Descriptors to notify upon.\r
593\r
594Returns:\r
595\r
596 Status - EFI_SUCCESS if successful\r
597 EFI_OUT_OF_RESOURCES if no space in the database\r
598 EFI_INVALID_PARAMETER if not a good decriptor\r
599\r
600--*/\r
601;\r
602\r
603VOID\r
604ProcessNotifyList (\r
605 IN PEI_CORE_INSTANCE *PrivateData\r
606 )\r
607/*++\r
608\r
609Routine Description:\r
610\r
611 Process the Notify List at dispatch level.\r
612\r
613Arguments:\r
614\r
615 PeiServices - Pointer to the PEI Service Table\r
616\r
617Returns:\r
618\r
619--*/\r
620;\r
621\r
622VOID\r
623DispatchNotify (\r
624 IN PEI_CORE_INSTANCE *PrivateData,\r
625 IN UINTN NotifyType,\r
626 IN INTN InstallStartIndex,\r
627 IN INTN InstallStopIndex,\r
628 IN INTN NotifyStartIndex,\r
629 IN INTN NotifyStopIndex\r
630 )\r
631/*++\r
632\r
633Routine Description:\r
634\r
635 Dispatch notifications.\r
636\r
637Arguments:\r
638\r
639 PeiServices - Pointer to the PEI Service Table\r
640 NotifyType - Type of notify to fire.\r
641 InstallStartIndex - Install Beginning index.\r
642 InstallStopIndex - Install Ending index.\r
643 NotifyStartIndex - Notify Beginning index.\r
644 NotifyStopIndex - Notify Ending index.\r
645\r
646Returns: None\r
647\r
648--*/\r
649;\r
650\r
651//\r
652// Boot mode support functions\r
653//\r
654EFI_STATUS\r
655EFIAPI\r
656PeiGetBootMode (\r
657 IN CONST EFI_PEI_SERVICES **PeiServices,\r
658 IN OUT EFI_BOOT_MODE *BootMode\r
659 )\r
660/*++\r
661\r
662Routine Description:\r
663\r
664 This service enables PEIMs to ascertain the present value of the boot mode.\r
665\r
666Arguments:\r
667\r
668 PeiServices - The PEI core services table.\r
669 BootMode - A pointer to contain the value of the boot mode.\r
670\r
671Returns:\r
672\r
673 EFI_SUCCESS - The boot mode was returned successfully.\r
674 EFI_INVALID_PARAMETER - BootMode is NULL.\r
675\r
676--*/\r
677;\r
678\r
679EFI_STATUS\r
680EFIAPI\r
681PeiSetBootMode (\r
682 IN CONST EFI_PEI_SERVICES **PeiServices,\r
683 IN EFI_BOOT_MODE BootMode\r
684 )\r
685/*++\r
686\r
687Routine Description:\r
688\r
689 This service enables PEIMs to update the boot mode variable.\r
690\r
691Arguments:\r
692\r
693 PeiServices - The PEI core services table.\r
694 BootMode - The value of the boot mode to set.\r
695\r
696Returns:\r
697\r
698 EFI_SUCCESS - The value was successfully updated\r
699\r
700--*/\r
701;\r
702\r
703//\r
704// Security support functions\r
705//\r
706VOID\r
707InitializeSecurityServices (\r
708 IN EFI_PEI_SERVICES **PeiServices,\r
709 IN PEI_CORE_INSTANCE *OldCoreData\r
710 )\r
711/*++\r
712\r
713Routine Description:\r
714\r
715 Initialize the security services.\r
716\r
717Arguments:\r
718\r
719 PeiServices - The PEI core services table.\r
720 OldCoreData - Pointer to the old core data.\r
721 NULL if being run in non-permament memory mode.\r
722Returns:\r
723\r
724 None\r
725\r
726--*/\r
727;\r
728\r
729EFI_STATUS\r
730VerifyFv (\r
731 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
732 )\r
733/*++\r
734\r
735Routine Description:\r
736\r
737 Provide a callout to the OEM FV verification service.\r
738\r
739Arguments:\r
740\r
741 CurrentFvAddress - Pointer to the FV under investigation.\r
742\r
743Returns:\r
744\r
745 Status - EFI_SUCCESS\r
746\r
747--*/\r
748;\r
749\r
750\r
751EFI_STATUS\r
752VerifyPeim (\r
753 IN PEI_CORE_INSTANCE *PrivateData,\r
754 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
755 IN EFI_PEI_FILE_HANDLE FileHandle\r
756 )\r
757/*++\r
758\r
759Routine Description:\r
760\r
761 Provide a callout to the security verification service.\r
762\r
763Arguments:\r
764\r
765 PeiServices - The PEI core services table.\r
766 CurrentPeimAddress - Pointer to the Firmware File under investigation.\r
767\r
768Returns:\r
769\r
770 EFI_SUCCESS - Image is OK\r
771 EFI_SECURITY_VIOLATION - Image is illegal\r
772\r
773--*/\r
774;\r
775\r
776\r
777EFI_STATUS\r
778EFIAPI\r
779PeiGetHobList (\r
780 IN CONST EFI_PEI_SERVICES **PeiServices,\r
781 IN OUT VOID **HobList\r
782 )\r
783/*++\r
784\r
785Routine Description:\r
786\r
787 Gets the pointer to the HOB List.\r
788\r
789Arguments:\r
790\r
791 PeiServices - The PEI core services table.\r
792 HobList - Pointer to the HOB List.\r
793\r
794Returns:\r
795\r
796 EFI_SUCCESS - Get the pointer of HOB List\r
797 EFI_NOT_AVAILABLE_YET - the HOB List is not yet published\r
798 EFI_INVALID_PARAMETER - HobList is NULL (in debug mode)\r
799\r
800--*/\r
801;\r
802\r
803EFI_STATUS\r
804EFIAPI\r
805PeiCreateHob (\r
806 IN CONST EFI_PEI_SERVICES **PeiServices,\r
807 IN UINT16 Type,\r
808 IN UINT16 Length,\r
809 IN OUT VOID **Hob\r
810 )\r
811/*++\r
812\r
813Routine Description:\r
814\r
815 Add a new HOB to the HOB List.\r
816\r
817Arguments:\r
818\r
819 PeiServices - The PEI core services table.\r
820 Type - Type of the new HOB.\r
821 Length - Length of the new HOB to allocate.\r
822 Hob - Pointer to the new HOB.\r
823\r
824Returns:\r
825\r
826 Status - EFI_SUCCESS\r
827 - EFI_INVALID_PARAMETER if Hob is NULL\r
828 - EFI_NOT_AVAILABLE_YET if HobList is still not available.\r
829 - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.\r
830\r
831--*/\r
832;\r
833\r
834EFI_STATUS\r
835PeiCoreBuildHobHandoffInfoTable (\r
836 IN EFI_BOOT_MODE BootMode,\r
837 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
838 IN UINT64 MemoryLength\r
839 )\r
840/*++\r
841\r
842Routine Description:\r
843\r
844 Builds a Handoff Information Table HOB\r
845\r
846Arguments:\r
847\r
848 BootMode - Current Bootmode\r
849 MemoryBegin - Start Memory Address.\r
850 MemoryLength - Length of Memory.\r
851\r
852Returns:\r
853\r
854 EFI_SUCCESS\r
855\r
856--*/\r
857;\r
858\r
859\r
860//\r
861// FFS Fw Volume support functions\r
862//\r
863EFI_STATUS\r
864EFIAPI\r
865PeiFfsFindNextFile (\r
866 IN CONST EFI_PEI_SERVICES **PeiServices,\r
867 IN UINT8 SearchType,\r
868 IN EFI_PEI_FV_HANDLE FwVolHeader,\r
869 IN OUT EFI_PEI_FILE_HANDLE *FileHeader\r
870 )\r
871/*++\r
872\r
873Routine Description:\r
874 Given the input file pointer, search for the next matching file in the\r
875 FFS volume as defined by SearchType. The search starts from FileHeader inside\r
876 the Firmware Volume defined by FwVolHeader.\r
877\r
878Arguments:\r
879 PeiServices - Pointer to the PEI Core Services Table.\r
880\r
881 SearchType - Filter to find only files of this type.\r
882 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
883\r
884 FwVolHeader - Pointer to the FV header of the volume to search.\r
885 This parameter must point to a valid FFS volume.\r
886\r
887 FileHeader - Pointer to the current file from which to begin searching.\r
888 This pointer will be updated upon return to reflect the file found.\r
889\r
890Returns:\r
891 EFI_NOT_FOUND - No files matching the search criteria were found\r
892 EFI_SUCCESS\r
893\r
894--*/\r
895;\r
896\r
897EFI_STATUS\r
898EFIAPI\r
899PeiFfsFindSectionData (\r
900 IN CONST EFI_PEI_SERVICES **PeiServices,\r
901 IN EFI_SECTION_TYPE SectionType,\r
902 IN EFI_PEI_FILE_HANDLE FfsFileHeader,\r
903 IN OUT VOID **SectionData\r
904 )\r
905/*++\r
906\r
907Routine Description:\r
908 Given the input file pointer, search for the next matching section in the\r
909 FFS volume.\r
910\r
911Arguments:\r
912 PeiServices - Pointer to the PEI Core Services Table.\r
913 SearchType - Filter to find only sections of this type.\r
914 FfsFileHeader - Pointer to the current file to search.\r
915 SectionData - Pointer to the Section matching SectionType in FfsFileHeader.\r
916 - NULL if section not found\r
917\r
918Returns:\r
919 EFI_NOT_FOUND - No files matching the search criteria were found\r
920 EFI_SUCCESS\r
921\r
922--*/\r
923;\r
924\r
925EFI_STATUS\r
926EFIAPI\r
927PeiFvFindNextVolume (\r
928 IN CONST EFI_PEI_SERVICES **PeiServices,\r
929 IN UINTN Instance,\r
930 IN OUT EFI_PEI_FV_HANDLE *FwVolHeader\r
931 )\r
932/*++\r
933\r
934Routine Description:\r
935\r
936 Return the BFV location\r
937\r
938 BugBug -- Move this to the location of this code to where the\r
939 other FV and FFS support code lives.\r
940 Also, update to use FindFV for instances #'s >= 1.\r
941\r
942Arguments:\r
943\r
944 PeiServices - The PEI core services table.\r
945 Instance - Instance of FV to find\r
946 FwVolHeader - Pointer to contain the data to return\r
947\r
948Returns:\r
949 Pointer to the Firmware Volume instance requested\r
950\r
951 EFI_INVALID_PARAMETER - FwVolHeader is NULL\r
952\r
953 EFI_SUCCESS - Firmware volume instance successfully found.\r
954\r
955--*/\r
956;\r
957\r
958//\r
959// Memory support functions\r
960//\r
961VOID\r
962InitializeMemoryServices (\r
963 IN PEI_CORE_INSTANCE *PrivateData,\r
964 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
965 IN PEI_CORE_INSTANCE *OldCoreData\r
966 )\r
967/*++\r
968\r
969Routine Description:\r
970\r
971 Initialize the memory services.\r
972\r
973Arguments:\r
974\r
975 PeiServices - The PEI core services table.\r
976 PeiStartupDescriptor - Information and services provided by SEC phase.\r
977 OldCoreData - Pointer to the PEI Core data.\r
978 NULL if being run in non-permament memory mode.\r
979\r
980Returns:\r
981\r
982 None\r
983\r
984--*/\r
985;\r
986\r
987EFI_STATUS\r
988EFIAPI\r
989PeiInstallPeiMemory (\r
990 IN CONST EFI_PEI_SERVICES **PeiServices,\r
991 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
992 IN UINT64 MemoryLength\r
993 )\r
994/*++\r
995\r
996Routine Description:\r
997\r
998 Install the permanent memory is now available.\r
999 Creates HOB (PHIT and Stack).\r
1000\r
1001Arguments:\r
1002\r
1003 PeiServices - The PEI core services table.\r
1004 MemoryBegin - Start of memory address.\r
1005 MemoryLength - Length of memory.\r
1006\r
1007Returns:\r
1008\r
1009 Status - EFI_SUCCESS\r
1010\r
1011--*/\r
1012;\r
1013\r
1014EFI_STATUS\r
1015EFIAPI\r
1016PeiAllocatePages (\r
1017 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1018 IN EFI_MEMORY_TYPE MemoryType,\r
1019 IN UINTN Pages,\r
1020 OUT EFI_PHYSICAL_ADDRESS *Memory\r
1021 )\r
1022/*++\r
1023\r
1024Routine Description:\r
1025\r
1026 Memory allocation service on permanent memory,\r
1027 not usable prior to the memory installation.\r
1028\r
1029Arguments:\r
1030\r
1031 PeiServices - The PEI core services table.\r
1032 Type - Type of allocation.\r
1033 MemoryType - Type of memory to allocate.\r
1034 Pages - Number of pages to allocate.\r
1035 Memory - Pointer of memory allocated.\r
1036\r
1037Returns:\r
1038\r
1039 Status - EFI_SUCCESS The allocation was successful\r
1040 EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.\r
1041 EFI_NOT_AVAILABLE_YET Called with permanent memory not available\r
1042 EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement\r
1043 to allocate the number of pages.\r
1044\r
1045--*/\r
1046;\r
1047\r
1048EFI_STATUS\r
1049EFIAPI\r
1050PeiAllocatePool (\r
1051 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1052 IN UINTN Size,\r
1053 OUT VOID **Buffer\r
1054 )\r
1055/*++\r
1056\r
1057Routine Description:\r
1058\r
1059 Memory allocation service on the CAR.\r
1060\r
1061Arguments:\r
1062\r
1063 PeiServices - The PEI core services table.\r
1064\r
1065 Size - Amount of memory required\r
1066\r
1067 Buffer - Address of pointer to the buffer\r
1068\r
1069Returns:\r
1070\r
1071 Status - EFI_SUCCESS The allocation was successful\r
1072 EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement\r
1073 to allocate the requested size.\r
1074\r
1075--*/\r
1076;\r
1077\r
1078EFI_STATUS\r
1079PeiLoadImage (\r
1080 IN EFI_PEI_SERVICES **PeiServices,\r
1081 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1082 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
1083 OUT UINT32 *AuthenticationState\r
1084 )\r
1085/*++\r
1086\r
1087Routine Description:\r
1088\r
1089 Get entry point of a Peim file.\r
1090\r
1091Arguments:\r
1092\r
1093 PeiServices - Calling context.\r
1094\r
1095 PeimFileHeader - Peim file's header.\r
1096\r
1097 EntryPoint - Entry point of that Peim file.\r
1098\r
1099Returns:\r
1100\r
1101 Status code.\r
1102\r
1103--*/\r
1104;\r
1105\r
1106\r
1107EFI_STATUS\r
1108EFIAPI\r
1109PeiReportStatusCode (\r
1110 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1111 IN EFI_STATUS_CODE_TYPE CodeType,\r
1112 IN EFI_STATUS_CODE_VALUE Value,\r
1113 IN UINT32 Instance,\r
1114 IN CONST EFI_GUID *CallerId,\r
1115 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
1116 )\r
1117/*++\r
1118\r
1119Routine Description:\r
1120\r
1121 Core version of the Status Code reporter\r
1122\r
1123Arguments:\r
1124\r
1125 PeiServices - The PEI core services table.\r
1126\r
1127 CodeType - Type of Status Code.\r
1128\r
1129 Value - Value to output for Status Code.\r
1130\r
1131 Instance - Instance Number of this status code.\r
1132\r
1133 CallerId - ID of the caller of this status code.\r
1134\r
1135 Data - Optional data associated with this status code.\r
1136\r
1137Returns:\r
1138\r
1139 Status - EFI_SUCCESS if status code is successfully reported\r
1140 - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed\r
1141\r
1142--*/\r
1143;\r
1144\r
1145\r
1146EFI_STATUS\r
1147EFIAPI\r
1148PeiResetSystem (\r
1149 IN CONST EFI_PEI_SERVICES **PeiServices\r
1150 )\r
1151/*++\r
1152\r
1153Routine Description:\r
1154\r
1155 Core version of the Reset System\r
1156\r
1157Arguments:\r
1158\r
1159 PeiServices - The PEI core services table.\r
1160\r
1161Returns:\r
1162\r
1163 Status - EFI_NOT_AVAILABLE_YET. PPI not available yet.\r
1164 - EFI_DEVICE_ERROR. Did not reset system.\r
1165\r
1166 Otherwise, resets the system.\r
1167\r
1168--*/\r
1169;\r
1170\r
1171VOID \r
1172PeiInitializeFv (\r
1173 IN PEI_CORE_INSTANCE *PrivateData,\r
1174 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
1175 )\r
1176/*++\r
1177\r
1178Routine Description:\r
1179\r
1180 Initialize PeiCore Fv List.\r
1181\r
1182Arguments:\r
1183 PrivateData - Pointer to PEI_CORE_INSTANCE.\r
1184 SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.\r
1185\r
1186Returns:\r
1187 NONE \r
1188 \r
1189--*/ \r
1190;\r
1191\r
1192EFI_STATUS\r
1193EFIAPI\r
1194FirmwareVolmeInfoPpiNotifyCallback (\r
1195 IN EFI_PEI_SERVICES **PeiServices,\r
1196 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
1197 IN VOID *Ppi\r
1198 )\r
1199/*++\r
1200\r
1201Routine Description:\r
1202\r
1203 Process Firmware Volum Information once FvInfoPPI install.\r
1204\r
1205Arguments:\r
1206\r
1207 PeiServices - General purpose services available to every PEIM.\r
1208 \r
1209Returns:\r
1210\r
1211 Status - EFI_SUCCESS if the interface could be successfully\r
1212 installed\r
1213\r
1214--*/\r
1215;\r
1216\r
1217\r
1218EFI_STATUS\r
1219EFIAPI \r
1220PeiFfsFindFileByName (\r
1221 IN CONST EFI_GUID *FileName,\r
1222 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
1223 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
1224 )\r
1225/*++\r
1226\r
1227Routine Description:\r
1228\r
1229 Given the input VolumeHandle, search for the next matching name file.\r
1230\r
1231Arguments:\r
1232\r
1233 FileName - File name to search.\r
1234 VolumeHandle - The current FV to search.\r
1235 FileHandle - Pointer to the file matching name in VolumeHandle.\r
1236 - NULL if file not found\r
1237Returns:\r
1238 EFI_STATUS\r
1239 \r
1240--*/ \r
1241;\r
1242\r
1243\r
1244EFI_STATUS\r
1245EFIAPI \r
1246PeiFfsGetFileInfo (\r
1247 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1248 OUT EFI_FV_FILE_INFO *FileInfo\r
1249 )\r
1250/*++\r
1251\r
1252Routine Description:\r
1253\r
1254 Collect information of given file.\r
1255\r
1256Arguments:\r
1257 FileHandle - The handle to file.\r
1258 FileInfo - Pointer to the file information.\r
1259\r
1260Returns:\r
1261 EFI_STATUS\r
1262 \r
1263--*/ \r
1264;\r
1265\r
1266EFI_STATUS\r
1267EFIAPI \r
1268PeiFfsGetVolumeInfo (\r
1269 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
1270 OUT EFI_FV_INFO *VolumeInfo\r
1271 )\r
1272/*++\r
1273\r
1274Routine Description:\r
1275\r
1276 Collect information of given Fv Volume.\r
1277\r
1278Arguments:\r
1279 VolumeHandle - The handle to Fv Volume.\r
1280 VolumeInfo - The pointer to volume information.\r
1281 \r
1282Returns:\r
1283 EFI_STATUS\r
1284 \r
1285--*/ \r
1286;\r
1287\r
1288\r
1289EFI_STATUS\r
1290EFIAPI\r
1291PeiRegisterForShadow (\r
1292 IN EFI_PEI_FILE_HANDLE FileHandle\r
1293 )\r
1294/*++\r
1295\r
1296Routine Description:\r
1297\r
1298 This routine enable a PEIM to register itself to shadow when PEI Foundation\r
1299 discovery permanent memory.\r
1300\r
1301Arguments:\r
1302 FileHandle - File handle of a PEIM.\r
1303 \r
1304Returns:\r
1305 EFI_NOT_FOUND - The file handle doesn't point to PEIM itself.\r
1306 EFI_ALREADY_STARTED - Indicate that the PEIM has been registered itself.\r
1307 EFI_SUCCESS - Successfully to register itself.\r
1308\r
1309--*/ \r
1310;\r
1311\r
1312\r
1313/**\r
1314 This routine enable a PEIM to register itself to shadow when PEI Foundation\r
1315 discovery permanent memory.\r
1316\r
1317 @param FileHandle File handle of a PEIM.\r
1318 \r
1319 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.\r
1320 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.\r
1321 @retval EFI_SUCCESS Successfully to register itself.\r
1322\r
1323**/ \r
1324EFI_STATUS\r
1325EFIAPI\r
1326PeiRegisterForShadow (\r
1327 IN EFI_PEI_FILE_HANDLE FileHandle\r
1328 )\r
1329;\r
1330\r
1331/**\r
1332 Transfers control to a function starting with a new stack.\r
1333\r
1334 Transfers control to the function specified by EntryPoint using the new stack\r
1335 specified by NewStack and passing in the parameters specified by Context1 and\r
1336 Context2. Context1 and Context2 are optional and may be NULL. The function\r
1337 EntryPoint must never return.\r
1338\r
1339 If EntryPoint is NULL, then ASSERT().\r
1340 If NewStack is NULL, then ASSERT().\r
1341\r
1342 @param EntryPoint A pointer to function to call with the new stack.\r
1343 @param Context1 A pointer to the context to pass into the EntryPoint\r
1344 function.\r
1345 @param Context2 A pointer to the context to pass into the EntryPoint\r
1346 function.\r
1347 @param NewStack A pointer to the new stack to use for the EntryPoint\r
1348 function.\r
1349 @param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's\r
1350 Reserved on other architectures.\r
1351\r
1352**/\r
1353VOID\r
1354EFIAPI\r
1355PeiSwitchStacks (\r
1356 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
1357 IN VOID *Context1, OPTIONAL\r
1358 IN VOID *Context2, OPTIONAL\r
1359 IN VOID *NewStack,\r
1360 IN VOID *NewBsp\r
1361 );\r
1362\r
1363EFI_STATUS\r
1364PeiFindFileEx (\r
1365 IN CONST EFI_PEI_FV_HANDLE FvHandle,\r
1366 IN CONST EFI_GUID *FileName, OPTIONAL\r
1367 IN EFI_FV_FILETYPE SearchType,\r
1368 IN OUT EFI_PEI_FILE_HANDLE *FileHandle,\r
1369 IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL\r
1370 )\r
1371/*++\r
1372\r
1373Routine Description:\r
1374 Given the input file pointer, search for the next matching file in the\r
1375 FFS volume as defined by SearchType. The search starts from FileHeader inside\r
1376 the Firmware Volume defined by FwVolHeader.\r
1377\r
1378Arguments:\r
1379 PeiServices - Pointer to the PEI Core Services Table.\r
1380 SearchType - Filter to find only files of this type.\r
1381 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
1382 FwVolHeader - Pointer to the FV header of the volume to search.\r
1383 This parameter must point to a valid FFS volume.\r
1384 FileHeader - Pointer to the current file from which to begin searching.\r
1385 This pointer will be updated upon return to reflect the file found.\r
1386 Flag - Indicator for if this is for PEI Dispath search \r
1387 \r
1388Returns:\r
1389 EFI_NOT_FOUND - No files matching the search criteria were found\r
1390 EFI_SUCCESS\r
1391\r
1392--*/\r
1393;\r
1394\r
1395VOID\r
1396InitializeImageServices (\r
1397 IN PEI_CORE_INSTANCE *PrivateData,\r
1398 IN PEI_CORE_INSTANCE *OldCoreData\r
1399 )\r
1400/*++\r
1401\r
1402Routine Description:\r
1403\r
1404 Regitser PeCoffLoader to PeiCore PrivateData. And install\r
1405 Pei Load File PPI.\r
1406\r
1407Arguments:\r
1408\r
1409 PrivateData - Pointer to PEI_CORE_INSTANCE.\r
1410 OldCoreData - Pointer to PEI_CORE_INSTANCE.\r
1411\r
1412Returns:\r
1413\r
1414 NONE.\r
1415 \r
1416--*/ \r
1417;\r
1418\r
1419#endif\r