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