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