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