]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add in Uc2ToUcThunk module.
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 19 May 2008 09:37:05 +0000 (09:37 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 19 May 2008 09:37:05 +0000 (09:37 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5222 6f19259b-4bc3-4df7-8a09-765794883524

EdkCompatibilityPkg/Compatibility/Uc2ToUcThunk/Uc2ToUcThunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Compatibility/Uc2ToUcThunk/Uc2ToUcThunk.inf [new file with mode: 0644]

diff --git a/EdkCompatibilityPkg/Compatibility/Uc2ToUcThunk/Uc2ToUcThunk.c b/EdkCompatibilityPkg/Compatibility/Uc2ToUcThunk/Uc2ToUcThunk.c
new file mode 100644 (file)
index 0000000..233f2a0
--- /dev/null
@@ -0,0 +1,464 @@
+/** @file\r
+Module produce UC2 on top of UC.\r
+\r
+UEFI 2.1 specification supersedes Inte's EFI Specification 1.10.\r
+EFI_UNICODE_COLLATION_PROTOCOL defined in Inte's EFI Specification 1.10 is replaced by\r
+EFI_UNICODE_COLLATION_PROTOCOL in UEFI 2.1.\r
+This module produces UC2 on top of UC. This module is used on platform when both of\r
+these two conditions are true:\r
+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
+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
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Module Name:\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Protocol/UnicodeCollation.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/HiiLib.h>\r
+\r
+\r
+\r
+/**\r
+  Performs a case-insensitive comparison of two Null-terminated Unicode \r
+  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
+\r
+  @retval 0   Str1 is equivalent to Str2\r
+  @retval > 0 Str1 is lexically greater than Str2\r
+  @retval < 0 Str1 is lexically less than Str2\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+StriColl (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN CHAR16                           *Str1,\r
+  IN CHAR16                           *Str2\r
+  )\r
+;\r
+\r
+/**\r
+  Converts all the Unicode characters in a Null-terminated Unicode string to \r
+  lower case Unicode characters.\r
+\r
+  @param  This   Protocol instance pointer.\r
+  @param  Str    A pointer to a Null-terminated Unicode string.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+StrLwr (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN OUT CHAR16                       *Str\r
+  )\r
+;\r
+\r
+/**\r
+  Converts all the Unicode characters in a Null-terminated Unicode string to upper\r
+  case Unicode characters.\r
+\r
+  @param  This   Protocol instance pointer.\r
+  @param  Str    A pointer to a Null-terminated Unicode string.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+StrUpr (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN OUT CHAR16                       *Str\r
+  )\r
+;\r
+\r
+/**\r
+  Performs a case-insensitive comparison of a Null-terminated Unicode \r
+  pattern string and a Null-terminated Unicode 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
+\r
+  @retval TRUE    Pattern was found in String.\r
+  @retval FALSE   Pattern was not found in String.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MetaiMatch (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN CHAR16                           *String,\r
+  IN CHAR16                           *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
+\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
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FatToStr (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN UINTN                            FatSize,\r
+  IN CHAR8                            *Fat,\r
+  OUT CHAR16                          *String\r
+  )\r
+;\r
+\r
+/**\r
+  Converts a Null-terminated Unicode 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  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
+\r
+  @retval TRUE    Fat is a Long File Name\r
+  @retval FALSE   Fat is an 8.3 file name\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+StrToFat (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN CHAR16                           *String,\r
+  IN UINTN                            FatSize,\r
+  OUT CHAR8                           *Fat\r
+  )\r
+;\r
+\r
+#define UC2_PRIVATE_DATA_SIGNATURE  EFI_SIGNATURE_32 ('_', 'U', 'C', '2')\r
+\r
+typedef struct {\r
+  UINT32                          Signature;\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, UC, UC2_PRIVATE_DATA_SIGNATURE)\r
+\r
+//\r
+// Firmware Volume Protocol template\r
+//\r
+EFI_EVENT  mUc2Registration;\r
+\r
+UC2_PRIVATE_DATA gUC2PrivateDataTemplate = {\r
+  UC2_PRIVATE_DATA_SIGNATURE,\r
+  {\r
+    StriColl,\r
+    MetaiMatch,\r
+    StrLwr,\r
+    StrUpr,\r
+    FatToStr,\r
+    StrToFat,\r
+    NULL\r
+  },\r
+  NULL\r
+};\r
+\r
+//\r
+// Module globals\r
+//\r
+\r
+VOID\r
+EFIAPI\r
+Uc2NotificationEvent (\r
+  IN  EFI_EVENT       Event,\r
+  IN  VOID            *Context\r
+  )\r
+{\r
+  EFI_STATUS                     Status;\r
+  UINTN                          BufferSize;\r
+  EFI_HANDLE                     Handle;\r
+  UC2_PRIVATE_DATA               *Private;\r
+  EFI_UNICODE_COLLATION_PROTOCOL *Uc2;\r
+\r
+  while (TRUE) {\r
+    BufferSize = sizeof (Handle);\r
+    Status = gBS->LocateHandle (\r
+                    ByRegisterNotify,\r
+                    &gEfiUnicodeCollationProtocolGuid,\r
+                    mUc2Registration,\r
+                    &BufferSize,\r
+                    &Handle\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Exit Path of While Loop....\r
+      //\r
+      break;\r
+    }\r
+\r
+    //\r
+    // Skip this handle if the Firmware Volume Protocol is already installed\r
+    //\r
+    Status = gBS->HandleProtocol (\r
+                    Handle,\r
+                    &gEfiUnicodeCollation2ProtocolGuid,\r
+                    (VOID **)&Uc2\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
+\r
+    //\r
+    // Allocate private data structure\r
+    //\r
+    Private = AllocateCopyPool (sizeof (UC2_PRIVATE_DATA), &gUC2PrivateDataTemplate);\r
+    if (Private == NULL) {\r
+      continue;\r
+    }\r
+\r
+    //\r
+    // Retrieve the UC Protocol\r
+    //\r
+    Status = gBS->HandleProtocol (\r
+                    Handle,\r
+                    &gEfiUnicodeCollationProtocolGuid,\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
+\r
+      //\r
+      // Install Firmware Volume Protocol onto same handle\r
+      //\r
+      Status = gBS->InstallMultipleProtocolInterfaces (\r
+                      &Handle,\r
+                      &gEfiUnicodeCollation2ProtocolGuid,\r
+                      &Private->UC2,\r
+                      NULL\r
+                      );\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+  }\r
+}\r
+\r
+\r
+/**\r
+  The user Entry Point for DXE driver. The user code starts with this function\r
+  as the real entry point for the image goes into a library that calls this \r
+  function.\r
+\r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
+  @param[in] SystemTable    A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeUC2 (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EfiCreateProtocolNotifyEvent (\r
+    &gEfiUnicodeCollationProtocolGuid,\r
+    TPL_CALLBACK,\r
+    Uc2NotificationEvent,\r
+    NULL,\r
+    &mUc2Registration\r
+    );\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Performs a case-insensitive comparison of two Null-terminated Unicode \r
+  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
+\r
+  @retval 0   Str1 is equivalent to Str2\r
+  @retval > 0 Str1 is lexically greater than Str2\r
+  @retval < 0 Str1 is lexically less than Str2\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+StriColl (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN CHAR16                           *Str1,\r
+  IN CHAR16                           *Str2\r
+  )\r
+{\r
+  UC2_PRIVATE_DATA *Private;\r
+  \r
+  Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
+  \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
+\r
+  @param  This   Protocol instance pointer.\r
+  @param  Str    A pointer to a Null-terminated Unicode string.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+StrLwr (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN OUT CHAR16                       *Str\r
+  )\r
+{\r
+  UC2_PRIVATE_DATA *Private;\r
+  \r
+  Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
+  \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
+\r
+  @param  This   Protocol instance pointer.\r
+  @param  Str    A pointer to a Null-terminated Unicode string.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+StrUpr (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN OUT CHAR16                       *Str\r
+  )\r
+{\r
+  UC2_PRIVATE_DATA *Private;\r
+  \r
+  Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
+  \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
+\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
+\r
+  @retval TRUE    Pattern was found in String.\r
+  @retval FALSE   Pattern was not found in String.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MetaiMatch (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN CHAR16                           *String,\r
+  IN CHAR16                           *Pattern\r
+  )\r
+{\r
+  UC2_PRIVATE_DATA *Private;\r
+  \r
+  Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
+  \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
+\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
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FatToStr (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN UINTN                            FatSize,\r
+  IN CHAR8                            *Fat,\r
+  OUT CHAR16                          *String\r
+  )\r
+{\r
+  UC2_PRIVATE_DATA *Private;\r
+  \r
+  Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
+  \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
+  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  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
+\r
+  @retval TRUE    Fat is a Long File Name\r
+  @retval FALSE   Fat is an 8.3 file name\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+StrToFat (\r
+  IN EFI_UNICODE_COLLATION_PROTOCOL   *This,\r
+  IN CHAR16                           *String,\r
+  IN UINTN                            FatSize,\r
+  OUT CHAR8                           *Fat\r
+  )\r
+{\r
+  UC2_PRIVATE_DATA *Private;\r
+  \r
+  Private = UC2_PRIVATE_DATA_FROM_THIS (This);\r
+  \r
+  return Private->UC->StrToFat (Private->UC, String, FatSize, Fat);\r
+}\r
+\r
diff --git a/EdkCompatibilityPkg/Compatibility/Uc2ToUcThunk/Uc2ToUcThunk.inf b/EdkCompatibilityPkg/Compatibility/Uc2ToUcThunk/Uc2ToUcThunk.inf
new file mode 100644 (file)
index 0000000..50fae2d
--- /dev/null
@@ -0,0 +1,61 @@
+#/** @file\r
+# Module produce UC2 on top of UC.\r
+#\r
+# UEFI 2.1 specification supersedes Inte's EFI Specification 1.10.\r
+# EFI_UNICODE_COLLATION_PROTOCOL defined in Inte's EFI Specification 1.10 is replaced by\r
+# EFI_UNICODE_COLLATION_PROTOCOL in UEFI 2.1.\r
+# This module produces UC2 on top of UC. This module is used on platform when both of\r
+# these two conditions are true:\r
+# 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\r
+#\r
+#  All rights reserved. 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
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = Uc2ToUcThunk\r
+  FILE_GUID                      = 69282DF3-778F-4269-91AA-D7DF6E193317\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+  ENTRY_POINT                    = InitializeUC2\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  Uc2ToUcThunk.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiDriverEntryPoint\r
+  UefiBootServicesTableLib\r
+  BaseLib\r
+  DebugLib\r
+  UefiLib\r
+  MemoryAllocationLib\r
+  HiiLib\r
+\r
+[Protocols]\r
+  gEfiUnicodeCollation2ProtocolGuid\r
+  gEfiUnicodeCollationProtocolGuid\r
+\r
+[Depex]\r
+  TRUE\r