]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Strings.c
Retiring the ANT/JAVA build and removing the older EDK II packages that required...
[mirror_edk2.git] / EdkModulePkg / Universal / UserInterface / HiiDataBase / Dxe / Strings.c
diff --git a/EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Strings.c b/EdkModulePkg/Universal/UserInterface/HiiDataBase/Dxe/Strings.c
deleted file mode 100644 (file)
index 4c56ab0..0000000
+++ /dev/null
@@ -1,1271 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation                                                         \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
-\r
-Module Name:\r
-\r
-  Strings.c\r
-\r
-Abstract:\r
-\r
-  This file contains the string processing code to the HII database.\r
-\r
---*/\r
-\r
-\r
-#include "HiiDatabase.h"\r
-\r
-STATIC\r
-VOID\r
-AsciiToUnicode (\r
-  IN    UINT8     *Lang,\r
-  IN    UINT16    *Language\r
-  )\r
-{\r
-  UINT8 Count;\r
-\r
-  //\r
-  // Convert the ASCII Lang variable to a Unicode Language variable\r
-  //\r
-  for (Count = 0; Count < 3; Count++) {\r
-    Language[Count] = (CHAR16) Lang[Count];\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-HiiTestString (\r
-  IN     EFI_HII_PROTOCOL   *This,\r
-  IN     CHAR16             *StringToTest,\r
-  IN OUT UINT32             *FirstMissing,\r
-  OUT    UINT32             *GlyphBufferSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Test if all of the characters in a string have corresponding font characters.\r
-  \r
-Arguments:\r
-\r
-Returns: \r
-\r
---*/\r
-{\r
-  EFI_HII_GLOBAL_DATA *GlobalData;\r
-  EFI_HII_DATA        *HiiData;\r
-  BOOLEAN             WideChar;\r
-  INT32               Location;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  HiiData     = EFI_HII_DATA_FROM_THIS (This);\r
-  GlobalData  = HiiData->GlobalData;\r
-\r
-  \r
-  //\r
-  // Rewind through the string looking for a glyph width identifier\r
-  // If no width identifier exists, we assume string has narrow width identifier\r
-  //\r
-  for (WideChar = FALSE, Location = (INT32) *FirstMissing; Location >= 0; Location--) {\r
-    if ((StringToTest[Location] == NARROW_CHAR) || (StringToTest[Location] == WIDE_CHAR)) {\r
-      //\r
-      // We found something that identifies what glyph database to look in\r
-      //\r
-      WideChar = (BOOLEAN) (StringToTest[Location] == WIDE_CHAR);\r
-      break;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Walk through the string until you hit the null terminator\r
-  //\r
-  for (*GlyphBufferSize = 0; StringToTest[*FirstMissing] != CHAR_NULL; (*FirstMissing)++) {\r
-    //\r
-    // We found something that identifies what glyph database to look in\r
-    //\r
-    if ((StringToTest[*FirstMissing] == NARROW_CHAR) || (StringToTest[*FirstMissing] == WIDE_CHAR)) {\r
-      WideChar = (BOOLEAN) (StringToTest[*FirstMissing] == WIDE_CHAR);\r
-      continue;\r
-    }\r
-\r
-    if (!WideChar) {\r
-      if (CompareMem (\r
-          GlobalData->NarrowGlyphs[StringToTest[*FirstMissing]].GlyphCol1,\r
-          &mUnknownGlyph,\r
-          NARROW_GLYPH_ARRAY_SIZE\r
-          ) == 0\r
-          ) {\r
-        //\r
-        // Break since this glyph isn't defined\r
-        //\r
-        return EFI_NOT_FOUND;\r
-      }\r
-    } else {\r
-      //\r
-      // Can compare wide glyph against only GlyphCol1 since GlyphCol1 and GlyphCol2 are contiguous - just give correct size\r
-      //\r
-      if (CompareMem (\r
-          GlobalData->WideGlyphs[StringToTest[*FirstMissing]].GlyphCol1,\r
-          &mUnknownGlyph,\r
-          WIDE_GLYPH_ARRAY_SIZE\r
-          ) == 0\r
-          ) {\r
-        //\r
-        // Break since this glyph isn't defined\r
-        //\r
-        return EFI_NOT_FOUND;\r
-      }\r
-    }\r
-\r
-    *GlyphBufferSize += (WideChar ? sizeof (EFI_WIDE_GLYPH) : sizeof (EFI_NARROW_GLYPH));\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-STATIC\r
-EFI_STATUS\r
-HiiNewString2 (\r
-  IN     EFI_HII_PROTOCOL       *This,\r
-  IN     CHAR16                 *Language,\r
-  IN     EFI_HII_HANDLE         Handle,\r
-  IN OUT STRING_REF             *Reference,\r
-  IN     CHAR16                 *NewString,\r
-  IN     BOOLEAN                ResetStrings\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function allows a new String to be added to an already existing String Package.\r
-  We will make a buffer the size of the package + EfiStrSize of the new string.  We will\r
-  copy the string package that first gets changed and the following language packages until\r
-  we encounter the NULL string package.  All this time we will ensure that the offsets have\r
-  been adjusted.  \r
-\r
-Arguments:\r
-  \r
-  This         -  Pointer to the HII protocol.\r
-  Language     -  Pointer to buffer which contains the language code of this NewString.\r
-  Handle       -  Handle of the package instance to be processed.\r
-  Reference    -  The token number for the string. If 0, new string token to be returned through this parameter.\r
-  NewString    -  Buffer pointer for the new string. \r
-  ResetStrings -  Indicate if we are resetting a string.\r
-  \r
-Returns: \r
-\r
-  EFI_SUCCESS            - The string has been added or reset to Hii database.\r
-  EFI_INVALID_PARAMETER  - Some parameter passed in is invalid.\r
-\r
---*/\r
-{\r
-  EFI_HII_PACKAGE_INSTANCE  *PackageInstance;\r
-  EFI_HII_PACKAGE_INSTANCE  *StringPackageInstance;\r
-  EFI_HII_DATA              *HiiData;\r
-  EFI_HII_STRING_PACK       *StringPack;\r
-  EFI_HII_STRING_PACK       *NewStringPack;\r
-  EFI_HII_HANDLE_DATABASE   *HandleDatabase;\r
-  EFI_HII_PACKAGE_INSTANCE  *NewBuffer;\r
-  UINT8                     *Location;\r
-  UINT8                     *StringLocation;\r
-  RELOFST                   *StringPointer;\r
-  UINTN                     Count;\r
-  UINTN                     Size;\r
-  UINTN                     Index;\r
-  UINTN                     SecondIndex;\r
-  BOOLEAN                   AddString;\r
-  EFI_STATUS                Status;\r
-  UINTN                     Increment;\r
-  UINTN                     StringCount;\r
-  UINT32                    TotalStringCount;\r
-  UINT32                    OriginalStringCount;\r
-  RELOFST                   StringSize;\r
-  UINT32                    Length;\r
-  RELOFST                   Offset;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  HiiData             = EFI_HII_DATA_FROM_THIS (This);\r
-\r
-  HandleDatabase      = HiiData->DatabaseHead;\r
-  PackageInstance     = NULL;\r
-  AddString           = FALSE;\r
-  Increment           = 0;\r
-  StringCount         = 0;\r
-  TotalStringCount    = 0;\r
-  OriginalStringCount = 0;\r
-\r
-  //\r
-  // Check numeric value against the head of the database\r
-  //\r
-  for (; HandleDatabase != NULL; HandleDatabase = HandleDatabase->NextHandleDatabase) {\r
-    //\r
-    // Match the numeric value with the database entry - if matched, extract PackageInstance\r
-    //\r
-    if (Handle == HandleDatabase->Handle) {\r
-      PackageInstance = HandleDatabase->Buffer;\r
-      if (ResetStrings) {\r
-        TotalStringCount = HandleDatabase->NumberOfTokens;\r
-      }\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // No handle was found - error condition\r
-  //\r
-  if (PackageInstance == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = ValidatePack (This, PackageInstance, &StringPackageInstance, &TotalStringCount);\r
-\r
-  //\r
-  // This sets Count to 0 or the size of the IfrData.  We intend to use Count as an offset value\r
-  //\r
-  Count = StringPackageInstance->IfrSize;\r
-\r
-  //\r
-  // This is the size of the complete series of string packs\r
-  //\r
-  Size = StringPackageInstance->StringSize;\r
-\r
-  //\r
-  // Based on if there is IFR data in this package instance, determine\r
-  // what the location is of the beginning of the string data.\r
-  //\r
-  if (StringPackageInstance->IfrSize > 0) {\r
-    Location = (UINT8 *) (&StringPackageInstance->IfrData) + StringPackageInstance->IfrSize;\r
-  } else {\r
-    Location = (UINT8 *) (&StringPackageInstance->IfrData);\r
-  }\r
-  //\r
-  // We allocate a buffer which is big enough for both adding and resetting string.\r
-  // The size is slightly larger than the real size of the packages when we are resetting a string.\r
-  //\r
-  NewBuffer = AllocateZeroPool (\r
-                sizeof (EFI_HII_PACKAGE_INSTANCE) -\r
-                2 * sizeof (VOID *) +\r
-                StringPackageInstance->IfrSize +\r
-                StringPackageInstance->StringSize +\r
-                sizeof (RELOFST) +\r
-                StrSize (NewString)\r
-                );\r
-  ASSERT (NewBuffer);\r
-\r
-  //\r
-  // Copy data to new buffer\r
-  //\r
-  NewBuffer->Handle   = StringPackageInstance->Handle;\r
-  NewBuffer->IfrSize  = StringPackageInstance->IfrSize;\r
-\r
-  //\r
-  // The worst case scenario for sizing is that we are adding a new string (not replacing one) and there was not a string\r
-  // package to begin with.\r
-  //\r
-  NewBuffer->StringSize = StringPackageInstance->StringSize + StrSize (NewString) + sizeof (EFI_HII_STRING_PACK);\r
-\r
-  if (StringPackageInstance->IfrSize > 0) {\r
-    CopyMem (&NewBuffer->IfrData, &StringPackageInstance->IfrData, StringPackageInstance->IfrSize);\r
-  }\r
-\r
-  StringPack = (EFI_HII_STRING_PACK *) Location;\r
-\r
-  //\r
-  // There may be multiple instances packed together of strings\r
-  // so we must walk the self describing structures until we encounter\r
-  // what we are looking for.  In the meantime, copy everything we encounter\r
-  // to the new buffer.\r
-  //\r
-  CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-  for (; Length != 0;) {\r
-    //\r
-    // If passed in Language ISO value is in this string pack's language string\r
-    // then we are dealing with the strings we want.\r
-    //\r
-    CopyMem (&Offset, &StringPack->LanguageNameString, sizeof (RELOFST));\r
-    Status = HiiCompareLanguage ((CHAR16 *) ((CHAR8 *) (StringPack) + Offset), Language);\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-\r
-    CopyMem (((CHAR8 *) (&NewBuffer->IfrData) + Count), StringPack, Length);\r
-\r
-    Count       = Count + Length;\r
-    StringPack  = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + Length);\r
-    CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-  }\r
-  //\r
-  // Found the language pack to update on a particular handle\r
-  // We need to Copy the Contents of this pack and adjust the offset values associated\r
-  // with adding/changing a string.  This is a particular piece of code that screams for\r
-  // it being prone to programming error.\r
-  //\r
-  //\r
-  // Copy the string package up to the string data\r
-  //\r
-  StringPointer = (RELOFST *) (StringPack + 1);\r
-  CopyMem (\r
-    ((CHAR8 *) (&NewBuffer->IfrData) + Count),\r
-    StringPack,\r
-    (UINTN) ((UINTN) (StringPointer) - (UINTN) (StringPack))\r
-    );\r
-\r
-  //\r
-  // Determine the number of StringPointers\r
-  //\r
-  if (!ResetStrings) {\r
-    CopyMem (&TotalStringCount, &StringPack->NumStringPointers, sizeof (RELOFST));\r
-  } else {\r
-    //\r
-    // If we are resetting the strings, use the original value when exported\r
-    //\r
-    CopyMem (&OriginalStringCount, &StringPack->NumStringPointers, sizeof (RELOFST));\r
-    ((EFI_HII_STRING_PACK *) ((CHAR8 *) (&NewBuffer->IfrData) + Count))->LanguageNameString -=\r
-      (\r
-        (RELOFST) (OriginalStringCount - TotalStringCount) *\r
-        sizeof (RELOFST)\r
-      );\r
-    ((EFI_HII_STRING_PACK *) ((CHAR8 *) (&NewBuffer->IfrData) + Count))->PrintableLanguageName -=\r
-      (\r
-        (RELOFST) (OriginalStringCount - TotalStringCount) *\r
-        sizeof (RELOFST)\r
-      );\r
-    ((EFI_HII_STRING_PACK *) ((CHAR8 *) (&NewBuffer->IfrData) + Count))->NumStringPointers  = TotalStringCount;\r
-    *Reference = (STRING_REF) (TotalStringCount);\r
-  }\r
-  //\r
-  // If the token value is not valid, error out\r
-  //\r
-  if ((*Reference >= TotalStringCount) && !ResetStrings) {\r
-    FreePool (NewBuffer);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // If Reference is 0, update it with what the new token reference will be and turn the AddString flag on\r
-  //\r
-  if (*Reference == 0) {\r
-    *Reference  = (STRING_REF) (TotalStringCount);\r
-    AddString   = TRUE;\r
-  }\r
-\r
-  if (AddString) {\r
-    ((EFI_HII_STRING_PACK *) ((CHAR8 *) (&NewBuffer->IfrData) + Count))->LanguageNameString += sizeof (RELOFST);\r
-    ((EFI_HII_STRING_PACK *) ((CHAR8 *) (&NewBuffer->IfrData) + Count))->PrintableLanguageName += sizeof (RELOFST);\r
-    ((EFI_HII_STRING_PACK *) ((CHAR8 *) (&NewBuffer->IfrData) + Count))->NumStringPointers++;\r
-  }\r
-  //\r
-  // Increment offset by amount of copied data\r
-  //\r
-  Count = Count + ((UINTN) (StringPointer) - (UINTN) StringPack);\r
-\r
-  for (Index = 0; Index < TotalStringCount; Index++) {\r
-    //\r
-    // If we are pointing to the size of the changing string value\r
-    // then cache the old string value so you know what the difference is\r
-    //\r
-    if (Index == *Reference) {\r
-      CopyMem (&Offset, &StringPointer[Index], sizeof (RELOFST));\r
-\r
-      StringLocation = ((UINT8 *) (StringPack) + Offset);\r
-      for (SecondIndex = 0;\r
-           (StringLocation[SecondIndex] != 0) || (StringLocation[SecondIndex + 1] != 0);\r
-           SecondIndex = SecondIndex + 2\r
-          )\r
-        ;\r
-      SecondIndex = SecondIndex + 2;\r
-\r
-      Size        = SecondIndex;\r
-\r
-      //\r
-      // NewString is a passed in local string which is assumed to be aligned\r
-      //\r
-      Size = StrSize (NewString) - Size;\r
-    }\r
-    //\r
-    // If we are about to copy the offset of the string that follows the changed string make\r
-    // sure that the offsets are adjusted accordingly\r
-    //\r
-    if ((Index > *Reference) && !ResetStrings) {\r
-      CopyMem (&Offset, &StringPointer[Index], sizeof (RELOFST));\r
-      Offset = (RELOFST) (Offset + Size);\r
-      CopyMem (&StringPointer[Index], &Offset, sizeof (RELOFST));\r
-    }\r
-    //\r
-    // If we are adding a string that means we will have an extra string pointer that will affect all string offsets\r
-    //\r
-    if (AddString) {\r
-      CopyMem (&Offset, &StringPointer[Index], sizeof (RELOFST));\r
-      Offset = (UINT32) (Offset + sizeof (RELOFST));\r
-      CopyMem (&StringPointer[Index], &Offset, sizeof (RELOFST));\r
-    }\r
-    //\r
-    // If resetting the strings, we need to reduce the offset by the difference in the strings\r
-    //\r
-    if (ResetStrings) {\r
-      CopyMem (&Length, &StringPointer[Index], sizeof (RELOFST));\r
-      Length = Length - ((RELOFST) (OriginalStringCount - TotalStringCount) * sizeof (RELOFST));\r
-      CopyMem (&StringPointer[Index], &Length, sizeof (RELOFST));\r
-    }\r
-    //\r
-    // Notice that if the string was being added as a new token, we don't have to worry about the\r
-    // offsets changing in the other indexes\r
-    //\r
-    CopyMem (((CHAR8 *) (&NewBuffer->IfrData) + Count), &StringPointer[Index], sizeof (RELOFST));\r
-    Count = Count + sizeof (RELOFST);\r
-    StringCount++;\r
-  }\r
-  //\r
-  // If we are adding a new string the above for loop did not copy the offset for us\r
-  //\r
-  if (AddString) {\r
-    //\r
-    // Since the Index is pointing to the beginning of the first string, we need to gather the size of the previous\r
-    // offset's string and create an offset to our new string.\r
-    //\r
-    CopyMem (&Offset, &StringPointer[Index - 1], sizeof (RELOFST));\r
-    StringLocation  = (UINT8 *) StringPack;\r
-    StringLocation  = StringLocation + Offset - sizeof (RELOFST);\r
-\r
-    //\r
-    // Since StringPack is a packed structure, we need to size it carefully (byte-wise) to avoid alignment issues\r
-    //\r
-    for (Length = 0;\r
-         (StringLocation[Length] != 0) || (StringLocation[Length + 1] != 0);\r
-         Length = (RELOFST) (Length + 2)\r
-        )\r
-      ;\r
-    Length      = (RELOFST) (Length + 2);\r
-\r
-    StringSize  = (RELOFST) (Offset + Length);\r
-\r
-    //\r
-    // Copy the new string offset\r
-    //\r
-    CopyMem (((CHAR8 *) (&NewBuffer->IfrData) + Count), &StringSize, sizeof (RELOFST));\r
-    Count = Count + sizeof (RELOFST);\r
-\r
-    CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-    Length = Length + sizeof (RELOFST);\r
-    CopyMem (&StringPack->Header.Length, &Length, sizeof (UINT32));\r
-  }\r
-  //\r
-  // Set Location to the First String\r
-  //\r
-  if (ResetStrings) {\r
-    Index = OriginalStringCount;\r
-  }\r
-  //\r
-  // Set Location to the First String\r
-  //\r
-  Location  = (UINT8 *) &StringPointer[Index];\r
-  Index     = 0;\r
-\r
-  //\r
-  // Keep copying strings until you run into two CHAR16's in a row that are NULL\r
-  //\r
-  do {\r
-    if ((*Reference == Increment) && !AddString) {\r
-      StringLocation = ((UINT8 *) (&NewBuffer->IfrData) + Count);\r
-      CopyMem (StringLocation, NewString, StrSize (NewString));\r
-\r
-      //\r
-      // Advance the destination location by Count number of bytes\r
-      //\r
-      Count = Count + StrSize (NewString);\r
-\r
-      //\r
-      // Add the difference between the new string and the old string to the length\r
-      //\r
-      CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-\r
-      //\r
-      // Since StringPack is a packed structure, we need to size it carefully (byte-wise) to avoid alignment issues\r
-      //\r
-      StringLocation = (UINT8 *) &Location[Index];\r
-      for (Offset = 0;\r
-           (StringLocation[Offset] != 0) || (StringLocation[Offset + 1] != 0);\r
-           Offset = (RELOFST) (Offset + 2)\r
-          )\r
-        ;\r
-      Offset  = (RELOFST) (Offset + 2);\r
-\r
-      Length  = Length + (UINT32) StrSize (NewString) - Offset;\r
-\r
-      CopyMem (&StringPack->Header.Length, &Length, sizeof (UINT32));\r
-    } else {\r
-      StringLocation = (UINT8 *) &Location[Index];\r
-      for (Offset = 0;\r
-           (StringLocation[Offset] != 0) || (StringLocation[Offset + 1] != 0);\r
-           Offset = (RELOFST) (Offset + 2)\r
-          )\r
-        ;\r
-      Offset = (RELOFST) (Offset + 2);\r
-\r
-      CopyMem (((CHAR8 *) (&NewBuffer->IfrData) + Count), StringLocation, Offset);\r
-\r
-      //\r
-      // Advance the destination location by Count number of bytes\r
-      //\r
-      Count = Count + Offset;\r
-    }\r
-    //\r
-    // Retrieve the number of characters to advance the index - should land at beginning of next string\r
-    //\r
-    Index = Index + Offset;\r
-    Increment++;\r
-    StringCount--;\r
-    Offset = 0;\r
-  } while (StringCount > 0);\r
-\r
-  //\r
-  // If we are adding a new string, then the above do/while will not suffice\r
-  //\r
-  if (AddString) {\r
-    Offset = (RELOFST) StrSize (NewString);\r
-    CopyMem (((CHAR8 *) (&NewBuffer->IfrData) + Count), NewString, Offset);\r
-\r
-    Count = Count + StrSize (NewString);\r
-    CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-    Length = Length + (UINT32) StrSize (NewString);\r
-    CopyMem (&StringPack->Header.Length, &Length, sizeof (UINT32));\r
-  }\r
-\r
-  if (ResetStrings) {\r
-    //\r
-    // Skip the remainder of strings in the string package\r
-    //\r
-    StringCount = OriginalStringCount - TotalStringCount;\r
-\r
-    while (StringCount > 0) {\r
-      StringLocation = (UINT8 *) &Location[Index];\r
-      for (Offset = 0;\r
-           (StringLocation[Offset] != 0) || (StringLocation[Offset + 1] != 0);\r
-           Offset = (RELOFST) (Offset + 2)\r
-          )\r
-        ;\r
-      Offset  = (RELOFST) (Offset + 2);\r
-      Index   = Index + Offset;\r
-      StringCount--;\r
-\r
-      //\r
-      // Adjust the size of the string pack by the string size we just skipped.\r
-      // Also reduce the length by the size of a RelativeOffset value since we\r
-      // obviously would have skipped that as well.\r
-      //\r
-      CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-      Length = Length - Offset - sizeof (RELOFST);\r
-      CopyMem (&StringPack->Header.Length, &Length, sizeof (UINT32));\r
-    }\r
-  }\r
-\r
-  StringPack = (EFI_HII_STRING_PACK *) &Location[Index];\r
-\r
-  CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-  for (; Length != 0;) {\r
-\r
-    CopyMem (((CHAR8 *) (&NewBuffer->IfrData) + Count), StringPack, Length);\r
-\r
-    Count       = Count + Length;\r
-    StringPack  = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + Length);\r
-    CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-  }\r
-  //\r
-  // Copy the null terminator to the new buffer\r
-  //\r
-  CopyMem (((CHAR8 *) (&NewBuffer->IfrData) + Count), StringPack, sizeof (EFI_HII_STRING_PACK));\r
-\r
-  //\r
-  // Based on if there is IFR data in this package instance, determine\r
-  // what the location is of the beginning of the string data.\r
-  //\r
-  if (StringPackageInstance->IfrSize > 0) {\r
-    Location      = (UINT8 *) (&StringPackageInstance->IfrData) + StringPackageInstance->IfrSize;\r
-    StringPack    = (EFI_HII_STRING_PACK *) Location;\r
-    Location      = (UINT8 *) (&NewBuffer->IfrData) + NewBuffer->IfrSize;\r
-    NewStringPack = (EFI_HII_STRING_PACK *) Location;\r
-  } else {\r
-    StringPack    = (EFI_HII_STRING_PACK *) (&StringPackageInstance->IfrData);\r
-    NewStringPack = (EFI_HII_STRING_PACK *) (&NewBuffer->IfrData);\r
-  }\r
-\r
-  CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-  for (; Length != 0;) {\r
-    //\r
-    // Since we updated the old version of the string data as we moved things over\r
-    // And we had a chicken-egg problem with the data we copied, let's post-fix the new\r
-    // buffer with accurate length data.\r
-    //\r
-    CopyMem (&Count, &NewStringPack->Header.Length, sizeof (UINT32));\r
-    CopyMem (&NewStringPack->Header.Length, &StringPack->Header.Length, sizeof (UINT32));\r
-    CopyMem (&StringPack->Header.Length, &Count, sizeof (UINT32));\r
-\r
-    CopyMem (&Count, &NewStringPack->Header.Length, sizeof (UINT32));\r
-    NewStringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (NewStringPack) + Count);\r
-    CopyMem (&Count, &StringPack->Header.Length, sizeof (UINT32));\r
-    StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + Count);\r
-    CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-  }\r
-\r
-  GetPackSize ((VOID *) ((CHAR8 *) (&NewBuffer->IfrData) + NewBuffer->IfrSize), &NewBuffer->StringSize, NULL);\r
-\r
-  //\r
-  // Search through the handles until the requested handle is found.\r
-  //\r
-  for (HandleDatabase = HiiData->DatabaseHead;\r
-       HandleDatabase->Handle != 0;\r
-       HandleDatabase = HandleDatabase->NextHandleDatabase\r
-      ) {\r
-    if (HandleDatabase->Handle == StringPackageInstance->Handle) {\r
-      //\r
-      // Free the previous buffer associated with this handle, and assign the new buffer to the handle\r
-      //\r
-      FreePool (HandleDatabase->Buffer);\r
-      HandleDatabase->Buffer = NewBuffer;\r
-      break;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-HiiNewString (\r
-  IN     EFI_HII_PROTOCOL       *This,\r
-  IN     CHAR16                 *Language,\r
-  IN     EFI_HII_HANDLE         Handle,\r
-  IN OUT STRING_REF             *Reference,\r
-  IN     CHAR16                 *NewString\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This function allows a new String to be added to an already existing String Package.\r
-  We will make a buffer the size of the package + StrSize of the new string.  We will\r
-  copy the string package that first gets changed and the following language packages until\r
-  we encounter the NULL string package.  All this time we will ensure that the offsets have\r
-  been adjusted.  \r
-\r
-Arguments:\r
-  \r
-Returns: \r
-\r
---*/\r
-{\r
-  UINTN       Index;\r
-  CHAR16      *LangCodes;\r
-  CHAR16      Lang[4];\r
-  STRING_REF  OriginalValue;\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // To avoid a warning 4 uninitialized variable warning\r
-  //\r
-  Status = EFI_SUCCESS;\r
-\r
-  Status = HiiGetPrimaryLanguages (\r
-            This,\r
-            Handle,\r
-            &LangCodes\r
-            );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    OriginalValue = *Reference;\r
-\r
-    if (Language == NULL) {\r
-      for (Index = 0; LangCodes[Index] != 0; Index += 3) {\r
-        *Reference = OriginalValue;\r
-        CopyMem (Lang, &LangCodes[Index], 6);\r
-        Lang[3] = 0;\r
-        Status = HiiNewString2 (\r
-                  This,\r
-                  Lang,\r
-                  Handle,\r
-                  Reference,\r
-                  NewString,\r
-                  FALSE\r
-                  );\r
-\r
-      }\r
-    } else {\r
-      Status = HiiNewString2 (\r
-                This,\r
-                Language,\r
-                Handle,\r
-                Reference,\r
-                NewString,\r
-                FALSE\r
-                );\r
-    }\r
-\r
-    FreePool (LangCodes);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-HiiResetStrings (\r
-  IN     EFI_HII_PROTOCOL   *This,\r
-  IN     EFI_HII_HANDLE     Handle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-    This function removes any new strings that were added after the initial string export for this handle.\r
-\r
-Arguments:\r
-\r
-Returns: \r
-\r
---*/\r
-{\r
-  UINTN       Index;\r
-  CHAR16      *LangCodes;\r
-  CHAR16      Lang[4];\r
-  STRING_REF  Reference;\r
-  CHAR16      NewString;\r
-  EFI_STATUS  Status;\r
-\r
-  Reference = 1;\r
-  NewString = 0;\r
-\r
-  HiiGetPrimaryLanguages (\r
-    This,\r
-    Handle,\r
-    &LangCodes\r
-    );\r
-\r
-  for (Index = 0; LangCodes[Index] != 0; Index += 3) {\r
-    CopyMem (Lang, &LangCodes[Index], 6);\r
-    Lang[3] = 0;\r
-    Status = HiiNewString2 (\r
-              This,\r
-              Lang,\r
-              Handle,\r
-              &Reference,\r
-              &NewString,\r
-              TRUE\r
-              );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  FreePool (LangCodes);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-HiiGetString (\r
-  IN     EFI_HII_PROTOCOL    *This,\r
-  IN     EFI_HII_HANDLE      Handle,\r
-  IN     STRING_REF          Token,\r
-  IN     BOOLEAN             Raw,\r
-  IN     CHAR16              *LanguageString,\r
-  IN OUT UINTN               *BufferLengthTemp,\r
-  OUT    EFI_STRING          StringBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  This function extracts a string from a package already registered with the EFI HII database.\r
-\r
-Arguments:\r
-  This            - A pointer to the EFI_HII_PROTOCOL instance.\r
-  Handle          - The HII handle on which the string resides.\r
-  Token           - The string token assigned to the string.\r
-  Raw             - If TRUE, the string is returned unedited in the internal storage format described\r
-                    above. If false, the string returned is edited by replacing <cr> with <space> \r
-                    and by removing special characters such as the <wide> prefix.\r
-  LanguageString  - Pointer to a NULL-terminated string containing a single ISO 639-2 language\r
-                    identifier, indicating the language to print. If the LanguageString is empty (starts\r
-                    with a NULL), the default system language will be used to determine the language.\r
-  BufferLength    - Length of the StringBuffer. If the status reports that the buffer width is too\r
-                    small, this parameter is filled with the length of the buffer needed.\r
-  StringBuffer    - The buffer designed to receive the characters in the string. Type EFI_STRING is\r
-                    defined in String.\r
-\r
-Returns: \r
-  EFI_INVALID_PARAMETER - If input parameter is invalid.\r
-  EFI_BUFFER_TOO_SMALL  - If the *BufferLength is too small.\r
-  EFI_SUCCESS           - Operation is successful.\r
-  \r
---*/\r
-{\r
-  EFI_HII_PACKAGE_INSTANCE  *PackageInstance;\r
-  EFI_HII_PACKAGE_INSTANCE  *StringPackageInstance;\r
-  EFI_HII_DATA              *HiiData;\r
-  EFI_HII_HANDLE_DATABASE   *HandleDatabase;\r
-  EFI_HII_STRING_PACK       *StringPack;\r
-  RELOFST                   *StringPointer;\r
-  EFI_STATUS                Status;\r
-  UINTN                     DataSize;\r
-  CHAR8                     Lang[3];\r
-  CHAR16                    Language[3];\r
-  UINT32                    Length;\r
-  UINTN                     Count;\r
-  RELOFST                   Offset;\r
-  UINT16                    *Local;\r
-  UINT16                    Zero;\r
-  UINT16                    Narrow;\r
-  UINT16                    Wide;\r
-  UINT16                    NoBreak;\r
-  BOOLEAN                   LangFound;\r
-  UINT16                    *BufferLength = (UINT16 *) BufferLengthTemp;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  LangFound       = TRUE;\r
-\r
-  DataSize        = sizeof (Lang);\r
-\r
-  HiiData         = EFI_HII_DATA_FROM_THIS (This);\r
-\r
-  PackageInstance = NULL;\r
-  Zero            = 0;\r
-  Narrow          = NARROW_CHAR;\r
-  Wide            = WIDE_CHAR;\r
-  NoBreak         = NON_BREAKING_CHAR;\r
-\r
-  //\r
-  // Check numeric value against the head of the database\r
-  //\r
-  for (HandleDatabase = HiiData->DatabaseHead;\r
-       HandleDatabase != NULL;\r
-       HandleDatabase = HandleDatabase->NextHandleDatabase\r
-      ) {\r
-    //\r
-    // Match the numeric value with the database entry - if matched, extract PackageInstance\r
-    //\r
-    if (Handle == HandleDatabase->Handle) {\r
-      PackageInstance = HandleDatabase->Buffer;\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // No handle was found - error condition\r
-  //\r
-  if (PackageInstance == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = ValidatePack (This, PackageInstance, &StringPackageInstance, NULL);\r
-\r
-  //\r
-  // If there is no specified language, assume the system default language\r
-  //\r
-  if (LanguageString == NULL) {\r
-    //\r
-    // Get system default language\r
-    //\r
-    Status = gRT->GetVariable (\r
-                    (CHAR16 *) L"Lang",\r
-                    &gEfiGlobalVariableGuid,\r
-                    NULL,\r
-                    &DataSize,\r
-                    Lang\r
-                    );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // If Lang doesn't exist, just use the first language you find\r
-      //\r
-      LangFound = FALSE;\r
-      goto LangNotFound;\r
-    }\r
-    //\r
-    // Convert the ASCII Lang variable to a Unicode Language variable\r
-    //\r
-    AsciiToUnicode ((UINT8 *)Lang, Language);\r
-  } else {\r
-    //\r
-    // Copy input ISO value to Language variable\r
-    //\r
-    CopyMem (Language, LanguageString, 6);\r
-  }\r
-  //\r
-  // Based on if there is IFR data in this package instance, determine\r
-  // what the location is of the beginning of the string data.\r
-  //\r
-LangNotFound:\r
-  if (StringPackageInstance->IfrSize > 0) {\r
-    StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (&StringPackageInstance->IfrData) + StringPackageInstance->IfrSize);\r
-  } else {\r
-    StringPack = (EFI_HII_STRING_PACK *) (&StringPackageInstance->IfrData);\r
-  }\r
-  //\r
-  // If Token is 0, extract entire string package\r
-  //\r
-  if (Token == 0) {\r
-    //\r
-    // Compute the entire string pack length, including all languages' and the terminating pack's.\r
-    //\r
-    Length = 0;\r
-    while (0 != StringPack->Header.Length) {\r
-      Length += StringPack->Header.Length;\r
-      StringPack = (VOID*)(((UINT8*)StringPack) + StringPack->Header.Length);\r
-    }\r
-    //\r
-    // Back to the start of package.\r
-    //\r
-    StringPack = (VOID*)(((UINT8*)StringPack) - Length); \r
-    //\r
-    // Terminating zero sub-pack.\r
-    //\r
-    Length += sizeof (EFI_HII_STRING_PACK); \r
-\r
-    //\r
-    // If trying to get the entire string package and have insufficient space.  Return error.\r
-    //\r
-    if (Length > *BufferLength || StringBuffer == NULL) {\r
-      *BufferLength = (UINT16)Length;\r
-      return EFI_BUFFER_TOO_SMALL;\r
-    }\r
-    //\r
-    // Copy the Pack to the caller's buffer.\r
-    //\r
-    *BufferLength = (UINT16)Length;\r
-    CopyMem (StringBuffer, StringPack, Length);\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // There may be multiple instances packed together of strings\r
-  // so we must walk the self describing structures until we encounter\r
-  // what we are looking for, and then extract the string we are looking for\r
-  //\r
-  CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-  for (; Length != 0;) {\r
-    //\r
-    // If passed in Language ISO value is in this string pack's language string\r
-    // then we are dealing with the strings we want.\r
-    //\r
-    CopyMem (&Offset, &StringPack->LanguageNameString, sizeof (RELOFST));\r
-    Status = HiiCompareLanguage ((CHAR16 *) ((CHAR8 *) (StringPack) + Offset), Language);\r
-\r
-    //\r
-    // If we cannot find the lang variable, we skip this check and use the first language available\r
-    //\r
-    if (LangFound) {\r
-      if (EFI_ERROR (Status)) {\r
-        StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + Length);\r
-        CopyMem (&Length, &StringPack->Header.Length, sizeof (UINT32));\r
-        continue;\r
-      }\r
-    }\r
-\r
-    StringPointer = (RELOFST *) (StringPack + 1);\r
-\r
-    //\r
-    // We have the right string package - size it, and copy it to the StringBuffer\r
-    //\r
-    if (Token >= StringPack->NumStringPointers) {\r
-      return EFI_INVALID_PARAMETER;\r
-    } else {\r
-      CopyMem (&Offset, &StringPointer[Token], sizeof (RELOFST));\r
-    }\r
-    //\r
-    // Since StringPack is a packed structure, we need to determine the string's\r
-    // size safely, thus byte-wise.  Post-increment the size to include the null-terminator\r
-    //\r
-    Local = (UINT16 *) ((CHAR8 *) (StringPack) + Offset);\r
-    for (Count = 0; CompareMem (&Local[Count], &Zero, 2); Count++)\r
-      ;\r
-    Count++;\r
-\r
-    Count = Count * sizeof (CHAR16);;\r
-\r
-    if (*BufferLength >= Count && StringBuffer != NULL) {\r
-      //\r
-      // Copy the string to the user's buffer\r
-      //\r
-      if (Raw) {\r
-        CopyMem (StringBuffer, Local, Count);\r
-      } else {\r
-        for (Count = 0; CompareMem (Local, &Zero, 2); Local++) {\r
-          //\r
-          // Skip "Narraw, Wide, NoBreak"\r
-          //\r
-          if (CompareMem (Local, &Narrow,  2) &&\r
-              CompareMem (Local, &Wide,    2) && \r
-              CompareMem (Local, &NoBreak, 2)) {          \r
-            CopyMem (&StringBuffer[Count++], Local, 2);          \r
-          }        \r
-        } \r
-        //\r
-        // Add "NULL" at the end.\r
-        //\r
-        CopyMem (&StringBuffer[Count], &Zero, 2);\r
-        Count++;\r
-        Count *= sizeof (CHAR16);\r
-      }\r
-\r
-      *BufferLength = (UINT16) Count;\r
-      return EFI_SUCCESS;\r
-    } else {\r
-      *BufferLength = (UINT16) Count;\r
-      return EFI_BUFFER_TOO_SMALL;\r
-    }\r
-\r
-  }\r
-\r
-  LangFound = FALSE;\r
-  goto LangNotFound;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-HiiGetLine (\r
-  IN     EFI_HII_PROTOCOL   *This,\r
-  IN     EFI_HII_HANDLE     Handle,\r
-  IN     STRING_REF         Token,\r
-  IN OUT UINT16             *Index,\r
-  IN     UINT16             LineWidth,\r
-  IN     CHAR16             *LanguageString,\r
-  IN OUT UINT16             *BufferLength,\r
-  OUT    EFI_STRING         StringBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function allows a program to extract a part of a string of not more than a given width.  \r
-  With repeated calls, this allows a calling program to extract "lines" of text that fit inside \r
-  columns.  The effort of measuring the fit of strings inside columns is localized to this call.\r
-\r
-Arguments:\r
-\r
-Returns: \r
-\r
---*/\r
-{\r
-  UINTN                     Count;\r
-  EFI_HII_PACKAGE_INSTANCE  *PackageInstance;\r
-  EFI_HII_PACKAGE_INSTANCE  *StringPackageInstance;\r
-  EFI_HII_DATA              *HiiData;\r
-  EFI_HII_HANDLE_DATABASE   *HandleDatabase;\r
-  EFI_HII_STRING_PACK       *StringPack;\r
-  RELOFST                   *StringPointer;\r
-  CHAR16                    *Location;\r
-  EFI_STATUS                Status;\r
-  UINTN                     DataSize;\r
-  CHAR8                     Lang[3];\r
-  CHAR16                    Language[3];\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  HiiData         = EFI_HII_DATA_FROM_THIS (This);\r
-\r
-  HandleDatabase  = HiiData->DatabaseHead;\r
-\r
-  PackageInstance = NULL;\r
-  DataSize        = 4;\r
-\r
-  //\r
-  // Check numeric value against the head of the database\r
-  //\r
-  for (; HandleDatabase != NULL; HandleDatabase = HandleDatabase->NextHandleDatabase) {\r
-    //\r
-    // Match the numeric value with the database entry - if matched, extract PackageInstance\r
-    //\r
-    if (Handle == HandleDatabase->Handle) {\r
-      PackageInstance = HandleDatabase->Buffer;\r
-    }\r
-  }\r
-  //\r
-  // No handle was found - error condition\r
-  //\r
-  if (PackageInstance == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = ValidatePack (This, PackageInstance, &StringPackageInstance, NULL);\r
-\r
-  //\r
-  // If there is no specified language, assume the system default language\r
-  //\r
-  if (LanguageString == NULL) {\r
-    //\r
-    // Get system default language\r
-    //\r
-    Status = gRT->GetVariable (\r
-                    (CHAR16 *) L"Lang",\r
-                    &gEfiGlobalVariableGuid,\r
-                    NULL,\r
-                    &DataSize,\r
-                    Lang\r
-                    );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    //\r
-    // Convert the ASCII Lang variable to a Unicode Language variable\r
-    //\r
-    AsciiToUnicode ((UINT8 *)Lang, Language);\r
-  } else {\r
-    //\r
-    // Copy input ISO value to Language variable\r
-    //\r
-    CopyMem (Language, LanguageString, 6);\r
-  }\r
-  //\r
-  // Based on if there is IFR data in this package instance, determine\r
-  // what the location is of the beginning of the string data.\r
-  //\r
-  if (StringPackageInstance->IfrSize > 0) {\r
-    StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (&StringPackageInstance->IfrData) + StringPackageInstance->IfrSize);\r
-  } else {\r
-    StringPack = (EFI_HII_STRING_PACK *) (&StringPackageInstance->IfrData);\r
-  }\r
-\r
-  StringPointer = (RELOFST *) (StringPack + 1);\r
-\r
-  //\r
-  // There may be multiple instances packed together of strings\r
-  // so we must walk the self describing structures until we encounter\r
-  // what we are looking for, and then extract the string we are looking for\r
-  //\r
-  for (; StringPack->Header.Length != 0;) {\r
-    //\r
-    // If passed in Language ISO value is in this string pack's language string\r
-    // then we are dealing with the strings we want.\r
-    //\r
-    Status = HiiCompareLanguage ((CHAR16 *) ((CHAR8 *) (StringPack) + StringPack->LanguageNameString), Language);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length);\r
-      continue;\r
-    }\r
-\r
-    Location = (CHAR16 *) ((CHAR8 *) (StringPack) + StringPointer[Token] +*Index * 2);\r
-\r
-    //\r
-    // If the size of the remaining string is less than the LineWidth\r
-    // then copy the entire thing\r
-    //\r
-    if (StrSize (Location) <= LineWidth) {\r
-      if (*BufferLength >= StrSize (Location)) {\r
-        StrCpy (StringBuffer, Location);\r
-        return EFI_SUCCESS;\r
-      } else {\r
-        *BufferLength = (UINT16) StrSize (Location);\r
-        return EFI_BUFFER_TOO_SMALL;\r
-      }\r
-    } else {\r
-      //\r
-      // Rewind the string from the maximum size until we see a space the break the line\r
-      //\r
-      for (Count = LineWidth; Location[Count] != 0x0020; Count--)\r
-        ;\r
-\r
-      //\r
-      // Put the index at the next character\r
-      //\r
-      *Index = (UINT16) (Count + 1);\r
-\r
-      if (*BufferLength >= Count) {\r
-        StrnCpy (StringBuffer, Location, Count);\r
-        return EFI_SUCCESS;\r
-      } else {\r
-        *BufferLength = (UINT16) Count;\r
-        return EFI_BUFFER_TOO_SMALL;\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-HiiCompareLanguage (\r
-  IN  CHAR16                *LanguageStringLocation,\r
-  IN  CHAR16                *Language\r
-  )\r
-{\r
-  UINT8   *Local;\r
-  UINTN   Index;\r
-  CHAR16  *InputString;\r
-  CHAR16  *OriginalInputString;\r
-\r
-  //\r
-  // Allocate a temporary buffer for InputString\r
-  //\r
-  InputString = AllocateZeroPool (0x100);\r
-\r
-  ASSERT (InputString);\r
-\r
-  OriginalInputString = InputString;\r
-\r
-  Local               = (UINT8 *) LanguageStringLocation;\r
-\r
-  //\r
-  // Determine the size of this packed string safely (e.g. access by byte), post-increment\r
-  // to include the null-terminator\r
-  //\r
-  for (Index = 0; Local[Index] != 0; Index = Index + 2)\r
-    ;\r
-  //\r
-  // MARMAR  Index = Index + 2;\r
-  //\r
-  // This is a packed structure that this location comes from, so let's make sure\r
-  // the value is aligned by copying it to a local variable and working on it.\r
-  //\r
-  CopyMem (InputString, LanguageStringLocation, Index);\r
-\r
-  for (Index = 0; Index < 3; Index++) {\r
-    InputString[Index]  = (CHAR16) (InputString[Index] | 0x20);\r
-    Language[Index]     = (CHAR16) (Language[Index] | 0x20);\r
-  }\r
-  //\r
-  // If the Language is the same return success\r
-  //\r
-  if (CompareMem (LanguageStringLocation, Language, 6) == 0) {\r
-    FreePool (InputString);\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Skip the first three letters that comprised the primary language,\r
-  // see if what is being compared against is a secondary language\r
-  //\r
-  InputString = InputString + 3;\r
-\r
-  //\r
-  // If the Language is not the same as the Primary language, see if there are any\r
-  // secondary languages, and if there are see if we have a match.  If not, return an error.\r
-  //\r
-  for (Index = 0; InputString[Index] != 0; Index = Index + 3) {\r
-    //\r
-    // Getting in here means we have a secondary language\r
-    //\r
-    if (CompareMem (&InputString[Index], Language, 6) == 0) {\r
-      FreePool (InputString);\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-  //\r
-  // If nothing was found, return the error\r
-  //\r
-  FreePool (OriginalInputString);\r
-  return EFI_NOT_FOUND;\r
-\r
-}\r