]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c
Rollback patch 14537 & 14538, because patch 14537 is not tested by Laszlo Ersek,...
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / ProcessOptions.c
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c
deleted file mode 100644 (file)
index aca043a..0000000
+++ /dev/null
@@ -1,1286 +0,0 @@
-/** @file\r
-Implementation for handling the User Interface option processing.\r
-\r
-\r
-Copyright (c) 2004 - 2012, 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
-\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
-#include "FormDisplay.h"\r
-\r
-/**\r
-  Concatenate a narrow string to another string.\r
-\r
-  @param Destination The destination string.\r
-  @param Source      The source string. The string to be concatenated.\r
-                     to the end of Destination.\r
-\r
-**/\r
-VOID\r
-NewStrCat (\r
-  IN OUT CHAR16               *Destination,\r
-  IN     CHAR16               *Source\r
-  )\r
-{\r
-  UINTN Length;\r
-\r
-  for (Length = 0; Destination[Length] != 0; Length++)\r
-    ;\r
-\r
-  //\r
-  // We now have the length of the original string\r
-  // We can safely assume for now that we are concatenating a narrow value to this string.\r
-  // For instance, the string is "XYZ" and cat'ing ">"\r
-  // If this assumption changes, we need to make this routine a bit more complex\r
-  //\r
-  Destination[Length] = NARROW_CHAR;\r
-  Length++;\r
-\r
-  StrCpy (Destination + Length, Source);\r
-}\r
-\r
-/**\r
-  Compare two Hii value.\r
-\r
-  @param  Value1                 Expression value to compare on left-hand.\r
-  @param  Value2                 Expression value to compare on right-hand.\r
-  @param  Result                 Return value after compare.\r
-                                 retval 0                      Two operators equal.\r
-                                 return Positive value if Value1 is greater than Value2.\r
-                                 retval Negative value if Value1 is less than Value2.\r
-  @param  HiiHandle              Only required for string compare.\r
-\r
-  @retval other                  Could not perform compare on two values.\r
-  @retval EFI_SUCCESS            Compare the value success.\r
-\r
-**/\r
-EFI_STATUS\r
-CompareHiiValue (\r
-  IN  EFI_HII_VALUE   *Value1,\r
-  IN  EFI_HII_VALUE   *Value2,\r
-  OUT INTN            *Result,\r
-  IN  EFI_HII_HANDLE  HiiHandle OPTIONAL\r
-  )\r
-{\r
-  INT64   Temp64;\r
-  CHAR16  *Str1;\r
-  CHAR16  *Str2;\r
-  UINTN   Len;\r
-\r
-  if (Value1->Type >= EFI_IFR_TYPE_OTHER || Value2->Type >= EFI_IFR_TYPE_OTHER ) {\r
-    if (Value1->Type != EFI_IFR_TYPE_BUFFER && Value2->Type != EFI_IFR_TYPE_BUFFER) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  }\r
-\r
-  if (Value1->Type == EFI_IFR_TYPE_STRING || Value2->Type == EFI_IFR_TYPE_STRING ) {\r
-    if (Value1->Type != Value2->Type) {\r
-      //\r
-      // Both Operator should be type of String\r
-      //\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    if (Value1->Value.string == 0 || Value2->Value.string == 0) {\r
-      //\r
-      // StringId 0 is reserved\r
-      //\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (Value1->Value.string == Value2->Value.string) {\r
-      *Result = 0;\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    Str1 = GetToken (Value1->Value.string, HiiHandle);\r
-    if (Str1 == NULL) {\r
-      //\r
-      // String not found\r
-      //\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    Str2 = GetToken (Value2->Value.string, HiiHandle);\r
-    if (Str2 == NULL) {\r
-      FreePool (Str1);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-\r
-    *Result = StrCmp (Str1, Str2);\r
-\r
-    FreePool (Str1);\r
-    FreePool (Str2);\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Value1->Type == EFI_IFR_TYPE_BUFFER || Value2->Type == EFI_IFR_TYPE_BUFFER ) {\r
-    if (Value1->Type != Value2->Type) {\r
-      //\r
-      // Both Operator should be type of Buffer.\r
-      //\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    Len = Value1->BufferLen > Value2->BufferLen ? Value2->BufferLen : Value1->BufferLen;\r
-    *Result = CompareMem (Value1->Buffer, Value2->Buffer, Len);\r
-    if ((*Result == 0) && (Value1->BufferLen != Value2->BufferLen))\r
-    {\r
-      //\r
-      // In this case, means base on samll number buffer, the data is same\r
-      // So which value has more data, which value is bigger.\r
-      //\r
-      *Result = Value1->BufferLen > Value2->BufferLen ? 1 : -1;\r
-    }\r
-    return EFI_SUCCESS;\r
-  }  \r
-\r
-  //\r
-  // Take remain types(integer, boolean, date/time) as integer\r
-  //\r
-  Temp64 = (INT64) (Value1->Value.u64 - Value2->Value.u64);\r
-  if (Temp64 > 0) {\r
-    *Result = 1;\r
-  } else if (Temp64 < 0) {\r
-    *Result = -1;\r
-  } else {\r
-    *Result = 0;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Search an Option of a Question by its value.\r
-\r
-  @param  Question               The Question\r
-  @param  OptionValue            Value for Option to be searched.\r
-\r
-  @retval Pointer                Pointer to the found Option.\r
-  @retval NULL                   Option not found.\r
-\r
-**/\r
-DISPLAY_QUESTION_OPTION *\r
-ValueToOption (\r
-  IN FORM_DISPLAY_ENGINE_STATEMENT   *Question,\r
-  IN EFI_HII_VALUE                   *OptionValue\r
-  )\r
-{\r
-  LIST_ENTRY               *Link;\r
-  DISPLAY_QUESTION_OPTION  *Option;\r
-  INTN                     Result;\r
-  EFI_HII_VALUE            Value;\r
-\r
-  Link = GetFirstNode (&Question->OptionListHead);\r
-  while (!IsNull (&Question->OptionListHead, Link)) {\r
-    Option = DISPLAY_QUESTION_OPTION_FROM_LINK (Link);\r
-\r
-    ZeroMem (&Value, sizeof (EFI_HII_VALUE));\r
-    Value.Type = Option->OptionOpCode->Type;\r
-    CopyMem (&Value.Value, &Option->OptionOpCode->Value, Option->OptionOpCode->Header.Length - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value));\r
-    \r
-    if ((CompareHiiValue (&Value, OptionValue, &Result, NULL) == EFI_SUCCESS) && (Result == 0)) {\r
-      return Option;\r
-    }\r
-\r
-    Link = GetNextNode (&Question->OptionListHead, Link);\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-\r
-/**\r
-  Return data element in an Array by its Index.\r
-\r
-  @param  Array                  The data array.\r
-  @param  Type                   Type of the data in this array.\r
-  @param  Index                  Zero based index for data in this array.\r
-\r
-  @retval Value                  The data to be returned\r
-\r
-**/\r
-UINT64\r
-GetArrayData (\r
-  IN VOID                     *Array,\r
-  IN UINT8                    Type,\r
-  IN UINTN                    Index\r
-  )\r
-{\r
-  UINT64 Data;\r
-\r
-  ASSERT (Array != NULL);\r
-\r
-  Data = 0;\r
-  switch (Type) {\r
-  case EFI_IFR_TYPE_NUM_SIZE_8:\r
-    Data = (UINT64) *(((UINT8 *) Array) + Index);\r
-    break;\r
-\r
-  case EFI_IFR_TYPE_NUM_SIZE_16:\r
-    Data = (UINT64) *(((UINT16 *) Array) + Index);\r
-    break;\r
-\r
-  case EFI_IFR_TYPE_NUM_SIZE_32:\r
-    Data = (UINT64) *(((UINT32 *) Array) + Index);\r
-    break;\r
-\r
-  case EFI_IFR_TYPE_NUM_SIZE_64:\r
-    Data = (UINT64) *(((UINT64 *) Array) + Index);\r
-    break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  return Data;\r
-}\r
-\r
-\r
-/**\r
-  Set value of a data element in an Array by its Index.\r
-\r
-  @param  Array                  The data array.\r
-  @param  Type                   Type of the data in this array.\r
-  @param  Index                  Zero based index for data in this array.\r
-  @param  Value                  The value to be set.\r
-\r
-**/\r
-VOID\r
-SetArrayData (\r
-  IN VOID                     *Array,\r
-  IN UINT8                    Type,\r
-  IN UINTN                    Index,\r
-  IN UINT64                   Value\r
-  )\r
-{\r
-\r
-  ASSERT (Array != NULL);\r
-\r
-  switch (Type) {\r
-  case EFI_IFR_TYPE_NUM_SIZE_8:\r
-    *(((UINT8 *) Array) + Index) = (UINT8) Value;\r
-    break;\r
-\r
-  case EFI_IFR_TYPE_NUM_SIZE_16:\r
-    *(((UINT16 *) Array) + Index) = (UINT16) Value;\r
-    break;\r
-\r
-  case EFI_IFR_TYPE_NUM_SIZE_32:\r
-    *(((UINT32 *) Array) + Index) = (UINT32) Value;\r
-    break;\r
-\r
-  case EFI_IFR_TYPE_NUM_SIZE_64:\r
-    *(((UINT64 *) Array) + Index) = (UINT64) Value;\r
-    break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-}\r
-\r
-/**\r
-  Check whether this value already in the array, if yes, return the index.\r
-\r
-  @param  Array                  The data array.\r
-  @param  Type                   Type of the data in this array.\r
-  @param  Value                  The value to be find.\r
-  @param  Index                  The index in the array which has same value with Value.\r
-  \r
-  @retval   TRUE Found the value in the array.\r
-  @retval   FALSE Not found the value.\r
-\r
-**/\r
-BOOLEAN \r
-FindArrayData (\r
-  IN VOID                     *Array,\r
-  IN UINT8                    Type,\r
-  IN UINT64                   Value,\r
-  OUT UINTN                   *Index OPTIONAL\r
-  )\r
-{\r
-  UINTN  Count;\r
-  UINT64 TmpValue;\r
-  UINT64 ValueComp;\r
-  \r
-  ASSERT (Array != NULL);\r
-\r
-  Count    = 0;\r
-  TmpValue = 0;\r
-\r
-  switch (Type) {\r
-  case EFI_IFR_TYPE_NUM_SIZE_8:\r
-    ValueComp = (UINT8) Value;\r
-    break;\r
-\r
-  case EFI_IFR_TYPE_NUM_SIZE_16:\r
-    ValueComp = (UINT16) Value;\r
-    break;\r
-\r
-  case EFI_IFR_TYPE_NUM_SIZE_32:\r
-    ValueComp = (UINT32) Value;\r
-    break;\r
-\r
-  case EFI_IFR_TYPE_NUM_SIZE_64:\r
-    ValueComp = (UINT64) Value;\r
-    break;\r
-\r
-  default:\r
-    ValueComp = 0;\r
-    break;\r
-  }\r
-\r
-  while ((TmpValue = GetArrayData (Array, Type, Count)) != 0) {\r
-    if (ValueComp == TmpValue) {\r
-      if (Index != NULL) {\r
-        *Index = Count;\r
-      }\r
-      return TRUE;\r
-    }\r
-\r
-    Count ++;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  Print Question Value according to it's storage width and display attributes.\r
-\r
-  @param  Question               The Question to be printed.\r
-  @param  FormattedNumber        Buffer for output string.\r
-  @param  BufferSize             The FormattedNumber buffer size in bytes.\r
-\r
-  @retval EFI_SUCCESS            Print success.\r
-  @retval EFI_BUFFER_TOO_SMALL   Buffer size is not enough for formatted number.\r
-\r
-**/\r
-EFI_STATUS\r
-PrintFormattedNumber (\r
-  IN FORM_DISPLAY_ENGINE_STATEMENT   *Question,\r
-  IN OUT CHAR16               *FormattedNumber,\r
-  IN UINTN                    BufferSize\r
-  )\r
-{\r
-  INT64          Value;\r
-  CHAR16         *Format;\r
-  EFI_HII_VALUE  *QuestionValue;\r
-  EFI_IFR_NUMERIC *NumericOp;\r
-\r
-  if (BufferSize < (21 * sizeof (CHAR16))) {\r
-    return EFI_BUFFER_TOO_SMALL;\r
-  }\r
-\r
-  QuestionValue = &Question->CurrentValue;\r
-  NumericOp     = (EFI_IFR_NUMERIC *) Question->OpCode;\r
-\r
-  Value = (INT64) QuestionValue->Value.u64;\r
-  switch (NumericOp->Flags & EFI_IFR_DISPLAY) {\r
-  case EFI_IFR_DISPLAY_INT_DEC:\r
-    switch (QuestionValue->Type) {\r
-    case EFI_IFR_NUMERIC_SIZE_1:\r
-      Value = (INT64) ((INT8) QuestionValue->Value.u8);\r
-      break;\r
-\r
-    case EFI_IFR_NUMERIC_SIZE_2:\r
-      Value = (INT64) ((INT16) QuestionValue->Value.u16);\r
-      break;\r
-\r
-    case EFI_IFR_NUMERIC_SIZE_4:\r
-      Value = (INT64) ((INT32) QuestionValue->Value.u32);\r
-      break;\r
-\r
-    case EFI_IFR_NUMERIC_SIZE_8:\r
-    default:\r
-      break;\r
-    }\r
-\r
-    if (Value < 0) {\r
-      Value = -Value;\r
-      Format = L"-%ld";\r
-    } else {\r
-      Format = L"%ld";\r
-    }\r
-    break;\r
-\r
-  case EFI_IFR_DISPLAY_UINT_DEC:\r
-    Format = L"%ld";\r
-    break;\r
-\r
-  case EFI_IFR_DISPLAY_UINT_HEX:\r
-    Format = L"%lx";\r
-    break;\r
-\r
-  default:\r
-    return EFI_UNSUPPORTED;\r
-    break;\r
-  }\r
-\r
-  UnicodeSPrint (FormattedNumber, BufferSize, Format, Value);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Draw a pop up windows based on the dimension, number of lines and\r
-  strings specified.\r
-\r
-  @param RequestedWidth  The width of the pop-up.\r
-  @param NumberOfLines   The number of lines.\r
-  @param Marker          The variable argument list for the list of string to be printed.\r
-\r
-**/\r
-VOID\r
-CreateSharedPopUp (\r
-  IN  UINTN                       RequestedWidth,\r
-  IN  UINTN                       NumberOfLines,\r
-  IN  VA_LIST                     Marker\r
-  )\r
-{\r
-  UINTN   Index;\r
-  UINTN   Count;\r
-  CHAR16  Character;\r
-  UINTN   Start;\r
-  UINTN   End;\r
-  UINTN   Top;\r
-  UINTN   Bottom;\r
-  CHAR16  *String;\r
-  UINTN   DimensionsWidth;\r
-  UINTN   DimensionsHeight;\r
-\r
-  DimensionsWidth   = gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn;\r
-  DimensionsHeight  = gStatementDimensions.BottomRow - gStatementDimensions.TopRow;\r
-\r
-  gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());\r
-\r
-  if ((RequestedWidth + 2) > DimensionsWidth) {\r
-    RequestedWidth = DimensionsWidth - 2;\r
-  }\r
-\r
-  //\r
-  // Subtract the PopUp width from total Columns, allow for one space extra on\r
-  // each end plus a border.\r
-  //\r
-  Start     = (DimensionsWidth - RequestedWidth - 2) / 2 + gStatementDimensions.LeftColumn + 1;\r
-  End       = Start + RequestedWidth + 1;\r
-\r
-  Top       = ((DimensionsHeight - NumberOfLines - 2) / 2) + gStatementDimensions.TopRow - 1;\r
-  Bottom    = Top + NumberOfLines + 2;\r
-\r
-  Character = BOXDRAW_DOWN_RIGHT;\r
-  PrintCharAt (Start, Top, Character);\r
-  Character = BOXDRAW_HORIZONTAL;\r
-  for (Index = Start; Index + 2 < End; Index++) {\r
-    PrintCharAt ((UINTN)-1, (UINTN)-1, Character);\r
-  }\r
-\r
-  Character = BOXDRAW_DOWN_LEFT;\r
-  PrintCharAt ((UINTN)-1, (UINTN)-1, Character);\r
-  Character = BOXDRAW_VERTICAL;\r
-\r
-  Count = 0;\r
-  for (Index = Top; Index + 2 < Bottom; Index++, Count++) {\r
-    String = VA_ARG (Marker, CHAR16*);\r
-\r
-    //\r
-    // This will clear the background of the line - we never know who might have been\r
-    // here before us.  This differs from the next clear in that it used the non-reverse\r
-    // video for normal printing.\r
-    //\r
-    if (GetStringWidth (String) / 2 > 1) {\r
-      ClearLines (Start, End, Index + 1, Index + 1, GetPopupColor ());\r
-    }\r
-\r
-    //\r
-    // Passing in a space results in the assumption that this is where typing will occur\r
-    //\r
-    if (String[0] == L' ') {\r
-      ClearLines (Start + 1, End - 1, Index + 1, Index + 1, GetPopupInverseColor ());\r
-    }\r
-\r
-    //\r
-    // Passing in a NULL results in a blank space\r
-    //\r
-    if (String[0] == CHAR_NULL) {\r
-      ClearLines (Start, End, Index + 1, Index + 1, GetPopupColor ());\r
-    }\r
-\r
-    PrintStringAt (\r
-      ((DimensionsWidth - GetStringWidth (String) / 2) / 2) + gStatementDimensions.LeftColumn + 1,\r
-      Index + 1,\r
-      String\r
-      );\r
-    gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());\r
-    PrintCharAt (Start, Index + 1, Character);\r
-    PrintCharAt (End - 1, Index + 1, Character);\r
-  }\r
-\r
-  Character = BOXDRAW_UP_RIGHT;\r
-  PrintCharAt (Start, Bottom - 1, Character);\r
-  Character = BOXDRAW_HORIZONTAL;\r
-  for (Index = Start; Index + 2 < End; Index++) {\r
-    PrintCharAt ((UINTN)-1, (UINTN)-1, Character);\r
-  }\r
-\r
-  Character = BOXDRAW_UP_LEFT;\r
-  PrintCharAt ((UINTN)-1, (UINTN)-1, Character);\r
-}\r
-\r
-/**\r
-  Draw a pop up windows based on the dimension, number of lines and\r
-  strings specified.\r
-\r
-  @param RequestedWidth  The width of the pop-up.\r
-  @param NumberOfLines   The number of lines.\r
-  @param ...             A series of text strings that displayed in the pop-up.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-CreateMultiStringPopUp (\r
-  IN  UINTN                       RequestedWidth,\r
-  IN  UINTN                       NumberOfLines,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST Marker;\r
-\r
-  VA_START (Marker, NumberOfLines);\r
-\r
-  CreateSharedPopUp (RequestedWidth, NumberOfLines, Marker);\r
-\r
-  VA_END (Marker);\r
-}\r
-\r
-/**\r
-  Process validate for one question.\r
-\r
-  @param  Question               The question need to be validate.\r
-\r
-  @retval EFI_SUCCESS            Question Option process success.\r
-  @retval EFI_INVALID_PARAMETER  Question Option process fail.\r
-\r
-**/\r
-EFI_STATUS \r
-ValidateQuestion (\r
-  IN FORM_DISPLAY_ENGINE_STATEMENT   *Question\r
-  )\r
-{\r
-  CHAR16                          *ErrorInfo;\r
-  EFI_INPUT_KEY                   Key;\r
-  EFI_STATUS                      Status;\r
-  STATEMENT_ERROR_INFO            RetInfo;\r
-  UINT32                          RetVal;\r
-\r
-  if (Question->ValidateQuestion == NULL) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Status = EFI_SUCCESS; \r
-  RetVal = Question->ValidateQuestion(gFormData, Question, &gUserInput->InputValue, &RetInfo);\r
\r
-  switch (RetVal) {\r
-  case INCOSISTENT_IF_TRUE:\r
-    //\r
-    // Condition meet, show up error message\r
-    //\r
-    ASSERT (RetInfo.StringId != 0);\r
-    ErrorInfo = GetToken (RetInfo.StringId, gFormData->HiiHandle);\r
-    do {\r
-      CreateDialog (&Key, gEmptyString, ErrorInfo, gPressEnter, gEmptyString, NULL);\r
-    } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
-    FreePool (ErrorInfo);\r
-\r
-    Status = EFI_INVALID_PARAMETER;\r
-  break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Display error message for invalid password.\r
-\r
-**/\r
-VOID\r
-PasswordInvalid (\r
-  VOID\r
-  )\r
-{\r
-  EFI_INPUT_KEY  Key;\r
-\r
-  //\r
-  // Invalid password, prompt error message\r
-  //\r
-  do {\r
-    CreateDialog (&Key, gEmptyString, gPassowordInvalid, gPressEnter, gEmptyString, NULL);\r
-  } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
-}\r
-\r
-/**\r
-  Process password op code.\r
-\r
-  @param  MenuOption             The menu for current password op code.\r
-\r
-  @retval EFI_SUCCESS            Question Option process success.\r
-  @retval Other                  Question Option process fail.\r
-\r
-**/\r
-EFI_STATUS\r
-PasswordProcess (\r
-  IN  UI_MENU_OPTION              *MenuOption\r
-  )\r
-{\r
-  CHAR16                          *StringPtr;\r
-  CHAR16                          *TempString;\r
-  UINTN                           Maximum;\r
-  EFI_STATUS                      Status;\r
-  EFI_IFR_PASSWORD                *PasswordInfo;\r
-  FORM_DISPLAY_ENGINE_STATEMENT   *Question;\r
-  EFI_INPUT_KEY                   Key;\r
-\r
-  Question     = MenuOption->ThisTag;\r
-  PasswordInfo = (EFI_IFR_PASSWORD *) Question->OpCode;\r
-  Maximum      = PasswordInfo->MaxSize;\r
-  Status       = EFI_SUCCESS;\r
-\r
-  StringPtr = AllocateZeroPool ((Maximum + 1) * sizeof (CHAR16));\r
-  ASSERT (StringPtr);\r
-  \r
-  //\r
-  // Use a NULL password to test whether old password is required\r
-  //\r
-  *StringPtr = 0;\r
-  Status = Question->PasswordCheck (gFormData, Question, StringPtr);\r
-  if (Status == EFI_NOT_AVAILABLE_YET || Status == EFI_UNSUPPORTED) {\r
-    //\r
-    // Password can't be set now. \r
-    //\r
-    FreePool (StringPtr);\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Old password exist, ask user for the old password\r
-    //\r
-    Status = ReadString (MenuOption, gPromptForPassword, StringPtr);\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (StringPtr);\r
-      return Status;\r
-    }\r
-\r
-    //\r
-    // Check user input old password\r
-    //\r
-    Status = Question->PasswordCheck (gFormData, Question, StringPtr);\r
-    if (EFI_ERROR (Status)) {\r
-      if (Status == EFI_NOT_READY) {\r
-        //\r
-        // Typed in old password incorrect\r
-        //\r
-        PasswordInvalid ();\r
-      } else {\r
-        Status = EFI_SUCCESS;\r
-      }\r
-\r
-      FreePool (StringPtr);\r
-      return Status;\r
-    }\r
-  }\r
-  \r
-  //\r
-  // Ask for new password\r
-  //\r
-  ZeroMem (StringPtr, (Maximum + 1) * sizeof (CHAR16));\r
-  Status = ReadString (MenuOption, gPromptForNewPassword, StringPtr);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Reset state machine for password\r
-    //\r
-    Question->PasswordCheck (gFormData, Question, NULL);\r
-    FreePool (StringPtr);\r
-    return Status;\r
-  }\r
-  \r
-  //\r
-  // Confirm new password\r
-  //\r
-  TempString = AllocateZeroPool ((Maximum + 1) * sizeof (CHAR16));\r
-  ASSERT (TempString);\r
-  Status = ReadString (MenuOption, gConfirmPassword, TempString);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Reset state machine for password\r
-    //\r
-    Question->PasswordCheck (gFormData, Question, NULL);\r
-    FreePool (StringPtr);\r
-    FreePool (TempString);\r
-    return Status;\r
-  }\r
-  \r
-  //\r
-  // Compare two typed-in new passwords\r
-  //\r
-  if (StrCmp (StringPtr, TempString) == 0) {     \r
-    gUserInput->InputValue.Buffer = AllocateCopyPool (Question->CurrentValue.BufferLen, StringPtr);\r
-    gUserInput->InputValue.BufferLen = Question->CurrentValue.BufferLen;\r
-    gUserInput->InputValue.Type = Question->CurrentValue.Type;\r
-    gUserInput->InputValue.Value.string = HiiSetString(gFormData->HiiHandle, gUserInput->InputValue.Value.string, StringPtr, NULL);\r
-    FreePool (StringPtr); \r
-\r
-    Status = ValidateQuestion (Question);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Reset state machine for password\r
-      //\r
-      Question->PasswordCheck (gFormData, Question, NULL);\r
-    }\r
-\r
-    return Status;\r
-  } else {\r
-    //\r
-    // Reset state machine for password\r
-    //\r
-    Question->PasswordCheck (gFormData, Question, NULL);\r
-  \r
-    //\r
-    // Two password mismatch, prompt error message\r
-    //\r
-    do {\r
-      CreateDialog (&Key, gEmptyString, gConfirmError, gPressEnter, gEmptyString, NULL);\r
-    } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
-\r
-    Status = EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  FreePool (TempString);\r
-  FreePool (StringPtr);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Process a Question's Option (whether selected or un-selected).\r
-\r
-  @param  MenuOption             The MenuOption for this Question.\r
-  @param  Selected               TRUE: if Question is selected.\r
-  @param  OptionString           Pointer of the Option String to be displayed.\r
-  @param  SkipErrorValue         Whether need to return when value without option for it.\r
-\r
-  @retval EFI_SUCCESS            Question Option process success.\r
-  @retval Other                  Question Option process fail.\r
-\r
-**/\r
-EFI_STATUS\r
-ProcessOptions (\r
-  IN  UI_MENU_OPTION              *MenuOption,\r
-  IN  BOOLEAN                     Selected,\r
-  OUT CHAR16                      **OptionString,\r
-  IN  BOOLEAN                     SkipErrorValue\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  CHAR16                          *StringPtr;\r
-  UINTN                           Index;\r
-  FORM_DISPLAY_ENGINE_STATEMENT   *Question;\r
-  CHAR16                          FormattedNumber[21];\r
-  UINT16                          Number;\r
-  CHAR16                          Character[2];\r
-  EFI_INPUT_KEY                   Key;\r
-  UINTN                           BufferSize;\r
-  DISPLAY_QUESTION_OPTION         *OneOfOption;\r
-  LIST_ENTRY                      *Link;\r
-  EFI_HII_VALUE                   HiiValue;\r
-  EFI_HII_VALUE                   *QuestionValue;\r
-  DISPLAY_QUESTION_OPTION         *Option;\r
-  UINTN                           Index2;\r
-  UINT8                           *ValueArray;\r
-  UINT8                           ValueType;\r
-  EFI_STRING_ID                   StringId;\r
-  EFI_IFR_ORDERED_LIST            *OrderList;\r
-  BOOLEAN                         ValueInvalid;\r
-\r
-  Status        = EFI_SUCCESS;\r
-\r
-  StringPtr     = NULL;\r
-  Character[1]  = L'\0';\r
-  *OptionString = NULL;\r
-  StringId      = 0;\r
-  ValueInvalid  = FALSE;\r
-\r
-  ZeroMem (FormattedNumber, 21 * sizeof (CHAR16));\r
-  BufferSize = (gOptionBlockWidth + 1) * 2 * gStatementDimensions.BottomRow;\r
-\r
-  Question = MenuOption->ThisTag;\r
-  QuestionValue = &Question->CurrentValue;\r
-\r
-  switch (Question->OpCode->OpCode) {\r
-  case EFI_IFR_ORDERED_LIST_OP:\r
-\r
-    //\r
-    // Check whether there are Options of this OrderedList\r
-    //\r
-    if (IsListEmpty (&Question->OptionListHead)) {\r
-      break;\r
-    }\r
-\r
-    OrderList = (EFI_IFR_ORDERED_LIST *) Question->OpCode;\r
-\r
-    Link = GetFirstNode (&Question->OptionListHead);\r
-    OneOfOption = DISPLAY_QUESTION_OPTION_FROM_LINK (Link);\r
-\r
-    ValueType =  OneOfOption->OptionOpCode->Type;\r
-    ValueArray = Question->CurrentValue.Buffer;\r
-\r
-    if (Selected) {\r
-      //\r
-      // Go ask for input\r
-      //\r
-      Status = GetSelectionInputPopUp (MenuOption);\r
-    } else {\r
-      //\r
-      // We now know how many strings we will have, so we can allocate the\r
-      // space required for the array or strings.\r
-      //\r
-      *OptionString = AllocateZeroPool (OrderList->MaxContainers * BufferSize);\r
-      ASSERT (*OptionString);\r
-\r
-      HiiValue.Type = ValueType;\r
-      HiiValue.Value.u64 = 0;\r
-      for (Index = 0; Index < OrderList->MaxContainers; Index++) {\r
-        HiiValue.Value.u64 = GetArrayData (ValueArray, ValueType, Index);\r
-        if (HiiValue.Value.u64 == 0) {\r
-          //\r
-          // Values for the options in ordered lists should never be a 0\r
-          //\r
-          break;\r
-        }\r
-\r
-        OneOfOption = ValueToOption (Question, &HiiValue);\r
-        if (OneOfOption == NULL) {\r
-          if (SkipErrorValue) {\r
-            //\r
-            // Just try to get the option string, skip the value which not has option.\r
-            //\r
-            continue;\r
-          }\r
-\r
-          //\r
-          // Show error message\r
-          //\r
-          do {\r
-            CreateDialog (&Key, gEmptyString, gOptionMismatch, gPressEnter, gEmptyString, NULL);\r
-          } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
-\r
-          //\r
-          // The initial value of the orderedlist is invalid, force to be valid value\r
-          // Exit current DisplayForm with new value.\r
-          //\r
-          gUserInput->SelectedStatement = Question;\r
-          \r
-          ValueArray = AllocateZeroPool (Question->CurrentValue.BufferLen);\r
-          ASSERT (ValueArray != NULL);\r
-          gUserInput->InputValue.Buffer    = ValueArray;\r
-          gUserInput->InputValue.BufferLen = Question->CurrentValue.BufferLen;\r
-          gUserInput->InputValue.Type      = Question->CurrentValue.Type;\r
-          \r
-          Link = GetFirstNode (&Question->OptionListHead);\r
-          Index2 = 0;\r
-          while (!IsNull (&Question->OptionListHead, Link) && Index2 < OrderList->MaxContainers) {\r
-            Option = DISPLAY_QUESTION_OPTION_FROM_LINK (Link);\r
-            Link = GetNextNode (&Question->OptionListHead, Link);\r
-            SetArrayData (ValueArray, ValueType, Index2, Option->OptionOpCode->Value.u64);\r
-            Index2++;\r
-          }\r
-          SetArrayData (ValueArray, ValueType, Index2, 0);\r
-\r
-          FreePool (*OptionString);\r
-          *OptionString = NULL;\r
-          return EFI_NOT_FOUND;\r
-        }\r
-\r
-        Character[0] = LEFT_ONEOF_DELIMITER;\r
-        NewStrCat (OptionString[0], Character);\r
-        StringPtr = GetToken (OneOfOption->OptionOpCode->Option, gFormData->HiiHandle);\r
-        ASSERT (StringPtr != NULL);\r
-        NewStrCat (OptionString[0], StringPtr);\r
-        Character[0] = RIGHT_ONEOF_DELIMITER;\r
-        NewStrCat (OptionString[0], Character);\r
-        Character[0] = CHAR_CARRIAGE_RETURN;\r
-        NewStrCat (OptionString[0], Character);\r
-        FreePool (StringPtr);\r
-      }\r
-\r
-      //\r
-      // If valid option more than the max container, skip these options.\r
-      //\r
-      if (Index >= OrderList->MaxContainers) {\r
-        break;\r
-      }\r
-\r
-      //\r
-      // Search the other options, try to find the one not in the container.\r
-      //\r
-      Link = GetFirstNode (&Question->OptionListHead);\r
-      while (!IsNull (&Question->OptionListHead, Link)) {\r
-        OneOfOption = DISPLAY_QUESTION_OPTION_FROM_LINK (Link);\r
-        Link = GetNextNode (&Question->OptionListHead, Link);\r
-\r
-        if (FindArrayData (ValueArray, ValueType, OneOfOption->OptionOpCode->Value.u64, NULL)) {\r
-          continue;\r
-        }\r
-\r
-        if (SkipErrorValue) {\r
-          //\r
-          // Not report error, just get the correct option string info.\r
-          //\r
-          Character[0] = LEFT_ONEOF_DELIMITER;\r
-          NewStrCat (OptionString[0], Character);\r
-          StringPtr = GetToken (OneOfOption->OptionOpCode->Option, gFormData->HiiHandle);\r
-          ASSERT (StringPtr != NULL);\r
-          NewStrCat (OptionString[0], StringPtr);\r
-          Character[0] = RIGHT_ONEOF_DELIMITER;\r
-          NewStrCat (OptionString[0], Character);\r
-          Character[0] = CHAR_CARRIAGE_RETURN;\r
-          NewStrCat (OptionString[0], Character);\r
-          FreePool (StringPtr);\r
-\r
-          continue;\r
-        }\r
-\r
-        if (!ValueInvalid) {\r
-          ValueInvalid = TRUE;\r
-          //\r
-          // Show error message\r
-          //\r
-          do {\r
-            CreateDialog (&Key, gEmptyString, gOptionMismatch, gPressEnter, gEmptyString, NULL);\r
-          } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
-\r
-          //\r
-          // The initial value of the orderedlist is invalid, force to be valid value\r
-          // Exit current DisplayForm with new value.\r
-          //\r
-          gUserInput->SelectedStatement = Question;\r
-          \r
-          ValueArray = AllocateCopyPool (Question->CurrentValue.BufferLen, Question->CurrentValue.Buffer);\r
-          ASSERT (ValueArray != NULL);\r
-          gUserInput->InputValue.Buffer    = ValueArray;\r
-          gUserInput->InputValue.BufferLen = Question->CurrentValue.BufferLen;\r
-          gUserInput->InputValue.Type      = Question->CurrentValue.Type;\r
-        }\r
-       \r
-        SetArrayData (ValueArray, ValueType, Index++, OneOfOption->OptionOpCode->Value.u64);\r
-      }\r
-\r
-      if (ValueInvalid) {\r
-        FreePool (*OptionString);\r
-        *OptionString = NULL;\r
-        return EFI_NOT_FOUND;\r
-      }\r
-    }\r
-    break;\r
-\r
-  case EFI_IFR_ONE_OF_OP:\r
-    //\r
-    // Check whether there are Options of this OneOf\r
-    //\r
-    if (IsListEmpty (&Question->OptionListHead)) {\r
-      break;\r
-    }\r
-    if (Selected) {\r
-      //\r
-      // Go ask for input\r
-      //\r
-      Status = GetSelectionInputPopUp (MenuOption);\r
-    } else {\r
-      *OptionString = AllocateZeroPool (BufferSize);\r
-      ASSERT (*OptionString);\r
-\r
-      OneOfOption = ValueToOption (Question, QuestionValue);\r
-      if (OneOfOption == NULL) {\r
-        if (SkipErrorValue) {\r
-          //\r
-          // Not report error, just get the correct option string info.\r
-          //          \r
-          Link = GetFirstNode (&Question->OptionListHead);\r
-          OneOfOption = DISPLAY_QUESTION_OPTION_FROM_LINK (Link);\r
-        } else {\r
-          //\r
-          // Show error message\r
-          //\r
-          do {\r
-            CreateDialog (&Key, gEmptyString, gOptionMismatch, gPressEnter, gEmptyString, NULL);\r
-          } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
-\r
-          //\r
-          // Force the Question value to be valid\r
-          // Exit current DisplayForm with new value.\r
-          //\r
-          Link = GetFirstNode (&Question->OptionListHead);\r
-          Option = DISPLAY_QUESTION_OPTION_FROM_LINK (Link);\r
-\r
-          CopyMem (&gUserInput->InputValue.Value, &Option->OptionOpCode->Value, sizeof (EFI_IFR_TYPE_VALUE));\r
-          gUserInput->InputValue.Type = Option->OptionOpCode->Type;\r
-          gUserInput->SelectedStatement = Question;\r
-\r
-          FreePool (*OptionString);\r
-          *OptionString = NULL;\r
-          return EFI_NOT_FOUND;\r
-        }\r
-      }\r
-\r
-      Character[0] = LEFT_ONEOF_DELIMITER;\r
-      NewStrCat (OptionString[0], Character);\r
-      StringPtr = GetToken (OneOfOption->OptionOpCode->Option, gFormData->HiiHandle);\r
-      ASSERT (StringPtr != NULL);\r
-      NewStrCat (OptionString[0], StringPtr);\r
-      Character[0] = RIGHT_ONEOF_DELIMITER;\r
-      NewStrCat (OptionString[0], Character);\r
-\r
-      FreePool (StringPtr);\r
-    }\r
-    break;\r
-\r
-  case EFI_IFR_CHECKBOX_OP:\r
-    if (Selected) {\r
-      //\r
-      // Since this is a BOOLEAN operation, flip it upon selection\r
-      //\r
-      gUserInput->InputValue.Type    = QuestionValue->Type;\r
-      gUserInput->InputValue.Value.b = (BOOLEAN) (QuestionValue->Value.b ? FALSE : TRUE);\r
-\r
-      //\r
-      // Perform inconsistent check\r
-      //\r
-      return ValidateQuestion (Question);\r
-    } else {    \r
-      *OptionString = AllocateZeroPool (BufferSize);\r
-      ASSERT (*OptionString);\r
-\r
-      *OptionString[0] = LEFT_CHECKBOX_DELIMITER;\r
-\r
-      if (QuestionValue->Value.b) {\r
-        *(OptionString[0] + 1) = CHECK_ON;\r
-      } else {\r
-        *(OptionString[0] + 1) = CHECK_OFF;\r
-      }\r
-      *(OptionString[0] + 2) = RIGHT_CHECKBOX_DELIMITER;\r
-    }\r
-    break;\r
-\r
-  case EFI_IFR_NUMERIC_OP:\r
-    if (Selected) {\r
-      //\r
-      // Go ask for input\r
-      //\r
-      Status = GetNumericInput (MenuOption);\r
-    } else {\r
-      *OptionString = AllocateZeroPool (BufferSize);\r
-      ASSERT (*OptionString);\r
-\r
-      *OptionString[0] = LEFT_NUMERIC_DELIMITER;\r
-\r
-      //\r
-      // Formatted print\r
-      //\r
-      PrintFormattedNumber (Question, FormattedNumber, 21 * sizeof (CHAR16));\r
-      Number = (UINT16) GetStringWidth (FormattedNumber);\r
-      CopyMem (OptionString[0] + 1, FormattedNumber, Number);\r
-\r
-      *(OptionString[0] + Number / 2) = RIGHT_NUMERIC_DELIMITER;\r
-    }\r
-    break;\r
-\r
-  case EFI_IFR_DATE_OP:\r
-    if (Selected) {\r
-      //\r
-      // This is similar to numerics\r
-      //\r
-      Status = GetNumericInput (MenuOption);\r
-    } else {\r
-      *OptionString = AllocateZeroPool (BufferSize);\r
-      ASSERT (*OptionString);\r
-\r
-      switch (MenuOption->Sequence) {\r
-      case 0:\r
-        *OptionString[0] = LEFT_NUMERIC_DELIMITER;\r
-        UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.date.Month);\r
-        *(OptionString[0] + 3) = DATE_SEPARATOR;\r
-        break;\r
-\r
-      case 1:\r
-        SetUnicodeMem (OptionString[0], 4, L' ');\r
-        UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.date.Day);\r
-        *(OptionString[0] + 6) = DATE_SEPARATOR;\r
-        break;\r
-\r
-      case 2:\r
-        SetUnicodeMem (OptionString[0], 7, L' ');\r
-        UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%04d", QuestionValue->Value.date.Year);\r
-        *(OptionString[0] + 11) = RIGHT_NUMERIC_DELIMITER;\r
-        break;\r
-      }\r
-    }\r
-    break;\r
-\r
-  case EFI_IFR_TIME_OP:\r
-    if (Selected) {\r
-      //\r
-      // This is similar to numerics\r
-      //\r
-      Status = GetNumericInput (MenuOption);\r
-    } else {\r
-      *OptionString = AllocateZeroPool (BufferSize);\r
-      ASSERT (*OptionString);\r
-\r
-      switch (MenuOption->Sequence) {\r
-      case 0:\r
-        *OptionString[0] = LEFT_NUMERIC_DELIMITER;\r
-        UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Hour);\r
-        *(OptionString[0] + 3) = TIME_SEPARATOR;\r
-        break;\r
-\r
-      case 1:\r
-        SetUnicodeMem (OptionString[0], 4, L' ');\r
-        UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Minute);\r
-        *(OptionString[0] + 6) = TIME_SEPARATOR;\r
-        break;\r
-\r
-      case 2:\r
-        SetUnicodeMem (OptionString[0], 7, L' ');\r
-        UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Second);\r
-        *(OptionString[0] + 9) = RIGHT_NUMERIC_DELIMITER;\r
-        break;\r
-      }\r
-    }\r
-    break;\r
-\r
-  case EFI_IFR_STRING_OP:\r
-    if (Selected) {\r
-      StringPtr = AllocateZeroPool (Question->CurrentValue.BufferLen + sizeof (CHAR16));\r
-      ASSERT (StringPtr);\r
-      CopyMem(StringPtr, Question->CurrentValue.Buffer, Question->CurrentValue.BufferLen);\r
-\r
-      Status = ReadString (MenuOption, gPromptForData, StringPtr);\r
-      if (EFI_ERROR (Status)) {\r
-        FreePool (StringPtr);\r
-        return Status;\r
-      }\r
-      \r
-      gUserInput->InputValue.Buffer = AllocateCopyPool (Question->CurrentValue.BufferLen, StringPtr);\r
-      gUserInput->InputValue.BufferLen = Question->CurrentValue.BufferLen;\r
-      gUserInput->InputValue.Type = Question->CurrentValue.Type;\r
-      gUserInput->InputValue.Value.string = HiiSetString(gFormData->HiiHandle, gUserInput->InputValue.Value.string, StringPtr, NULL);\r
-      FreePool (StringPtr);\r
-      return ValidateQuestion (Question);\r
-    } else {\r
-      *OptionString = AllocateZeroPool (BufferSize);\r
-      ASSERT (*OptionString);\r
-\r
-      if (((CHAR16 *) Question->CurrentValue.Buffer)[0] == 0x0000) {\r
-        *(OptionString[0]) = '_';\r
-      } else {\r
-        if (Question->CurrentValue.BufferLen < BufferSize) {\r
-          BufferSize = Question->CurrentValue.BufferLen;\r
-        }\r
-        CopyMem (OptionString[0], (CHAR16 *) Question->CurrentValue.Buffer, BufferSize);\r
-      }\r
-    }\r
-    break;\r
-\r
-  case EFI_IFR_PASSWORD_OP:\r
-    if (Selected) {\r
-      Status = PasswordProcess (MenuOption);\r
-    }\r
-    break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Process the help string: Split StringPtr to several lines of strings stored in\r
-  FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.\r
-\r
-  @param  StringPtr              The entire help string.\r
-  @param  FormattedString        The oupput formatted string.\r
-  @param  EachLineWidth          The max string length of each line in the formatted string.\r
-  @param  RowCount               TRUE: if Question is selected.\r
-\r
-**/\r
-UINTN\r
-ProcessHelpString (\r
-  IN  CHAR16  *StringPtr,\r
-  OUT CHAR16  **FormattedString,\r
-  OUT UINT16  *EachLineWidth,\r
-  IN  UINTN   RowCount\r
-  )\r
-{\r
-  UINTN   Index;\r
-  CHAR16  *OutputString;\r
-  UINTN   TotalRowNum;\r
-  UINTN   CheckedNum;\r
-  UINT16  GlyphWidth;\r
-  UINT16  LineWidth;\r
-  UINT16  MaxStringLen;\r
-  UINT16  StringLen;\r
-\r
-  TotalRowNum    = 0;\r
-  CheckedNum     = 0;\r
-  GlyphWidth     = 1;\r
-  Index          = 0;\r
-  MaxStringLen   = 0;\r
-  StringLen      = 0;\r
-\r
-  //\r
-  // Set default help string width.\r
-  //\r
-  LineWidth      = (UINT16) (gHelpBlockWidth - 1);\r
-\r
-  //\r
-  // Get row number of the String.\r
-  //\r
-  while ((StringLen = GetLineByWidth (StringPtr, LineWidth, &GlyphWidth, &Index, &OutputString)) != 0) {\r
-    if (StringLen > MaxStringLen) {\r
-      MaxStringLen = StringLen;\r
-    }\r
-\r
-    TotalRowNum ++;\r
-    FreePool (OutputString);\r
-  }\r
-  *EachLineWidth = MaxStringLen;\r
-\r
-  *FormattedString = AllocateZeroPool (TotalRowNum * MaxStringLen * sizeof (CHAR16));\r
-  ASSERT (*FormattedString != NULL);\r
-\r
-  //\r
-  // Generate formatted help string array.\r
-  //\r
-  GlyphWidth  = 1;\r
-  Index       = 0;\r
-  while((StringLen = GetLineByWidth (StringPtr, LineWidth, &GlyphWidth, &Index, &OutputString)) != 0) {\r
-    CopyMem (*FormattedString + CheckedNum * MaxStringLen, OutputString, StringLen * sizeof (CHAR16));\r
-    CheckedNum ++;\r
-    FreePool (OutputString);\r
-  }\r
-\r
-  return TotalRowNum; \r
-}\r