]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/UefiLib.h
Update doxygen comment for VarArg list parameter. "..."'s description is added.
[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
50a64e5b 11Copyright (c) 2006 - 2008, Intel Corporation\r
12All rights reserved. This program and the accompanying materials\r
13are licensed and made available under the terms and conditions of the BSD License\r
14which accompanies this distribution. The full text of the license may be found at\r
15http://opensource.org/licenses/bsd-license.php\r
fb3df220 16\r
50a64e5b 17THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
18WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
fb3df220 19\r
20**/\r
21\r
22#ifndef __UEFI_LIB_H__\r
23#define __UEFI_LIB_H__\r
24\r
c7d265a9 25#include <Protocol/DriverBinding.h>\r
26#include <Protocol/DriverConfiguration.h>\r
27#include <Protocol/ComponentName.h>\r
28#include <Protocol/ComponentName2.h>\r
29#include <Protocol/DriverDiagnostics.h>\r
30#include <Protocol/DriverDiagnostics2.h>\r
31\r
52ca0d98 32#include <Library/BaseLib.h>\r
33\r
fc30687f 34///\r
35/// Unicode String Table\r
36///\r
fb3df220 37typedef struct {\r
38 CHAR8 *Language;\r
39 CHAR16 *UnicodeString;\r
40} EFI_UNICODE_STRING_TABLE;\r
41\r
fc30687f 42///\r
43/// EFI Lock Status\r
44///\r
fb3df220 45typedef enum {\r
46 EfiLockUninitialized = 0,\r
47 EfiLockReleased = 1,\r
48 EfiLockAcquired = 2\r
49} EFI_LOCK_STATE;\r
50\r
fc30687f 51///\r
52/// EFI Lock \r
53///\r
fb3df220 54typedef struct {\r
55 EFI_TPL Tpl;\r
56 EFI_TPL OwnerTpl;\r
57 EFI_LOCK_STATE Lock;\r
58} EFI_LOCK;\r
59\r
60\r
52ca0d98 61/**\r
62 Macro that returns the number of 100 ns units for a specified number of microseconds.\r
63 Useful for managing EFI timer events.\r
64\r
65 @param Microseconds Number of microseonds.\r
66\r
67 @return The number of 100 ns units equivalent to the number of microseconds specified\r
68 by Microseconds.\r
69\r
70**/\r
71#define EFI_TIMER_PERIOD_MICROSECONDS(Microseconds) MultU64x32((UINT64)(Microseconds), 10)\r
72\r
73\r
74/**\r
75 Macro that returns the number of 100 ns units for a specified number of milliseoconds.\r
76 Useful for managing EFI timer events.\r
77\r
78 @param Milliseconds Number of milliseconds.\r
79\r
80 @return The number of 100 ns units equivalent to the number of milliseconds specified\r
81 by Milliseconds.\r
82\r
83**/\r
84#define EFI_TIMER_PERIOD_MILLISECONDS(Milliseconds) MultU64x32((UINT64)(Milliseconds), 10000)\r
85\r
86\r
87/**\r
88 Macro that returns the number of 100 ns units for a specified number of seoconds.\r
89 Useful for managing EFI timer events.\r
90\r
91 @param Seconds Number of seconds.\r
92\r
93 @return The number of 100 ns units equivalent to the number of seconds specified\r
94 by Seconds.\r
95\r
96**/\r
97#define EFI_TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)\r
98\r
99\r
fb3df220 100/**\r
101 This function searches the list of configuration tables stored in the EFI System \r
102 Table for a table with a GUID that matches TableGuid. If a match is found, \r
103 then a pointer to the configuration table is returned in Table, and EFI_SUCCESS \r
104 is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned.\r
105\r
106 @param TableGuid Pointer to table's GUID type..\r
107 @param Table Pointer to the table associated with TableGuid in the EFI System Table.\r
108\r
109 @retval EFI_SUCCESS A configuration table matching TableGuid was found.\r
110 @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.\r
111\r
112**/\r
113EFI_STATUS\r
114EFIAPI\r
115EfiGetSystemConfigurationTable ( \r
116 IN EFI_GUID *TableGuid,\r
117 OUT VOID **Table\r
118 );\r
119\r
120/**\r
121 This function causes the notification function to be executed for every protocol \r
122 of type ProtocolGuid instance that exists in the system when this function is \r
123 invoked. In addition, every time a protocol of type ProtocolGuid instance is \r
124 installed or reinstalled, the notification function is also executed.\r
125\r
126 @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.\r
127 @param NotifyTpl Supplies the task priority level of the event notifications.\r
128 @param NotifyFunction Supplies the function to notify when the event is signaled.\r
129 @param NotifyContext The context parameter to pass to NotifyFunction.\r
130 @param Registration A pointer to a memory location to receive the registration value.\r
131\r
132 @return The notification event that was created. \r
133\r
134**/\r
135EFI_EVENT\r
136EFIAPI\r
137EfiCreateProtocolNotifyEvent(\r
138 IN EFI_GUID *ProtocolGuid,\r
139 IN EFI_TPL NotifyTpl,\r
140 IN EFI_EVENT_NOTIFY NotifyFunction,\r
141 IN VOID *NotifyContext, OPTIONAL\r
142 OUT VOID **Registration\r
143 );\r
144\r
145/**\r
146 This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.\r
147 This event is signaled with EfiNamedEventSignal(). This provide the ability for \r
148 one or more listeners on the same event named by the GUID specified by Name.\r
149\r
150 @param Name Supplies GUID name of the event.\r
151 @param NotifyTpl Supplies the task priority level of the event notifications.\r
152 @param NotifyFunction Supplies the function to notify when the event is signaled.\r
153 @param NotifyContext The context parameter to pass to NotifyFunction. \r
154 @param Registration A pointer to a memory location to receive the registration value.\r
155\r
156 @retval EFI_SUCCESS A named event was created.\r
157 @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event.\r
158\r
159**/\r
160EFI_STATUS\r
161EFIAPI\r
162EfiNamedEventListen (\r
163 IN CONST EFI_GUID *Name,\r
164 IN EFI_TPL NotifyTpl,\r
165 IN EFI_EVENT_NOTIFY NotifyFunction,\r
166 IN CONST VOID *NotifyContext, OPTIONAL\r
167 OUT VOID *Registration OPTIONAL\r
168 );\r
169\r
170/**\r
171 This function signals the named event specified by Name. The named event must \r
172 have been created with EfiNamedEventListen().\r
173\r
174 @param Name Supplies GUID name of the event.\r
175\r
176 @retval EFI_SUCCESS A named event was signaled.\r
177 @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event.\r
178\r
179**/\r
180EFI_STATUS\r
181EFIAPI\r
182EfiNamedEventSignal (\r
183 IN CONST EFI_GUID *Name\r
184 );\r
185\r
186/** \r
187 Returns the current TPL.\r
188\r
189 This function returns the current TPL. There is no EFI service to directly \r
190 retrieve the current TPL. Instead, the RaiseTPL() function is used to raise \r
191 the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level \r
192 can then immediately be restored back to the current TPL level with a call \r
193 to RestoreTPL().\r
194\r
01aef47b 195 @return The current TPL.\r
fb3df220 196\r
197**/\r
198EFI_TPL\r
199EFIAPI\r
200EfiGetCurrentTpl (\r
201 VOID\r
202 );\r
203\r
204/**\r
205 This function initializes a basic mutual exclusion lock to the released state \r
206 and returns the lock. Each lock provides mutual exclusion access at its task \r
207 priority level. Since there is no preemption or multiprocessor support in EFI,\r
208 acquiring the lock only consists of raising to the locks TPL.\r
209\r
210 @param Lock A pointer to the lock data structure to initialize.\r
211 @param Priority EFI TPL associated with the lock.\r
212\r
213 @return The lock.\r
214\r
215**/\r
216EFI_LOCK *\r
217EFIAPI\r
218EfiInitializeLock (\r
219 IN OUT EFI_LOCK *Lock,\r
220 IN EFI_TPL Priority\r
221 );\r
222\r
223/**\r
224 This macro initializes the contents of a basic mutual exclusion lock to the \r
225 released state. Each lock provides mutual exclusion access at its task \r
226 priority level. Since there is no preemption or multiprocessor support in EFI,\r
227 acquiring the lock only consists of raising to the locks TPL.\r
228\r
fb3df220 229 @param Priority The task priority level of the lock.\r
230\r
231 @return The lock.\r
232\r
233**/\r
234#define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \\r
50615d1f 235 {Priority, TPL_APPLICATION, EfiLockReleased }\r
fb3df220 236\r
237\r
238/**\r
239 \r
240 Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state.\r
241\r
242 If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, \r
243 then this macro evaluates the EFI_LOCK structure specified by Lock. If Lock \r
244 is not in the locked state, then DebugAssert() is called passing in the source \r
245 filename, source line number, and Lock.\r
246\r
247 If Lock is NULL, then ASSERT().\r
248\r
249 @param LockParameter A pointer to the lock to acquire.\r
250\r
251**/\r
252#define ASSERT_LOCKED(LockParameter) \\r
253 do { \\r
254 if (DebugAssertEnabled ()) { \\r
255 ASSERT (LockParameter != NULL); \\r
256 if ((LockParameter)->Lock != EfiLockAcquired) { \\r
257 _ASSERT (LockParameter not locked); \\r
258 } \\r
259 } \\r
260 } while (FALSE)\r
261\r
262\r
263/**\r
264 This function raises the system's current task priority level to the task \r
265 priority level of the mutual exclusion lock. Then, it places the lock in the \r
266 acquired state.\r
267\r
01aef47b 268 @param Lock A pointer to the lock to acquire.\r
fb3df220 269\r
270**/\r
271VOID\r
272EFIAPI\r
273EfiAcquireLock (\r
274 IN EFI_LOCK *Lock\r
275 );\r
276\r
277/**\r
278 This function raises the system's current task priority level to the task \r
279 priority level of the mutual exclusion lock. Then, it attempts to place the \r
280 lock in the acquired state.\r
281\r
282 @param Lock A pointer to the lock to acquire.\r
283\r
284 @retval EFI_SUCCESS The lock was acquired.\r
285 @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.\r
286\r
287**/\r
288EFI_STATUS\r
289EFIAPI\r
290EfiAcquireLockOrFail (\r
291 IN EFI_LOCK *Lock\r
292 );\r
293\r
294/**\r
295 This function transitions a mutual exclusion lock from the acquired state to \r
296 the released state, and restores the system's task priority level to its \r
297 previous level.\r
298\r
299 @param Lock A pointer to the lock to release.\r
300\r
301**/\r
302VOID\r
303EFIAPI\r
304EfiReleaseLock (\r
305 IN EFI_LOCK *Lock\r
306 );\r
307\r
0c9d7395 308/**\r
309 Tests whether a controller handle is being managed by a specific driver.\r
310\r
fb3df220 311 This function tests whether the driver specified by DriverBindingHandle is\r
312 currently managing the controller specified by ControllerHandle. This test\r
313 is performed by evaluating if the the protocol specified by ProtocolGuid is\r
314 present on ControllerHandle and is was opened by DriverBindingHandle with an\r
315 attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r
316 If ProtocolGuid is NULL, then ASSERT().\r
0c9d7395 317\r
318 @param ControllerHandle A handle for a controller to test.\r
319 @param DriverBindingHandle Specifies the driver binding handle for the\r
320 driver.\r
321 @param ProtocolGuid Specifies the protocol that the driver specified\r
322 by DriverBindingHandle opens in its Start()\r
323 function.\r
324\r
325 @retval EFI_SUCCESS ControllerHandle is managed by the driver\r
326 specifed by DriverBindingHandle.\r
327 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver\r
328 specifed by DriverBindingHandle.\r
329\r
fb3df220 330**/\r
331EFI_STATUS\r
332EFIAPI\r
333EfiTestManagedDevice (\r
334 IN CONST EFI_HANDLE ControllerHandle,\r
335 IN CONST EFI_HANDLE DriverBindingHandle,\r
336 IN CONST EFI_GUID *ProtocolGuid\r
337 );\r
338\r
0c9d7395 339/**\r
340 Tests whether a child handle is a child device of the controller.\r
341\r
fb3df220 342 This function tests whether ChildHandle is one of the children of\r
343 ControllerHandle. This test is performed by checking to see if the protocol\r
344 specified by ProtocolGuid is present on ControllerHandle and opened by\r
345 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
346 If ProtocolGuid is NULL, then ASSERT().\r
0c9d7395 347\r
348 @param ControllerHandle A handle for a (parent) controller to test. \r
349 @param ChildHandle A child handle to test.\r
01aef47b 350 @param ProtocolGuid Supplies the protocol that the child controller\r
0c9d7395 351 opens on its parent controller. \r
352\r
353 @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle.\r
354 @retval EFI_UNSUPPORTED ChildHandle is not a child of the\r
355 ControllerHandle.\r
356\r
fb3df220 357**/\r
358EFI_STATUS\r
359EFIAPI\r
360EfiTestChildHandle (\r
361 IN CONST EFI_HANDLE ControllerHandle,\r
362 IN CONST EFI_HANDLE ChildHandle,\r
363 IN CONST EFI_GUID *ProtocolGuid\r
364 );\r
365\r
366/**\r
367 This function looks up a Unicode string in UnicodeStringTable. If Language is \r
368 a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable\r
369 that matches the language code specified by Language, then it is returned in \r
370 UnicodeString.\r
371\r
372 @param Language A pointer to the ISO 639-2 language code for the \r
373 Unicode string to look up and return.\r
374 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes \r
375 that the Unicode string table supports. Language \r
376 must be a member of this set.\r
377 @param UnicodeStringTable A pointer to the table of Unicode strings.\r
378 @param UnicodeString A pointer to the Unicode string from UnicodeStringTable\r
379 that matches the language specified by Language.\r
380\r
381 @retval EFI_SUCCESS The Unicode string that matches the language \r
382 specified by Language was found\r
383 in the table of Unicoide strings UnicodeStringTable, \r
384 and it was returned in UnicodeString.\r
385 @retval EFI_INVALID_PARAMETER Language is NULL.\r
386 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
387 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
388 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.\r
389 @retval EFI_UNSUPPORTED The language specified by Language is not a \r
390 member of SupportedLanguages.\r
391 @retval EFI_UNSUPPORTED The language specified by Language is not \r
392 supported by UnicodeStringTable.\r
393\r
394**/\r
395EFI_STATUS\r
396EFIAPI\r
397LookupUnicodeString (\r
398 IN CONST CHAR8 *Language,\r
399 IN CONST CHAR8 *SupportedLanguages,\r
400 IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,\r
401 OUT CHAR16 **UnicodeString\r
402 );\r
403\r
a73480f6 404/**\r
405 This function looks up a Unicode string in UnicodeStringTable.\r
406 If Language is a member of SupportedLanguages and a Unicode\r
407 string is found in UnicodeStringTable that matches the\r
408 language code specified by Language, then it is returned in\r
409 UnicodeString.\r
410\r
411 @param Language A pointer to the ISO 639-2 or\r
412 RFC 3066 language code for the\r
413 Unicode string to look up and\r
414 return.\r
415 \r
416 @param SupportedLanguages A pointer to the set of ISO\r
417 639-2 or RFC 3066 language\r
418 codes that the Unicode string\r
419 table supports. Language must\r
420 be a member of this set.\r
421 \r
422 @param UnicodeStringTable A pointer to the table of\r
423 Unicode strings.\r
424 \r
425 @param UnicodeString A pointer to the Unicode\r
426 string from UnicodeStringTable\r
427 that matches the language\r
428 specified by Language.\r
429\r
430 @param Iso639Language Specify the language code\r
431 format supported. If true,\r
432 then the format follow ISO\r
433 639-2. If false, then it\r
434 follows RFC3066.\r
435\r
436 @retval EFI_SUCCESS The Unicode string that\r
437 matches the language specified\r
438 by Language was found in the\r
439 table of Unicoide strings\r
440 UnicodeStringTable, and it was\r
441 returned in UnicodeString.\r
442 \r
443 @retval EFI_INVALID_PARAMETER Language is NULL.\r
444 \r
445 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
446 \r
447 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
448 \r
449 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.\r
450 \r
451 @retval EFI_UNSUPPORTED The language specified by\r
452 Language is not a member\r
453 ofSupportedLanguages.\r
454 \r
455 @retval EFI_UNSUPPORTED The language specified by\r
456 Language is not supported by\r
457 UnicodeStringTable.\r
458\r
459**/\r
460EFI_STATUS\r
461EFIAPI\r
462LookupUnicodeString2 (\r
463 IN CONST CHAR8 *Language,\r
464 IN CONST CHAR8 *SupportedLanguages,\r
465 IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,\r
466 OUT CHAR16 **UnicodeString,\r
467 IN BOOLEAN Iso639Language\r
ed66e1bc 468 );\r
a73480f6 469\r
fb3df220 470/**\r
471 This function adds a Unicode string to UnicodeStringTable.\r
472 If Language is a member of SupportedLanguages then UnicodeString is added to \r
473 UnicodeStringTable. New buffers are allocated for both Language and \r
474 UnicodeString. The contents of Language and UnicodeString are copied into \r
475 these new buffers. These buffers are automatically freed when \r
476 FreeUnicodeStringTable() is called.\r
477\r
478 @param Language A pointer to the ISO 639-2 language code for the Unicode \r
479 string to add.\r
480 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes\r
481 that the Unicode string table supports.\r
482 Language must be a member of this set.\r
483 @param UnicodeStringTable A pointer to the table of Unicode strings.\r
484 @param UnicodeString A pointer to the Unicode string to add.\r
485\r
486 @retval EFI_SUCCESS The Unicode string that matches the language \r
487 specified by Language was found in the table of \r
488 Unicode strings UnicodeStringTable, and it was \r
489 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_INVALID_PARAMETER UnicodeString is an empty string.\r
493 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
494 @retval EFI_ALREADY_STARTED A Unicode string with language Language is \r
495 already present in UnicodeStringTable.\r
496 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another \r
497 Unicode string to UnicodeStringTable.\r
498 @retval EFI_UNSUPPORTED The language specified by Language is not a \r
499 member of SupportedLanguages.\r
500\r
501**/\r
502EFI_STATUS\r
503EFIAPI\r
504AddUnicodeString (\r
505 IN CONST CHAR8 *Language,\r
506 IN CONST CHAR8 *SupportedLanguages,\r
507 IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable,\r
508 IN CONST CHAR16 *UnicodeString\r
509 );\r
510\r
a73480f6 511/**\r
512 \r
513 This function adds a Unicode string to UnicodeStringTable.\r
514 If Language is a member of SupportedLanguages then\r
515 UnicodeString is added to UnicodeStringTable. New buffers are\r
516 allocated for both Language and UnicodeString. The contents\r
517 of Language and UnicodeString are copied into these new\r
518 buffers. These buffers are automatically freed when\r
519 FreeUnicodeStringTable() is called.\r
520\r
521 @param Language A pointer to the ISO 639-2 or\r
522 RFC 3066 language code for the\r
523 Unicode string to add.\r
524 \r
525 @param SupportedLanguages A pointer to the set of ISO\r
0c9d7395 526 639-2 or RFC 3066 language\r
a73480f6 527 codes that the Unicode string\r
528 table supports. Language must\r
529 be a member of this set.\r
530 \r
531 @param UnicodeStringTable A pointer to the table of\r
532 Unicode strings.\r
533 \r
534 @param UnicodeString A pointer to the Unicode\r
535 string to add.\r
536 \r
537 @param Iso639Language Specify the language code\r
538 format supported. If true,\r
539 then the format follow ISO\r
540 639-2. If false, then it\r
541 follows RFC3066.\r
542\r
543 @retval EFI_SUCCESS The Unicode string that\r
544 matches the language specified\r
545 by Language was found in the\r
546 table of Unicode strings\r
547 UnicodeStringTable, and it was\r
548 returned in UnicodeString.\r
549 \r
550 @retval EFI_INVALID_PARAMETER Language is NULL.\r
551 \r
552 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
553 \r
554 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.\r
555 \r
556 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
557 \r
558 @retval EFI_ALREADY_STARTED A Unicode string with language\r
559 Language is already present in\r
560 UnicodeStringTable.\r
561 \r
562 @retval EFI_OUT_OF_RESOURCES There is not enough memory to\r
563 add another Unicode string to\r
564 UnicodeStringTable.\r
565 \r
566 @retval EFI_UNSUPPORTED The language specified by\r
567 Language is not a member of\r
568 SupportedLanguages.\r
569\r
570**/\r
571EFI_STATUS\r
572EFIAPI\r
573AddUnicodeString2 (\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 IN BOOLEAN Iso639Language\r
ed66e1bc 579 );\r
a73480f6 580\r
fb3df220 581/**\r
582 This function frees the table of Unicode strings in UnicodeStringTable.\r
583 If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.\r
584 Otherwise, each language code, and each Unicode string in the Unicode string \r
585 table are freed, and EFI_SUCCESS is returned.\r
586\r
587 @param UnicodeStringTable A pointer to the table of Unicode strings.\r
588\r
589 @retval EFI_SUCCESS The Unicode string table was freed.\r
590\r
591**/\r
592EFI_STATUS\r
593EFIAPI\r
594FreeUnicodeStringTable (\r
595 IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable\r
596 );\r
597\r
598/**\r
599 This function computes and returns the width of the Unicode character \r
600 specified by UnicodeChar.\r
601\r
602 @param UnicodeChar A Unicode character.\r
603\r
604 @retval 0 The width if UnicodeChar could not be determined.\r
605 @retval 1 UnicodeChar is a narrow glyph.\r
606 @retval 2 UnicodeChar is a wide glyph.\r
607\r
608**/\r
609UINTN\r
610EFIAPI\r
611GetGlyphWidth (\r
612 IN CHAR16 UnicodeChar\r
613 );\r
614\r
615/**\r
616 This function computes and returns the display length of\r
617 the Null-terminated Unicode string specified by String.\r
618 If String is NULL, then 0 is returned.\r
619 If any of the widths of the Unicode characters in String\r
620 can not be determined, then 0 is returned.\r
621\r
622 @param String A pointer to a Null-terminated Unicode string.\r
623\r
624 @return The display length of the Null-terminated Unicode string specified by String.\r
625 \r
626**/\r
627UINTN\r
628EFIAPI\r
629UnicodeStringDisplayLength (\r
630 IN CONST CHAR16 *String\r
631 );\r
632\r
633//\r
634// Functions that abstract early Framework contamination of UEFI.\r
635//\r
636/**\r
637 Signal a Ready to Boot Event. \r
638 \r
639 Create a Ready to Boot Event. Signal it and close it. This causes other \r
640 events of the same event group to be signaled in other modules. \r
641\r
642**/\r
643VOID\r
644EFIAPI\r
645EfiSignalEventReadyToBoot (\r
646 VOID\r
647 );\r
648\r
649/**\r
650 Signal a Legacy Boot Event. \r
651 \r
652 Create a legacy Boot Event. Signal it and close it. This causes other \r
653 events of the same event group to be signaled in other modules. \r
654\r
655**/\r
656VOID\r
657EFIAPI\r
658EfiSignalEventLegacyBoot (\r
659 VOID\r
660 );\r
661\r
662/**\r
7f1eba7b 663 Creates an EFI event in the Legacy Boot Event Group. Prior to UEFI 2.0 this \r
664 was done via a non blessed UEFI extensions and this library abstracts the \r
665 implementation mechanism of this event from the caller.\r
fb3df220 666 \r
7f1eba7b 667 This function abstracts the creation of the Legacy Boot Event. The Framework \r
668 moved from a proprietary to UEFI 2.0 based mechanism. This library abstracts \r
669 the caller from how this event is created to prevent to code form having to \r
670 change with the version of the specification supported.\r
671 If LegacyBootEvent is NULL, then ASSERT().\r
fb3df220 672\r
673 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
674\r
675 @retval EFI_SUCCESS Event was created.\r
676 @retval Other Event was not created.\r
677\r
678**/\r
679EFI_STATUS\r
680EFIAPI\r
681EfiCreateEventLegacyBoot (\r
682 OUT EFI_EVENT *LegacyBootEvent\r
683 );\r
684\r
685/**\r
686 Create an EFI event in the Legacy Boot Event Group and allows\r
687 the caller to specify a notification function. \r
688 \r
689 This function abstracts the creation of the Legacy Boot Event.\r
690 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
691 This library abstracts the caller from how this event is created to prevent\r
692 to code form having to change with the version of the specification supported.\r
693 If LegacyBootEvent is NULL, then ASSERT().\r
694\r
695 @param NotifyTpl The task priority level of the event.\r
696 @param NotifyFunction The notification function to call when the event is signaled.\r
697 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
698 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
699\r
700 @retval EFI_SUCCESS Event was created.\r
701 @retval Other Event was not created.\r
702\r
703**/\r
704EFI_STATUS\r
705EFIAPI\r
706EfiCreateEventLegacyBootEx (\r
707 IN EFI_TPL NotifyTpl,\r
708 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
709 IN VOID *NotifyContext, OPTIONAL\r
710 OUT EFI_EVENT *LegacyBootEvent\r
711 );\r
712\r
713/**\r
7f1eba7b 714 Create an EFI event in the Ready To Boot Event Group. Prior to UEFI 2.0 this \r
715 was done via a non-standard UEFI extension, and this library abstracts the \r
716 implementation mechanism of this event from the caller. \r
fb3df220 717 \r
7f1eba7b 718 This function abstracts the creation of the Ready to Boot Event. The Framework \r
719 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts \r
720 the caller from how this event is created to prevent the code form having to \r
721 change with the version of the specification supported.\r
722 If ReadyToBootEvent is NULL, then ASSERT().\r
fb3df220 723\r
01aef47b 724 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
fb3df220 725\r
726 @retval EFI_SUCCESS Event was created.\r
727 @retval Other Event was not created.\r
728\r
729**/\r
730EFI_STATUS\r
731EFIAPI\r
732EfiCreateEventReadyToBoot (\r
733 OUT EFI_EVENT *ReadyToBootEvent\r
734 );\r
735\r
736/**\r
737 Create an EFI event in the Ready To Boot Event Group and allows\r
738 the caller to specify a notification function. \r
739 \r
740 This function abstracts the creation of the Ready to Boot Event.\r
741 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
742 This library abstracts the caller from how this event is created to prevent\r
743 to code form having to change with the version of the specification supported.\r
744 If ReadyToBootEvent is NULL, then ASSERT().\r
745\r
746 @param NotifyTpl The task priority level of the event.\r
747 @param NotifyFunction The notification function to call when the event is signaled.\r
748 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
01aef47b 749 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
fb3df220 750\r
751 @retval EFI_SUCCESS Event was created.\r
752 @retval Other Event was not created.\r
753\r
754**/\r
755EFI_STATUS\r
756EFIAPI\r
757EfiCreateEventReadyToBootEx (\r
758 IN EFI_TPL NotifyTpl,\r
759 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
760 IN VOID *NotifyContext, OPTIONAL\r
761 OUT EFI_EVENT *ReadyToBootEvent\r
762 );\r
763\r
764/**\r
765 Initialize a Firmware Volume (FV) Media Device Path node.\r
766 \r
7f1eba7b 767 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification. \r
768 This library function abstracts initializing a device path node.\r
769 \r
770 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device \r
771 path changed in the DXE CIS version 0.92 in a non back ward compatible way to \r
772 not conflict with the UEFI 2.0 specification. This function abstracts the \r
773 differences from the caller.\r
774 \r
775 If FvDevicePathNode is NULL, then ASSERT().\r
776 If NameGuid is NULL, then ASSERT().\r
777 \r
fb3df220 778 @param FvDevicePathNode Pointer to a FV device path node to initialize\r
779 @param NameGuid FV file name to use in FvDevicePathNode\r
780\r
781**/\r
782VOID\r
783EFIAPI\r
784EfiInitializeFwVolDevicepathNode (\r
785 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r
786 IN CONST EFI_GUID *NameGuid\r
787 );\r
788\r
789/**\r
790 Check to see if the Firmware Volume (FV) Media Device Path is valid \r
791 \r
7f1eba7b 792 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification. \r
793 This library function abstracts validating a device path node.\r
794 \r
795 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid. \r
796 If it is valid, then return the GUID file name from the device path node. Otherwise, \r
797 return NULL. This device path changed in the DXE CIS version 0.92 in a non back ward \r
798 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts \r
799 the differences from the caller.\r
800 If FvDevicePathNode is NULL, then ASSERT().\r
fb3df220 801\r
802 @param FvDevicePathNode Pointer to FV device path to check.\r
803\r
804 @retval NULL FvDevicePathNode is not valid.\r
805 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r
806\r
807**/\r
808EFI_GUID *\r
809EFIAPI\r
810EfiGetNameGuidFromFwVolDevicePathNode (\r
811 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r
812 );\r
813\r
814/** \r
815 Prints a formatted Unicode string to the console output device specified by \r
816 ConOut defined in the EFI_SYSTEM_TABLE.\r
817\r
818 This function prints a formatted Unicode string to the console output device \r
819 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode \r
820 characters that printed to ConOut. If the length of the formatted Unicode \r
821 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
822 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
823\r
824 @param Format Null-terminated Unicode format string.\r
825 @param ... VARARG list consumed to process Format.\r
826 If Format is NULL, then ASSERT().\r
827 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
9199040c 828 \r
829 @return Number of Unicode characters printed to ConOut.\r
fb3df220 830\r
831**/\r
832UINTN\r
833EFIAPI\r
834Print (\r
835 IN CONST CHAR16 *Format,\r
836 ...\r
837 );\r
838\r
839/** \r
840 Prints a formatted Unicode string to the console output device specified by \r
841 StdErr defined in the EFI_SYSTEM_TABLE.\r
842\r
843 This function prints a formatted Unicode string to the console output device \r
844 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode \r
845 characters that printed to StdErr. If the length of the formatted Unicode \r
846 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
847 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
848\r
849 @param Format Null-terminated Unicode format string.\r
850 @param ... VARARG list consumed to process Format.\r
851 If Format is NULL, then ASSERT().\r
852 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
9199040c 853 \r
854 @return Number of Unicode characters printed to StdErr.\r
fb3df220 855\r
856**/\r
857UINTN\r
858EFIAPI\r
859ErrorPrint (\r
860 IN CONST CHAR16 *Format,\r
861 ...\r
862 );\r
863\r
864/** \r
865 Prints a formatted ASCII string to the console output device specified by \r
866 ConOut defined in the EFI_SYSTEM_TABLE.\r
867\r
868 This function prints a formatted ASCII string to the console output device \r
869 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII \r
870 characters that printed to ConOut. If the length of the formatted ASCII \r
871 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
872 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
873\r
874 @param Format Null-terminated ASCII format string.\r
875 @param ... VARARG list consumed to process Format.\r
876 If Format is NULL, then ASSERT().\r
877 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
9199040c 878 \r
879 @return Number of ASCII characters printed to ConOut.\r
fb3df220 880\r
881**/\r
882UINTN\r
883EFIAPI\r
884AsciiPrint (\r
885 IN CONST CHAR8 *Format,\r
886 ...\r
887 );\r
888\r
889/** \r
890 Prints a formatted ASCII string to the console output device specified by \r
891 StdErr defined in the EFI_SYSTEM_TABLE.\r
892\r
893 This function prints a formatted ASCII string to the console output device \r
894 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII \r
895 characters that printed to StdErr. If the length of the formatted ASCII \r
896 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
897 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
898\r
899 @param Format Null-terminated ASCII format string.\r
900 @param ... VARARG list consumed to process Format.\r
901 If Format is NULL, then ASSERT().\r
902 If Format is not aligned on a 16-bit boundary, then ASSERT().\r
9199040c 903 \r
904 @return Number of ASCII characters printed to ConErr.\r
fb3df220 905\r
906**/\r
907UINTN\r
908EFIAPI\r
909AsciiErrorPrint (\r
910 IN CONST CHAR8 *Format,\r
911 ...\r
912 );\r
913\r
c7d265a9 914/**\r
0c9d7395 915 Initializes a driver by installing the Driver Binding Protocol onto the driver's\r
f662c194 916 DriverBindingHandle. This is typically the same as the driver's ImageHandle, but\r
917 it can be different if the driver produces multiple DriverBinding Protocols. \r
0c9d7395 918 If the Driver Binding Protocol interface is NULL, then ASSERT (). \r
f662c194 919 If the installation fails, then ASSERT ().\r
c7d265a9 920\r
f662c194 921 @param ImageHandle The image handle of the driver.\r
922 @param SystemTable The EFI System Table that was passed to the driver's entry point.\r
923 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.\r
0c9d7395 924 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this\r
f662c194 925 parameter is NULL, then a new handle is created.\r
c7d265a9 926\r
f662c194 927 @retval EFI_SUCCESS The protocol installation is completed successfully.\r
928 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().\r
c7d265a9 929\r
930**/\r
931EFI_STATUS\r
932EFIAPI\r
933EfiLibInstallDriverBinding (\r
934 IN CONST EFI_HANDLE ImageHandle,\r
935 IN CONST EFI_SYSTEM_TABLE *SystemTable,\r
936 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
937 IN EFI_HANDLE DriverBindingHandle\r
938 );\r
939\r
c7d265a9 940\r
f662c194 941/**\r
0c9d7395 942 Initializes a driver by installing the Driver Binding Protocol together with the optional Component Name,\r
f662c194 943 Driver Configure and Driver Diagnostic Protocols onto the driver's DriverBindingHandle. This is\r
944 typically the same as the driver's ImageHandle, but it can be different if the driver produces multiple\r
945 DriverBinding Protocols. \r
0c9d7395 946 If the Driver Binding Protocol interface is NULL, then ASSERT (). \r
f662c194 947 If the installation fails, then ASSERT ().\r
948\r
949 @param ImageHandle The image handle of the driver.\r
950 @param SystemTable The EFI System Table that was passed to the driver's entry point.\r
951 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.\r
0c9d7395 952 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this\r
f662c194 953 parameter is NULL, then a new handle is created.\r
954 @param ComponentName A Component Name Protocol instance that this driver is producing.\r
955 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.\r
956 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.\r
957\r
958 @retval EFI_SUCCESS The protocol installation is completed successfully.\r
959 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().\r
c7d265a9 960\r
961**/\r
962EFI_STATUS\r
963EFIAPI\r
964EfiLibInstallAllDriverProtocols (\r
965 IN CONST EFI_HANDLE ImageHandle,\r
966 IN CONST EFI_SYSTEM_TABLE *SystemTable,\r
967 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
968 IN EFI_HANDLE DriverBindingHandle,\r
969 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
970 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL\r
971 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL\r
972 );\r
973\r
974\r
f662c194 975\r
c7d265a9 976/**\r
0c9d7395 977 Initializes a driver by installing the Driver Binding Protocol together with the optional Component Name,\r
f662c194 978 Component Name 2 onto the driver's DriverBindingHandle. This is typically the same as the driver's\r
979 ImageHandle, but it can be different if the driver produces multiple DriverBinding Protocols. \r
0c9d7395 980 If the Driver Binding Protocol interface is NULL, then ASSERT (). \r
f662c194 981 If the installation fails, then ASSERT ().\r
982\r
983 @param ImageHandle The image handle of the driver.\r
984 @param SystemTable The EFI System Table that was passed to the driver's entry point.\r
985 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.\r
0c9d7395 986 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this\r
f662c194 987 parameter is NULL, then a new handle is created.\r
988 @param ComponentName A Component Name Protocol instance that this driver is producing.\r
989 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.\r
c7d265a9 990\r
f662c194 991 @retval EFI_SUCCESS The protocol installation is completed successfully.\r
992 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().\r
993\r
994**/\r
995EFI_STATUS\r
996EFIAPI\r
997EfiLibInstallDriverBindingComponentName2 (\r
998 IN CONST EFI_HANDLE ImageHandle,\r
999 IN CONST EFI_SYSTEM_TABLE *SystemTable,\r
1000 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
1001 IN EFI_HANDLE DriverBindingHandle,\r
1002 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
1003 IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL\r
1004 );\r
1005\r
1006\r
1007/**\r
def220c4 1008 Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name,\r
f662c194 1009 Component Name 2, Driver Configure, Driver Diagnostic and Driver Diagnostic 2 Protocols onto the driver's\r
1010 DriverBindingHandle. This is typically the same as the driver's ImageHandle, but it can be different if\r
1011 the driver produces multiple DriverBinding Protocols. \r
def220c4 1012 If the Drvier Binding Protocol interface is NULL, then ASSERT (). \r
f662c194 1013 If the installation fails, then ASSERT ().\r
1014\r
1015 @param ImageHandle The image handle of the driver.\r
1016 @param SystemTable The EFI System Table that was passed to the driver's entry point.\r
1017 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.\r
def220c4 1018 @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this\r
f662c194 1019 parameter is NULL, then a new handle is created.\r
1020 @param ComponentName A Component Name Protocol instance that this driver is producing.\r
1021 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.\r
1022 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.\r
def220c4 1023 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver is producing.\r
f662c194 1024 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.\r
1025 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing.\r
1026\r
1027 @retval EFI_SUCCESS The protocol installation is completed successfully.\r
1028 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().\r
c7d265a9 1029\r
1030**/\r
1031EFI_STATUS\r
1032EFIAPI\r
1033EfiLibInstallAllDriverProtocols2 (\r
1034 IN CONST EFI_HANDLE ImageHandle,\r
1035 IN CONST EFI_SYSTEM_TABLE *SystemTable,\r
1036 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
1037 IN EFI_HANDLE DriverBindingHandle,\r
def220c4 1038 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
1039 IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL\r
1040 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL\r
1041 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration2, OPTIONAL\r
1042 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics, OPTIONAL\r
1043 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL\r
c7d265a9 1044 );\r
1045\r
f8d18bad 1046/**\r
1047 Determine what is the current language setting. The space reserved for Lang\r
1048 must be at least RFC_3066_ENTRY_SIZE bytes;\r
1049\r
1050 If Lang is NULL, then ASSERT.\r
1051\r
1052 @param Lang Pointer of system language. Lang will always be filled with \r
1053 a valid RFC 3066 language string. If "PlatformLang" is not\r
1054 set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang\r
1055 is returned.\r
1056\r
1057 @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.\r
1058 @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.\r
1059\r
1060**/\r
1061EFI_STATUS\r
1062EFIAPI\r
1063GetCurrentLanguage (\r
1064 OUT CHAR8 *Lang\r
1065 );\r
1066\r
1067\r
fb3df220 1068#endif\r