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