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.
142 In addition, every time a protocol of type ProtocolGuid instance is installed or reinstalled,
143 the notification function is also executed. This function returns the notification event
145 If ProtocolGuid is NULL, then ASSERT().
146 If NotifyTpl is not a legal TPL value, then ASSERT().
147 If NotifyFunction is NULL, then ASSERT().
148 If Registration is NULL, then ASSERT().
150 @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.
151 @param NotifyTpl Supplies the task priority level of the event notifications.
152 @param NotifyFunction Supplies the function to notify when the event is signaled.
153 @param NotifyContext The context parameter to pass to NotifyFunction.
154 @param Registration A pointer to a memory location to receive the registration value.
155 This value is passed to LocateHandle() to obtain new handles that
156 have been added that support the ProtocolGuid-specified protocol.
158 @return The notification event that was created.
163 EfiCreateProtocolNotifyEvent(
164 IN EFI_GUID
*ProtocolGuid
,
165 IN EFI_TPL NotifyTpl
,
166 IN EFI_EVENT_NOTIFY NotifyFunction
,
167 IN VOID
*NotifyContext
, OPTIONAL
168 OUT VOID
**Registration
172 Creates a named event that can be signaled with EfiNamedEventSignal().
174 This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.
175 This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more
176 listeners on the same event named by the GUID specified by Name.
177 If Name is NULL, then ASSERT().
178 If NotifyTpl is not a legal TPL value, then ASSERT().
179 If NotifyFunction is NULL, then ASSERT().
181 @param Name Supplies GUID name of the event.
182 @param NotifyTpl Supplies the task priority level of the event notifications.
183 @param NotifyFunction Supplies the function to notify when the event is signaled.
184 @param NotifyContext The context parameter to pass to NotifyFunction.
185 @param Registration A pointer to a memory location to receive the registration value.
187 @retval EFI_SUCCESS A named event was created.
188 @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event.
193 EfiNamedEventListen (
194 IN CONST EFI_GUID
*Name
,
195 IN EFI_TPL NotifyTpl
,
196 IN EFI_EVENT_NOTIFY NotifyFunction
,
197 IN CONST VOID
*NotifyContext
, OPTIONAL
198 OUT VOID
*Registration OPTIONAL
202 Signals a named event created with EfiNamedEventListen().
204 This function signals the named event specified by Name. The named event must have been
205 created with EfiNamedEventListen().
206 If Name is NULL, then ASSERT().
208 @param Name Supplies GUID name of the event.
210 @retval EFI_SUCCESS A named event was signaled.
211 @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event.
216 EfiNamedEventSignal (
217 IN CONST EFI_GUID
*Name
221 Returns the current TPL.
223 This function returns the current TPL. There is no EFI service to directly
224 retrieve the current TPL. Instead, the RaiseTPL() function is used to raise
225 the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level
226 can then immediately be restored back to the current TPL level with a call
229 @return The current TPL.
239 Initializes a basic mutual exclusion lock.
241 This function initializes a basic mutual exclusion lock to the released state
242 and returns the lock. Each lock provides mutual exclusion access at its task
243 priority level. Since there is no preemption or multiprocessor support in EFI,
244 acquiring the lock only consists of raising to the locks TPL.
245 If Lock is NULL, then ASSERT().
246 If Priority is not a valid TPL value, then ASSERT().
248 @param Lock A pointer to the lock data structure to initialize.
249 @param Priority EFI TPL associated with the lock.
257 IN OUT EFI_LOCK
*Lock
,
262 Initializes a basic mutual exclusion lock.
264 This macro initializes the contents of a basic mutual exclusion lock to the
265 released state. Each lock provides mutual exclusion access at its task
266 priority level. Since there is no preemption or multiprocessor support in EFI,
267 acquiring the lock only consists of raising to the locks TPL.
269 @param Priority The task priority level of the lock.
274 #define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \
275 {Priority, TPL_APPLICATION, EfiLockReleased }
279 Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state.
281 If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set,
282 then this macro evaluates the EFI_LOCK structure specified by Lock. If Lock
283 is not in the locked state, then DebugAssert() is called passing in the source
284 filename, source line number, and Lock.
285 If Lock is NULL, then ASSERT().
287 @param LockParameter A pointer to the lock to acquire.
290 #define ASSERT_LOCKED(LockParameter) \
292 if (DebugAssertEnabled ()) { \
293 ASSERT (LockParameter != NULL); \
294 if ((LockParameter)->Lock != EfiLockAcquired) { \
295 _ASSERT (LockParameter not locked); \
302 Acquires ownership of a lock.
304 This function raises the system's current task priority level to the task
305 priority level of the mutual exclusion lock. Then, it places the lock in the
307 If Lock is NULL, then ASSERT().
308 If Lock is not initialized, then ASSERT().
309 If Lock is already in the acquired state, then ASSERT().
311 @param Lock A pointer to the lock to acquire.
321 Acquires ownership of a lock.
323 This function raises the system's current task priority level to the task priority
324 level of the mutual exclusion lock. Then, it attempts to place the lock in the acquired state.
325 If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.
326 Otherwise, EFI_SUCCESS is returned.
327 If Lock is NULL, then ASSERT().
328 If Lock is not initialized, then ASSERT().
330 @param Lock A pointer to the lock to acquire.
332 @retval EFI_SUCCESS The lock was acquired.
333 @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.
338 EfiAcquireLockOrFail (
343 Releases ownership of a lock.
345 This function transitions a mutual exclusion lock from the acquired state to
346 the released state, and restores the system's task priority level to its
348 If Lock is NULL, then ASSERT().
349 If Lock is not initialized, then ASSERT().
350 If Lock is already in the released state, then ASSERT().
352 @param Lock A pointer to the lock to release.
362 Tests whether a controller handle is being managed by a specific driver.
364 This function tests whether the driver specified by DriverBindingHandle is
365 currently managing the controller specified by ControllerHandle. This test
366 is performed by evaluating if the the protocol specified by ProtocolGuid is
367 present on ControllerHandle and is was opened by DriverBindingHandle with an
368 attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
369 If ProtocolGuid is NULL, then ASSERT().
371 @param ControllerHandle A handle for a controller to test.
372 @param DriverBindingHandle Specifies the driver binding handle for the
374 @param ProtocolGuid Specifies the protocol that the driver specified
375 by DriverBindingHandle opens in its Start()
378 @retval EFI_SUCCESS ControllerHandle is managed by the driver
379 specifed by DriverBindingHandle.
380 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
381 specifed by DriverBindingHandle.
386 EfiTestManagedDevice (
387 IN CONST EFI_HANDLE ControllerHandle
,
388 IN CONST EFI_HANDLE DriverBindingHandle
,
389 IN CONST EFI_GUID
*ProtocolGuid
393 Tests whether a child handle is a child device of the controller.
395 This function tests whether ChildHandle is one of the children of
396 ControllerHandle. This test is performed by checking to see if the protocol
397 specified by ProtocolGuid is present on ControllerHandle and opened by
398 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
399 If ProtocolGuid is NULL, then ASSERT().
401 @param ControllerHandle A handle for a (parent) controller to test.
402 @param ChildHandle A child handle to test.
403 @param ProtocolGuid Supplies the protocol that the child controller
404 opens on its parent controller.
406 @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle.
407 @retval EFI_UNSUPPORTED ChildHandle is not a child of the
414 IN CONST EFI_HANDLE ControllerHandle
,
415 IN CONST EFI_HANDLE ChildHandle
,
416 IN CONST EFI_GUID
*ProtocolGuid
420 This function looks up a Unicode string in UnicodeStringTable.
422 If Language is a member of SupportedLanguages and a Unicode string is found in
423 UnicodeStringTable that matches the language code specified by Language, then it
424 is returned in UnicodeString.
426 @param Language A pointer to the ISO 639-2 language code for the
427 Unicode string to look up and return.
428 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
429 that the Unicode string table supports. Language
430 must be a member of this set.
431 @param UnicodeStringTable A pointer to the table of Unicode strings.
432 @param UnicodeString A pointer to the Unicode string from UnicodeStringTable
433 that matches the language specified by Language.
435 @retval EFI_SUCCESS The Unicode string that matches the language
436 specified by Language was found
437 in the table of Unicoide strings UnicodeStringTable,
438 and it was returned in UnicodeString.
439 @retval EFI_INVALID_PARAMETER Language is NULL.
440 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
441 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
442 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
443 @retval EFI_UNSUPPORTED The language specified by Language is not a
444 member of SupportedLanguages.
445 @retval EFI_UNSUPPORTED The language specified by Language is not
446 supported by UnicodeStringTable.
451 LookupUnicodeString (
452 IN CONST CHAR8
*Language
,
453 IN CONST CHAR8
*SupportedLanguages
,
454 IN CONST EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
,
455 OUT CHAR16
**UnicodeString
459 This function looks up a Unicode string in UnicodeStringTable.
461 If Language is a member of SupportedLanguages and a Unicode string is found in
462 UnicodeStringTable that matches the language code specified by Language, then
463 it is returned in UnicodeString.
465 @param Language A pointer to an ASCII string containing the ISO 639-2 or the
466 RFC 4646 language code for the Unicode string to look up and
467 return. If Iso639Language is TRUE, then this ASCII string is
468 not assumed to be Null-terminated, and only the first three
469 chacters are used. If Iso639Language is FALSE, then this ASCII
470 string must be Null-terminated.
471 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains a
472 set of ISO 639-2 or RFC 4646 language codes that the Unicode
473 string table supports. Language must be a member of this set.
474 If Iso639Language is TRUE, then this string contains one or more
475 ISO 639-2 language codes with no separator characters. If Iso639Language
476 is FALSE, then is string contains one or more RFC 4646 language
477 codes separated by ';'.
478 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE
479 is defined in "Related Definitions".
480 @param UnicodeString A pointer to the Null-terminated Unicode string from UnicodeStringTable
481 that matches the language specified by Language.
482 @param Iso639Language Specifies the supported language code format. If it is TRUE, then
483 Language and SupportedLanguages follow ISO 639-2 language code format.
484 Otherwise, they follow RFC 4646 language code format.
487 @retval EFI_SUCCESS The Unicode string that matches the language specified by Language
488 was found in the table of Unicode strings UnicodeStringTable, and
489 it was returned in UnicodeString.
490 @retval EFI_INVALID_PARAMETER Language is NULL.
491 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
492 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
493 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
494 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.
495 @retval EFI_UNSUPPORTED The language specified by Language is not supported by UnicodeStringTable.
500 LookupUnicodeString2 (
501 IN CONST CHAR8
*Language
,
502 IN CONST CHAR8
*SupportedLanguages
,
503 IN CONST EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
,
504 OUT CHAR16
**UnicodeString
,
505 IN BOOLEAN Iso639Language
509 This function adds a Unicode string to UnicodeStringTable.
511 If Language is a member of SupportedLanguages then UnicodeString is added to
512 UnicodeStringTable. New buffers are allocated for both Language and
513 UnicodeString. The contents of Language and UnicodeString are copied into
514 these new buffers. These buffers are automatically freed when
515 FreeUnicodeStringTable() is called.
517 @param Language A pointer to the ISO 639-2 language code for the Unicode
519 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
520 that the Unicode string table supports.
521 Language must be a member of this set.
522 @param UnicodeStringTable A pointer to the table of Unicode strings.
523 @param UnicodeString A pointer to the Unicode string to add.
525 @retval EFI_SUCCESS The Unicode string that matches the language
526 specified by Language was found in the table of
527 Unicode strings UnicodeStringTable, and it was
528 returned in UnicodeString.
529 @retval EFI_INVALID_PARAMETER Language is NULL.
530 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
531 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
532 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
533 @retval EFI_ALREADY_STARTED A Unicode string with language Language is
534 already present in UnicodeStringTable.
535 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another
536 Unicode string to UnicodeStringTable.
537 @retval EFI_UNSUPPORTED The language specified by Language is not a
538 member of SupportedLanguages.
544 IN CONST CHAR8
*Language
,
545 IN CONST CHAR8
*SupportedLanguages
,
546 IN EFI_UNICODE_STRING_TABLE
**UnicodeStringTable
,
547 IN CONST CHAR16
*UnicodeString
551 This function adds the Null-terminated Unicode string specified by UnicodeString
552 to UnicodeStringTable.
554 If Language is a member of SupportedLanguages then UnicodeString is added to
555 UnicodeStringTable. New buffers are allocated for both Language and UnicodeString.
556 The contents of Language and UnicodeString are copied into these new buffers.
557 These buffers are automatically freed when EfiLibFreeUnicodeStringTable() is called.
559 @param Language A pointer to an ASCII string containing the ISO 639-2 or
560 the RFC 4646 language code for the Unicode string to add.
561 If Iso639Language is TRUE, then this ASCII string is not
562 assumed to be Null-terminated, and only the first three
563 chacters are used. If Iso639Language is FALSE, then this
564 ASCII string must be Null-terminated.
565 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains
566 a set of ISO 639-2 or RFC 4646 language codes that the Unicode
567 string table supports. Language must be a member of this set.
568 If Iso639Language is TRUE, then this string contains one or more
569 ISO 639-2 language codes with no separator characters.
570 If Iso639Language is FALSE, then is string contains one or more
571 RFC 4646 language codes separated by ';'.
572 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE
573 is defined in "Related Definitions".
574 @param UnicodeString A pointer to the Unicode string to add.
575 @param Iso639Language Specifies the supported language code format. If it is TRUE,
576 then Language and SupportedLanguages follow ISO 639-2 language code format.
577 Otherwise, they follow RFC 4646 language code format.
579 @retval EFI_SUCCESS The Unicode string that matches the language specified by
580 Language was found in the table of Unicode strings UnicodeStringTable,
581 and it was returned in UnicodeString.
582 @retval EFI_INVALID_PARAMETER Language is NULL.
583 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
584 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
585 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
586 @retval EFI_ALREADY_STARTED A Unicode string with language Language is already present in
588 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another Unicode string UnicodeStringTable.
589 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.
595 IN CONST CHAR8
*Language
,
596 IN CONST CHAR8
*SupportedLanguages
,
597 IN EFI_UNICODE_STRING_TABLE
**UnicodeStringTable
,
598 IN CONST CHAR16
*UnicodeString
,
599 IN BOOLEAN Iso639Language
603 This function frees the table of Unicode strings in UnicodeStringTable.
605 If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.
606 Otherwise, each language code, and each Unicode string in the Unicode string
607 table are freed, and EFI_SUCCESS is returned.
609 @param UnicodeStringTable A pointer to the table of Unicode strings.
611 @retval EFI_SUCCESS The Unicode string table was freed.
616 FreeUnicodeStringTable (
617 IN EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
621 Retrieves the width of a Unicode character.
623 This function computes and returns the width of the Unicode character specified
626 @param UnicodeChar A Unicode character.
628 @retval 0 The width if UnicodeChar could not be determined.
629 @retval 1 UnicodeChar is a narrow glyph.
630 @retval 2 UnicodeChar is a wide glyph.
636 IN CHAR16 UnicodeChar
640 Computes the display length of a Null-terminated Unicode String.
642 This function computes and returns the display length of the Null-terminated Unicode
643 string specified by String. If String is NULL then 0 is returned. If any of the widths
644 of the Unicode characters in String can not be determined, then 0 is returned. The display
645 width of String can be computed by summing the display widths of each Unicode character
646 in String. Unicode characters that are narrow glyphs have a width of 1, and Unicode
647 characters that are width glyphs have a width of 2.
648 If String is not aligned on a 16-bit boundary, then ASSERT().
650 @param String A pointer to a Null-terminated Unicode string.
652 @return The display length of the Null-terminated Unicode string specified by String.
657 UnicodeStringDisplayLength (
658 IN CONST CHAR16
*String
662 // Functions that abstract early Framework contamination of UEFI.
665 Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().
667 This function abstracts the signaling of the Ready to Boot Event. The Framework moved
668 from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller
669 from how this event is created to prevent to code form having to change with the
670 version of the specification supported.
675 EfiSignalEventReadyToBoot (
680 Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().
682 This function abstracts the signaling of the Legacy Boot Event. The Framework moved from
683 a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how
684 this event is created to prevent to code form having to change with the version of the
685 specification supported.
690 EfiSignalEventLegacyBoot (
695 Creates an EFI event in the Legacy Boot Event Group.
697 Prior to UEFI 2.0 this was done via a non blessed UEFI extensions and this library
698 abstracts the implementation mechanism of this event from the caller. This function
699 abstracts the creation of the Legacy Boot Event. The Framework moved from a proprietary
700 to UEFI 2.0 based mechanism. This library abstracts the caller from how this event
701 is created to prevent to code form having to change with the version of the
702 specification supported.
703 If LegacyBootEvent is NULL, then ASSERT().
705 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
707 @retval EFI_SUCCESS Event was created.
708 @retval Other Event was not created.
713 EfiCreateEventLegacyBoot (
714 OUT EFI_EVENT
*LegacyBootEvent
718 Create an EFI event in the Legacy Boot Event Group and allows
719 the caller to specify a notification function.
721 This function abstracts the creation of the Legacy Boot Event.
722 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
723 This library abstracts the caller from how this event is created to prevent
724 to code form having to change with the version of the specification supported.
725 If LegacyBootEvent is NULL, then ASSERT().
727 @param NotifyTpl The task priority level of the event.
728 @param NotifyFunction The notification function to call when the event is signaled.
729 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
730 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
732 @retval EFI_SUCCESS Event was created.
733 @retval Other Event was not created.
738 EfiCreateEventLegacyBootEx (
739 IN EFI_TPL NotifyTpl
,
740 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
741 IN VOID
*NotifyContext
, OPTIONAL
742 OUT EFI_EVENT
*LegacyBootEvent
746 Create an EFI event in the Ready To Boot Event Group.
748 Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library
749 abstracts the implementation mechanism of this event from the caller.
750 This function abstracts the creation of the Ready to Boot Event. The Framework
751 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts
752 the caller from how this event is created to prevent the code form having to
753 change with the version of the specification supported.
754 If ReadyToBootEvent is NULL, then ASSERT().
756 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
758 @retval EFI_SUCCESS Event was created.
759 @retval Other Event was not created.
764 EfiCreateEventReadyToBoot (
765 OUT EFI_EVENT
*ReadyToBootEvent
769 Create an EFI event in the Ready To Boot Event Group and allows
770 the caller to specify a notification function.
772 This function abstracts the creation of the Ready to Boot Event.
773 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
774 This library abstracts the caller from how this event is created to prevent
775 to code form having to change with the version of the specification supported.
776 If ReadyToBootEvent is NULL, then ASSERT().
778 @param NotifyTpl The task priority level of the event.
779 @param NotifyFunction The notification function to call when the event is signaled.
780 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
781 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
783 @retval EFI_SUCCESS Event was created.
784 @retval Other Event was not created.
789 EfiCreateEventReadyToBootEx (
790 IN EFI_TPL NotifyTpl
,
791 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
792 IN VOID
*NotifyContext
, OPTIONAL
793 OUT EFI_EVENT
*ReadyToBootEvent
797 Initialize a Firmware Volume (FV) Media Device Path node.
799 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
800 This library function abstracts initializing a device path node.
801 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device
802 path changed in the DXE CIS version 0.92 in a non back ward compatible way to
803 not conflict with the UEFI 2.0 specification. This function abstracts the
804 differences from the caller.
805 If FvDevicePathNode is NULL, then ASSERT().
806 If NameGuid is NULL, then ASSERT().
808 @param FvDevicePathNode Pointer to a FV device path node to initialize
809 @param NameGuid FV file name to use in FvDevicePathNode
814 EfiInitializeFwVolDevicepathNode (
815 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
816 IN CONST EFI_GUID
*NameGuid
820 Check to see if the Firmware Volume (FV) Media Device Path is valid
822 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
823 This library function abstracts validating a device path node.
824 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.
825 If it is valid, then return the GUID file name from the device path node. Otherwise,
826 return NULL. This device path changed in the DXE CIS version 0.92 in a non back ward
827 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts
828 the differences from the caller.
829 If FvDevicePathNode is NULL, then ASSERT().
831 @param FvDevicePathNode Pointer to FV device path to check.
833 @retval NULL FvDevicePathNode is not valid.
834 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
839 EfiGetNameGuidFromFwVolDevicePathNode (
840 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
844 Prints a formatted Unicode string to the console output device specified by
845 ConOut defined in the EFI_SYSTEM_TABLE.
847 This function prints a formatted Unicode string to the console output device
848 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
849 characters that printed to ConOut. If the length of the formatted Unicode
850 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
851 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
852 If Format is NULL, then ASSERT().
853 If Format is not aligned on a 16-bit boundary, then ASSERT().
855 @param Format Null-terminated Unicode format string.
856 @param ... Variable argument list whose contents are accessed based
857 on the format string specified by Format.
859 @return Number of Unicode characters printed to ConOut.
865 IN CONST CHAR16
*Format
,
870 Prints a formatted Unicode string to the console output device specified by
871 StdErr defined in the EFI_SYSTEM_TABLE.
873 This function prints a formatted Unicode string to the console output device
874 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
875 characters that printed to StdErr. If the length of the formatted Unicode
876 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
877 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
878 If Format is NULL, then ASSERT().
879 If Format is not aligned on a 16-bit boundary, then ASSERT().
881 @param Format Null-terminated Unicode format string.
882 @param ... Variable argument list whose contents are accessed based
883 on the format string specified by Format.
885 @return Number of Unicode characters printed to StdErr.
891 IN CONST CHAR16
*Format
,
896 Prints a formatted ASCII string to the console output device specified by
897 ConOut defined in the EFI_SYSTEM_TABLE.
899 This function prints a formatted ASCII string to the console output device
900 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
901 characters that printed to ConOut. If the length of the formatted ASCII
902 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
903 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
904 If Format is NULL, then ASSERT().
906 @param Format Null-terminated ASCII format string.
907 @param ... Variable argument list whose contents are accessed based
908 on the format string specified by Format.
910 @return Number of ASCII characters printed to ConOut.
916 IN CONST CHAR8
*Format
,
921 Prints a formatted ASCII string to the console output device specified by
922 StdErr defined in the EFI_SYSTEM_TABLE.
924 This function prints a formatted ASCII string to the console output device
925 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
926 characters that printed to StdErr. If the length of the formatted ASCII
927 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
928 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
929 If Format is NULL, then ASSERT().
931 @param Format Null-terminated ASCII format string.
932 @param ... Variable argument list whose contents are accessed based
933 on the format string specified by Format.
935 @return Number of ASCII characters printed to ConErr.
941 IN CONST CHAR8
*Format
,
946 Prints a formatted Unicode string to a graphics console device specified by
947 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
949 This function prints a formatted Unicode string to the graphics console device
950 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
951 Unicode characters printed. If the length of the formatted Unicode string is
952 greater than PcdUefiLibMaxPrintBufferSize, then only the first
953 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
954 is used to convert the string to a bitmap using the glyphs registered with the
955 HII database. No wrapping is performed, so any portions of the string the fall
956 outside the active display region will not be displayed.
958 If a graphics console device is not associated with the ConsoleOutputHandle
959 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
960 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
961 string is printed, and 0 is returned.
962 If Format is NULL, then ASSERT().
963 If Format is not aligned on a 16-bit boundary, then ASSERT().
965 @param X X coordinate to print the string.
966 @param Y Y coordinate to print the string.
967 @param ForeGround The forground color of the string being printed. This is
968 an optional parameter that may be NULL. If it is NULL,
969 then the foreground color of the current ConOut device
970 in the EFI_SYSTEM_TABLE is used.
971 @param BackGround The background color of the string being printed. This is
972 an optional parameter that may be NULL. If it is NULL,
973 then the background color of the current ConOut device
974 in the EFI_SYSTEM_TABLE is used.
975 @param Format Null-terminated Unicode format string. See Print Library
976 for the supported format string syntax.
977 @param ... Variable argument list whose contents are accessed based on
978 the format string specified by Format.
980 @return The number of Unicode characters printed.
988 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
989 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
990 IN CONST CHAR16
*Format
,
995 Prints a formatted ASCII string to a graphics console device specified by
996 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
998 This function prints a formatted ASCII string to the graphics console device
999 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
1000 ASCII characters printed. If the length of the formatted ASCII string is
1001 greater than PcdUefiLibMaxPrintBufferSize, then only the first
1002 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
1003 is used to convert the string to a bitmap using the glyphs registered with the
1004 HII database. No wrapping is performed, so any portions of the string the fall
1005 outside the active display region will not be displayed.
1007 If a graphics console device is not associated with the ConsoleOutputHandle
1008 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
1009 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
1010 string is printed, and 0 is returned.
1011 If Format is NULL, then ASSERT().
1013 @param X X coordinate to print the string.
1014 @param Y Y coordinate to print the string.
1015 @param ForeGround The forground color of the string being printed. This is
1016 an optional parameter that may be NULL. If it is NULL,
1017 then the foreground color of the current ConOut device
1018 in the EFI_SYSTEM_TABLE is used.
1019 @param BackGround The background color of the string being printed. This is
1020 an optional parameter that may be NULL. If it is NULL,
1021 then the background color of the current ConOut device
1022 in the EFI_SYSTEM_TABLE is used.
1023 @param Format Null-terminated ASCII format string. See Print Library
1024 for the supported format string syntax.
1025 @param ... Variable argument list whose contents are accessed based on
1026 the format string specified by Format.
1028 @return The number of ASCII characters printed.
1036 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
1037 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
1038 IN CONST CHAR8
*Format
,
1043 Installs and completes the initialization of a Driver Binding Protocol instance.
1045 Installs the Driver Binding Protocol specified by DriverBinding onto the handle
1046 specified by DriverBindingHandle. If DriverBindingHandle is NULL, then DriverBinding
1047 is installed onto a newly created handle. DriverBindingHandle is typically the same
1048 as the driver's ImageHandle, but it can be different if the driver produces multiple
1049 Driver Binding Protocols.
1050 If DriverBinding is NULL, then ASSERT().
1051 If DriverBinding can not be installed onto a handle, then ASSERT().
1053 @param ImageHandle The image handle of the driver.
1054 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1055 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1056 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1057 parameter is NULL, then a new handle is created.
1059 @retval EFI_SUCCESS The protocol installation is completed successfully.
1060 @retval EFI_OUT_OF_RESOURCES There was not enough system resources to install the protocol.
1061 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
1066 EfiLibInstallDriverBinding (
1067 IN CONST EFI_HANDLE ImageHandle
,
1068 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1069 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1070 IN EFI_HANDLE DriverBindingHandle
1075 Installs and completes the initialization of a Driver Binding Protocol instance and
1076 optionally installs the Component Name, Driver Configuration and Driver Diagnostics Protocols.
1078 Initializes a driver by installing the Driver Binding Protocol together with the
1079 optional Component Name, optional Driver Configure and optional Driver Diagnostic
1080 Protocols onto the driver's DriverBindingHandle. If DriverBindingHandle is NULL,
1081 then the protocols are installed onto a newly created handle. DriverBindingHandle
1082 is typically the same as the driver's ImageHandle, but it can be different if the
1083 driver produces multiple Driver Binding Protocols.
1084 If DriverBinding is NULL, then ASSERT().
1085 If the installation fails, then ASSERT().
1087 @param ImageHandle The image handle of the driver.
1088 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1089 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1090 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1091 parameter is NULL, then a new handle is created.
1092 @param ComponentName A Component Name Protocol instance that this driver is producing.
1093 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1094 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1096 @retval EFI_SUCCESS The protocol installation is completed successfully.
1097 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1102 EfiLibInstallAllDriverProtocols (
1103 IN CONST EFI_HANDLE ImageHandle
,
1104 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1105 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1106 IN EFI_HANDLE DriverBindingHandle
,
1107 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1108 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1109 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics OPTIONAL
1115 Installs Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.
1117 Initializes a driver by installing the Driver Binding Protocol together with the
1118 optional Component Name and optional Component Name 2 protocols onto the driver's
1119 DriverBindingHandle. If DriverBindingHandle is NULL, then the protocols are installed
1120 onto a newly created handle. DriverBindingHandle is typically the same as the driver's
1121 ImageHandle, but it can be different if the driver produces multiple Driver Binding Protocols.
1122 If DriverBinding is NULL, then ASSERT().
1123 If the installation fails, then ASSERT().
1125 @param ImageHandle The image handle of the driver.
1126 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1127 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1128 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1129 parameter is NULL, then a new handle is created.
1130 @param ComponentName A Component Name Protocol instance that this driver is producing.
1131 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1133 @retval EFI_SUCCESS The protocol installation is completed successfully.
1134 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1139 EfiLibInstallDriverBindingComponentName2 (
1140 IN CONST EFI_HANDLE ImageHandle
,
1141 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1142 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1143 IN EFI_HANDLE DriverBindingHandle
,
1144 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1145 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2 OPTIONAL
1150 Installs Driver Binding Protocol with optional Component Name, Component Name 2, Driver
1151 Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.
1153 Initializes a driver by installing the Driver Binding Protocol together with the optional
1154 Component Name, optional Component Name 2, optional Driver Configuration, optional Driver Configuration 2,
1155 optional Driver Diagnostic, and optional Driver Diagnostic 2 Protocols onto the driver's DriverBindingHandle.
1156 DriverBindingHandle is typically the same as the driver's ImageHandle, but it can be different if the driver
1157 produces multiple Driver Binding Protocols.
1158 If DriverBinding is NULL, then ASSERT().
1159 If the installation fails, then ASSERT().
1162 @param ImageHandle The image handle of the driver.
1163 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1164 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1165 @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this
1166 parameter is NULL, then a new handle is created.
1167 @param ComponentName A Component Name Protocol instance that this driver is producing.
1168 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1169 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1170 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver is producing.
1171 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1172 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing.
1174 @retval EFI_SUCCESS The protocol installation is completed successfully.
1175 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1180 EfiLibInstallAllDriverProtocols2 (
1181 IN CONST EFI_HANDLE ImageHandle
,
1182 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1183 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1184 IN EFI_HANDLE DriverBindingHandle
,
1185 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1186 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
, OPTIONAL
1187 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1188 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration2
, OPTIONAL
1189 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics
, OPTIONAL
1190 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL
*DriverDiagnostics2 OPTIONAL