]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/UefiLib.h
BaseTools:Add [packages] section in dsc file
[mirror_edk2.git] / MdePkg / Include / Library / UefiLib.h
CommitLineData
fb3df220 1/** @file\r
50a64e5b 2 Provides library functions for common UEFI operations. Only available to DXE\r
3 and UEFI module types.\r
4\r
9095d37b
LG
5 The UEFI Library provides functions and macros that simplify the development of\r
6 UEFI Drivers and UEFI Applications. These functions and macros help manage EFI\r
7 events, build simple locks utilizing EFI Task Priority Levels (TPLs), install\r
8 EFI Driver Model related protocols, manage Unicode string tables for UEFI Drivers,\r
e500088c 9 and print messages on the console output and standard error devices.\r
fb3df220 10\r
5ee9264a 11 Note that a reserved macro named MDEPKG_NDEBUG is introduced for the intention\r
12 of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is\r
13 defined, then debug and assert related macros wrapped by it are the NULL implementations.\r
14\r
0290fca2 15Copyright (c) 2019, NVIDIA Corporation. All rights reserved.\r
40070a18 16Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 17SPDX-License-Identifier: BSD-2-Clause-Patent\r
fb3df220 18\r
19**/\r
20\r
21#ifndef __UEFI_LIB_H__\r
22#define __UEFI_LIB_H__\r
23\r
af5e9521
SZ
24#include <IndustryStandard/Acpi.h>\r
25\r
c7d265a9 26#include <Protocol/DriverBinding.h>\r
27#include <Protocol/DriverConfiguration.h>\r
28#include <Protocol/ComponentName.h>\r
29#include <Protocol/ComponentName2.h>\r
30#include <Protocol/DriverDiagnostics.h>\r
31#include <Protocol/DriverDiagnostics2.h>\r
b3154720 32#include <Protocol/GraphicsOutput.h>\r
768b6111
LE
33#include <Protocol/DevicePath.h>\r
34#include <Protocol/SimpleFileSystem.h>\r
c7d265a9 35\r
52ca0d98 36#include <Library/BaseLib.h>\r
37\r
fc30687f 38///\r
39/// Unicode String Table\r
40///\r
fb3df220 41typedef struct {\r
42 CHAR8 *Language;\r
43 CHAR16 *UnicodeString;\r
44} EFI_UNICODE_STRING_TABLE;\r
45\r
fc30687f 46///\r
47/// EFI Lock Status\r
48///\r
fb3df220 49typedef enum {\r
50 EfiLockUninitialized = 0,\r
51 EfiLockReleased = 1,\r
52 EfiLockAcquired = 2\r
53} EFI_LOCK_STATE;\r
54\r
fc30687f 55///\r
9095d37b 56/// EFI Lock\r
fc30687f 57///\r
fb3df220 58typedef struct {\r
59 EFI_TPL Tpl;\r
60 EFI_TPL OwnerTpl;\r
61 EFI_LOCK_STATE Lock;\r
62} EFI_LOCK;\r
63\r
52ca0d98 64/**\r
65 Macro that returns the number of 100 ns units for a specified number of microseconds.\r
af2dc6a7 66 This is useful for managing EFI timer events.\r
52ca0d98 67\r
af2dc6a7 68 @param Microseconds The number of microseconds.\r
52ca0d98 69\r
70 @return The number of 100 ns units equivalent to the number of microseconds specified\r
71 by Microseconds.\r
72\r
73**/\r
74#define EFI_TIMER_PERIOD_MICROSECONDS(Microseconds) MultU64x32((UINT64)(Microseconds), 10)\r
75\r
52ca0d98 76/**\r
28d3e14f 77 Macro that returns the number of 100 ns units for a specified number of milliseconds.\r
af2dc6a7 78 This is useful for managing EFI timer events.\r
52ca0d98 79\r
af2dc6a7 80 @param Milliseconds The number of milliseconds.\r
52ca0d98 81\r
82 @return The number of 100 ns units equivalent to the number of milliseconds specified\r
83 by Milliseconds.\r
84\r
85**/\r
86#define EFI_TIMER_PERIOD_MILLISECONDS(Milliseconds) MultU64x32((UINT64)(Milliseconds), 10000)\r
87\r
52ca0d98 88/**\r
28d3e14f 89 Macro that returns the number of 100 ns units for a specified number of seconds.\r
af2dc6a7 90 This is useful for managing EFI timer events.\r
52ca0d98 91\r
af2dc6a7 92 @param Seconds The number of seconds.\r
52ca0d98 93\r
94 @return The number of 100 ns units equivalent to the number of seconds specified\r
95 by Seconds.\r
96\r
97**/\r
98#define EFI_TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)\r
99\r
9bfdfa52 100/**\r
9095d37b
LG
101 Macro that returns the a pointer to the next EFI_MEMORY_DESCRIPTOR in an array\r
102 returned from GetMemoryMap().\r
9bfdfa52 103\r
daa6553a 104 @param MemoryDescriptor A pointer to an EFI_MEMORY_DESCRIPTOR.\r
9bfdfa52 105\r
106 @param Size The size, in bytes, of the current EFI_MEMORY_DESCRIPTOR.\r
107\r
108 @return A pointer to the next EFI_MEMORY_DESCRIPTOR.\r
109\r
110**/\r
111#define NEXT_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \\r
112 ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) + (Size)))\r
52ca0d98 113\r
fb3df220 114/**\r
1d37ab9f 115 Retrieves a pointer to the system configuration table from the EFI System Table\r
116 based on a specified GUID.\r
9095d37b 117\r
1d37ab9f 118 This function searches the list of configuration tables stored in the EFI System Table\r
1a2f870c 119 for a table with a GUID that matches TableGuid. If a match is found, then a pointer to\r
120 the configuration table is returned in Table, and EFI_SUCCESS is returned. If a matching GUID\r
1d37ab9f 121 is not found, then EFI_NOT_FOUND is returned.\r
122 If TableGuid is NULL, then ASSERT().\r
123 If Table is NULL, then ASSERT().\r
fb3df220 124\r
af2dc6a7 125 @param TableGuid The pointer to table's GUID type..\r
126 @param Table The pointer to the table associated with TableGuid in the EFI System Table.\r
fb3df220 127\r
128 @retval EFI_SUCCESS A configuration table matching TableGuid was found.\r
129 @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.\r
130\r
131**/\r
132EFI_STATUS\r
133EFIAPI\r
9095d37b 134EfiGetSystemConfigurationTable (\r
fb3df220 135 IN EFI_GUID *TableGuid,\r
136 OUT VOID **Table\r
137 );\r
138\r
139/**\r
1d37ab9f 140 Creates and returns a notification event and registers that event with all the protocol\r
141 instances specified by ProtocolGuid.\r
142\r
143 This function causes the notification function to be executed for every protocol of type\r
f0a8eeb2 144 ProtocolGuid instance that exists in the system when this function is invoked. If there are\r
145 no instances of ProtocolGuid in the handle database at the time this function is invoked,\r
146 then the notification function is still executed one time. In addition, every time a protocol\r
147 of type ProtocolGuid instance is installed or reinstalled, the notification function is also\r
9095d37b 148 executed. This function returns the notification event that was created.\r
1d37ab9f 149 If ProtocolGuid is NULL, then ASSERT().\r
150 If NotifyTpl is not a legal TPL value, then ASSERT().\r
151 If NotifyFunction is NULL, then ASSERT().\r
152 If Registration is NULL, then ASSERT().\r
fb3df220 153\r
f0a8eeb2 154\r
fb3df220 155 @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.\r
156 @param NotifyTpl Supplies the task priority level of the event notifications.\r
157 @param NotifyFunction Supplies the function to notify when the event is signaled.\r
158 @param NotifyContext The context parameter to pass to NotifyFunction.\r
159 @param Registration A pointer to a memory location to receive the registration value.\r
1d37ab9f 160 This value is passed to LocateHandle() to obtain new handles that\r
9095d37b 161 have been added that support the ProtocolGuid-specified protocol.\r
fb3df220 162\r
1d37ab9f 163 @return The notification event that was created.\r
fb3df220 164\r
165**/\r
166EFI_EVENT\r
167EFIAPI\r
168EfiCreateProtocolNotifyEvent(\r
169 IN EFI_GUID *ProtocolGuid,\r
170 IN EFI_TPL NotifyTpl,\r
171 IN EFI_EVENT_NOTIFY NotifyFunction,\r
172 IN VOID *NotifyContext, OPTIONAL\r
173 OUT VOID **Registration\r
174 );\r
175\r
176/**\r
1d37ab9f 177 Creates a named event that can be signaled with EfiNamedEventSignal().\r
178\r
fb3df220 179 This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.\r
1d37ab9f 180 This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more\r
9095d37b 181 listeners on the same event named by the GUID specified by Name.\r
1d37ab9f 182 If Name is NULL, then ASSERT().\r
183 If NotifyTpl is not a legal TPL value, then ASSERT().\r
184 If NotifyFunction is NULL, then ASSERT().\r
fb3df220 185\r
186 @param Name Supplies GUID name of the event.\r
187 @param NotifyTpl Supplies the task priority level of the event notifications.\r
188 @param NotifyFunction Supplies the function to notify when the event is signaled.\r
9095d37b 189 @param NotifyContext The context parameter to pass to NotifyFunction.\r
fb3df220 190 @param Registration A pointer to a memory location to receive the registration value.\r
191\r
192 @retval EFI_SUCCESS A named event was created.\r
af2dc6a7 193 @retval EFI_OUT_OF_RESOURCES There are not enough resources to create the named event.\r
fb3df220 194\r
195**/\r
196EFI_STATUS\r
197EFIAPI\r
198EfiNamedEventListen (\r
199 IN CONST EFI_GUID *Name,\r
200 IN EFI_TPL NotifyTpl,\r
201 IN EFI_EVENT_NOTIFY NotifyFunction,\r
202 IN CONST VOID *NotifyContext, OPTIONAL\r
203 OUT VOID *Registration OPTIONAL\r
204 );\r
205\r
206/**\r
1d37ab9f 207 Signals a named event created with EfiNamedEventListen().\r
208\r
209 This function signals the named event specified by Name. The named event must have been\r
210 created with EfiNamedEventListen().\r
211 If Name is NULL, then ASSERT().\r
fb3df220 212\r
af2dc6a7 213 @param Name Supplies the GUID name of the event.\r
fb3df220 214\r
215 @retval EFI_SUCCESS A named event was signaled.\r
af2dc6a7 216 @retval EFI_OUT_OF_RESOURCES There are not enough resources to signal the named event.\r
fb3df220 217\r
218**/\r
219EFI_STATUS\r
220EFIAPI\r
221EfiNamedEventSignal (\r
222 IN CONST EFI_GUID *Name\r
223 );\r
224\r
772fb7cb
LE
225/**\r
226 Signals an event group by placing a new event in the group temporarily and\r
227 signaling it.\r
228\r
229 @param[in] EventGroup Supplies the unique identifier of the event\r
230 group to signal.\r
231\r
232 @retval EFI_SUCCESS The event group was signaled successfully.\r
233 @retval EFI_INVALID_PARAMETER EventGroup is NULL.\r
234 @return Error codes that report problems about event\r
235 creation or signaling.\r
236**/\r
237EFI_STATUS\r
238EFIAPI\r
239EfiEventGroupSignal (\r
240 IN CONST EFI_GUID *EventGroup\r
241 );\r
242\r
1b197063
SZ
243/**\r
244 An empty function that can be used as NotifyFunction parameter of\r
245 CreateEvent() or CreateEventEx().\r
246\r
247 @param Event Event whose notification function is being invoked.\r
248 @param Context The pointer to the notification function's context,\r
249 which is implementation-dependent.\r
250\r
251**/\r
252VOID\r
253EFIAPI\r
254EfiEventEmptyFunction (\r
255 IN EFI_EVENT Event,\r
256 IN VOID *Context\r
257 );\r
258\r
9095d37b 259/**\r
fb3df220 260 Returns the current TPL.\r
261\r
9095d37b
LG
262 This function returns the current TPL. There is no EFI service to directly\r
263 retrieve the current TPL. Instead, the RaiseTPL() function is used to raise\r
264 the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level\r
265 can then immediately be restored back to the current TPL level with a call\r
fb3df220 266 to RestoreTPL().\r
267\r
01aef47b 268 @return The current TPL.\r
fb3df220 269\r
270**/\r
271EFI_TPL\r
272EFIAPI\r
273EfiGetCurrentTpl (\r
274 VOID\r
275 );\r
276\r
277/**\r
1d37ab9f 278 Initializes a basic mutual exclusion lock.\r
279\r
9095d37b
LG
280 This function initializes a basic mutual exclusion lock to the released state\r
281 and returns the lock. Each lock provides mutual exclusion access at its task\r
fb3df220 282 priority level. Since there is no preemption or multiprocessor support in EFI,\r
283 acquiring the lock only consists of raising to the locks TPL.\r
1d37ab9f 284 If Lock is NULL, then ASSERT().\r
285 If Priority is not a valid TPL value, then ASSERT().\r
fb3df220 286\r
287 @param Lock A pointer to the lock data structure to initialize.\r
af2dc6a7 288 @param Priority The EFI TPL associated with the lock.\r
fb3df220 289\r
290 @return The lock.\r
291\r
292**/\r
293EFI_LOCK *\r
294EFIAPI\r
295EfiInitializeLock (\r
296 IN OUT EFI_LOCK *Lock,\r
297 IN EFI_TPL Priority\r
298 );\r
299\r
300/**\r
cf8ae2f6 301 Initializes a basic mutual exclusion lock.\r
302\r
9095d37b
LG
303 This macro initializes the contents of a basic mutual exclusion lock to the\r
304 released state. Each lock provides mutual exclusion access at its task\r
fb3df220 305 priority level. Since there is no preemption or multiprocessor support in EFI,\r
306 acquiring the lock only consists of raising to the locks TPL.\r
307\r
fb3df220 308 @param Priority The task priority level of the lock.\r
309\r
310 @return The lock.\r
311\r
312**/\r
313#define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \\r
50615d1f 314 {Priority, TPL_APPLICATION, EfiLockReleased }\r
fb3df220 315\r
316\r
317/**\r
fb3df220 318 Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state.\r
319\r
9095d37b
LG
320 If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED\r
321 bit of PcdDebugProperyMask is set, then this macro evaluates the EFI_LOCK\r
5ee9264a 322 structure specified by Lock. If Lock is not in the locked state, then\r
9095d37b 323 DebugAssert() is called passing in the source filename, source line number,\r
5ee9264a 324 and Lock.\r
325\r
fb3df220 326 If Lock is NULL, then ASSERT().\r
327\r
328 @param LockParameter A pointer to the lock to acquire.\r
329\r
330**/\r
9095d37b 331#if !defined(MDEPKG_NDEBUG)\r
5ee9264a 332 #define ASSERT_LOCKED(LockParameter) \\r
333 do { \\r
334 if (DebugAssertEnabled ()) { \\r
335 ASSERT (LockParameter != NULL); \\r
336 if ((LockParameter)->Lock != EfiLockAcquired) { \\r
337 _ASSERT (LockParameter not locked); \\r
338 } \\r
339 } \\r
340 } while (FALSE)\r
341#else\r
342 #define ASSERT_LOCKED(LockParameter)\r
343#endif\r
fb3df220 344\r
345\r
346/**\r
1d37ab9f 347 Acquires ownership of a lock.\r
348\r
9095d37b
LG
349 This function raises the system's current task priority level to the task\r
350 priority level of the mutual exclusion lock. Then, it places the lock in the\r
fb3df220 351 acquired state.\r
1d37ab9f 352 If Lock is NULL, then ASSERT().\r
353 If Lock is not initialized, then ASSERT().\r
354 If Lock is already in the acquired state, then ASSERT().\r
fb3df220 355\r
01aef47b 356 @param Lock A pointer to the lock to acquire.\r
fb3df220 357\r
358**/\r
359VOID\r
360EFIAPI\r
361EfiAcquireLock (\r
362 IN EFI_LOCK *Lock\r
363 );\r
364\r
365/**\r
cf8ae2f6 366 Acquires ownership of a lock.\r
1d37ab9f 367\r
cf8ae2f6 368 This function raises the system's current task priority level to the task priority\r
369 level of the mutual exclusion lock. Then, it attempts to place the lock in the acquired state.\r
370 If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.\r
371 Otherwise, EFI_SUCCESS is returned.\r
1d37ab9f 372 If Lock is NULL, then ASSERT().\r
373 If Lock is not initialized, then ASSERT().\r
fb3df220 374\r
375 @param Lock A pointer to the lock to acquire.\r
376\r
377 @retval EFI_SUCCESS The lock was acquired.\r
378 @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.\r
379\r
380**/\r
381EFI_STATUS\r
382EFIAPI\r
383EfiAcquireLockOrFail (\r
384 IN EFI_LOCK *Lock\r
385 );\r
386\r
387/**\r
1d37ab9f 388 Releases ownership of a lock.\r
389\r
9095d37b
LG
390 This function transitions a mutual exclusion lock from the acquired state to\r
391 the released state, and restores the system's task priority level to its\r
fb3df220 392 previous level.\r
1d37ab9f 393 If Lock is NULL, then ASSERT().\r
394 If Lock is not initialized, then ASSERT().\r
395 If Lock is already in the released state, then ASSERT().\r
fb3df220 396\r
397 @param Lock A pointer to the lock to release.\r
398\r
399**/\r
400VOID\r
401EFIAPI\r
402EfiReleaseLock (\r
403 IN EFI_LOCK *Lock\r
404 );\r
405\r
0c9d7395 406/**\r
407 Tests whether a controller handle is being managed by a specific driver.\r
408\r
fb3df220 409 This function tests whether the driver specified by DriverBindingHandle is\r
410 currently managing the controller specified by ControllerHandle. This test\r
411 is performed by evaluating if the the protocol specified by ProtocolGuid is\r
412 present on ControllerHandle and is was opened by DriverBindingHandle with an\r
9095d37b 413 attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.\r
fb3df220 414 If ProtocolGuid is NULL, then ASSERT().\r
0c9d7395 415\r
416 @param ControllerHandle A handle for a controller to test.\r
417 @param DriverBindingHandle Specifies the driver binding handle for the\r
418 driver.\r
419 @param ProtocolGuid Specifies the protocol that the driver specified\r
420 by DriverBindingHandle opens in its Start()\r
421 function.\r
422\r
423 @retval EFI_SUCCESS ControllerHandle is managed by the driver\r
28d3e14f 424 specified by DriverBindingHandle.\r
0c9d7395 425 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver\r
28d3e14f 426 specified by DriverBindingHandle.\r
0c9d7395 427\r
fb3df220 428**/\r
429EFI_STATUS\r
430EFIAPI\r
431EfiTestManagedDevice (\r
432 IN CONST EFI_HANDLE ControllerHandle,\r
433 IN CONST EFI_HANDLE DriverBindingHandle,\r
434 IN CONST EFI_GUID *ProtocolGuid\r
435 );\r
436\r
0c9d7395 437/**\r
438 Tests whether a child handle is a child device of the controller.\r
439\r
fb3df220 440 This function tests whether ChildHandle is one of the children of\r
441 ControllerHandle. This test is performed by checking to see if the protocol\r
442 specified by ProtocolGuid is present on ControllerHandle and opened by\r
443 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
444 If ProtocolGuid is NULL, then ASSERT().\r
0c9d7395 445\r
9095d37b 446 @param ControllerHandle A handle for a (parent) controller to test.\r
0c9d7395 447 @param ChildHandle A child handle to test.\r
01aef47b 448 @param ProtocolGuid Supplies the protocol that the child controller\r
9095d37b 449 opens on its parent controller.\r
0c9d7395 450\r
451 @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle.\r
452 @retval EFI_UNSUPPORTED ChildHandle is not a child of the\r
453 ControllerHandle.\r
454\r
fb3df220 455**/\r
456EFI_STATUS\r
457EFIAPI\r
458EfiTestChildHandle (\r
459 IN CONST EFI_HANDLE ControllerHandle,\r
460 IN CONST EFI_HANDLE ChildHandle,\r
461 IN CONST EFI_GUID *ProtocolGuid\r
462 );\r
463\r
ea331a5c
TZ
464/**\r
465 * This function checks the supported languages list for a target language,\r
466 * This only supports RFC 4646 Languages.\r
467 *\r
468 * @param SupportedLanguages The supported languages\r
469 * @param TargetLanguage The target language\r
470 *\r
471 * @return Returns EFI_SUCCESS if the language is supported,\r
472 * EFI_UNSUPPORTED otherwise\r
473 */\r
474EFI_STATUS\r
475EFIAPI\r
476IsLanguageSupported (\r
477 IN CONST CHAR8 *SupportedLanguages,\r
478 IN CONST CHAR8 *TargetLanguage\r
479 );\r
480\r
fb3df220 481/**\r
1d37ab9f 482 This function looks up a Unicode string in UnicodeStringTable.\r
483\r
cf8ae2f6 484 If Language is a member of SupportedLanguages and a Unicode string is found in\r
1d37ab9f 485 UnicodeStringTable that matches the language code specified by Language, then it\r
486 is returned in UnicodeString.\r
fb3df220 487\r
9095d37b 488 @param Language A pointer to the ISO 639-2 language code for the\r
fb3df220 489 Unicode string to look up and return.\r
9095d37b
LG
490 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes\r
491 that the Unicode string table supports. Language\r
fb3df220 492 must be a member of this set.\r
493 @param UnicodeStringTable A pointer to the table of Unicode strings.\r
494 @param UnicodeString A pointer to the Unicode string from UnicodeStringTable\r
495 that matches the language specified by Language.\r
496\r
9095d37b 497 @retval EFI_SUCCESS The Unicode string that matches the language\r
fb3df220 498 specified by Language was found\r
9095d37b 499 in the table of Unicode strings UnicodeStringTable,\r
fb3df220 500 and it was returned in UnicodeString.\r
501 @retval EFI_INVALID_PARAMETER Language is NULL.\r
502 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
503 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
504 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.\r
9095d37b 505 @retval EFI_UNSUPPORTED The language specified by Language is not a\r
fb3df220 506 member of SupportedLanguages.\r
9095d37b 507 @retval EFI_UNSUPPORTED The language specified by Language is not\r
fb3df220 508 supported by UnicodeStringTable.\r
509\r
510**/\r
511EFI_STATUS\r
512EFIAPI\r
513LookupUnicodeString (\r
514 IN CONST CHAR8 *Language,\r
515 IN CONST CHAR8 *SupportedLanguages,\r
516 IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,\r
517 OUT CHAR16 **UnicodeString\r
518 );\r
519\r
a73480f6 520/**\r
521 This function looks up a Unicode string in UnicodeStringTable.\r
1d37ab9f 522\r
cf8ae2f6 523 If Language is a member of SupportedLanguages and a Unicode string is found in\r
524 UnicodeStringTable that matches the language code specified by Language, then\r
525 it is returned in UnicodeString.\r
526\r
527 @param Language A pointer to an ASCII string containing the ISO 639-2 or the\r
528 RFC 4646 language code for the Unicode string to look up and\r
529 return. If Iso639Language is TRUE, then this ASCII string is\r
530 not assumed to be Null-terminated, and only the first three\r
28d3e14f 531 characters are used. If Iso639Language is FALSE, then this ASCII\r
9095d37b 532 string must be Null-terminated.\r
cf8ae2f6 533 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains a\r
534 set of ISO 639-2 or RFC 4646 language codes that the Unicode\r
535 string table supports. Language must be a member of this set.\r
536 If Iso639Language is TRUE, then this string contains one or more\r
537 ISO 639-2 language codes with no separator characters. If Iso639Language\r
538 is FALSE, then is string contains one or more RFC 4646 language\r
539 codes separated by ';'.\r
540 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE\r
541 is defined in "Related Definitions".\r
542 @param UnicodeString A pointer to the Null-terminated Unicode string from UnicodeStringTable\r
543 that matches the language specified by Language.\r
544 @param Iso639Language Specifies the supported language code format. If it is TRUE, then\r
545 Language and SupportedLanguages follow ISO 639-2 language code format.\r
af2dc6a7 546 Otherwise, they follow the RFC 4646 language code format.\r
cf8ae2f6 547\r
548\r
549 @retval EFI_SUCCESS The Unicode string that matches the language specified by Language\r
550 was found in the table of Unicode strings UnicodeStringTable, and\r
551 it was returned in UnicodeString.\r
9095d37b
LG
552 @retval EFI_INVALID_PARAMETER Language is NULL.\r
553 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
554 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
555 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.\r
556 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.\r
cf8ae2f6 557 @retval EFI_UNSUPPORTED The language specified by Language is not supported by UnicodeStringTable.\r
a73480f6 558\r
559**/\r
560EFI_STATUS\r
561EFIAPI\r
562LookupUnicodeString2 (\r
563 IN CONST CHAR8 *Language,\r
564 IN CONST CHAR8 *SupportedLanguages,\r
565 IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,\r
566 OUT CHAR16 **UnicodeString,\r
567 IN BOOLEAN Iso639Language\r
ed66e1bc 568 );\r
a73480f6 569\r
fb3df220 570/**\r
571 This function adds a Unicode string to UnicodeStringTable.\r
1d37ab9f 572\r
9095d37b
LG
573 If Language is a member of SupportedLanguages then UnicodeString is added to\r
574 UnicodeStringTable. New buffers are allocated for both Language and\r
575 UnicodeString. The contents of Language and UnicodeString are copied into\r
576 these new buffers. These buffers are automatically freed when\r
fb3df220 577 FreeUnicodeStringTable() is called.\r
578\r
9095d37b 579 @param Language A pointer to the ISO 639-2 language code for the Unicode\r
fb3df220 580 string to add.\r
581 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes\r
582 that the Unicode string table supports.\r
583 Language must be a member of this set.\r
584 @param UnicodeStringTable A pointer to the table of Unicode strings.\r
585 @param UnicodeString A pointer to the Unicode string to add.\r
586\r
9095d37b
LG
587 @retval EFI_SUCCESS The Unicode string that matches the language\r
588 specified by Language was found in the table of\r
589 Unicode strings UnicodeStringTable, and it was\r
fb3df220 590 returned in UnicodeString.\r
591 @retval EFI_INVALID_PARAMETER Language is NULL.\r
592 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
593 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.\r
594 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
9095d37b 595 @retval EFI_ALREADY_STARTED A Unicode string with language Language is\r
fb3df220 596 already present in UnicodeStringTable.\r
9095d37b 597 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another\r
fb3df220 598 Unicode string to UnicodeStringTable.\r
9095d37b 599 @retval EFI_UNSUPPORTED The language specified by Language is not a\r
fb3df220 600 member of SupportedLanguages.\r
601\r
602**/\r
603EFI_STATUS\r
604EFIAPI\r
605AddUnicodeString (\r
5b9626e8
MH
606 IN CONST CHAR8 *Language,\r
607 IN CONST CHAR8 *SupportedLanguages,\r
608 IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable,\r
609 IN CONST CHAR16 *UnicodeString\r
fb3df220 610 );\r
611\r
a73480f6 612/**\r
cf8ae2f6 613 This function adds the Null-terminated Unicode string specified by UnicodeString\r
614 to UnicodeStringTable.\r
615\r
616 If Language is a member of SupportedLanguages then UnicodeString is added to\r
617 UnicodeStringTable. New buffers are allocated for both Language and UnicodeString.\r
618 The contents of Language and UnicodeString are copied into these new buffers.\r
619 These buffers are automatically freed when EfiLibFreeUnicodeStringTable() is called.\r
620\r
621 @param Language A pointer to an ASCII string containing the ISO 639-2 or\r
622 the RFC 4646 language code for the Unicode string to add.\r
623 If Iso639Language is TRUE, then this ASCII string is not\r
624 assumed to be Null-terminated, and only the first three\r
625 chacters are used. If Iso639Language is FALSE, then this\r
626 ASCII string must be Null-terminated.\r
627 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains\r
628 a set of ISO 639-2 or RFC 4646 language codes that the Unicode\r
629 string table supports. Language must be a member of this set.\r
630 If Iso639Language is TRUE, then this string contains one or more\r
631 ISO 639-2 language codes with no separator characters.\r
632 If Iso639Language is FALSE, then is string contains one or more\r
633 RFC 4646 language codes separated by ';'.\r
634 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE\r
635 is defined in "Related Definitions".\r
9095d37b 636 @param UnicodeString A pointer to the Unicode string to add.\r
cf8ae2f6 637 @param Iso639Language Specifies the supported language code format. If it is TRUE,\r
638 then Language and SupportedLanguages follow ISO 639-2 language code format.\r
639 Otherwise, they follow RFC 4646 language code format.\r
640\r
641 @retval EFI_SUCCESS The Unicode string that matches the language specified by\r
642 Language was found in the table of Unicode strings UnicodeStringTable,\r
9095d37b
LG
643 and it was returned in UnicodeString.\r
644 @retval EFI_INVALID_PARAMETER Language is NULL.\r
645 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
646 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.\r
647 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
cf8ae2f6 648 @retval EFI_ALREADY_STARTED A Unicode string with language Language is already present in\r
9095d37b
LG
649 UnicodeStringTable.\r
650 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another Unicode string UnicodeStringTable.\r
cf8ae2f6 651 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.\r
a73480f6 652\r
653**/\r
654EFI_STATUS\r
655EFIAPI\r
656AddUnicodeString2 (\r
5b9626e8
MH
657 IN CONST CHAR8 *Language,\r
658 IN CONST CHAR8 *SupportedLanguages,\r
659 IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable,\r
660 IN CONST CHAR16 *UnicodeString,\r
661 IN BOOLEAN Iso639Language\r
ed66e1bc 662 );\r
a73480f6 663\r
fb3df220 664/**\r
665 This function frees the table of Unicode strings in UnicodeStringTable.\r
1d37ab9f 666\r
fb3df220 667 If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.\r
9095d37b 668 Otherwise, each language code, and each Unicode string in the Unicode string\r
fb3df220 669 table are freed, and EFI_SUCCESS is returned.\r
670\r
671 @param UnicodeStringTable A pointer to the table of Unicode strings.\r
672\r
673 @retval EFI_SUCCESS The Unicode string table was freed.\r
674\r
675**/\r
676EFI_STATUS\r
677EFIAPI\r
678FreeUnicodeStringTable (\r
679 IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable\r
680 );\r
681\r
bf4a3dbd 682#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
6d28c497 683\r
684/**\r
bf4a3dbd
ED
685 [ATTENTION] This function will be deprecated for security reason.\r
686\r
9095d37b
LG
687 Returns a pointer to an allocated buffer that contains the contents of a\r
688 variable retrieved through the UEFI Runtime Service GetVariable(). The\r
6d28c497 689 returned buffer is allocated using AllocatePool(). The caller is responsible\r
690 for freeing this buffer with FreePool().\r
691\r
692 If Name is NULL, then ASSERT().\r
693 If Guid is NULL, then ASSERT().\r
694\r
af2dc6a7 695 @param[in] Name The pointer to a Null-terminated Unicode string.\r
696 @param[in] Guid The pointer to an EFI_GUID structure.\r
6d28c497 697\r
698 @retval NULL The variable could not be retrieved.\r
699 @retval NULL There are not enough resources available for the variable contents.\r
700 @retval Other A pointer to allocated buffer containing the variable contents.\r
701\r
702**/\r
703VOID *\r
704EFIAPI\r
705GetVariable (\r
706 IN CONST CHAR16 *Name,\r
707 IN CONST EFI_GUID *Guid\r
708 );\r
709\r
710/**\r
bf4a3dbd
ED
711 [ATTENTION] This function will be deprecated for security reason.\r
712\r
9095d37b
LG
713 Returns a pointer to an allocated buffer that contains the contents of a\r
714 variable retrieved through the UEFI Runtime Service GetVariable(). This\r
6d28c497 715 function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables.\r
9095d37b 716 The returned buffer is allocated using AllocatePool(). The caller is\r
6d28c497 717 responsible for freeing this buffer with FreePool().\r
718\r
719 If Name is NULL, then ASSERT().\r
720\r
af2dc6a7 721 @param[in] Name The pointer to a Null-terminated Unicode string.\r
6d28c497 722\r
723 @retval NULL The variable could not be retrieved.\r
724 @retval NULL There are not enough resources available for the variable contents.\r
725 @retval Other A pointer to allocated buffer containing the variable contents.\r
726\r
727**/\r
728VOID *\r
729EFIAPI\r
730GetEfiGlobalVariable (\r
731 IN CONST CHAR16 *Name\r
732 );\r
bf4a3dbd
ED
733#endif\r
734\r
735\r
736/**\r
9095d37b
LG
737 Returns the status whether get the variable success. The function retrieves\r
738 variable through the UEFI Runtime Service GetVariable(). The\r
bf4a3dbd
ED
739 returned buffer is allocated using AllocatePool(). The caller is responsible\r
740 for freeing this buffer with FreePool().\r
741\r
742 If Name is NULL, then ASSERT().\r
743 If Guid is NULL, then ASSERT().\r
744 If Value is NULL, then ASSERT().\r
745\r
746 @param[in] Name The pointer to a Null-terminated Unicode string.\r
747 @param[in] Guid The pointer to an EFI_GUID structure\r
748 @param[out] Value The buffer point saved the variable info.\r
749 @param[out] Size The buffer size of the variable.\r
750\r
37bf6787
BB
751 @retval EFI_OUT_OF_RESOURCES Allocate buffer failed.\r
752 @retval EFI_SUCCESS Find the specified variable.\r
753 @retval Others Errors Return errors from call to gRT->GetVariable.\r
bf4a3dbd
ED
754\r
755**/\r
756EFI_STATUS\r
757EFIAPI\r
758GetVariable2 (\r
759 IN CONST CHAR16 *Name,\r
760 IN CONST EFI_GUID *Guid,\r
761 OUT VOID **Value,\r
762 OUT UINTN *Size OPTIONAL\r
763 );\r
764\r
765/**\r
9095d37b
LG
766 Returns a pointer to an allocated buffer that contains the contents of a\r
767 variable retrieved through the UEFI Runtime Service GetVariable(). This\r
bf4a3dbd 768 function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables.\r
9095d37b 769 The returned buffer is allocated using AllocatePool(). The caller is\r
bf4a3dbd
ED
770 responsible for freeing this buffer with FreePool().\r
771\r
772 If Name is NULL, then ASSERT().\r
773 If Value is NULL, then ASSERT().\r
6d28c497 774\r
bf4a3dbd
ED
775 @param[in] Name The pointer to a Null-terminated Unicode string.\r
776 @param[out] Value The buffer point saved the variable info.\r
777 @param[out] Size The buffer size of the variable.\r
778\r
37bf6787
BB
779 @retval EFI_OUT_OF_RESOURCES Allocate buffer failed.\r
780 @retval EFI_SUCCESS Find the specified variable.\r
781 @retval Others Errors Return errors from call to gRT->GetVariable.\r
bf4a3dbd
ED
782\r
783**/\r
784EFI_STATUS\r
785EFIAPI\r
786GetEfiGlobalVariable2 (\r
787 IN CONST CHAR16 *Name,\r
788 OUT VOID **Value,\r
789 OUT UINTN *Size OPTIONAL\r
790 );\r
6d28c497 791\r
37bf6787
BB
792/** Return the attributes of the variable.\r
793\r
794 Returns the status whether get the variable success. The function retrieves\r
795 variable through the UEFI Runtime Service GetVariable(). The\r
796 returned buffer is allocated using AllocatePool(). The caller is responsible\r
797 for freeing this buffer with FreePool(). The attributes are returned if\r
798 the caller provides a valid Attribute parameter.\r
799\r
800 If Name is NULL, then ASSERT().\r
801 If Guid is NULL, then ASSERT().\r
802 If Value is NULL, then ASSERT().\r
803\r
804 @param[in] Name The pointer to a Null-terminated Unicode string.\r
805 @param[in] Guid The pointer to an EFI_GUID structure\r
806 @param[out] Value The buffer point saved the variable info.\r
807 @param[out] Size The buffer size of the variable.\r
808 @param[out] Attr The pointer to the variable attributes as found in var store\r
809\r
810 @retval EFI_OUT_OF_RESOURCES Allocate buffer failed.\r
811 @retval EFI_SUCCESS Find the specified variable.\r
812 @retval Others Errors Return errors from call to gRT->GetVariable.\r
813\r
814**/\r
815EFI_STATUS\r
816EFIAPI\r
817GetVariable3(\r
818 IN CONST CHAR16 *Name,\r
819 IN CONST EFI_GUID *Guid,\r
820 OUT VOID **Value,\r
821 OUT UINTN *Size OPTIONAL,\r
822 OUT UINT32 *Attr OPTIONAL\r
823 );\r
824\r
6d28c497 825/**\r
9095d37b
LG
826 Returns a pointer to an allocated buffer that contains the best matching language\r
827 from a set of supported languages.\r
828\r
829 This function supports both ISO 639-2 and RFC 4646 language codes, but language\r
830 code types may not be mixed in a single call to this function. The language\r
831 code returned is allocated using AllocatePool(). The caller is responsible for\r
6d28c497 832 freeing the allocated buffer using FreePool(). This function supports a variable\r
9095d37b
LG
833 argument list that allows the caller to pass in a prioritized list of language\r
834 codes to test against all the language codes in SupportedLanguages.\r
6d28c497 835\r
836 If SupportedLanguages is NULL, then ASSERT().\r
837\r
838 @param[in] SupportedLanguages A pointer to a Null-terminated ASCII string that\r
9095d37b 839 contains a set of language codes in the format\r
6d28c497 840 specified by Iso639Language.\r
3d7c6cfb
LG
841 @param[in] Iso639Language If not zero, then all language codes are assumed to be\r
842 in ISO 639-2 format. If zero, then all language\r
6d28c497 843 codes are assumed to be in RFC 4646 language format\r
9095d37b 844 @param[in] ... A variable argument list that contains pointers to\r
6d28c497 845 Null-terminated ASCII strings that contain one or more\r
846 language codes in the format specified by Iso639Language.\r
847 The first language code from each of these language\r
848 code lists is used to determine if it is an exact or\r
9095d37b 849 close match to any of the language codes in\r
6d28c497 850 SupportedLanguages. Close matches only apply to RFC 4646\r
851 language codes, and the matching algorithm from RFC 4647\r
9095d37b 852 is used to determine if a close match is present. If\r
6d28c497 853 an exact or close match is found, then the matching\r
854 language code from SupportedLanguages is returned. If\r
855 no matches are found, then the next variable argument\r
9095d37b 856 parameter is evaluated. The variable argument list\r
6d28c497 857 is terminated by a NULL.\r
858\r
859 @retval NULL The best matching language could not be found in SupportedLanguages.\r
9095d37b 860 @retval NULL There are not enough resources available to return the best matching\r
6d28c497 861 language.\r
9095d37b 862 @retval Other A pointer to a Null-terminated ASCII string that is the best matching\r
6d28c497 863 language in SupportedLanguages.\r
864\r
865**/\r
866CHAR8 *\r
867EFIAPI\r
868GetBestLanguage (\r
9095d37b 869 IN CONST CHAR8 *SupportedLanguages,\r
d2aafe1e 870 IN UINTN Iso639Language,\r
6d28c497 871 ...\r
872 );\r
873\r
db2ef756 874/**\r
9095d37b 875 Draws a dialog box to the console output device specified by\r
db2ef756 876 ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke\r
9095d37b 877 from the console input device specified by ConIn defined in the\r
db2ef756
LG
878 EFI_SYSTEM_TABLE.\r
879\r
880 If there are no strings in the variable argument list, then ASSERT().\r
881 If all the strings in the variable argument list are empty, then ASSERT().\r
882\r
883 @param[in] Attribute Specifies the foreground and background color of the popup.\r
9095d37b 884 @param[out] Key A pointer to the EFI_KEY value of the key that was\r
db2ef756
LG
885 pressed. This is an optional parameter that may be NULL.\r
886 If it is NULL then no wait for a keypress will be performed.\r
887 @param[in] ... The variable argument list that contains pointers to Null-\r
9095d37b 888 terminated Unicode strings to display in the dialog box.\r
db2ef756
LG
889 The variable argument list is terminated by a NULL.\r
890\r
891**/\r
892VOID\r
893EFIAPI\r
894CreatePopUp (\r
9095d37b 895 IN UINTN Attribute,\r
db2ef756
LG
896 OUT EFI_INPUT_KEY *Key, OPTIONAL\r
897 ...\r
898 );\r
6d28c497 899\r
fb3df220 900/**\r
cf8ae2f6 901 Retrieves the width of a Unicode character.\r
902\r
903 This function computes and returns the width of the Unicode character specified\r
904 by UnicodeChar.\r
fb3df220 905\r
906 @param UnicodeChar A Unicode character.\r
907\r
908 @retval 0 The width if UnicodeChar could not be determined.\r
909 @retval 1 UnicodeChar is a narrow glyph.\r
910 @retval 2 UnicodeChar is a wide glyph.\r
911\r
912**/\r
913UINTN\r
914EFIAPI\r
915GetGlyphWidth (\r
916 IN CHAR16 UnicodeChar\r
917 );\r
918\r
919/**\r
1d37ab9f 920 Computes the display length of a Null-terminated Unicode String.\r
921\r
cf8ae2f6 922 This function computes and returns the display length of the Null-terminated Unicode\r
923 string specified by String. If String is NULL then 0 is returned. If any of the widths\r
924 of the Unicode characters in String can not be determined, then 0 is returned. The display\r
925 width of String can be computed by summing the display widths of each Unicode character\r
926 in String. Unicode characters that are narrow glyphs have a width of 1, and Unicode\r
9095d37b 927 characters that are width glyphs have a width of 2.\r
cf8ae2f6 928 If String is not aligned on a 16-bit boundary, then ASSERT().\r
fb3df220 929\r
930 @param String A pointer to a Null-terminated Unicode string.\r
931\r
932 @return The display length of the Null-terminated Unicode string specified by String.\r
9095d37b 933\r
fb3df220 934**/\r
935UINTN\r
936EFIAPI\r
937UnicodeStringDisplayLength (\r
938 IN CONST CHAR16 *String\r
939 );\r
940\r
941//\r
942// Functions that abstract early Framework contamination of UEFI.\r
943//\r
944/**\r
1d37ab9f 945 Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().\r
9095d37b 946\r
1d37ab9f 947 This function abstracts the signaling of the Ready to Boot Event. The Framework moved\r
cf8ae2f6 948 from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller\r
949 from how this event is created to prevent to code form having to change with the\r
950 version of the specification supported.\r
fb3df220 951\r
952**/\r
953VOID\r
954EFIAPI\r
955EfiSignalEventReadyToBoot (\r
956 VOID\r
957 );\r
958\r
959/**\r
1d37ab9f 960 Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().\r
961\r
962 This function abstracts the signaling of the Legacy Boot Event. The Framework moved from\r
963 a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how\r
964 this event is created to prevent to code form having to change with the version of the\r
965 specification supported.\r
fb3df220 966\r
967**/\r
968VOID\r
969EFIAPI\r
970EfiSignalEventLegacyBoot (\r
971 VOID\r
972 );\r
973\r
974/**\r
cf8ae2f6 975 Creates an EFI event in the Legacy Boot Event Group.\r
976\r
977 Prior to UEFI 2.0 this was done via a non blessed UEFI extensions and this library\r
978 abstracts the implementation mechanism of this event from the caller. This function\r
979 abstracts the creation of the Legacy Boot Event. The Framework moved from a proprietary\r
980 to UEFI 2.0 based mechanism. This library abstracts the caller from how this event\r
981 is created to prevent to code form having to change with the version of the\r
982 specification supported.\r
7f1eba7b 983 If LegacyBootEvent is NULL, then ASSERT().\r
fb3df220 984\r
985 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
986\r
af2dc6a7 987 @retval EFI_SUCCESS The event was created.\r
988 @retval Other The event was not created.\r
fb3df220 989\r
990**/\r
991EFI_STATUS\r
992EFIAPI\r
993EfiCreateEventLegacyBoot (\r
994 OUT EFI_EVENT *LegacyBootEvent\r
995 );\r
996\r
997/**\r
998 Create an EFI event in the Legacy Boot Event Group and allows\r
9095d37b
LG
999 the caller to specify a notification function.\r
1000\r
fb3df220 1001 This function abstracts the creation of the Legacy Boot Event.\r
1002 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
1003 This library abstracts the caller from how this event is created to prevent\r
1004 to code form having to change with the version of the specification supported.\r
1005 If LegacyBootEvent is NULL, then ASSERT().\r
1006\r
1007 @param NotifyTpl The task priority level of the event.\r
1008 @param NotifyFunction The notification function to call when the event is signaled.\r
1009 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
1010 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
1011\r
af2dc6a7 1012 @retval EFI_SUCCESS The event was created.\r
1013 @retval Other The event was not created.\r
fb3df220 1014\r
1015**/\r
1016EFI_STATUS\r
1017EFIAPI\r
1018EfiCreateEventLegacyBootEx (\r
1019 IN EFI_TPL NotifyTpl,\r
1020 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
1021 IN VOID *NotifyContext, OPTIONAL\r
1022 OUT EFI_EVENT *LegacyBootEvent\r
1023 );\r
1024\r
1025/**\r
cf8ae2f6 1026 Create an EFI event in the Ready To Boot Event Group.\r
1027\r
1028 Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library\r
9095d37b
LG
1029 abstracts the implementation mechanism of this event from the caller.\r
1030 This function abstracts the creation of the Ready to Boot Event. The Framework\r
1031 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts\r
1032 the caller from how this event is created to prevent the code form having to\r
7f1eba7b 1033 change with the version of the specification supported.\r
1034 If ReadyToBootEvent is NULL, then ASSERT().\r
fb3df220 1035\r
01aef47b 1036 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
fb3df220 1037\r
af2dc6a7 1038 @retval EFI_SUCCESS The event was created.\r
1039 @retval Other The event was not created.\r
fb3df220 1040\r
1041**/\r
1042EFI_STATUS\r
1043EFIAPI\r
1044EfiCreateEventReadyToBoot (\r
1045 OUT EFI_EVENT *ReadyToBootEvent\r
1046 );\r
1047\r
1048/**\r
1049 Create an EFI event in the Ready To Boot Event Group and allows\r
9095d37b
LG
1050 the caller to specify a notification function.\r
1051\r
fb3df220 1052 This function abstracts the creation of the Ready to Boot Event.\r
1053 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
1054 This library abstracts the caller from how this event is created to prevent\r
1055 to code form having to change with the version of the specification supported.\r
1056 If ReadyToBootEvent is NULL, then ASSERT().\r
1057\r
1058 @param NotifyTpl The task priority level of the event.\r
1059 @param NotifyFunction The notification function to call when the event is signaled.\r
1060 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
01aef47b 1061 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
fb3df220 1062\r
af2dc6a7 1063 @retval EFI_SUCCESS The event was created.\r
1064 @retval Other The event was not created.\r
fb3df220 1065\r
1066**/\r
1067EFI_STATUS\r
1068EFIAPI\r
1069EfiCreateEventReadyToBootEx (\r
1070 IN EFI_TPL NotifyTpl,\r
1071 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
1072 IN VOID *NotifyContext, OPTIONAL\r
1073 OUT EFI_EVENT *ReadyToBootEvent\r
1074 );\r
1075\r
1076/**\r
1077 Initialize a Firmware Volume (FV) Media Device Path node.\r
9095d37b
LG
1078\r
1079 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.\r
1080 This library function abstracts initializing a device path node.\r
1081 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device\r
1082 path changed in the DXE CIS version 0.92 in a non back ward compatible way to\r
1083 not conflict with the UEFI 2.0 specification. This function abstracts the\r
7f1eba7b 1084 differences from the caller.\r
7f1eba7b 1085 If FvDevicePathNode is NULL, then ASSERT().\r
1086 If NameGuid is NULL, then ASSERT().\r
9095d37b 1087\r
af2dc6a7 1088 @param FvDevicePathNode The pointer to a FV device path node to initialize\r
fb3df220 1089 @param NameGuid FV file name to use in FvDevicePathNode\r
1090\r
1091**/\r
1092VOID\r
1093EFIAPI\r
1094EfiInitializeFwVolDevicepathNode (\r
1095 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r
1096 IN CONST EFI_GUID *NameGuid\r
1097 );\r
1098\r
1099/**\r
9095d37b
LG
1100 Check to see if the Firmware Volume (FV) Media Device Path is valid\r
1101\r
1102 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.\r
7f1eba7b 1103 This library function abstracts validating a device path node.\r
9095d37b
LG
1104 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.\r
1105 If it is valid, then return the GUID file name from the device path node. Otherwise,\r
1106 return NULL. This device path changed in the DXE CIS version 0.92 in a non backward\r
1107 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts\r
7f1eba7b 1108 the differences from the caller.\r
1109 If FvDevicePathNode is NULL, then ASSERT().\r
fb3df220 1110\r
af2dc6a7 1111 @param FvDevicePathNode The pointer to FV device path to check.\r
fb3df220 1112\r
1113 @retval NULL FvDevicePathNode is not valid.\r
1114 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r
1115\r
1116**/\r
1117EFI_GUID *\r
1118EFIAPI\r
1119EfiGetNameGuidFromFwVolDevicePathNode (\r
1120 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r
1121 );\r
1122\r
9095d37b
LG
1123/**\r
1124 Prints a formatted Unicode string to the console output device specified by\r
fb3df220 1125 ConOut defined in the EFI_SYSTEM_TABLE.\r
1126\r
9095d37b
LG
1127 This function prints a formatted Unicode string to the console output device\r
1128 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode\r
1129 characters that printed to ConOut. If the length of the formatted Unicode\r
1130 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
fb3df220 1131 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
1d37ab9f 1132 If Format is NULL, then ASSERT().\r
1133 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
cda8ba5e 1134 If gST->ConOut is NULL, then ASSERT().\r
fb3df220 1135\r
af2dc6a7 1136 @param Format A null-terminated Unicode format string.\r
9095d37b 1137 @param ... The variable argument list whose contents are accessed based\r
285010e7 1138 on the format string specified by Format.\r
9095d37b 1139\r
9199040c 1140 @return Number of Unicode characters printed to ConOut.\r
fb3df220 1141\r
1142**/\r
1143UINTN\r
1144EFIAPI\r
1145Print (\r
1146 IN CONST CHAR16 *Format,\r
1147 ...\r
1148 );\r
1149\r
9095d37b
LG
1150/**\r
1151 Prints a formatted Unicode string to the console output device specified by\r
fb3df220 1152 StdErr defined in the EFI_SYSTEM_TABLE.\r
1153\r
9095d37b
LG
1154 This function prints a formatted Unicode string to the console output device\r
1155 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode\r
1156 characters that printed to StdErr. If the length of the formatted Unicode\r
1157 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
fb3df220 1158 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
1d37ab9f 1159 If Format is NULL, then ASSERT().\r
1160 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
cda8ba5e 1161 If gST->StdErr is NULL, then ASSERT().\r
fb3df220 1162\r
af2dc6a7 1163 @param Format A null-terminated Unicode format string.\r
9095d37b 1164 @param ... The variable argument list whose contents are accessed based\r
285010e7 1165 on the format string specified by Format.\r
9095d37b 1166\r
9199040c 1167 @return Number of Unicode characters printed to StdErr.\r
fb3df220 1168\r
1169**/\r
1170UINTN\r
1171EFIAPI\r
1172ErrorPrint (\r
1173 IN CONST CHAR16 *Format,\r
1174 ...\r
1175 );\r
1176\r
9095d37b
LG
1177/**\r
1178 Prints a formatted ASCII string to the console output device specified by\r
fb3df220 1179 ConOut defined in the EFI_SYSTEM_TABLE.\r
1180\r
9095d37b
LG
1181 This function prints a formatted ASCII string to the console output device\r
1182 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII\r
1183 characters that printed to ConOut. If the length of the formatted ASCII\r
1184 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
fb3df220 1185 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
1d37ab9f 1186 If Format is NULL, then ASSERT().\r
cda8ba5e 1187 If gST->ConOut is NULL, then ASSERT().\r
fb3df220 1188\r
af2dc6a7 1189 @param Format A null-terminated ASCII format string.\r
9095d37b 1190 @param ... The variable argument list whose contents are accessed based\r
285010e7 1191 on the format string specified by Format.\r
9095d37b 1192\r
9199040c 1193 @return Number of ASCII characters printed to ConOut.\r
fb3df220 1194\r
1195**/\r
1196UINTN\r
1197EFIAPI\r
1198AsciiPrint (\r
1199 IN CONST CHAR8 *Format,\r
1200 ...\r
1201 );\r
1202\r
9095d37b
LG
1203/**\r
1204 Prints a formatted ASCII string to the console output device specified by\r
fb3df220 1205 StdErr defined in the EFI_SYSTEM_TABLE.\r
1206\r
9095d37b
LG
1207 This function prints a formatted ASCII string to the console output device\r
1208 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII\r
1209 characters that printed to StdErr. If the length of the formatted ASCII\r
1210 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
fb3df220 1211 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
1d37ab9f 1212 If Format is NULL, then ASSERT().\r
cda8ba5e 1213 If gST->StdErr is NULL, then ASSERT().\r
fb3df220 1214\r
af2dc6a7 1215 @param Format A null-terminated ASCII format string.\r
9095d37b 1216 @param ... The variable argument list whose contents are accessed based\r
285010e7 1217 on the format string specified by Format.\r
9095d37b 1218\r
9199040c 1219 @return Number of ASCII characters printed to ConErr.\r
fb3df220 1220\r
1221**/\r
1222UINTN\r
1223EFIAPI\r
1224AsciiErrorPrint (\r
1225 IN CONST CHAR8 *Format,\r
1226 ...\r
1227 );\r
1228\r
51969ecb 1229\r
b3154720 1230/**\r
9095d37b 1231 Prints a formatted Unicode string to a graphics console device specified by\r
b3154720 1232 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.\r
1233\r
9095d37b
LG
1234 This function prints a formatted Unicode string to the graphics console device\r
1235 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of\r
1236 Unicode characters displayed, not including partial characters that may be clipped\r
b9c8d8bd 1237 by the right edge of the display. If the length of the formatted Unicode string is\r
9095d37b 1238 greater than PcdUefiLibMaxPrintBufferSize, then at most the first\r
1a2f870c 1239 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL\r
9095d37b 1240 is used to convert the string to a bitmap using the glyphs registered with the\r
1a2f870c 1241 HII database. No wrapping is performed, so any portions of the string the fall\r
1242 outside the active display region will not be displayed.\r
b3154720 1243\r
9095d37b 1244 If a graphics console device is not associated with the ConsoleOutputHandle\r
b3154720 1245 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.\r
9095d37b 1246 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no\r
b3154720 1247 string is printed, and 0 is returned.\r
1248 If Format is NULL, then ASSERT().\r
1249 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
cda8ba5e 1250 If gST->ConsoleOutputHandle is NULL, then ASSERT().\r
b3154720 1251\r
51969ecb 1252 @param PointX X coordinate to print the string.\r
1253 @param PointY Y coordinate to print the string.\r
28d3e14f 1254 @param ForeGround The foreground color of the string being printed. This is\r
b3154720 1255 an optional parameter that may be NULL. If it is NULL,\r
1256 then the foreground color of the current ConOut device\r
1257 in the EFI_SYSTEM_TABLE is used.\r
1258 @param BackGround The background color of the string being printed. This is\r
9095d37b 1259 an optional parameter that may be NULL. If it is NULL,\r
b3154720 1260 then the background color of the current ConOut device\r
1261 in the EFI_SYSTEM_TABLE is used.\r
9095d37b 1262 @param Format A null-terminated Unicode format string. See Print Library\r
b3154720 1263 for the supported format string syntax.\r
9095d37b
LG
1264 @param ... Variable argument list whose contents are accessed based on\r
1265 the format string specified by Format.\r
b3154720 1266\r
1267 @return The number of Unicode characters printed.\r
1268\r
1269**/\r
1270UINTN\r
1271EFIAPI\r
1272PrintXY (\r
51969ecb 1273 IN UINTN PointX,\r
1274 IN UINTN PointY,\r
b3154720 1275 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL\r
1276 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL\r
1277 IN CONST CHAR16 *Format,\r
1278 ...\r
1279 );\r
1280\r
1281/**\r
9095d37b 1282 Prints a formatted ASCII string to a graphics console device specified by\r
b3154720 1283 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.\r
1284\r
9095d37b
LG
1285 This function prints a formatted ASCII string to the graphics console device\r
1286 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of\r
1287 ASCII characters displayed, not including partial characters that may be clipped\r
b9c8d8bd 1288 by the right edge of the display. If the length of the formatted ASCII string is\r
9095d37b 1289 greater than PcdUefiLibMaxPrintBufferSize, then at most the first\r
1a2f870c 1290 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL\r
9095d37b 1291 is used to convert the string to a bitmap using the glyphs registered with the\r
1a2f870c 1292 HII database. No wrapping is performed, so any portions of the string the fall\r
1293 outside the active display region will not be displayed.\r
b3154720 1294\r
9095d37b 1295 If a graphics console device is not associated with the ConsoleOutputHandle\r
b3154720 1296 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.\r
9095d37b 1297 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no\r
b3154720 1298 string is printed, and 0 is returned.\r
1299 If Format is NULL, then ASSERT().\r
cda8ba5e 1300 If gST->ConsoleOutputHandle is NULL, then ASSERT().\r
b3154720 1301\r
51969ecb 1302 @param PointX X coordinate to print the string.\r
1303 @param PointY Y coordinate to print the string.\r
28d3e14f 1304 @param ForeGround The foreground color of the string being printed. This is\r
b3154720 1305 an optional parameter that may be NULL. If it is NULL,\r
1306 then the foreground color of the current ConOut device\r
1307 in the EFI_SYSTEM_TABLE is used.\r
1308 @param BackGround The background color of the string being printed. This is\r
9095d37b 1309 an optional parameter that may be NULL. If it is NULL,\r
b3154720 1310 then the background color of the current ConOut device\r
1311 in the EFI_SYSTEM_TABLE is used.\r
9095d37b 1312 @param Format A null-terminated ASCII format string. See Print Library\r
b3154720 1313 for the supported format string syntax.\r
9095d37b
LG
1314 @param ... The variable argument list whose contents are accessed based on\r
1315 the format string specified by Format.\r
b3154720 1316\r
1317 @return The number of ASCII characters printed.\r
1318\r
1319**/\r
1320UINTN\r
1321EFIAPI\r
1322AsciiPrintXY (\r
51969ecb 1323 IN UINTN PointX,\r
1324 IN UINTN PointY,\r
b3154720 1325 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL\r
1326 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL\r
1327 IN CONST CHAR8 *Format,\r
1328 ...\r
1329 );\r
1330\r
0290fca2 1331\r
c7d265a9 1332/**\r
cf8ae2f6 1333 Installs and completes the initialization of a Driver Binding Protocol instance.\r
9095d37b 1334\r
cf8ae2f6 1335 Installs the Driver Binding Protocol specified by DriverBinding onto the handle\r
1336 specified by DriverBindingHandle. If DriverBindingHandle is NULL, then DriverBinding\r
1337 is installed onto a newly created handle. DriverBindingHandle is typically the same\r
1338 as the driver's ImageHandle, but it can be different if the driver produces multiple\r
9095d37b
LG
1339 Driver Binding Protocols.\r
1340 If DriverBinding is NULL, then ASSERT().\r
cf8ae2f6 1341 If DriverBinding can not be installed onto a handle, then ASSERT().\r
1342\r
1343 @param ImageHandle The image handle of the driver.\r
1344 @param SystemTable The EFI System Table that was passed to the driver's entry point.\r
1345 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.\r
1346 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this\r
1347 parameter is NULL, then a new handle is created.\r
1348\r
af2dc6a7 1349 @retval EFI_SUCCESS The protocol installation completed successfully.\r
cf8ae2f6 1350 @retval EFI_OUT_OF_RESOURCES There was not enough system resources to install the protocol.\r
1351 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().\r
c7d265a9 1352\r
1353**/\r
1354EFI_STATUS\r
1355EFIAPI\r
1356EfiLibInstallDriverBinding (\r
1357 IN CONST EFI_HANDLE ImageHandle,\r
1358 IN CONST EFI_SYSTEM_TABLE *SystemTable,\r
1359 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
1360 IN EFI_HANDLE DriverBindingHandle\r
1361 );\r
1362\r
c7d265a9 1363\r
0290fca2
AS
1364/**\r
1365 Uninstalls a Driver Binding Protocol instance.\r
1366\r
1367 If DriverBinding is NULL, then ASSERT().\r
1368 If DriverBinding can not be uninstalled, then ASSERT().\r
1369\r
1370 @param DriverBinding A Driver Binding Protocol instance that this driver produced.\r
1371\r
1372 @retval EFI_SUCCESS The protocol uninstallation successfully completed.\r
1373 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().\r
1374\r
1375**/\r
1376EFI_STATUS\r
1377EFIAPI\r
1378EfiLibUninstallDriverBinding (\r
1379 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding\r
1380 );\r
1381\r
1382\r
f662c194 1383/**\r
cf8ae2f6 1384 Installs and completes the initialization of a Driver Binding Protocol instance and\r
1385 optionally installs the Component Name, Driver Configuration and Driver Diagnostics Protocols.\r
1386\r
1387 Initializes a driver by installing the Driver Binding Protocol together with the\r
1388 optional Component Name, optional Driver Configure and optional Driver Diagnostic\r
1389 Protocols onto the driver's DriverBindingHandle. If DriverBindingHandle is NULL,\r
1a2f870c 1390 then the protocols are installed onto a newly created handle. DriverBindingHandle\r
cf8ae2f6 1391 is typically the same as the driver's ImageHandle, but it can be different if the\r
9095d37b
LG
1392 driver produces multiple Driver Binding Protocols.\r
1393 If DriverBinding is NULL, then ASSERT().\r
cf8ae2f6 1394 If the installation fails, then ASSERT().\r
9095d37b 1395\r
cf8ae2f6 1396 @param ImageHandle The image handle of the driver.\r
1397 @param SystemTable The EFI System Table that was passed to the driver's entry point.\r
1398 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.\r
1399 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this\r
1400 parameter is NULL, then a new handle is created.\r
1401 @param ComponentName A Component Name Protocol instance that this driver is producing.\r
1402 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.\r
1403 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.\r
1404\r
af2dc6a7 1405 @retval EFI_SUCCESS The protocol installation completed successfully.\r
1406 @retval EFI_OUT_OF_RESOURCES There was not enough memory in the pool to install all the protocols.\r
c7d265a9 1407\r
1408**/\r
1409EFI_STATUS\r
1410EFIAPI\r
1411EfiLibInstallAllDriverProtocols (\r
1412 IN CONST EFI_HANDLE ImageHandle,\r
1413 IN CONST EFI_SYSTEM_TABLE *SystemTable,\r
1414 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
1415 IN EFI_HANDLE DriverBindingHandle,\r
1416 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
1417 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL\r
1418 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL\r
1419 );\r
1420\r
1421\r
0290fca2
AS
1422/**\r
1423 Uninstalls a Driver Binding Protocol instance and optionally uninstalls the\r
1424 Component Name, Driver Configuration and Driver Diagnostics Protocols.\r
1425\r
1426 If DriverBinding is NULL, then ASSERT().\r
1427 If the uninstallation fails, then ASSERT().\r
1428\r
1429 @param DriverBinding A Driver Binding Protocol instance that this driver produced.\r
1430 @param ComponentName A Component Name Protocol instance that this driver produced.\r
1431 @param DriverConfiguration A Driver Configuration Protocol instance that this driver produced.\r
1432 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver produced.\r
1433\r
1434 @retval EFI_SUCCESS The protocol uninstallation successfully completed.\r
1435 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().\r
1436\r
1437**/\r
1438EFI_STATUS\r
1439EFIAPI\r
1440EfiLibUninstallAllDriverProtocols (\r
1441 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
1442 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
1443 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL\r
1444 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL\r
1445 );\r
1446\r
f662c194 1447\r
c7d265a9 1448/**\r
cf8ae2f6 1449 Installs Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.\r
1450\r
1451 Initializes a driver by installing the Driver Binding Protocol together with the\r
1452 optional Component Name and optional Component Name 2 protocols onto the driver's\r
1453 DriverBindingHandle. If DriverBindingHandle is NULL, then the protocols are installed\r
1454 onto a newly created handle. DriverBindingHandle is typically the same as the driver's\r
9095d37b
LG
1455 ImageHandle, but it can be different if the driver produces multiple Driver Binding Protocols.\r
1456 If DriverBinding is NULL, then ASSERT().\r
cf8ae2f6 1457 If the installation fails, then ASSERT().\r
1458\r
1459 @param ImageHandle The image handle of the driver.\r
1460 @param SystemTable The EFI System Table that was passed to the driver's entry point.\r
1461 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.\r
1462 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this\r
1463 parameter is NULL, then a new handle is created.\r
1464 @param ComponentName A Component Name Protocol instance that this driver is producing.\r
1465 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.\r
1466\r
af2dc6a7 1467 @retval EFI_SUCCESS The protocol installation completed successfully.\r
cf8ae2f6 1468 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.\r
f662c194 1469\r
1470**/\r
1471EFI_STATUS\r
1472EFIAPI\r
1473EfiLibInstallDriverBindingComponentName2 (\r
1474 IN CONST EFI_HANDLE ImageHandle,\r
1475 IN CONST EFI_SYSTEM_TABLE *SystemTable,\r
1476 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
1477 IN EFI_HANDLE DriverBindingHandle,\r
1478 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
1479 IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL\r
1480 );\r
1481\r
1482\r
0290fca2
AS
1483/**\r
1484 Uninstalls Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.\r
1485\r
1486 If DriverBinding is NULL, then ASSERT().\r
1487 If the uninstallation fails, then ASSERT().\r
1488\r
1489 @param DriverBinding A Driver Binding Protocol instance that this driver produced.\r
1490 @param ComponentName A Component Name Protocol instance that this driver produced.\r
1491 @param ComponentName2 A Component Name 2 Protocol instance that this driver produced.\r
1492\r
1493 @retval EFI_SUCCESS The protocol installation successfully completed.\r
1494 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().\r
1495\r
1496**/\r
1497EFI_STATUS\r
1498EFIAPI\r
1499EfiLibUninstallDriverBindingComponentName2 (\r
1500 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
1501 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
1502 IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL\r
1503 );\r
1504\r
1505\r
f662c194 1506/**\r
cf8ae2f6 1507 Installs Driver Binding Protocol with optional Component Name, Component Name 2, Driver\r
1508 Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.\r
1509\r
1510 Initializes a driver by installing the Driver Binding Protocol together with the optional\r
63ba999c 1511 Component Name, optional Component Name 2, optional Driver Configuration, optional Driver Configuration 2,\r
1512 optional Driver Diagnostic, and optional Driver Diagnostic 2 Protocols onto the driver's DriverBindingHandle.\r
1513 DriverBindingHandle is typically the same as the driver's ImageHandle, but it can be different if the driver\r
9095d37b
LG
1514 produces multiple Driver Binding Protocols.\r
1515 If DriverBinding is NULL, then ASSERT().\r
63ba999c 1516 If the installation fails, then ASSERT().\r
1517\r
cf8ae2f6 1518\r
1519 @param ImageHandle The image handle of the driver.\r
1520 @param SystemTable The EFI System Table that was passed to the driver's entry point.\r
1521 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.\r
28d3e14f 1522 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this\r
cf8ae2f6 1523 parameter is NULL, then a new handle is created.\r
1524 @param ComponentName A Component Name Protocol instance that this driver is producing.\r
1525 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.\r
1526 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.\r
1527 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver is producing.\r
1528 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.\r
1529 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing.\r
1530\r
af2dc6a7 1531 @retval EFI_SUCCESS The protocol installation completed successfully.\r
cf8ae2f6 1532 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.\r
c7d265a9 1533\r
1534**/\r
1535EFI_STATUS\r
1536EFIAPI\r
1537EfiLibInstallAllDriverProtocols2 (\r
1538 IN CONST EFI_HANDLE ImageHandle,\r
1539 IN CONST EFI_SYSTEM_TABLE *SystemTable,\r
1540 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
1541 IN EFI_HANDLE DriverBindingHandle,\r
def220c4 1542 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
1543 IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL\r
1544 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL\r
8408411a 1545 IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2, OPTIONAL\r
def220c4 1546 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics, OPTIONAL\r
1547 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL\r
c7d265a9 1548 );\r
1549\r
0290fca2
AS
1550\r
1551/**\r
1552 Uninstalls Driver Binding Protocol with optional Component Name, Component Name 2, Driver\r
1553 Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.\r
1554\r
1555 If DriverBinding is NULL, then ASSERT().\r
1556 If the installation fails, then ASSERT().\r
1557\r
1558\r
1559 @param DriverBinding A Driver Binding Protocol instance that this driver produced.\r
1560 @param ComponentName A Component Name Protocol instance that this driver produced.\r
1561 @param ComponentName2 A Component Name 2 Protocol instance that this driver produced.\r
1562 @param DriverConfiguration A Driver Configuration Protocol instance that this driver produced.\r
1563 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver produced.\r
1564 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver produced.\r
1565 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver produced.\r
1566\r
1567 @retval EFI_SUCCESS The protocol uninstallation successfully completed.\r
1568 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().\r
1569\r
1570**/\r
1571EFI_STATUS\r
1572EFIAPI\r
1573EfiLibUninstallAllDriverProtocols2 (\r
1574 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
1575 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
1576 IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL\r
1577 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL\r
1578 IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2, OPTIONAL\r
1579 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics, OPTIONAL\r
1580 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL\r
1581 );\r
1582\r
1583\r
9095d37b 1584/**\r
f405c067 1585 Appends a formatted Unicode string to a Null-terminated Unicode string\r
9095d37b
LG
1586\r
1587 This function appends a formatted Unicode string to the Null-terminated\r
f405c067 1588 Unicode string specified by String. String is optional and may be NULL.\r
9095d37b 1589 Storage for the formatted Unicode string returned is allocated using\r
f405c067 1590 AllocatePool(). The pointer to the appended string is returned. The caller\r
1591 is responsible for freeing the returned string.\r
9095d37b 1592\r
f405c067 1593 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().\r
1594 If FormatString is NULL, then ASSERT().\r
1595 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
9095d37b 1596\r
f405c067 1597 @param[in] String A Null-terminated Unicode string.\r
1598 @param[in] FormatString A Null-terminated Unicode format string.\r
1599 @param[in] Marker VA_LIST marker for the variable argument list.\r
1600\r
1601 @retval NULL There was not enough available memory.\r
9095d37b 1602 @return Null-terminated Unicode string is that is the formatted\r
f405c067 1603 string appended to String.\r
1604**/\r
1605CHAR16*\r
1606EFIAPI\r
1607CatVSPrint (\r
1608 IN CHAR16 *String, OPTIONAL\r
1609 IN CONST CHAR16 *FormatString,\r
1610 IN VA_LIST Marker\r
1611 );\r
1612\r
9095d37b 1613/**\r
f405c067 1614 Appends a formatted Unicode string to a Null-terminated Unicode string\r
9095d37b
LG
1615\r
1616 This function appends a formatted Unicode string to the Null-terminated\r
f405c067 1617 Unicode string specified by String. String is optional and may be NULL.\r
9095d37b 1618 Storage for the formatted Unicode string returned is allocated using\r
f405c067 1619 AllocatePool(). The pointer to the appended string is returned. The caller\r
1620 is responsible for freeing the returned string.\r
9095d37b 1621\r
f405c067 1622 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().\r
1623 If FormatString is NULL, then ASSERT().\r
1624 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
9095d37b 1625\r
f405c067 1626 @param[in] String A Null-terminated Unicode string.\r
1627 @param[in] FormatString A Null-terminated Unicode format string.\r
9095d37b
LG
1628 @param[in] ... The variable argument list whose contents are\r
1629 accessed based on the format string specified by\r
f405c067 1630 FormatString.\r
1631\r
1632 @retval NULL There was not enough available memory.\r
9095d37b 1633 @return Null-terminated Unicode string is that is the formatted\r
f405c067 1634 string appended to String.\r
1635**/\r
1636CHAR16 *\r
1637EFIAPI\r
1638CatSPrint (\r
1639 IN CHAR16 *String, OPTIONAL\r
1640 IN CONST CHAR16 *FormatString,\r
1641 ...\r
1642 );\r
1643\r
40070a18
MK
1644/**\r
1645 Returns an array of protocol instance that matches the given protocol.\r
1646\r
1647 @param[in] Protocol Provides the protocol to search for.\r
1648 @param[out] NoProtocols The number of protocols returned in Buffer.\r
1649 @param[out] Buffer A pointer to the buffer to return the requested\r
1650 array of protocol instances that match Protocol.\r
1651 The returned buffer is allocated using\r
1652 EFI_BOOT_SERVICES.AllocatePool(). The caller is\r
1653 responsible for freeing this buffer with\r
1654 EFI_BOOT_SERVICES.FreePool().\r
1655\r
1656 @retval EFI_SUCCESS The array of protocols was returned in Buffer,\r
1657 and the number of protocols in Buffer was\r
1658 returned in NoProtocols.\r
1659 @retval EFI_NOT_FOUND No protocols found.\r
1660 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the\r
1661 matching results.\r
1662 @retval EFI_INVALID_PARAMETER Protocol is NULL.\r
1663 @retval EFI_INVALID_PARAMETER NoProtocols is NULL.\r
1664 @retval EFI_INVALID_PARAMETER Buffer is NULL.\r
1665\r
1666**/\r
1667EFI_STATUS\r
1668EFIAPI\r
1669EfiLocateProtocolBuffer (\r
1670 IN EFI_GUID *Protocol,\r
1671 OUT UINTN *NoProtocols,\r
1672 OUT VOID ***Buffer\r
1673 );\r
768b6111
LE
1674\r
1675/**\r
1676 Open or create a file or directory, possibly creating the chain of\r
1677 directories leading up to the directory.\r
1678\r
1679 EfiOpenFileByDevicePath() first locates EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on\r
1680 FilePath, and opens the root directory of that filesystem with\r
1681 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume().\r
1682\r
1683 On the remaining device path, the longest initial sequence of\r
1684 FILEPATH_DEVICE_PATH nodes is node-wise traversed with\r
5dbc768f 1685 EFI_FILE_PROTOCOL.Open().\r
768b6111
LE
1686\r
1687 (As a consequence, if OpenMode includes EFI_FILE_MODE_CREATE, and Attributes\r
1688 includes EFI_FILE_DIRECTORY, and each FILEPATH_DEVICE_PATH specifies a single\r
1689 pathname component, then EfiOpenFileByDevicePath() ensures that the specified\r
1690 series of subdirectories exist on return.)\r
1691\r
1692 The EFI_FILE_PROTOCOL identified by the last FILEPATH_DEVICE_PATH node is\r
1693 output to the caller; intermediate EFI_FILE_PROTOCOL instances are closed. If\r
1694 there are no FILEPATH_DEVICE_PATH nodes past the node that identifies the\r
1695 filesystem, then the EFI_FILE_PROTOCOL of the root directory of the\r
1696 filesystem is output to the caller. If a device path node that is different\r
1697 from FILEPATH_DEVICE_PATH is encountered relative to the filesystem, the\r
1698 traversal is stopped with an error, and a NULL EFI_FILE_PROTOCOL is output.\r
1699\r
1700 @param[in,out] FilePath On input, the device path to the file or directory\r
1701 to open or create. The caller is responsible for\r
1702 ensuring that the device path pointed-to by FilePath\r
1703 is well-formed. On output, FilePath points one past\r
1704 the last node in the original device path that has\r
1705 been successfully processed. FilePath is set on\r
1706 output even if EfiOpenFileByDevicePath() returns an\r
1707 error.\r
1708\r
1709 @param[out] File On error, File is set to NULL. On success, File is\r
1710 set to the EFI_FILE_PROTOCOL of the root directory\r
1711 of the filesystem, if there are no\r
1712 FILEPATH_DEVICE_PATH nodes in FilePath; otherwise,\r
1713 File is set to the EFI_FILE_PROTOCOL identified by\r
1714 the last node in FilePath.\r
1715\r
1716 @param[in] OpenMode The OpenMode parameter to pass to\r
5dbc768f 1717 EFI_FILE_PROTOCOL.Open().\r
768b6111
LE
1718\r
1719 @param[in] Attributes The Attributes parameter to pass to\r
5dbc768f 1720 EFI_FILE_PROTOCOL.Open().\r
768b6111
LE
1721\r
1722 @retval EFI_SUCCESS The file or directory has been opened or\r
1723 created.\r
1724\r
1725 @retval EFI_INVALID_PARAMETER FilePath is NULL; or File is NULL; or FilePath\r
1726 contains a device path node, past the node\r
1727 that identifies\r
1728 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, that is not a\r
1729 FILEPATH_DEVICE_PATH node.\r
1730\r
1731 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r
1732\r
1733 @return Error codes propagated from the\r
1734 LocateDevicePath() and OpenProtocol() boot\r
1735 services, and from the\r
1736 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume()\r
1737 and EFI_FILE_PROTOCOL.Open() member functions.\r
1738**/\r
1739EFI_STATUS\r
1740EFIAPI\r
1741EfiOpenFileByDevicePath (\r
1742 IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r
1743 OUT EFI_FILE_PROTOCOL **File,\r
1744 IN UINT64 OpenMode,\r
1745 IN UINT64 Attributes\r
1746 );\r
af5e9521
SZ
1747\r
1748/**\r
1749 This function locates next ACPI table in XSDT/RSDT based on Signature and\r
1750 previous returned Table.\r
1751\r
1752 If PreviousTable is NULL:\r
1753 This function will locate the first ACPI table in XSDT/RSDT based on\r
1754 Signature in gEfiAcpi20TableGuid system configuration table first, and then\r
1755 gEfiAcpi10TableGuid system configuration table.\r
1756 This function will locate in XSDT first, and then RSDT.\r
1757 For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in\r
1758 FADT.\r
1759 For FACS, this function will locate XFirmwareCtrl in FADT first, and then\r
1760 FirmwareCtrl in FADT.\r
1761\r
1762 If PreviousTable is not NULL:\r
1763 1. If it could be located in XSDT in gEfiAcpi20TableGuid system configuration\r
1764 table, then this function will just locate next table in XSDT in\r
1765 gEfiAcpi20TableGuid system configuration table.\r
1766 2. If it could be located in RSDT in gEfiAcpi20TableGuid system configuration\r
1767 table, then this function will just locate next table in RSDT in\r
1768 gEfiAcpi20TableGuid system configuration table.\r
1769 3. If it could be located in RSDT in gEfiAcpi10TableGuid system configuration\r
1770 table, then this function will just locate next table in RSDT in\r
1771 gEfiAcpi10TableGuid system configuration table.\r
1772\r
1773 It's not supported that PreviousTable is not NULL but PreviousTable->Signature\r
1774 is not same with Signature, NULL will be returned.\r
1775\r
1776 @param Signature ACPI table signature.\r
1777 @param PreviousTable Pointer to previous returned table to locate next\r
1778 table, or NULL to locate first table.\r
1779\r
1780 @return Next ACPI table or NULL if not found.\r
1781\r
1782**/\r
1783EFI_ACPI_COMMON_HEADER *\r
1784EFIAPI\r
1785EfiLocateNextAcpiTable (\r
1786 IN UINT32 Signature,\r
1787 IN EFI_ACPI_COMMON_HEADER *PreviousTable OPTIONAL\r
1788 );\r
1789\r
1790/**\r
1791 This function locates first ACPI table in XSDT/RSDT based on Signature.\r
1792\r
1793 This function will locate the first ACPI table in XSDT/RSDT based on\r
1794 Signature in gEfiAcpi20TableGuid system configuration table first, and then\r
1795 gEfiAcpi10TableGuid system configuration table.\r
1796 This function will locate in XSDT first, and then RSDT.\r
1797 For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in\r
1798 FADT.\r
1799 For FACS, this function will locate XFirmwareCtrl in FADT first, and then\r
1800 FirmwareCtrl in FADT.\r
1801\r
1802 @param Signature ACPI table signature.\r
1803\r
1804 @return First ACPI table or NULL if not found.\r
1805\r
1806**/\r
1807EFI_ACPI_COMMON_HEADER *\r
1808EFIAPI\r
1809EfiLocateFirstAcpiTable (\r
1810 IN UINT32 Signature\r
1811 );\r
1812\r
fb3df220 1813#endif\r