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