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