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) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
16 This program and the accompanying materials are licensed and made available under
17 the terms and conditions of the BSD License that accompanies this distribution.
18 The full text of the license may be found at
19 http://opensource.org/licenses/bsd-license.php.
21 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
22 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
26 #ifndef __UEFI_LIB_H__
27 #define __UEFI_LIB_H__
29 #include <Protocol/DriverBinding.h>
30 #include <Protocol/DriverConfiguration.h>
31 #include <Protocol/ComponentName.h>
32 #include <Protocol/ComponentName2.h>
33 #include <Protocol/DriverDiagnostics.h>
34 #include <Protocol/DriverDiagnostics2.h>
35 #include <Protocol/GraphicsOutput.h>
36 #include <Protocol/DevicePath.h>
37 #include <Protocol/SimpleFileSystem.h>
39 #include <Library/BaseLib.h>
42 /// Unicode String Table
46 CHAR16
*UnicodeString
;
47 } EFI_UNICODE_STRING_TABLE
;
53 EfiLockUninitialized
= 0,
68 Macro that returns the number of 100 ns units for a specified number of microseconds.
69 This is useful for managing EFI timer events.
71 @param Microseconds The number of microseconds.
73 @return The number of 100 ns units equivalent to the number of microseconds specified
77 #define EFI_TIMER_PERIOD_MICROSECONDS(Microseconds) MultU64x32((UINT64)(Microseconds), 10)
80 Macro that returns the number of 100 ns units for a specified number of milliseconds.
81 This is useful for managing EFI timer events.
83 @param Milliseconds The number of milliseconds.
85 @return The number of 100 ns units equivalent to the number of milliseconds specified
89 #define EFI_TIMER_PERIOD_MILLISECONDS(Milliseconds) MultU64x32((UINT64)(Milliseconds), 10000)
92 Macro that returns the number of 100 ns units for a specified number of seconds.
93 This is useful for managing EFI timer events.
95 @param Seconds The number of seconds.
97 @return The number of 100 ns units equivalent to the number of seconds specified
101 #define EFI_TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)
104 Macro that returns the a pointer to the next EFI_MEMORY_DESCRIPTOR in an array
105 returned from GetMemoryMap().
107 @param MemoryDescriptor A pointer to an EFI_MEMORY_DESCRIPTOR.
109 @param Size The size, in bytes, of the current EFI_MEMORY_DESCRIPTOR.
111 @return A pointer to the next EFI_MEMORY_DESCRIPTOR.
114 #define NEXT_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
115 ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) + (Size)))
118 Retrieves a pointer to the system configuration table from the EFI System Table
119 based on a specified GUID.
121 This function searches the list of configuration tables stored in the EFI System Table
122 for a table with a GUID that matches TableGuid. If a match is found, then a pointer to
123 the configuration table is returned in Table, and EFI_SUCCESS is returned. If a matching GUID
124 is not found, then EFI_NOT_FOUND is returned.
125 If TableGuid is NULL, then ASSERT().
126 If Table is NULL, then ASSERT().
128 @param TableGuid The pointer to table's GUID type..
129 @param Table The pointer to the table associated with TableGuid in the EFI System Table.
131 @retval EFI_SUCCESS A configuration table matching TableGuid was found.
132 @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.
137 EfiGetSystemConfigurationTable (
138 IN EFI_GUID
*TableGuid
,
143 Creates and returns a notification event and registers that event with all the protocol
144 instances specified by ProtocolGuid.
146 This function causes the notification function to be executed for every protocol of type
147 ProtocolGuid instance that exists in the system when this function is invoked. If there are
148 no instances of ProtocolGuid in the handle database at the time this function is invoked,
149 then the notification function is still executed one time. In addition, every time a protocol
150 of type ProtocolGuid instance is installed or reinstalled, the notification function is also
151 executed. This function returns the notification event that was created.
152 If ProtocolGuid is NULL, then ASSERT().
153 If NotifyTpl is not a legal TPL value, then ASSERT().
154 If NotifyFunction is NULL, then ASSERT().
155 If Registration is NULL, then ASSERT().
158 @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.
159 @param NotifyTpl Supplies the task priority level of the event notifications.
160 @param NotifyFunction Supplies the function to notify when the event is signaled.
161 @param NotifyContext The context parameter to pass to NotifyFunction.
162 @param Registration A pointer to a memory location to receive the registration value.
163 This value is passed to LocateHandle() to obtain new handles that
164 have been added that support the ProtocolGuid-specified protocol.
166 @return The notification event that was created.
171 EfiCreateProtocolNotifyEvent(
172 IN EFI_GUID
*ProtocolGuid
,
173 IN EFI_TPL NotifyTpl
,
174 IN EFI_EVENT_NOTIFY NotifyFunction
,
175 IN VOID
*NotifyContext
, OPTIONAL
176 OUT VOID
**Registration
180 Creates a named event that can be signaled with EfiNamedEventSignal().
182 This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.
183 This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more
184 listeners on the same event named by the GUID specified by Name.
185 If Name is NULL, then ASSERT().
186 If NotifyTpl is not a legal TPL value, then ASSERT().
187 If NotifyFunction is NULL, then ASSERT().
189 @param Name Supplies GUID name of the event.
190 @param NotifyTpl Supplies the task priority level of the event notifications.
191 @param NotifyFunction Supplies the function to notify when the event is signaled.
192 @param NotifyContext The context parameter to pass to NotifyFunction.
193 @param Registration A pointer to a memory location to receive the registration value.
195 @retval EFI_SUCCESS A named event was created.
196 @retval EFI_OUT_OF_RESOURCES There are not enough resources to create the named event.
201 EfiNamedEventListen (
202 IN CONST EFI_GUID
*Name
,
203 IN EFI_TPL NotifyTpl
,
204 IN EFI_EVENT_NOTIFY NotifyFunction
,
205 IN CONST VOID
*NotifyContext
, OPTIONAL
206 OUT VOID
*Registration OPTIONAL
210 Signals a named event created with EfiNamedEventListen().
212 This function signals the named event specified by Name. The named event must have been
213 created with EfiNamedEventListen().
214 If Name is NULL, then ASSERT().
216 @param Name Supplies the GUID name of the event.
218 @retval EFI_SUCCESS A named event was signaled.
219 @retval EFI_OUT_OF_RESOURCES There are not enough resources to signal the named event.
224 EfiNamedEventSignal (
225 IN CONST EFI_GUID
*Name
229 Signals an event group by placing a new event in the group temporarily and
232 @param[in] EventGroup Supplies the unique identifier of the event
235 @retval EFI_SUCCESS The event group was signaled successfully.
236 @retval EFI_INVALID_PARAMETER EventGroup is NULL.
237 @return Error codes that report problems about event
238 creation or signaling.
242 EfiEventGroupSignal (
243 IN CONST EFI_GUID
*EventGroup
247 An empty function that can be used as NotifyFunction parameter of
248 CreateEvent() or CreateEventEx().
250 @param Event Event whose notification function is being invoked.
251 @param Context The pointer to the notification function's context,
252 which is implementation-dependent.
257 EfiEventEmptyFunction (
263 Returns the current TPL.
265 This function returns the current TPL. There is no EFI service to directly
266 retrieve the current TPL. Instead, the RaiseTPL() function is used to raise
267 the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level
268 can then immediately be restored back to the current TPL level with a call
271 @return The current TPL.
281 Initializes a basic mutual exclusion lock.
283 This function initializes a basic mutual exclusion lock to the released state
284 and returns the lock. Each lock provides mutual exclusion access at its task
285 priority level. Since there is no preemption or multiprocessor support in EFI,
286 acquiring the lock only consists of raising to the locks TPL.
287 If Lock is NULL, then ASSERT().
288 If Priority is not a valid TPL value, then ASSERT().
290 @param Lock A pointer to the lock data structure to initialize.
291 @param Priority The EFI TPL associated with the lock.
299 IN OUT EFI_LOCK
*Lock
,
304 Initializes a basic mutual exclusion lock.
306 This macro initializes the contents of a basic mutual exclusion lock to the
307 released state. Each lock provides mutual exclusion access at its task
308 priority level. Since there is no preemption or multiprocessor support in EFI,
309 acquiring the lock only consists of raising to the locks TPL.
311 @param Priority The task priority level of the lock.
316 #define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \
317 {Priority, TPL_APPLICATION, EfiLockReleased }
321 Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state.
323 If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED
324 bit of PcdDebugProperyMask is set, then this macro evaluates the EFI_LOCK
325 structure specified by Lock. If Lock is not in the locked state, then
326 DebugAssert() is called passing in the source filename, source line number,
329 If Lock is NULL, then ASSERT().
331 @param LockParameter A pointer to the lock to acquire.
334 #if !defined(MDEPKG_NDEBUG)
335 #define ASSERT_LOCKED(LockParameter) \
337 if (DebugAssertEnabled ()) { \
338 ASSERT (LockParameter != NULL); \
339 if ((LockParameter)->Lock != EfiLockAcquired) { \
340 _ASSERT (LockParameter not locked); \
345 #define ASSERT_LOCKED(LockParameter)
350 Acquires ownership of a lock.
352 This function raises the system's current task priority level to the task
353 priority level of the mutual exclusion lock. Then, it places the lock in the
355 If Lock is NULL, then ASSERT().
356 If Lock is not initialized, then ASSERT().
357 If Lock is already in the acquired state, then ASSERT().
359 @param Lock A pointer to the lock to acquire.
369 Acquires ownership of a lock.
371 This function raises the system's current task priority level to the task priority
372 level of the mutual exclusion lock. Then, it attempts to place the lock in the acquired state.
373 If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.
374 Otherwise, EFI_SUCCESS is returned.
375 If Lock is NULL, then ASSERT().
376 If Lock is not initialized, then ASSERT().
378 @param Lock A pointer to the lock to acquire.
380 @retval EFI_SUCCESS The lock was acquired.
381 @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.
386 EfiAcquireLockOrFail (
391 Releases ownership of a lock.
393 This function transitions a mutual exclusion lock from the acquired state to
394 the released state, and restores the system's task priority level to its
396 If Lock is NULL, then ASSERT().
397 If Lock is not initialized, then ASSERT().
398 If Lock is already in the released state, then ASSERT().
400 @param Lock A pointer to the lock to release.
410 Tests whether a controller handle is being managed by a specific driver.
412 This function tests whether the driver specified by DriverBindingHandle is
413 currently managing the controller specified by ControllerHandle. This test
414 is performed by evaluating if the the protocol specified by ProtocolGuid is
415 present on ControllerHandle and is was opened by DriverBindingHandle with an
416 attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
417 If ProtocolGuid is NULL, then ASSERT().
419 @param ControllerHandle A handle for a controller to test.
420 @param DriverBindingHandle Specifies the driver binding handle for the
422 @param ProtocolGuid Specifies the protocol that the driver specified
423 by DriverBindingHandle opens in its Start()
426 @retval EFI_SUCCESS ControllerHandle is managed by the driver
427 specified by DriverBindingHandle.
428 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
429 specified by DriverBindingHandle.
434 EfiTestManagedDevice (
435 IN CONST EFI_HANDLE ControllerHandle
,
436 IN CONST EFI_HANDLE DriverBindingHandle
,
437 IN CONST EFI_GUID
*ProtocolGuid
441 Tests whether a child handle is a child device of the controller.
443 This function tests whether ChildHandle is one of the children of
444 ControllerHandle. This test is performed by checking to see if the protocol
445 specified by ProtocolGuid is present on ControllerHandle and opened by
446 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
447 If ProtocolGuid is NULL, then ASSERT().
449 @param ControllerHandle A handle for a (parent) controller to test.
450 @param ChildHandle A child handle to test.
451 @param ProtocolGuid Supplies the protocol that the child controller
452 opens on its parent controller.
454 @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle.
455 @retval EFI_UNSUPPORTED ChildHandle is not a child of the
462 IN CONST EFI_HANDLE ControllerHandle
,
463 IN CONST EFI_HANDLE ChildHandle
,
464 IN CONST EFI_GUID
*ProtocolGuid
468 This function looks up a Unicode string in UnicodeStringTable.
470 If Language is a member of SupportedLanguages and a Unicode string is found in
471 UnicodeStringTable that matches the language code specified by Language, then it
472 is returned in UnicodeString.
474 @param Language A pointer to the ISO 639-2 language code for the
475 Unicode string to look up and return.
476 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
477 that the Unicode string table supports. Language
478 must be a member of this set.
479 @param UnicodeStringTable A pointer to the table of Unicode strings.
480 @param UnicodeString A pointer to the Unicode string from UnicodeStringTable
481 that matches the language specified by Language.
483 @retval EFI_SUCCESS The Unicode string that matches the language
484 specified by Language was found
485 in the table of Unicode strings UnicodeStringTable,
486 and it was returned in UnicodeString.
487 @retval EFI_INVALID_PARAMETER Language is NULL.
488 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
489 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
490 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
491 @retval EFI_UNSUPPORTED The language specified by Language is not a
492 member of SupportedLanguages.
493 @retval EFI_UNSUPPORTED The language specified by Language is not
494 supported by UnicodeStringTable.
499 LookupUnicodeString (
500 IN CONST CHAR8
*Language
,
501 IN CONST CHAR8
*SupportedLanguages
,
502 IN CONST EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
,
503 OUT CHAR16
**UnicodeString
507 This function looks up a Unicode string in UnicodeStringTable.
509 If Language is a member of SupportedLanguages and a Unicode string is found in
510 UnicodeStringTable that matches the language code specified by Language, then
511 it is returned in UnicodeString.
513 @param Language A pointer to an ASCII string containing the ISO 639-2 or the
514 RFC 4646 language code for the Unicode string to look up and
515 return. If Iso639Language is TRUE, then this ASCII string is
516 not assumed to be Null-terminated, and only the first three
517 characters are used. If Iso639Language is FALSE, then this ASCII
518 string must be Null-terminated.
519 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains a
520 set of ISO 639-2 or RFC 4646 language codes that the Unicode
521 string table supports. Language must be a member of this set.
522 If Iso639Language is TRUE, then this string contains one or more
523 ISO 639-2 language codes with no separator characters. If Iso639Language
524 is FALSE, then is string contains one or more RFC 4646 language
525 codes separated by ';'.
526 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE
527 is defined in "Related Definitions".
528 @param UnicodeString A pointer to the Null-terminated Unicode string from UnicodeStringTable
529 that matches the language specified by Language.
530 @param Iso639Language Specifies the supported language code format. If it is TRUE, then
531 Language and SupportedLanguages follow ISO 639-2 language code format.
532 Otherwise, they follow the RFC 4646 language code format.
535 @retval EFI_SUCCESS The Unicode string that matches the language specified by Language
536 was found in the table of Unicode strings UnicodeStringTable, and
537 it was returned in UnicodeString.
538 @retval EFI_INVALID_PARAMETER Language is NULL.
539 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
540 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
541 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
542 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.
543 @retval EFI_UNSUPPORTED The language specified by Language is not supported by UnicodeStringTable.
548 LookupUnicodeString2 (
549 IN CONST CHAR8
*Language
,
550 IN CONST CHAR8
*SupportedLanguages
,
551 IN CONST EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
,
552 OUT CHAR16
**UnicodeString
,
553 IN BOOLEAN Iso639Language
557 This function adds a Unicode string to UnicodeStringTable.
559 If Language is a member of SupportedLanguages then UnicodeString is added to
560 UnicodeStringTable. New buffers are allocated for both Language and
561 UnicodeString. The contents of Language and UnicodeString are copied into
562 these new buffers. These buffers are automatically freed when
563 FreeUnicodeStringTable() is called.
565 @param Language A pointer to the ISO 639-2 language code for the Unicode
567 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
568 that the Unicode string table supports.
569 Language must be a member of this set.
570 @param UnicodeStringTable A pointer to the table of Unicode strings.
571 @param UnicodeString A pointer to the Unicode string to add.
573 @retval EFI_SUCCESS The Unicode string that matches the language
574 specified by Language was found in the table of
575 Unicode strings UnicodeStringTable, and it was
576 returned in UnicodeString.
577 @retval EFI_INVALID_PARAMETER Language is NULL.
578 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
579 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
580 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
581 @retval EFI_ALREADY_STARTED A Unicode string with language Language is
582 already present in UnicodeStringTable.
583 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another
584 Unicode string to UnicodeStringTable.
585 @retval EFI_UNSUPPORTED The language specified by Language is not a
586 member of SupportedLanguages.
592 IN CONST CHAR8
*Language
,
593 IN CONST CHAR8
*SupportedLanguages
,
594 IN OUT EFI_UNICODE_STRING_TABLE
**UnicodeStringTable
,
595 IN CONST CHAR16
*UnicodeString
599 This function adds the Null-terminated Unicode string specified by UnicodeString
600 to UnicodeStringTable.
602 If Language is a member of SupportedLanguages then UnicodeString is added to
603 UnicodeStringTable. New buffers are allocated for both Language and UnicodeString.
604 The contents of Language and UnicodeString are copied into these new buffers.
605 These buffers are automatically freed when EfiLibFreeUnicodeStringTable() is called.
607 @param Language A pointer to an ASCII string containing the ISO 639-2 or
608 the RFC 4646 language code for the Unicode string to add.
609 If Iso639Language is TRUE, then this ASCII string is not
610 assumed to be Null-terminated, and only the first three
611 chacters are used. If Iso639Language is FALSE, then this
612 ASCII string must be Null-terminated.
613 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains
614 a set of ISO 639-2 or RFC 4646 language codes that the Unicode
615 string table supports. Language must be a member of this set.
616 If Iso639Language is TRUE, then this string contains one or more
617 ISO 639-2 language codes with no separator characters.
618 If Iso639Language is FALSE, then is string contains one or more
619 RFC 4646 language codes separated by ';'.
620 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE
621 is defined in "Related Definitions".
622 @param UnicodeString A pointer to the Unicode string to add.
623 @param Iso639Language Specifies the supported language code format. If it is TRUE,
624 then Language and SupportedLanguages follow ISO 639-2 language code format.
625 Otherwise, they follow RFC 4646 language code format.
627 @retval EFI_SUCCESS The Unicode string that matches the language specified by
628 Language was found in the table of Unicode strings UnicodeStringTable,
629 and it was returned in UnicodeString.
630 @retval EFI_INVALID_PARAMETER Language is NULL.
631 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
632 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
633 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
634 @retval EFI_ALREADY_STARTED A Unicode string with language Language is already present in
636 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another Unicode string UnicodeStringTable.
637 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.
643 IN CONST CHAR8
*Language
,
644 IN CONST CHAR8
*SupportedLanguages
,
645 IN OUT EFI_UNICODE_STRING_TABLE
**UnicodeStringTable
,
646 IN CONST CHAR16
*UnicodeString
,
647 IN BOOLEAN Iso639Language
651 This function frees the table of Unicode strings in UnicodeStringTable.
653 If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.
654 Otherwise, each language code, and each Unicode string in the Unicode string
655 table are freed, and EFI_SUCCESS is returned.
657 @param UnicodeStringTable A pointer to the table of Unicode strings.
659 @retval EFI_SUCCESS The Unicode string table was freed.
664 FreeUnicodeStringTable (
665 IN EFI_UNICODE_STRING_TABLE
*UnicodeStringTable
668 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
671 [ATTENTION] This function will be deprecated for security reason.
673 Returns a pointer to an allocated buffer that contains the contents of a
674 variable retrieved through the UEFI Runtime Service GetVariable(). The
675 returned buffer is allocated using AllocatePool(). The caller is responsible
676 for freeing this buffer with FreePool().
678 If Name is NULL, then ASSERT().
679 If Guid is NULL, then ASSERT().
681 @param[in] Name The pointer to a Null-terminated Unicode string.
682 @param[in] Guid The pointer to an EFI_GUID structure.
684 @retval NULL The variable could not be retrieved.
685 @retval NULL There are not enough resources available for the variable contents.
686 @retval Other A pointer to allocated buffer containing the variable contents.
692 IN CONST CHAR16
*Name
,
693 IN CONST EFI_GUID
*Guid
697 [ATTENTION] This function will be deprecated for security reason.
699 Returns a pointer to an allocated buffer that contains the contents of a
700 variable retrieved through the UEFI Runtime Service GetVariable(). This
701 function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables.
702 The returned buffer is allocated using AllocatePool(). The caller is
703 responsible for freeing this buffer with FreePool().
705 If Name is NULL, then ASSERT().
707 @param[in] Name The pointer to a Null-terminated Unicode string.
709 @retval NULL The variable could not be retrieved.
710 @retval NULL There are not enough resources available for the variable contents.
711 @retval Other A pointer to allocated buffer containing the variable contents.
716 GetEfiGlobalVariable (
717 IN CONST CHAR16
*Name
723 Returns the status whether get the variable success. The function retrieves
724 variable through the UEFI Runtime Service GetVariable(). The
725 returned buffer is allocated using AllocatePool(). The caller is responsible
726 for freeing this buffer with FreePool().
728 If Name is NULL, then ASSERT().
729 If Guid is NULL, then ASSERT().
730 If Value is NULL, then ASSERT().
732 @param[in] Name The pointer to a Null-terminated Unicode string.
733 @param[in] Guid The pointer to an EFI_GUID structure
734 @param[out] Value The buffer point saved the variable info.
735 @param[out] Size The buffer size of the variable.
737 @return EFI_OUT_OF_RESOURCES Allocate buffer failed.
738 @return EFI_SUCCESS Find the specified variable.
739 @return Others Errors Return errors from call to gRT->GetVariable.
745 IN CONST CHAR16
*Name
,
746 IN CONST EFI_GUID
*Guid
,
748 OUT UINTN
*Size OPTIONAL
752 Returns a pointer to an allocated buffer that contains the contents of a
753 variable retrieved through the UEFI Runtime Service GetVariable(). This
754 function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables.
755 The returned buffer is allocated using AllocatePool(). The caller is
756 responsible for freeing this buffer with FreePool().
758 If Name is NULL, then ASSERT().
759 If Value is NULL, then ASSERT().
761 @param[in] Name The pointer to a Null-terminated Unicode string.
762 @param[out] Value The buffer point saved the variable info.
763 @param[out] Size The buffer size of the variable.
765 @return EFI_OUT_OF_RESOURCES Allocate buffer failed.
766 @return EFI_SUCCESS Find the specified variable.
767 @return Others Errors Return errors from call to gRT->GetVariable.
772 GetEfiGlobalVariable2 (
773 IN CONST CHAR16
*Name
,
775 OUT UINTN
*Size OPTIONAL
779 Returns a pointer to an allocated buffer that contains the best matching language
780 from a set of supported languages.
782 This function supports both ISO 639-2 and RFC 4646 language codes, but language
783 code types may not be mixed in a single call to this function. The language
784 code returned is allocated using AllocatePool(). The caller is responsible for
785 freeing the allocated buffer using FreePool(). This function supports a variable
786 argument list that allows the caller to pass in a prioritized list of language
787 codes to test against all the language codes in SupportedLanguages.
789 If SupportedLanguages is NULL, then ASSERT().
791 @param[in] SupportedLanguages A pointer to a Null-terminated ASCII string that
792 contains a set of language codes in the format
793 specified by Iso639Language.
794 @param[in] Iso639Language If not zero, then all language codes are assumed to be
795 in ISO 639-2 format. If zero, then all language
796 codes are assumed to be in RFC 4646 language format
797 @param[in] ... A variable argument list that contains pointers to
798 Null-terminated ASCII strings that contain one or more
799 language codes in the format specified by Iso639Language.
800 The first language code from each of these language
801 code lists is used to determine if it is an exact or
802 close match to any of the language codes in
803 SupportedLanguages. Close matches only apply to RFC 4646
804 language codes, and the matching algorithm from RFC 4647
805 is used to determine if a close match is present. If
806 an exact or close match is found, then the matching
807 language code from SupportedLanguages is returned. If
808 no matches are found, then the next variable argument
809 parameter is evaluated. The variable argument list
810 is terminated by a NULL.
812 @retval NULL The best matching language could not be found in SupportedLanguages.
813 @retval NULL There are not enough resources available to return the best matching
815 @retval Other A pointer to a Null-terminated ASCII string that is the best matching
816 language in SupportedLanguages.
822 IN CONST CHAR8
*SupportedLanguages
,
823 IN UINTN Iso639Language
,
828 Draws a dialog box to the console output device specified by
829 ConOut defined in the EFI_SYSTEM_TABLE and waits for a keystroke
830 from the console input device specified by ConIn defined in the
833 If there are no strings in the variable argument list, then ASSERT().
834 If all the strings in the variable argument list are empty, then ASSERT().
836 @param[in] Attribute Specifies the foreground and background color of the popup.
837 @param[out] Key A pointer to the EFI_KEY value of the key that was
838 pressed. This is an optional parameter that may be NULL.
839 If it is NULL then no wait for a keypress will be performed.
840 @param[in] ... The variable argument list that contains pointers to Null-
841 terminated Unicode strings to display in the dialog box.
842 The variable argument list is terminated by a NULL.
849 OUT EFI_INPUT_KEY
*Key
, OPTIONAL
854 Retrieves the width of a Unicode character.
856 This function computes and returns the width of the Unicode character specified
859 @param UnicodeChar A Unicode character.
861 @retval 0 The width if UnicodeChar could not be determined.
862 @retval 1 UnicodeChar is a narrow glyph.
863 @retval 2 UnicodeChar is a wide glyph.
869 IN CHAR16 UnicodeChar
873 Computes the display length of a Null-terminated Unicode String.
875 This function computes and returns the display length of the Null-terminated Unicode
876 string specified by String. If String is NULL then 0 is returned. If any of the widths
877 of the Unicode characters in String can not be determined, then 0 is returned. The display
878 width of String can be computed by summing the display widths of each Unicode character
879 in String. Unicode characters that are narrow glyphs have a width of 1, and Unicode
880 characters that are width glyphs have a width of 2.
881 If String is not aligned on a 16-bit boundary, then ASSERT().
883 @param String A pointer to a Null-terminated Unicode string.
885 @return The display length of the Null-terminated Unicode string specified by String.
890 UnicodeStringDisplayLength (
891 IN CONST CHAR16
*String
895 // Functions that abstract early Framework contamination of UEFI.
898 Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().
900 This function abstracts the signaling of the Ready to Boot Event. The Framework moved
901 from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller
902 from how this event is created to prevent to code form having to change with the
903 version of the specification supported.
908 EfiSignalEventReadyToBoot (
913 Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().
915 This function abstracts the signaling of the Legacy Boot Event. The Framework moved from
916 a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how
917 this event is created to prevent to code form having to change with the version of the
918 specification supported.
923 EfiSignalEventLegacyBoot (
928 Creates an EFI event in the Legacy Boot Event Group.
930 Prior to UEFI 2.0 this was done via a non blessed UEFI extensions and this library
931 abstracts the implementation mechanism of this event from the caller. This function
932 abstracts the creation of the Legacy Boot Event. The Framework moved from a proprietary
933 to UEFI 2.0 based mechanism. This library abstracts the caller from how this event
934 is created to prevent to code form having to change with the version of the
935 specification supported.
936 If LegacyBootEvent is NULL, then ASSERT().
938 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
940 @retval EFI_SUCCESS The event was created.
941 @retval Other The event was not created.
946 EfiCreateEventLegacyBoot (
947 OUT EFI_EVENT
*LegacyBootEvent
951 Create an EFI event in the Legacy Boot Event Group and allows
952 the caller to specify a notification function.
954 This function abstracts the creation of the Legacy Boot Event.
955 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
956 This library abstracts the caller from how this event is created to prevent
957 to code form having to change with the version of the specification supported.
958 If LegacyBootEvent is NULL, then ASSERT().
960 @param NotifyTpl The task priority level of the event.
961 @param NotifyFunction The notification function to call when the event is signaled.
962 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
963 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
965 @retval EFI_SUCCESS The event was created.
966 @retval Other The event was not created.
971 EfiCreateEventLegacyBootEx (
972 IN EFI_TPL NotifyTpl
,
973 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
974 IN VOID
*NotifyContext
, OPTIONAL
975 OUT EFI_EVENT
*LegacyBootEvent
979 Create an EFI event in the Ready To Boot Event Group.
981 Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library
982 abstracts the implementation mechanism of this event from the caller.
983 This function abstracts the creation of the Ready to Boot Event. The Framework
984 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts
985 the caller from how this event is created to prevent the code form having to
986 change with the version of the specification supported.
987 If ReadyToBootEvent is NULL, then ASSERT().
989 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
991 @retval EFI_SUCCESS The event was created.
992 @retval Other The event was not created.
997 EfiCreateEventReadyToBoot (
998 OUT EFI_EVENT
*ReadyToBootEvent
1002 Create an EFI event in the Ready To Boot Event Group and allows
1003 the caller to specify a notification function.
1005 This function abstracts the creation of the Ready to Boot Event.
1006 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
1007 This library abstracts the caller from how this event is created to prevent
1008 to code form having to change with the version of the specification supported.
1009 If ReadyToBootEvent is NULL, then ASSERT().
1011 @param NotifyTpl The task priority level of the event.
1012 @param NotifyFunction The notification function to call when the event is signaled.
1013 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
1014 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
1016 @retval EFI_SUCCESS The event was created.
1017 @retval Other The event was not created.
1022 EfiCreateEventReadyToBootEx (
1023 IN EFI_TPL NotifyTpl
,
1024 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
1025 IN VOID
*NotifyContext
, OPTIONAL
1026 OUT EFI_EVENT
*ReadyToBootEvent
1030 Initialize a Firmware Volume (FV) Media Device Path node.
1032 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
1033 This library function abstracts initializing a device path node.
1034 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device
1035 path changed in the DXE CIS version 0.92 in a non back ward compatible way to
1036 not conflict with the UEFI 2.0 specification. This function abstracts the
1037 differences from the caller.
1038 If FvDevicePathNode is NULL, then ASSERT().
1039 If NameGuid is NULL, then ASSERT().
1041 @param FvDevicePathNode The pointer to a FV device path node to initialize
1042 @param NameGuid FV file name to use in FvDevicePathNode
1047 EfiInitializeFwVolDevicepathNode (
1048 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
1049 IN CONST EFI_GUID
*NameGuid
1053 Check to see if the Firmware Volume (FV) Media Device Path is valid
1055 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
1056 This library function abstracts validating a device path node.
1057 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.
1058 If it is valid, then return the GUID file name from the device path node. Otherwise,
1059 return NULL. This device path changed in the DXE CIS version 0.92 in a non backward
1060 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts
1061 the differences from the caller.
1062 If FvDevicePathNode is NULL, then ASSERT().
1064 @param FvDevicePathNode The pointer to FV device path to check.
1066 @retval NULL FvDevicePathNode is not valid.
1067 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
1072 EfiGetNameGuidFromFwVolDevicePathNode (
1073 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
1077 Prints a formatted Unicode string to the console output device specified by
1078 ConOut defined in the EFI_SYSTEM_TABLE.
1080 This function prints a formatted Unicode string to the console output device
1081 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
1082 characters that printed to ConOut. If the length of the formatted Unicode
1083 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1084 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
1085 If Format is NULL, then ASSERT().
1086 If Format is not aligned on a 16-bit boundary, then ASSERT().
1087 If gST->ConOut is NULL, then ASSERT().
1089 @param Format A null-terminated Unicode format string.
1090 @param ... The variable argument list whose contents are accessed based
1091 on the format string specified by Format.
1093 @return Number of Unicode characters printed to ConOut.
1099 IN CONST CHAR16
*Format
,
1104 Prints a formatted Unicode string to the console output device specified by
1105 StdErr defined in the EFI_SYSTEM_TABLE.
1107 This function prints a formatted Unicode string to the console output device
1108 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
1109 characters that printed to StdErr. If the length of the formatted Unicode
1110 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1111 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
1112 If Format is NULL, then ASSERT().
1113 If Format is not aligned on a 16-bit boundary, then ASSERT().
1114 If gST->StdErr is NULL, then ASSERT().
1116 @param Format A null-terminated Unicode format string.
1117 @param ... The variable argument list whose contents are accessed based
1118 on the format string specified by Format.
1120 @return Number of Unicode characters printed to StdErr.
1126 IN CONST CHAR16
*Format
,
1131 Prints a formatted ASCII string to the console output device specified by
1132 ConOut defined in the EFI_SYSTEM_TABLE.
1134 This function prints a formatted ASCII string to the console output device
1135 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
1136 characters that printed to ConOut. If the length of the formatted ASCII
1137 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1138 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
1139 If Format is NULL, then ASSERT().
1140 If gST->ConOut is NULL, then ASSERT().
1142 @param Format A null-terminated ASCII format string.
1143 @param ... The variable argument list whose contents are accessed based
1144 on the format string specified by Format.
1146 @return Number of ASCII characters printed to ConOut.
1152 IN CONST CHAR8
*Format
,
1157 Prints a formatted ASCII string to the console output device specified by
1158 StdErr defined in the EFI_SYSTEM_TABLE.
1160 This function prints a formatted ASCII string to the console output device
1161 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
1162 characters that printed to StdErr. If the length of the formatted ASCII
1163 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
1164 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
1165 If Format is NULL, then ASSERT().
1166 If gST->StdErr is NULL, then ASSERT().
1168 @param Format A null-terminated ASCII format string.
1169 @param ... The variable argument list whose contents are accessed based
1170 on the format string specified by Format.
1172 @return Number of ASCII characters printed to ConErr.
1178 IN CONST CHAR8
*Format
,
1184 Prints a formatted Unicode string to a graphics console device specified by
1185 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
1187 This function prints a formatted Unicode string to the graphics console device
1188 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
1189 Unicode characters displayed, not including partial characters that may be clipped
1190 by the right edge of the display. If the length of the formatted Unicode string is
1191 greater than PcdUefiLibMaxPrintBufferSize, then at most the first
1192 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
1193 is used to convert the string to a bitmap using the glyphs registered with the
1194 HII database. No wrapping is performed, so any portions of the string the fall
1195 outside the active display region will not be displayed.
1197 If a graphics console device is not associated with the ConsoleOutputHandle
1198 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
1199 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
1200 string is printed, and 0 is returned.
1201 If Format is NULL, then ASSERT().
1202 If Format is not aligned on a 16-bit boundary, then ASSERT().
1203 If gST->ConsoleOutputHandle is NULL, then ASSERT().
1205 @param PointX X coordinate to print the string.
1206 @param PointY Y coordinate to print the string.
1207 @param ForeGround The foreground color of the string being printed. This is
1208 an optional parameter that may be NULL. If it is NULL,
1209 then the foreground color of the current ConOut device
1210 in the EFI_SYSTEM_TABLE is used.
1211 @param BackGround The background color of the string being printed. This is
1212 an optional parameter that may be NULL. If it is NULL,
1213 then the background color of the current ConOut device
1214 in the EFI_SYSTEM_TABLE is used.
1215 @param Format A null-terminated Unicode format string. See Print Library
1216 for the supported format string syntax.
1217 @param ... Variable argument list whose contents are accessed based on
1218 the format string specified by Format.
1220 @return The number of Unicode characters printed.
1228 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
1229 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
1230 IN CONST CHAR16
*Format
,
1235 Prints a formatted ASCII string to a graphics console device specified by
1236 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
1238 This function prints a formatted ASCII string to the graphics console device
1239 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
1240 ASCII characters displayed, not including partial characters that may be clipped
1241 by the right edge of the display. If the length of the formatted ASCII string is
1242 greater than PcdUefiLibMaxPrintBufferSize, then at most the first
1243 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
1244 is used to convert the string to a bitmap using the glyphs registered with the
1245 HII database. No wrapping is performed, so any portions of the string the fall
1246 outside the active display region will not be displayed.
1248 If a graphics console device is not associated with the ConsoleOutputHandle
1249 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
1250 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
1251 string is printed, and 0 is returned.
1252 If Format is NULL, then ASSERT().
1253 If gST->ConsoleOutputHandle is NULL, then ASSERT().
1255 @param PointX X coordinate to print the string.
1256 @param PointY Y coordinate to print the string.
1257 @param ForeGround The foreground color of the string being printed. This is
1258 an optional parameter that may be NULL. If it is NULL,
1259 then the foreground color of the current ConOut device
1260 in the EFI_SYSTEM_TABLE is used.
1261 @param BackGround The background color of the string being printed. This is
1262 an optional parameter that may be NULL. If it is NULL,
1263 then the background color of the current ConOut device
1264 in the EFI_SYSTEM_TABLE is used.
1265 @param Format A null-terminated ASCII format string. See Print Library
1266 for the supported format string syntax.
1267 @param ... The variable argument list whose contents are accessed based on
1268 the format string specified by Format.
1270 @return The number of ASCII characters printed.
1278 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
1279 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
1280 IN CONST CHAR8
*Format
,
1285 Installs and completes the initialization of a Driver Binding Protocol instance.
1287 Installs the Driver Binding Protocol specified by DriverBinding onto the handle
1288 specified by DriverBindingHandle. If DriverBindingHandle is NULL, then DriverBinding
1289 is installed onto a newly created handle. DriverBindingHandle is typically the same
1290 as the driver's ImageHandle, but it can be different if the driver produces multiple
1291 Driver Binding Protocols.
1292 If DriverBinding is NULL, then ASSERT().
1293 If DriverBinding can not be installed onto a handle, then ASSERT().
1295 @param ImageHandle The image handle of the driver.
1296 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1297 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1298 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1299 parameter is NULL, then a new handle is created.
1301 @retval EFI_SUCCESS The protocol installation completed successfully.
1302 @retval EFI_OUT_OF_RESOURCES There was not enough system resources to install the protocol.
1303 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
1308 EfiLibInstallDriverBinding (
1309 IN CONST EFI_HANDLE ImageHandle
,
1310 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1311 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1312 IN EFI_HANDLE DriverBindingHandle
1317 Installs and completes the initialization of a Driver Binding Protocol instance and
1318 optionally installs the Component Name, Driver Configuration and Driver Diagnostics Protocols.
1320 Initializes a driver by installing the Driver Binding Protocol together with the
1321 optional Component Name, optional Driver Configure and optional Driver Diagnostic
1322 Protocols onto the driver's DriverBindingHandle. If DriverBindingHandle is NULL,
1323 then the protocols are installed onto a newly created handle. DriverBindingHandle
1324 is typically the same as the driver's ImageHandle, but it can be different if the
1325 driver produces multiple Driver Binding Protocols.
1326 If DriverBinding is NULL, then ASSERT().
1327 If the installation fails, then ASSERT().
1329 @param ImageHandle The image handle of the driver.
1330 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1331 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1332 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1333 parameter is NULL, then a new handle is created.
1334 @param ComponentName A Component Name Protocol instance that this driver is producing.
1335 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1336 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1338 @retval EFI_SUCCESS The protocol installation completed successfully.
1339 @retval EFI_OUT_OF_RESOURCES There was not enough memory in the pool to install all the protocols.
1344 EfiLibInstallAllDriverProtocols (
1345 IN CONST EFI_HANDLE ImageHandle
,
1346 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1347 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1348 IN EFI_HANDLE DriverBindingHandle
,
1349 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1350 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1351 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics OPTIONAL
1357 Installs Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.
1359 Initializes a driver by installing the Driver Binding Protocol together with the
1360 optional Component Name and optional Component Name 2 protocols onto the driver's
1361 DriverBindingHandle. If DriverBindingHandle is NULL, then the protocols are installed
1362 onto a newly created handle. DriverBindingHandle is typically the same as the driver's
1363 ImageHandle, but it can be different if the driver produces multiple Driver Binding Protocols.
1364 If DriverBinding is NULL, then ASSERT().
1365 If the installation fails, then ASSERT().
1367 @param ImageHandle The image handle of the driver.
1368 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1369 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1370 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1371 parameter is NULL, then a new handle is created.
1372 @param ComponentName A Component Name Protocol instance that this driver is producing.
1373 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1375 @retval EFI_SUCCESS The protocol installation completed successfully.
1376 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1381 EfiLibInstallDriverBindingComponentName2 (
1382 IN CONST EFI_HANDLE ImageHandle
,
1383 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1384 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1385 IN EFI_HANDLE DriverBindingHandle
,
1386 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1387 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2 OPTIONAL
1392 Installs Driver Binding Protocol with optional Component Name, Component Name 2, Driver
1393 Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.
1395 Initializes a driver by installing the Driver Binding Protocol together with the optional
1396 Component Name, optional Component Name 2, optional Driver Configuration, optional Driver Configuration 2,
1397 optional Driver Diagnostic, and optional Driver Diagnostic 2 Protocols onto the driver's DriverBindingHandle.
1398 DriverBindingHandle is typically the same as the driver's ImageHandle, but it can be different if the driver
1399 produces multiple Driver Binding Protocols.
1400 If DriverBinding is NULL, then ASSERT().
1401 If the installation fails, then ASSERT().
1404 @param ImageHandle The image handle of the driver.
1405 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1406 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1407 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1408 parameter is NULL, then a new handle is created.
1409 @param ComponentName A Component Name Protocol instance that this driver is producing.
1410 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1411 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1412 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver is producing.
1413 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1414 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing.
1416 @retval EFI_SUCCESS The protocol installation completed successfully.
1417 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
1422 EfiLibInstallAllDriverProtocols2 (
1423 IN CONST EFI_HANDLE ImageHandle
,
1424 IN CONST EFI_SYSTEM_TABLE
*SystemTable
,
1425 IN EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
,
1426 IN EFI_HANDLE DriverBindingHandle
,
1427 IN CONST EFI_COMPONENT_NAME_PROTOCOL
*ComponentName
, OPTIONAL
1428 IN CONST EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
, OPTIONAL
1429 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
*DriverConfiguration
, OPTIONAL
1430 IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL
*DriverConfiguration2
, OPTIONAL
1431 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*DriverDiagnostics
, OPTIONAL
1432 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL
*DriverDiagnostics2 OPTIONAL
1436 Appends a formatted Unicode string to a Null-terminated Unicode string
1438 This function appends a formatted Unicode string to the Null-terminated
1439 Unicode string specified by String. String is optional and may be NULL.
1440 Storage for the formatted Unicode string returned is allocated using
1441 AllocatePool(). The pointer to the appended string is returned. The caller
1442 is responsible for freeing the returned string.
1444 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().
1445 If FormatString is NULL, then ASSERT().
1446 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
1448 @param[in] String A Null-terminated Unicode string.
1449 @param[in] FormatString A Null-terminated Unicode format string.
1450 @param[in] Marker VA_LIST marker for the variable argument list.
1452 @retval NULL There was not enough available memory.
1453 @return Null-terminated Unicode string is that is the formatted
1454 string appended to String.
1459 IN CHAR16
*String
, OPTIONAL
1460 IN CONST CHAR16
*FormatString
,
1465 Appends a formatted Unicode string to a Null-terminated Unicode string
1467 This function appends a formatted Unicode string to the Null-terminated
1468 Unicode string specified by String. String is optional and may be NULL.
1469 Storage for the formatted Unicode string returned is allocated using
1470 AllocatePool(). The pointer to the appended string is returned. The caller
1471 is responsible for freeing the returned string.
1473 If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().
1474 If FormatString is NULL, then ASSERT().
1475 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
1477 @param[in] String A Null-terminated Unicode string.
1478 @param[in] FormatString A Null-terminated Unicode format string.
1479 @param[in] ... The variable argument list whose contents are
1480 accessed based on the format string specified by
1483 @retval NULL There was not enough available memory.
1484 @return Null-terminated Unicode string is that is the formatted
1485 string appended to String.
1490 IN CHAR16
*String
, OPTIONAL
1491 IN CONST CHAR16
*FormatString
,
1496 Returns an array of protocol instance that matches the given protocol.
1498 @param[in] Protocol Provides the protocol to search for.
1499 @param[out] NoProtocols The number of protocols returned in Buffer.
1500 @param[out] Buffer A pointer to the buffer to return the requested
1501 array of protocol instances that match Protocol.
1502 The returned buffer is allocated using
1503 EFI_BOOT_SERVICES.AllocatePool(). The caller is
1504 responsible for freeing this buffer with
1505 EFI_BOOT_SERVICES.FreePool().
1507 @retval EFI_SUCCESS The array of protocols was returned in Buffer,
1508 and the number of protocols in Buffer was
1509 returned in NoProtocols.
1510 @retval EFI_NOT_FOUND No protocols found.
1511 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the
1513 @retval EFI_INVALID_PARAMETER Protocol is NULL.
1514 @retval EFI_INVALID_PARAMETER NoProtocols is NULL.
1515 @retval EFI_INVALID_PARAMETER Buffer is NULL.
1520 EfiLocateProtocolBuffer (
1521 IN EFI_GUID
*Protocol
,
1522 OUT UINTN
*NoProtocols
,
1527 Open or create a file or directory, possibly creating the chain of
1528 directories leading up to the directory.
1530 EfiOpenFileByDevicePath() first locates EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on
1531 FilePath, and opens the root directory of that filesystem with
1532 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume().
1534 On the remaining device path, the longest initial sequence of
1535 FILEPATH_DEVICE_PATH nodes is node-wise traversed with
1536 EFI_FILE_PROTOCOL.Open(). For the pathname fragment specified by each
1537 traversed FILEPATH_DEVICE_PATH node, EfiOpenFileByDevicePath() first masks
1538 EFI_FILE_MODE_CREATE out of OpenMode, and passes 0 for Attributes. If
1539 EFI_FILE_PROTOCOL.Open() fails, and OpenMode includes EFI_FILE_MODE_CREATE,
1540 then the operation is retried with the caller's OpenMode and Attributes
1543 (As a consequence, if OpenMode includes EFI_FILE_MODE_CREATE, and Attributes
1544 includes EFI_FILE_DIRECTORY, and each FILEPATH_DEVICE_PATH specifies a single
1545 pathname component, then EfiOpenFileByDevicePath() ensures that the specified
1546 series of subdirectories exist on return.)
1548 The EFI_FILE_PROTOCOL identified by the last FILEPATH_DEVICE_PATH node is
1549 output to the caller; intermediate EFI_FILE_PROTOCOL instances are closed. If
1550 there are no FILEPATH_DEVICE_PATH nodes past the node that identifies the
1551 filesystem, then the EFI_FILE_PROTOCOL of the root directory of the
1552 filesystem is output to the caller. If a device path node that is different
1553 from FILEPATH_DEVICE_PATH is encountered relative to the filesystem, the
1554 traversal is stopped with an error, and a NULL EFI_FILE_PROTOCOL is output.
1556 @param[in,out] FilePath On input, the device path to the file or directory
1557 to open or create. The caller is responsible for
1558 ensuring that the device path pointed-to by FilePath
1559 is well-formed. On output, FilePath points one past
1560 the last node in the original device path that has
1561 been successfully processed. FilePath is set on
1562 output even if EfiOpenFileByDevicePath() returns an
1565 @param[out] File On error, File is set to NULL. On success, File is
1566 set to the EFI_FILE_PROTOCOL of the root directory
1567 of the filesystem, if there are no
1568 FILEPATH_DEVICE_PATH nodes in FilePath; otherwise,
1569 File is set to the EFI_FILE_PROTOCOL identified by
1570 the last node in FilePath.
1572 @param[in] OpenMode The OpenMode parameter to pass to
1573 EFI_FILE_PROTOCOL.Open(). For each
1574 FILEPATH_DEVICE_PATH node in FilePath,
1575 EfiOpenFileByDevicePath() first opens the specified
1576 pathname fragment with EFI_FILE_MODE_CREATE masked
1577 out of OpenMode and with Attributes set to 0, and
1578 only retries the operation with EFI_FILE_MODE_CREATE
1579 unmasked and Attributes propagated if the first open
1582 @param[in] Attributes The Attributes parameter to pass to
1583 EFI_FILE_PROTOCOL.Open(), when EFI_FILE_MODE_CREATE
1584 is propagated unmasked in OpenMode.
1586 @retval EFI_SUCCESS The file or directory has been opened or
1589 @retval EFI_INVALID_PARAMETER FilePath is NULL; or File is NULL; or FilePath
1590 contains a device path node, past the node
1592 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, that is not a
1593 FILEPATH_DEVICE_PATH node.
1595 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
1597 @return Error codes propagated from the
1598 LocateDevicePath() and OpenProtocol() boot
1599 services, and from the
1600 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume()
1601 and EFI_FILE_PROTOCOL.Open() member functions.
1605 EfiOpenFileByDevicePath (
1606 IN OUT EFI_DEVICE_PATH_PROTOCOL
**FilePath
,
1607 OUT EFI_FILE_PROTOCOL
**File
,
1609 IN UINT64 Attributes