]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c
SecurityPkg: Add TPM PTP support in TPM2 device lib.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / Uc2OnUcThunk / Uc2OnUcThunk.c
index b8cfd5dc66017f13f10176de31b04b82149ded8e..021f3e68f50b636c50df36bc951157b896690c54 100644 (file)
@@ -9,8 +9,8 @@ these two conditions are true:
 1) EFI 1.10 module producing UC present\r
 2) And the rest of modules on the platform consume UC2\r
 \r
-Copyright (c) 2006 - 2008 Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -30,20 +30,15 @@ Module Name:
 #include <Library/UefiLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/HiiLib.h>\r
-\r
-\r
-///\r
-/// The size of a 3 character ISO639 language code.\r
-///\r
-#define ISO_639_2_ENTRY_SIZE            3\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/LanguageLib.h>\r
 \r
 /**\r
-  Performs a case-insensitive comparison of two Null-terminated Unicode \r
-  strings.\r
+  Performs a case-insensitive comparison of two Null-terminated strings.\r
 \r
   @param  This Protocol instance pointer.\r
-  @param  Str1 A pointer to a Null-terminated Unicode string.\r
-  @param  Str2 A pointer to a Null-terminated Unicode string.\r
+  @param  Str1 A pointer to a Null-terminated string.\r
+  @param  Str2 A pointer to a Null-terminated string.\r
 \r
   @retval 0   Str1 is equivalent to Str2\r
   @retval > 0 Str1 is lexically greater than Str2\r
@@ -59,11 +54,11 @@ StriColl (
   );\r
 \r
 /**\r
-  Converts all the Unicode characters in a Null-terminated Unicode string to \r
-  lower case Unicode characters.\r
+  Converts all the characters in a Null-terminated string to \r
+  lower case characters.\r
 \r
   @param  This   Protocol instance pointer.\r
-  @param  Str    A pointer to a Null-terminated Unicode string.\r
+  @param  Str    A pointer to a Null-terminated string.\r
 \r
 **/\r
 VOID\r
@@ -74,11 +69,11 @@ StrLwr (
   );\r
 \r
 /**\r
-  Converts all the Unicode characters in a Null-terminated Unicode string to upper\r
-  case Unicode characters.\r
+  Converts all the characters in a Null-terminated string to upper\r
+  case characters.\r
 \r
   @param  This   Protocol instance pointer.\r
-  @param  Str    A pointer to a Null-terminated Unicode string.\r
+  @param  Str    A pointer to a Null-terminated string.\r
 \r
 **/\r
 VOID\r
@@ -89,12 +84,12 @@ StrUpr (
   );\r
 \r
 /**\r
-  Performs a case-insensitive comparison of a Null-terminated Unicode \r
-  pattern string and a Null-terminated Unicode string.\r
+  Performs a case-insensitive comparison of a Null-terminated\r
+  pattern string and a Null-terminated string.\r
 \r
   @param  This    Protocol instance pointer.\r
-  @param  String  A pointer to a Null-terminated Unicode string.\r
-  @param  Pattern A pointer to a Null-terminated Unicode pattern string.\r
+  @param  String  A pointer to a Null-terminated string.\r
+  @param  Pattern A pointer to a Null-terminated pattern string.\r
 \r
   @retval TRUE    Pattern was found in String.\r
   @retval FALSE   Pattern was not found in String.\r
@@ -109,15 +104,14 @@ MetaiMatch (
   );\r
 \r
 /**\r
-  Converts an 8.3 FAT file name in an OEM character set to a Null-terminated \r
-  Unicode string.\r
+  Converts an 8.3 FAT file name in an OEM character set to a Null-terminated string.\r
 \r
   @param  This    Protocol instance pointer.\r
   @param  FatSize The size of the string Fat in bytes.\r
   @param  Fat     A pointer to a Null-terminated string that contains an 8.3 file\r
                   name using an OEM character set.\r
-  @param  String  A pointer to a Null-terminated Unicode string. The string must\r
-                  be preallocated to hold FatSize Unicode characters.\r
+  @param  String  A pointer to a Null-terminated string. The string must\r
+                  be preallocated to hold FatSize characters.\r
 \r
 **/\r
 VOID\r
@@ -130,12 +124,12 @@ FatToStr (
   );\r
 \r
 /**\r
-  Converts a Null-terminated Unicode string to legal characters in a FAT \r
+  Converts a Null-terminated string to legal characters in a FAT \r
   filename using an OEM character set. \r
 \r
   @param  This    Protocol instance pointer.\r
-  @param  String  A pointer to a Null-terminated Unicode string. The string must\r
-                  be preallocated to hold FatSize Unicode characters.\r
+  @param  String  A pointer to a Null-terminated string. The string must\r
+                  be preallocated to hold FatSize characters.\r
   @param  FatSize The size of the string Fat in bytes.\r
   @param  Fat     A pointer to a Null-terminated string that contains an 8.3 file\r
                   name using an OEM character set.\r
@@ -157,11 +151,11 @@ StrToFat (
 \r
 typedef struct {\r
   UINT32                          Signature;\r
-  EFI_UNICODE_COLLATION_PROTOCOL  UC2;\r
-  EFI_UNICODE_COLLATION_PROTOCOL *UC;\r
+  EFI_UNICODE_COLLATION_PROTOCOL  Uc2;\r
+  EFI_UNICODE_COLLATION_PROTOCOL *Uc;\r
 } UC2_PRIVATE_DATA;\r
 \r
-#define UC2_PRIVATE_DATA_FROM_THIS(a) CR (a, UC2_PRIVATE_DATA, UC2, UC2_PRIVATE_DATA_SIGNATURE)\r
+#define UC2_PRIVATE_DATA_FROM_THIS(a) CR (a, UC2_PRIVATE_DATA, Uc2, UC2_PRIVATE_DATA_SIGNATURE)\r
 \r
 //\r
 // Firmware Volume Protocol template\r
@@ -185,7 +179,15 @@ UC2_PRIVATE_DATA gUC2PrivateDataTemplate = {
 //\r
 // Module globals\r
 //\r
+/**\r
+  This notification function is invoked when an instance of the\r
+  EFI_UNICODE_COLLATION_PROTOCOL is produced. It installs another instance of the\r
+  EFI_UNICODE_COLLATION_PROTOCOL2 on the same handle.\r
+\r
+  @param  Event                 The event that occured\r
+  @param  Context               Context of event. Not used in this nofication function.\r
 \r
+**/\r
 VOID\r
 EFIAPI\r
 UcNotificationEvent (\r
@@ -241,25 +243,23 @@ UcNotificationEvent (
     Status = gBS->HandleProtocol (\r
                     Handle,\r
                     &gEfiUnicodeCollationProtocolGuid,\r
-                    (VOID **)&Private->UC\r
+                    (VOID **)&Private->Uc\r
                     );\r
     ASSERT_EFI_ERROR (Status);\r
 \r
     //\r
     // Fill in rest of private data structure\r
     //\r
-    Private->UC2.SupportedLanguages = AllocateZeroPool (RFC_3066_ENTRY_SIZE);\r
-    Status = ConvertIso639LanguageToRfc3066Language (Private->UC->SupportedLanguages, Private->UC2.SupportedLanguages);\r
-\r
-    if (!EFI_ERROR (Status)) {\r
+    Private->Uc2.SupportedLanguages = ConvertLanguagesIso639ToRfc4646 (Private->Uc->SupportedLanguages);\r
+    if (Private->Uc2.SupportedLanguages != NULL) {\r
 \r
       //\r
-      // Install Firmware Volume Protocol onto same handle\r
+      // Install UC2 Protocol onto same handle\r
       //\r
       Status = gBS->InstallMultipleProtocolInterfaces (\r
                       &Handle,\r
                       &gEfiUnicodeCollation2ProtocolGuid,\r
-                      &Private->UC2,\r
+                      &Private->Uc2,\r
                       NULL\r
                       );\r
       ASSERT_EFI_ERROR (Status);\r
@@ -299,12 +299,11 @@ InitializeUC2 (
 \r
 \r
 /**\r
-  Performs a case-insensitive comparison of two Null-terminated Unicode \r
-  strings.\r
+  Performs a case-insensitive comparison of two Null-terminated strings.\r
 \r
   @param  This Protocol instance pointer.\r
-  @param  Str1 A pointer to a Null-terminated Unicode string.\r
-  @param  Str2 A pointer to a Null-terminated Unicode string.\r
+  @param  Str1 A pointer to a Null-terminated string.\r
+  @param  Str2 A pointer to a Null-terminated string.\r
 \r
   @retval 0   Str1 is equivalent to Str2\r
   @retval > 0 Str1 is lexically greater than Str2\r
@@ -323,16 +322,16 @@ StriColl (
   \r
   Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
   \r
-  return Private->UC->StriColl (Private->UC, Str1, Str2);\r
+  return Private->Uc->StriColl (Private->Uc, Str1, Str2);\r
 }\r
 \r
 \r
 /**\r
-  Converts all the Unicode characters in a Null-terminated Unicode string to \r
-  lower case Unicode characters.\r
+  Converts all the characters in a Null-terminated string to \r
+  lower case characters.\r
 \r
   @param  This   Protocol instance pointer.\r
-  @param  Str    A pointer to a Null-terminated Unicode string.\r
+  @param  Str    A pointer to a Null-terminated string.\r
 \r
 **/\r
 VOID\r
@@ -346,16 +345,16 @@ StrLwr (
   \r
   Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
   \r
-  Private->UC->StrLwr (Private->UC, Str);\r
+  Private->Uc->StrLwr (Private->Uc, Str);\r
 }\r
 \r
 \r
 /**\r
-  Converts all the Unicode characters in a Null-terminated Unicode string to upper\r
-  case Unicode characters.\r
+  Converts all the characters in a Null-terminated string to upper\r
+  case characters.\r
 \r
   @param  This   Protocol instance pointer.\r
-  @param  Str    A pointer to a Null-terminated Unicode string.\r
+  @param  Str    A pointer to a Null-terminated string.\r
 \r
 **/\r
 VOID\r
@@ -369,16 +368,16 @@ StrUpr (
   \r
   Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
   \r
-  Private->UC->StrUpr (Private->UC, Str);\r
+  Private->Uc->StrUpr (Private->Uc, Str);\r
 }\r
 \r
 /**\r
-  Performs a case-insensitive comparison of a Null-terminated Unicode \r
-  pattern string and a Null-terminated Unicode string.\r
+  Performs a case-insensitive comparison of a Null-terminated\r
+  pattern string and a Null-terminated string.\r
 \r
   @param  This    Protocol instance pointer.\r
-  @param  String  A pointer to a Null-terminated Unicode string.\r
-  @param  Pattern A pointer to a Null-terminated Unicode pattern string.\r
+  @param  String  A pointer to a Null-terminated string.\r
+  @param  Pattern A pointer to a Null-terminated pattern string.\r
 \r
   @retval TRUE    Pattern was found in String.\r
   @retval FALSE   Pattern was not found in String.\r
@@ -396,20 +395,19 @@ MetaiMatch (
   \r
   Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
   \r
-  return Private->UC->MetaiMatch (Private->UC, String, Pattern);\r
+  return Private->Uc->MetaiMatch (Private->Uc, String, Pattern);\r
 }\r
 \r
 \r
 /**\r
-  Converts an 8.3 FAT file name in an OEM character set to a Null-terminated \r
-  Unicode string.\r
+  Converts an 8.3 FAT file name in an OEM character set to a Null-terminated string.\r
 \r
   @param  This    Protocol instance pointer.\r
   @param  FatSize The size of the string Fat in bytes.\r
   @param  Fat     A pointer to a Null-terminated string that contains an 8.3 file\r
-                  name using an OEM character set.\r
-  @param  String  A pointer to a Null-terminated Unicode string. The string must\r
-                  be preallocated to hold FatSize Unicode characters.\r
+                  name using an 8-bit OEM character set.\r
+  @param  String  A pointer to a Null-terminated string. The string must\r
+                  be preallocated to hold FatSize characters.\r
 \r
 **/\r
 VOID\r
@@ -425,17 +423,17 @@ FatToStr (
   \r
   Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
   \r
-  Private->UC->FatToStr (Private->UC, FatSize, Fat, String);\r
+  Private->Uc->FatToStr (Private->Uc, FatSize, Fat, String);\r
 }\r
 \r
 \r
 /**\r
-  Converts a Null-terminated Unicode string to legal characters in a FAT \r
+  Converts a Null-terminated string to legal characters in a FAT \r
   filename using an OEM character set. \r
 \r
   @param  This    Protocol instance pointer.\r
-  @param  String  A pointer to a Null-terminated Unicode string. The string must\r
-                  be preallocated to hold FatSize Unicode characters.\r
+  @param  String  A pointer to a Null-terminated string. The string must\r
+                  be preallocated to hold FatSize characters.\r
   @param  FatSize The size of the string Fat in bytes.\r
   @param  Fat     A pointer to a Null-terminated string that contains an 8.3 file\r
                   name using an OEM character set.\r
@@ -457,6 +455,6 @@ StrToFat (
   \r
   Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
   \r
-  return Private->UC->StrToFat (Private->UC, String, FatSize, Fat);\r
+  return Private->Uc->StrToFat (Private->Uc, String, FatSize, Fat);\r
 }\r
 \r