2 Provides library functions for common UEFI operations. Only available to DXE
5 The UEFI Library provides functions and macros that simplify the development of
6 UEFI Drivers and UEFI Applications. These functions and macros help manage EFI
7 events, build simple locks utilizing EFI Task Priority Levels (TPLs), install
8 EFI Driver Model related protocols, manage Unicode string tables for UEFI Drivers,
9 and print messages on the console output and standard error devices.
11 Copyright (c) 2006 - 2008, Intel Corporation<BR>
12 All rights reserved. This program and the accompanying materials
13 are licensed and made available under the terms and conditions of the BSD License
14 which accompanies this distribution. The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #ifndef __UEFI_LIB_H__
23 #define __UEFI_LIB_H__
25 #include <Protocol/DriverBinding.h>
26 #include <Protocol/DriverConfiguration.h>
27 #include <Protocol/ComponentName.h>
28 #include <Protocol/ComponentName2.h>
29 #include <Protocol/DriverDiagnostics.h>
30 #include <Protocol/DriverDiagnostics2.h>
31 #include <Protocol/GraphicsOutput.h>
33 #include <Library/BaseLib.h>
36 /// Unicode String Table
40 CHAR16
*UnicodeString
;
41 } EFI_UNICODE_STRING_TABLE
;
47 EfiLockUninitialized
= 0,
62 Macro that returns the number of 100 ns units for a specified number of microseconds.
63 Useful for managing EFI timer events.
65 @param Microseconds Number of microseonds.
67 @return The number of 100 ns units equivalent to the number of microseconds specified
71 #define EFI_TIMER_PERIOD_MICROSECONDS(Microseconds) MultU64x32((UINT64)(Microseconds), 10)
74 Macro that returns the number of 100 ns units for a specified number of milliseoconds.
75 Useful for managing EFI timer events.
77 @param Milliseconds Number of milliseconds.
79 @return The number of 100 ns units equivalent to the number of milliseconds specified
83 #define EFI_TIMER_PERIOD_MILLISECONDS(Milliseconds) MultU64x32((UINT64)(Milliseconds), 10000)
86 Macro that returns the number of 100 ns units for a specified number of seoconds.
87 Useful for managing EFI timer events.
89 @param Seconds Number of seconds.
91 @return The number of 100 ns units equivalent to the number of seconds specified
95 #define EFI_TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)
98 Macro that returns the a pointer to the next EFI_MEMORY_DESCRIPTOR in an array
99 returned from GetMemoryMap().
101 @param MemoryDescriptor A pointer to an EFI_MEMORY_DESCRIPTOR.
103 @param Size The size, in bytes, of the current EFI_MEMORY_DESCRIPTOR.
105 @return A pointer to the next EFI_MEMORY_DESCRIPTOR.
108 #define NEXT_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
109 ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) + (Size)))
112 Retrieves a pointer to the system configuration table from the EFI System Table
113 based on a specified GUID.
115 This function searches the list of configuration tables stored in the EFI System Table
116 for a table with a GUID that matches TableGuid. If a match is found, then a pointer to
117 the configuration table is returned in Table., and EFI_SUCCESS is returned. If a matching GUID
118 is not found, then EFI_NOT_FOUND is returned.
119 If TableGuid is NULL, then ASSERT().
120 If Table is NULL, then ASSERT().
122 @param TableGuid Pointer to table's GUID type..
123 @param Table Pointer to the table associated with TableGuid in the EFI System Table.
125 @retval EFI_SUCCESS A configuration table matching TableGuid was found.
126 @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.
131 EfiGetSystemConfigurationTable (
132 IN EFI_GUID
*TableGuid
,
137 Creates and returns a notification event and registers that event with all the protocol
138 instances specified by ProtocolGuid.
140 This function causes the notification function to be executed for every protocol of type
141 ProtocolGuid instance that exists in the system when this function is invoked. If there are
142 no instances of ProtocolGuid in the handle database at the time this function is invoked,
143 then the notification function is still executed one time. In addition, every time a protocol
144 of type ProtocolGuid instance is installed or reinstalled, the notification function is also
145 executed. This function returns the notification event that was created.
146 If ProtocolGuid is NULL, then ASSERT().
147 If NotifyTpl is not a legal TPL value, then ASSERT().
148 If NotifyFunction is NULL, then ASSERT().
149 If Registration is NULL, then ASSERT().
152 @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.
153 @param NotifyTpl Supplies the task priority level of the event notifications.
154 @param NotifyFunction Supplies the function to notify when the event is signaled.
155 @param NotifyContext The context parameter to pass to NotifyFunction.
156 @param Registration A pointer to a memory location to receive the registration value.
157 This value is passed to LocateHandle() to obtain new handles that
158 have been added that support the ProtocolGuid-specified protocol.
160 @return The notification event that was created.
165 EfiCreateProtocolNotifyEvent(
166 IN EFI_GUID
*ProtocolGuid
,
167 IN EFI_TPL NotifyTpl
,
168 IN EFI_EVENT_NOTIFY NotifyFunction
,
169 IN VOID
*NotifyContext
, OPTIONAL
170 OUT VOID
**Registration
174 Creates a named event that can be signaled with EfiNamedEventSignal().
176 This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.
177 This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more
178 listeners on the same event named by the GUID specified by Name.
179 If Name is NULL, then ASSERT().
180 If NotifyTpl is not a legal TPL value, then ASSERT().
181 If NotifyFunction is NULL, then ASSERT().
183 @param Name Supplies GUID name of the event.
184 @param NotifyTpl Supplies the task priority level of the event notifications.
185 @param NotifyFunction Supplies the function to notify when the event is signaled.
186 @param NotifyContext The context parameter to pass to NotifyFunction.
187 @param Registration A pointer to a memory location to receive the registration value.
189 @retval EFI_SUCCESS A named event was created.
190 @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event.
195 EfiNamedEventListen (
196 IN CONST EFI_GUID
*Name
,
197 IN EFI_TPL NotifyTpl
,
198 IN EFI_EVENT_NOTIFY NotifyFunction
,
199 IN CONST VOID
*NotifyContext
, OPTIONAL
200 OUT VOID
*Registration OPTIONAL
204 Signals a named event created with EfiNamedEventListen().
206 This function signals the named event specified by Name. The named event must have been
207 created with EfiNamedEventListen().
208 If Name is NULL, then ASSERT().
210 @param Name Supplies GUID name of the event.
212 @retval EFI_SUCCESS A named event was signaled.
213 @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event.
218 EfiNamedEventSignal (
219 IN CONST EFI_GUID
*Name
223 Returns the current TPL.
225 This function returns the current TPL. There is no EFI service to directly
226 retrieve the current TPL. Instead, the RaiseTPL() function is used to raise
227 the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level
228 can then immediately be restored back to the current TPL level with a call
231 @return The current TPL.
241 Initializes a basic mutual exclusion lock.
243 This function initializes a basic mutual exclusion lock to the released state
244 and returns the lock. Each lock provides mutual exclusion access at its task
245 priority level. Since there is no preemption or multiprocessor support in EFI,
246 acquiring the lock only consists of raising to the locks TPL.
247 If Lock is NULL, then ASSERT().
248 If Priority is not a valid TPL value, then ASSERT().
250 @param Lock A pointer to the lock data structure to initialize.
251 @param Priority EFI TPL associated with the lock.
259 IN OUT EFI_LOCK
*Lock
,
264 Initializes a basic mutual exclusion lock.
266 This macro initializes the contents of a basic mutual exclusion lock to the
267 released state. Each lock provides mutual exclusion access at its task
268 priority level. Since there is no preemption or multiprocessor support in EFI,
269 acquiring the lock only consists of raising to the locks TPL.
271 @param Priority The task priority level of the lock.
276 #define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \
277 {Priority, TPL_APPLICATION, EfiLockReleased }
281 Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state.
283 If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set,
284 then this macro evaluates the EFI_LOCK structure specified by Lock. If Lock
285 is not in the locked state, then DebugAssert() is called passing in the source
286 filename, source line number, and Lock.
287 If Lock is NULL, then ASSERT().
289 @param LockParameter A pointer to the lock to acquire.
292 #define ASSERT_LOCKED(LockParameter) \
294 if (DebugAssertEnabled ()) { \
295 ASSERT (LockParameter != NULL); \
296 if ((LockParameter)->Lock != EfiLockAcquired) { \
297 _ASSERT (LockParameter not locked); \
304 Acquires ownership of a lock.
306 This function raises the system's current task priority level to the task
307 priority level of the mutual exclusion lock. Then, it places the lock in the
309 If Lock is NULL, then ASSERT().
310 If Lock is not initialized, then ASSERT().
311 If Lock is already in the acquired state, then ASSERT().
313 @param Lock A pointer to the lock to acquire.
323 Acquires ownership of a lock.
325 This function raises the system's current task priority level to the task priority
326 level of the mutual exclusion lock. Then, it attempts to place the lock in the acquired state.
327 If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.
328 Otherwise, EFI_SUCCESS is returned.
329 If Lock is NULL, then ASSERT().
330 If Lock is not initialized, then ASSERT().
332 @param Lock A pointer to the lock to acquire.
334 @retval EFI_SUCCESS The lock was acquired.
335 @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.
340 EfiAcquireLockOrFail (
345 Releases ownership of a lock.
347 This function transitions a mutual exclusion lock from the acquired state to
348 the released state, and restores the system's task priority level to its
350 If Lock is NULL, then ASSERT().
351 If Lock is not initialized, then ASSERT().
352 If Lock is already in the released state, then ASSERT().
354 @param Lock A pointer to the lock to release.
364 Tests whether a controller handle is being managed by a specific driver.
366 This function tests whether the driver specified by DriverBindingHandle is
367 currently managing the controller specified by ControllerHandle. This test
368 is performed by evaluating if the the protocol specified by ProtocolGuid is
369 present on ControllerHandle and is was opened by DriverBindingHandle with an
370 attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
371 If ProtocolGuid is NULL, then ASSERT().
373 @param ControllerHandle A handle for a controller to test.
374 @param DriverBindingHandle Specifies the driver binding handle for the
376 @param ProtocolGuid Specifies the protocol that the driver specified
377 by DriverBindingHandle opens in its Start()
380 @retval EFI_SUCCESS ControllerHandle is managed by the driver
381 specifed by DriverBindingHandle.
382 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
383 specifed by DriverBindingHandle.
388 EfiTestManagedDevice (
389 IN CONST EFI_HANDLE ControllerHandle
,
390 IN CONST EFI_HANDLE DriverBindingHandle
,
391 IN CONST EFI_GUID
*ProtocolGuid
395 Tests whether a child handle is a child device of the controller.
397 This function tests whether ChildHandle is one of the children of
398 ControllerHandle. This test is performed by checking to see if the protocol
399 specified by ProtocolGuid is present on ControllerHandle and opened by
400 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
401 If ProtocolGuid is NULL, then ASSERT().
403 @param ControllerHandle A handle for a (parent) controller to test.
404 @param ChildHandle A child handle to test.
405 @param ProtocolGuid Supplies the protocol that the child controller
406 opens on its parent controller.
408 @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle.
409 @retval EFI_UNSUPPORTED ChildHandle is not a child of the
416 IN CONST EFI_HANDLE ControllerHandle
,
417 IN CONST EFI_HANDLE ChildHandle
,
418 IN CONST EFI_GUID
*ProtocolGuid
422 This function looks up a Unicode string in UnicodeStringTable.
424 If Language is a member of SupportedLanguages and a Unicode string is found in
425 UnicodeStringTable that matches the language code specified by Language, then it
426 is returned in UnicodeString.
428 @param Language A pointer to the ISO 639-2 language code for the
429 Unicode string to look up and return.
430 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
431 that the Unicode string table supports. Language
432 must be a member of this set.
433 @param UnicodeStringTable A pointer to the table of Unicode strings.
434 @param UnicodeString A pointer to the Unicode string from UnicodeStringTable
435 that matches the language specified by Language.
437 @retval EFI_SUCCESS The Unicode string that matches the language
438 specified by Language was found
439 in the table of Unicoide strings UnicodeStringTable,
440 and it was returned in UnicodeString.
441 @retval EFI_INVALID_PARAMETER Language is NULL.
442 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
443 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
444 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
445 @retval EFI_UNSUPPORTED The language specified by Language is not a
446 member of SupportedLanguages.
447 @retval EFI_UNSUPPORTED The language specified by Language is not
448 supported by UnicodeStringTable.
453 LookupUnicodeString (
454 IN CONST CHAR8
*Language
,
455 IN CONST CHAR8
*SupportedLanguages
,
456 IN CONST EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
,
457 OUT CHAR16
**UnicodeString
461 This function looks up a Unicode string in UnicodeStringTable.
463 If Language is a member of SupportedLanguages and a Unicode string is found in
464 UnicodeStringTable that matches the language code specified by Language, then
465 it is returned in UnicodeString.
467 @param Language A pointer to an ASCII string containing the ISO 639-2 or the
468 RFC 4646 language code for the Unicode string to look up and
469 return. If Iso639Language is TRUE, then this ASCII string is
470 not assumed to be Null-terminated, and only the first three
471 chacters are used. If Iso639Language is FALSE, then this ASCII
472 string must be Null-terminated.
473 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains a
474 set of ISO 639-2 or RFC 4646 language codes that the Unicode
475 string table supports. Language must be a member of this set.
476 If Iso639Language is TRUE, then this string contains one or more
477 ISO 639-2 language codes with no separator characters. If Iso639Language
478 is FALSE, then is string contains one or more RFC 4646 language
479 codes separated by ';'.
480 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE
481 is defined in "Related Definitions".
482 @param UnicodeString A pointer to the Null-terminated Unicode string from UnicodeStringTable
483 that matches the language specified by Language.
484 @param Iso639Language Specifies the supported language code format. If it is TRUE, then
485 Language and SupportedLanguages follow ISO 639-2 language code format.
486 Otherwise, they follow RFC 4646 language code format.
489 @retval EFI_SUCCESS The Unicode string that matches the language specified by Language
490 was found in the table of Unicode strings UnicodeStringTable, and
491 it was returned in UnicodeString.
492 @retval EFI_INVALID_PARAMETER Language is NULL.
493 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
494 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
495 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
496 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.
497 @retval EFI_UNSUPPORTED The language specified by Language is not supported by UnicodeStringTable.
502 LookupUnicodeString2 (
503 IN CONST CHAR8
*Language
,
504 IN CONST CHAR8
*SupportedLanguages
,
505 IN CONST EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
,
506 OUT CHAR16
**UnicodeString
,
507 IN BOOLEAN Iso639Language
511 This function adds a Unicode string to UnicodeStringTable.
513 If Language is a member of SupportedLanguages then UnicodeString is added to
514 UnicodeStringTable. New buffers are allocated for both Language and
515 UnicodeString. The contents of Language and UnicodeString are copied into
516 these new buffers. These buffers are automatically freed when
517 FreeUnicodeStringTable() is called.
519 @param Language A pointer to the ISO 639-2 language code for the Unicode
521 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
522 that the Unicode string table supports.
523 Language must be a member of this set.
524 @param UnicodeStringTable A pointer to the table of Unicode strings.
525 @param UnicodeString A pointer to the Unicode string to add.
527 @retval EFI_SUCCESS The Unicode string that matches the language
528 specified by Language was found in the table of
529 Unicode strings UnicodeStringTable, and it was
530 returned in UnicodeString.
531 @retval EFI_INVALID_PARAMETER Language is NULL.
532 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
533 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
534 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
535 @retval EFI_ALREADY_STARTED A Unicode string with language Language is
536 already present in UnicodeStringTable.
537 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another
538 Unicode string to UnicodeStringTable.
539 @retval EFI_UNSUPPORTED The language specified by Language is not a
540 member of SupportedLanguages.
546 IN CONST CHAR8
*Language
,
547 IN CONST CHAR8
*SupportedLanguages
,
548 IN EFI_UNICODE_STRING_TABLE
**UnicodeStringTable
,
549 IN CONST CHAR16
*UnicodeString
553 This function adds the Null-terminated Unicode string specified by UnicodeString
554 to UnicodeStringTable.
556 If Language is a member of SupportedLanguages then UnicodeString is added to
557 UnicodeStringTable. New buffers are allocated for both Language and UnicodeString.
558 The contents of Language and UnicodeString are copied into these new buffers.
559 These buffers are automatically freed when EfiLibFreeUnicodeStringTable() is called.
561 @param Language A pointer to an ASCII string containing the ISO 639-2 or
562 the RFC 4646 language code for the Unicode string to add.
563 If Iso639Language is TRUE, then this ASCII string is not
564 assumed to be Null-terminated, and only the first three
565 chacters are used. If Iso639Language is FALSE, then this
566 ASCII string must be Null-terminated.
567 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains
568 a set of ISO 639-2 or RFC 4646 language codes that the Unicode
569 string table supports. Language must be a member of this set.
570 If Iso639Language is TRUE, then this string contains one or more
571 ISO 639-2 language codes with no separator characters.
572 If Iso639Language is FALSE, then is string contains one or more
573 RFC 4646 language codes separated by ';'.
574 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE
575 is defined in "Related Definitions".
576 @param UnicodeString A pointer to the Unicode string to add.
577 @param Iso639Language Specifies the supported language code format. If it is TRUE,
578 then Language and SupportedLanguages follow ISO 639-2 language code format.
579 Otherwise, they follow RFC 4646 language code format.
581 @retval EFI_SUCCESS The Unicode string that matches the language specified by
582 Language was found in the table of Unicode strings UnicodeStringTable,
583 and it was returned in UnicodeString.
584 @retval EFI_INVALID_PARAMETER Language is NULL.
585 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
586 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
587 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
588 @retval EFI_ALREADY_STARTED A Unicode string with language Language is already present in
590 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another Unicode string UnicodeStringTable.
591 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.
597 IN CONST CHAR8
*Language
,
598 IN CONST CHAR8
*SupportedLanguages
,
599 IN EFI_UNICODE_STRING_TABLE
**UnicodeStringTable
,
600 IN CONST CHAR16
*UnicodeString
,
601 IN BOOLEAN Iso639Language
605 This function frees the table of Unicode strings in UnicodeStringTable.
607 If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.
608 Otherwise, each language code, and each Unicode string in the Unicode string
609 table are freed, and EFI_SUCCESS is returned.
611 @param UnicodeStringTable A pointer to the table of Unicode strings.
613 @retval EFI_SUCCESS The Unicode string table was freed.
618 FreeUnicodeStringTable (
619 IN EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
623 Retrieves the width of a Unicode character.
625 This function computes and returns the width of the Unicode character specified
628 @param UnicodeChar A Unicode character.
630 @retval 0 The width if UnicodeChar could not be determined.
631 @retval 1 UnicodeChar is a narrow glyph.
632 @retval 2 UnicodeChar is a wide glyph.
638 IN CHAR16 UnicodeChar
642 Computes the display length of a Null-terminated Unicode String.
644 This function computes and returns the display length of the Null-terminated Unicode
645 string specified by String. If String is NULL then 0 is returned. If any of the widths
646 of the Unicode characters in String can not be determined, then 0 is returned. The display
647 width of String can be computed by summing the display widths of each Unicode character
648 in String. Unicode characters that are narrow glyphs have a width of 1, and Unicode
649 characters that are width glyphs have a width of 2.
650 If String is not aligned on a 16-bit boundary, then ASSERT().
652 @param String A pointer to a Null-terminated Unicode string.
654 @return The display length of the Null-terminated Unicode string specified by String.
659 UnicodeStringDisplayLength (
660 IN CONST CHAR16
*String
664 // Functions that abstract early Framework contamination of UEFI.
667 Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().
669 This function abstracts the signaling of the Ready to Boot Event. The Framework moved
670 from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller
671 from how this event is created to prevent to code form having to change with the
672 version of the specification supported.
677 EfiSignalEventReadyToBoot (
682 Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().
684 This function abstracts the signaling of the Legacy Boot Event. The Framework moved from
685 a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how
686 this event is created to prevent to code form having to change with the version of the
687 specification supported.
692 EfiSignalEventLegacyBoot (
697 Creates an EFI event in the Legacy Boot Event Group.
699 Prior to UEFI 2.0 this was done via a non blessed UEFI extensions and this library
700 abstracts the implementation mechanism of this event from the caller. This function
701 abstracts the creation of the Legacy Boot Event. The Framework moved from a proprietary
702 to UEFI 2.0 based mechanism. This library abstracts the caller from how this event
703 is created to prevent to code form having to change with the version of the
704 specification supported.
705 If LegacyBootEvent is NULL, then ASSERT().
707 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
709 @retval EFI_SUCCESS Event was created.
710 @retval Other Event was not created.
715 EfiCreateEventLegacyBoot (
716 OUT EFI_EVENT
*LegacyBootEvent
720 Create an EFI event in the Legacy Boot Event Group and allows
721 the caller to specify a notification function.
723 This function abstracts the creation of the Legacy Boot Event.
724 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
725 This library abstracts the caller from how this event is created to prevent
726 to code form having to change with the version of the specification supported.
727 If LegacyBootEvent is NULL, then ASSERT().
729 @param NotifyTpl The task priority level of the event.
730 @param NotifyFunction The notification function to call when the event is signaled.
731 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
732 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
734 @retval EFI_SUCCESS Event was created.
735 @retval Other Event was not created.
740 EfiCreateEventLegacyBootEx (
741 IN EFI_TPL NotifyTpl
,
742 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
743 IN VOID
*NotifyContext
, OPTIONAL
744 OUT EFI_EVENT
*LegacyBootEvent
748 Create an EFI event in the Ready To Boot Event Group.
750 Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library
751 abstracts the implementation mechanism of this event from the caller.
752 This function abstracts the creation of the Ready to Boot Event. The Framework
753 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts
754 the caller from how this event is created to prevent the code form having to
755 change with the version of the specification supported.
756 If ReadyToBootEvent is NULL, then ASSERT().
758 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
760 @retval EFI_SUCCESS Event was created.
761 @retval Other Event was not created.
766 EfiCreateEventReadyToBoot (
767 OUT EFI_EVENT
*ReadyToBootEvent
771 Create an EFI event in the Ready To Boot Event Group and allows
772 the caller to specify a notification function.
774 This function abstracts the creation of the Ready to Boot Event.
775 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
776 This library abstracts the caller from how this event is created to prevent
777 to code form having to change with the version of the specification supported.
778 If ReadyToBootEvent is NULL, then ASSERT().
780 @param NotifyTpl The task priority level of the event.
781 @param NotifyFunction The notification function to call when the event is signaled.
782 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
783 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
785 @retval EFI_SUCCESS Event was created.
786 @retval Other Event was not created.
791 EfiCreateEventReadyToBootEx (
792 IN EFI_TPL NotifyTpl
,
793 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
794 IN VOID
*NotifyContext
, OPTIONAL
795 OUT EFI_EVENT
*ReadyToBootEvent
799 Initialize a Firmware Volume (FV) Media Device Path node.
801 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
802 This library function abstracts initializing a device path node.
803 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device
804 path changed in the DXE CIS version 0.92 in a non back ward compatible way to
805 not conflict with the UEFI 2.0 specification. This function abstracts the
806 differences from the caller.
807 If FvDevicePathNode is NULL, then ASSERT().
808 If NameGuid is NULL, then ASSERT().
810 @param FvDevicePathNode Pointer to a FV device path node to initialize
811 @param NameGuid FV file name to use in FvDevicePathNode
816 EfiInitializeFwVolDevicepathNode (
817 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
818 IN CONST EFI_GUID
*NameGuid
822 Check to see if the Firmware Volume (FV) Media Device Path is valid
824 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
825 This library function abstracts validating a device path node.
826 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.
827 If it is valid, then return the GUID file name from the device path node. Otherwise,
828 return NULL. This device path changed in the DXE CIS version 0.92 in a non back ward
829 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts
830 the differences from the caller.
831 If FvDevicePathNode is NULL, then ASSERT().
833 @param FvDevicePathNode Pointer to FV device path to check.
835 @retval NULL FvDevicePathNode is not valid.
836 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
841 EfiGetNameGuidFromFwVolDevicePathNode (
842 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
846 Prints a formatted Unicode string to the console output device specified by
847 ConOut defined in the EFI_SYSTEM_TABLE.
849 This function prints a formatted Unicode string to the console output device
850 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
851 characters that printed to ConOut. If the length of the formatted Unicode
852 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
853 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
854 If Format is NULL, then ASSERT().
855 If Format is not aligned on a 16-bit boundary, then ASSERT().
857 @param Format Null-terminated Unicode format string.
858 @param ... Variable argument list whose contents are accessed based
859 on the format string specified by Format.
861 @return Number of Unicode characters printed to ConOut.
867 IN CONST CHAR16
*Format
,
872 Prints a formatted Unicode string to the console output device specified by
873 StdErr defined in the EFI_SYSTEM_TABLE.
875 This function prints a formatted Unicode string to the console output device
876 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
877 characters that printed to StdErr. If the length of the formatted Unicode
878 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
879 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
880 If Format is NULL, then ASSERT().
881 If Format is not aligned on a 16-bit boundary, then ASSERT().
883 @param Format Null-terminated Unicode format string.
884 @param ... Variable argument list whose contents are accessed based
885 on the format string specified by Format.
887 @return Number of Unicode characters printed to StdErr.
893 IN CONST CHAR16
*Format
,
898 Prints a formatted ASCII string to the console output device specified by
899 ConOut defined in the EFI_SYSTEM_TABLE.
901 This function prints a formatted ASCII string to the console output device
902 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
903 characters that printed to ConOut. If the length of the formatted ASCII
904 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
905 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
906 If Format is NULL, then ASSERT().
908 @param Format Null-terminated ASCII format string.
909 @param ... Variable argument list whose contents are accessed based
910 on the format string specified by Format.
912 @return Number of ASCII characters printed to ConOut.
918 IN CONST CHAR8
*Format
,
923 Prints a formatted ASCII string to the console output device specified by
924 StdErr defined in the EFI_SYSTEM_TABLE.
926 This function prints a formatted ASCII string to the console output device
927 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
928 characters that printed to StdErr. If the length of the formatted ASCII
929 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
930 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
931 If Format is NULL, then ASSERT().
933 @param Format Null-terminated ASCII format string.
934 @param ... Variable argument list whose contents are accessed based
935 on the format string specified by Format.
937 @return Number of ASCII characters printed to ConErr.
943 IN CONST CHAR8
*Format
,
948 Prints a formatted Unicode string to a graphics console device specified by
949 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
951 This function prints a formatted Unicode string to the graphics console device
952 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
953 Unicode characters printed. If the length of the formatted Unicode string is
954 greater than PcdUefiLibMaxPrintBufferSize, then only the first
955 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
956 is used to convert the string to a bitmap using the glyphs registered with the
957 HII database. No wrapping is performed, so any portions of the string the fall
958 outside the active display region will not be displayed.
960 If a graphics console device is not associated with the ConsoleOutputHandle
961 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
962 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
963 string is printed, and 0 is returned.
964 If Format is NULL, then ASSERT().
965 If Format is not aligned on a 16-bit boundary, then ASSERT().
967 @param X X coordinate to print the string.
968 @param Y Y coordinate to print the string.
969 @param ForeGround The forground color of the string being printed. This is
970 an optional parameter that may be NULL. If it is NULL,
971 then the foreground color of the current ConOut device
972 in the EFI_SYSTEM_TABLE is used.
973 @param BackGround The background color of the string being printed. This is
974 an optional parameter that may be NULL. If it is NULL,
975 then the background color of the current ConOut device
976 in the EFI_SYSTEM_TABLE is used.
977 @param Format Null-terminated Unicode format string. See Print Library
978 for the supported format string syntax.
979 @param ... Variable argument list whose contents are accessed based on
980 the format string specified by Format.
982 @return The number of Unicode characters printed.
990 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
991 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
992 IN CONST CHAR16
*Format
,
997 Prints a formatted ASCII string to a graphics console device specified by
998 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
1000 This function prints a formatted ASCII string to the graphics console device
1001 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
1002 ASCII characters printed. If the length of the formatted ASCII string is
1003 greater than PcdUefiLibMaxPrintBufferSize, then only the first
1004 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
1005 is used to convert the string to a bitmap using the glyphs registered with the
1006 HII database. No wrapping is performed, so any portions of the string the fall
1007 outside the active display region will not be displayed.
1009 If a graphics console device is not associated with the ConsoleOutputHandle
1010 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
1011 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
1012 string is printed, and 0 is returned.
1013 If Format is NULL, then ASSERT().
1015 @param X X coordinate to print the string.
1016 @param Y Y coordinate to print the string.
1017 @param ForeGround The forground color of the string being printed. This is
1018 an optional parameter that may be NULL. If it is NULL,
1019 then the foreground color of the current ConOut device
1020 in the EFI_SYSTEM_TABLE is used.
1021 @param BackGround The background color of the string being printed. This is
1022 an optional parameter that may be NULL. If it is NULL,
1023 then the background color of the current ConOut device
1024 in the EFI_SYSTEM_TABLE is used.
1025 @param Format Null-terminated ASCII format string. See Print Library
1026 for the supported format string syntax.
1027 @param ... Variable argument list whose contents are accessed based on
1028 the format string specified by Format.
1030 @return The number of ASCII characters printed.
1038 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
1039 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
1040 IN CONST CHAR8
*Format
,
1045 Installs and completes the initialization of a Driver Binding Protocol instance.
1047 Installs the Driver Binding Protocol specified by DriverBinding onto the handle
1048 specified by DriverBindingHandle. If DriverBindingHandle is NULL, then DriverBinding
1049 is installed onto a newly created handle. DriverBindingHandle is typically the same
1050 as the driver's ImageHandle, but it can be different if the driver produces multiple
1051 Driver Binding Protocols.
1052 If DriverBinding is NULL, then ASSERT().
1053 If DriverBinding can not be installed onto a handle, then ASSERT().
1055 @param ImageHandle The image handle of the driver.
1056 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1057 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1058 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1059 parameter is NULL, then a new handle is created.
1061 @retval EFI_SUCCESS The protocol installation is completed successfully.
1062 @retval EFI_OUT_OF_RESOURCES There was not enough system resources to install the protocol.
1063 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
1068 EfiLibInstallDriverBinding (
1069 IN CONST EFI_HANDLE ImageHandle
,
1070 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1071 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1072 IN EFI_HANDLE DriverBindingHandle
1077 Installs and completes the initialization of a Driver Binding Protocol instance and
1078 optionally installs the Component Name, Driver Configuration and Driver Diagnostics Protocols.
1080 Initializes a driver by installing the Driver Binding Protocol together with the
1081 optional Component Name, optional Driver Configure and optional Driver Diagnostic
1082 Protocols onto the driver's DriverBindingHandle. If DriverBindingHandle is NULL,
1083 then the protocols are installed onto a newly created handle. DriverBindingHandle
1084 is typically the same as the driver's ImageHandle, but it can be different if the
1085 driver produces multiple Driver Binding Protocols.
1086 If DriverBinding is NULL, then ASSERT().
1087 If the installation fails, then ASSERT().
1089 @param ImageHandle The image handle of the driver.
1090 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1091 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1092 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1093 parameter is NULL, then a new handle is created.
1094 @param ComponentName A Component Name Protocol instance that this driver is producing.
1095 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1096 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1098 @retval EFI_SUCCESS The protocol installation is completed successfully.
1099 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1104 EfiLibInstallAllDriverProtocols (
1105 IN CONST EFI_HANDLE ImageHandle
,
1106 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1107 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1108 IN EFI_HANDLE DriverBindingHandle
,
1109 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1110 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1111 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics OPTIONAL
1117 Installs Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.
1119 Initializes a driver by installing the Driver Binding Protocol together with the
1120 optional Component Name and optional Component Name 2 protocols onto the driver's
1121 DriverBindingHandle. If DriverBindingHandle is NULL, then the protocols are installed
1122 onto a newly created handle. DriverBindingHandle is typically the same as the driver's
1123 ImageHandle, but it can be different if the driver produces multiple Driver Binding Protocols.
1124 If DriverBinding is NULL, then ASSERT().
1125 If the installation fails, then ASSERT().
1127 @param ImageHandle The image handle of the driver.
1128 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1129 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1130 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1131 parameter is NULL, then a new handle is created.
1132 @param ComponentName A Component Name Protocol instance that this driver is producing.
1133 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1135 @retval EFI_SUCCESS The protocol installation is completed successfully.
1136 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1141 EfiLibInstallDriverBindingComponentName2 (
1142 IN CONST EFI_HANDLE ImageHandle
,
1143 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1144 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1145 IN EFI_HANDLE DriverBindingHandle
,
1146 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1147 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2 OPTIONAL
1152 Installs Driver Binding Protocol with optional Component Name, Component Name 2, Driver
1153 Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.
1155 Initializes a driver by installing the Driver Binding Protocol together with the optional
1156 Component Name, optional Component Name 2, optional Driver Configuration, optional Driver Configuration 2,
1157 optional Driver Diagnostic, and optional Driver Diagnostic 2 Protocols onto the driver's DriverBindingHandle.
1158 DriverBindingHandle is typically the same as the driver's ImageHandle, but it can be different if the driver
1159 produces multiple Driver Binding Protocols.
1160 If DriverBinding is NULL, then ASSERT().
1161 If the installation fails, then ASSERT().
1164 @param ImageHandle The image handle of the driver.
1165 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1166 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1167 @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this
1168 parameter is NULL, then a new handle is created.
1169 @param ComponentName A Component Name Protocol instance that this driver is producing.
1170 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1171 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1172 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver is producing.
1173 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1174 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing.
1176 @retval EFI_SUCCESS The protocol installation is completed successfully.
1177 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1182 EfiLibInstallAllDriverProtocols2 (
1183 IN CONST EFI_HANDLE ImageHandle
,
1184 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1185 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1186 IN EFI_HANDLE DriverBindingHandle
,
1187 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1188 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
, OPTIONAL
1189 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1190 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration2
, OPTIONAL
1191 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics
, OPTIONAL
1192 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL
*DriverDiagnostics2 OPTIONAL