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 @retval EFI_OUT_OF_RESOURCES Allocate buffer failed.
741 @retval EFI_SUCCESS Find the specified variable.
742 @retval 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 @retval EFI_OUT_OF_RESOURCES Allocate buffer failed.
769 @retval EFI_SUCCESS Find the specified variable.
770 @retval Others Errors Return errors from call to gRT->GetVariable.
775 GetEfiGlobalVariable2 (
776 IN CONST CHAR16
*Name
,
778 OUT UINTN
*Size OPTIONAL
781 /** Return the attributes of the variable.
783 Returns the status whether get the variable success. The function retrieves
784 variable through the UEFI Runtime Service GetVariable(). The
785 returned buffer is allocated using AllocatePool(). The caller is responsible
786 for freeing this buffer with FreePool(). The attributes are returned if
787 the caller provides a valid Attribute parameter.
789 If Name is NULL, then ASSERT().
790 If Guid is NULL, then ASSERT().
791 If Value is NULL, then ASSERT().
793 @param[in] Name The pointer to a Null-terminated Unicode string.
794 @param[in] Guid The pointer to an EFI_GUID structure
795 @param[out] Value The buffer point saved the variable info.
796 @param[out] Size The buffer size of the variable.
797 @param[out] Attr The pointer to the variable attributes as found in var store
799 @retval EFI_OUT_OF_RESOURCES Allocate buffer failed.
800 @retval EFI_SUCCESS Find the specified variable.
801 @retval Others Errors Return errors from call to gRT->GetVariable.
807 IN CONST CHAR16
*Name
,
808 IN CONST EFI_GUID
*Guid
,
810 OUT UINTN
*Size OPTIONAL
,
811 OUT UINT32
*Attr OPTIONAL
815 Returns a pointer to an allocated buffer that contains the best matching language
816 from a set of supported languages.
818 This function supports both ISO 639-2 and RFC 4646 language codes, but language
819 code types may not be mixed in a single call to this function. The language
820 code returned is allocated using AllocatePool(). The caller is responsible for
821 freeing the allocated buffer using FreePool(). This function supports a variable
822 argument list that allows the caller to pass in a prioritized list of language
823 codes to test against all the language codes in SupportedLanguages.
825 If SupportedLanguages is NULL, then ASSERT().
827 @param[in] SupportedLanguages A pointer to a Null-terminated ASCII string that
828 contains a set of language codes in the format
829 specified by Iso639Language.
830 @param[in] Iso639Language If not zero, then all language codes are assumed to be
831 in ISO 639-2 format. If zero, then all language
832 codes are assumed to be in RFC 4646 language format
833 @param[in] ... A variable argument list that contains pointers to
834 Null-terminated ASCII strings that contain one or more
835 language codes in the format specified by Iso639Language.
836 The first language code from each of these language
837 code lists is used to determine if it is an exact or
838 close match to any of the language codes in
839 SupportedLanguages. Close matches only apply to RFC 4646
840 language codes, and the matching algorithm from RFC 4647
841 is used to determine if a close match is present. If
842 an exact or close match is found, then the matching
843 language code from SupportedLanguages is returned. If
844 no matches are found, then the next variable argument
845 parameter is evaluated. The variable argument list
846 is terminated by a NULL.
848 @retval NULL The best matching language could not be found in SupportedLanguages.
849 @retval NULL There are not enough resources available to return the best matching
851 @retval Other A pointer to a Null-terminated ASCII string that is the best matching
852 language in SupportedLanguages.
858 IN CONST CHAR8
*SupportedLanguages
,
859 IN UINTN Iso639Language
,
864 Draws a dialog box to the console output device specified by
865 ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke
866 from the console input device specified by ConIn defined in the
869 If there are no strings in the variable argument list, then ASSERT().
870 If all the strings in the variable argument list are empty, then ASSERT().
872 @param[in] Attribute Specifies the foreground and background color of the popup.
873 @param[out] Key A pointer to the EFI_KEY value of the key that was
874 pressed. This is an optional parameter that may be NULL.
875 If it is NULL then no wait for a keypress will be performed.
876 @param[in] ... The variable argument list that contains pointers to Null-
877 terminated Unicode strings to display in the dialog box.
878 The variable argument list is terminated by a NULL.
885 OUT EFI_INPUT_KEY
*Key
, OPTIONAL
890 Retrieves the width of a Unicode character.
892 This function computes and returns the width of the Unicode character specified
895 @param UnicodeChar A Unicode character.
897 @retval 0 The width if UnicodeChar could not be determined.
898 @retval 1 UnicodeChar is a narrow glyph.
899 @retval 2 UnicodeChar is a wide glyph.
905 IN CHAR16 UnicodeChar
909 Computes the display length of a Null-terminated Unicode String.
911 This function computes and returns the display length of the Null-terminated Unicode
912 string specified by String. If String is NULL then 0 is returned. If any of the widths
913 of the Unicode characters in String can not be determined, then 0 is returned. The display
914 width of String can be computed by summing the display widths of each Unicode character
915 in String. Unicode characters that are narrow glyphs have a width of 1, and Unicode
916 characters that are width glyphs have a width of 2.
917 If String is not aligned on a 16-bit boundary, then ASSERT().
919 @param String A pointer to a Null-terminated Unicode string.
921 @return The display length of the Null-terminated Unicode string specified by String.
926 UnicodeStringDisplayLength (
927 IN CONST CHAR16
*String
931 // Functions that abstract early Framework contamination of UEFI.
934 Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().
936 This function abstracts the signaling of the Ready to Boot Event. The Framework moved
937 from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller
938 from how this event is created to prevent to code form having to change with the
939 version of the specification supported.
944 EfiSignalEventReadyToBoot (
949 Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().
951 This function abstracts the signaling of the Legacy Boot Event. The Framework moved from
952 a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how
953 this event is created to prevent to code form having to change with the version of the
954 specification supported.
959 EfiSignalEventLegacyBoot (
964 Creates an EFI event in the Legacy Boot Event Group.
966 Prior to UEFI 2.0 this was done via a non blessed UEFI extensions and this library
967 abstracts the implementation mechanism of this event from the caller. This function
968 abstracts the creation of the Legacy Boot Event. The Framework moved from a proprietary
969 to UEFI 2.0 based mechanism. This library abstracts the caller from how this event
970 is created to prevent to code form having to change with the version of the
971 specification supported.
972 If LegacyBootEvent is NULL, then ASSERT().
974 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
976 @retval EFI_SUCCESS The event was created.
977 @retval Other The event was not created.
982 EfiCreateEventLegacyBoot (
983 OUT EFI_EVENT
*LegacyBootEvent
987 Create an EFI event in the Legacy Boot Event Group and allows
988 the caller to specify a notification function.
990 This function abstracts the creation of the Legacy Boot Event.
991 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
992 This library abstracts the caller from how this event is created to prevent
993 to code form having to change with the version of the specification supported.
994 If LegacyBootEvent is NULL, then ASSERT().
996 @param NotifyTpl The task priority level of the event.
997 @param NotifyFunction The notification function to call when the event is signaled.
998 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
999 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
1001 @retval EFI_SUCCESS The event was created.
1002 @retval Other The event was not created.
1007 EfiCreateEventLegacyBootEx (
1008 IN EFI_TPL NotifyTpl
,
1009 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1010 IN VOID
*NotifyContext
, OPTIONAL
1011 OUT EFI_EVENT
*LegacyBootEvent
1015 Create an EFI event in the Ready To Boot Event Group.
1017 Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library
1018 abstracts the implementation mechanism of this event from the caller.
1019 This function abstracts the creation of the Ready to Boot Event. The Framework
1020 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts
1021 the caller from how this event is created to prevent the code form having to
1022 change with the version of the specification supported.
1023 If ReadyToBootEvent is NULL, then ASSERT().
1025 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
1027 @retval EFI_SUCCESS The event was created.
1028 @retval Other The event was not created.
1033 EfiCreateEventReadyToBoot (
1034 OUT EFI_EVENT
*ReadyToBootEvent
1038 Create an EFI event in the Ready To Boot Event Group and allows
1039 the caller to specify a notification function.
1041 This function abstracts the creation of the Ready to Boot Event.
1042 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
1043 This library abstracts the caller from how this event is created to prevent
1044 to code form having to change with the version of the specification supported.
1045 If ReadyToBootEvent is NULL, then ASSERT().
1047 @param NotifyTpl The task priority level of the event.
1048 @param NotifyFunction The notification function to call when the event is signaled.
1049 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
1050 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
1052 @retval EFI_SUCCESS The event was created.
1053 @retval Other The event was not created.
1058 EfiCreateEventReadyToBootEx (
1059 IN EFI_TPL NotifyTpl
,
1060 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1061 IN VOID
*NotifyContext
, OPTIONAL
1062 OUT EFI_EVENT
*ReadyToBootEvent
1066 Initialize a Firmware Volume (FV) Media Device Path node.
1068 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
1069 This library function abstracts initializing a device path node.
1070 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device
1071 path changed in the DXE CIS version 0.92 in a non back ward compatible way to
1072 not conflict with the UEFI 2.0 specification. This function abstracts the
1073 differences from the caller.
1074 If FvDevicePathNode is NULL, then ASSERT().
1075 If NameGuid is NULL, then ASSERT().
1077 @param FvDevicePathNode The pointer to a FV device path node to initialize
1078 @param NameGuid FV file name to use in FvDevicePathNode
1083 EfiInitializeFwVolDevicepathNode (
1084 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
1085 IN CONST EFI_GUID
*NameGuid
1089 Check to see if the Firmware Volume (FV) Media Device Path is valid
1091 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
1092 This library function abstracts validating a device path node.
1093 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.
1094 If it is valid, then return the GUID file name from the device path node. Otherwise,
1095 return NULL. This device path changed in the DXE CIS version 0.92 in a non backward
1096 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts
1097 the differences from the caller.
1098 If FvDevicePathNode is NULL, then ASSERT().
1100 @param FvDevicePathNode The pointer to FV device path to check.
1102 @retval NULL FvDevicePathNode is not valid.
1103 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
1108 EfiGetNameGuidFromFwVolDevicePathNode (
1109 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
1113 Prints a formatted Unicode string to the console output device specified by
1114 ConOut defined in the EFI_SYSTEM_TABLE.
1116 This function prints a formatted Unicode string to the console output device
1117 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
1118 characters that printed to ConOut. If the length of the formatted Unicode
1119 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1120 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
1121 If Format is NULL, then ASSERT().
1122 If Format is not aligned on a 16-bit boundary, then ASSERT().
1123 If gST->ConOut is NULL, then ASSERT().
1125 @param Format A null-terminated Unicode format string.
1126 @param ... The variable argument list whose contents are accessed based
1127 on the format string specified by Format.
1129 @return Number of Unicode characters printed to ConOut.
1135 IN CONST CHAR16
*Format
,
1140 Prints a formatted Unicode string to the console output device specified by
1141 StdErr defined in the EFI_SYSTEM_TABLE.
1143 This function prints a formatted Unicode string to the console output device
1144 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
1145 characters that printed to StdErr. If the length of the formatted Unicode
1146 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1147 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
1148 If Format is NULL, then ASSERT().
1149 If Format is not aligned on a 16-bit boundary, then ASSERT().
1150 If gST->StdErr is NULL, then ASSERT().
1152 @param Format A null-terminated Unicode format string.
1153 @param ... The variable argument list whose contents are accessed based
1154 on the format string specified by Format.
1156 @return Number of Unicode characters printed to StdErr.
1162 IN CONST CHAR16
*Format
,
1167 Prints a formatted ASCII string to the console output device specified by
1168 ConOut defined in the EFI_SYSTEM_TABLE.
1170 This function prints a formatted ASCII string to the console output device
1171 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
1172 characters that printed to ConOut. If the length of the formatted ASCII
1173 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1174 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
1175 If Format is NULL, then ASSERT().
1176 If gST->ConOut is NULL, then ASSERT().
1178 @param Format A null-terminated ASCII format string.
1179 @param ... The variable argument list whose contents are accessed based
1180 on the format string specified by Format.
1182 @return Number of ASCII characters printed to ConOut.
1188 IN CONST CHAR8
*Format
,
1193 Prints a formatted ASCII string to the console output device specified by
1194 StdErr defined in the EFI_SYSTEM_TABLE.
1196 This function prints a formatted ASCII string to the console output device
1197 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
1198 characters that printed to StdErr. If the length of the formatted ASCII
1199 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1200 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
1201 If Format is NULL, then ASSERT().
1202 If gST->StdErr is NULL, then ASSERT().
1204 @param Format A null-terminated ASCII format string.
1205 @param ... The variable argument list whose contents are accessed based
1206 on the format string specified by Format.
1208 @return Number of ASCII characters printed to ConErr.
1214 IN CONST CHAR8
*Format
,
1220 Prints a formatted Unicode string to a graphics console device specified by
1221 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
1223 This function prints a formatted Unicode string to the graphics console device
1224 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
1225 Unicode characters displayed, not including partial characters that may be clipped
1226 by the right edge of the display. If the length of the formatted Unicode string is
1227 greater than PcdUefiLibMaxPrintBufferSize, then at most the first
1228 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
1229 is used to convert the string to a bitmap using the glyphs registered with the
1230 HII database. No wrapping is performed, so any portions of the string the fall
1231 outside the active display region will not be displayed.
1233 If a graphics console device is not associated with the ConsoleOutputHandle
1234 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
1235 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
1236 string is printed, and 0 is returned.
1237 If Format is NULL, then ASSERT().
1238 If Format is not aligned on a 16-bit boundary, then ASSERT().
1239 If gST->ConsoleOutputHandle is NULL, then ASSERT().
1241 @param PointX X coordinate to print the string.
1242 @param PointY Y coordinate to print the string.
1243 @param ForeGround The foreground color of the string being printed. This is
1244 an optional parameter that may be NULL. If it is NULL,
1245 then the foreground color of the current ConOut device
1246 in the EFI_SYSTEM_TABLE is used.
1247 @param BackGround The background color of the string being printed. This is
1248 an optional parameter that may be NULL. If it is NULL,
1249 then the background color of the current ConOut device
1250 in the EFI_SYSTEM_TABLE is used.
1251 @param Format A null-terminated Unicode format string. See Print Library
1252 for the supported format string syntax.
1253 @param ... Variable argument list whose contents are accessed based on
1254 the format string specified by Format.
1256 @return The number of Unicode characters printed.
1264 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
1265 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
1266 IN CONST CHAR16
*Format
,
1271 Prints a formatted ASCII string to a graphics console device specified by
1272 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
1274 This function prints a formatted ASCII string to the graphics console device
1275 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
1276 ASCII characters displayed, not including partial characters that may be clipped
1277 by the right edge of the display. If the length of the formatted ASCII string is
1278 greater than PcdUefiLibMaxPrintBufferSize, then at most the first
1279 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
1280 is used to convert the string to a bitmap using the glyphs registered with the
1281 HII database. No wrapping is performed, so any portions of the string the fall
1282 outside the active display region will not be displayed.
1284 If a graphics console device is not associated with the ConsoleOutputHandle
1285 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
1286 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
1287 string is printed, and 0 is returned.
1288 If Format is NULL, then ASSERT().
1289 If gST->ConsoleOutputHandle is NULL, then ASSERT().
1291 @param PointX X coordinate to print the string.
1292 @param PointY Y coordinate to print the string.
1293 @param ForeGround The foreground color of the string being printed. This is
1294 an optional parameter that may be NULL. If it is NULL,
1295 then the foreground color of the current ConOut device
1296 in the EFI_SYSTEM_TABLE is used.
1297 @param BackGround The background color of the string being printed. This is
1298 an optional parameter that may be NULL. If it is NULL,
1299 then the background color of the current ConOut device
1300 in the EFI_SYSTEM_TABLE is used.
1301 @param Format A null-terminated ASCII format string. See Print Library
1302 for the supported format string syntax.
1303 @param ... The variable argument list whose contents are accessed based on
1304 the format string specified by Format.
1306 @return The number of ASCII characters printed.
1314 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
1315 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
1316 IN CONST CHAR8
*Format
,
1322 Installs and completes the initialization of a Driver Binding Protocol instance.
1324 Installs the Driver Binding Protocol specified by DriverBinding onto the handle
1325 specified by DriverBindingHandle. If DriverBindingHandle is NULL, then DriverBinding
1326 is installed onto a newly created handle. DriverBindingHandle is typically the same
1327 as the driver's ImageHandle, but it can be different if the driver produces multiple
1328 Driver Binding Protocols.
1329 If DriverBinding is NULL, then ASSERT().
1330 If DriverBinding can not be installed onto a handle, then ASSERT().
1332 @param ImageHandle The image handle of the driver.
1333 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1334 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1335 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1336 parameter is NULL, then a new handle is created.
1338 @retval EFI_SUCCESS The protocol installation completed successfully.
1339 @retval EFI_OUT_OF_RESOURCES There was not enough system resources to install the protocol.
1340 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
1345 EfiLibInstallDriverBinding (
1346 IN CONST EFI_HANDLE ImageHandle
,
1347 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1348 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1349 IN EFI_HANDLE DriverBindingHandle
1354 Uninstalls a Driver Binding Protocol instance.
1356 If DriverBinding is NULL, then ASSERT().
1357 If DriverBinding can not be uninstalled, then ASSERT().
1359 @param DriverBinding A Driver Binding Protocol instance that this driver produced.
1361 @retval EFI_SUCCESS The protocol uninstallation successfully completed.
1362 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().
1367 EfiLibUninstallDriverBinding (
1368 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
1373 Installs and completes the initialization of a Driver Binding Protocol instance and
1374 optionally installs the Component Name, Driver Configuration and Driver Diagnostics Protocols.
1376 Initializes a driver by installing the Driver Binding Protocol together with the
1377 optional Component Name, optional Driver Configure and optional Driver Diagnostic
1378 Protocols onto the driver's DriverBindingHandle. If DriverBindingHandle is NULL,
1379 then the protocols are installed onto a newly created handle. DriverBindingHandle
1380 is typically the same as the driver's ImageHandle, but it can be different if the
1381 driver produces multiple Driver Binding Protocols.
1382 If DriverBinding is NULL, then ASSERT().
1383 If the installation fails, then ASSERT().
1385 @param ImageHandle The image handle of the driver.
1386 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1387 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1388 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1389 parameter is NULL, then a new handle is created.
1390 @param ComponentName A Component Name Protocol instance that this driver is producing.
1391 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1392 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1394 @retval EFI_SUCCESS The protocol installation completed successfully.
1395 @retval EFI_OUT_OF_RESOURCES There was not enough memory in the pool to install all the protocols.
1400 EfiLibInstallAllDriverProtocols (
1401 IN CONST EFI_HANDLE ImageHandle
,
1402 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1403 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1404 IN EFI_HANDLE DriverBindingHandle
,
1405 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1406 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1407 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics OPTIONAL
1412 Uninstalls a Driver Binding Protocol instance and optionally uninstalls the
1413 Component Name, Driver Configuration and Driver Diagnostics Protocols.
1415 If DriverBinding is NULL, then ASSERT().
1416 If the uninstallation fails, then ASSERT().
1418 @param DriverBinding A Driver Binding Protocol instance that this driver produced.
1419 @param ComponentName A Component Name Protocol instance that this driver produced.
1420 @param DriverConfiguration A Driver Configuration Protocol instance that this driver produced.
1421 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver produced.
1423 @retval EFI_SUCCESS The protocol uninstallation successfully completed.
1424 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().
1429 EfiLibUninstallAllDriverProtocols (
1430 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1431 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1432 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1433 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics OPTIONAL
1438 Installs Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.
1440 Initializes a driver by installing the Driver Binding Protocol together with the
1441 optional Component Name and optional Component Name 2 protocols onto the driver's
1442 DriverBindingHandle. If DriverBindingHandle is NULL, then the protocols are installed
1443 onto a newly created handle. DriverBindingHandle is typically the same as the driver's
1444 ImageHandle, but it can be different if the driver produces multiple Driver Binding Protocols.
1445 If DriverBinding is NULL, then ASSERT().
1446 If the installation fails, then ASSERT().
1448 @param ImageHandle The image handle of the driver.
1449 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1450 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1451 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1452 parameter is NULL, then a new handle is created.
1453 @param ComponentName A Component Name Protocol instance that this driver is producing.
1454 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1456 @retval EFI_SUCCESS The protocol installation completed successfully.
1457 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1462 EfiLibInstallDriverBindingComponentName2 (
1463 IN CONST EFI_HANDLE ImageHandle
,
1464 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1465 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1466 IN EFI_HANDLE DriverBindingHandle
,
1467 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1468 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2 OPTIONAL
1473 Uninstalls Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.
1475 If DriverBinding is NULL, then ASSERT().
1476 If the uninstallation fails, then ASSERT().
1478 @param DriverBinding A Driver Binding Protocol instance that this driver produced.
1479 @param ComponentName A Component Name Protocol instance that this driver produced.
1480 @param ComponentName2 A Component Name 2 Protocol instance that this driver produced.
1482 @retval EFI_SUCCESS The protocol installation successfully completed.
1483 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().
1488 EfiLibUninstallDriverBindingComponentName2 (
1489 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1490 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1491 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2 OPTIONAL
1496 Installs Driver Binding Protocol with optional Component Name, Component Name 2, Driver
1497 Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.
1499 Initializes a driver by installing the Driver Binding Protocol together with the optional
1500 Component Name, optional Component Name 2, optional Driver Configuration, optional Driver Configuration 2,
1501 optional Driver Diagnostic, and optional Driver Diagnostic 2 Protocols onto the driver's DriverBindingHandle.
1502 DriverBindingHandle is typically the same as the driver's ImageHandle, but it can be different if the driver
1503 produces multiple Driver Binding Protocols.
1504 If DriverBinding is NULL, then ASSERT().
1505 If the installation fails, then ASSERT().
1508 @param ImageHandle The image handle of the driver.
1509 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1510 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1511 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1512 parameter is NULL, then a new handle is created.
1513 @param ComponentName A Component Name Protocol instance that this driver is producing.
1514 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1515 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1516 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver is producing.
1517 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1518 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing.
1520 @retval EFI_SUCCESS The protocol installation completed successfully.
1521 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1526 EfiLibInstallAllDriverProtocols2 (
1527 IN CONST EFI_HANDLE ImageHandle
,
1528 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1529 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1530 IN EFI_HANDLE DriverBindingHandle
,
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 Uninstalls Driver Binding Protocol with optional Component Name, Component Name 2, Driver
1542 Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.
1544 If DriverBinding is NULL, then ASSERT().
1545 If the installation fails, then ASSERT().
1548 @param DriverBinding A Driver Binding Protocol instance that this driver produced.
1549 @param ComponentName A Component Name Protocol instance that this driver produced.
1550 @param ComponentName2 A Component Name 2 Protocol instance that this driver produced.
1551 @param DriverConfiguration A Driver Configuration Protocol instance that this driver produced.
1552 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver produced.
1553 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver produced.
1554 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver produced.
1556 @retval EFI_SUCCESS The protocol uninstallation successfully completed.
1557 @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().
1562 EfiLibUninstallAllDriverProtocols2 (
1563 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1564 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1565 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
, OPTIONAL
1566 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1567 IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL
*DriverConfiguration2
, OPTIONAL
1568 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics
, OPTIONAL
1569 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL
*DriverDiagnostics2 OPTIONAL
1574 Appends a formatted Unicode string to a Null-terminated Unicode string
1576 This function appends a formatted Unicode string to the Null-terminated
1577 Unicode string specified by String. String is optional and may be NULL.
1578 Storage for the formatted Unicode string returned is allocated using
1579 AllocatePool(). The pointer to the appended string is returned. The caller
1580 is responsible for freeing the returned string.
1582 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().
1583 If FormatString is NULL, then ASSERT().
1584 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
1586 @param[in] String A Null-terminated Unicode string.
1587 @param[in] FormatString A Null-terminated Unicode format string.
1588 @param[in] Marker VA_LIST marker for the variable argument list.
1590 @retval NULL There was not enough available memory.
1591 @return Null-terminated Unicode string is that is the formatted
1592 string appended to String.
1597 IN CHAR16
*String
, OPTIONAL
1598 IN CONST CHAR16
*FormatString
,
1603 Appends a formatted Unicode string to a Null-terminated Unicode string
1605 This function appends a formatted Unicode string to the Null-terminated
1606 Unicode string specified by String. String is optional and may be NULL.
1607 Storage for the formatted Unicode string returned is allocated using
1608 AllocatePool(). The pointer to the appended string is returned. The caller
1609 is responsible for freeing the returned string.
1611 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().
1612 If FormatString is NULL, then ASSERT().
1613 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
1615 @param[in] String A Null-terminated Unicode string.
1616 @param[in] FormatString A Null-terminated Unicode format string.
1617 @param[in] ... The variable argument list whose contents are
1618 accessed based on the format string specified by
1621 @retval NULL There was not enough available memory.
1622 @return Null-terminated Unicode string is that is the formatted
1623 string appended to String.
1628 IN CHAR16
*String
, OPTIONAL
1629 IN CONST CHAR16
*FormatString
,
1634 Returns an array of protocol instance that matches the given protocol.
1636 @param[in] Protocol Provides the protocol to search for.
1637 @param[out] NoProtocols The number of protocols returned in Buffer.
1638 @param[out] Buffer A pointer to the buffer to return the requested
1639 array of protocol instances that match Protocol.
1640 The returned buffer is allocated using
1641 EFI_BOOT_SERVICES.AllocatePool(). The caller is
1642 responsible for freeing this buffer with
1643 EFI_BOOT_SERVICES.FreePool().
1645 @retval EFI_SUCCESS The array of protocols was returned in Buffer,
1646 and the number of protocols in Buffer was
1647 returned in NoProtocols.
1648 @retval EFI_NOT_FOUND No protocols found.
1649 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1651 @retval EFI_INVALID_PARAMETER Protocol is NULL.
1652 @retval EFI_INVALID_PARAMETER NoProtocols is NULL.
1653 @retval EFI_INVALID_PARAMETER Buffer is NULL.
1658 EfiLocateProtocolBuffer (
1659 IN EFI_GUID
*Protocol
,
1660 OUT UINTN
*NoProtocols
,
1665 Open or create a file or directory, possibly creating the chain of
1666 directories leading up to the directory.
1668 EfiOpenFileByDevicePath() first locates EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on
1669 FilePath, and opens the root directory of that filesystem with
1670 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume().
1672 On the remaining device path, the longest initial sequence of
1673 FILEPATH_DEVICE_PATH nodes is node-wise traversed with
1674 EFI_FILE_PROTOCOL.Open().
1676 (As a consequence, if OpenMode includes EFI_FILE_MODE_CREATE, and Attributes
1677 includes EFI_FILE_DIRECTORY, and each FILEPATH_DEVICE_PATH specifies a single
1678 pathname component, then EfiOpenFileByDevicePath() ensures that the specified
1679 series of subdirectories exist on return.)
1681 The EFI_FILE_PROTOCOL identified by the last FILEPATH_DEVICE_PATH node is
1682 output to the caller; intermediate EFI_FILE_PROTOCOL instances are closed. If
1683 there are no FILEPATH_DEVICE_PATH nodes past the node that identifies the
1684 filesystem, then the EFI_FILE_PROTOCOL of the root directory of the
1685 filesystem is output to the caller. If a device path node that is different
1686 from FILEPATH_DEVICE_PATH is encountered relative to the filesystem, the
1687 traversal is stopped with an error, and a NULL EFI_FILE_PROTOCOL is output.
1689 @param[in,out] FilePath On input, the device path to the file or directory
1690 to open or create. The caller is responsible for
1691 ensuring that the device path pointed-to by FilePath
1692 is well-formed. On output, FilePath points one past
1693 the last node in the original device path that has
1694 been successfully processed. FilePath is set on
1695 output even if EfiOpenFileByDevicePath() returns an
1698 @param[out] File On error, File is set to NULL. On success, File is
1699 set to the EFI_FILE_PROTOCOL of the root directory
1700 of the filesystem, if there are no
1701 FILEPATH_DEVICE_PATH nodes in FilePath; otherwise,
1702 File is set to the EFI_FILE_PROTOCOL identified by
1703 the last node in FilePath.
1705 @param[in] OpenMode The OpenMode parameter to pass to
1706 EFI_FILE_PROTOCOL.Open().
1708 @param[in] Attributes The Attributes parameter to pass to
1709 EFI_FILE_PROTOCOL.Open().
1711 @retval EFI_SUCCESS The file or directory has been opened or
1714 @retval EFI_INVALID_PARAMETER FilePath is NULL; or File is NULL; or FilePath
1715 contains a device path node, past the node
1717 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, that is not a
1718 FILEPATH_DEVICE_PATH node.
1720 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
1722 @return Error codes propagated from the
1723 LocateDevicePath() and OpenProtocol() boot
1724 services, and from the
1725 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume()
1726 and EFI_FILE_PROTOCOL.Open() member functions.
1730 EfiOpenFileByDevicePath (
1731 IN OUT EFI_DEVICE_PATH_PROTOCOL
**FilePath
,
1732 OUT EFI_FILE_PROTOCOL
**File
,
1734 IN UINT64 Attributes
1738 This function locates next ACPI table in XSDT/RSDT based on Signature and
1739 previous returned Table.
1741 If PreviousTable is NULL:
1742 This function will locate the first ACPI table in XSDT/RSDT based on
1743 Signature in gEfiAcpi20TableGuid system configuration table first, and then
1744 gEfiAcpi10TableGuid system configuration table.
1745 This function will locate in XSDT first, and then RSDT.
1746 For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in
1748 For FACS, this function will locate XFirmwareCtrl in FADT first, and then
1749 FirmwareCtrl in FADT.
1751 If PreviousTable is not NULL:
1752 1. If it could be located in XSDT in gEfiAcpi20TableGuid system configuration
1753 table, then this function will just locate next table in XSDT in
1754 gEfiAcpi20TableGuid system configuration table.
1755 2. If it could be located in RSDT in gEfiAcpi20TableGuid system configuration
1756 table, then this function will just locate next table in RSDT in
1757 gEfiAcpi20TableGuid system configuration table.
1758 3. If it could be located in RSDT in gEfiAcpi10TableGuid system configuration
1759 table, then this function will just locate next table in RSDT in
1760 gEfiAcpi10TableGuid system configuration table.
1762 It's not supported that PreviousTable is not NULL but PreviousTable->Signature
1763 is not same with Signature, NULL will be returned.
1765 @param Signature ACPI table signature.
1766 @param PreviousTable Pointer to previous returned table to locate next
1767 table, or NULL to locate first table.
1769 @return Next ACPI table or NULL if not found.
1772 EFI_ACPI_COMMON_HEADER
*
1774 EfiLocateNextAcpiTable (
1775 IN UINT32 Signature
,
1776 IN EFI_ACPI_COMMON_HEADER
*PreviousTable OPTIONAL
1780 This function locates first ACPI table in XSDT/RSDT based on Signature.
1782 This function will locate the first ACPI table in XSDT/RSDT based on
1783 Signature in gEfiAcpi20TableGuid system configuration table first, and then
1784 gEfiAcpi10TableGuid system configuration table.
1785 This function will locate in XSDT first, and then RSDT.
1786 For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in
1788 For FACS, this function will locate XFirmwareCtrl in FADT first, and then
1789 FirmwareCtrl in FADT.
1791 @param Signature ACPI table signature.
1793 @return First ACPI table or NULL if not found.
1796 EFI_ACPI_COMMON_HEADER
*
1798 EfiLocateFirstAcpiTable (