]>
Commit | Line | Data |
---|---|---|
738ec565 | 1 | /** @file\r |
2 | Implementation for PEI Services Library.\r | |
3 | \r | |
d821151e | 4 | Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r |
9344f092 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
738ec565 | 6 | \r |
738ec565 | 7 | **/\r |
8 | \r | |
c892d846 | 9 | \r |
c7d265a9 | 10 | #include <PiPei.h>\r |
c892d846 | 11 | \r |
729675ae | 12 | #include <Ppi/FirmwareVolumeInfo.h>\r |
c7935105 | 13 | #include <Ppi/FirmwareVolumeInfo2.h>\r |
729675ae | 14 | #include <Guid/FirmwareFileSystem2.h>\r |
c892d846 | 15 | \r |
c7d265a9 | 16 | #include <Library/PeiServicesLib.h>\r |
17 | #include <Library/PeiServicesTablePointerLib.h>\r | |
729675ae | 18 | #include <Library/DebugLib.h>\r |
19 | #include <Library/MemoryAllocationLib.h>\r | |
20 | #include <Library/BaseMemoryLib.h>\r | |
21 | \r | |
738ec565 | 22 | /**\r |
23 | This service enables a given PEIM to register an interface into the PEI Foundation.\r | |
24 | \r | |
25 | @param PpiList A pointer to the list of interfaces that the caller shall install.\r | |
26 | \r | |
27 | @retval EFI_SUCCESS The interface was successfully installed.\r | |
28 | @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r | |
29 | @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r | |
30 | EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r | |
31 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r | |
32 | \r | |
33 | **/\r | |
34 | EFI_STATUS\r | |
35 | EFIAPI\r | |
36 | PeiServicesInstallPpi (\r | |
1c280088 | 37 | IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r |
738ec565 | 38 | )\r |
39 | {\r | |
1c280088 | 40 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 41 | \r |
5240b97c | 42 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 43 | return (*PeiServices)->InstallPpi (PeiServices, PpiList);\r |
44 | }\r | |
45 | \r | |
46 | /**\r | |
47 | This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r | |
48 | \r | |
2fc59a00 | 49 | @param OldPpi The pointer to the old PEI PPI Descriptors.\r |
50 | @param NewPpi The pointer to the new PEI PPI Descriptors.\r | |
738ec565 | 51 | \r |
52 | @retval EFI_SUCCESS The interface was successfully installed.\r | |
53 | @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r | |
54 | @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r | |
55 | EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r | |
56 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r | |
57 | @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been\r | |
58 | installed.\r | |
59 | \r | |
60 | **/\r | |
61 | EFI_STATUS\r | |
62 | EFIAPI\r | |
63 | PeiServicesReInstallPpi (\r | |
1c280088 | 64 | IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r |
65 | IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r | |
738ec565 | 66 | )\r |
67 | {\r | |
1c280088 | 68 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 69 | \r |
5240b97c | 70 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 71 | return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi);\r |
72 | }\r | |
73 | \r | |
74 | /**\r | |
75 | This service enables PEIMs to discover a given instance of an interface.\r | |
76 | \r | |
77 | @param Guid A pointer to the GUID whose corresponding interface needs to be\r | |
78 | found.\r | |
79 | @param Instance The N-th instance of the interface that is required.\r | |
80 | @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r | |
81 | @param Ppi A pointer to the instance of the interface.\r | |
82 | \r | |
83 | @retval EFI_SUCCESS The interface was successfully returned.\r | |
84 | @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.\r | |
85 | \r | |
86 | **/\r | |
87 | EFI_STATUS\r | |
88 | EFIAPI\r | |
89 | PeiServicesLocatePpi (\r | |
1c280088 | 90 | IN CONST EFI_GUID *Guid,\r |
738ec565 | 91 | IN UINTN Instance,\r |
ced8f52f | 92 | IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, OPTIONAL\r |
738ec565 | 93 | IN OUT VOID **Ppi\r |
94 | )\r | |
95 | {\r | |
1c280088 | 96 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 97 | \r |
5240b97c | 98 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 99 | return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);\r |
100 | }\r | |
101 | \r | |
102 | /**\r | |
103 | This service enables PEIMs to register a given service to be invoked when another service is\r | |
104 | installed or reinstalled.\r | |
105 | \r | |
9095d37b | 106 | @param NotifyList A pointer to the list of notification interfaces\r |
58380e9c | 107 | that the caller shall install.\r |
738ec565 | 108 | \r |
109 | @retval EFI_SUCCESS The interface was successfully installed.\r | |
110 | @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r | |
58380e9c | 111 | @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do\r |
112 | not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES\r | |
113 | bit set in the Flags field.\r | |
738ec565 | 114 | @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.\r |
115 | \r | |
116 | **/\r | |
117 | EFI_STATUS\r | |
118 | EFIAPI\r | |
119 | PeiServicesNotifyPpi (\r | |
1c280088 | 120 | IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r |
738ec565 | 121 | )\r |
122 | {\r | |
1c280088 | 123 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 124 | \r |
5240b97c | 125 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 126 | return (*PeiServices)->NotifyPpi (PeiServices, NotifyList);\r |
127 | }\r | |
128 | \r | |
129 | /**\r | |
130 | This service enables PEIMs to ascertain the present value of the boot mode.\r | |
131 | \r | |
132 | @param BootMode A pointer to contain the value of the boot mode.\r | |
133 | \r | |
134 | @retval EFI_SUCCESS The boot mode was returned successfully.\r | |
135 | @retval EFI_INVALID_PARAMETER BootMode is NULL.\r | |
136 | \r | |
137 | **/\r | |
138 | EFI_STATUS\r | |
139 | EFIAPI\r | |
140 | PeiServicesGetBootMode (\r | |
c3363c92 | 141 | OUT EFI_BOOT_MODE *BootMode\r |
738ec565 | 142 | )\r |
143 | {\r | |
1c280088 | 144 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 145 | \r |
5240b97c | 146 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 147 | return (*PeiServices)->GetBootMode (PeiServices, BootMode);\r |
148 | }\r | |
149 | \r | |
150 | /**\r | |
151 | This service enables PEIMs to update the boot mode variable.\r | |
152 | \r | |
153 | @param BootMode The value of the boot mode to set.\r | |
154 | \r | |
155 | @retval EFI_SUCCESS The value was successfully updated\r | |
156 | \r | |
157 | **/\r | |
158 | EFI_STATUS\r | |
159 | EFIAPI\r | |
160 | PeiServicesSetBootMode (\r | |
161 | IN EFI_BOOT_MODE BootMode\r | |
162 | )\r | |
163 | {\r | |
1c280088 | 164 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 165 | \r |
5240b97c | 166 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 167 | return (*PeiServices)->SetBootMode (PeiServices, BootMode);\r |
168 | }\r | |
169 | \r | |
170 | /**\r | |
171 | This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r | |
172 | \r | |
9095d37b | 173 | @param HobList A pointer to the list of HOBs that the PEI Foundation\r |
58380e9c | 174 | will initialize.\r |
9095d37b | 175 | \r |
738ec565 | 176 | @retval EFI_SUCCESS The list was successfully returned.\r |
177 | @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r | |
178 | \r | |
179 | **/\r | |
180 | EFI_STATUS\r | |
181 | EFIAPI\r | |
182 | PeiServicesGetHobList (\r | |
f38fdc74 | 183 | OUT VOID **HobList\r |
738ec565 | 184 | )\r |
185 | {\r | |
1c280088 | 186 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 187 | \r |
5240b97c | 188 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 189 | return (*PeiServices)->GetHobList (PeiServices, HobList);\r |
190 | }\r | |
191 | \r | |
192 | /**\r | |
193 | This service enables PEIMs to create various types of HOBs.\r | |
194 | \r | |
195 | @param Type The type of HOB to be installed.\r | |
196 | @param Length The length of the HOB to be added.\r | |
9095d37b | 197 | @param Hob The address of a pointer that will contain the\r |
58380e9c | 198 | HOB header.\r |
738ec565 | 199 | \r |
200 | @retval EFI_SUCCESS The HOB was successfully created.\r | |
201 | @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r | |
202 | \r | |
203 | **/\r | |
204 | EFI_STATUS\r | |
205 | EFIAPI\r | |
206 | PeiServicesCreateHob (\r | |
207 | IN UINT16 Type,\r | |
208 | IN UINT16 Length,\r | |
dd652088 | 209 | OUT VOID **Hob\r |
738ec565 | 210 | )\r |
211 | {\r | |
1c280088 | 212 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 213 | \r |
5240b97c | 214 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 215 | return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob);\r |
216 | }\r | |
217 | \r | |
218 | /**\r | |
219 | This service enables PEIMs to discover additional firmware volumes.\r | |
220 | \r | |
9095d37b | 221 | @param Instance This instance of the firmware volume to find. The\r |
58380e9c | 222 | value 0 is the Boot Firmware Volume (BFV).\r |
223 | @param VolumeHandle Handle of the firmware volume header of the volume\r | |
224 | to return.\r | |
738ec565 | 225 | \r |
226 | @retval EFI_SUCCESS The volume was found.\r | |
227 | @retval EFI_NOT_FOUND The volume was not found.\r | |
228 | @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r | |
229 | \r | |
230 | **/\r | |
231 | EFI_STATUS\r | |
232 | EFIAPI\r | |
233 | PeiServicesFfsFindNextVolume (\r | |
234 | IN UINTN Instance,\r | |
1c280088 | 235 | IN OUT EFI_PEI_FV_HANDLE *VolumeHandle\r |
738ec565 | 236 | )\r |
237 | {\r | |
1c280088 | 238 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 239 | \r |
5240b97c | 240 | PeiServices = GetPeiServicesTablePointer ();\r |
1c280088 | 241 | return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, VolumeHandle);\r |
738ec565 | 242 | }\r |
243 | \r | |
244 | /**\r | |
245 | This service enables PEIMs to discover additional firmware files.\r | |
246 | \r | |
247 | @param SearchType A filter to find files only of this type.\r | |
9095d37b LG |
248 | @param VolumeHandle The pointer to the firmware volume header of the\r |
249 | volume to search. This parameter must point to a\r | |
250 | valid FFS volume.\r | |
42eedea9 | 251 | @param FileHandle Handle of the current file from which to begin searching.\r |
738ec565 | 252 | \r |
253 | @retval EFI_SUCCESS The file was found.\r | |
254 | @retval EFI_NOT_FOUND The file was not found.\r | |
255 | @retval EFI_NOT_FOUND The header checksum was not zero.\r | |
256 | \r | |
257 | **/\r | |
258 | EFI_STATUS\r | |
259 | EFIAPI\r | |
260 | PeiServicesFfsFindNextFile (\r | |
261 | IN EFI_FV_FILETYPE SearchType,\r | |
1c280088 | 262 | IN EFI_PEI_FV_HANDLE VolumeHandle,\r |
263 | IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r | |
738ec565 | 264 | )\r |
265 | {\r | |
1c280088 | 266 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 267 | \r |
5240b97c | 268 | PeiServices = GetPeiServicesTablePointer ();\r |
1c280088 | 269 | return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, VolumeHandle, FileHandle);\r |
738ec565 | 270 | }\r |
271 | \r | |
272 | /**\r | |
273 | This service enables PEIMs to discover sections of a given type within a valid FFS file.\r | |
274 | \r | |
42eedea9 | 275 | @param SectionType The value of the section type to find.\r |
9095d37b | 276 | @param FileHandle A pointer to the file header that contains the set\r |
58380e9c | 277 | of sections to be searched.\r |
738ec565 | 278 | @param SectionData A pointer to the discovered section, if successful.\r |
279 | \r | |
280 | @retval EFI_SUCCESS The section was found.\r | |
281 | @retval EFI_NOT_FOUND The section was not found.\r | |
282 | \r | |
283 | **/\r | |
284 | EFI_STATUS\r | |
285 | EFIAPI\r | |
286 | PeiServicesFfsFindSectionData (\r | |
287 | IN EFI_SECTION_TYPE SectionType,\r | |
122e2191 | 288 | IN EFI_PEI_FILE_HANDLE FileHandle,\r |
67c89a21 | 289 | OUT VOID **SectionData\r |
738ec565 | 290 | )\r |
291 | {\r | |
1c280088 | 292 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 293 | \r |
5240b97c | 294 | PeiServices = GetPeiServicesTablePointer ();\r |
122e2191 | 295 | return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FileHandle, SectionData);\r |
738ec565 | 296 | }\r |
297 | \r | |
c7935105 SZ |
298 | /**\r |
299 | This service enables PEIMs to discover sections of a given instance and type within a valid FFS file.\r | |
300 | \r | |
301 | @param SectionType The value of the section type to find.\r | |
302 | @param SectionInstance Section instance to find.\r | |
9095d37b | 303 | @param FileHandle A pointer to the file header that contains the set\r |
c7935105 SZ |
304 | of sections to be searched.\r |
305 | @param SectionData A pointer to the discovered section, if successful.\r | |
306 | @param AuthenticationStatus A pointer to the authentication status for this section.\r | |
307 | \r | |
308 | @retval EFI_SUCCESS The section was found.\r | |
309 | @retval EFI_NOT_FOUND The section was not found.\r | |
310 | \r | |
311 | **/\r | |
312 | EFI_STATUS\r | |
313 | EFIAPI\r | |
314 | PeiServicesFfsFindSectionData3 (\r | |
315 | IN EFI_SECTION_TYPE SectionType,\r | |
316 | IN UINTN SectionInstance,\r | |
317 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
318 | OUT VOID **SectionData,\r | |
319 | OUT UINT32 *AuthenticationStatus\r | |
320 | )\r | |
321 | {\r | |
322 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
323 | \r | |
324 | PeiServices = GetPeiServicesTablePointer ();\r | |
325 | return (*PeiServices)->FindSectionData3 (PeiServices, SectionType, SectionInstance, FileHandle, SectionData, AuthenticationStatus);\r | |
326 | }\r | |
327 | \r | |
738ec565 | 328 | /**\r |
329 | This service enables PEIMs to register the permanent memory configuration\r | |
330 | that has been initialized with the PEI Foundation.\r | |
331 | \r | |
332 | @param MemoryBegin The value of a region of installed memory.\r | |
333 | @param MemoryLength The corresponding length of a region of installed memory.\r | |
334 | \r | |
335 | @retval EFI_SUCCESS The region was successfully installed in a HOB.\r | |
336 | @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r | |
337 | @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.\r | |
338 | \r | |
339 | **/\r | |
340 | EFI_STATUS\r | |
341 | EFIAPI\r | |
342 | PeiServicesInstallPeiMemory (\r | |
343 | IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r | |
344 | IN UINT64 MemoryLength\r | |
345 | )\r | |
346 | {\r | |
1c280088 | 347 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 348 | \r |
5240b97c | 349 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 350 | return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength);\r |
351 | }\r | |
352 | \r | |
353 | /**\r | |
3f315ecd | 354 | This service enables PEIMs to allocate memory.\r |
738ec565 | 355 | \r |
356 | @param MemoryType Type of memory to allocate.\r | |
2fc59a00 | 357 | @param Pages The number of pages to allocate.\r |
738ec565 | 358 | @param Memory Pointer of memory allocated.\r |
359 | \r | |
360 | @retval EFI_SUCCESS The memory range was successfully allocated.\r | |
3f315ecd SZ |
361 | @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,\r |
362 | EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,\r | |
363 | EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.\r | |
738ec565 | 364 | @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.\r |
365 | \r | |
366 | **/\r | |
367 | EFI_STATUS\r | |
368 | EFIAPI\r | |
369 | PeiServicesAllocatePages (\r | |
370 | IN EFI_MEMORY_TYPE MemoryType,\r | |
371 | IN UINTN Pages,\r | |
67c89a21 | 372 | OUT EFI_PHYSICAL_ADDRESS *Memory\r |
738ec565 | 373 | )\r |
374 | {\r | |
1c280088 | 375 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 376 | \r |
5240b97c | 377 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 378 | return (*PeiServices)->AllocatePages (PeiServices, MemoryType, Pages, Memory);\r |
379 | }\r | |
380 | \r | |
3f315ecd SZ |
381 | /**\r |
382 | This service enables PEIMs to free memory.\r | |
383 | \r | |
384 | @param Memory Memory to be freed.\r | |
385 | @param Pages The number of pages to free.\r | |
386 | \r | |
387 | @retval EFI_SUCCESS The requested pages were freed.\r | |
388 | @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.\r | |
389 | @retval EFI_NOT_FOUND The requested memory pages were not allocated with\r | |
390 | AllocatePages().\r | |
391 | \r | |
392 | **/\r | |
393 | EFI_STATUS\r | |
394 | EFIAPI\r | |
395 | PeiServicesFreePages (\r | |
396 | IN EFI_PHYSICAL_ADDRESS Memory,\r | |
397 | IN UINTN Pages\r | |
398 | )\r | |
399 | {\r | |
400 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
401 | \r | |
402 | PeiServices = GetPeiServicesTablePointer ();\r | |
403 | return (*PeiServices)->FreePages (PeiServices, Memory, Pages);\r | |
404 | }\r | |
405 | \r | |
738ec565 | 406 | /**\r |
407 | This service allocates memory from the Hand-Off Block (HOB) heap.\r | |
408 | \r | |
409 | @param Size The number of bytes to allocate from the pool.\r | |
9095d37b | 410 | @param Buffer If the call succeeds, a pointer to a pointer to\r |
58380e9c | 411 | the allocate buffer; otherwise, undefined.\r |
738ec565 | 412 | \r |
413 | @retval EFI_SUCCESS The allocation was successful\r | |
414 | @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.\r | |
415 | \r | |
416 | **/\r | |
417 | EFI_STATUS\r | |
418 | EFIAPI\r | |
419 | PeiServicesAllocatePool (\r | |
420 | IN UINTN Size,\r | |
421 | OUT VOID **Buffer\r | |
422 | )\r | |
423 | {\r | |
1c280088 | 424 | CONST EFI_PEI_SERVICES **PeiServices;\r |
738ec565 | 425 | \r |
5240b97c | 426 | PeiServices = GetPeiServicesTablePointer ();\r |
738ec565 | 427 | return (*PeiServices)->AllocatePool (PeiServices, Size, Buffer);\r |
428 | }\r | |
429 | \r | |
430 | /**\r | |
67c89a21 | 431 | Resets the entire platform.\r |
738ec565 | 432 | \r |
67c89a21 | 433 | @retval EFI_SUCCESS The function completed successfully.\r |
738ec565 | 434 | @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r |
435 | \r | |
436 | **/\r | |
437 | EFI_STATUS\r | |
438 | EFIAPI\r | |
439 | PeiServicesResetSystem (\r | |
440 | VOID\r | |
441 | )\r | |
b0d803fe | 442 | {\r |
443 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
444 | \r | |
5240b97c | 445 | PeiServices = GetPeiServicesTablePointer ();\r |
b0d803fe | 446 | return (*PeiServices)->ResetSystem (PeiServices);\r |
447 | }\r | |
448 | \r | |
67c89a21 | 449 | /**\r |
9095d37b LG |
450 | This service is a wrapper for the PEI Service RegisterForShadow(), except the\r |
451 | pointer to the PEI Services Table has been removed. See the Platform\r | |
452 | Initialization Pre-EFI Initialization Core Interface Specification for details.\r | |
67c89a21 | 453 | \r |
58380e9c | 454 | @param FileHandle PEIM's file handle. Must be the currently\r |
455 | executing PEIM.\r | |
9095d37b | 456 | \r |
58380e9c | 457 | @retval EFI_SUCCESS The PEIM was successfully registered for\r |
458 | shadowing.\r | |
67c89a21 | 459 | \r |
460 | @retval EFI_ALREADY_STARTED The PEIM was previously\r | |
461 | registered for shadowing.\r | |
462 | \r | |
58380e9c | 463 | @retval EFI_NOT_FOUND The FileHandle does not refer to a\r |
464 | valid file handle.\r | |
67c89a21 | 465 | **/\r |
b0d803fe | 466 | EFI_STATUS\r |
467 | EFIAPI\r | |
468 | PeiServicesRegisterForShadow (\r | |
469 | IN EFI_PEI_FILE_HANDLE FileHandle\r | |
470 | )\r | |
738ec565 | 471 | {\r |
484c7785 | 472 | return (*GetPeiServicesTablePointer())->RegisterForShadow (FileHandle);\r |
738ec565 | 473 | }\r |
b0d803fe | 474 | \r |
67c89a21 | 475 | /**\r |
9095d37b LG |
476 | This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services\r |
477 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r | |
478 | Specification for details.\r | |
67c89a21 | 479 | \r |
58380e9c | 480 | @param FileHandle The handle of the file.\r |
67c89a21 | 481 | \r |
58380e9c | 482 | @param FileInfo Upon exit, points to the file's\r |
483 | information.\r | |
67c89a21 | 484 | \r |
485 | @retval EFI_SUCCESS File information returned.\r | |
9095d37b | 486 | \r |
67c89a21 | 487 | @retval EFI_INVALID_PARAMETER If FileHandle does not\r |
488 | represent a valid file.\r | |
9095d37b | 489 | \r |
58380e9c | 490 | @retval EFI_INVALID_PARAMETER FileInfo is NULL.\r |
9095d37b | 491 | \r |
67c89a21 | 492 | **/\r |
b0d803fe | 493 | EFI_STATUS\r |
9095d37b | 494 | EFIAPI\r |
b0d803fe | 495 | PeiServicesFfsGetFileInfo (\r |
496 | IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r | |
497 | OUT EFI_FV_FILE_INFO *FileInfo\r | |
498 | )\r | |
499 | {\r | |
484c7785 | 500 | return (*GetPeiServicesTablePointer())->FfsGetFileInfo (FileHandle, FileInfo);\r |
b0d803fe | 501 | }\r |
502 | \r | |
c7935105 SZ |
503 | /**\r |
504 | This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services\r | |
505 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r | |
506 | Specification for details.\r | |
507 | \r | |
508 | @param FileHandle The handle of the file.\r | |
509 | @param FileInfo Upon exit, points to the file's\r | |
510 | information.\r | |
511 | \r | |
512 | @retval EFI_SUCCESS File information returned.\r | |
513 | @retval EFI_INVALID_PARAMETER If FileHandle does not\r | |
514 | represent a valid file.\r | |
515 | @retval EFI_INVALID_PARAMETER FileInfo is NULL.\r | |
516 | \r | |
517 | **/\r | |
518 | EFI_STATUS\r | |
519 | EFIAPI\r | |
520 | PeiServicesFfsGetFileInfo2 (\r | |
521 | IN CONST EFI_PEI_FILE_HANDLE FileHandle,\r | |
522 | OUT EFI_FV_FILE_INFO2 *FileInfo\r | |
523 | )\r | |
524 | {\r | |
525 | return (*GetPeiServicesTablePointer())->FfsGetFileInfo2 (FileHandle, FileInfo);\r | |
526 | }\r | |
b0d803fe | 527 | \r |
67c89a21 | 528 | /**\r |
9095d37b LG |
529 | This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services\r |
530 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r | |
531 | Specification for details.\r | |
67c89a21 | 532 | \r |
58380e9c | 533 | @param FileName A pointer to the name of the file to\r |
534 | find within the firmware volume.\r | |
67c89a21 | 535 | \r |
58380e9c | 536 | @param VolumeHandle The firmware volume to search FileHandle\r |
537 | Upon exit, points to the found file's\r | |
538 | handle or NULL if it could not be found.\r | |
9095d37b | 539 | @param FileHandle The pointer to found file handle\r |
42eedea9 | 540 | \r |
67c89a21 | 541 | @retval EFI_SUCCESS File was found.\r |
542 | \r | |
543 | @retval EFI_NOT_FOUND File was not found.\r | |
544 | \r | |
545 | @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or\r | |
546 | FileName was NULL.\r | |
547 | \r | |
548 | **/\r | |
b0d803fe | 549 | EFI_STATUS\r |
550 | EFIAPI\r | |
551 | PeiServicesFfsFindFileByName (\r | |
552 | IN CONST EFI_GUID *FileName,\r | |
553 | IN CONST EFI_PEI_FV_HANDLE VolumeHandle,\r | |
554 | OUT EFI_PEI_FILE_HANDLE *FileHandle\r | |
555 | )\r | |
556 | {\r | |
557 | return (*GetPeiServicesTablePointer())->FfsFindFileByName (FileName, VolumeHandle, FileHandle);\r | |
558 | }\r | |
559 | \r | |
560 | \r | |
67c89a21 | 561 | /**\r |
9095d37b LG |
562 | This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services\r |
563 | Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface\r | |
564 | Specification for details.\r | |
67c89a21 | 565 | \r |
58380e9c | 566 | @param VolumeHandle Handle of the volume.\r |
67c89a21 | 567 | \r |
58380e9c | 568 | @param VolumeInfo Upon exit, points to the volume's\r |
569 | information.\r | |
67c89a21 | 570 | \r |
571 | @retval EFI_SUCCESS File information returned.\r | |
9095d37b | 572 | \r |
67c89a21 | 573 | @retval EFI_INVALID_PARAMETER If FileHandle does not\r |
574 | represent a valid file.\r | |
9095d37b | 575 | \r |
67c89a21 | 576 | @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r |
577 | \r | |
578 | **/\r | |
b0d803fe | 579 | EFI_STATUS\r |
580 | EFIAPI\r | |
581 | PeiServicesFfsGetVolumeInfo (\r | |
582 | IN EFI_PEI_FV_HANDLE VolumeHandle,\r | |
583 | OUT EFI_FV_INFO *VolumeInfo\r | |
584 | )\r | |
585 | {\r | |
586 | return (*GetPeiServicesTablePointer())->FfsGetVolumeInfo (VolumeHandle, VolumeInfo);\r | |
587 | }\r | |
588 | \r | |
729675ae | 589 | /**\r |
c7935105 | 590 | Install a EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance so the PEI Core will be notified about a new firmware volume.\r |
b75a165d | 591 | \r |
c7935105 SZ |
592 | This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI using\r |
593 | the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance.\r | |
594 | If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI, then ASSERT().\r | |
595 | If the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI can not be installed, then ASSERT().\r | |
f66ad5d2 | 596 | If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r |
c7935105 SZ |
597 | \r |
598 | @param InstallFvInfoPpi Install FvInfo Ppi if it is TRUE. Otherwise, install FvInfo2 Ppi.\r | |
599 | @param FvFormat Unique identifier of the format of the memory-mapped\r | |
600 | firmware volume. This parameter is optional and\r | |
601 | may be NULL. If NULL is specified, the\r | |
58380e9c | 602 | EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r |
c7935105 SZ |
603 | @param FvInfo Points to a buffer which allows the\r |
604 | EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r | |
605 | The format of this buffer is specific to the FvFormat.\r | |
606 | For memory-mapped firmware volumes, this typically\r | |
58380e9c | 607 | points to the first byte of the firmware volume.\r |
c7935105 SZ |
608 | @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r |
609 | firmware volumes, this is typically the size of\r | |
58380e9c | 610 | the firmware volume.\r |
c7935105 SZ |
611 | @param ParentFvName If the new firmware volume originated from a file\r |
612 | in a different firmware volume, then this parameter\r | |
58380e9c | 613 | specifies the GUID name of the originating firmware\r |
614 | volume. Otherwise, this parameter must be NULL.\r | |
c7935105 SZ |
615 | @param ParentFileName If the new firmware volume originated from a file\r |
616 | in a different firmware volume, then this parameter\r | |
617 | specifies the GUID file name of the originating\r | |
58380e9c | 618 | firmware file. Otherwise, this parameter must be NULL.\r |
c7935105 | 619 | @param AuthenticationStatus Authentication Status, it will be ignored if InstallFvInfoPpi is TRUE.\r |
729675ae | 620 | **/\r |
621 | VOID\r | |
622 | EFIAPI\r | |
c7935105 SZ |
623 | InternalPeiServicesInstallFvInfoPpi (\r |
624 | IN BOOLEAN InstallFvInfoPpi,\r | |
729675ae | 625 | IN CONST EFI_GUID *FvFormat, OPTIONAL\r |
626 | IN CONST VOID *FvInfo,\r | |
627 | IN UINT32 FvInfoSize,\r | |
628 | IN CONST EFI_GUID *ParentFvName, OPTIONAL\r | |
c7935105 SZ |
629 | IN CONST EFI_GUID *ParentFileName, OPTIONAL\r |
630 | IN UINT32 AuthenticationStatus\r | |
729675ae | 631 | )\r |
632 | {\r | |
9095d37b | 633 | EFI_STATUS Status;\r |
729675ae | 634 | EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi;\r |
635 | EFI_PEI_PPI_DESCRIPTOR *FvInfoPpiDescriptor;\r | |
3831f3e9 LG |
636 | EFI_GUID *ParentFvNameValue;\r |
637 | EFI_GUID *ParentFileNameValue;\r | |
c7935105 | 638 | EFI_GUID *PpiGuid;\r |
729675ae | 639 | \r |
3831f3e9 LG |
640 | ParentFvNameValue = NULL;\r |
641 | ParentFileNameValue = NULL;\r | |
c7935105 SZ |
642 | if (InstallFvInfoPpi) {\r |
643 | //\r | |
644 | // To install FvInfo Ppi.\r | |
645 | //\r | |
646 | FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));\r | |
ed84519c | 647 | ASSERT (FvInfoPpi != NULL);\r |
c7935105 SZ |
648 | PpiGuid = &gEfiPeiFirmwareVolumeInfoPpiGuid;\r |
649 | } else {\r | |
650 | //\r | |
651 | // To install FvInfo2 Ppi.\r | |
652 | //\r | |
653 | FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI));\r | |
ed84519c | 654 | ASSERT (FvInfoPpi != NULL);\r |
c7935105 SZ |
655 | ((EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *) FvInfoPpi)->AuthenticationStatus = AuthenticationStatus;\r |
656 | PpiGuid = &gEfiPeiFirmwareVolumeInfo2PpiGuid;\r | |
657 | }\r | |
729675ae | 658 | \r |
659 | if (FvFormat != NULL) {\r | |
660 | CopyGuid (&FvInfoPpi->FvFormat, FvFormat);\r | |
661 | } else {\r | |
662 | CopyGuid (&FvInfoPpi->FvFormat, &gEfiFirmwareFileSystem2Guid);\r | |
f66ad5d2 SZ |
663 | //\r |
664 | // Since the EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed if NULL is specified for FvFormat,\r | |
665 | // check the FileSystemGuid pointed by FvInfo against EFI_FIRMWARE_FILE_SYSTEM2_GUID to make sure\r | |
666 | // FvInfo has the firmware file system 2 format.\r | |
667 | // If the ASSERT really appears, FvFormat needs to be specified correctly, for example,\r | |
668 | // EFI_FIRMWARE_FILE_SYSTEM3_GUID can be used for firmware file system 3 format, or\r | |
669 | // ((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo)->FileSystemGuid can be just used for both\r | |
670 | // firmware file system 2 and 3 format.\r | |
671 | //\r | |
672 | ASSERT (CompareGuid (&(((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo)->FileSystemGuid), &gEfiFirmwareFileSystem2Guid));\r | |
729675ae | 673 | }\r |
674 | FvInfoPpi->FvInfo = (VOID *) FvInfo;\r | |
675 | FvInfoPpi->FvInfoSize = FvInfoSize;\r | |
3831f3e9 LG |
676 | if (ParentFvName != NULL) {\r |
677 | ParentFvNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFvName);\r | |
60bd4ccd | 678 | ASSERT (ParentFvNameValue != NULL);\r |
3831f3e9 LG |
679 | FvInfoPpi->ParentFvName = ParentFvNameValue;\r |
680 | }\r | |
681 | if (ParentFileName != NULL) {\r | |
682 | ParentFileNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFileName);\r | |
683 | ASSERT (ParentFileNameValue != NULL);\r | |
684 | FvInfoPpi->ParentFileName = ParentFileNameValue;\r | |
685 | }\r | |
729675ae | 686 | \r |
c7935105 | 687 | FvInfoPpiDescriptor = AllocatePool (sizeof (EFI_PEI_PPI_DESCRIPTOR));\r |
729675ae | 688 | ASSERT (FvInfoPpiDescriptor != NULL);\r |
689 | \r | |
c7935105 SZ |
690 | FvInfoPpiDescriptor->Guid = PpiGuid;\r |
691 | FvInfoPpiDescriptor->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r | |
729675ae | 692 | FvInfoPpiDescriptor->Ppi = (VOID *) FvInfoPpi;\r |
693 | Status = PeiServicesInstallPpi (FvInfoPpiDescriptor);\r | |
694 | ASSERT_EFI_ERROR (Status);\r | |
695 | \r | |
696 | }\r | |
697 | \r | |
c7935105 SZ |
698 | /**\r |
699 | Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.\r | |
700 | \r | |
701 | This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using\r | |
702 | the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.\r | |
703 | If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().\r | |
704 | If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().\r | |
f66ad5d2 | 705 | If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r |
c7935105 SZ |
706 | \r |
707 | @param FvFormat Unique identifier of the format of the memory-mapped\r | |
708 | firmware volume. This parameter is optional and\r | |
709 | may be NULL. If NULL is specified, the\r | |
710 | EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r | |
711 | @param FvInfo Points to a buffer which allows the\r | |
712 | EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r | |
713 | The format of this buffer is specific to the FvFormat.\r | |
714 | For memory-mapped firmware volumes, this typically\r | |
715 | points to the first byte of the firmware volume.\r | |
716 | @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r | |
717 | firmware volumes, this is typically the size of\r | |
718 | the firmware volume.\r | |
719 | @param ParentFvName If the new firmware volume originated from a file\r | |
720 | in a different firmware volume, then this parameter\r | |
721 | specifies the GUID name of the originating firmware\r | |
722 | volume. Otherwise, this parameter must be NULL.\r | |
723 | @param ParentFileName If the new firmware volume originated from a file\r | |
724 | in a different firmware volume, then this parameter\r | |
725 | specifies the GUID file name of the originating\r | |
726 | firmware file. Otherwise, this parameter must be NULL.\r | |
727 | **/\r | |
728 | VOID\r | |
729 | EFIAPI\r | |
730 | PeiServicesInstallFvInfoPpi (\r | |
731 | IN CONST EFI_GUID *FvFormat, OPTIONAL\r | |
732 | IN CONST VOID *FvInfo,\r | |
733 | IN UINT32 FvInfoSize,\r | |
734 | IN CONST EFI_GUID *ParentFvName, OPTIONAL\r | |
735 | IN CONST EFI_GUID *ParentFileName OPTIONAL\r | |
736 | )\r | |
737 | {\r | |
738 | InternalPeiServicesInstallFvInfoPpi (TRUE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, 0);\r | |
739 | }\r | |
740 | \r | |
741 | /**\r | |
742 | Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.\r | |
743 | \r | |
744 | This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using\r | |
745 | the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.\r | |
746 | If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().\r | |
747 | If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().\r | |
f66ad5d2 | 748 | If NULL is specified for FvFormat, but FvInfo does not have the firmware file system 2 format, then ASSERT.\r |
c7935105 SZ |
749 | \r |
750 | @param FvFormat Unique identifier of the format of the memory-mapped\r | |
751 | firmware volume. This parameter is optional and\r | |
752 | may be NULL. If NULL is specified, the\r | |
753 | EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r | |
754 | @param FvInfo Points to a buffer which allows the\r | |
755 | EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.\r | |
756 | The format of this buffer is specific to the FvFormat.\r | |
757 | For memory-mapped firmware volumes, this typically\r | |
758 | points to the first byte of the firmware volume.\r | |
759 | @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped\r | |
760 | firmware volumes, this is typically the size of\r | |
761 | the firmware volume.\r | |
762 | @param ParentFvName If the new firmware volume originated from a file\r | |
763 | in a different firmware volume, then this parameter\r | |
764 | specifies the GUID name of the originating firmware\r | |
765 | volume. Otherwise, this parameter must be NULL.\r | |
766 | @param ParentFileName If the new firmware volume originated from a file\r | |
767 | in a different firmware volume, then this parameter\r | |
768 | specifies the GUID file name of the originating\r | |
769 | firmware file. Otherwise, this parameter must be NULL.\r | |
770 | @param AuthenticationStatus Authentication Status\r | |
771 | **/\r | |
772 | VOID\r | |
773 | EFIAPI\r | |
774 | PeiServicesInstallFvInfo2Ppi (\r | |
775 | IN CONST EFI_GUID *FvFormat, OPTIONAL\r | |
776 | IN CONST VOID *FvInfo,\r | |
777 | IN UINT32 FvInfoSize,\r | |
778 | IN CONST EFI_GUID *ParentFvName, OPTIONAL\r | |
779 | IN CONST EFI_GUID *ParentFileName, OPTIONAL\r | |
780 | IN UINT32 AuthenticationStatus\r | |
781 | )\r | |
782 | {\r | |
783 | InternalPeiServicesInstallFvInfoPpi (FALSE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, AuthenticationStatus);\r | |
784 | }\r | |
785 | \r | |
dacf87e8 MK |
786 | /**\r |
787 | Resets the entire platform.\r | |
788 | \r | |
789 | @param[in] ResetType The type of reset to perform.\r | |
790 | @param[in] ResetStatus The status code for the reset.\r | |
791 | @param[in] DataSize The size, in bytes, of ResetData.\r | |
792 | @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r | |
793 | the data buffer starts with a Null-terminated string, optionally\r | |
794 | followed by additional binary data. The string is a description\r | |
795 | that the caller may use to further indicate the reason for the\r | |
d821151e | 796 | system reset.\r |
dacf87e8 MK |
797 | \r |
798 | **/\r | |
799 | VOID\r | |
800 | EFIAPI\r | |
801 | PeiServicesResetSystem2 (\r | |
802 | IN EFI_RESET_TYPE ResetType,\r | |
803 | IN EFI_STATUS ResetStatus,\r | |
804 | IN UINTN DataSize,\r | |
805 | IN VOID *ResetData OPTIONAL\r | |
806 | )\r | |
807 | {\r | |
808 | (*GetPeiServicesTablePointer())->ResetSystem2 (ResetType, ResetStatus, DataSize, ResetData);\r | |
809 | }\r |