]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c
EmulatorPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmulatorPkg / Library / SecPeiServicesLib / PeiServicesLib.c
1 /** @file
2 Implementation for PEI Services Library.
3
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9
10 #include <PiPei.h>
11 #include <Library/EmuMagicPageLib.h>
12 #include <Library/PeiServicesLib.h>
13 #include <Library/DebugLib.h>
14 #include <Library/BaseMemoryLib.h>
15
16
17
18 EFI_STATUS
19 SecFfsFindNextFile (
20 IN EFI_FV_FILETYPE SearchType,
21 IN EFI_PEI_FV_HANDLE VolumeHandle,
22 IN OUT EFI_PEI_FILE_HANDLE *FileHandle
23 );
24
25 EFI_STATUS
26 SecFfsFindSectionData (
27 IN EFI_SECTION_TYPE SectionType,
28 IN EFI_PEI_FILE_HANDLE FileHandle,
29 OUT VOID **SectionData
30 );
31
32
33 /**
34 This service enables a given PEIM to register an interface into the PEI Foundation.
35
36 @param PpiList A pointer to the list of interfaces that the caller shall install.
37
38 @retval EFI_SUCCESS The interface was successfully installed.
39 @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
40 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
41 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
42 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
43
44 **/
45 EFI_STATUS
46 EFIAPI
47 PeiServicesInstallPpi (
48 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
49 )
50 {
51 ASSERT (FALSE);
52 return EFI_OUT_OF_RESOURCES;
53 }
54
55 /**
56 This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
57
58 @param OldPpi The pointer to the old PEI PPI Descriptors.
59 @param NewPpi The pointer to the new PEI PPI Descriptors.
60
61 @retval EFI_SUCCESS The interface was successfully installed.
62 @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
63 @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
64 EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
65 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
66 @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
67 installed.
68
69 **/
70 EFI_STATUS
71 EFIAPI
72 PeiServicesReInstallPpi (
73 IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
74 IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
75 )
76 {
77 ASSERT (FALSE);
78 return EFI_OUT_OF_RESOURCES;
79 }
80
81 /**
82 This service enables PEIMs to discover a given instance of an interface.
83
84 So this is, well a hack, so we can reuse the same libraries as the PEI Core
85 for XIP modules....
86
87 @param Guid A pointer to the GUID whose corresponding interface needs to be
88 found.
89 @param Instance The N-th instance of the interface that is required.
90 @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
91 @param Ppi A pointer to the instance of the interface.
92
93 @retval EFI_SUCCESS The interface was successfully returned.
94 @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
95
96 **/
97 EFI_STATUS
98 EFIAPI
99 PeiServicesLocatePpi (
100 IN CONST EFI_GUID *Guid,
101 IN UINTN Instance,
102 IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
103 IN OUT VOID **Ppi
104 )
105 {
106 EFI_PEI_PPI_DESCRIPTOR *PpiList;
107
108 if (Instance != 0) {
109 return EFI_NOT_FOUND;
110 }
111
112 for (PpiList = EMU_MAGIC_PAGE()->PpiList; ; PpiList++) {
113 if (CompareGuid (PpiList->Guid, Guid)) {
114 if (PpiDescriptor != NULL) {
115 *PpiDescriptor = PpiList;
116 }
117 if (Ppi != NULL) {
118 *Ppi = PpiList->Ppi;
119 }
120 return EFI_SUCCESS;
121 }
122
123 if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
124 break;
125 }
126 }
127
128
129 return EFI_NOT_FOUND;
130 }
131
132 /**
133 This service enables PEIMs to register a given service to be invoked when another service is
134 installed or reinstalled.
135
136 @param NotifyList A pointer to the list of notification interfaces
137 that the caller shall install.
138
139 @retval EFI_SUCCESS The interface was successfully installed.
140 @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
141 @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do
142 not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES
143 bit set in the Flags field.
144 @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
145
146 **/
147 EFI_STATUS
148 EFIAPI
149 PeiServicesNotifyPpi (
150 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
151 )
152 {
153 ASSERT (FALSE);
154 return EFI_OUT_OF_RESOURCES;
155 }
156
157 /**
158 This service enables PEIMs to ascertain the present value of the boot mode.
159
160 @param BootMode A pointer to contain the value of the boot mode.
161
162 @retval EFI_SUCCESS The boot mode was returned successfully.
163 @retval EFI_INVALID_PARAMETER BootMode is NULL.
164
165 **/
166 EFI_STATUS
167 EFIAPI
168 PeiServicesGetBootMode (
169 OUT EFI_BOOT_MODE *BootMode
170 )
171 {
172 ASSERT (FALSE);
173 return EFI_OUT_OF_RESOURCES;
174 }
175
176 /**
177 This service enables PEIMs to update the boot mode variable.
178
179 @param BootMode The value of the boot mode to set.
180
181 @retval EFI_SUCCESS The value was successfully updated
182
183 **/
184 EFI_STATUS
185 EFIAPI
186 PeiServicesSetBootMode (
187 IN EFI_BOOT_MODE BootMode
188 )
189 {
190 ASSERT (FALSE);
191 return EFI_OUT_OF_RESOURCES;
192 }
193
194 /**
195 This service enables a PEIM to ascertain the address of the list of HOBs in memory.
196
197 @param HobList A pointer to the list of HOBs that the PEI Foundation
198 will initialize.
199
200 @retval EFI_SUCCESS The list was successfully returned.
201 @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
202
203 **/
204 EFI_STATUS
205 EFIAPI
206 PeiServicesGetHobList (
207 OUT VOID **HobList
208 )
209 {
210 ASSERT (FALSE);
211 return EFI_OUT_OF_RESOURCES;
212 }
213
214 /**
215 This service enables PEIMs to create various types of HOBs.
216
217 @param Type The type of HOB to be installed.
218 @param Length The length of the HOB to be added.
219 @param Hob The address of a pointer that will contain the
220 HOB header.
221
222 @retval EFI_SUCCESS The HOB was successfully created.
223 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
224
225 **/
226 EFI_STATUS
227 EFIAPI
228 PeiServicesCreateHob (
229 IN UINT16 Type,
230 IN UINT16 Length,
231 OUT VOID **Hob
232 )
233 {
234 ASSERT (FALSE);
235 return EFI_OUT_OF_RESOURCES;
236 }
237
238 /**
239 This service enables PEIMs to discover additional firmware volumes.
240
241 @param Instance This instance of the firmware volume to find. The
242 value 0 is the Boot Firmware Volume (BFV).
243 @param VolumeHandle Handle of the firmware volume header of the volume
244 to return.
245
246 @retval EFI_SUCCESS The volume was found.
247 @retval EFI_NOT_FOUND The volume was not found.
248 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
249
250 **/
251 EFI_STATUS
252 EFIAPI
253 PeiServicesFfsFindNextVolume (
254 IN UINTN Instance,
255 IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
256 )
257 {
258 ASSERT (FALSE);
259 return EFI_OUT_OF_RESOURCES;
260 }
261
262 /**
263 This service enables PEIMs to discover additional firmware files.
264
265 @param SearchType A filter to find files only of this type.
266 @param VolumeHandle The pointer to the firmware volume header of the
267 volume to search. This parameter must point to a
268 valid FFS volume.
269 @param FileHandle Handle of the current file from which to begin searching.
270
271 @retval EFI_SUCCESS The file was found.
272 @retval EFI_NOT_FOUND The file was not found.
273 @retval EFI_NOT_FOUND The header checksum was not zero.
274
275 **/
276 EFI_STATUS
277 EFIAPI
278 PeiServicesFfsFindNextFile (
279 IN EFI_FV_FILETYPE SearchType,
280 IN EFI_PEI_FV_HANDLE VolumeHandle,
281 IN OUT EFI_PEI_FILE_HANDLE *FileHandle
282 )
283 {
284 return SecFfsFindNextFile (SearchType, VolumeHandle, FileHandle);
285 }
286
287 /**
288 This service enables PEIMs to discover sections of a given type within a valid FFS file.
289
290 @param SectionType The value of the section type to find.
291 @param FileHandle A pointer to the file header that contains the set
292 of sections to be searched.
293 @param SectionData A pointer to the discovered section, if successful.
294
295 @retval EFI_SUCCESS The section was found.
296 @retval EFI_NOT_FOUND The section was not found.
297
298 **/
299 EFI_STATUS
300 EFIAPI
301 PeiServicesFfsFindSectionData (
302 IN EFI_SECTION_TYPE SectionType,
303 IN EFI_PEI_FILE_HANDLE FileHandle,
304 OUT VOID **SectionData
305 )
306 {
307 return SecFfsFindSectionData (SectionType, FileHandle, SectionData);
308 }
309
310 /**
311 This service enables PEIMs to register the permanent memory configuration
312 that has been initialized with the PEI Foundation.
313
314 @param MemoryBegin The value of a region of installed memory.
315 @param MemoryLength The corresponding length of a region of installed memory.
316
317 @retval EFI_SUCCESS The region was successfully installed in a HOB.
318 @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
319 @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
320
321 **/
322 EFI_STATUS
323 EFIAPI
324 PeiServicesInstallPeiMemory (
325 IN EFI_PHYSICAL_ADDRESS MemoryBegin,
326 IN UINT64 MemoryLength
327 )
328 {
329 ASSERT (FALSE);
330 return EFI_OUT_OF_RESOURCES;
331 }
332
333 /**
334 This service enables PEIMs to allocate memory after the permanent memory has been
335 installed by a PEIM.
336
337 @param MemoryType Type of memory to allocate.
338 @param Pages The number of pages to allocate.
339 @param Memory Pointer of memory allocated.
340
341 @retval EFI_SUCCESS The memory range was successfully allocated.
342 @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
343 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
344 @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
345
346 **/
347 EFI_STATUS
348 EFIAPI
349 PeiServicesAllocatePages (
350 IN EFI_MEMORY_TYPE MemoryType,
351 IN UINTN Pages,
352 OUT EFI_PHYSICAL_ADDRESS *Memory
353 )
354 {
355 ASSERT (FALSE);
356 return EFI_OUT_OF_RESOURCES;
357 }
358
359 /**
360 This service allocates memory from the Hand-Off Block (HOB) heap.
361
362 @param Size The number of bytes to allocate from the pool.
363 @param Buffer If the call succeeds, a pointer to a pointer to
364 the allocate buffer; otherwise, undefined.
365
366 @retval EFI_SUCCESS The allocation was successful
367 @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
368
369 **/
370 EFI_STATUS
371 EFIAPI
372 PeiServicesAllocatePool (
373 IN UINTN Size,
374 OUT VOID **Buffer
375 )
376 {
377 ASSERT (FALSE);
378 return EFI_OUT_OF_RESOURCES;
379 }
380
381 /**
382 Resets the entire platform.
383
384 @retval EFI_SUCCESS The function completed successfully.
385 @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
386
387 **/
388 EFI_STATUS
389 EFIAPI
390 PeiServicesResetSystem (
391 VOID
392 )
393 {
394 ASSERT (FALSE);
395 return EFI_OUT_OF_RESOURCES;
396 }
397
398 /**
399 This service is a wrapper for the PEI Service RegisterForShadow(), except the
400 pointer to the PEI Services Table has been removed. See the Platform
401 Initialization Pre-EFI Initialization Core Interface Specification for details.
402
403 @param FileHandle PEIM's file handle. Must be the currently
404 executing PEIM.
405
406 @retval EFI_SUCCESS The PEIM was successfully registered for
407 shadowing.
408
409 @retval EFI_ALREADY_STARTED The PEIM was previously
410 registered for shadowing.
411
412 @retval EFI_NOT_FOUND The FileHandle does not refer to a
413 valid file handle.
414 **/
415 EFI_STATUS
416 EFIAPI
417 PeiServicesRegisterForShadow (
418 IN EFI_PEI_FILE_HANDLE FileHandle
419 )
420 {
421 ASSERT (FALSE);
422 return EFI_OUT_OF_RESOURCES;
423 }
424
425 /**
426 This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services
427 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
428 Specification for details.
429
430 @param FileHandle The handle of the file.
431
432 @param FileInfo Upon exit, points to the file's
433 information.
434
435 @retval EFI_SUCCESS File information returned.
436
437 @retval EFI_INVALID_PARAMETER If FileHandle does not
438 represent a valid file.
439
440 @retval EFI_INVALID_PARAMETER FileInfo is NULL.
441
442 **/
443 EFI_STATUS
444 EFIAPI
445 PeiServicesFfsGetFileInfo (
446 IN CONST EFI_PEI_FILE_HANDLE FileHandle,
447 OUT EFI_FV_FILE_INFO *FileInfo
448 )
449 {
450 ASSERT (FALSE);
451 return EFI_OUT_OF_RESOURCES;
452 }
453
454
455 /**
456 This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
457 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
458 Specification for details.
459
460 @param FileName A pointer to the name of the file to
461 find within the firmware volume.
462
463 @param VolumeHandle The firmware volume to search FileHandle
464 Upon exit, points to the found file's
465 handle or NULL if it could not be found.
466 @param FileHandle The pointer to found file handle
467
468 @retval EFI_SUCCESS File was found.
469
470 @retval EFI_NOT_FOUND File was not found.
471
472 @retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
473 FileName was NULL.
474
475 **/
476 EFI_STATUS
477 EFIAPI
478 PeiServicesFfsFindFileByName (
479 IN CONST EFI_GUID *FileName,
480 IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
481 OUT EFI_PEI_FILE_HANDLE *FileHandle
482 )
483 {
484 ASSERT (FALSE);
485 return EFI_OUT_OF_RESOURCES;
486 }
487
488
489 /**
490 This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
491 Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
492 Specification for details.
493
494 @param VolumeHandle Handle of the volume.
495
496 @param VolumeInfo Upon exit, points to the volume's
497 information.
498
499 @retval EFI_SUCCESS File information returned.
500
501 @retval EFI_INVALID_PARAMETER If FileHandle does not
502 represent a valid file.
503
504 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
505
506 **/
507 EFI_STATUS
508 EFIAPI
509 PeiServicesFfsGetVolumeInfo (
510 IN EFI_PEI_FV_HANDLE VolumeHandle,
511 OUT EFI_FV_INFO *VolumeInfo
512 )
513 {
514 ASSERT (FALSE);
515 return EFI_OUT_OF_RESOURCES;
516 }
517
518 /**
519 Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
520
521 This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
522 the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
523 If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
524 If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
525
526
527 @param FvFormat Unique identifier of the format of the memory-mapped
528 firmware volume. This parameter is optional and
529 may be NULL. If NULL is specified, the
530 EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
531 @param FvInfo Points to a buffer which allows the
532 EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
533 The format of this buffer is specific to the FvFormat.
534 For memory-mapped firmware volumes, this typically
535 points to the first byte of the firmware volume.
536 @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
537 firmware volumes, this is typically the size of
538 the firmware volume.
539 @param ParentFvName If the new firmware volume originated from a file
540 in a different firmware volume, then this parameter
541 specifies the GUID name of the originating firmware
542 volume. Otherwise, this parameter must be NULL.
543 @param ParentFileName If the new firmware volume originated from a file
544 in a different firmware volume, then this parameter
545 specifies the GUID file name of the originating
546 firmware file. Otherwise, this parameter must be NULL.
547 **/
548 VOID
549 EFIAPI
550 PeiServicesInstallFvInfoPpi (
551 IN CONST EFI_GUID *FvFormat, OPTIONAL
552 IN CONST VOID *FvInfo,
553 IN UINT32 FvInfoSize,
554 IN CONST EFI_GUID *ParentFvName, OPTIONAL
555 IN CONST EFI_GUID *ParentFileName OPTIONAL
556 )
557 {
558 ASSERT (FALSE);
559 return;
560 }
561