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