]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/UefiLib.h
fa04704c33ff0a3ef976c52ebbf481b85c055e75
[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 Create a Legacy Boot Event.
622
623 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
624 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
625 added and now it's possible to not voilate the UEFI specification by
626 declaring a GUID for the legacy boot event class. This library supports
627 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
628 work both ways.
629
630 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
631
632 @retval EFI_SUCCESS Event was created.
633 @retval Other Event was not created.
634
635 **/
636 EFI_STATUS
637 EFIAPI
638 EfiCreateEventLegacyBoot (
639 OUT EFI_EVENT *LegacyBootEvent
640 );
641
642 /**
643 Create an EFI event in the Legacy Boot Event Group and allows
644 the caller to specify a notification function.
645
646 This function abstracts the creation of the Legacy Boot Event.
647 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
648 This library abstracts the caller from how this event is created to prevent
649 to code form having to change with the version of the specification supported.
650 If LegacyBootEvent is NULL, then ASSERT().
651
652 @param NotifyTpl The task priority level of the event.
653 @param NotifyFunction The notification function to call when the event is signaled.
654 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
655 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
656
657 @retval EFI_SUCCESS Event was created.
658 @retval Other Event was not created.
659
660 **/
661 EFI_STATUS
662 EFIAPI
663 EfiCreateEventLegacyBootEx (
664 IN EFI_TPL NotifyTpl,
665 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
666 IN VOID *NotifyContext, OPTIONAL
667 OUT EFI_EVENT *LegacyBootEvent
668 );
669
670 /**
671 Create a Read to Boot Event.
672
673 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
674 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
675 added and now it's possible to not voilate the UEFI specification and use
676 the ready to boot event class defined in UEFI 2.0. This library supports
677 the EDK/EFI 1.10 form and EDKII/UEFI 2.0 form and allows common code to
678 work both ways.
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 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
724 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
725 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
726 device path is defined for Tiano extensions of device path. If the code
727 is compiled to conform with the UEFI 2.0 specification use the new device path
728 else use the old form for backwards compatability.
729
730 @param FvDevicePathNode Pointer to a FV device path node to initialize
731 @param NameGuid FV file name to use in FvDevicePathNode
732
733 **/
734 VOID
735 EFIAPI
736 EfiInitializeFwVolDevicepathNode (
737 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
738 IN CONST EFI_GUID *NameGuid
739 );
740
741 /**
742 Check to see if the Firmware Volume (FV) Media Device Path is valid
743
744 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
745 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
746 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
747 device path is defined for Tiano extensions of device path. If the code
748 is compiled to conform with the UEFI 2.0 specification use the new device path
749 else use the old form for backwards compatability. The return value to this
750 function points to a location in FvDevicePathNode and it does not allocate
751 new memory for the GUID pointer that is returned.
752
753 @param FvDevicePathNode Pointer to FV device path to check.
754
755 @retval NULL FvDevicePathNode is not valid.
756 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
757
758 **/
759 EFI_GUID *
760 EFIAPI
761 EfiGetNameGuidFromFwVolDevicePathNode (
762 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode
763 );
764
765 /**
766 Prints a formatted Unicode string to the console output device specified by
767 ConOut defined in the EFI_SYSTEM_TABLE.
768
769 This function prints a formatted Unicode string to the console output device
770 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode
771 characters that printed to ConOut. If the length of the formatted Unicode
772 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
773 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
774
775 @param Format Null-terminated Unicode format string.
776 @param ... VARARG list consumed to process Format.
777 If Format is NULL, then ASSERT().
778 If Format is not aligned on a 16-bit boundary, then ASSERT().
779
780 @return Number of Unicode characters printed to ConOut.
781
782 **/
783 UINTN
784 EFIAPI
785 Print (
786 IN CONST CHAR16 *Format,
787 ...
788 );
789
790 /**
791 Prints a formatted Unicode string to the console output device specified by
792 StdErr defined in the EFI_SYSTEM_TABLE.
793
794 This function prints a formatted Unicode string to the console output device
795 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode
796 characters that printed to StdErr. If the length of the formatted Unicode
797 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
798 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
799
800 @param Format Null-terminated Unicode format string.
801 @param ... VARARG list consumed to process Format.
802 If Format is NULL, then ASSERT().
803 If Format is not aligned on a 16-bit boundary, then ASSERT().
804
805 @return Number of Unicode characters printed to StdErr.
806
807 **/
808 UINTN
809 EFIAPI
810 ErrorPrint (
811 IN CONST CHAR16 *Format,
812 ...
813 );
814
815 /**
816 Prints a formatted ASCII string to the console output device specified by
817 ConOut defined in the EFI_SYSTEM_TABLE.
818
819 This function prints a formatted ASCII string to the console output device
820 specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII
821 characters that printed to ConOut. If the length of the formatted ASCII
822 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
823 PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
824
825 @param Format Null-terminated ASCII format string.
826 @param ... VARARG list consumed to process Format.
827 If Format is NULL, then ASSERT().
828 If Format is not aligned on a 16-bit boundary, then ASSERT().
829
830 @return Number of ASCII characters printed to ConOut.
831
832 **/
833 UINTN
834 EFIAPI
835 AsciiPrint (
836 IN CONST CHAR8 *Format,
837 ...
838 );
839
840 /**
841 Prints a formatted ASCII string to the console output device specified by
842 StdErr defined in the EFI_SYSTEM_TABLE.
843
844 This function prints a formatted ASCII string to the console output device
845 specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII
846 characters that printed to StdErr. If the length of the formatted ASCII
847 string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
848 PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
849
850 @param Format Null-terminated ASCII format string.
851 @param ... VARARG list consumed to process Format.
852 If Format is NULL, then ASSERT().
853 If Format is not aligned on a 16-bit boundary, then ASSERT().
854
855 @return Number of ASCII characters printed to ConErr.
856
857 **/
858 UINTN
859 EFIAPI
860 AsciiErrorPrint (
861 IN CONST CHAR8 *Format,
862 ...
863 );
864
865 /**
866 Initializes a driver by installing the Driver Binding Protocol onto the driver's
867 DriverBindingHandle. This is typically the same as the driver's ImageHandle, but
868 it can be different if the driver produces multiple DriverBinding Protocols.
869 If the Driver Binding Protocol interface is NULL, then ASSERT ().
870 If the installation fails, then ASSERT ().
871
872 @param ImageHandle The image handle of the driver.
873 @param SystemTable The EFI System Table that was passed to the driver's entry point.
874 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
875 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
876 parameter is NULL, then a new handle is created.
877
878 @retval EFI_SUCCESS The protocol installation is completed successfully.
879 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
880
881 **/
882 EFI_STATUS
883 EFIAPI
884 EfiLibInstallDriverBinding (
885 IN CONST EFI_HANDLE ImageHandle,
886 IN CONST EFI_SYSTEM_TABLE *SystemTable,
887 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
888 IN EFI_HANDLE DriverBindingHandle
889 );
890
891
892 /**
893 Initializes a driver by installing the Driver Binding Protocol together with the optional Component Name,
894 Driver Configure and Driver Diagnostic Protocols onto the driver's DriverBindingHandle. This is
895 typically the same as the driver's ImageHandle, but it can be different if the driver produces multiple
896 DriverBinding Protocols.
897 If the Driver Binding Protocol interface is NULL, then ASSERT ().
898 If the installation fails, then ASSERT ().
899
900 @param ImageHandle The image handle of the driver.
901 @param SystemTable The EFI System Table that was passed to the driver's entry point.
902 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
903 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
904 parameter is NULL, then a new handle is created.
905 @param ComponentName A Component Name Protocol instance that this driver is producing.
906 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
907 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
908
909 @retval EFI_SUCCESS The protocol installation is completed successfully.
910 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
911
912 **/
913 EFI_STATUS
914 EFIAPI
915 EfiLibInstallAllDriverProtocols (
916 IN CONST EFI_HANDLE ImageHandle,
917 IN CONST EFI_SYSTEM_TABLE *SystemTable,
918 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
919 IN EFI_HANDLE DriverBindingHandle,
920 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL
921 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL
922 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL
923 );
924
925
926
927 /**
928 Initializes a driver by installing the Driver Binding Protocol together with the optional Component Name,
929 Component Name 2 onto the driver's DriverBindingHandle. This is typically the same as the driver's
930 ImageHandle, but it can be different if the driver produces multiple DriverBinding Protocols.
931 If the Driver Binding Protocol interface is NULL, then ASSERT ().
932 If the installation fails, then ASSERT ().
933
934 @param ImageHandle The image handle of the driver.
935 @param SystemTable The EFI System Table that was passed to the driver's entry point.
936 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
937 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
938 parameter is NULL, then a new handle is created.
939 @param ComponentName A Component Name Protocol instance that this driver is producing.
940 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
941
942 @retval EFI_SUCCESS The protocol installation is completed successfully.
943 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
944
945 **/
946 EFI_STATUS
947 EFIAPI
948 EfiLibInstallDriverBindingComponentName2 (
949 IN CONST EFI_HANDLE ImageHandle,
950 IN CONST EFI_SYSTEM_TABLE *SystemTable,
951 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
952 IN EFI_HANDLE DriverBindingHandle,
953 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL
954 IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL
955 );
956
957
958 /**
959 Initializes a driver by installing the Driver Binding Protocol together with the optional Component Name,
960 Component Name 2, Driver Configure, Driver Diagnostic and Driver Diagnostic 2 Protocols onto the driver's
961 DriverBindingHandle. This is typically the same as the driver's ImageHandle, but it can be different if
962 the driver produces multiple DriverBinding Protocols.
963 If the Driver Binding Protocol interface is NULL, then ASSERT ().
964 If the installation fails, then ASSERT ().
965
966 @param ImageHandle The image handle of the driver.
967 @param SystemTable The EFI System Table that was passed to the driver's entry point.
968 @param DriverBinding A Driver Binding Protocol instance that this driver is producing.
969 @param DriverBindingHandle The handle that DriverBinding is to be installed onto. If this
970 parameter is NULL, then a new handle is created.
971 @param ComponentName A Component Name Protocol instance that this driver is producing.
972 @param ComponentName2 A Component Name 2 Protocol instance that this driver is producing.
973 @param DriverConfiguration A Driver Configuration Protocol instance that this driver is producing.
974 @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing.
975 @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver is producing.
976
977 @retval EFI_SUCCESS The protocol installation is completed successfully.
978 @retval Others Status from gBS->InstallMultipleProtocolInterfaces().
979
980 **/
981 EFI_STATUS
982 EFIAPI
983 EfiLibInstallAllDriverProtocols2 (
984 IN CONST EFI_HANDLE ImageHandle,
985 IN CONST EFI_SYSTEM_TABLE *SystemTable,
986 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
987 IN EFI_HANDLE DriverBindingHandle,
988 IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL
989 IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL
990 IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL
991 IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics, OPTIONAL
992 IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL
993 );
994
995 /**
996 Determine what is the current language setting. The space reserved for Lang
997 must be at least RFC_3066_ENTRY_SIZE bytes;
998
999 If Lang is NULL, then ASSERT.
1000
1001 @param Lang Pointer of system language. Lang will always be filled with
1002 a valid RFC 3066 language string. If "PlatformLang" is not
1003 set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang
1004 is returned.
1005
1006 @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.
1007 @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.
1008
1009 **/
1010 EFI_STATUS
1011 EFIAPI
1012 GetCurrentLanguage (
1013 OUT CHAR8 *Lang
1014 );
1015
1016
1017 #endif