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