summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Disk/UnicodeCollation
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/Disk/UnicodeCollation')
-rw-r--r--MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/CommonHeader.h35
-rw-r--r--MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.inf93
-rw-r--r--MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.msa55
-rw-r--r--MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/UnicodeCollationEng.c479
-rw-r--r--MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/UnicodeCollationEng.h117
5 files changed, 779 insertions, 0 deletions
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/CommonHeader.h b/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/CommonHeader.h
new file mode 100644
index 0000000..f1a8cc6
--- /dev/null
+++ b/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/CommonHeader.h
@@ -0,0 +1,35 @@
+/**@file
+ Common header file shared by all source files.
+
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.
+
+ Copyright (c) 2006 - 2007, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+
+#ifndef __COMMON_HEADER_H_
+#define __COMMON_HEADER_H_
+
+
+//
+// The package level header files this module uses
+//
+#include <PiDxe.h>
+
+//
+// The protocols, PPI and GUID defintions for this module
+//
+#include <Protocol/UnicodeCollation.h>
+//
+// The Library classes this module consumes
+//
+#include <Library/DebugLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#endif
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.inf b/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.inf
new file mode 100644
index 0000000..7022ab1
--- /dev/null
+++ b/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.inf
@@ -0,0 +1,93 @@
+#/** @file
+# Component description file for English module for unicode collation.
+#
+# This driver installs UEFI EFI_UNICODE_COLLATION_PROTOCOL protocol to provide Unicode strings function.
+# Copyright (c) 2006 - 2007, Intel Corporation
+#
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+#**/
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = English
+ FILE_GUID = CD3BAFB6-50FB-4fe8-8E4E-AB74D2C1A600
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ EDK_RELEASE_VERSION = 0x00020000
+ EFI_SPECIFICATION_VERSION = 0x00020000
+
+ ENTRY_POINT = InitializeUnicodeCollationEng
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+################################################################################
+#
+# Sources Section - list of files that are required for the build to succeed.
+#
+################################################################################
+
+[Sources.common]
+ UnicodeCollationEng.c
+ UnicodeCollationEng.h
+
+
+################################################################################
+#
+# Includes Section - list of Include locations that are required for
+# this module.
+#
+################################################################################
+
+[Includes]
+ $(WORKSPACE)/MdePkg/Include/Library
+
+################################################################################
+#
+# Package Dependency Section - list of Package files that are required for
+# this module.
+#
+################################################################################
+
+[Packages]
+ $(WORKSPACE)/MdeModulePkg/MdeModulePkg.dec
+ $(WORKSPACE)/MdePkg/MdePkg.dec
+
+################################################################################
+#
+# Library Class Section - list of Library Classes that are required for
+# this module.
+#
+################################################################################
+
+[LibraryClasses]
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ DebugLib
+
+
+################################################################################
+#
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names
+# that this module uses or produces.
+#
+################################################################################
+
+[Protocols]
+ gEfiUnicodeCollationProtocolGuid # PROTOCOL ALWAYS_PRODUCED
+
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.msa b/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.msa
new file mode 100644
index 0000000..3a72998
--- /dev/null
+++ b/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.msa
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
+ <MsaHeader>
+ <ModuleName>English</ModuleName>
+ <ModuleType>UEFI_DRIVER</ModuleType>
+ <GuidValue>CD3BAFB6-50FB-4fe8-8E4E-AB74D2C1A600</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Component description file for English module for unicode collation.</Abstract>
+ <Description>This driver installs UEFI EFI_UNICODE_COLLATION_PROTOCOL protocol to provide Unicode strings function.</Description>
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>
+ <License>All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>English</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED" RecommendedInstanceGuid="bda39d3a-451b-4350-8266-81ab10fa0523">
+ <Keyword>DebugLib</Keyword>
+ <HelpText>Recommended libary Instance is PeiDxeDebugLibReportStatusCode instance in MdePkg.</HelpText>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiDriverEntryPoint</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>UefiBootServicesTableLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>UnicodeCollationEng.h</Filename>
+ <Filename>UnicodeCollationEng.c</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ </PackageDependencies>
+ <Protocols>
+ <Protocol Usage="ALWAYS_PRODUCED">
+ <ProtocolCName>gEfiUnicodeCollationProtocolGuid</ProtocolCName>
+ </Protocol>
+ </Protocols>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ <Extern>
+ <ModuleEntryPoint>InitializeUnicodeCollationEng</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea> \ No newline at end of file
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/UnicodeCollationEng.c b/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/UnicodeCollationEng.c
new file mode 100644
index 0000000..5b543e9
--- /dev/null
+++ b/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/UnicodeCollationEng.c
@@ -0,0 +1,479 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UnicodeCollationEng.c
+
+Abstract:
+
+ Unicode Collation Protocol (English)
+
+Revision History
+
+--*/
+
+
+#include "UnicodeCollationEng.h"
+
+CHAR8 mEngUpperMap[0x100];
+CHAR8 mEngLowerMap[0x100];
+CHAR8 mEngInfoMap[0x100];
+
+CHAR8 mOtherChars[] = {
+ '0',
+ '1',
+ '2',
+ '3',
+ '4',
+ '5',
+ '6',
+ '7',
+ '8',
+ '9',
+ '\\',
+ '.',
+ '_',
+ '^',
+ '$',
+ '~',
+ '!',
+ '#',
+ '%',
+ '&',
+ '-',
+ '{',
+ '}',
+ '(',
+ ')',
+ '@',
+ '`',
+ '\'',
+ '\0'
+};
+
+EFI_HANDLE mHandle = NULL;
+
+EFI_UNICODE_COLLATION_PROTOCOL UnicodeEng = {
+ EngStriColl,
+ EngMetaiMatch,
+ EngStrLwr,
+ EngStrUpr,
+ EngFatToStr,
+ EngStrToFat,
+ "eng"
+};
+
+//
+//
+//
+EFI_STATUS
+InitializeUnicodeCollationEng (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Initializes the Unicode Collation Driver
+
+Arguments:
+
+ ImageHandle -
+
+ SystemTable -
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_OUT_OF_RESOURCES
+
+--*/
+{
+ UINTN Index;
+ UINTN Index2;
+
+ //
+ // Initialize mapping tables for the supported languages
+ //
+ for (Index = 0; Index < 0x100; Index++) {
+ mEngUpperMap[Index] = (CHAR8) Index;
+ mEngLowerMap[Index] = (CHAR8) Index;
+ mEngInfoMap[Index] = 0;
+
+ if ((Index >= 'a' && Index <= 'z') || (Index >= 0xe0 && Index <= 0xf6) || (Index >= 0xf8 && Index <= 0xfe)) {
+
+ Index2 = Index - 0x20;
+ mEngUpperMap[Index] = (CHAR8) Index2;
+ mEngLowerMap[Index2] = (CHAR8) Index;
+
+ mEngInfoMap[Index] |= CHAR_FAT_VALID;
+ mEngInfoMap[Index2] |= CHAR_FAT_VALID;
+ }
+ }
+
+ for (Index = 0; mOtherChars[Index]; Index++) {
+ Index2 = mOtherChars[Index];
+ mEngInfoMap[Index2] |= CHAR_FAT_VALID;
+ }
+ //
+ // Create a handle for the device
+ //
+ return gBS->InstallProtocolInterface (
+ &mHandle,
+ &gEfiUnicodeCollationProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &UnicodeEng
+ );
+}
+
+INTN
+EFIAPI
+EngStriColl (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *s1,
+ IN CHAR16 *s2
+ )
+/*++
+
+Routine Description:
+
+ Performs a case-insensitive comparison of two Null-terminated Unicode strings.
+
+Arguments:
+
+ This
+ s1
+ s2
+
+Returns:
+
+--*/
+{
+ while (*s1) {
+ if (ToUpper (*s1) != ToUpper (*s2)) {
+ break;
+ }
+
+ s1 += 1;
+ s2 += 1;
+ }
+
+ return ToUpper (*s1) - ToUpper (*s2);
+}
+
+VOID
+EFIAPI
+EngStrLwr (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN OUT CHAR16 *Str
+ )
+/*++
+
+Routine Description:
+
+ Converts all the Unicode characters in a Null-terminated Unicode string
+ to lower case Unicode characters.
+
+Arguments:
+
+ This - A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
+ Str1 - A pointer to a Null-terminated Unicode string.
+ Str2 - A pointer to a Null-terminated Unicode string.
+
+Returns:
+
+ 0 - s1 is equivalent to s2.
+ > 0 - s1 is lexically greater than s2.
+ < 0 - s1 is lexically less than s2.
+
+--*/
+{
+ while (*Str) {
+ *Str = ToLower (*Str);
+ Str += 1;
+ }
+}
+
+VOID
+EFIAPI
+EngStrUpr (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN OUT CHAR16 *Str
+ )
+/*++
+
+Routine Description:
+
+ Converts all the Unicode characters in a Null-terminated
+ Unicode string to upper case Unicode characters.
+
+Arguments:
+ This
+ Str
+
+Returns:
+ None
+
+--*/
+{
+ while (*Str) {
+ *Str = ToUpper (*Str);
+ Str += 1;
+ }
+}
+
+BOOLEAN
+EFIAPI
+EngMetaiMatch (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *String,
+ IN CHAR16 *Pattern
+ )
+/*++
+
+Routine Description:
+
+ Performs a case-insensitive comparison between a Null-terminated
+ Unicode pattern string and a Null-terminated Unicode string.
+
+ The pattern string can use the '?' wildcard to match any character,
+ and the '*' wildcard to match any sub-string.
+
+Arguments:
+
+ This - A pointer to the EFI_UNICODE_COLLATION_PROTOCOL instance.
+ String - A pointer to a Null-terminated Unicode string.
+ Pattern - A pointer to a Null-terminated Unicode pattern string.
+
+Returns:
+
+ TRUE - Pattern was found in String.
+ FALSE - Pattern was not found in String.
+
+--*/
+{
+ CHAR16 CharC;
+ CHAR16 CharP;
+ CHAR16 Index3;
+
+ for (;;) {
+ CharP = *Pattern;
+ Pattern += 1;
+
+ switch (CharP) {
+ case 0:
+ //
+ // End of pattern. If end of string, TRUE match
+ //
+ if (*String) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+
+ case '*':
+ //
+ // Match zero or more chars
+ //
+ while (*String) {
+ if (EngMetaiMatch (This, String, Pattern)) {
+ return TRUE;
+ }
+
+ String += 1;
+ }
+
+ return EngMetaiMatch (This, String, Pattern);
+
+ case '?':
+ //
+ // Match any one char
+ //
+ if (!*String) {
+ return FALSE;
+ }
+
+ String += 1;
+ break;
+
+ case '[':
+ //
+ // Match char set
+ //
+ CharC = *String;
+ if (!CharC) {
+ //
+ // syntax problem
+ //
+ return FALSE;
+ }
+
+ Index3 = 0;
+ CharP = *Pattern++;
+ while (CharP) {
+ if (CharP == ']') {
+ return FALSE;
+ }
+
+ if (CharP == '-') {
+ //
+ // if range of chars, get high range
+ //
+ CharP = *Pattern;
+ if (CharP == 0 || CharP == ']') {
+ //
+ // syntax problem
+ //
+ return FALSE;
+ }
+
+ if (ToUpper (CharC) >= ToUpper (Index3) && ToUpper (CharC) <= ToUpper (CharP)) {
+ //
+ // if in range, it's a match
+ //
+ break;
+ }
+ }
+
+ Index3 = CharP;
+ if (ToUpper (CharC) == ToUpper (CharP)) {
+ //
+ // if char matches
+ //
+ break;
+ }
+
+ CharP = *Pattern++;
+ }
+ //
+ // skip to end of match char set
+ //
+ while (CharP && CharP != ']') {
+ CharP = *Pattern;
+ Pattern += 1;
+ }
+
+ String += 1;
+ break;
+
+ default:
+ CharC = *String;
+ if (ToUpper (CharC) != ToUpper (CharP)) {
+ return FALSE;
+ }
+
+ String += 1;
+ break;
+ }
+ }
+}
+
+VOID
+EFIAPI
+EngFatToStr (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN UINTN FatSize,
+ IN CHAR8 *Fat,
+ OUT CHAR16 *String
+ )
+/*++
+
+Routine Description:
+
+ Converts an 8.3 FAT file name using an OEM character set
+ to a Null-terminated Unicode string.
+
+ BUGBUG: Function has to expand DBCS FAT chars, currently not.
+
+Arguments:
+ This
+ FatSize
+ Fat
+ String
+
+Returns:
+
+--*/
+{
+ //
+ // No DBCS issues, just expand and add null terminate to end of string
+ //
+ while (*Fat && FatSize) {
+ *String = *Fat;
+ String += 1;
+ Fat += 1;
+ FatSize -= 1;
+ }
+
+ *String = 0;
+}
+
+BOOLEAN
+EFIAPI
+EngStrToFat (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *String,
+ IN UINTN FatSize,
+ OUT CHAR8 *Fat
+ )
+/*++
+
+Routine Description:
+
+ Converts a Null-terminated Unicode string to legal characters
+ in a FAT filename using an OEM character set.
+
+ Functions has to crunch string to a fat string. Replacing
+ any chars that can't be represented in the fat name.
+
+Arguments:
+ This
+ String
+ FatSize
+ Fat
+
+Returns:
+ TRUE
+ FALSE
+--*/
+{
+ BOOLEAN SpecialCharExist;
+
+ SpecialCharExist = FALSE;
+ while (*String && FatSize) {
+ //
+ // Skip '.' or ' ' when making a fat name
+ //
+ if (*String != '.' && *String != ' ') {
+ //
+ // If this is a valid fat char, move it.
+ // Otherwise, move a '_' and flag the fact that the name needs an Lfn
+ //
+ if (*String < 0x100 && (mEngInfoMap[*String] & CHAR_FAT_VALID)) {
+ *Fat = mEngUpperMap[*String];
+ } else {
+ *Fat = '_';
+ SpecialCharExist = TRUE;
+ }
+
+ Fat += 1;
+ FatSize -= 1;
+ }
+
+ String += 1;
+ }
+ //
+ // Do not terminate that fat string
+ //
+ return SpecialCharExist;
+}
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/UnicodeCollationEng.h b/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/UnicodeCollationEng.h
new file mode 100644
index 0000000..c8485ac
--- /dev/null
+++ b/MdeModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/UnicodeCollationEng.h
@@ -0,0 +1,117 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UnicodeCollationEng.h
+
+Abstract:
+
+ Head file for Unicode Collation Protocol (English)
+
+Revision History
+
+--*/
+
+#ifndef _UNICODE_COLLATION_ENG_H
+#define _UNICODE_COLLATION_ENG_H
+
+
+//
+// The package level header files this module uses
+//
+#include <PiDxe.h>
+
+//
+// The protocols, PPI and GUID defintions for this module
+//
+#include <Protocol/UnicodeCollation.h>
+//
+// The Library classes this module consumes
+//
+#include <Library/DebugLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+//
+// Defines
+//
+#define CHAR_FAT_VALID 0x01
+
+#define ToUpper(a) (CHAR16) (a <= 0xFF ? mEngUpperMap[a] : a)
+#define ToLower(a) (CHAR16) (a <= 0xFF ? mEngLowerMap[a] : a)
+
+//
+// Prototypes
+//
+INTN
+EFIAPI
+EngStriColl (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *s1,
+ IN CHAR16 *s2
+ )
+;
+
+BOOLEAN
+EFIAPI
+EngMetaiMatch (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *String,
+ IN CHAR16 *Pattern
+ )
+;
+
+VOID
+EFIAPI
+EngStrLwr (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN OUT CHAR16 *Str
+ )
+;
+
+VOID
+EFIAPI
+EngStrUpr (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN OUT CHAR16 *Str
+ )
+;
+
+VOID
+EFIAPI
+EngFatToStr (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN UINTN FatSize,
+ IN CHAR8 *Fat,
+ OUT CHAR16 *String
+ )
+;
+
+BOOLEAN
+EFIAPI
+EngStrToFat (
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *String,
+ IN UINTN FatSize,
+ OUT CHAR8 *Fat
+ )
+;
+
+EFI_STATUS
+EFIAPI
+InitializeUnicodeCollationEng (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+;
+
+#endif