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