]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/UefiLib.h
synchronize the files with the MDE_Library_Spec
[mirror_edk2.git] / MdePkg / Include / Library / UefiLib.h
1 /** @file
2 Provides library functions for common UEFI operations. Only available to DXE
3 and UEFI module types.
4
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.
10
11 Copyright (c) 2006 - 2008, Intel Corporation
12 All rights reserved. This program and the accompanying materials
13 are licensed and made available under the terms and conditions of the BSD License
14 which accompanies this distribution. The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php
16
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19
20 **/
21
22 #ifndef __UEFI_LIB_H__
23 #define __UEFI_LIB_H__
24
25 #include <Protocol/DriverBinding.h>
26 #include <Protocol/DriverConfiguration.h>
27 #include <Protocol/ComponentName.h>
28 #include <Protocol/ComponentName2.h>
29 #include <Protocol/DriverDiagnostics.h>
30 #include <Protocol/DriverDiagnostics2.h>
31 #include <Protocol/GraphicsOutput.h>
32
33 #include <Library/BaseLib.h>
34
35 ///
36 /// Unicode String Table
37 ///
38 typedef struct {
39 CHAR8 *Language;
40 CHAR16 *UnicodeString;
41 } EFI_UNICODE_STRING_TABLE;
42
43 ///
44 /// EFI Lock Status
45 ///
46 typedef enum {
47 EfiLockUninitialized = 0,
48 EfiLockReleased = 1,
49 EfiLockAcquired = 2
50 } EFI_LOCK_STATE;
51
52 ///
53 /// EFI Lock
54 ///
55 typedef struct {
56 EFI_TPL Tpl;
57 EFI_TPL OwnerTpl;
58 EFI_LOCK_STATE Lock;
59 } EFI_LOCK;
60
61
62 /**
63 Macro that returns the number of 100 ns units for a specified number of microseconds.
64 Useful for managing EFI timer events.
65
66 @param Microseconds Number of microseonds.
67
68 @return The number of 100 ns units equivalent to the number of microseconds specified
69 by Microseconds.
70
71 **/
72 #define EFI_TIMER_PERIOD_MICROSECONDS(Microseconds) MultU64x32((UINT64)(Microseconds), 10)
73
74
75 /**
76 Macro that returns the number of 100 ns units for a specified number of milliseoconds.
77 Useful for managing EFI timer events.
78
79 @param Milliseconds Number of milliseconds.
80
81 @return The number of 100 ns units equivalent to the number of milliseconds specified
82 by Milliseconds.
83
84 **/
85 #define EFI_TIMER_PERIOD_MILLISECONDS(Milliseconds) MultU64x32((UINT64)(Milliseconds), 10000)
86
87
88 /**
89 Macro that returns the number of 100 ns units for a specified number of seoconds.
90 Useful for managing EFI timer events.
91
92 @param Seconds Number of seconds.
93
94 @return The number of 100 ns units equivalent to the number of seconds specified
95 by Seconds.
96
97 **/
98 #define EFI_TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)
99
100
101 /**
102 Retrieves a pointer to the system configuration table from the EFI System Table
103 based on a specified GUID.
104
105 This function searches the list of configuration tables stored in the EFI System Table
106 for a table with a GUID that matches TableGuid. If a match is found, then a pointer to
107 the configuration table is returned in Table., and EFI_SUCCESS is returned. If a matching GUID
108 is not found, then EFI_NOT_FOUND is returned.
109 If TableGuid is NULL, then ASSERT().
110 If Table is NULL, then ASSERT().
111
112 @param TableGuid Pointer to table's GUID type..
113 @param Table Pointer to the table associated with TableGuid in the EFI System Table.
114
115 @retval EFI_SUCCESS A configuration table matching TableGuid was found.
116 @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.
117
118 **/
119 EFI_STATUS
120 EFIAPI
121 EfiGetSystemConfigurationTable (
122 IN EFI_GUID *TableGuid,
123 OUT VOID **Table
124 );
125
126 /**
127 Creates and returns a notification event and registers that event with all the protocol
128 instances specified by ProtocolGuid.
129
130 This function causes the notification function to be executed for every protocol of type
131 ProtocolGuid instance that exists in the system when this function is invoked.
132 In addition, every time a protocol of type ProtocolGuid instance is installed or reinstalled,
133 the notification function is also executed. This function returns the notification event
134 that was created.
135 If ProtocolGuid is NULL, then ASSERT().
136 If NotifyTpl is not a legal TPL value, then ASSERT().
137 If NotifyFunction is NULL, then ASSERT().
138 If Registration is NULL, then ASSERT().
139
140 @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.
141 @param NotifyTpl Supplies the task priority level of the event notifications.
142 @param NotifyFunction Supplies the function to notify when the event is signaled.
143 @param NotifyContext The context parameter to pass to NotifyFunction.
144 @param Registration A pointer to a memory location to receive the registration value.
145 This value is passed to LocateHandle() to obtain new handles that
146 have been added that support the ProtocolGuid-specified protocol.
147
148 @return The notification event that was created.
149
150 **/
151 EFI_EVENT
152 EFIAPI
153 EfiCreateProtocolNotifyEvent(
154 IN EFI_GUID *ProtocolGuid,
155 IN EFI_TPL NotifyTpl,
156 IN EFI_EVENT_NOTIFY NotifyFunction,
157 IN VOID *NotifyContext, OPTIONAL
158 OUT VOID **Registration
159 );
160
161 /**
162 Creates a named event that can be signaled with EfiNamedEventSignal().
163
164 This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.
165 This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more
166 listeners on the same event named by the GUID specified by Name.
167 If Name is NULL, then ASSERT().
168 If NotifyTpl is not a legal TPL value, then ASSERT().
169 If NotifyFunction is NULL, then ASSERT().
170
171 @param Name Supplies GUID name of the event.
172 @param NotifyTpl Supplies the task priority level of the event notifications.
173 @param NotifyFunction Supplies the function to notify when the event is signaled.
174 @param NotifyContext The context parameter to pass to NotifyFunction.
175 @param Registration A pointer to a memory location to receive the registration value.
176
177 @retval EFI_SUCCESS A named event was created.
178 @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event.
179
180 **/
181 EFI_STATUS
182 EFIAPI
183 EfiNamedEventListen (
184 IN CONST EFI_GUID *Name,
185 IN EFI_TPL NotifyTpl,
186 IN EFI_EVENT_NOTIFY NotifyFunction,
187 IN CONST VOID *NotifyContext, OPTIONAL
188 OUT VOID *Registration OPTIONAL
189 );
190
191 /**
192 Signals a named event created with EfiNamedEventListen().
193
194 This function signals the named event specified by Name. The named event must have been
195 created with EfiNamedEventListen().
196 If Name is NULL, then ASSERT().
197
198 @param Name Supplies GUID name of the event.
199
200 @retval EFI_SUCCESS A named event was signaled.
201 @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event.
202
203 **/
204 EFI_STATUS
205 EFIAPI
206 EfiNamedEventSignal (
207 IN CONST EFI_GUID *Name
208 );
209
210 /**
211 Returns the current TPL.
212
213 This function returns the current TPL. There is no EFI service to directly
214 retrieve the current TPL. Instead, the RaiseTPL() function is used to raise
215 the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level
216 can then immediately be restored back to the current TPL level with a call
217 to RestoreTPL().
218
219 @return The current TPL.
220
221 **/
222 EFI_TPL
223 EFIAPI
224 EfiGetCurrentTpl (
225 VOID
226 );
227
228 /**
229 Initializes a basic mutual exclusion lock.
230
231 This function initializes a basic mutual exclusion lock to the released state
232 and returns the lock. Each lock provides mutual exclusion access at its task
233 priority level. Since there is no preemption or multiprocessor support in EFI,
234 acquiring the lock only consists of raising to the locks TPL.
235 If Lock is NULL, then ASSERT().
236 If Priority is not a valid TPL value, then ASSERT().
237
238 @param Lock A pointer to the lock data structure to initialize.
239 @param Priority EFI TPL associated with the lock.
240
241 @return The lock.
242
243 **/
244 EFI_LOCK *
245 EFIAPI
246 EfiInitializeLock (
247 IN OUT EFI_LOCK *Lock,
248 IN EFI_TPL Priority
249 );
250
251 /**
252 This macro initializes the contents of a basic mutual exclusion lock to the
253 released state. Each lock provides mutual exclusion access at its task
254 priority level. Since there is no preemption or multiprocessor support in EFI,
255 acquiring the lock only consists of raising to the locks TPL.
256
257 @param Priority The task priority level of the lock.
258
259 @return The lock.
260
261 **/
262 #define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \
263 {Priority, TPL_APPLICATION, EfiLockReleased }
264
265
266 /**
267
268 Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state.
269
270 If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set,
271 then this macro evaluates the EFI_LOCK structure specified by Lock. If Lock
272 is not in the locked state, then DebugAssert() is called passing in the source
273 filename, source line number, and Lock.
274 If Lock is NULL, then ASSERT().
275
276 @param LockParameter A pointer to the lock to acquire.
277
278 **/
279 #define ASSERT_LOCKED(LockParameter) \
280 do { \
281 if (DebugAssertEnabled ()) { \
282 ASSERT (LockParameter != NULL); \
283 if ((LockParameter)->Lock != EfiLockAcquired) { \
284 _ASSERT (LockParameter not locked); \
285 } \
286 } \
287 } while (FALSE)
288
289
290 /**
291 Acquires ownership of a lock.
292
293 This function raises the system's current task priority level to the task
294 priority level of the mutual exclusion lock. Then, it places the lock in the
295 acquired state.
296 If Lock is NULL, then ASSERT().
297 If Lock is not initialized, then ASSERT().
298 If Lock is already in the acquired state, then ASSERT().
299
300 @param Lock A pointer to the lock to acquire.
301
302 **/
303 VOID
304 EFIAPI
305 EfiAcquireLock (
306 IN EFI_LOCK *Lock
307 );
308
309 /**
310 Acquires ownership of a lock. If the lock is already owned , then an error is returned.
311
312 This function raises the system's current task priority level to the task
313 priority level of the mutual exclusion lock. Then, it attempts to place the
314 lock in the acquired state.
315 If Lock is NULL, then ASSERT().
316 If Lock is not initialized, then ASSERT().
317
318 @param Lock A pointer to the lock to acquire.
319
320 @retval EFI_SUCCESS The lock was acquired.
321 @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.
322
323 **/
324 EFI_STATUS
325 EFIAPI
326 EfiAcquireLockOrFail (
327 IN EFI_LOCK *Lock
328 );
329
330 /**
331 Releases ownership of a lock.
332
333 This function transitions a mutual exclusion lock from the acquired state to
334 the released state, and restores the system's task priority level to its
335 previous level.
336 If Lock is NULL, then ASSERT().
337 If Lock is not initialized, then ASSERT().
338 If Lock is already in the released state, then ASSERT().
339
340 @param Lock A pointer to the lock to release.
341
342 **/
343 VOID
344 EFIAPI
345 EfiReleaseLock (
346 IN EFI_LOCK *Lock
347 );
348
349 /**
350 Tests whether a controller handle is being managed by a specific driver.
351
352 This function tests whether the driver specified by DriverBindingHandle is
353 currently managing the controller specified by ControllerHandle. This test
354 is performed by evaluating if the the protocol specified by ProtocolGuid is
355 present on ControllerHandle and is was opened by DriverBindingHandle with an
356 attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
357 If ProtocolGuid is NULL, then ASSERT().
358
359 @param ControllerHandle A handle for a controller to test.
360 @param DriverBindingHandle Specifies the driver binding handle for the
361 driver.
362 @param ProtocolGuid Specifies the protocol that the driver specified
363 by DriverBindingHandle opens in its Start()
364 function.
365
366 @retval EFI_SUCCESS ControllerHandle is managed by the driver
367 specifed by DriverBindingHandle.
368 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
369 specifed by DriverBindingHandle.
370
371 **/
372 EFI_STATUS
373 EFIAPI
374 EfiTestManagedDevice (
375 IN CONST EFI_HANDLE ControllerHandle,
376 IN CONST EFI_HANDLE DriverBindingHandle,
377 IN CONST EFI_GUID *ProtocolGuid
378 );
379
380 /**
381 Tests whether a child handle is a child device of the controller.
382
383 This function tests whether ChildHandle is one of the children of
384 ControllerHandle. This test is performed by checking to see if the protocol
385 specified by ProtocolGuid is present on ControllerHandle and opened by
386 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
387 If ProtocolGuid is NULL, then ASSERT().
388
389 @param ControllerHandle A handle for a (parent) controller to test.
390 @param ChildHandle A child handle to test.
391 @param ProtocolGuid Supplies the protocol that the child controller
392 opens on its parent controller.
393
394 @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle.
395 @retval EFI_UNSUPPORTED ChildHandle is not a child of the
396 ControllerHandle.
397
398 **/
399 EFI_STATUS
400 EFIAPI
401 EfiTestChildHandle (
402 IN CONST EFI_HANDLE ControllerHandle,
403 IN CONST EFI_HANDLE ChildHandle,
404 IN CONST EFI_GUID *ProtocolGuid
405 );
406
407 /**
408 This function looks up a Unicode string in UnicodeStringTable.
409
410 If Language is a member of SupportedLanguages and a Unicode string is found in
411 UnicodeStringTable that matches the language code specified by Language, then it
412 is returned in UnicodeString.
413
414 @param Language A pointer to the ISO 639-2 language code for the
415 Unicode string to look up and return.
416 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
417 that the Unicode string table supports. Language
418 must be a member of this set.
419 @param UnicodeStringTable A pointer to the table of Unicode strings.
420 @param UnicodeString A pointer to the Unicode string from UnicodeStringTable
421 that matches the language specified by Language.
422
423 @retval EFI_SUCCESS The Unicode string that matches the language
424 specified by Language was found
425 in the table of Unicoide strings UnicodeStringTable,
426 and it was returned in UnicodeString.
427 @retval EFI_INVALID_PARAMETER Language is NULL.
428 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
429 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
430 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
431 @retval EFI_UNSUPPORTED The language specified by Language is not a
432 member of SupportedLanguages.
433 @retval EFI_UNSUPPORTED The language specified by Language is not
434 supported by UnicodeStringTable.
435
436 **/
437 EFI_STATUS
438 EFIAPI
439 LookupUnicodeString (
440 IN CONST CHAR8 *Language,
441 IN CONST CHAR8 *SupportedLanguages,
442 IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,
443 OUT CHAR16 **UnicodeString
444 );
445
446 /**
447 This function looks up a Unicode string in UnicodeStringTable.
448 If Language is a member of SupportedLanguages and a Unicode
449 string is found in UnicodeStringTable that matches the
450 language code specified by Language, then it is returned in
451 UnicodeString.
452
453 @param Language A pointer to the ISO 639-2 or
454 RFC 3066 language code for the
455 Unicode string to look up and
456 return.
457 @param SupportedLanguages A pointer to the set of ISO
458 639-2 or RFC 3066 language
459 codes that the Unicode string
460 table supports. Language must
461 be a member of this set.
462 @param UnicodeStringTable A pointer to the table of
463 Unicode strings.
464 @param UnicodeString A pointer to the Unicode
465 string from UnicodeStringTable
466 that matches the language
467 specified by Language.
468 @param Iso639Language Specify the language code
469 format supported. If true,
470 then the format follow ISO
471 639-2. If false, then it
472 follows RFC3066.
473 @retval EFI_SUCCESS The Unicode string that
474 matches the language specified
475 by Language was found in the
476 table of Unicoide strings
477 UnicodeStringTable, and it was
478 returned in UnicodeString.
479
480 @retval EFI_INVALID_PARAMETER Language is NULL.
481 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
482 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
483 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
484 @retval EFI_UNSUPPORTED The language specified by
485 Language is not a member
486 ofSupportedLanguages.
487 @retval EFI_UNSUPPORTED The language specified by
488 Language is not supported by
489 UnicodeStringTable.
490
491 **/
492 EFI_STATUS
493 EFIAPI
494 LookupUnicodeString2 (
495 IN CONST CHAR8 *Language,
496 IN CONST CHAR8 *SupportedLanguages,
497 IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,
498 OUT CHAR16 **UnicodeString,
499 IN BOOLEAN Iso639Language
500 );
501
502 /**
503 This function adds a Unicode string to UnicodeStringTable.
504
505 If Language is a member of SupportedLanguages then UnicodeString is added to
506 UnicodeStringTable. New buffers are allocated for both Language and
507 UnicodeString. The contents of Language and UnicodeString are copied into
508 these new buffers. These buffers are automatically freed when
509 FreeUnicodeStringTable() is called.
510
511 @param Language A pointer to the ISO 639-2 language code for the Unicode
512 string to add.
513 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
514 that the Unicode string table supports.
515 Language must be a member of this set.
516 @param UnicodeStringTable A pointer to the table of Unicode strings.
517 @param UnicodeString A pointer to the Unicode string to add.
518
519 @retval EFI_SUCCESS The Unicode string that matches the language
520 specified by Language was found in the table of
521 Unicode strings UnicodeStringTable, and it was
522 returned in UnicodeString.
523 @retval EFI_INVALID_PARAMETER Language is NULL.
524 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
525 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
526 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
527 @retval EFI_ALREADY_STARTED A Unicode string with language Language is
528 already present in UnicodeStringTable.
529 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another
530 Unicode string to UnicodeStringTable.
531 @retval EFI_UNSUPPORTED The language specified by Language is not a
532 member of SupportedLanguages.
533
534 **/
535 EFI_STATUS
536 EFIAPI
537 AddUnicodeString (
538 IN CONST CHAR8 *Language,
539 IN CONST CHAR8 *SupportedLanguages,
540 IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable,
541 IN CONST CHAR16 *UnicodeString
542 );
543
544 /**
545 This function adds a Unicode string to UnicodeStringTable.
546
547 If Language is a member of SupportedLanguages then
548 UnicodeString is added to UnicodeStringTable. New buffers are
549 allocated for both Language and UnicodeString. The contents
550 of Language and UnicodeString are copied into these new
551 buffers. These buffers are automatically freed when
552 FreeUnicodeStringTable() is called.
553
554 @param Language A pointer to the ISO 639-2 or
555 RFC 3066 language code for the
556 Unicode string to add.
557 @param SupportedLanguages A pointer to the set of ISO
558 639-2 or RFC 3066 language
559 codes that the Unicode string
560 table supports. Language must
561 be a member of this set.
562 @param UnicodeStringTable A pointer to the table of
563 Unicode strings.
564 @param UnicodeString A pointer to the Unicode
565 string to add.
566 @param Iso639Language Specify the language code
567 format supported. If true,
568 then the format follow ISO
569 639-2. If false, then it
570 follows RFC3066.
571 @retval EFI_SUCCESS The Unicode string that
572 matches the language specified
573 by Language was found in the
574 table of Unicode strings
575 UnicodeStringTable, and it was
576 returned in UnicodeString.
577
578 @retval EFI_INVALID_PARAMETER Language is NULL.
579 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
580 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
581 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
582 @retval EFI_ALREADY_STARTED A Unicode string with language
583 Language is already present in
584 UnicodeStringTable.
585 @retval EFI_OUT_OF_RESOURCES There is not enough memory to
586 add another Unicode string to
587 UnicodeStringTable.
588 @retval EFI_UNSUPPORTED The language specified by
589 Language is not a member of
590 SupportedLanguages.
591
592 **/
593 EFI_STATUS
594 EFIAPI
595 AddUnicodeString2 (
596 IN CONST CHAR8 *Language,
597 IN CONST CHAR8 *SupportedLanguages,
598 IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable,
599 IN CONST CHAR16 *UnicodeString,
600 IN BOOLEAN Iso639Language
601 );
602
603 /**
604 This function frees the table of Unicode strings in UnicodeStringTable.
605
606 If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.
607 Otherwise, each language code, and each Unicode string in the Unicode string
608 table are freed, and EFI_SUCCESS is returned.
609
610 @param UnicodeStringTable A pointer to the table of Unicode strings.
611
612 @retval EFI_SUCCESS The Unicode string table was freed.
613
614 **/
615 EFI_STATUS
616 EFIAPI
617 FreeUnicodeStringTable (
618 IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable
619 );
620
621 /**
622 This function computes and returns the width of the Unicode character
623 specified by UnicodeChar.
624
625 @param UnicodeChar A Unicode character.
626
627 @retval 0 The width if UnicodeChar could not be determined.
628 @retval 1 UnicodeChar is a narrow glyph.
629 @retval 2 UnicodeChar is a wide glyph.
630
631 **/
632 UINTN
633 EFIAPI
634 GetGlyphWidth (
635 IN CHAR16 UnicodeChar
636 );
637
638 /**
639 Computes the display length of a Null-terminated Unicode String.
640
641 This function computes and returns the display length of
642 the Null-terminated Unicode string specified by String.
643 If String is NULL, then 0 is returned.
644 If any of the widths of the Unicode characters in String
645 can not be determined, then 0 is returned.
646
647 @param String A pointer to a Null-terminated Unicode string.
648
649 @return The display length of the Null-terminated Unicode string specified by String.
650
651 **/
652 UINTN
653 EFIAPI
654 UnicodeStringDisplayLength (
655 IN CONST CHAR16 *String
656 );
657
658 //
659 // Functions that abstract early Framework contamination of UEFI.
660 //
661 /**
662 Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().
663
664 This function abstracts the signaling of the Ready to Boot Event. The Framework moved
665 from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from
666 how this event is created to prevent to code form having to change with the version of
667 the specification supported.
668
669 **/
670 VOID
671 EFIAPI
672 EfiSignalEventReadyToBoot (
673 VOID
674 );
675
676 /**
677 Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().
678
679 This function abstracts the signaling of the Legacy Boot Event. The Framework moved from
680 a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how
681 this event is created to prevent to code form having to change with the version of the
682 specification supported.
683
684 **/
685 VOID
686 EFIAPI
687 EfiSignalEventLegacyBoot (
688 VOID
689 );
690
691 /**
692 Creates an EFI event in the Legacy Boot Event Group. Prior to UEFI 2.0 this
693 was done via a non blessed UEFI extensions and this library abstracts the
694 implementation mechanism of this event from the caller.
695
696 This function abstracts the creation of the Legacy Boot Event. The Framework
697 moved from a proprietary to UEFI 2.0 based mechanism. This library abstracts
698 the caller from how this event is created to prevent to code form having to
699 change with the version of the specification supported.
700 If LegacyBootEvent is NULL, then ASSERT().
701
702 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
703
704 @retval EFI_SUCCESS Event was created.
705 @retval Other Event was not created.
706
707 **/
708 EFI_STATUS
709 EFIAPI
710 EfiCreateEventLegacyBoot (
711 OUT EFI_EVENT *LegacyBootEvent
712 );
713
714 /**
715 Create an EFI event in the Legacy Boot Event Group and allows
716 the caller to specify a notification function.
717
718 This function abstracts the creation of the Legacy Boot Event.
719 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
720 This library abstracts the caller from how this event is created to prevent
721 to code form having to change with the version of the specification supported.
722 If LegacyBootEvent is NULL, then ASSERT().
723
724 @param NotifyTpl The task priority level of the event.
725 @param NotifyFunction The notification function to call when the event is signaled.
726 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
727 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
728
729 @retval EFI_SUCCESS Event was created.
730 @retval Other Event was not created.
731
732 **/
733 EFI_STATUS
734 EFIAPI
735 EfiCreateEventLegacyBootEx (
736 IN EFI_TPL NotifyTpl,
737 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
738 IN VOID *NotifyContext, OPTIONAL
739 OUT EFI_EVENT *LegacyBootEvent
740 );
741
742 /**
743 Create an EFI event in the Ready To Boot Event Group. Prior to UEFI 2.0 this
744 was done via a non-standard UEFI extension, and this library abstracts the
745 implementation mechanism of this event from the caller.
746
747 This function abstracts the creation of the Ready to Boot Event. The Framework
748 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts
749 the caller from how this event is created to prevent the code form having to
750 change with the version of the specification supported.
751 If ReadyToBootEvent is NULL, then ASSERT().
752
753 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
754
755 @retval EFI_SUCCESS Event was created.
756 @retval Other Event was not created.
757
758 **/
759 EFI_STATUS
760 EFIAPI
761 EfiCreateEventReadyToBoot (
762 OUT EFI_EVENT *ReadyToBootEvent
763 );
764
765 /**
766 Create an EFI event in the Ready To Boot Event Group and allows
767 the caller to specify a notification function.
768
769 This function abstracts the creation of the Ready to Boot Event.
770 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
771 This library abstracts the caller from how this event is created to prevent
772 to code form having to change with the version of the specification supported.
773 If ReadyToBootEvent is NULL, then ASSERT().
774
775 @param NotifyTpl The task priority level of the event.
776 @param NotifyFunction The notification function to call when the event is signaled.
777 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
778 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
779
780 @retval EFI_SUCCESS Event was created.
781 @retval Other Event was not created.
782
783 **/
784 EFI_STATUS
785 EFIAPI
786 EfiCreateEventReadyToBootEx (
787 IN EFI_TPL NotifyTpl,
788 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
789 IN VOID *NotifyContext, OPTIONAL
790 OUT EFI_EVENT *ReadyToBootEvent
791 );
792
793 /**
794 Initialize a Firmware Volume (FV) Media Device Path node.
795
796 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
797 This library function abstracts initializing a device path node.
798 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device
799 path changed in the DXE CIS version 0.92 in a non back ward compatible way to
800 not conflict with the UEFI 2.0 specification. This function abstracts the
801 differences from the caller.
802 If FvDevicePathNode is NULL, then ASSERT().
803 If NameGuid is NULL, then ASSERT().
804
805 @param FvDevicePathNode Pointer to a FV device path node to initialize
806 @param NameGuid FV file name to use in FvDevicePathNode
807
808 **/
809 VOID
810 EFIAPI
811 EfiInitializeFwVolDevicepathNode (
812 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
813 IN CONST EFI_GUID *NameGuid
814 );
815
816 /**
817 Check to see if the Firmware Volume (FV) Media Device Path is valid
818
819 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
820 This library function abstracts validating a device path node.
821 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.
822 If it is valid, then return the GUID file name from the device path node. Otherwise,
823 return NULL. This device path changed in the DXE CIS version 0.92 in a non back ward
824 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts
825 the differences from the caller.
826 If FvDevicePathNode is NULL, then ASSERT().
827
828 @param FvDevicePathNode Pointer to FV device path to check.
829
830 @retval NULL FvDevicePathNode is not valid.
831 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
832
833 **/
834 EFI_GUID *
835 EFIAPI
836 EfiGetNameGuidFromFwVolDevicePathNode (
837 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode
838 );
839
840 /**
841 Prints a formatted Unicode string to the console output device specified by
842 ConOut defined in the EFI_SYSTEM_TABLE.
843
844 This function prints a formatted Unicode string to the console output device
845 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
846 characters that printed to ConOut. If the length of the formatted Unicode
847 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
848 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
849 If Format is NULL, then ASSERT().
850 If Format is not aligned on a 16-bit boundary, then ASSERT().
851
852 @param Format Null-terminated Unicode format string.
853 @param ... Variable argument list whose contents are accessed based
854 on the format string specified by Format.
855
856 @return Number of Unicode characters printed to ConOut.
857
858 **/
859 UINTN
860 EFIAPI
861 Print (
862 IN CONST CHAR16 *Format,
863 ...
864 );
865
866 /**
867 Prints a formatted Unicode string to the console output device specified by
868 StdErr defined in the EFI_SYSTEM_TABLE.
869
870 This function prints a formatted Unicode string to the console output device
871 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
872 characters that printed to StdErr. If the length of the formatted Unicode
873 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
874 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
875 If Format is NULL, then ASSERT().
876 If Format is not aligned on a 16-bit boundary, then ASSERT().
877
878 @param Format Null-terminated Unicode format string.
879 @param ... Variable argument list whose contents are accessed based
880 on the format string specified by Format.
881
882 @return Number of Unicode characters printed to StdErr.
883
884 **/
885 UINTN
886 EFIAPI
887 ErrorPrint (
888 IN CONST CHAR16 *Format,
889 ...
890 );
891
892 /**
893 Prints a formatted ASCII string to the console output device specified by
894 ConOut defined in the EFI_SYSTEM_TABLE.
895
896 This function prints a formatted ASCII string to the console output device
897 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
898 characters that printed to ConOut. If the length of the formatted ASCII
899 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
900 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
901 If Format is NULL, then ASSERT().
902 If Format is not aligned on a 16-bit boundary, then ASSERT().
903
904 @param Format Null-terminated ASCII format string.
905 @param ... Variable argument list whose contents are accessed based
906 on the format string specified by Format.
907
908 @return Number of ASCII characters printed to ConOut.
909
910 **/
911 UINTN
912 EFIAPI
913 AsciiPrint (
914 IN CONST CHAR8 *Format,
915 ...
916 );
917
918 /**
919 Prints a formatted ASCII string to the console output device specified by
920 StdErr defined in the EFI_SYSTEM_TABLE.
921
922 This function prints a formatted ASCII string to the console output device
923 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
924 characters that printed to StdErr. If the length of the formatted ASCII
925 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
926 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
927 If Format is NULL, then ASSERT().
928 If Format is not aligned on a 16-bit boundary, then ASSERT().
929
930 @param Format Null-terminated ASCII format string.
931 @param ... Variable argument list whose contents are accessed based
932 on the format string specified by Format.
933
934 @return Number of ASCII characters printed to ConErr.
935
936 **/
937 UINTN
938 EFIAPI
939 AsciiErrorPrint (
940 IN CONST CHAR8 *Format,
941 ...
942 );
943
944 /**
945 Prints a formatted Unicode string to a graphics console device specified by
946 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
947
948 This function prints a formatted Unicode string to the graphics console device
949 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
950 Unicode characters printed. If the length of the formatted Unicode string is
951 greater than PcdUefiLibMaxPrintBufferSize, then only the first
952 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
953 is used to convert the string to a bitmap using the glyphs registered with the
954 HII database. No wrapping is performed, so any portions of the string the fall
955 outside the active display region will not be displayed.
956
957 If a graphics console device is not associated with the ConsoleOutputHandle
958 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
959 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
960 string is printed, and 0 is returned.
961 If Format is NULL, then ASSERT().
962 If Format is not aligned on a 16-bit boundary, then ASSERT().
963
964 @param X X coordinate to print the string.
965 @param Y Y coordinate to print the string.
966 @param ForeGround The forground color of the string being printed. This is
967 an optional parameter that may be NULL. If it is NULL,
968 then the foreground color of the current ConOut device
969 in the EFI_SYSTEM_TABLE is used.
970 @param BackGround The background color of the string being printed. This is
971 an optional parameter that may be NULL. If it is NULL,
972 then the background color of the current ConOut device
973 in the EFI_SYSTEM_TABLE is used.
974 @param Format Null-terminated Unicode format string. See Print Library
975 for the supported format string syntax.
976 @param ... Variable argument list whose contents are accessed based on
977 the format string specified by Format.
978
979 @return The number of Unicode characters printed.
980
981 **/
982 UINTN
983 EFIAPI
984 PrintXY (
985 IN UINTN X,
986 IN UINTN Y,
987 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL
988 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL
989 IN CONST CHAR16 *Format,
990 ...
991 );
992
993 /**
994 Prints a formatted ASCII string to a graphics console device specified by
995 ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.
996
997 This function prints a formatted ASCII string to the graphics console device
998 specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of
999 ASCII characters printed. If the length of the formatted ASCII string is
1000 greater than PcdUefiLibMaxPrintBufferSize, then only the first
1001 PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL
1002 is used to convert the string to a bitmap using the glyphs registered with the
1003 HII database. No wrapping is performed, so any portions of the string the fall
1004 outside the active display region will not be displayed.
1005
1006 If a graphics console device is not associated with the ConsoleOutputHandle
1007 defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
1008 If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
1009 string is printed, and 0 is returned.
1010 If Format is NULL, then ASSERT().
1011 If Format is not aligned on a 16-bit boundary, then ASSERT().
1012
1013 @param X X coordinate to print the string.
1014 @param Y Y coordinate to print the string.
1015 @param ForeGround The forground color of the string being printed. This is
1016 an optional parameter that may be NULL. If it is NULL,
1017 then the foreground color of the current ConOut device
1018 in the EFI_SYSTEM_TABLE is used.
1019 @param BackGround The background color of the string being printed. This is
1020 an optional parameter that may be NULL. If it is NULL,
1021 then the background color of the current ConOut device
1022 in the EFI_SYSTEM_TABLE is used.
1023 @param Format Null-terminated ASCII format string. See Print Library
1024 for the supported format string syntax.
1025 @param ... Variable argument list whose contents are accessed based on
1026 the format string specified by Format.
1027
1028 @return The number of ASCII characters printed.
1029
1030 **/
1031 UINTN
1032 EFIAPI
1033 AsciiPrintXY (
1034 IN UINTN X,
1035 IN UINTN Y,
1036 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL
1037 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL
1038 IN CONST CHAR8 *Format,
1039 ...
1040 );
1041
1042 /**
1043 Initializes a driver by installing the Driver Binding Protocol onto the driver's
1044 DriverBindingHandle.
1045
1046 This is typically the same as the driver's ImageHandle, but
1047 it can be different if the driver produces multiple DriverBinding Protocols.
1048 If the Driver Binding Protocol interface is NULL, then ASSERT ().
1049 If the installation fails, then ASSERT ().
1050
1051 @param ImageHandle The image handle of the driver.
1052 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1053 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1054 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1055 parameter is NULL, then a new handle is created.
1056
1057 @retval EFI_SUCCESS The protocol installation is completed successfully.
1058 @retval EFI_OUT_OF_RESOURCES There was not enough system resources to install the protocol.
1059 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
1060
1061 **/
1062 EFI_STATUS
1063 EFIAPI
1064 EfiLibInstallDriverBinding (
1065 IN CONST EFI_HANDLE ImageHandle,
1066 IN CONST EFI_SYSTEM_TABLE *SystemTable,
1067 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
1068 IN EFI_HANDLE DriverBindingHandle
1069 );
1070
1071
1072 /**
1073 Initializes a driver by installing the Driver Binding Protocol together with the optional Component Name,
1074 Driver Configure and Driver Diagnostic Protocols onto the driver's DriverBindingHandle.
1075
1076 This is typically the same as the driver's ImageHandle, but it can be different if the driver produces multiple
1077 DriverBinding Protocols.
1078 If the Driver Binding Protocol interface is NULL, then ASSERT ().
1079 If the installation fails, then ASSERT ().
1080
1081 @param ImageHandle The image handle of the driver.
1082 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1083 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1084 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1085 parameter is NULL, then a new handle is created.
1086 @param ComponentName A Component Name Protocol instance that this driver is producing.
1087 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1088 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1089
1090 @retval EFI_SUCCESS The protocol installation is completed successfully.
1091 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
1092
1093 **/
1094 EFI_STATUS
1095 EFIAPI
1096 EfiLibInstallAllDriverProtocols (
1097 IN CONST EFI_HANDLE ImageHandle,
1098 IN CONST EFI_SYSTEM_TABLE *SystemTable,
1099 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
1100 IN EFI_HANDLE DriverBindingHandle,
1101 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL
1102 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL
1103 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL
1104 );
1105
1106
1107
1108 /**
1109 Initializes a driver by installing the Driver Binding Protocol together with the optional Component Name,
1110 Component Name 2 onto the driver's DriverBindingHandle. This is typically the same as the driver's
1111 ImageHandle, but it can be different if the driver produces multiple DriverBinding Protocols.
1112 If the Driver Binding Protocol interface is NULL, then ASSERT ().
1113 If the installation fails, then ASSERT ().
1114
1115 @param ImageHandle The image handle of the driver.
1116 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1117 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1118 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
1119 parameter is NULL, then a new handle is created.
1120 @param ComponentName A Component Name Protocol instance that this driver is producing.
1121 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1122
1123 @retval EFI_SUCCESS The protocol installation is completed successfully.
1124 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
1125
1126 **/
1127 EFI_STATUS
1128 EFIAPI
1129 EfiLibInstallDriverBindingComponentName2 (
1130 IN CONST EFI_HANDLE ImageHandle,
1131 IN CONST EFI_SYSTEM_TABLE *SystemTable,
1132 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
1133 IN EFI_HANDLE DriverBindingHandle,
1134 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL
1135 IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL
1136 );
1137
1138
1139 /**
1140 Intialize a driver by installing the Driver Binding Protocol together with the optional Component Name,
1141 Component Name 2, Driver Configure, Driver Diagnostic and Driver Diagnostic 2 Protocols onto the driver's
1142 DriverBindingHandle.
1143
1144 This is typically the same as the driver's ImageHandle, but it can be different if
1145 the driver produces multiple DriverBinding Protocols.
1146 If the Drvier Binding Protocol interface is NULL, then ASSERT ().
1147 If the installation fails, then ASSERT ().
1148
1149 @param ImageHandle The image handle of the driver.
1150 @param SystemTable The EFI System Table that was passed to the driver's entry point.
1151 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
1152 @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this
1153 parameter is NULL, then a new handle is created.
1154 @param ComponentName A Component Name Protocol instance that this driver is producing.
1155 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
1156 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
1157 @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver is producing.
1158 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
1159 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing.
1160
1161 @retval EFI_SUCCESS The protocol installation is completed successfully.
1162 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
1163
1164 **/
1165 EFI_STATUS
1166 EFIAPI
1167 EfiLibInstallAllDriverProtocols2 (
1168 IN CONST EFI_HANDLE ImageHandle,
1169 IN CONST EFI_SYSTEM_TABLE *SystemTable,
1170 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
1171 IN EFI_HANDLE DriverBindingHandle,
1172 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL
1173 IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL
1174 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL
1175 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration2, OPTIONAL
1176 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics, OPTIONAL
1177 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL
1178 );
1179
1180 /**
1181 Determine what is the current language setting. The space reserved for Lang
1182 must be at least RFC_3066_ENTRY_SIZE bytes;
1183
1184 If Lang is NULL, then ASSERT.
1185
1186 @param Lang Pointer of system language. Lang will always be filled with a valid RFC 3066
1187 language string. If "PlatformLang" is not set in the system, the default
1188 language specifed by PcdUefiVariableDefaultPlatformLang is returned.
1189
1190 @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.
1191 @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.
1192
1193 **/
1194 EFI_STATUS
1195 EFIAPI
1196 GetCurrentLanguage (
1197 OUT CHAR8 *Lang
1198 );
1199
1200
1201 #endif