]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiLib/UefiLib.c
Update copyright for files modified in this year
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiLib.c
CommitLineData
e386b444 1/** @file\r
5ad97f35 2 The UEFI Library provides functions and macros that simplify the development of \r
3 UEFI Drivers and UEFI Applications. These functions and macros help manage EFI \r
4 events, build simple locks utilizing EFI Task Priority Levels (TPLs), install \r
5 EFI Driver Model related protocols, manage Unicode string tables for UEFI Drivers, \r
6 and print messages on the console output and standard error devices.\r
e386b444 7\r
373ade0e 8 Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
e386b444 9 All rights reserved. This program and the accompanying materials\r
10 are licensed and made available under the terms and conditions of the BSD License\r
11 which accompanies this distribution. The full text of the license may be found at\r
12 http://opensource.org/licenses/bsd-license.php\r
13\r
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
16\r
e386b444 17**/\r
18\r
1efcc4ae 19\r
f734a10a 20#include "UefiLibInternal.h"\r
e386b444 21\r
22/**\r
23 Compare whether two names of languages are identical.\r
24\r
25 @param Language1 Name of language 1.\r
26 @param Language2 Name of language 2.\r
27\r
28 @retval TRUE Language 1 and language 2 are the same.\r
29 @retval FALSE Language 1 and language 2 are not the same.\r
30\r
31**/\r
e386b444 32BOOLEAN\r
33CompareIso639LanguageCode (\r
34 IN CONST CHAR8 *Language1,\r
35 IN CONST CHAR8 *Language2\r
36 )\r
37{\r
38 UINT32 Name1;\r
39 UINT32 Name2;\r
40\r
41 Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1);\r
42 Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2);\r
43\r
44 return (BOOLEAN) (Name1 == Name2);\r
45}\r
46\r
47/**\r
1d37ab9f 48 Retrieves a pointer to the system configuration table from the EFI System Table\r
49 based on a specified GUID.\r
50 \r
51 This function searches the list of configuration tables stored in the EFI System Table\r
52 for a table with a GUID that matches TableGuid. If a match is found, then a pointer to\r
53 the configuration table is returned in Table., and EFI_SUCCESS is returned. If a matching GUID\r
54 is not found, then EFI_NOT_FOUND is returned.\r
9edc73ad 55 If TableGuid is NULL, then ASSERT().\r
56 If Table is NULL, then ASSERT().\r
e386b444 57\r
58 @param TableGuid Pointer to table's GUID type..\r
59 @param Table Pointer to the table associated with TableGuid in the EFI System Table.\r
60\r
61 @retval EFI_SUCCESS A configuration table matching TableGuid was found.\r
62 @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.\r
63\r
64**/\r
65EFI_STATUS\r
66EFIAPI\r
67EfiGetSystemConfigurationTable (\r
68 IN EFI_GUID *TableGuid,\r
69 OUT VOID **Table\r
70 )\r
71{\r
72 EFI_SYSTEM_TABLE *SystemTable;\r
73 UINTN Index;\r
74\r
75 ASSERT (TableGuid != NULL);\r
76 ASSERT (Table != NULL);\r
77\r
78 SystemTable = gST;\r
79 *Table = NULL;\r
80 for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {\r
81 if (CompareGuid (TableGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) {\r
82 *Table = SystemTable->ConfigurationTable[Index].VendorTable;\r
83 return EFI_SUCCESS;\r
84 }\r
85 }\r
86\r
87 return EFI_NOT_FOUND;\r
88}\r
89\r
90/**\r
1d37ab9f 91 Creates and returns a notification event and registers that event with all the protocol\r
92 instances specified by ProtocolGuid.\r
93\r
94 This function causes the notification function to be executed for every protocol of type\r
95 ProtocolGuid instance that exists in the system when this function is invoked.\r
96 In addition, every time a protocol of type ProtocolGuid instance is installed or reinstalled,\r
97 the notification function is also executed. This function returns the notification event\r
98 that was created. \r
99 If ProtocolGuid is NULL, then ASSERT().\r
100 If NotifyTpl is not a legal TPL value, then ASSERT().\r
101 If NotifyFunction is NULL, then ASSERT().\r
102 If Registration is NULL, then ASSERT().\r
e386b444 103\r
104 @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.\r
105 @param NotifyTpl Supplies the task priority level of the event notifications.\r
106 @param NotifyFunction Supplies the function to notify when the event is signaled.\r
107 @param NotifyContext The context parameter to pass to NotifyFunction.\r
108 @param Registration A pointer to a memory location to receive the registration value.\r
1d37ab9f 109 This value is passed to LocateHandle() to obtain new handles that\r
110 have been added that support the ProtocolGuid-specified protocol. \r
e386b444 111\r
112 @return The notification event that was created.\r
113\r
114**/\r
115EFI_EVENT\r
116EFIAPI\r
117EfiCreateProtocolNotifyEvent(\r
118 IN EFI_GUID *ProtocolGuid,\r
119 IN EFI_TPL NotifyTpl,\r
120 IN EFI_EVENT_NOTIFY NotifyFunction,\r
121 IN VOID *NotifyContext, OPTIONAL\r
122 OUT VOID **Registration\r
123 )\r
124{\r
125 EFI_STATUS Status;\r
126 EFI_EVENT Event;\r
127\r
1d37ab9f 128 ASSERT (ProtocolGuid != NULL);\r
129 ASSERT (NotifyFunction != NULL);\r
130 ASSERT (Registration != NULL);\r
131\r
e386b444 132 //\r
133 // Create the event\r
134 //\r
135\r
136 Status = gBS->CreateEvent (\r
137 EVT_NOTIFY_SIGNAL,\r
138 NotifyTpl,\r
139 NotifyFunction,\r
140 NotifyContext,\r
141 &Event\r
142 );\r
143 ASSERT_EFI_ERROR (Status);\r
144\r
145 //\r
146 // Register for protocol notifactions on this event\r
147 //\r
148\r
149 Status = gBS->RegisterProtocolNotify (\r
150 ProtocolGuid,\r
151 Event,\r
152 Registration\r
153 );\r
154\r
155 ASSERT_EFI_ERROR (Status);\r
156\r
157 //\r
158 // Kick the event so we will perform an initial pass of\r
159 // current installed drivers\r
160 //\r
161\r
162 gBS->SignalEvent (Event);\r
163 return Event;\r
164}\r
165\r
166/**\r
1d37ab9f 167 Creates a named event that can be signaled with EfiNamedEventSignal().\r
168\r
e386b444 169 This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.\r
1d37ab9f 170 This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more\r
171 listeners on the same event named by the GUID specified by Name. \r
9edc73ad 172 If Name is NULL, then ASSERT().\r
173 If NotifyTpl is not a legal TPL value, then ASSERT().\r
174 If NotifyFunction is NULL, then ASSERT().\r
e386b444 175\r
176 @param Name Supplies GUID name of the event.\r
177 @param NotifyTpl Supplies the task priority level of the event notifications.\r
178 @param NotifyFunction Supplies the function to notify when the event is signaled.\r
1d37ab9f 179 @param NotifyContext The context parameter to pass to NotifyFunction. \r
e386b444 180 @param Registration A pointer to a memory location to receive the registration value.\r
181\r
182 @retval EFI_SUCCESS A named event was created.\r
183 @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event.\r
184\r
185**/\r
186EFI_STATUS\r
187EFIAPI\r
188EfiNamedEventListen (\r
189 IN CONST EFI_GUID *Name,\r
190 IN EFI_TPL NotifyTpl,\r
191 IN EFI_EVENT_NOTIFY NotifyFunction,\r
192 IN CONST VOID *NotifyContext, OPTIONAL\r
193 OUT VOID *Registration OPTIONAL\r
194 )\r
195{\r
196 EFI_STATUS Status;\r
197 EFI_EVENT Event;\r
198 VOID *RegistrationLocal;\r
199\r
9edc73ad 200 ASSERT (Name != NULL);\r
201 ASSERT (NotifyFunction != NULL);\r
202 ASSERT (NotifyTpl <= TPL_HIGH_LEVEL);\r
203 \r
e386b444 204 //\r
205 // Create event\r
206 //\r
207 Status = gBS->CreateEvent (\r
208 EVT_NOTIFY_SIGNAL,\r
209 NotifyTpl,\r
210 NotifyFunction,\r
211 (VOID *) NotifyContext,\r
212 &Event\r
213 );\r
214 ASSERT_EFI_ERROR (Status);\r
215\r
216 //\r
217 // The Registration is not optional to RegisterProtocolNotify().\r
218 // To make it optional to EfiNamedEventListen(), may need to substitute with a local.\r
219 //\r
220 if (Registration != NULL) {\r
221 RegistrationLocal = Registration;\r
222 } else {\r
223 RegistrationLocal = &RegistrationLocal;\r
224 }\r
225\r
226 //\r
227 // Register for an installation of protocol interface\r
228 //\r
229\r
230 Status = gBS->RegisterProtocolNotify (\r
231 (EFI_GUID *) Name,\r
232 Event,\r
233 RegistrationLocal\r
234 );\r
235 ASSERT_EFI_ERROR (Status);\r
236\r
9edc73ad 237 return Status;\r
e386b444 238}\r
239\r
240/**\r
1d37ab9f 241 Signals a named event created with EfiNamedEventListen().\r
242\r
243 This function signals the named event specified by Name. The named event must have been\r
244 created with EfiNamedEventListen().\r
245 If Name is NULL, then ASSERT().\r
e386b444 246\r
247 @param Name Supplies GUID name of the event.\r
248\r
249 @retval EFI_SUCCESS A named event was signaled.\r
250 @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event.\r
251\r
252**/\r
253EFI_STATUS\r
254EFIAPI\r
255EfiNamedEventSignal (\r
256 IN CONST EFI_GUID *Name\r
257 )\r
258{\r
259 EFI_STATUS Status;\r
260 EFI_HANDLE Handle;\r
261\r
1d37ab9f 262 ASSERT(Name != NULL);\r
263\r
e386b444 264 Handle = NULL;\r
265 Status = gBS->InstallProtocolInterface (\r
266 &Handle,\r
267 (EFI_GUID *) Name,\r
268 EFI_NATIVE_INTERFACE,\r
269 NULL\r
270 );\r
271 ASSERT_EFI_ERROR (Status);\r
272\r
273 Status = gBS->UninstallProtocolInterface (\r
274 Handle,\r
275 (EFI_GUID *) Name,\r
276 NULL\r
277 );\r
278 ASSERT_EFI_ERROR (Status);\r
279\r
9edc73ad 280 return Status;\r
e386b444 281}\r
282\r
cf8ae2f6 283/** \r
e386b444 284 Returns the current TPL.\r
285\r
cf8ae2f6 286 This function returns the current TPL. There is no EFI service to directly \r
287 retrieve the current TPL. Instead, the RaiseTPL() function is used to raise \r
288 the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level \r
289 can then immediately be restored back to the current TPL level with a call \r
e386b444 290 to RestoreTPL().\r
291\r
cf8ae2f6 292 @return The current TPL.\r
e386b444 293\r
294**/\r
295EFI_TPL\r
296EFIAPI\r
297EfiGetCurrentTpl (\r
298 VOID\r
299 )\r
300{\r
301 EFI_TPL Tpl;\r
302\r
303 Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
304 gBS->RestoreTPL (Tpl);\r
305\r
306 return Tpl;\r
307}\r
308\r
309\r
310/**\r
1d37ab9f 311 Initializes a basic mutual exclusion lock.\r
312\r
313 This function initializes a basic mutual exclusion lock to the released state \r
314 and returns the lock. Each lock provides mutual exclusion access at its task \r
e386b444 315 priority level. Since there is no preemption or multiprocessor support in EFI,\r
316 acquiring the lock only consists of raising to the locks TPL.\r
9edc73ad 317 If Lock is NULL, then ASSERT().\r
318 If Priority is not a valid TPL value, then ASSERT().\r
e386b444 319\r
320 @param Lock A pointer to the lock data structure to initialize.\r
321 @param Priority EFI TPL associated with the lock.\r
322\r
323 @return The lock.\r
324\r
325**/\r
326EFI_LOCK *\r
327EFIAPI\r
328EfiInitializeLock (\r
329 IN OUT EFI_LOCK *Lock,\r
330 IN EFI_TPL Priority\r
331 )\r
332{\r
333 ASSERT (Lock != NULL);\r
334 ASSERT (Priority <= TPL_HIGH_LEVEL);\r
335\r
336 Lock->Tpl = Priority;\r
337 Lock->OwnerTpl = TPL_APPLICATION;\r
338 Lock->Lock = EfiLockReleased ;\r
339 return Lock;\r
340}\r
341\r
342/**\r
1d37ab9f 343 Acquires ownership of a lock.\r
344\r
345 This function raises the system's current task priority level to the task \r
346 priority level of the mutual exclusion lock. Then, it places the lock in the \r
e386b444 347 acquired state.\r
9edc73ad 348 If Lock is NULL, then ASSERT().\r
349 If Lock is not initialized, then ASSERT().\r
350 If Lock is already in the acquired state, then ASSERT().\r
e386b444 351\r
1d37ab9f 352 @param Lock A pointer to the lock to acquire.\r
e386b444 353\r
354**/\r
355VOID\r
356EFIAPI\r
357EfiAcquireLock (\r
358 IN EFI_LOCK *Lock\r
359 )\r
360{\r
361 ASSERT (Lock != NULL);\r
362 ASSERT (Lock->Lock == EfiLockReleased);\r
363\r
364 Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);\r
365 Lock->Lock = EfiLockAcquired;\r
366}\r
367\r
368/**\r
cf8ae2f6 369 Acquires ownership of a lock.\r
1d37ab9f 370\r
cf8ae2f6 371 This function raises the system's current task priority level to the task priority\r
372 level of the mutual exclusion lock. Then, it attempts to place the lock in the acquired state.\r
373 If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.\r
374 Otherwise, EFI_SUCCESS is returned.\r
1d37ab9f 375 If Lock is NULL, then ASSERT().\r
376 If Lock is not initialized, then ASSERT().\r
e386b444 377\r
378 @param Lock A pointer to the lock to acquire.\r
379\r
380 @retval EFI_SUCCESS The lock was acquired.\r
381 @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.\r
382\r
383**/\r
384EFI_STATUS\r
385EFIAPI\r
386EfiAcquireLockOrFail (\r
387 IN EFI_LOCK *Lock\r
388 )\r
389{\r
390\r
391 ASSERT (Lock != NULL);\r
392 ASSERT (Lock->Lock != EfiLockUninitialized);\r
393\r
394 if (Lock->Lock == EfiLockAcquired) {\r
395 //\r
396 // Lock is already owned, so bail out\r
397 //\r
398 return EFI_ACCESS_DENIED;\r
399 }\r
400\r
401 Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);\r
402\r
403 Lock->Lock = EfiLockAcquired;\r
404\r
405 return EFI_SUCCESS;\r
406}\r
407\r
408/**\r
1d37ab9f 409 Releases ownership of a lock.\r
410\r
411 This function transitions a mutual exclusion lock from the acquired state to \r
412 the released state, and restores the system's task priority level to its \r
e386b444 413 previous level.\r
1d37ab9f 414 If Lock is NULL, then ASSERT().\r
415 If Lock is not initialized, then ASSERT().\r
416 If Lock is already in the released state, then ASSERT().\r
e386b444 417\r
418 @param Lock A pointer to the lock to release.\r
419\r
420**/\r
421VOID\r
422EFIAPI\r
423EfiReleaseLock (\r
424 IN EFI_LOCK *Lock\r
425 )\r
426{\r
427 EFI_TPL Tpl;\r
428\r
429 ASSERT (Lock != NULL);\r
430 ASSERT (Lock->Lock == EfiLockAcquired);\r
431\r
432 Tpl = Lock->OwnerTpl;\r
433\r
434 Lock->Lock = EfiLockReleased;\r
435\r
436 gBS->RestoreTPL (Tpl);\r
437}\r
438\r
439/**\r
440 Tests whether a controller handle is being managed by a specific driver.\r
441\r
442 This function tests whether the driver specified by DriverBindingHandle is\r
443 currently managing the controller specified by ControllerHandle. This test\r
444 is performed by evaluating if the the protocol specified by ProtocolGuid is\r
445 present on ControllerHandle and is was opened by DriverBindingHandle with an\r
cf8ae2f6 446 attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r
e386b444 447 If ProtocolGuid is NULL, then ASSERT().\r
448\r
449 @param ControllerHandle A handle for a controller to test.\r
450 @param DriverBindingHandle Specifies the driver binding handle for the\r
451 driver.\r
452 @param ProtocolGuid Specifies the protocol that the driver specified\r
453 by DriverBindingHandle opens in its Start()\r
454 function.\r
455\r
456 @retval EFI_SUCCESS ControllerHandle is managed by the driver\r
457 specifed by DriverBindingHandle.\r
458 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver\r
459 specifed by DriverBindingHandle.\r
460\r
461**/\r
462EFI_STATUS\r
463EFIAPI\r
464EfiTestManagedDevice (\r
465 IN CONST EFI_HANDLE ControllerHandle,\r
466 IN CONST EFI_HANDLE DriverBindingHandle,\r
467 IN CONST EFI_GUID *ProtocolGuid\r
468 )\r
469{\r
470 EFI_STATUS Status;\r
471 VOID *ManagedInterface;\r
472\r
473 ASSERT (ProtocolGuid != NULL);\r
474\r
475 Status = gBS->OpenProtocol (\r
476 ControllerHandle,\r
477 (EFI_GUID *) ProtocolGuid,\r
478 &ManagedInterface,\r
479 DriverBindingHandle,\r
480 ControllerHandle,\r
481 EFI_OPEN_PROTOCOL_BY_DRIVER\r
482 );\r
483 if (!EFI_ERROR (Status)) {\r
484 gBS->CloseProtocol (\r
485 ControllerHandle,\r
486 (EFI_GUID *) ProtocolGuid,\r
487 DriverBindingHandle,\r
488 ControllerHandle\r
489 );\r
490 return EFI_UNSUPPORTED;\r
491 }\r
492\r
493 if (Status != EFI_ALREADY_STARTED) {\r
494 return EFI_UNSUPPORTED;\r
495 }\r
496\r
497 return EFI_SUCCESS;\r
498}\r
499\r
500/**\r
501 Tests whether a child handle is a child device of the controller.\r
502\r
503 This function tests whether ChildHandle is one of the children of\r
504 ControllerHandle. This test is performed by checking to see if the protocol\r
505 specified by ProtocolGuid is present on ControllerHandle and opened by\r
506 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
507 If ProtocolGuid is NULL, then ASSERT().\r
508\r
cf8ae2f6 509 @param ControllerHandle A handle for a (parent) controller to test. \r
e386b444 510 @param ChildHandle A child handle to test.\r
42eedea9 511 @param ProtocolGuid Supplies the protocol that the child controller\r
cf8ae2f6 512 opens on its parent controller. \r
e386b444 513\r
514 @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle.\r
515 @retval EFI_UNSUPPORTED ChildHandle is not a child of the\r
516 ControllerHandle.\r
517\r
518**/\r
519EFI_STATUS\r
520EFIAPI\r
521EfiTestChildHandle (\r
522 IN CONST EFI_HANDLE ControllerHandle,\r
523 IN CONST EFI_HANDLE ChildHandle,\r
524 IN CONST EFI_GUID *ProtocolGuid\r
525 )\r
526{\r
527 EFI_STATUS Status;\r
528 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
529 UINTN EntryCount;\r
530 UINTN Index;\r
531\r
532 ASSERT (ProtocolGuid != NULL);\r
533\r
534 //\r
535 // Retrieve the list of agents that are consuming the specific protocol\r
536 // on ControllerHandle.\r
537 //\r
538 Status = gBS->OpenProtocolInformation (\r
539 ControllerHandle,\r
540 (EFI_GUID *) ProtocolGuid,\r
541 &OpenInfoBuffer,\r
542 &EntryCount\r
543 );\r
544 if (EFI_ERROR (Status)) {\r
545 return EFI_UNSUPPORTED;\r
546 }\r
547\r
548 //\r
549 // Inspect if ChildHandle is one of the agents.\r
550 //\r
551 Status = EFI_UNSUPPORTED;\r
552 for (Index = 0; Index < EntryCount; Index++) {\r
553 if ((OpenInfoBuffer[Index].ControllerHandle == ChildHandle) &&\r
554 (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
555 Status = EFI_SUCCESS;\r
556 break;\r
557 }\r
558 }\r
559\r
560 FreePool (OpenInfoBuffer);\r
561 return Status;\r
562}\r
563\r
564/**\r
dd51a993 565 This function looks up a Unicode string in UnicodeStringTable.\r
dd51a993 566\r
cf8ae2f6 567 If Language is a member of SupportedLanguages and a Unicode string is found in\r
1d37ab9f 568 UnicodeStringTable that matches the language code specified by Language, then it\r
569 is returned in UnicodeString.\r
570\r
571 @param Language A pointer to the ISO 639-2 language code for the \r
572 Unicode string to look up and return.\r
573 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes \r
574 that the Unicode string table supports. Language \r
575 must be a member of this set.\r
576 @param UnicodeStringTable A pointer to the table of Unicode strings.\r
577 @param UnicodeString A pointer to the Unicode string from UnicodeStringTable\r
578 that matches the language specified by Language.\r
579\r
580 @retval EFI_SUCCESS The Unicode string that matches the language \r
581 specified by Language was found\r
582 in the table of Unicoide strings UnicodeStringTable, \r
583 and it was returned in UnicodeString.\r
584 @retval EFI_INVALID_PARAMETER Language is NULL.\r
585 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
586 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
587 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.\r
588 @retval EFI_UNSUPPORTED The language specified by Language is not a \r
589 member of SupportedLanguages.\r
590 @retval EFI_UNSUPPORTED The language specified by Language is not \r
591 supported by UnicodeStringTable.\r
e386b444 592\r
593**/\r
594EFI_STATUS\r
595EFIAPI\r
596LookupUnicodeString (\r
597 IN CONST CHAR8 *Language,\r
598 IN CONST CHAR8 *SupportedLanguages,\r
599 IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,\r
600 OUT CHAR16 **UnicodeString\r
601 )\r
602{\r
603 //\r
604 // Make sure the parameters are valid\r
605 //\r
606 if (Language == NULL || UnicodeString == NULL) {\r
607 return EFI_INVALID_PARAMETER;\r
608 }\r
609\r
610 //\r
611 // If there are no supported languages, or the Unicode String Table is empty, then the\r
612 // Unicode String specified by Language is not supported by this Unicode String Table\r
613 //\r
614 if (SupportedLanguages == NULL || UnicodeStringTable == NULL) {\r
615 return EFI_UNSUPPORTED;\r
616 }\r
617\r
618 //\r
619 // Make sure Language is in the set of Supported Languages\r
620 //\r
621 while (*SupportedLanguages != 0) {\r
622 if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
623\r
624 //\r
625 // Search the Unicode String Table for the matching Language specifier\r
626 //\r
627 while (UnicodeStringTable->Language != NULL) {\r
628 if (CompareIso639LanguageCode (Language, UnicodeStringTable->Language)) {\r
629\r
630 //\r
631 // A matching string was found, so return it\r
632 //\r
633 *UnicodeString = UnicodeStringTable->UnicodeString;\r
634 return EFI_SUCCESS;\r
635 }\r
636\r
637 UnicodeStringTable++;\r
638 }\r
639\r
640 return EFI_UNSUPPORTED;\r
641 }\r
642\r
643 SupportedLanguages += 3;\r
644 }\r
645\r
646 return EFI_UNSUPPORTED;\r
647}\r
648\r
dd51a993 649\r
650\r
e386b444 651/**\r
dd51a993 652 This function looks up a Unicode string in UnicodeStringTable.\r
cf8ae2f6 653\r
654 If Language is a member of SupportedLanguages and a Unicode string is found in\r
655 UnicodeStringTable that matches the language code specified by Language, then\r
656 it is returned in UnicodeString.\r
657\r
658 @param Language A pointer to an ASCII string containing the ISO 639-2 or the\r
659 RFC 4646 language code for the Unicode string to look up and\r
660 return. If Iso639Language is TRUE, then this ASCII string is\r
661 not assumed to be Null-terminated, and only the first three\r
662 chacters are used. If Iso639Language is FALSE, then this ASCII\r
663 string must be Null-terminated. \r
664 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains a\r
665 set of ISO 639-2 or RFC 4646 language codes that the Unicode\r
666 string table supports. Language must be a member of this set.\r
667 If Iso639Language is TRUE, then this string contains one or more\r
668 ISO 639-2 language codes with no separator characters. If Iso639Language\r
669 is FALSE, then is string contains one or more RFC 4646 language\r
670 codes separated by ';'.\r
671 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE\r
672 is defined in "Related Definitions".\r
673 @param UnicodeString A pointer to the Null-terminated Unicode string from UnicodeStringTable\r
674 that matches the language specified by Language.\r
675 @param Iso639Language Specifies the supported language code format. If it is TRUE, then\r
676 Language and SupportedLanguages follow ISO 639-2 language code format.\r
677 Otherwise, they follow RFC 4646 language code format.\r
678\r
679\r
680 @retval EFI_SUCCESS The Unicode string that matches the language specified by Language\r
681 was found in the table of Unicode strings UnicodeStringTable, and\r
682 it was returned in UnicodeString.\r
1d37ab9f 683 @retval EFI_INVALID_PARAMETER Language is NULL. \r
684 @retval EFI_INVALID_PARAMETER UnicodeString is NULL. \r
685 @retval EFI_UNSUPPORTED SupportedLanguages is NULL. \r
cf8ae2f6 686 @retval EFI_UNSUPPORTED UnicodeStringTable is NULL. \r
687 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages. \r
688 @retval EFI_UNSUPPORTED The language specified by Language is not supported by UnicodeStringTable.\r
dd51a993 689\r
690**/\r
691EFI_STATUS\r
692EFIAPI\r
693LookupUnicodeString2 (\r
694 IN CONST CHAR8 *Language,\r
695 IN CONST CHAR8 *SupportedLanguages,\r
696 IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,\r
697 OUT CHAR16 **UnicodeString,\r
698 IN BOOLEAN Iso639Language\r
699 )\r
700{\r
701 BOOLEAN Found;\r
702 UINTN Index;\r
703 CHAR8 *LanguageString;\r
704\r
705 //\r
706 // Make sure the parameters are valid\r
707 //\r
708 if (Language == NULL || UnicodeString == NULL) {\r
709 return EFI_INVALID_PARAMETER;\r
710 }\r
711\r
712 //\r
713 // If there are no supported languages, or the Unicode String Table is empty, then the\r
714 // Unicode String specified by Language is not supported by this Unicode String Table\r
715 //\r
716 if (SupportedLanguages == NULL || UnicodeStringTable == NULL) {\r
717 return EFI_UNSUPPORTED;\r
718 }\r
719\r
720 //\r
721 // Make sure Language is in the set of Supported Languages\r
722 //\r
723 Found = FALSE;\r
724 while (*SupportedLanguages != 0) {\r
725 if (Iso639Language) {\r
726 if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
727 Found = TRUE;\r
728 break;\r
729 }\r
730 SupportedLanguages += 3;\r
731 } else {\r
732 for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
634aa59d 733 if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {\r
dd51a993 734 Found = TRUE;\r
735 break;\r
736 }\r
737 SupportedLanguages += Index;\r
738 for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
739 }\r
740 }\r
741\r
742 //\r
743 // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED\r
744 //\r
745 if (!Found) {\r
746 return EFI_UNSUPPORTED;\r
747 }\r
748\r
749 //\r
750 // Search the Unicode String Table for the matching Language specifier\r
751 //\r
752 while (UnicodeStringTable->Language != NULL) {\r
753 LanguageString = UnicodeStringTable->Language;\r
754 while (0 != *LanguageString) {\r
755 for (Index = 0 ;LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++);\r
756 if (AsciiStrnCmp(LanguageString, Language, Index) == 0) {\r
757 *UnicodeString = UnicodeStringTable->UnicodeString;\r
758 return EFI_SUCCESS;\r
759 }\r
760 LanguageString += Index;\r
761 for (Index = 0 ;LanguageString[Index] != 0 && LanguageString[Index] == ';'; Index++);\r
762 }\r
763 UnicodeStringTable++;\r
764 }\r
765\r
766 return EFI_UNSUPPORTED;\r
767}\r
768\r
769\r
770/**\r
e386b444 771 This function adds a Unicode string to UnicodeStringTable.\r
1d37ab9f 772\r
773 If Language is a member of SupportedLanguages then UnicodeString is added to \r
774 UnicodeStringTable. New buffers are allocated for both Language and \r
775 UnicodeString. The contents of Language and UnicodeString are copied into \r
776 these new buffers. These buffers are automatically freed when \r
e386b444 777 FreeUnicodeStringTable() is called.\r
778\r
1d37ab9f 779 @param Language A pointer to the ISO 639-2 language code for the Unicode \r
e386b444 780 string to add.\r
1d37ab9f 781 @param SupportedLanguages A pointer to the set of ISO 639-2 language codes\r
782 that the Unicode string table supports.\r
783 Language must be a member of this set.\r
784 @param UnicodeStringTable A pointer to the table of Unicode strings.\r
785 @param UnicodeString A pointer to the Unicode string to add.\r
786\r
787 @retval EFI_SUCCESS The Unicode string that matches the language \r
788 specified by Language was found in the table of \r
789 Unicode strings UnicodeStringTable, and it was \r
e386b444 790 returned in UnicodeString.\r
791 @retval EFI_INVALID_PARAMETER Language is NULL.\r
792 @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
793 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.\r
794 @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
1d37ab9f 795 @retval EFI_ALREADY_STARTED A Unicode string with language Language is \r
796 already present in UnicodeStringTable.\r
797 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another \r
798 Unicode string to UnicodeStringTable.\r
799 @retval EFI_UNSUPPORTED The language specified by Language is not a \r
800 member of SupportedLanguages.\r
e386b444 801\r
802**/\r
803EFI_STATUS\r
804EFIAPI\r
805AddUnicodeString (\r
806 IN CONST CHAR8 *Language,\r
807 IN CONST CHAR8 *SupportedLanguages,\r
808 IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable,\r
809 IN CONST CHAR16 *UnicodeString\r
810 )\r
811{\r
812 UINTN NumberOfEntries;\r
813 EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable;\r
814 EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable;\r
815 UINTN UnicodeStringLength;\r
816\r
817 //\r
818 // Make sure the parameter are valid\r
819 //\r
820 if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {\r
821 return EFI_INVALID_PARAMETER;\r
822 }\r
823\r
824 //\r
825 // If there are no supported languages, then a Unicode String can not be added\r
826 //\r
827 if (SupportedLanguages == NULL) {\r
828 return EFI_UNSUPPORTED;\r
829 }\r
830\r
831 //\r
832 // If the Unicode String is empty, then a Unicode String can not be added\r
833 //\r
834 if (UnicodeString[0] == 0) {\r
835 return EFI_INVALID_PARAMETER;\r
836 }\r
837\r
838 //\r
839 // Make sure Language is a member of SupportedLanguages\r
840 //\r
841 while (*SupportedLanguages != 0) {\r
842 if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
843\r
844 //\r
845 // Determine the size of the Unicode String Table by looking for a NULL Language entry\r
846 //\r
847 NumberOfEntries = 0;\r
848 if (*UnicodeStringTable != NULL) {\r
849 OldUnicodeStringTable = *UnicodeStringTable;\r
850 while (OldUnicodeStringTable->Language != NULL) {\r
851 if (CompareIso639LanguageCode (Language, OldUnicodeStringTable->Language)) {\r
852 return EFI_ALREADY_STARTED;\r
853 }\r
854\r
855 OldUnicodeStringTable++;\r
856 NumberOfEntries++;\r
857 }\r
858 }\r
859\r
860 //\r
861 // Allocate space for a new Unicode String Table. It must hold the current number of\r
862 // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table\r
863 // marker\r
864 //\r
865 NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE));\r
866 if (NewUnicodeStringTable == NULL) {\r
867 return EFI_OUT_OF_RESOURCES;\r
868 }\r
869\r
870 //\r
871 // If the current Unicode String Table contains any entries, then copy them to the\r
872 // newly allocated Unicode String Table.\r
873 //\r
874 if (*UnicodeStringTable != NULL) {\r
875 CopyMem (\r
876 NewUnicodeStringTable,\r
877 *UnicodeStringTable,\r
878 NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE)\r
879 );\r
880 }\r
881\r
882 //\r
883 // Allocate space for a copy of the Language specifier\r
884 //\r
885 NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (3, Language);\r
886 if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {\r
887 gBS->FreePool (NewUnicodeStringTable);\r
888 return EFI_OUT_OF_RESOURCES;\r
889 }\r
890\r
891 //\r
892 // Compute the length of the Unicode String\r
893 //\r
894 for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++)\r
895 ;\r
896\r
897 //\r
898 // Allocate space for a copy of the Unicode String\r
899 //\r
900 NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool (\r
901 (UnicodeStringLength + 1) * sizeof (CHAR16),\r
902 UnicodeString\r
903 );\r
904 if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) {\r
905 gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language);\r
906 gBS->FreePool (NewUnicodeStringTable);\r
907 return EFI_OUT_OF_RESOURCES;\r
908 }\r
909\r
910 //\r
911 // Mark the end of the Unicode String Table\r
912 //\r
913 NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL;\r
914 NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL;\r
915\r
916 //\r
917 // Free the old Unicode String Table\r
918 //\r
919 if (*UnicodeStringTable != NULL) {\r
920 gBS->FreePool (*UnicodeStringTable);\r
921 }\r
922\r
923 //\r
924 // Point UnicodeStringTable at the newly allocated Unicode String Table\r
925 //\r
926 *UnicodeStringTable = NewUnicodeStringTable;\r
927\r
928 return EFI_SUCCESS;\r
929 }\r
930\r
931 SupportedLanguages += 3;\r
932 }\r
933\r
934 return EFI_UNSUPPORTED;\r
935}\r
936\r
dd51a993 937\r
938/**\r
cf8ae2f6 939 This function adds the Null-terminated Unicode string specified by UnicodeString\r
940 to UnicodeStringTable.\r
941\r
942 If Language is a member of SupportedLanguages then UnicodeString is added to\r
943 UnicodeStringTable. New buffers are allocated for both Language and UnicodeString.\r
944 The contents of Language and UnicodeString are copied into these new buffers.\r
945 These buffers are automatically freed when EfiLibFreeUnicodeStringTable() is called.\r
946\r
947 @param Language A pointer to an ASCII string containing the ISO 639-2 or\r
948 the RFC 4646 language code for the Unicode string to add.\r
949 If Iso639Language is TRUE, then this ASCII string is not\r
950 assumed to be Null-terminated, and only the first three\r
951 chacters are used. If Iso639Language is FALSE, then this\r
952 ASCII string must be Null-terminated.\r
953 @param SupportedLanguages A pointer to a Null-terminated ASCII string that contains\r
954 a set of ISO 639-2 or RFC 4646 language codes that the Unicode\r
955 string table supports. Language must be a member of this set.\r
956 If Iso639Language is TRUE, then this string contains one or more\r
957 ISO 639-2 language codes with no separator characters.\r
958 If Iso639Language is FALSE, then is string contains one or more\r
959 RFC 4646 language codes separated by ';'.\r
960 @param UnicodeStringTable A pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE\r
961 is defined in "Related Definitions".\r
962 @param UnicodeString A pointer to the Unicode string to add. \r
963 @param Iso639Language Specifies the supported language code format. If it is TRUE,\r
964 then Language and SupportedLanguages follow ISO 639-2 language code format.\r
965 Otherwise, they follow RFC 4646 language code format.\r
966\r
967 @retval EFI_SUCCESS The Unicode string that matches the language specified by\r
968 Language was found in the table of Unicode strings UnicodeStringTable,\r
969 and it was returned in UnicodeString. \r
970 @retval EFI_INVALID_PARAMETER Language is NULL. \r
971 @retval EFI_INVALID_PARAMETER UnicodeString is NULL. \r
972 @retval EFI_INVALID_PARAMETER UnicodeString is an empty string. \r
973 @retval EFI_UNSUPPORTED SupportedLanguages is NULL. \r
974 @retval EFI_ALREADY_STARTED A Unicode string with language Language is already present in\r
975 UnicodeStringTable. \r
976 @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another Unicode string UnicodeStringTable. \r
977 @retval EFI_UNSUPPORTED The language specified by Language is not a member of SupportedLanguages.\r
dd51a993 978\r
979**/\r
980EFI_STATUS\r
981EFIAPI\r
982AddUnicodeString2 (\r
983 IN CONST CHAR8 *Language,\r
984 IN CONST CHAR8 *SupportedLanguages,\r
985 IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable,\r
986 IN CONST CHAR16 *UnicodeString,\r
987 IN BOOLEAN Iso639Language\r
988 )\r
989{\r
990 UINTN NumberOfEntries;\r
991 EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable;\r
992 EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable;\r
993 UINTN UnicodeStringLength;\r
994 BOOLEAN Found;\r
995 UINTN Index;\r
996 CHAR8 *LanguageString;\r
997\r
998 //\r
999 // Make sure the parameter are valid\r
1000 //\r
1001 if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {\r
1002 return EFI_INVALID_PARAMETER;\r
1003 }\r
1004\r
1005 //\r
1006 // If there are no supported languages, then a Unicode String can not be added\r
1007 //\r
1008 if (SupportedLanguages == NULL) {\r
1009 return EFI_UNSUPPORTED;\r
1010 }\r
1011\r
1012 //\r
1013 // If the Unicode String is empty, then a Unicode String can not be added\r
1014 //\r
1015 if (UnicodeString[0] == 0) {\r
1016 return EFI_INVALID_PARAMETER;\r
1017 }\r
1018\r
1019 //\r
1020 // Make sure Language is a member of SupportedLanguages\r
1021 //\r
1022 Found = FALSE;\r
1023 while (*SupportedLanguages != 0) {\r
1024 if (Iso639Language) {\r
1025 if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
1026 Found = TRUE;\r
1027 break;\r
1028 }\r
1029 SupportedLanguages += 3;\r
1030 } else {\r
1031 for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
1032 if (AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) {\r
1033 Found = TRUE;\r
1034 break;\r
1035 }\r
1036 SupportedLanguages += Index;\r
1037 for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
1038 }\r
1039 }\r
1040\r
1041 //\r
1042 // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED\r
1043 //\r
1044 if (!Found) {\r
1045 return EFI_UNSUPPORTED;\r
1046 }\r
1047\r
1048 //\r
1049 // Determine the size of the Unicode String Table by looking for a NULL Language entry\r
1050 //\r
1051 NumberOfEntries = 0;\r
1052 if (*UnicodeStringTable != NULL) {\r
1053 OldUnicodeStringTable = *UnicodeStringTable;\r
1054 while (OldUnicodeStringTable->Language != NULL) {\r
1055 LanguageString = OldUnicodeStringTable->Language;\r
1056\r
42eedea9 1057 while (*LanguageString != 0) {\r
dd51a993 1058 for (Index = 0; LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++);\r
1059\r
1060 if (AsciiStrnCmp (Language, LanguageString, Index) == 0) { \r
1061 return EFI_ALREADY_STARTED;\r
1062 }\r
1063 LanguageString += Index;\r
1064 for (; *LanguageString != 0 && *LanguageString == ';'; LanguageString++);\r
1065 }\r
1066 OldUnicodeStringTable++;\r
1067 NumberOfEntries++;\r
1068 }\r
1069 }\r
1070\r
1071 //\r
1072 // Allocate space for a new Unicode String Table. It must hold the current number of\r
1073 // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table\r
1074 // marker\r
1075 //\r
1076 NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE));\r
1077 if (NewUnicodeStringTable == NULL) {\r
1078 return EFI_OUT_OF_RESOURCES;\r
1079 }\r
1080\r
1081 //\r
1082 // If the current Unicode String Table contains any entries, then copy them to the\r
1083 // newly allocated Unicode String Table.\r
1084 //\r
1085 if (*UnicodeStringTable != NULL) {\r
1086 CopyMem (\r
1087 NewUnicodeStringTable,\r
1088 *UnicodeStringTable,\r
1089 NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE)\r
1090 );\r
1091 }\r
1092\r
1093 //\r
1094 // Allocate space for a copy of the Language specifier\r
1095 //\r
1096 NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize(Language), Language);\r
1097 if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {\r
1098 gBS->FreePool (NewUnicodeStringTable);\r
1099 return EFI_OUT_OF_RESOURCES;\r
1100 }\r
1101\r
1102 //\r
1103 // Compute the length of the Unicode String\r
1104 //\r
1105 for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++);\r
1106\r
1107 //\r
1108 // Allocate space for a copy of the Unicode String\r
1109 //\r
1110 NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool (StrSize (UnicodeString), UnicodeString);\r
1111 if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) {\r
1112 gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language);\r
1113 gBS->FreePool (NewUnicodeStringTable);\r
1114 return EFI_OUT_OF_RESOURCES;\r
1115 }\r
1116\r
1117 //\r
1118 // Mark the end of the Unicode String Table\r
1119 //\r
1120 NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL;\r
1121 NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL;\r
1122\r
1123 //\r
1124 // Free the old Unicode String Table\r
1125 //\r
1126 if (*UnicodeStringTable != NULL) {\r
1127 gBS->FreePool (*UnicodeStringTable);\r
1128 }\r
1129\r
1130 //\r
1131 // Point UnicodeStringTable at the newly allocated Unicode String Table\r
1132 //\r
1133 *UnicodeStringTable = NewUnicodeStringTable;\r
1134\r
1135 return EFI_SUCCESS;\r
1136}\r
1137\r
e386b444 1138/**\r
1139 This function frees the table of Unicode strings in UnicodeStringTable.\r
1d37ab9f 1140\r
e386b444 1141 If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.\r
dd51a993 1142 Otherwise, each language code, and each Unicode string in the Unicode string \r
e386b444 1143 table are freed, and EFI_SUCCESS is returned.\r
1144\r
1145 @param UnicodeStringTable A pointer to the table of Unicode strings.\r
1146\r
1147 @retval EFI_SUCCESS The Unicode string table was freed.\r
1148\r
1149**/\r
1150EFI_STATUS\r
1151EFIAPI\r
1152FreeUnicodeStringTable (\r
1153 IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable\r
1154 )\r
1155{\r
1156 UINTN Index;\r
1157\r
1158 //\r
1159 // If the Unicode String Table is NULL, then it is already freed\r
1160 //\r
1161 if (UnicodeStringTable == NULL) {\r
1162 return EFI_SUCCESS;\r
1163 }\r
1164\r
1165 //\r
1166 // Loop through the Unicode String Table until we reach the end of table marker\r
1167 //\r
1168 for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) {\r
1169\r
1170 //\r
1171 // Free the Language string from the Unicode String Table\r
1172 //\r
1173 gBS->FreePool (UnicodeStringTable[Index].Language);\r
1174\r
1175 //\r
1176 // Free the Unicode String from the Unicode String Table\r
1177 //\r
1178 if (UnicodeStringTable[Index].UnicodeString != NULL) {\r
1179 gBS->FreePool (UnicodeStringTable[Index].UnicodeString);\r
1180 }\r
1181 }\r
1182\r
1183 //\r
1184 // Free the Unicode String Table itself\r
1185 //\r
1186 gBS->FreePool (UnicodeStringTable);\r
1187\r
1188 return EFI_SUCCESS;\r
1189}\r