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