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