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