+++ /dev/null
-/** @file\r
-Module produce UC on top of UC2.\r
-\r
-UEFI 2.1 specification supersedes Inte's EFI Specification 1.10.\r
-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 UC on top of UC2. This module is used on platform when both of\r
-these two conditions are true:\r
-1) EFI 1.10 module consuming UC present\r
-2) And the rest of modules on the platform produce 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
- 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
- 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
- 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
- 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
- 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
-#define UC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('_', 'U', 'C', '_')\r
-\r
-typedef struct {\r
- UINT32 Signature;\r
- EFI_UNICODE_COLLATION_PROTOCOL UC;\r
- EFI_UNICODE_COLLATION_PROTOCOL *UC2;\r
-} UC_PRIVATE_DATA;\r
-\r
-#define UC_PRIVATE_DATA_FROM_THIS(a) CR (a, UC_PRIVATE_DATA, UC, UC_PRIVATE_DATA_SIGNATURE)\r
-\r
-//\r
-// Firmware Volume Protocol template\r
-//\r
-EFI_EVENT mUcRegistration;\r
-\r
-UC_PRIVATE_DATA gUCPrivateDataTemplate = {\r
- UC_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
- UC_PRIVATE_DATA *Private;\r
- EFI_UNICODE_COLLATION_PROTOCOL *Uc2;\r
-\r
- while (TRUE) {\r
- BufferSize = sizeof (Handle);\r
- Status = gBS->LocateHandle (\r
- ByRegisterNotify,\r
- &gEfiUnicodeCollation2ProtocolGuid,\r
- mUcRegistration,\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
- &gEfiUnicodeCollationProtocolGuid,\r
- (VOID **)&Uc2\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- //\r
- // Allocate private data structure\r
- //\r
- Private = AllocateCopyPool (sizeof (UC_PRIVATE_DATA), &gUCPrivateDataTemplate);\r
- if (Private == NULL) {\r
- continue;\r
- }\r
-\r
- //\r
- // Retrieve the UC Protocol\r
- //\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiUnicodeCollation2ProtocolGuid,\r
- (VOID **)&Private->UC2\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Fill in rest of private data structure\r
- //\r
- Private->UC.SupportedLanguages = AllocateZeroPool (ISO_639_2_ENTRY_SIZE + 1);\r
- Status = ConvertRfc3066LanguageToIso639Language (Private->UC2->SupportedLanguages, Private->UC.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
- &gEfiUnicodeCollationProtocolGuid,\r
- &Private->UC,\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
-InitializeUC (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EfiCreateProtocolNotifyEvent (\r
- &gEfiUnicodeCollation2ProtocolGuid,\r
- TPL_CALLBACK,\r
- Uc2NotificationEvent,\r
- NULL,\r
- &mUcRegistration\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
- UC_PRIVATE_DATA *Private;\r
- \r
- Private = UC_PRIVATE_DATA_FROM_THIS (This);\r
- \r
- return Private->UC2->StriColl (Private->UC2, 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
- UC_PRIVATE_DATA *Private;\r
- \r
- Private = UC_PRIVATE_DATA_FROM_THIS (This);\r
- \r
- Private->UC2->StrLwr (Private->UC2, 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
- UC_PRIVATE_DATA *Private;\r
- \r
- Private = UC_PRIVATE_DATA_FROM_THIS (This);\r
- \r
- Private->UC2->StrUpr (Private->UC2, 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
- UC_PRIVATE_DATA *Private;\r
- \r
- Private = UC_PRIVATE_DATA_FROM_THIS (This);\r
- \r
- return Private->UC2->MetaiMatch (Private->UC2, 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
- UC_PRIVATE_DATA *Private;\r
- \r
- Private = UC_PRIVATE_DATA_FROM_THIS (This);\r
- \r
- Private->UC2->FatToStr (Private->UC2, 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
- UC_PRIVATE_DATA *Private;\r
- \r
- Private = UC_PRIVATE_DATA_FROM_THIS (This);\r
- \r
- return Private->UC2->StrToFat (Private->UC2, String, FatSize, Fat);\r
-}\r
-\r