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