]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Pei/PeiMain.h
Enable the Load Module At fixed Address feature
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
... / ...
CommitLineData
1/** @file\r
2 Definition of Pei Core Structures and Services\r
3 \r
4Copyright (c) 2006 - 2010, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _PEI_MAIN_H_\r
16#define _PEI_MAIN_H_\r
17\r
18#include <PiPei.h>\r
19#include <Ppi/DxeIpl.h>\r
20#include <Ppi/MemoryDiscovered.h>\r
21#include <Ppi/StatusCode.h>\r
22#include <Ppi/Reset.h>\r
23#include <Ppi/FirmwareVolume.h>\r
24#include <Ppi/FirmwareVolumeInfo.h>\r
25#include <Ppi/Decompress.h>\r
26#include <Ppi/GuidedSectionExtraction.h>\r
27#include <Ppi/LoadFile.h>\r
28#include <Ppi/Security2.h>\r
29#include <Ppi/TemporaryRamSupport.h>\r
30#include <Library/DebugLib.h>\r
31#include <Library/PeiCoreEntryPoint.h>\r
32#include <Library/BaseLib.h>\r
33#include <Library/HobLib.h>\r
34#include <Library/PerformanceLib.h>\r
35#include <Library/PeiServicesLib.h>\r
36#include <Library/ReportStatusCodeLib.h>\r
37#include <Library/PeCoffLib.h>\r
38#include <Library/PeCoffGetEntryPointLib.h>\r
39#include <Library/BaseMemoryLib.h>\r
40#include <Library/CacheMaintenanceLib.h>\r
41#include <Library/TimerLib.h>\r
42#include <Library/PcdLib.h>\r
43#include <IndustryStandard/PeImage.h>\r
44#include <Library/PeiServicesTablePointerLib.h>\r
45#include <Library/MemoryAllocationLib.h>\r
46#include <Guid/FirmwareFileSystem2.h>\r
47#include <Guid/AprioriFileName.h>\r
48\r
49///\r
50/// It is an FFS type extension used for PeiFindFileEx. It indicates current\r
51/// Ffs searching is for all PEIMs can be dispatched by PeiCore.\r
52///\r
53#define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE 0xff\r
54\r
55///\r
56/// Pei Core private data structures\r
57///\r
58typedef union {\r
59 EFI_PEI_PPI_DESCRIPTOR *Ppi;\r
60 EFI_PEI_NOTIFY_DESCRIPTOR *Notify;\r
61 VOID *Raw;\r
62} PEI_PPI_LIST_POINTERS;\r
63\r
64///\r
65/// PPI database structure which contains two link: PpiList and NotifyList. PpiList\r
66/// is in head of PpiListPtrs array and notify is in end of PpiListPtrs.\r
67///\r
68typedef struct {\r
69 ///\r
70 /// index of end of PpiList link list.\r
71 ///\r
72 INTN PpiListEnd;\r
73 ///\r
74 /// index of end of notify link list.\r
75 ///\r
76 INTN NotifyListEnd;\r
77 ///\r
78 /// index of the dispatched notify list.\r
79 ///\r
80 INTN DispatchListEnd;\r
81 ///\r
82 /// index of last installed Ppi description in PpiList link list.\r
83 ///\r
84 INTN LastDispatchedInstall;\r
85 ///\r
86 /// index of last dispatched notify in Notify link list.\r
87 /// \r
88 INTN LastDispatchedNotify;\r
89 ///\r
90 /// Ppi database.\r
91 ///\r
92 PEI_PPI_LIST_POINTERS PpiListPtrs[FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)];\r
93} PEI_PPI_DATABASE;\r
94\r
95\r
96//\r
97// PEI_CORE_FV_HANDE.PeimState\r
98// Do not change these values as there is code doing math to change states.\r
99// Look for Private->Fv[FvCount].PeimState[PeimCount]++;\r
100//\r
101#define PEIM_STATE_NOT_DISPATCHED 0x00\r
102#define PEIM_STATE_DISPATCHED 0x01\r
103#define PEIM_STATE_REGISITER_FOR_SHADOW 0x02\r
104#define PEIM_STATE_DONE 0x03\r
105\r
106typedef struct {\r
107 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
108 EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;\r
109 EFI_PEI_FV_HANDLE FvHandle;\r
110 UINT8 PeimState[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
111 EFI_PEI_FILE_HANDLE FvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
112 BOOLEAN ScanFv;\r
113} PEI_CORE_FV_HANDLE;\r
114\r
115typedef struct {\r
116 EFI_GUID FvFormat;\r
117 VOID *FvInfo;\r
118 UINT32 FvInfoSize;\r
119 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;\r
120} PEI_CORE_UNKNOW_FORMAT_FV_INFO;\r
121\r
122#define CACHE_SETION_MAX_NUMBER 0x10\r
123typedef struct {\r
124 EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];\r
125 VOID* SectionData[CACHE_SETION_MAX_NUMBER];\r
126 UINTN SectionSize[CACHE_SETION_MAX_NUMBER];\r
127 UINTN AllSectionCount;\r
128 UINTN SectionIndex;\r
129} CACHE_SECTION_DATA;\r
130\r
131\r
132#define PEI_CORE_HANDLE_SIGNATURE SIGNATURE_32('P','e','i','C')\r
133\r
134///\r
135/// Pei Core private data structure instance\r
136///\r
137typedef struct{\r
138 UINTN Signature;\r
139 \r
140 ///\r
141 /// Point to ServiceTableShadow\r
142 ///\r
143 EFI_PEI_SERVICES *PS;\r
144 PEI_PPI_DATABASE PpiData;\r
145 \r
146 ///\r
147 /// The count of FVs which contains FFS and could be dispatched by PeiCore.\r
148 ///\r
149 UINTN FvCount;\r
150 \r
151 ///\r
152 /// The instance arrary for FVs which contains FFS and could be dispatched by PeiCore.\r
153 ///\r
154 PEI_CORE_FV_HANDLE Fv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
155 PEI_CORE_UNKNOW_FORMAT_FV_INFO UnknownFvInfo[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
156 UINTN UnknownFvInfoCount;\r
157 \r
158 EFI_PEI_FILE_HANDLE CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
159 UINTN AprioriCount;\r
160 UINTN CurrentPeimFvCount;\r
161 UINTN CurrentPeimCount;\r
162 EFI_PEI_FILE_HANDLE CurrentFileHandle;\r
163 BOOLEAN PeimNeedingDispatch;\r
164 BOOLEAN PeimDispatchOnThisPass;\r
165 BOOLEAN PeimDispatcherReenter;\r
166 EFI_PEI_HOB_POINTERS HobList;\r
167 BOOLEAN SwitchStackSignal;\r
168 BOOLEAN PeiMemoryInstalled;\r
169 EFI_PHYSICAL_ADDRESS StackBase;\r
170 UINT64 StackSize;\r
171 VOID *CpuIo;\r
172 EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi;\r
173 EFI_PEI_SERVICES ServiceTableShadow;\r
174 EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;\r
175 EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin;\r
176 UINT64 PhysicalMemoryLength;\r
177 EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop;\r
178 VOID* ShadowedPeiCore;\r
179 CACHE_SECTION_DATA CacheSection;\r
180 //\r
181 // For Loading modules at fixed address feature to cache the top address below which the \r
182 // Runtime code, boot time code and PEI memory will be placed. Please note that the offset between this field \r
183 // and PS should not be changed since maybe user could get this top address by using the offet to PS. \r
184 //\r
185 EFI_PHYSICAL_ADDRESS LoadModuleAtFixAddressTopAddress;\r
186 //\r
187 // The field is define for Loading modules at fixed address feature to tracker the PEI code\r
188 // memory range usage. It is a bit mapped array in which every bit indicates the correspoding memory page\r
189 // available or not. \r
190 //\r
191 UINT64 *PeiCodeMemoryRangeUsageBitMap;\r
192} PEI_CORE_INSTANCE;\r
193\r
194///\r
195/// Pei Core Instance Data Macros\r
196///\r
197#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \\r
198 CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)\r
199\r
200/**\r
201 Function Pointer type for PeiCore function.\r
202 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
203 and location of temporary RAM, the stack location and the BFV location.\r
204 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
205 An empty PPI list consists of a single descriptor with the end-tag\r
206 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
207 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
208 that both the PEI Foundation and any modules can leverage the associated service\r
209 calls and/or code in these early PPIs\r
210 @param OldCoreData Pointer to old core data that is used to initialize the\r
211 core's data areas.\r
212**/\r
213typedef\r
214EFI_STATUS\r
215(EFIAPI *PEICORE_FUNCTION_POINTER)(\r
216 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
217 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
218 IN PEI_CORE_INSTANCE *OldCoreData\r
219 );\r
220\r
221///\r
222/// Union of temporarily used function pointers (to save stack space)\r
223///\r
224typedef union {\r
225 PEICORE_FUNCTION_POINTER PeiCore;\r
226 EFI_PEIM_ENTRY_POINT2 PeimEntry;\r
227 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;\r
228 EFI_DXE_IPL_PPI *DxeIpl;\r
229 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
230 EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;\r
231 VOID *Raw;\r
232} PEI_CORE_TEMP_POINTERS;\r
233\r
234typedef struct {\r
235 CONST EFI_SEC_PEI_HAND_OFF *SecCoreData;\r
236 EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
237 VOID *Data;\r
238} PEI_CORE_PARAMETERS;\r
239\r
240//\r
241// PeiCore function\r
242//\r
243/**\r
244\r
245 The entry routine to Pei Core, invoked by PeiMain during transition\r
246 from SEC to PEI. After switching stack in the PEI core, it will restart\r
247 with the old core data.\r
248\r
249\r
250 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
251 and location of temporary RAM, the stack location and the BFV location.\r
252 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
253 An empty PPI list consists of a single descriptor with the end-tag\r
254 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
255 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
256 that both the PEI Foundation and any modules can leverage the associated service\r
257 calls and/or code in these early PPIs\r
258 @param Data Pointer to old core data that is used to initialize the\r
259 core's data areas.\r
260\r
261**/\r
262VOID\r
263EFIAPI\r
264PeiCore (\r
265 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
266 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
267 IN VOID *Data\r
268 );\r
269\r
270//\r
271// Dispatcher support functions\r
272//\r
273\r
274/**\r
275\r
276 This is the POSTFIX version of the dependency evaluator. When a\r
277 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on\r
278 the evaluation stack. When that entry is poped from the evaluation\r
279 stack, the PPI is checked if it is installed. This method allows\r
280 some time savings as not all PPIs must be checked for certain\r
281 operation types (AND, OR).\r
282\r
283\r
284 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
285 @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to\r
286 the BNF described above and is stored in postfix notation.\r
287\r
288 @retval TRUE if it is a well-formed Grammar\r
289 @retval FALSE if the dependency expression overflows the evaluation stack\r
290 if the dependency expression underflows the evaluation stack\r
291 if the dependency expression is not a well-formed Grammar.\r
292\r
293**/\r
294BOOLEAN\r
295PeimDispatchReadiness (\r
296 IN EFI_PEI_SERVICES **PeiServices,\r
297 IN VOID *DependencyExpression\r
298 );\r
299\r
300/**\r
301 Conduct PEIM dispatch.\r
302\r
303 @param SecCoreData Pointer to the data structure containing SEC to PEI handoff data\r
304 @param PrivateData Pointer to the private data passed in from caller\r
305\r
306**/\r
307VOID\r
308PeiDispatcher (\r
309 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
310 IN PEI_CORE_INSTANCE *PrivateData\r
311 );\r
312\r
313/**\r
314 Initialize the Dispatcher's data members\r
315\r
316 @param PrivateData PeiCore's private data structure\r
317 @param OldCoreData Old data from SecCore\r
318 NULL if being run in non-permament memory mode.\r
319 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
320 and location of temporary RAM, the stack location and the BFV location.\r
321\r
322**/\r
323VOID\r
324InitializeDispatcherData (\r
325 IN PEI_CORE_INSTANCE *PrivateData,\r
326 IN PEI_CORE_INSTANCE *OldCoreData,\r
327 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
328 );\r
329\r
330/**\r
331 This routine parses the Dependency Expression, if available, and\r
332 decides if the module can be executed.\r
333\r
334\r
335 @param Private PeiCore's private data structure\r
336 @param FileHandle PEIM's file handle\r
337 @param PeimCount The index of last dispatched PEIM.\r
338\r
339 @retval TRUE Can be dispatched\r
340 @retval FALSE Cannot be dispatched\r
341\r
342**/\r
343BOOLEAN\r
344DepexSatisfied (\r
345 IN PEI_CORE_INSTANCE *Private,\r
346 IN EFI_PEI_FILE_HANDLE FileHandle,\r
347 IN UINTN PeimCount\r
348 );\r
349\r
350//\r
351// PPI support functions\r
352//\r
353/**\r
354\r
355 Initialize PPI services.\r
356\r
357 @param PrivateData Pointer to the PEI Core data.\r
358 @param OldCoreData Pointer to old PEI Core data. \r
359 NULL if being run in non-permament memory mode.\r
360\r
361**/\r
362VOID\r
363InitializePpiServices (\r
364 IN PEI_CORE_INSTANCE *PrivateData,\r
365 IN PEI_CORE_INSTANCE *OldCoreData\r
366 );\r
367\r
368/**\r
369\r
370 Migrate the Hob list from the temporary memory stack to PEI installed memory.\r
371\r
372 @param PrivateData Pointer to PeiCore's private data structure.\r
373 @param OldCheckingBottom Bottom of temporary memory range. All Ppi in this range\r
374 will be fixup for PpiData and PpiDescriptor pointer.\r
375 @param OldCheckingTop Top of temporary memory range. All Ppi in this range\r
376 will be fixup for PpiData and PpiDescriptor.\r
377 @param Fixup The address difference between\r
378 the new Hob list and old Hob list.\r
379\r
380**/\r
381VOID\r
382ConvertPpiPointers (\r
383 IN PEI_CORE_INSTANCE *PrivateData,\r
384 IN UINTN OldCheckingBottom,\r
385 IN UINTN OldCheckingTop,\r
386 IN INTN Fixup\r
387 );\r
388\r
389/**\r
390\r
391 Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.\r
392\r
393 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
394 @param PpiList Pointer to ppi array that want to be installed.\r
395\r
396 @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.\r
397 @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer\r
398 if any PPI in PpiList is not valid\r
399 @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI\r
400\r
401**/\r
402EFI_STATUS\r
403EFIAPI\r
404PeiInstallPpi (\r
405 IN CONST EFI_PEI_SERVICES **PeiServices,\r
406 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
407 );\r
408\r
409/**\r
410\r
411 Re-Install PPI services.\r
412\r
413 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
414 @param OldPpi Pointer to the old PEI PPI Descriptors.\r
415 @param NewPpi Pointer to the new PEI PPI Descriptors.\r
416\r
417 @retval EFI_SUCCESS if the operation was successful\r
418 @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL\r
419 if NewPpi is not valid\r
420 @retval EFI_NOT_FOUND if the PPI was not in the database\r
421\r
422**/\r
423EFI_STATUS\r
424EFIAPI\r
425PeiReInstallPpi (\r
426 IN CONST EFI_PEI_SERVICES **PeiServices,\r
427 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
428 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
429 );\r
430\r
431/**\r
432\r
433 Locate a given named PPI.\r
434\r
435\r
436 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
437 @param Guid Pointer to GUID of the PPI.\r
438 @param Instance Instance Number to discover.\r
439 @param PpiDescriptor Pointer to reference the found descriptor. If not NULL,\r
440 returns a pointer to the descriptor (includes flags, etc)\r
441 @param Ppi Pointer to reference the found PPI\r
442\r
443 @retval EFI_SUCCESS if the PPI is in the database\r
444 @retval EFI_NOT_FOUND if the PPI is not in the database\r
445\r
446**/\r
447EFI_STATUS\r
448EFIAPI\r
449PeiLocatePpi (\r
450 IN CONST EFI_PEI_SERVICES **PeiServices,\r
451 IN CONST EFI_GUID *Guid,\r
452 IN UINTN Instance,\r
453 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
454 IN OUT VOID **Ppi\r
455 );\r
456\r
457/**\r
458\r
459 Install a notification for a given PPI.\r
460\r
461\r
462 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
463 @param NotifyList Pointer to list of Descriptors to notify upon.\r
464\r
465 @retval EFI_SUCCESS if successful\r
466 @retval EFI_OUT_OF_RESOURCES if no space in the database\r
467 @retval EFI_INVALID_PARAMETER if not a good decriptor\r
468\r
469**/\r
470EFI_STATUS\r
471EFIAPI\r
472PeiNotifyPpi (\r
473 IN CONST EFI_PEI_SERVICES **PeiServices,\r
474 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
475 );\r
476\r
477/**\r
478\r
479 Process the Notify List at dispatch level.\r
480\r
481 @param PrivateData PeiCore's private data structure.\r
482\r
483**/\r
484VOID\r
485ProcessNotifyList (\r
486 IN PEI_CORE_INSTANCE *PrivateData\r
487 );\r
488\r
489/**\r
490\r
491 Dispatch notifications.\r
492\r
493 @param PrivateData PeiCore's private data structure\r
494 @param NotifyType Type of notify to fire.\r
495 @param InstallStartIndex Install Beginning index.\r
496 @param InstallStopIndex Install Ending index.\r
497 @param NotifyStartIndex Notify Beginning index.\r
498 @param NotifyStopIndex Notify Ending index.\r
499\r
500**/\r
501VOID\r
502DispatchNotify (\r
503 IN PEI_CORE_INSTANCE *PrivateData,\r
504 IN UINTN NotifyType,\r
505 IN INTN InstallStartIndex,\r
506 IN INTN InstallStopIndex,\r
507 IN INTN NotifyStartIndex,\r
508 IN INTN NotifyStopIndex\r
509 );\r
510\r
511//\r
512// Boot mode support functions\r
513//\r
514/**\r
515 This service enables PEIMs to ascertain the present value of the boot mode.\r
516\r
517 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
518 @param BootMode A pointer to contain the value of the boot mode.\r
519\r
520 @retval EFI_SUCCESS The boot mode was returned successfully.\r
521 @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
522\r
523**/\r
524EFI_STATUS\r
525EFIAPI\r
526PeiGetBootMode (\r
527 IN CONST EFI_PEI_SERVICES **PeiServices,\r
528 IN OUT EFI_BOOT_MODE *BootMode\r
529 );\r
530\r
531/**\r
532 This service enables PEIMs to update the boot mode variable.\r
533\r
534\r
535 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
536 @param BootMode The value of the boot mode to set.\r
537\r
538 @return EFI_SUCCESS The value was successfully updated\r
539\r
540**/\r
541EFI_STATUS\r
542EFIAPI\r
543PeiSetBootMode (\r
544 IN CONST EFI_PEI_SERVICES **PeiServices,\r
545 IN EFI_BOOT_MODE BootMode\r
546 );\r
547\r
548//\r
549// Security support functions\r
550//\r
551/**\r
552\r
553 Initialize the security services.\r
554\r
555 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
556 @param OldCoreData Pointer to the old core data.\r
557 NULL if being run in non-permament memory mode.\r
558\r
559**/\r
560VOID\r
561InitializeSecurityServices (\r
562 IN EFI_PEI_SERVICES **PeiServices,\r
563 IN PEI_CORE_INSTANCE *OldCoreData\r
564 );\r
565\r
566/**\r
567 Verify a Firmware volume.\r
568\r
569 @param CurrentFvAddress Pointer to the current Firmware Volume under consideration\r
570\r
571 @retval EFI_SUCCESS Firmware Volume is legal\r
572 @retval EFI_SECURITY_VIOLATION Firmware Volume fails integrity test\r
573\r
574**/\r
575EFI_STATUS\r
576VerifyFv (\r
577 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
578 );\r
579\r
580/**\r
581\r
582 Provide a callout to the security verification service.\r
583\r
584\r
585 @param PrivateData PeiCore's private data structure\r
586 @param VolumeHandle Handle of FV\r
587 @param FileHandle Handle of PEIM's ffs\r
588\r
589 @retval EFI_SUCCESS Image is OK\r
590 @retval EFI_SECURITY_VIOLATION Image is illegal\r
591\r
592**/\r
593EFI_STATUS\r
594VerifyPeim (\r
595 IN PEI_CORE_INSTANCE *PrivateData,\r
596 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
597 IN EFI_PEI_FILE_HANDLE FileHandle\r
598 );\r
599\r
600/**\r
601\r
602 Gets the pointer to the HOB List.\r
603\r
604\r
605 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
606 @param HobList Pointer to the HOB List.\r
607\r
608 @retval EFI_SUCCESS Get the pointer of HOB List\r
609 @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published\r
610 @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode)\r
611\r
612**/\r
613EFI_STATUS\r
614EFIAPI\r
615PeiGetHobList (\r
616 IN CONST EFI_PEI_SERVICES **PeiServices,\r
617 IN OUT VOID **HobList\r
618 );\r
619\r
620/**\r
621 Add a new HOB to the HOB List.\r
622\r
623 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
624 @param Type Type of the new HOB.\r
625 @param Length Length of the new HOB to allocate.\r
626 @param Hob Pointer to the new HOB.\r
627\r
628 @return EFI_SUCCESS Success to create hob.\r
629 @retval EFI_INVALID_PARAMETER if Hob is NULL\r
630 @retval EFI_NOT_AVAILABLE_YET if HobList is still not available.\r
631 @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.\r
632\r
633**/\r
634EFI_STATUS\r
635EFIAPI\r
636PeiCreateHob (\r
637 IN CONST EFI_PEI_SERVICES **PeiServices,\r
638 IN UINT16 Type,\r
639 IN UINT16 Length,\r
640 IN OUT VOID **Hob\r
641 );\r
642\r
643/**\r
644\r
645 Builds a Handoff Information Table HOB\r
646\r
647 @param BootMode - Current Bootmode\r
648 @param MemoryBegin - Start Memory Address.\r
649 @param MemoryLength - Length of Memory.\r
650\r
651 @return EFI_SUCCESS Always success to initialize HOB.\r
652\r
653**/\r
654EFI_STATUS\r
655PeiCoreBuildHobHandoffInfoTable (\r
656 IN EFI_BOOT_MODE BootMode,\r
657 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
658 IN UINT64 MemoryLength\r
659 );\r
660\r
661\r
662//\r
663// FFS Fw Volume support functions\r
664//\r
665/**\r
666 Searches for the next matching file in the firmware volume.\r
667\r
668 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
669 @param SearchType Filter to find only files of this type.\r
670 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
671 @param FvHandle Handle of firmware volume in which to search.\r
672 @param FileHandle On entry, points to the current handle from which to begin searching or NULL to start\r
673 at the beginning of the firmware volume. On exit, points the file handle of the next file\r
674 in the volume or NULL if there are no more files.\r
675\r
676 @retval EFI_NOT_FOUND The file was not found.\r
677 @retval EFI_NOT_FOUND The header checksum was not zero.\r
678 @retval EFI_SUCCESS The file was found.\r
679\r
680**/\r
681EFI_STATUS\r
682EFIAPI\r
683PeiFfsFindNextFile (\r
684 IN CONST EFI_PEI_SERVICES **PeiServices,\r
685 IN UINT8 SearchType,\r
686 IN EFI_PEI_FV_HANDLE FvHandle,\r
687 IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r
688 );\r
689\r
690/**\r
691 Searches for the next matching section within the specified file.\r
692\r
693 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
694 @param SectionType Filter to find only sections of this type.\r
695 @param FileHandle Pointer to the current file to search.\r
696 @param SectionData A pointer to the discovered section, if successful.\r
697 NULL if section not found\r
698\r
699 @retval EFI_NOT_FOUND The section was not found.\r
700 @retval EFI_SUCCESS The section was found.\r
701\r
702**/\r
703EFI_STATUS\r
704EFIAPI\r
705PeiFfsFindSectionData (\r
706 IN CONST EFI_PEI_SERVICES **PeiServices,\r
707 IN EFI_SECTION_TYPE SectionType,\r
708 IN EFI_PEI_FILE_HANDLE FileHandle,\r
709 OUT VOID **SectionData\r
710 );\r
711\r
712/**\r
713 Search the firmware volumes by index\r
714\r
715 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
716 @param Instance This instance of the firmware volume to find. The value 0 is the Boot Firmware\r
717 Volume (BFV).\r
718 @param VolumeHandle On exit, points to the next volume handle or NULL if it does not exist.\r
719\r
720 @retval EFI_INVALID_PARAMETER VolumeHandle is NULL\r
721 @retval EFI_NOT_FOUND The volume was not found.\r
722 @retval EFI_SUCCESS The volume was found.\r
723\r
724**/\r
725EFI_STATUS\r
726EFIAPI\r
727PeiFfsFindNextVolume (\r
728 IN CONST EFI_PEI_SERVICES **PeiServices,\r
729 IN UINTN Instance,\r
730 IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r
731 );\r
732\r
733//\r
734// Memory support functions\r
735//\r
736/**\r
737\r
738 Initialize the memory services.\r
739\r
740 @param PrivateData PeiCore's private data structure\r
741 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
742 and location of temporary RAM, the stack location and the BFV location.\r
743 @param OldCoreData Pointer to the PEI Core data.\r
744 NULL if being run in non-permament memory mode.\r
745\r
746**/\r
747VOID\r
748InitializeMemoryServices (\r
749 IN PEI_CORE_INSTANCE *PrivateData,\r
750 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
751 IN PEI_CORE_INSTANCE *OldCoreData\r
752 );\r
753\r
754/**\r
755\r
756 Install the permanent memory is now available.\r
757 Creates HOB (PHIT and Stack).\r
758\r
759 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
760 @param MemoryBegin Start of memory address.\r
761 @param MemoryLength Length of memory.\r
762\r
763 @return EFI_SUCCESS Always success.\r
764\r
765**/\r
766EFI_STATUS\r
767EFIAPI\r
768PeiInstallPeiMemory (\r
769 IN CONST EFI_PEI_SERVICES **PeiServices,\r
770 IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
771 IN UINT64 MemoryLength\r
772 );\r
773\r
774/**\r
775\r
776 Memory allocation service on permanent memory,\r
777 not usable prior to the memory installation.\r
778\r
779\r
780 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
781 @param MemoryType Type of memory to allocate.\r
782 @param Pages Number of pages to allocate.\r
783 @param Memory Pointer of memory allocated.\r
784\r
785 @retval EFI_SUCCESS The allocation was successful\r
786 @retval EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.\r
787 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available\r
788 @retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement\r
789 to allocate the number of pages.\r
790\r
791**/\r
792EFI_STATUS\r
793EFIAPI\r
794PeiAllocatePages (\r
795 IN CONST EFI_PEI_SERVICES **PeiServices,\r
796 IN EFI_MEMORY_TYPE MemoryType,\r
797 IN UINTN Pages,\r
798 OUT EFI_PHYSICAL_ADDRESS *Memory\r
799 );\r
800\r
801/**\r
802\r
803 Memory allocation service on the temporary memory.\r
804\r
805\r
806 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
807 @param Size Amount of memory required\r
808 @param Buffer Address of pointer to the buffer\r
809\r
810 @retval EFI_SUCCESS The allocation was successful\r
811 @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement\r
812 to allocate the requested size.\r
813\r
814**/\r
815EFI_STATUS\r
816EFIAPI\r
817PeiAllocatePool (\r
818 IN CONST EFI_PEI_SERVICES **PeiServices,\r
819 IN UINTN Size,\r
820 OUT VOID **Buffer\r
821 );\r
822\r
823/**\r
824\r
825 Routine for load image file.\r
826\r
827\r
828 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
829 @param FileHandle Pointer to the FFS file header of the image.\r
830 @param PeimState The dispatch state of the input PEIM handle.\r
831 @param EntryPoint Pointer to entry point of specified image file for output.\r
832 @param AuthenticationState Pointer to attestation authentication state of image.\r
833\r
834 @retval EFI_SUCCESS Image is successfully loaded.\r
835 @retval EFI_NOT_FOUND Fail to locate necessary PPI\r
836 @retval Others Fail to load file.\r
837\r
838**/\r
839EFI_STATUS\r
840PeiLoadImage (\r
841 IN CONST EFI_PEI_SERVICES **PeiServices,\r
842 IN EFI_PEI_FILE_HANDLE FileHandle,\r
843 IN UINT8 PeimState,\r
844 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
845 OUT UINT32 *AuthenticationState\r
846 );\r
847\r
848/**\r
849\r
850 Core version of the Status Code reporter\r
851\r
852\r
853 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
854 @param CodeType Type of Status Code.\r
855 @param Value Value to output for Status Code.\r
856 @param Instance Instance Number of this status code.\r
857 @param CallerId ID of the caller of this status code.\r
858 @param Data Optional data associated with this status code.\r
859\r
860 @retval EFI_SUCCESS if status code is successfully reported\r
861 @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed\r
862\r
863**/\r
864EFI_STATUS\r
865EFIAPI\r
866PeiReportStatusCode (\r
867 IN CONST EFI_PEI_SERVICES **PeiServices,\r
868 IN EFI_STATUS_CODE_TYPE CodeType,\r
869 IN EFI_STATUS_CODE_VALUE Value,\r
870 IN UINT32 Instance,\r
871 IN CONST EFI_GUID *CallerId,\r
872 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
873 );\r
874\r
875/**\r
876\r
877 Core version of the Reset System\r
878\r
879\r
880 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
881\r
882 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.\r
883 @retval EFI_DEVICE_ERROR Did not reset system.\r
884 Otherwise, resets the system.\r
885\r
886**/\r
887EFI_STATUS\r
888EFIAPI\r
889PeiResetSystem (\r
890 IN CONST EFI_PEI_SERVICES **PeiServices\r
891 );\r
892\r
893/**\r
894\r
895 Initialize PeiCore Fv List.\r
896\r
897\r
898 @param PrivateData - Pointer to PEI_CORE_INSTANCE.\r
899 @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.\r
900\r
901**/\r
902VOID\r
903PeiInitializeFv (\r
904 IN PEI_CORE_INSTANCE *PrivateData,\r
905 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
906 );\r
907\r
908/**\r
909 Process Firmware Volum Information once FvInfoPPI install.\r
910\r
911 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
912 @param NotifyDescriptor Address of the notification descriptor data structure.\r
913 @param Ppi Address of the PPI that was installed.\r
914\r
915 @retval EFI_SUCCESS if the interface could be successfully installed\r
916\r
917**/\r
918EFI_STATUS\r
919EFIAPI\r
920FirmwareVolmeInfoPpiNotifyCallback (\r
921 IN EFI_PEI_SERVICES **PeiServices,\r
922 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
923 IN VOID *Ppi\r
924 );\r
925\r
926/**\r
927\r
928 Given the input VolumeHandle, search for the next matching name file.\r
929\r
930 @param FileName File name to search.\r
931 @param VolumeHandle The current FV to search.\r
932 @param FileHandle Pointer to the file matching name in VolumeHandle.\r
933 NULL if file not found\r
934\r
935 @retval EFI_NOT_FOUND No files matching the search criteria were found\r
936 @retval EFI_SUCCESS Success to search given file\r
937\r
938**/\r
939EFI_STATUS\r
940EFIAPI\r
941PeiFfsFindFileByName (\r
942 IN CONST EFI_GUID *FileName,\r
943 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
944 OUT EFI_PEI_FILE_HANDLE *FileHandle\r
945 );\r
946\r
947/**\r
948 Returns information about a specific file.\r
949\r
950 @param FileHandle Handle of the file.\r
951 @param FileInfo Upon exit, points to the file's information.\r
952\r
953 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
954 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
955 @retval EFI_SUCCESS File information returned.\r
956\r
957**/\r
958EFI_STATUS\r
959EFIAPI\r
960PeiFfsGetFileInfo (\r
961 IN EFI_PEI_FILE_HANDLE FileHandle,\r
962 OUT EFI_FV_FILE_INFO *FileInfo\r
963 );\r
964\r
965/**\r
966 Returns information about the specified volume.\r
967\r
968 @param VolumeHandle Handle of the volume.\r
969 @param VolumeInfo Upon exit, points to the volume's information.\r
970\r
971 @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.\r
972 @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.\r
973 @retval EFI_SUCCESS Volume information returned.\r
974**/\r
975EFI_STATUS\r
976EFIAPI\r
977PeiFfsGetVolumeInfo (\r
978 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
979 OUT EFI_FV_INFO *VolumeInfo\r
980 );\r
981\r
982/**\r
983 This routine enable a PEIM to register itself to shadow when PEI Foundation\r
984 discovery permanent memory.\r
985\r
986 @param FileHandle File handle of a PEIM.\r
987\r
988 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.\r
989 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.\r
990 @retval EFI_SUCCESS Successfully to register itself.\r
991\r
992**/\r
993EFI_STATUS\r
994EFIAPI\r
995PeiRegisterForShadow (\r
996 IN EFI_PEI_FILE_HANDLE FileHandle\r
997 );\r
998\r
999/**\r
1000 Initialize image service that install PeiLoadFilePpi.\r
1001\r
1002 @param PrivateData Pointer to PeiCore's private data structure PEI_CORE_INSTANCE.\r
1003 @param OldCoreData Pointer to Old PeiCore's private data.\r
1004 If NULL, PeiCore is entered at first time, stack/heap in temporary memory.\r
1005 If not NULL, PeiCore is entered at second time, stack/heap has been moved\r
1006 to permenent memory.\r
1007\r
1008**/\r
1009VOID\r
1010InitializeImageServices (\r
1011 IN PEI_CORE_INSTANCE *PrivateData,\r
1012 IN PEI_CORE_INSTANCE *OldCoreData\r
1013 );\r
1014\r
1015/**\r
1016 The wrapper function of PeiLoadImageLoadImage().\r
1017\r
1018 @param This Pointer to EFI_PEI_LOAD_FILE_PPI.\r
1019 @param FileHandle Pointer to the FFS file header of the image.\r
1020 @param ImageAddressArg Pointer to PE/TE image.\r
1021 @param ImageSizeArg Size of PE/TE image.\r
1022 @param EntryPoint Pointer to entry point of specified image file for output.\r
1023 @param AuthenticationState Pointer to attestation authentication state of image.\r
1024\r
1025 @return Status of PeiLoadImageLoadImage().\r
1026\r
1027**/\r
1028EFI_STATUS\r
1029EFIAPI\r
1030PeiLoadImageLoadImageWrapper (\r
1031 IN CONST EFI_PEI_LOAD_FILE_PPI *This,\r
1032 IN EFI_PEI_FILE_HANDLE FileHandle,\r
1033 OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL\r
1034 OUT UINT64 *ImageSizeArg, OPTIONAL\r
1035 OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
1036 OUT UINT32 *AuthenticationState\r
1037 );\r
1038\r
1039/**\r
1040\r
1041 Provide a callback for when the security PPI is installed.\r
1042\r
1043 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
1044 @param NotifyDescriptor The descriptor for the notification event.\r
1045 @param Ppi Pointer to the PPI in question.\r
1046\r
1047 @return Always success\r
1048\r
1049**/\r
1050EFI_STATUS\r
1051EFIAPI\r
1052SecurityPpiNotifyCallback (\r
1053 IN EFI_PEI_SERVICES **PeiServices,\r
1054 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
1055 IN VOID *Ppi\r
1056 );\r
1057\r
1058/**\r
1059 Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
1060\r
1061 @param ParentFvCoreHandle Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.\r
1062 @param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.\r
1063\r
1064 @retval EFI_NOT_FOUND FV image can't be found.\r
1065 @retval EFI_SUCCESS Successfully to process it.\r
1066 @retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image\r
1067 @retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
1068 \r
1069**/\r
1070EFI_STATUS\r
1071ProcessFvFile (\r
1072 IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle,\r
1073 IN EFI_PEI_FILE_HANDLE ParentFvFileHandle\r
1074 );\r
1075 \r
1076/**\r
1077 Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.\r
1078 \r
1079 This routine also will install FvInfo ppi for FV hob in PI ways.\r
1080 \r
1081 @param Private Pointer of PEI_CORE_INSTANCE\r
1082 @param Instance The index of FV want to be searched.\r
1083 \r
1084 @return Instance of PEI_CORE_FV_HANDLE.\r
1085**/\r
1086PEI_CORE_FV_HANDLE *\r
1087FindNextCoreFvHandle (\r
1088 IN PEI_CORE_INSTANCE *Private,\r
1089 IN UINTN Instance\r
1090 );\r
1091 \r
1092//\r
1093// Default EFI_PEI_CPU_IO_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.\r
1094// \r
1095\r
1096/**\r
1097 Memory-based read services.\r
1098 \r
1099 This function is to perform the Memory Access Read service based on installed \r
1100 instance of the EFI_PEI_CPU_IO_PPI. \r
1101 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1102 return EFI_NOT_YET_AVAILABLE. \r
1103 \r
1104 @param PeiServices An indirect pointer to the PEI Services Table\r
1105 published by the PEI Foundation.\r
1106 @param This Pointer to local data for the interface.\r
1107 @param Width The width of the access. Enumerated in bytes.\r
1108 @param Address The physical address of the access.\r
1109 @param Count The number of accesses to perform.\r
1110 @param Buffer A pointer to the buffer of data.\r
1111\r
1112 @retval EFI_SUCCESS The function completed successfully.\r
1113 @retval EFI_NOT_YET_AVAILABLE The service has not been installed. \r
1114**/\r
1115EFI_STATUS\r
1116EFIAPI\r
1117PeiDefaultMemRead (\r
1118 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1119 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1120 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1121 IN UINT64 Address,\r
1122 IN UINTN Count,\r
1123 IN OUT VOID *Buffer\r
1124 );\r
1125 \r
1126/**\r
1127 Memory-based write services.\r
1128 \r
1129 This function is to perform the Memory Access Write service based on installed \r
1130 instance of the EFI_PEI_CPU_IO_PPI. \r
1131 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1132 return EFI_NOT_YET_AVAILABLE. \r
1133 \r
1134 @param PeiServices An indirect pointer to the PEI Services Table\r
1135 published by the PEI Foundation.\r
1136 @param This Pointer to local data for the interface.\r
1137 @param Width The width of the access. Enumerated in bytes.\r
1138 @param Address The physical address of the access.\r
1139 @param Count The number of accesses to perform.\r
1140 @param Buffer A pointer to the buffer of data.\r
1141\r
1142 @retval EFI_SUCCESS The function completed successfully.\r
1143 @retval EFI_NOT_YET_AVAILABLE The service has not been installed. \r
1144**/\r
1145EFI_STATUS\r
1146EFIAPI\r
1147PeiDefaultMemWrite (\r
1148 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1149 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1150 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1151 IN UINT64 Address,\r
1152 IN UINTN Count,\r
1153 IN OUT VOID *Buffer\r
1154 );\r
1155 \r
1156/**\r
1157 IO-based read services.\r
1158 \r
1159 This function is to perform the IO-base read service for the EFI_PEI_CPU_IO_PPI.\r
1160 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1161 return EFI_NOT_YET_AVAILABLE. \r
1162 \r
1163 @param PeiServices An indirect pointer to the PEI Services Table\r
1164 published by the PEI Foundation.\r
1165 @param This Pointer to local data for the interface.\r
1166 @param Width The width of the access. Enumerated in bytes.\r
1167 @param Address The physical address of the access.\r
1168 @param Count The number of accesses to perform.\r
1169 @param Buffer A pointer to the buffer of data.\r
1170\r
1171 @retval EFI_SUCCESS The function completed successfully.\r
1172 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
1173**/\r
1174EFI_STATUS\r
1175EFIAPI\r
1176PeiDefaultIoRead (\r
1177 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1178 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1179 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1180 IN UINT64 Address,\r
1181 IN UINTN Count,\r
1182 IN OUT VOID *Buffer\r
1183 );\r
1184 \r
1185/**\r
1186 IO-based write services.\r
1187 \r
1188 This function is to perform the IO-base write service for the EFI_PEI_CPU_IO_PPI.\r
1189 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1190 return EFI_NOT_YET_AVAILABLE. \r
1191 \r
1192 @param PeiServices An indirect pointer to the PEI Services Table\r
1193 published by the PEI Foundation.\r
1194 @param This Pointer to local data for the interface.\r
1195 @param Width The width of the access. Enumerated in bytes.\r
1196 @param Address The physical address of the access.\r
1197 @param Count The number of accesses to perform.\r
1198 @param Buffer A pointer to the buffer of data.\r
1199\r
1200 @retval EFI_SUCCESS The function completed successfully.\r
1201 @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
1202**/\r
1203EFI_STATUS\r
1204EFIAPI\r
1205PeiDefaultIoWrite (\r
1206 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1207 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1208 IN EFI_PEI_CPU_IO_PPI_WIDTH Width,\r
1209 IN UINT64 Address,\r
1210 IN UINTN Count,\r
1211 IN OUT VOID *Buffer\r
1212 );\r
1213 \r
1214/**\r
1215 8-bit I/O read operations.\r
1216 \r
1217 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1218 return 0.\r
1219 \r
1220 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1221 @param This Pointer to local data for the interface.\r
1222 @param Address The physical address of the access.\r
1223\r
1224 @return An 8-bit value returned from the I/O space.\r
1225**/\r
1226UINT8\r
1227EFIAPI\r
1228PeiDefaultIoRead8 (\r
1229 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1230 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1231 IN UINT64 Address\r
1232 );\r
1233 \r
1234/**\r
1235 Reads an 16-bit I/O port.\r
1236 \r
1237 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1238 return 0.\r
1239 \r
1240 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1241 @param This Pointer to local data for the interface.\r
1242 @param Address The physical address of the access.\r
1243\r
1244 @return A 16-bit value returned from the I/O space.\r
1245**/\r
1246UINT16\r
1247EFIAPI\r
1248PeiDefaultIoRead16 (\r
1249 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1250 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1251 IN UINT64 Address\r
1252 );\r
1253 \r
1254/**\r
1255 Reads an 32-bit I/O port.\r
1256 \r
1257 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1258 return 0.\r
1259 \r
1260 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1261 @param This Pointer to local data for the interface.\r
1262 @param Address The physical address of the access.\r
1263\r
1264 @return A 32-bit value returned from the I/O space.\r
1265**/\r
1266UINT32\r
1267EFIAPI\r
1268PeiDefaultIoRead32 (\r
1269 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1270 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1271 IN UINT64 Address\r
1272 );\r
1273 \r
1274/**\r
1275 Reads an 64-bit I/O port.\r
1276 \r
1277 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1278 return 0.\r
1279 \r
1280 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1281 @param This Pointer to local data for the interface.\r
1282 @param Address The physical address of the access.\r
1283\r
1284 @return A 64-bit value returned from the I/O space.\r
1285**/\r
1286UINT64\r
1287EFIAPI\r
1288PeiDefaultIoRead64 (\r
1289 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1290 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1291 IN UINT64 Address\r
1292 );\r
1293 \r
1294/**\r
1295 8-bit I/O write operations.\r
1296\r
1297 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1298 @param This Pointer to local data for the interface.\r
1299 @param Address The physical address of the access.\r
1300 @param Data The data to write.\r
1301**/\r
1302VOID\r
1303EFIAPI\r
1304PeiDefaultIoWrite8 (\r
1305 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1306 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1307 IN UINT64 Address,\r
1308 IN UINT8 Data\r
1309 );\r
1310 \r
1311/**\r
1312 16-bit I/O write operations.\r
1313\r
1314 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1315 @param This Pointer to local data for the interface.\r
1316 @param Address The physical address of the access.\r
1317 @param Data The data to write.\r
1318**/\r
1319VOID\r
1320EFIAPI\r
1321PeiDefaultIoWrite16 (\r
1322 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1323 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1324 IN UINT64 Address,\r
1325 IN UINT16 Data\r
1326 );\r
1327 \r
1328/**\r
1329 32-bit I/O write operations.\r
1330\r
1331 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1332 @param This Pointer to local data for the interface.\r
1333 @param Address The physical address of the access.\r
1334 @param Data The data to write.\r
1335**/\r
1336VOID\r
1337EFIAPI\r
1338PeiDefaultIoWrite32 (\r
1339 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1340 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1341 IN UINT64 Address,\r
1342 IN UINT32 Data\r
1343 );\r
1344 \r
1345/**\r
1346 64-bit I/O write operations.\r
1347\r
1348 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1349 @param This Pointer to local data for the interface.\r
1350 @param Address The physical address of the access.\r
1351 @param Data The data to write.\r
1352**/\r
1353VOID\r
1354EFIAPI\r
1355PeiDefaultIoWrite64 (\r
1356 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1357 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1358 IN UINT64 Address,\r
1359 IN UINT64 Data\r
1360 );\r
1361 \r
1362/**\r
1363 8-bit memory read operations.\r
1364\r
1365 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1366 return 0.\r
1367 \r
1368 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1369 @param This Pointer to local data for the interface.\r
1370 @param Address The physical address of the access.\r
1371\r
1372 @return An 8-bit value returned from the memory space.\r
1373\r
1374**/\r
1375UINT8\r
1376EFIAPI\r
1377PeiDefaultMemRead8 (\r
1378 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1379 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1380 IN UINT64 Address\r
1381 );\r
1382 \r
1383/**\r
1384 16-bit memory read operations.\r
1385\r
1386 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1387 return 0.\r
1388 \r
1389 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1390 @param This Pointer to local data for the interface.\r
1391 @param Address The physical address of the access.\r
1392\r
1393 @return An 16-bit value returned from the memory space.\r
1394\r
1395**/\r
1396UINT16\r
1397EFIAPI\r
1398PeiDefaultMemRead16 (\r
1399 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1400 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1401 IN UINT64 Address\r
1402 );\r
1403 \r
1404/**\r
1405 32-bit memory read operations.\r
1406\r
1407 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1408 return 0.\r
1409 \r
1410 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1411 @param This Pointer to local data for the interface.\r
1412 @param Address The physical address of the access.\r
1413\r
1414 @return An 32-bit value returned from the memory space.\r
1415\r
1416**/\r
1417UINT32\r
1418EFIAPI\r
1419PeiDefaultMemRead32 (\r
1420 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1421 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1422 IN UINT64 Address\r
1423 );\r
1424 \r
1425/**\r
1426 64-bit memory read operations.\r
1427\r
1428 If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
1429 return 0.\r
1430 \r
1431 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1432 @param This Pointer to local data for the interface.\r
1433 @param Address The physical address of the access.\r
1434\r
1435 @return An 64-bit value returned from the memory space.\r
1436\r
1437**/\r
1438UINT64\r
1439EFIAPI\r
1440PeiDefaultMemRead64 (\r
1441 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1442 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1443 IN UINT64 Address\r
1444 );\r
1445 \r
1446/**\r
1447 8-bit memory write operations.\r
1448\r
1449 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1450 @param This Pointer to local data for the interface.\r
1451 @param Address The physical address of the access.\r
1452 @param Data The data to write.\r
1453\r
1454**/\r
1455VOID\r
1456EFIAPI\r
1457PeiDefaultMemWrite8 (\r
1458 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1459 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1460 IN UINT64 Address,\r
1461 IN UINT8 Data\r
1462 );\r
1463 \r
1464/**\r
1465 16-bit memory write operations.\r
1466\r
1467 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1468 @param This Pointer to local data for the interface.\r
1469 @param Address The physical address of the access.\r
1470 @param Data The data to write.\r
1471\r
1472**/\r
1473VOID\r
1474EFIAPI\r
1475PeiDefaultMemWrite16 (\r
1476 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1477 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1478 IN UINT64 Address,\r
1479 IN UINT16 Data\r
1480 );\r
1481\r
1482/**\r
1483 32-bit memory write operations.\r
1484\r
1485 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1486 @param This Pointer to local data for the interface.\r
1487 @param Address The physical address of the access.\r
1488 @param Data The data to write.\r
1489\r
1490**/\r
1491VOID\r
1492EFIAPI\r
1493PeiDefaultMemWrite32 (\r
1494 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1495 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1496 IN UINT64 Address,\r
1497 IN UINT32 Data\r
1498 );\r
1499 \r
1500/**\r
1501 64-bit memory write operations.\r
1502\r
1503 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1504 @param This Pointer to local data for the interface.\r
1505 @param Address The physical address of the access.\r
1506 @param Data The data to write.\r
1507\r
1508**/\r
1509VOID\r
1510EFIAPI\r
1511PeiDefaultMemWrite64 (\r
1512 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1513 IN CONST EFI_PEI_CPU_IO_PPI *This,\r
1514 IN UINT64 Address,\r
1515 IN UINT64 Data\r
1516 );\r
1517 \r
1518extern EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi; \r
1519\r
1520//\r
1521// Default EFI_PEI_PCI_CFG2_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.\r
1522// \r
1523\r
1524/**\r
1525 Reads from a given location in the PCI configuration space.\r
1526\r
1527 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then \r
1528 return EFI_NOT_YET_AVAILABLE. \r
1529 \r
1530 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1531 @param This Pointer to local data for the interface.\r
1532 @param Width The width of the access. Enumerated in bytes.\r
1533 See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
1534 @param Address The physical address of the access. The format of\r
1535 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
1536 @param Buffer A pointer to the buffer of data.\r
1537\r
1538 @retval EFI_SUCCESS The function completed successfully.\r
1539 @retval EFI_INVALID_PARAMETER The invalid access width.\r
1540 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
1541 \r
1542**/\r
1543EFI_STATUS\r
1544EFIAPI\r
1545PeiDefaultPciCfg2Read (\r
1546 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1547 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
1548 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
1549 IN UINT64 Address,\r
1550 IN OUT VOID *Buffer\r
1551 );\r
1552 \r
1553/**\r
1554 Write to a given location in the PCI configuration space.\r
1555\r
1556 If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then \r
1557 return EFI_NOT_YET_AVAILABLE. \r
1558 \r
1559 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
1560 @param This Pointer to local data for the interface.\r
1561 @param Width The width of the access. Enumerated in bytes.\r
1562 See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
1563 @param Address The physical address of the access. The format of\r
1564 the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
1565 @param Buffer A pointer to the buffer of data.\r
1566\r
1567 @retval EFI_SUCCESS The function completed successfully.\r
1568 @retval EFI_INVALID_PARAMETER The invalid access width.\r
1569 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
1570**/\r
1571EFI_STATUS\r
1572EFIAPI\r
1573PeiDefaultPciCfg2Write (\r
1574 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1575 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
1576 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
1577 IN UINT64 Address,\r
1578 IN OUT VOID *Buffer\r
1579 );\r
1580 \r
1581/**\r
1582 This function performs a read-modify-write operation on the contents from a given\r
1583 location in the PCI configuration space.\r
1584\r
1585 @param PeiServices An indirect pointer to the PEI Services Table\r
1586 published by the PEI Foundation.\r
1587 @param This Pointer to local data for the interface.\r
1588 @param Width The width of the access. Enumerated in bytes. Type\r
1589 EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().\r
1590 @param Address The physical address of the access.\r
1591 @param SetBits Points to value to bitwise-OR with the read configuration value.\r
1592 The size of the value is determined by Width.\r
1593 @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.\r
1594 The size of the value is determined by Width.\r
1595\r
1596 @retval EFI_SUCCESS The function completed successfully.\r
1597 @retval EFI_INVALID_PARAMETER The invalid access width.\r
1598 @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
1599**/\r
1600EFI_STATUS\r
1601EFIAPI\r
1602PeiDefaultPciCfg2Modify (\r
1603 IN CONST EFI_PEI_SERVICES **PeiServices,\r
1604 IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
1605 IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
1606 IN UINT64 Address,\r
1607 IN VOID *SetBits,\r
1608 IN VOID *ClearBits\r
1609 ); \r
1610 \r
1611extern EFI_PEI_PCI_CFG2_PPI gPeiDefaultPciCfg2Ppi;\r
1612\r
1613/**\r
1614 After PeiCore image is shadowed into permanent memory, all build-in FvPpi should\r
1615 be re-installed with the instance in permanent memory and all cached FvPpi pointers in \r
1616 PrivateData->Fv[] array should be fixed up to be pointed to the one in permenant\r
1617 memory.\r
1618 \r
1619 @param PrivateData Pointer to PEI_CORE_INSTANCE.\r
1620**/ \r
1621VOID\r
1622PeiReinitializeFv (\r
1623 IN PEI_CORE_INSTANCE *PrivateData\r
1624 );\r
1625 \r
1626#endif\r