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 Note that a reserved macro named MDEPKG_NDEBUG is introduced for the intention
12 of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is
13 defined, then debug and assert related macros wrapped by it are the NULL implementations.
15 Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
16 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
17 This program and the accompanying materials are licensed and made available under
18 the terms and conditions of the BSD License that accompanies this distribution.
19 The full text of the license may be found at
20 http://opensource.org/licenses/bsd-license.php.
22 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
23 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
27 #ifndef __UEFI_LIB_H__
28 #define __UEFI_LIB_H__
30 #include <IndustryStandard/Acpi.h>
32 #include <Protocol/DriverBinding.h>
33 #include <Protocol/DriverConfiguration.h>
34 #include <Protocol/ComponentName.h>
35 #include <Protocol/ComponentName2.h>
36 #include <Protocol/DriverDiagnostics.h>
37 #include <Protocol/DriverDiagnostics2.h>
38 #include <Protocol/GraphicsOutput.h>
39 #include <Protocol/DevicePath.h>
40 #include <Protocol/SimpleFileSystem.h>
42 #include <Library/BaseLib.h>
45 /// Unicode String Table
49 CHAR16
*UnicodeString
;
50 } EFI_UNICODE_STRING_TABLE
;
56 EfiLockUninitialized
= 0,
71 Macro that returns the number of 100 ns units for a specified number of microseconds.
72 This is useful for managing EFI timer events.
74 @param Microseconds The number of microseconds.
76 @return The number of 100 ns units equivalent to the number of microseconds specified
80 #define EFI_TIMER_PERIOD_MICROSECONDS(Microseconds) MultU64x32((UINT64)(Microseconds), 10)
83 Macro that returns the number of 100 ns units for a specified number of milliseconds.
84 This is useful for managing EFI timer events.
86 @param Milliseconds The number of milliseconds.
88 @return The number of 100 ns units equivalent to the number of milliseconds specified
92 #define EFI_TIMER_PERIOD_MILLISECONDS(Milliseconds) MultU64x32((UINT64)(Milliseconds), 10000)
95 Macro that returns the number of 100 ns units for a specified number of seconds.
96 This is useful for managing EFI timer events.
98 @param Seconds The number of seconds.
100 @return The number of 100 ns units equivalent to the number of seconds specified
104 #define EFI_TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)
107 Macro that returns the a pointer to the next EFI_MEMORY_DESCRIPTOR in an array
108 returned from GetMemoryMap().
110 @param MemoryDescriptor A pointer to an EFI_MEMORY_DESCRIPTOR.
112 @param Size The size, in bytes, of the current EFI_MEMORY_DESCRIPTOR.
114 @return A pointer to the next EFI_MEMORY_DESCRIPTOR.
117 #define NEXT_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
118 ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) + (Size)))
121 Retrieves a pointer to the system configuration table from the EFI System Table
122 based on a specified GUID.
124 This function searches the list of configuration tables stored in the EFI System Table
125 for a table with a GUID that matches TableGuid. If a match is found, then a pointer to
126 the configuration table is returned in Table, and EFI_SUCCESS is returned. If a matching GUID
127 is not found, then EFI_NOT_FOUND is returned.
128 If TableGuid is NULL, then ASSERT().
129 If Table is NULL, then ASSERT().
131 @param TableGuid The pointer to table's GUID type..
132 @param Table The pointer to the table associated with TableGuid in the EFI System Table.
134 @retval EFI_SUCCESS A configuration table matching TableGuid was found.
135 @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.
140 EfiGetSystemConfigurationTable (
141 IN EFI_GUID
*TableGuid
,
146 Creates and returns a notification event and registers that event with all the protocol
147 instances specified by ProtocolGuid.
149 This function causes the notification function to be executed for every protocol of type
150 ProtocolGuid instance that exists in the system when this function is invoked. If there are
151 no instances of ProtocolGuid in the handle database at the time this function is invoked,
152 then the notification function is still executed one time. In addition, every time a protocol
153 of type ProtocolGuid instance is installed or reinstalled, the notification function is also
154 executed. This function returns the notification event that was created.
155 If ProtocolGuid is NULL, then ASSERT().
156 If NotifyTpl is not a legal TPL value, then ASSERT().
157 If NotifyFunction is NULL, then ASSERT().
158 If Registration is NULL, then ASSERT().
161 @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.
162 @param NotifyTpl Supplies the task priority level of the event notifications.
163 @param NotifyFunction Supplies the function to notify when the event is signaled.
164 @param NotifyContext The context parameter to pass to NotifyFunction.
165 @param Registration A pointer to a memory location to receive the registration value.
166 This value is passed to LocateHandle() to obtain new handles that
167 have been added that support the ProtocolGuid-specified protocol.
169 @return The notification event that was created.
174 EfiCreateProtocolNotifyEvent(
175 IN EFI_GUID
*ProtocolGuid
,
176 IN EFI_TPL NotifyTpl
,
177 IN EFI_EVENT_NOTIFY NotifyFunction
,
178 IN VOID
*NotifyContext
, OPTIONAL
179 OUT VOID
**Registration
183 Creates a named event that can be signaled with EfiNamedEventSignal().
185 This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.
186 This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more
187 listeners on the same event named by the GUID specified by Name.
188 If Name is NULL, then ASSERT().
189 If NotifyTpl is not a legal TPL value, then ASSERT().
190 If NotifyFunction is NULL, then ASSERT().
192 @param Name Supplies GUID name of the event.
193 @param NotifyTpl Supplies the task priority level of the event notifications.
194 @param NotifyFunction Supplies the function to notify when the event is signaled.
195 @param NotifyContext The context parameter to pass to NotifyFunction.
196 @param Registration A pointer to a memory location to receive the registration value.
198 @retval EFI_SUCCESS A named event was created.
199 @retval EFI_OUT_OF_RESOURCES There are not enough resources to create the named event.
204 EfiNamedEventListen (
205 IN CONST EFI_GUID
*Name
,
206 IN EFI_TPL NotifyTpl
,
207 IN EFI_EVENT_NOTIFY NotifyFunction
,
208 IN CONST VOID
*NotifyContext
, OPTIONAL
209 OUT VOID
*Registration OPTIONAL
213 Signals a named event created with EfiNamedEventListen().
215 This function signals the named event specified by Name. The named event must have been
216 created with EfiNamedEventListen().
217 If Name is NULL, then ASSERT().
219 @param Name Supplies the GUID name of the event.
221 @retval EFI_SUCCESS A named event was signaled.
222 @retval EFI_OUT_OF_RESOURCES There are not enough resources to signal the named event.
227 EfiNamedEventSignal (
228 IN CONST EFI_GUID
*Name
232 Signals an event group by placing a new event in the group temporarily and
235 @param[in] EventGroup Supplies the unique identifier of the event
238 @retval EFI_SUCCESS The event group was signaled successfully.
239 @retval EFI_INVALID_PARAMETER EventGroup is NULL.
240 @return Error codes that report problems about event
241 creation or signaling.
245 EfiEventGroupSignal (
246 IN CONST EFI_GUID
*EventGroup
250 An empty function that can be used as NotifyFunction parameter of
251 CreateEvent() or CreateEventEx().
253 @param Event Event whose notification function is being invoked.
254 @param Context The pointer to the notification function's context,
255 which is implementation-dependent.
260 EfiEventEmptyFunction (
266 Returns the current TPL.
268 This function returns the current TPL. There is no EFI service to directly
269 retrieve the current TPL. Instead, the RaiseTPL() function is used to raise
270 the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level
271 can then immediately be restored back to the current TPL level with a call
274 @return The current TPL.
284 Initializes a basic mutual exclusion lock.
286 This function initializes a basic mutual exclusion lock to the released state
287 and returns the lock. Each lock provides mutual exclusion access at its task
288 priority level. Since there is no preemption or multiprocessor support in EFI,
289 acquiring the lock only consists of raising to the locks TPL.
290 If Lock is NULL, then ASSERT().
291 If Priority is not a valid TPL value, then ASSERT().
293 @param Lock A pointer to the lock data structure to initialize.
294 @param Priority The EFI TPL associated with the lock.
302 IN OUT EFI_LOCK
*Lock
,
307 Initializes a basic mutual exclusion lock.
309 This macro initializes the contents of a basic mutual exclusion lock to the
310 released state. Each lock provides mutual exclusion access at its task
311 priority level. Since there is no preemption or multiprocessor support in EFI,
312 acquiring the lock only consists of raising to the locks TPL.
314 @param Priority The task priority level of the lock.
319 #define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \
320 {Priority, TPL_APPLICATION, EfiLockReleased }
324 Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state.
326 If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED
327 bit of PcdDebugProperyMask is set, then this macro evaluates the EFI_LOCK
328 structure specified by Lock. If Lock is not in the locked state, then
329 DebugAssert() is called passing in the source filename, source line number,
332 If Lock is NULL, then ASSERT().
334 @param LockParameter A pointer to the lock to acquire.
337 #if !defined(MDEPKG_NDEBUG)
338 #define ASSERT_LOCKED(LockParameter) \
340 if (DebugAssertEnabled ()) { \
341 ASSERT (LockParameter != NULL); \
342 if ((LockParameter)->Lock != EfiLockAcquired) { \
343 _ASSERT (LockParameter not locked); \
348 #define ASSERT_LOCKED(LockParameter)
353 Acquires ownership of a lock.
355 This function raises the system's current task priority level to the task
356 priority level of the mutual exclusion lock. Then, it places the lock in the
358 If Lock is NULL, then ASSERT().
359 If Lock is not initialized, then ASSERT().
360 If Lock is already in the acquired state, then ASSERT().
362 @param Lock A pointer to the lock to acquire.
372 Acquires ownership of a lock.
374 This function raises the system's current task priority level to the task priority
375 level of the mutual exclusion lock. Then, it attempts to place the lock in the acquired state.
376 If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.
377 Otherwise, EFI_SUCCESS is returned.
378 If Lock is NULL, then ASSERT().
379 If Lock is not initialized, then ASSERT().
381 @param Lock A pointer to the lock to acquire.
383 @retval EFI_SUCCESS The lock was acquired.
384 @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.
389 EfiAcquireLockOrFail (
394 Releases ownership of a lock.
396 This function transitions a mutual exclusion lock from the acquired state to
397 the released state, and restores the system's task priority level to its
399 If Lock is NULL, then ASSERT().
400 If Lock is not initialized, then ASSERT().
401 If Lock is already in the released state, then ASSERT().
403 @param Lock A pointer to the lock to release.
413 Tests whether a controller handle is being managed by a specific driver.
415 This function tests whether the driver specified by DriverBindingHandle is
416 currently managing the controller specified by ControllerHandle. This test
417 is performed by evaluating if the the protocol specified by ProtocolGuid is
418 present on ControllerHandle and is was opened by DriverBindingHandle with an
419 attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
420 If ProtocolGuid is NULL, then ASSERT().
422 @param ControllerHandle A handle for a controller to test.
423 @param DriverBindingHandle Specifies the driver binding handle for the
425 @param ProtocolGuid Specifies the protocol that the driver specified
426 by DriverBindingHandle opens in its Start()
429 @retval EFI_SUCCESS ControllerHandle is managed by the driver
430 specified by DriverBindingHandle.
431 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
432 specified by DriverBindingHandle.
437 EfiTestManagedDevice (
438 IN CONST EFI_HANDLE ControllerHandle
,
439 IN CONST EFI_HANDLE DriverBindingHandle
,
440 IN CONST EFI_GUID
*ProtocolGuid
444 Tests whether a child handle is a child device of the controller.
446 This function tests whether ChildHandle is one of the children of
447 ControllerHandle. This test is performed by checking to see if the protocol
448 specified by ProtocolGuid is present on ControllerHandle and opened by
449 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
450 If ProtocolGuid is NULL, then ASSERT().
452 @param ControllerHandle A handle for a (parent) controller to test.
453 @param ChildHandle A child handle to test.
454 @param ProtocolGuid Supplies the protocol that the child controller
455 opens on its parent controller.
457 @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle.
458 @retval EFI_UNSUPPORTED ChildHandle is not a child of the
465 IN CONST EFI_HANDLE ControllerHandle
,
466 IN CONST EFI_HANDLE ChildHandle
,
467 IN CONST EFI_GUID
*ProtocolGuid
471 This function looks up a Unicode string in UnicodeStringTable.
473 If Language is a member of SupportedLanguages and a Unicode string is found in
474 UnicodeStringTable that matches the language code specified by Language, then it
475 is returned in UnicodeString.
477 @param Language A pointer to the ISO 639-2 language code for the
478 Unicode string to look up and return.
479 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
480 that the Unicode string table supports. Language
481 must be a member of this set.
482 @param UnicodeStringTable A pointer to the table of Unicode strings.
483 @param UnicodeString A pointer to the Unicode string from UnicodeStringTable
484 that matches the language specified by Language.
486 @retval EFI_SUCCESS The Unicode string that matches the language
487 specified by Language was found
488 in the table of Unicode strings UnicodeStringTable,
489 and 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
495 member of SupportedLanguages.
496 @retval EFI_UNSUPPORTED The language specified by Language is not
497 supported by UnicodeStringTable.
502 LookupUnicodeString (
503 IN CONST CHAR8
*Language
,
504 IN CONST CHAR8
*SupportedLanguages
,
505 IN CONST EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
,
506 OUT CHAR16
**UnicodeString
510 This function looks up a Unicode string in UnicodeStringTable.
512 If Language is a member of SupportedLanguages and a Unicode string is found in
513 UnicodeStringTable that matches the language code specified by Language, then
514 it is returned in UnicodeString.
516 @param Language A pointer to an ASCII string containing the ISO 639-2 or the
517 RFC 4646 language code for the Unicode string to look up and
518 return. If Iso639Language is TRUE, then this ASCII string is
519 not assumed to be Null-terminated, and only the first three
520 characters are used. If Iso639Language is FALSE, then this ASCII
521 string must be Null-terminated.
522 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains a
523 set of ISO 639-2 or RFC 4646 language codes that the Unicode
524 string table supports. Language must be a member of this set.
525 If Iso639Language is TRUE, then this string contains one or more
526 ISO 639-2 language codes with no separator characters. If Iso639Language
527 is FALSE, then is string contains one or more RFC 4646 language
528 codes separated by ';'.
529 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE
530 is defined in "Related Definitions".
531 @param UnicodeString A pointer to the Null-terminated Unicode string from UnicodeStringTable
532 that matches the language specified by Language.
533 @param Iso639Language Specifies the supported language code format. If it is TRUE, then
534 Language and SupportedLanguages follow ISO 639-2 language code format.
535 Otherwise, they follow the RFC 4646 language code format.
538 @retval EFI_SUCCESS The Unicode string that matches the language specified by Language
539 was found in the table of Unicode strings UnicodeStringTable, and
540 it was returned in UnicodeString.
541 @retval EFI_INVALID_PARAMETER Language is NULL.
542 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
543 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
544 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
545 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.
546 @retval EFI_UNSUPPORTED The language specified by Language is not supported by UnicodeStringTable.
551 LookupUnicodeString2 (
552 IN CONST CHAR8
*Language
,
553 IN CONST CHAR8
*SupportedLanguages
,
554 IN CONST EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
,
555 OUT CHAR16
**UnicodeString
,
556 IN BOOLEAN Iso639Language
560 This function adds a Unicode string to UnicodeStringTable.
562 If Language is a member of SupportedLanguages then UnicodeString is added to
563 UnicodeStringTable. New buffers are allocated for both Language and
564 UnicodeString. The contents of Language and UnicodeString are copied into
565 these new buffers. These buffers are automatically freed when
566 FreeUnicodeStringTable() is called.
568 @param Language A pointer to the ISO 639-2 language code for the Unicode
570 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
571 that the Unicode string table supports.
572 Language must be a member of this set.
573 @param UnicodeStringTable A pointer to the table of Unicode strings.
574 @param UnicodeString A pointer to the Unicode string to add.
576 @retval EFI_SUCCESS The Unicode string that matches the language
577 specified by Language was found in the table of
578 Unicode strings UnicodeStringTable, and it was
579 returned in UnicodeString.
580 @retval EFI_INVALID_PARAMETER Language is NULL.
581 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
582 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
583 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
584 @retval EFI_ALREADY_STARTED A Unicode string with language Language is
585 already present in UnicodeStringTable.
586 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another
587 Unicode string to UnicodeStringTable.
588 @retval EFI_UNSUPPORTED The language specified by Language is not a
589 member of SupportedLanguages.
595 IN CONST CHAR8
*Language
,
596 IN CONST CHAR8
*SupportedLanguages
,
597 IN OUT EFI_UNICODE_STRING_TABLE
**UnicodeStringTable
,
598 IN CONST CHAR16
*UnicodeString
602 This function adds the Null-terminated Unicode string specified by UnicodeString
603 to UnicodeStringTable.
605 If Language is a member of SupportedLanguages then UnicodeString is added to
606 UnicodeStringTable. New buffers are allocated for both Language and UnicodeString.
607 The contents of Language and UnicodeString are copied into these new buffers.
608 These buffers are automatically freed when EfiLibFreeUnicodeStringTable() is called.
610 @param Language A pointer to an ASCII string containing the ISO 639-2 or
611 the RFC 4646 language code for the Unicode string to add.
612 If Iso639Language is TRUE, then this ASCII string is not
613 assumed to be Null-terminated, and only the first three
614 chacters are used. If Iso639Language is FALSE, then this
615 ASCII string must be Null-terminated.
616 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains
617 a set of ISO 639-2 or RFC 4646 language codes that the Unicode
618 string table supports. Language must be a member of this set.
619 If Iso639Language is TRUE, then this string contains one or more
620 ISO 639-2 language codes with no separator characters.
621 If Iso639Language is FALSE, then is string contains one or more
622 RFC 4646 language codes separated by ';'.
623 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE
624 is defined in "Related Definitions".
625 @param UnicodeString A pointer to the Unicode string to add.
626 @param Iso639Language Specifies the supported language code format. If it is TRUE,
627 then Language and SupportedLanguages follow ISO 639-2 language code format.
628 Otherwise, they follow RFC 4646 language code format.
630 @retval EFI_SUCCESS The Unicode string that matches the language specified by
631 Language was found in the table of Unicode strings UnicodeStringTable,
632 and it was returned in UnicodeString.
633 @retval EFI_INVALID_PARAMETER Language is NULL.
634 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
635 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
636 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
637 @retval EFI_ALREADY_STARTED A Unicode string with language Language is already present in
639 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another Unicode string UnicodeStringTable.
640 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.
646 IN CONST CHAR8
*Language
,
647 IN CONST CHAR8
*SupportedLanguages
,
648 IN OUT EFI_UNICODE_STRING_TABLE
**UnicodeStringTable
,
649 IN CONST CHAR16
*UnicodeString
,
650 IN BOOLEAN Iso639Language
654 This function frees the table of Unicode strings in UnicodeStringTable.
656 If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.
657 Otherwise, each language code, and each Unicode string in the Unicode string
658 table are freed, and EFI_SUCCESS is returned.
660 @param UnicodeStringTable A pointer to the table of Unicode strings.
662 @retval EFI_SUCCESS The Unicode string table was freed.
667 FreeUnicodeStringTable (
668 IN EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
671 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
674 [ATTENTION] This function will be deprecated for security reason.
676 Returns a pointer to an allocated buffer that contains the contents of a
677 variable retrieved through the UEFI Runtime Service GetVariable(). The
678 returned buffer is allocated using AllocatePool(). The caller is responsible
679 for freeing this buffer with FreePool().
681 If Name is NULL, then ASSERT().
682 If Guid is NULL, then ASSERT().
684 @param[in] Name The pointer to a Null-terminated Unicode string.
685 @param[in] Guid The pointer to an EFI_GUID structure.
687 @retval NULL The variable could not be retrieved.
688 @retval NULL There are not enough resources available for the variable contents.
689 @retval Other A pointer to allocated buffer containing the variable contents.
695 IN CONST CHAR16
*Name
,
696 IN CONST EFI_GUID
*Guid
700 [ATTENTION] This function will be deprecated for security reason.
702 Returns a pointer to an allocated buffer that contains the contents of a
703 variable retrieved through the UEFI Runtime Service GetVariable(). This
704 function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables.
705 The returned buffer is allocated using AllocatePool(). The caller is
706 responsible for freeing this buffer with FreePool().
708 If Name is NULL, then ASSERT().
710 @param[in] Name The pointer to a Null-terminated Unicode string.
712 @retval NULL The variable could not be retrieved.
713 @retval NULL There are not enough resources available for the variable contents.
714 @retval Other A pointer to allocated buffer containing the variable contents.
719 GetEfiGlobalVariable (
720 IN CONST CHAR16
*Name
726 Returns the status whether get the variable success. The function retrieves
727 variable through the UEFI Runtime Service GetVariable(). The
728 returned buffer is allocated using AllocatePool(). The caller is responsible
729 for freeing this buffer with FreePool().
731 If Name is NULL, then ASSERT().
732 If Guid is NULL, then ASSERT().
733 If Value is NULL, then ASSERT().
735 @param[in] Name The pointer to a Null-terminated Unicode string.
736 @param[in] Guid The pointer to an EFI_GUID structure
737 @param[out] Value The buffer point saved the variable info.
738 @param[out] Size The buffer size of the variable.
740 @return EFI_OUT_OF_RESOURCES Allocate buffer failed.
741 @return EFI_SUCCESS Find the specified variable.
742 @return Others Errors Return errors from call to gRT->GetVariable.
748 IN CONST CHAR16
*Name
,
749 IN CONST EFI_GUID
*Guid
,
751 OUT UINTN
*Size OPTIONAL
755 Returns a pointer to an allocated buffer that contains the contents of a
756 variable retrieved through the UEFI Runtime Service GetVariable(). This
757 function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables.
758 The returned buffer is allocated using AllocatePool(). The caller is
759 responsible for freeing this buffer with FreePool().
761 If Name is NULL, then ASSERT().
762 If Value is NULL, then ASSERT().
764 @param[in] Name The pointer to a Null-terminated Unicode string.
765 @param[out] Value The buffer point saved the variable info.
766 @param[out] Size The buffer size of the variable.
768 @return EFI_OUT_OF_RESOURCES Allocate buffer failed.
769 @return EFI_SUCCESS Find the specified variable.
770 @return Others Errors Return errors from call to gRT->GetVariable.
775 GetEfiGlobalVariable2 (
776 IN CONST CHAR16
*Name
,
778 OUT UINTN
*Size OPTIONAL
782 Returns a pointer to an allocated buffer that contains the best matching language
783 from a set of supported languages.
785 This function supports both ISO 639-2 and RFC 4646 language codes, but language
786 code types may not be mixed in a single call to this function. The language
787 code returned is allocated using AllocatePool(). The caller is responsible for
788 freeing the allocated buffer using FreePool(). This function supports a variable
789 argument list that allows the caller to pass in a prioritized list of language
790 codes to test against all the language codes in SupportedLanguages.
792 If SupportedLanguages is NULL, then ASSERT().
794 @param[in] SupportedLanguages A pointer to a Null-terminated ASCII string that
795 contains a set of language codes in the format
796 specified by Iso639Language.
797 @param[in] Iso639Language If not zero, then all language codes are assumed to be
798 in ISO 639-2 format. If zero, then all language
799 codes are assumed to be in RFC 4646 language format
800 @param[in] ... A variable argument list that contains pointers to
801 Null-terminated ASCII strings that contain one or more
802 language codes in the format specified by Iso639Language.
803 The first language code from each of these language
804 code lists is used to determine if it is an exact or
805 close match to any of the language codes in
806 SupportedLanguages. Close matches only apply to RFC 4646
807 language codes, and the matching algorithm from RFC 4647
808 is used to determine if a close match is present. If
809 an exact or close match is found, then the matching
810 language code from SupportedLanguages is returned. If
811 no matches are found, then the next variable argument
812 parameter is evaluated. The variable argument list
813 is terminated by a NULL.
815 @retval NULL The best matching language could not be found in SupportedLanguages.
816 @retval NULL There are not enough resources available to return the best matching
818 @retval Other A pointer to a Null-terminated ASCII string that is the best matching
819 language in SupportedLanguages.
825 IN CONST CHAR8
*SupportedLanguages
,
826 IN UINTN Iso639Language
,
831 Draws a dialog box to the console output device specified by
832 ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke
833 from the console input device specified by ConIn defined in the
836 If there are no strings in the variable argument list, then ASSERT().
837 If all the strings in the variable argument list are empty, then ASSERT().
839 @param[in] Attribute Specifies the foreground and background color of the popup.
840 @param[out] Key A pointer to the EFI_KEY value of the key that was
841 pressed. This is an optional parameter that may be NULL.
842 If it is NULL then no wait for a keypress will be performed.
843 @param[in] ... The variable argument list that contains pointers to Null-
844 terminated Unicode strings to display in the dialog box.
845 The variable argument list is terminated by a NULL.
852 OUT EFI_INPUT_KEY
*Key
, OPTIONAL
857 Retrieves the width of a Unicode character.
859 This function computes and returns the width of the Unicode character specified
862 @param UnicodeChar A Unicode character.
864 @retval 0 The width if UnicodeChar could not be determined.
865 @retval 1 UnicodeChar is a narrow glyph.
866 @retval 2 UnicodeChar is a wide glyph.
872 IN CHAR16 UnicodeChar
876 Computes the display length of a Null-terminated Unicode String.
878 This function computes and returns the display length of the Null-terminated Unicode
879 string specified by String. If String is NULL then 0 is returned. If any of the widths
880 of the Unicode characters in String can not be determined, then 0 is returned. The display
881 width of String can be computed by summing the display widths of each Unicode character
882 in String. Unicode characters that are narrow glyphs have a width of 1, and Unicode
883 characters that are width glyphs have a width of 2.
884 If String is not aligned on a 16-bit boundary, then ASSERT().
886 @param String A pointer to a Null-terminated Unicode string.
888 @return The display length of the Null-terminated Unicode string specified by String.
893 UnicodeStringDisplayLength (
894 IN CONST CHAR16
*String
898 // Functions that abstract early Framework contamination of UEFI.
901 Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().
903 This function abstracts the signaling of the Ready to Boot Event. The Framework moved
904 from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller
905 from how this event is created to prevent to code form having to change with the
906 version of the specification supported.
911 EfiSignalEventReadyToBoot (
916 Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().
918 This function abstracts the signaling of the Legacy Boot Event. The Framework moved from
919 a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how
920 this event is created to prevent to code form having to change with the version of the
921 specification supported.
926 EfiSignalEventLegacyBoot (
931 Creates an EFI event in the Legacy Boot Event Group.
933 Prior to UEFI 2.0 this was done via a non blessed UEFI extensions and this library
934 abstracts the implementation mechanism of this event from the caller. This function
935 abstracts the creation of the Legacy Boot Event. The Framework moved from a proprietary
936 to UEFI 2.0 based mechanism. This library abstracts the caller from how this event
937 is created to prevent to code form having to change with the version of the
938 specification supported.
939 If LegacyBootEvent is NULL, then ASSERT().
941 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
943 @retval EFI_SUCCESS The event was created.
944 @retval Other The event was not created.
949 EfiCreateEventLegacyBoot (
950 OUT EFI_EVENT
*LegacyBootEvent
954 Create an EFI event in the Legacy Boot Event Group and allows
955 the caller to specify a notification function.
957 This function abstracts the creation of the Legacy Boot Event.
958 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
959 This library abstracts the caller from how this event is created to prevent
960 to code form having to change with the version of the specification supported.
961 If LegacyBootEvent is NULL, then ASSERT().
963 @param NotifyTpl The task priority level of the event.
964 @param NotifyFunction The notification function to call when the event is signaled.
965 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
966 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
968 @retval EFI_SUCCESS The event was created.
969 @retval Other The event was not created.
974 EfiCreateEventLegacyBootEx (
975 IN EFI_TPL NotifyTpl
,
976 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
977 IN VOID
*NotifyContext
, OPTIONAL
978 OUT EFI_EVENT
*LegacyBootEvent
982 Create an EFI event in the Ready To Boot Event Group.
984 Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library
985 abstracts the implementation mechanism of this event from the caller.
986 This function abstracts the creation of the Ready to Boot Event. The Framework
987 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts
988 the caller from how this event is created to prevent the code form having to
989 change with the version of the specification supported.
990 If ReadyToBootEvent is NULL, then ASSERT().
992 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
994 @retval EFI_SUCCESS The event was created.
995 @retval Other The event was not created.
1000 EfiCreateEventReadyToBoot (
1001 OUT EFI_EVENT
*ReadyToBootEvent
1005 Create an EFI event in the Ready To Boot Event Group and allows
1006 the caller to specify a notification function.
1008 This function abstracts the creation of the Ready to Boot Event.
1009 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
1010 This library abstracts the caller from how this event is created to prevent
1011 to code form having to change with the version of the specification supported.
1012 If ReadyToBootEvent is NULL, then ASSERT().
1014 @param NotifyTpl The task priority level of the event.
1015 @param NotifyFunction The notification function to call when the event is signaled.
1016 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
1017 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
1019 @retval EFI_SUCCESS The event was created.
1020 @retval Other The event was not created.
1025 EfiCreateEventReadyToBootEx (
1026 IN EFI_TPL NotifyTpl
,
1027 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1028 IN VOID
*NotifyContext
, OPTIONAL
1029 OUT EFI_EVENT
*ReadyToBootEvent
1033 Initialize a Firmware Volume (FV) Media Device Path node.
1035 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
1036 This library function abstracts initializing a device path node.
1037 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device
1038 path changed in the DXE CIS version 0.92 in a non back ward compatible way to
1039 not conflict with the UEFI 2.0 specification. This function abstracts the
1040 differences from the caller.
1041 If FvDevicePathNode is NULL, then ASSERT().
1042 If NameGuid is NULL, then ASSERT().
1044 @param FvDevicePathNode The pointer to a FV device path node to initialize
1045 @param NameGuid FV file name to use in FvDevicePathNode
1050 EfiInitializeFwVolDevicepathNode (
1051 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
1052 IN CONST EFI_GUID
*NameGuid
1056 Check to see if the Firmware Volume (FV) Media Device Path is valid
1058 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
1059 This library function abstracts validating a device path node.
1060 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.
1061 If it is valid, then return the GUID file name from the device path node. Otherwise,
1062 return NULL. This device path changed in the DXE CIS version 0.92 in a non backward
1063 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts
1064 the differences from the caller.
1065 If FvDevicePathNode is NULL, then ASSERT().
1067 @param FvDevicePathNode The pointer to FV device path to check.
1069 @retval NULL FvDevicePathNode is not valid.
1070 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
1075 EfiGetNameGuidFromFwVolDevicePathNode (
1076 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
1080 Prints a formatted Unicode string to the console output device specified by
1081 ConOut defined in the EFI_SYSTEM_TABLE.
1083 This function prints a formatted Unicode string to the console output device
1084 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
1085 characters that printed to ConOut. If the length of the formatted Unicode
1086 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1087 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
1088 If Format is NULL, then ASSERT().
1089 If Format is not aligned on a 16-bit boundary, then ASSERT().
1090 If gST->ConOut is NULL, then ASSERT().
1092 @param Format A null-terminated Unicode format string.
1093 @param ... The variable argument list whose contents are accessed based
1094 on the format string specified by Format.
1096 @return Number of Unicode characters printed to ConOut.
1102 IN CONST CHAR16
*Format
,
1107 Prints a formatted Unicode string to the console output device specified by
1108 StdErr defined in the EFI_SYSTEM_TABLE.
1110 This function prints a formatted Unicode string to the console output device
1111 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
1112 characters that printed to StdErr. If the length of the formatted Unicode
1113 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1114 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
1115 If Format is NULL, then ASSERT().
1116 If Format is not aligned on a 16-bit boundary, then ASSERT().
1117 If gST->StdErr is NULL, then ASSERT().
1119 @param Format A null-terminated Unicode format string.
1120 @param ... The variable argument list whose contents are accessed based
1121 on the format string specified by Format.
1123 @return Number of Unicode characters printed to StdErr.
1129 IN CONST CHAR16
*Format
,
1134 Prints a formatted ASCII string to the console output device specified by
1135 ConOut defined in the EFI_SYSTEM_TABLE.
1137 This function prints a formatted ASCII string to the console output device
1138 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
1139 characters that printed to ConOut. If the length of the formatted ASCII
1140 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1141 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
1142 If Format is NULL, then ASSERT().
1143 If gST->ConOut is NULL, then ASSERT().
1145 @param Format A null-terminated ASCII format string.
1146 @param ... The variable argument list whose contents are accessed based
1147 on the format string specified by Format.
1149 @return Number of ASCII characters printed to ConOut.
1155 IN CONST CHAR8
*Format
,
1160 Prints a formatted ASCII string to the console output device specified by
1161 StdErr defined in the EFI_SYSTEM_TABLE.
1163 This function prints a formatted ASCII string to the console output device
1164 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
1165 characters that printed to StdErr. If the length of the formatted ASCII
1166 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1167 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
1168 If Format is NULL, then ASSERT().
1169 If gST->StdErr is NULL, then ASSERT().
1171 @param Format A null-terminated ASCII format string.
1172 @param ... The variable argument list whose contents are accessed based
1173 on the format string specified by Format.
1175 @return Number of ASCII characters printed to ConErr.
1181 IN CONST CHAR8
*Format
,
1187 Prints a formatted Unicode string to a graphics console device specified by
1188 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
1190 This function prints a formatted Unicode string to the graphics console device
1191 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
1192 Unicode characters displayed, not including partial characters that may be clipped
1193 by the right edge of the display. If the length of the formatted Unicode string is
1194 greater than PcdUefiLibMaxPrintBufferSize, then at most the first
1195 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
1196 is used to convert the string to a bitmap using the glyphs registered with the
1197 HII database. No wrapping is performed, so any portions of the string the fall
1198 outside the active display region will not be displayed.
1200 If a graphics console device is not associated with the ConsoleOutputHandle
1201 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
1202 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
1203 string is printed, and 0 is returned.
1204 If Format is NULL, then ASSERT().
1205 If Format is not aligned on a 16-bit boundary, then ASSERT().
1206 If gST->ConsoleOutputHandle is NULL, then ASSERT().
1208 @param PointX X coordinate to print the string.
1209 @param PointY Y coordinate to print the string.
1210 @param ForeGround The foreground color of the string being printed. This is
1211 an optional parameter that may be NULL. If it is NULL,
1212 then the foreground color of the current ConOut device
1213 in the EFI_SYSTEM_TABLE is used.
1214 @param BackGround The background color of the string being printed. This is
1215 an optional parameter that may be NULL. If it is NULL,
1216 then the background color of the current ConOut device
1217 in the EFI_SYSTEM_TABLE is used.
1218 @param Format A null-terminated Unicode format string. See Print Library
1219 for the supported format string syntax.
1220 @param ... Variable argument list whose contents are accessed based on
1221 the format string specified by Format.
1223 @return The number of Unicode characters printed.
1231 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
1232 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
1233 IN CONST CHAR16
*Format
,
1238 Prints a formatted ASCII string to a graphics console device specified by
1239 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
1241 This function prints a formatted ASCII string to the graphics console device
1242 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
1243 ASCII characters displayed, not including partial characters that may be clipped
1244 by the right edge of the display. If the length of the formatted ASCII string is
1245 greater than PcdUefiLibMaxPrintBufferSize, then at most the first
1246 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
1247 is used to convert the string to a bitmap using the glyphs registered with the
1248 HII database. No wrapping is performed, so any portions of the string the fall
1249 outside the active display region will not be displayed.
1251 If a graphics console device is not associated with the ConsoleOutputHandle
1252 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
1253 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
1254 string is printed, and 0 is returned.
1255 If Format is NULL, then ASSERT().
1256 If gST->ConsoleOutputHandle is NULL, then ASSERT().
1258 @param PointX X coordinate to print the string.
1259 @param PointY Y coordinate to print the string.
1260 @param ForeGround The foreground color of the string being printed. This is
1261 an optional parameter that may be NULL. If it is NULL,
1262 then the foreground color of the current ConOut device
1263 in the EFI_SYSTEM_TABLE is used.
1264 @param BackGround The background color of the string being printed. This is
1265 an optional parameter that may be NULL. If it is NULL,
1266 then the background color of the current ConOut device
1267 in the EFI_SYSTEM_TABLE is used.
1268 @param Format A null-terminated ASCII format string. See Print Library
1269 for the supported format string syntax.
1270 @param ... The variable argument list whose contents are accessed based on
1271 the format string specified by Format.
1273 @return The number of ASCII characters printed.
1281 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
1282 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
1283 IN CONST CHAR8
*Format
,
1289 Installs and completes the initialization of a Driver Binding Protocol instance.
1291 Installs the Driver Binding Protocol specified by DriverBinding onto the handle
1292 specified by DriverBindingHandle. If DriverBindingHandle is NULL, then DriverBinding
1293 is installed onto a newly created handle. DriverBindingHandle is typically the same
1294 as the driver's ImageHandle, but it can be different if the driver produces multiple
1295 Driver Binding Protocols.
1296 If DriverBinding is NULL, then ASSERT().
1297 If DriverBinding can not be installed onto a handle, then ASSERT().
1299 @param ImageHandle The image handle of the driver.
1300 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1301 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1302 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1303 parameter is NULL, then a new handle is created.
1305 @retval EFI_SUCCESS The protocol installation completed successfully.
1306 @retval EFI_OUT_OF_RESOURCES There was not enough system resources to install the protocol.
1307 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
1312 EfiLibInstallDriverBinding (
1313 IN CONST EFI_HANDLE ImageHandle
,
1314 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1315 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1316 IN EFI_HANDLE DriverBindingHandle
1321 Uninstalls a Driver Binding Protocol instance.
1323 If DriverBinding is NULL, then ASSERT().
1324 If DriverBinding can not be uninstalled, then ASSERT().
1326 @param DriverBinding A Driver Binding Protocol instance that this driver produced.
1328 @retval EFI_SUCCESS The protocol uninstallation successfully completed.
1329 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().
1334 EfiLibUninstallDriverBinding (
1335 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
1340 Installs and completes the initialization of a Driver Binding Protocol instance and
1341 optionally installs the Component Name, Driver Configuration and Driver Diagnostics Protocols.
1343 Initializes a driver by installing the Driver Binding Protocol together with the
1344 optional Component Name, optional Driver Configure and optional Driver Diagnostic
1345 Protocols onto the driver's DriverBindingHandle. If DriverBindingHandle is NULL,
1346 then the protocols are installed onto a newly created handle. DriverBindingHandle
1347 is typically the same as the driver's ImageHandle, but it can be different if the
1348 driver produces multiple Driver Binding Protocols.
1349 If DriverBinding is NULL, then ASSERT().
1350 If the installation fails, then ASSERT().
1352 @param ImageHandle The image handle of the driver.
1353 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1354 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1355 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1356 parameter is NULL, then a new handle is created.
1357 @param ComponentName A Component Name Protocol instance that this driver is producing.
1358 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1359 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1361 @retval EFI_SUCCESS The protocol installation completed successfully.
1362 @retval EFI_OUT_OF_RESOURCES There was not enough memory in the pool to install all the protocols.
1367 EfiLibInstallAllDriverProtocols (
1368 IN CONST EFI_HANDLE ImageHandle
,
1369 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1370 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1371 IN EFI_HANDLE DriverBindingHandle
,
1372 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1373 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1374 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics OPTIONAL
1379 Uninstalls a Driver Binding Protocol instance and optionally uninstalls the
1380 Component Name, Driver Configuration and Driver Diagnostics Protocols.
1382 If DriverBinding is NULL, then ASSERT().
1383 If the uninstallation fails, then ASSERT().
1385 @param DriverBinding A Driver Binding Protocol instance that this driver produced.
1386 @param ComponentName A Component Name Protocol instance that this driver produced.
1387 @param DriverConfiguration A Driver Configuration Protocol instance that this driver produced.
1388 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver produced.
1390 @retval EFI_SUCCESS The protocol uninstallation successfully completed.
1391 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().
1396 EfiLibUninstallAllDriverProtocols (
1397 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1398 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1399 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1400 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics OPTIONAL
1405 Installs Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.
1407 Initializes a driver by installing the Driver Binding Protocol together with the
1408 optional Component Name and optional Component Name 2 protocols onto the driver's
1409 DriverBindingHandle. If DriverBindingHandle is NULL, then the protocols are installed
1410 onto a newly created handle. DriverBindingHandle is typically the same as the driver's
1411 ImageHandle, but it can be different if the driver produces multiple Driver Binding Protocols.
1412 If DriverBinding is NULL, then ASSERT().
1413 If the installation fails, then ASSERT().
1415 @param ImageHandle The image handle of the driver.
1416 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1417 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1418 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1419 parameter is NULL, then a new handle is created.
1420 @param ComponentName A Component Name Protocol instance that this driver is producing.
1421 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1423 @retval EFI_SUCCESS The protocol installation completed successfully.
1424 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1429 EfiLibInstallDriverBindingComponentName2 (
1430 IN CONST EFI_HANDLE ImageHandle
,
1431 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1432 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1433 IN EFI_HANDLE DriverBindingHandle
,
1434 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1435 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2 OPTIONAL
1440 Uninstalls Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.
1442 If DriverBinding is NULL, then ASSERT().
1443 If the uninstallation fails, then ASSERT().
1445 @param DriverBinding A Driver Binding Protocol instance that this driver produced.
1446 @param ComponentName A Component Name Protocol instance that this driver produced.
1447 @param ComponentName2 A Component Name 2 Protocol instance that this driver produced.
1449 @retval EFI_SUCCESS The protocol installation successfully completed.
1450 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().
1455 EfiLibUninstallDriverBindingComponentName2 (
1456 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1457 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1458 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2 OPTIONAL
1463 Installs Driver Binding Protocol with optional Component Name, Component Name 2, Driver
1464 Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.
1466 Initializes a driver by installing the Driver Binding Protocol together with the optional
1467 Component Name, optional Component Name 2, optional Driver Configuration, optional Driver Configuration 2,
1468 optional Driver Diagnostic, and optional Driver Diagnostic 2 Protocols onto the driver's DriverBindingHandle.
1469 DriverBindingHandle is typically the same as the driver's ImageHandle, but it can be different if the driver
1470 produces multiple Driver Binding Protocols.
1471 If DriverBinding is NULL, then ASSERT().
1472 If the installation fails, then ASSERT().
1475 @param ImageHandle The image handle of the driver.
1476 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1477 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1478 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1479 parameter is NULL, then a new handle is created.
1480 @param ComponentName A Component Name Protocol instance that this driver is producing.
1481 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1482 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1483 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver is producing.
1484 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1485 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing.
1487 @retval EFI_SUCCESS The protocol installation completed successfully.
1488 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1493 EfiLibInstallAllDriverProtocols2 (
1494 IN CONST EFI_HANDLE ImageHandle
,
1495 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1496 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1497 IN EFI_HANDLE DriverBindingHandle
,
1498 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1499 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
, OPTIONAL
1500 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1501 IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL
*DriverConfiguration2
, OPTIONAL
1502 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics
, OPTIONAL
1503 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL
*DriverDiagnostics2 OPTIONAL
1508 Uninstalls Driver Binding Protocol with optional Component Name, Component Name 2, Driver
1509 Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.
1511 If DriverBinding is NULL, then ASSERT().
1512 If the installation fails, then ASSERT().
1515 @param DriverBinding A Driver Binding Protocol instance that this driver produced.
1516 @param ComponentName A Component Name Protocol instance that this driver produced.
1517 @param ComponentName2 A Component Name 2 Protocol instance that this driver produced.
1518 @param DriverConfiguration A Driver Configuration Protocol instance that this driver produced.
1519 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver produced.
1520 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver produced.
1521 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver produced.
1523 @retval EFI_SUCCESS The protocol uninstallation successfully completed.
1524 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().
1529 EfiLibUninstallAllDriverProtocols2 (
1530 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1531 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1532 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
, OPTIONAL
1533 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1534 IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL
*DriverConfiguration2
, OPTIONAL
1535 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics
, OPTIONAL
1536 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL
*DriverDiagnostics2 OPTIONAL
1541 Appends a formatted Unicode string to a Null-terminated Unicode string
1543 This function appends a formatted Unicode string to the Null-terminated
1544 Unicode string specified by String. String is optional and may be NULL.
1545 Storage for the formatted Unicode string returned is allocated using
1546 AllocatePool(). The pointer to the appended string is returned. The caller
1547 is responsible for freeing the returned string.
1549 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().
1550 If FormatString is NULL, then ASSERT().
1551 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
1553 @param[in] String A Null-terminated Unicode string.
1554 @param[in] FormatString A Null-terminated Unicode format string.
1555 @param[in] Marker VA_LIST marker for the variable argument list.
1557 @retval NULL There was not enough available memory.
1558 @return Null-terminated Unicode string is that is the formatted
1559 string appended to String.
1564 IN CHAR16
*String
, OPTIONAL
1565 IN CONST CHAR16
*FormatString
,
1570 Appends a formatted Unicode string to a Null-terminated Unicode string
1572 This function appends a formatted Unicode string to the Null-terminated
1573 Unicode string specified by String. String is optional and may be NULL.
1574 Storage for the formatted Unicode string returned is allocated using
1575 AllocatePool(). The pointer to the appended string is returned. The caller
1576 is responsible for freeing the returned string.
1578 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().
1579 If FormatString is NULL, then ASSERT().
1580 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
1582 @param[in] String A Null-terminated Unicode string.
1583 @param[in] FormatString A Null-terminated Unicode format string.
1584 @param[in] ... The variable argument list whose contents are
1585 accessed based on the format string specified by
1588 @retval NULL There was not enough available memory.
1589 @return Null-terminated Unicode string is that is the formatted
1590 string appended to String.
1595 IN CHAR16
*String
, OPTIONAL
1596 IN CONST CHAR16
*FormatString
,
1601 Returns an array of protocol instance that matches the given protocol.
1603 @param[in] Protocol Provides the protocol to search for.
1604 @param[out] NoProtocols The number of protocols returned in Buffer.
1605 @param[out] Buffer A pointer to the buffer to return the requested
1606 array of protocol instances that match Protocol.
1607 The returned buffer is allocated using
1608 EFI_BOOT_SERVICES.AllocatePool(). The caller is
1609 responsible for freeing this buffer with
1610 EFI_BOOT_SERVICES.FreePool().
1612 @retval EFI_SUCCESS The array of protocols was returned in Buffer,
1613 and the number of protocols in Buffer was
1614 returned in NoProtocols.
1615 @retval EFI_NOT_FOUND No protocols found.
1616 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1618 @retval EFI_INVALID_PARAMETER Protocol is NULL.
1619 @retval EFI_INVALID_PARAMETER NoProtocols is NULL.
1620 @retval EFI_INVALID_PARAMETER Buffer is NULL.
1625 EfiLocateProtocolBuffer (
1626 IN EFI_GUID
*Protocol
,
1627 OUT UINTN
*NoProtocols
,
1632 Open or create a file or directory, possibly creating the chain of
1633 directories leading up to the directory.
1635 EfiOpenFileByDevicePath() first locates EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on
1636 FilePath, and opens the root directory of that filesystem with
1637 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume().
1639 On the remaining device path, the longest initial sequence of
1640 FILEPATH_DEVICE_PATH nodes is node-wise traversed with
1641 EFI_FILE_PROTOCOL.Open().
1643 (As a consequence, if OpenMode includes EFI_FILE_MODE_CREATE, and Attributes
1644 includes EFI_FILE_DIRECTORY, and each FILEPATH_DEVICE_PATH specifies a single
1645 pathname component, then EfiOpenFileByDevicePath() ensures that the specified
1646 series of subdirectories exist on return.)
1648 The EFI_FILE_PROTOCOL identified by the last FILEPATH_DEVICE_PATH node is
1649 output to the caller; intermediate EFI_FILE_PROTOCOL instances are closed. If
1650 there are no FILEPATH_DEVICE_PATH nodes past the node that identifies the
1651 filesystem, then the EFI_FILE_PROTOCOL of the root directory of the
1652 filesystem is output to the caller. If a device path node that is different
1653 from FILEPATH_DEVICE_PATH is encountered relative to the filesystem, the
1654 traversal is stopped with an error, and a NULL EFI_FILE_PROTOCOL is output.
1656 @param[in,out] FilePath On input, the device path to the file or directory
1657 to open or create. The caller is responsible for
1658 ensuring that the device path pointed-to by FilePath
1659 is well-formed. On output, FilePath points one past
1660 the last node in the original device path that has
1661 been successfully processed. FilePath is set on
1662 output even if EfiOpenFileByDevicePath() returns an
1665 @param[out] File On error, File is set to NULL. On success, File is
1666 set to the EFI_FILE_PROTOCOL of the root directory
1667 of the filesystem, if there are no
1668 FILEPATH_DEVICE_PATH nodes in FilePath; otherwise,
1669 File is set to the EFI_FILE_PROTOCOL identified by
1670 the last node in FilePath.
1672 @param[in] OpenMode The OpenMode parameter to pass to
1673 EFI_FILE_PROTOCOL.Open().
1675 @param[in] Attributes The Attributes parameter to pass to
1676 EFI_FILE_PROTOCOL.Open().
1678 @retval EFI_SUCCESS The file or directory has been opened or
1681 @retval EFI_INVALID_PARAMETER FilePath is NULL; or File is NULL; or FilePath
1682 contains a device path node, past the node
1684 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, that is not a
1685 FILEPATH_DEVICE_PATH node.
1687 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
1689 @return Error codes propagated from the
1690 LocateDevicePath() and OpenProtocol() boot
1691 services, and from the
1692 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume()
1693 and EFI_FILE_PROTOCOL.Open() member functions.
1697 EfiOpenFileByDevicePath (
1698 IN OUT EFI_DEVICE_PATH_PROTOCOL
**FilePath
,
1699 OUT EFI_FILE_PROTOCOL
**File
,
1701 IN UINT64 Attributes
1705 This function locates next ACPI table in XSDT/RSDT based on Signature and
1706 previous returned Table.
1708 If PreviousTable is NULL:
1709 This function will locate the first ACPI table in XSDT/RSDT based on
1710 Signature in gEfiAcpi20TableGuid system configuration table first, and then
1711 gEfiAcpi10TableGuid system configuration table.
1712 This function will locate in XSDT first, and then RSDT.
1713 For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in
1715 For FACS, this function will locate XFirmwareCtrl in FADT first, and then
1716 FirmwareCtrl in FADT.
1718 If PreviousTable is not NULL:
1719 1. If it could be located in XSDT in gEfiAcpi20TableGuid system configuration
1720 table, then this function will just locate next table in XSDT in
1721 gEfiAcpi20TableGuid system configuration table.
1722 2. If it could be located in RSDT in gEfiAcpi20TableGuid system configuration
1723 table, then this function will just locate next table in RSDT in
1724 gEfiAcpi20TableGuid system configuration table.
1725 3. If it could be located in RSDT in gEfiAcpi10TableGuid system configuration
1726 table, then this function will just locate next table in RSDT in
1727 gEfiAcpi10TableGuid system configuration table.
1729 It's not supported that PreviousTable is not NULL but PreviousTable->Signature
1730 is not same with Signature, NULL will be returned.
1732 @param Signature ACPI table signature.
1733 @param PreviousTable Pointer to previous returned table to locate next
1734 table, or NULL to locate first table.
1736 @return Next ACPI table or NULL if not found.
1739 EFI_ACPI_COMMON_HEADER
*
1741 EfiLocateNextAcpiTable (
1742 IN UINT32 Signature
,
1743 IN EFI_ACPI_COMMON_HEADER
*PreviousTable OPTIONAL
1747 This function locates first ACPI table in XSDT/RSDT based on Signature.
1749 This function will locate the first ACPI table in XSDT/RSDT based on
1750 Signature in gEfiAcpi20TableGuid system configuration table first, and then
1751 gEfiAcpi10TableGuid system configuration table.
1752 This function will locate in XSDT first, and then RSDT.
1753 For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in
1755 For FACS, this function will locate XFirmwareCtrl in FADT first, and then
1756 FirmwareCtrl in FADT.
1758 @param Signature ACPI table signature.
1760 @return First ACPI table or NULL if not found.
1763 EFI_ACPI_COMMON_HEADER
*
1765 EfiLocateFirstAcpiTable (