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