]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Ui.c
Add some definitions for efi event in Uefi/UefiSpec.h to follow spec.
[mirror_edk2.git] / EdkModulePkg / Universal / UserInterface / SetupBrowser / Dxe / Ui.c
index 7a2ec044034acabb65bd0bb8df424b8f129a6830..3d30c1bd2def0396919ddb2e124467b01d9e95c8 100644 (file)
@@ -1,25 +1,16 @@
-/*++\r
-\r
-Copyright (c) 2006, 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
-  Ui.c\r
-\r
-Abstract:\r
-   \r
+/**@file\r
   Implementation for UI.\r
 \r
-Revision History\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
---*/\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 "Setup.h"\r
 #include "Ui.h"\r
@@ -72,7 +63,7 @@ Routine Description:
   Initialize Menu option list.\r
 \r
 Arguments:\r
-           \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -90,7 +81,7 @@ Routine Description:
   Initialize Menu option list.\r
 \r
 Arguments:\r
-           \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -109,7 +100,7 @@ Routine Description:
   Remove Menu option list.\r
 \r
 Arguments:\r
-           \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -128,7 +119,7 @@ Returns:
     (*PreviousSelection)->Handle    = UiMenuList->Selection.Handle;\r
     gEntryNumber                    = UiMenuList->FormerEntryNumber;\r
     RemoveEntryList (&UiMenuList->MenuLink);\r
-    gBS->FreePool (UiMenuList);\r
+    FreePool (UiMenuList);\r
   }\r
 }\r
 \r
@@ -142,7 +133,7 @@ Routine Description:
   Free Menu option linked list.\r
 \r
 Arguments:\r
-           \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -152,7 +143,7 @@ Returns:
   while (!IsListEmpty (&gMenuList)) {\r
     UiMenuList = CR (gMenuList.ForwardLink, UI_MENU_LIST, MenuLink, UI_MENU_LIST_SIGNATURE);\r
     RemoveEntryList (&UiMenuList->MenuLink);\r
-    gBS->FreePool (UiMenuList);\r
+    FreePool (UiMenuList);\r
   }\r
 }\r
 \r
@@ -166,7 +157,7 @@ Routine Description:
   Add one menu entry to the linked lst\r
 \r
 Arguments:\r
-           \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -192,7 +183,7 @@ Routine Description:
   Free Menu option linked list.\r
 \r
 Arguments:\r
-           \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -206,11 +197,12 @@ Returns:
     //\r
     // We allocated space for this description when we did a GetToken, free it here\r
     //\r
-    gBS->FreePool (MenuOption->Description);\r
-    gBS->FreePool (MenuOption);\r
+    FreePool (MenuOption->Description);\r
+    FreePool (MenuOption);\r
   }\r
 }\r
 \r
+STATIC\r
 VOID\r
 UpdateDateAndTime (\r
   VOID\r
@@ -221,7 +213,7 @@ Routine Description:
   Refresh screen with current date and/or time based on screen context\r
 \r
 Arguments:\r
-           \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -264,7 +256,7 @@ Returns:
   }\r
 \r
   if (OptionString != NULL) {\r
-    gBS->FreePool (OptionString);\r
+    FreePool (OptionString);\r
   }\r
 }\r
 \r
@@ -299,7 +291,7 @@ Returns:
     //\r
     // Create a timer event\r
     //\r
-    Status = gBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent);\r
+    Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);\r
     if (!EFI_ERROR (Status)) {\r
       //\r
       // Set the timer event\r
@@ -332,7 +324,7 @@ Returns:
     Timeout = ONE_SECOND;\r
 \r
     do {\r
-      Status = gBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent);\r
+      Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);\r
 \r
       //\r
       // Set the timer event\r
@@ -381,7 +373,7 @@ Routine Description:
 Arguments:\r
   String - String description for this option.\r
   Context - Context data for entry.\r
-           \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -422,7 +414,7 @@ Routine Description:
 Arguments:\r
   String - String description for this option.\r
   Context - Context data for entry.\r
-           \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -465,7 +457,7 @@ Routine Description:
 \r
 Arguments:\r
   NumberOfLines -     The number of lines for the dialog box\r
-  HotKey -            Defines whether a single character is parsed (TRUE) and returned in KeyValue \r
+  HotKey -            Defines whether a single character is parsed (TRUE) and returned in KeyValue\r
                       or a string is returned in StringBuffer.  Two special characters are considered when entering a string, a SCAN_ESC and\r
                       an CHAR_CARRIAGE_RETURN.  SCAN_ESC terminates string input and returns\r
   MaximumStringSize - The maximum size in bytes of a typed in string (each character is a CHAR16) and the minimum string returned is two bytes\r
@@ -473,7 +465,7 @@ Arguments:
   KeyValue -          The EFI_KEY value returned if HotKey is TRUE..\r
   String -            Pointer to the first string in the list\r
   ... -               A series of (quantity == NumberOfLines) text strings which will be used to construct the dialog box\r
-           \r
+\r
 Returns:\r
   EFI_SUCCESS -           Displayed dialog and received user interaction\r
   EFI_INVALID_PARAMETER - One of the parameters was invalid (e.g. (StringBuffer == NULL) && (HotKey == FALSE))\r
@@ -492,7 +484,6 @@ Returns:
   UINTN         Start;\r
   UINTN         Top;\r
   UINTN         Index;\r
-  EFI_STATUS    Status;\r
   BOOLEAN       SelectionComplete;\r
   UINTN         InputOffset;\r
   UINTN         CurrentAttribute;\r
@@ -570,19 +561,19 @@ Returns:
   // Take the first key typed and report it back?\r
   //\r
   if (HotKey) {\r
-    Status = WaitForKeyStroke (&Key);\r
+    WaitForKeyStroke (&Key);\r
     CopyMem (KeyValue, &Key, sizeof (EFI_INPUT_KEY));\r
 \r
   } else {\r
     do {\r
-      Status = WaitForKeyStroke (&Key);\r
+      WaitForKeyStroke (&Key);\r
 \r
       switch (Key.UnicodeChar) {\r
       case CHAR_NULL:\r
         switch (Key.ScanCode) {\r
         case SCAN_ESC:\r
-          gBS->FreePool (TempString);\r
-          gBS->FreePool (BufferedString);\r
+          FreePool (TempString);\r
+          FreePool (BufferedString);\r
           gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);\r
           gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
           return EFI_DEVICE_ERROR;\r
@@ -595,8 +586,8 @@ Returns:
 \r
       case CHAR_CARRIAGE_RETURN:\r
         SelectionComplete = TRUE;\r
-        gBS->FreePool (TempString);\r
-        gBS->FreePool (BufferedString);\r
+        FreePool (TempString);\r
+        FreePool (BufferedString);\r
         gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);\r
         gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
         return EFI_SUCCESS;\r
@@ -838,8 +829,8 @@ UpdateStatusBar (
     break;\r
   }\r
 \r
-  gBS->FreePool (InputErrorMessage);\r
-  gBS->FreePool (NvUpdateMessage);\r
+  FreePool (InputErrorMessage);\r
+  FreePool (NvUpdateMessage);\r
   return ;\r
 }\r
 \r
@@ -852,11 +843,11 @@ FreeData (
 /*++\r
 \r
 Routine Description:\r
-  \r
+\r
   Used to remove the allocated data instances\r
 \r
 Arguments:\r
-             \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -876,11 +867,11 @@ Returns:
   FileForm = FileFormTagsHead;\r
 \r
   if (FormattedString != NULL) {\r
-    gBS->FreePool (FormattedString);\r
+    FreePool (FormattedString);\r
   }\r
 \r
   if (OptionString != NULL) {\r
-    gBS->FreePool (OptionString);\r
+    FreePool (OptionString);\r
   }\r
 \r
   for (; FileForm != NULL;) {\r
@@ -917,17 +908,17 @@ Returns:
         }\r
 \r
         if (FormTags->Tags[Index].IntList != NULL) {\r
-          gBS->FreePool (FormTags->Tags[Index].IntList);\r
+          FreePool (FormTags->Tags[Index].IntList);\r
         }\r
       }\r
 \r
       if (PreviousFormTags != NULL) {\r
-        gBS->FreePool (FormTags->Tags);\r
+        FreePool (FormTags->Tags);\r
         FormTags = PreviousFormTags;\r
-        gBS->FreePool (FormTags->Next);\r
+        FreePool (FormTags->Next);\r
         FormTags->Next = NULL;\r
       } else {\r
-        gBS->FreePool (FormTags->Tags);\r
+        FreePool (FormTags->Tags);\r
         FormTags = NULL;\r
       }\r
     }\r
@@ -951,7 +942,7 @@ Returns:
       //\r
       // Free the current entry\r
       //\r
-      gBS->FreePool (Inconsistent);\r
+      FreePool (Inconsistent);\r
 \r
       //\r
       // Restore the Previous pointer\r
@@ -972,26 +963,32 @@ Returns:
         PreviousVariableDefinition = VariableDefinition;\r
       }\r
 \r
-      gBS->FreePool (VariableDefinition->VariableName);\r
-      gBS->FreePool (VariableDefinition->NvRamMap);\r
-      gBS->FreePool (VariableDefinition->FakeNvRamMap);\r
+      FreePool (VariableDefinition->VariableName);\r
+\r
+      if (VariableDefinition->NvRamMap != NULL) {\r
+        FreePool (VariableDefinition->NvRamMap);\r
+      }\r
+\r
+      if (VariableDefinition->FakeNvRamMap != NULL) {\r
+        FreePool (VariableDefinition->FakeNvRamMap);\r
+      }\r
 \r
       if (PreviousVariableDefinition != NULL) {\r
         VariableDefinition = PreviousVariableDefinition;\r
-        gBS->FreePool (VariableDefinition->Next);\r
+        FreePool (VariableDefinition->Next);\r
         VariableDefinition->Next = NULL;\r
       } else {\r
-        gBS->FreePool (VariableDefinition);\r
+        FreePool (VariableDefinition);\r
         VariableDefinition = NULL;\r
       }\r
     }\r
 \r
     if (PreviousFileForm != NULL) {\r
       FileForm = PreviousFileForm;\r
-      gBS->FreePool (FileForm->NextFile);\r
+      FreePool (FileForm->NextFile);\r
       FileForm->NextFile = NULL;\r
     } else {\r
-      gBS->FreePool (FileForm);\r
+      FreePool (FileForm);\r
       FileForm = NULL;\r
     }\r
   }\r
@@ -1009,43 +1006,44 @@ Returns:
       PreviousIfrBinary = IfrBinary;\r
     }\r
 \r
-    gBS->FreePool (IfrBinary->IfrPackage);\r
+    FreePool (IfrBinary->IfrPackage);\r
 \r
     if (PreviousIfrBinary != NULL) {\r
       IfrBinary = PreviousIfrBinary;\r
-      gBS->FreePool (IfrBinary->Next);\r
+      FreePool (IfrBinary->Next);\r
       IfrBinary->Next = NULL;\r
     } else {\r
-      gBS->FreePool (IfrBinary);\r
+      FreePool (IfrBinary);\r
       IfrBinary = NULL;\r
     }\r
   }\r
 \r
-  gBS->FreePool (gPreviousValue);\r
+  FreePool (gPreviousValue);\r
   gPreviousValue = NULL;\r
 \r
   //\r
   // Free Browser Strings\r
   //\r
-  gBS->FreePool (gPressEnter);\r
-  gBS->FreePool (gConfirmError);\r
-  gBS->FreePool (gConfirmPassword);\r
-  gBS->FreePool (gPromptForNewPassword);\r
-  gBS->FreePool (gPromptForPassword);\r
-  gBS->FreePool (gToggleCheckBox);\r
-  gBS->FreePool (gNumericInput);\r
-  gBS->FreePool (gMakeSelection);\r
-  gBS->FreePool (gMoveHighlight);\r
-  gBS->FreePool (gEscapeString);\r
-  gBS->FreePool (gEnterCommitString);\r
-  gBS->FreePool (gEnterString);\r
-  gBS->FreePool (gFunctionOneString);\r
-  gBS->FreePool (gFunctionTwoString);\r
-  gBS->FreePool (gFunctionNineString);\r
-  gBS->FreePool (gFunctionTenString);\r
+  FreePool (gPressEnter);\r
+  FreePool (gConfirmError);\r
+  FreePool (gConfirmPassword);\r
+  FreePool (gPromptForNewPassword);\r
+  FreePool (gPromptForPassword);\r
+  FreePool (gToggleCheckBox);\r
+  FreePool (gNumericInput);\r
+  FreePool (gMakeSelection);\r
+  FreePool (gMoveHighlight);\r
+  FreePool (gEscapeString);\r
+  FreePool (gEnterCommitString);\r
+  FreePool (gEnterString);\r
+  FreePool (gFunctionOneString);\r
+  FreePool (gFunctionTwoString);\r
+  FreePool (gFunctionNineString);\r
+  FreePool (gFunctionTenString);\r
   return ;\r
 }\r
 \r
+STATIC\r
 BOOLEAN\r
 SelectionsAreValid (\r
   IN  UI_MENU_OPTION               *MenuOption,\r
@@ -1054,11 +1052,11 @@ SelectionsAreValid (
 /*++\r
 \r
 Routine Description:\r
-  Initiate late consistency checks against the current page.  \r
+  Initiate late consistency checks against the current page.\r
 \r
 Arguments:\r
   None\r
-           \r
+\r
 Returns:\r
 \r
 --*/\r
@@ -1068,7 +1066,6 @@ Returns:
   EFI_FILE_FORM_TAGS      *FileFormTags;\r
   CHAR16                  *StringPtr;\r
   CHAR16                  NullCharacter;\r
-  EFI_STATUS              Status;\r
   UINTN                   Index;\r
   UINT16                  *NvRamMap;\r
   STRING_REF              PopUp;\r
@@ -1103,7 +1100,7 @@ Returns:
           CreatePopUp (GetStringWidth (StringPtr) / 2, 3, &NullCharacter, StringPtr, &NullCharacter);\r
 \r
           do {\r
-            Status = WaitForKeyStroke (&Key);\r
+            WaitForKeyStroke (&Key);\r
 \r
             switch (Key.UnicodeChar) {\r
 \r
@@ -1112,7 +1109,7 @@ Returns:
               // Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth\r
               //\r
               CopyMem (NvRamMap, &Tag->OldValue, Tag->StorageWidth);\r
-              gBS->FreePool (StringPtr);\r
+              FreePool (StringPtr);\r
               break;\r
 \r
             default:\r
@@ -1142,7 +1139,7 @@ Routine Description:
 Arguments:\r
   Tag - The Tag structure passed in.\r
   Handle - The handle in the HII database being used\r
-  \r
+\r
 Returns:\r
   Returns the number of CHAR16 characters that is support.\r
 \r
@@ -1160,7 +1157,7 @@ Returns:
   if ((Tag->Operand == EFI_IFR_TEXT_OP) && (Tag->TextTwo != 0)) {\r
     String  = GetToken (Tag->TextTwo, Handle);\r
     Size    = StrLen (String);\r
-    gBS->FreePool (String);\r
+    FreePool (String);\r
   }\r
 \r
   if ((Tag->Operand == EFI_IFR_SUBTITLE_OP) ||\r
@@ -1197,7 +1194,7 @@ Arguments:
   LineWidth - Width of the desired string to extract in CHAR16 characters\r
   Index - Where in InputString to start the copy process\r
   OutputString - Buffer to copy the string into\r
-           \r
+\r
 Returns:\r
   Returns the number of CHAR16 characters that were copied into the OutputString buffer.\r
 \r
@@ -1222,14 +1219,14 @@ Returns:
   // Ensure we have got a valid buffer\r
   //\r
   if (*OutputString != NULL) {\r
-  \r
+\r
     //\r
     //NARROW_CHAR can not be printed in screen, so if a line only contain  the two CHARs: 'NARROW_CHAR + CHAR_CARRIAGE_RETURN' , it is a empty line  in Screen.\r
     //To avoid displaying this  empty line in screen,  just skip  the two CHARs here.\r
     //\r
    if ((InputString[*Index] == NARROW_CHAR) && (InputString[*Index + 1] == CHAR_CARRIAGE_RETURN)) {\r
      *Index = *Index + 2;\r
-   } \r
+   }\r
 \r
     //\r
     // Fast-forward the string and see if there is a carriage-return in the string\r
@@ -1284,6 +1281,7 @@ Returns:
   }\r
 }\r
 \r
+STATIC\r
 VOID\r
 UpdateOptionSkipLines (\r
   IN EFI_IFR_DATA_ARRAY           *PageData,\r
@@ -1294,7 +1292,6 @@ UpdateOptionSkipLines (
   )\r
 {\r
   UINTN   Index;\r
-  UINTN   Loop;\r
   UINT16  Width;\r
   UINTN   Row;\r
   UINTN   OriginalRow;\r
@@ -1308,19 +1305,6 @@ UpdateOptionSkipLines (
   ProcessOptions (MenuOption, FALSE, FileFormTagsHead, PageData, &OptionString);\r
 \r
   if (OptionString != NULL) {\r
-    //\r
-    // If leading spaces on OptionString - remove the spaces\r
-    //\r
-    for (Index = 0; OptionString[Index] == L' '; Index++)\r
-    ;\r
-\r
-    for (Loop = 0; OptionString[Index] != CHAR_NULL; Index++) {\r
-      OptionString[Loop] = OptionString[Index];\r
-      Loop++;\r
-    }\r
-\r
-    OptionString[Loop]  = CHAR_NULL;\r
-\r
     Width               = (UINT16) gOptionBlockWidth;\r
 \r
     OriginalRow         = Row;\r
@@ -1345,7 +1329,7 @@ UpdateOptionSkipLines (
         }\r
       }\r
 \r
-      gBS->FreePool (OutputString);\r
+      FreePool (OutputString);\r
       if (SkipValue != 0) {\r
         SkipValue--;\r
       }\r
@@ -1404,9 +1388,9 @@ Arguments:
   SubMenu          - Indicate is sub menu.\r
   FileFormTagsHead - A pointer to the EFI_FILE_FORM_TAGS structure.\r
   PageData         - A pointer to the EFI_IFR_DATA_ARRAY.\r
-           \r
+\r
 Returns:\r
-  Return the pointer of the menu which selected, \r
+  Return the pointer of the menu which selected,\r
   otherwise return NULL.\r
 \r
 --*/\r
@@ -1570,7 +1554,7 @@ Returns:
         while (gMenuRefreshHead != NULL) {\r
           OldMenuRefreshEntry = gMenuRefreshHead->Next;\r
 \r
-          gBS->FreePool (gMenuRefreshHead);\r
+          FreePool (gMenuRefreshHead);\r
 \r
           gMenuRefreshHead = OldMenuRefreshEntry;\r
         }\r
@@ -1608,7 +1592,7 @@ Returns:
                 }\r
               }\r
 \r
-              gBS->FreePool (OutputString);\r
+              FreePool (OutputString);\r
               if (Temp != 0) {\r
                 Temp--;\r
               }\r
@@ -1622,19 +1606,23 @@ Returns:
             ProcessOptions (MenuOption, FALSE, FileFormTagsHead, PageData, &OptionString);\r
 \r
             if (OptionString != NULL) {\r
-              //\r
-              // If leading spaces on OptionString - remove the spaces\r
-              //\r
-              for (Index = 0; OptionString[Index] == L' '; Index++) {\r
-                MenuOption->OptCol++;\r
-              }\r
+              if (MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP ||\r
+                  MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP\r
+                  ) {\r
+                //\r
+                // If leading spaces on OptionString - remove the spaces\r
+                //\r
+                for (Index = 0; OptionString[Index] == L' '; Index++) {\r
+                  MenuOption->OptCol++;\r
+                }\r
 \r
-              for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) {\r
-                OptionString[Count] = OptionString[Index];\r
-                Count++;\r
-              }\r
+                for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) {\r
+                  OptionString[Count] = OptionString[Index];\r
+                  Count++;\r
+                }\r
 \r
-              OptionString[Count] = CHAR_NULL;\r
+                OptionString[Count] = CHAR_NULL;\r
+              }\r
 \r
               //\r
               // If this is a date or time op-code and is used to reflect an RTC, register the op-code\r
@@ -1699,7 +1687,7 @@ Returns:
                   }\r
                 }\r
 \r
-                gBS->FreePool (OutputString);\r
+                FreePool (OutputString);\r
                 if (Temp2 != 0) {\r
                   Temp2--;\r
                 }\r
@@ -1741,14 +1729,14 @@ Returns:
                   }\r
                 }\r
 \r
-                gBS->FreePool (OutputString);\r
+                FreePool (OutputString);\r
                 if (Temp2 != 0) {\r
                   Temp2--;\r
                 }\r
               }\r
 \r
               Row = OriginalRow;\r
-              gBS->FreePool (StringPtr);\r
+              FreePool (StringPtr);\r
             }\r
           } else {\r
             //\r
@@ -1834,18 +1822,22 @@ Returns:
           ProcessOptions (MenuOption, FALSE, FileFormTagsHead, PageData, &OptionString);\r
           gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r
           if (OptionString != NULL) {\r
-            //\r
-            // If leading spaces on OptionString - remove the spaces\r
-            //\r
-            for (Index = 0; OptionString[Index] == L' '; Index++)\r
-              ;\r
+            if (MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP ||\r
+                MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP\r
+                ) {\r
+              //\r
+              // If leading spaces on OptionString - remove the spaces\r
+              //\r
+              for (Index = 0; OptionString[Index] == L' '; Index++)\r
+                ;\r
 \r
-            for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) {\r
-              OptionString[Count] = OptionString[Index];\r
-              Count++;\r
-            }\r
+              for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) {\r
+                OptionString[Count] = OptionString[Index];\r
+                Count++;\r
+              }\r
 \r
-            OptionString[Count] = CHAR_NULL;\r
+              OptionString[Count] = CHAR_NULL;\r
+            }\r
 \r
             Width               = (UINT16) gOptionBlockWidth;\r
 \r
@@ -1862,7 +1854,7 @@ Returns:
                 MenuOption->Row++;\r
               }\r
 \r
-              gBS->FreePool (OutputString);\r
+              FreePool (OutputString);\r
             }\r
 \r
             MenuOption->Row = OriginalRow;\r
@@ -1890,7 +1882,7 @@ Returns:
                   MenuOption->Row++;\r
                 }\r
 \r
-                gBS->FreePool (OutputString);\r
+                FreePool (OutputString);\r
               }\r
 \r
               MenuOption->Row = OriginalRow;\r
@@ -1952,19 +1944,22 @@ Returns:
         if (SubMenu) {\r
           ProcessOptions (MenuOption, FALSE, FileFormTagsHead, PageData, &OptionString);\r
           if (OptionString != NULL) {\r
-            //\r
-            // If leading spaces on OptionString - remove the spaces\r
-            //\r
-            for (Index = 0; OptionString[Index] == L' '; Index++)\r
-              ;\r
-\r
-            for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) {\r
-              OptionString[Count] = OptionString[Index];\r
-              Count++;\r
-            }\r
+            if (MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP ||\r
+                MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP\r
+                ) {\r
+              //\r
+              // If leading spaces on OptionString - remove the spaces\r
+              //\r
+              for (Index = 0; OptionString[Index] == L' '; Index++)\r
+                ;\r
 \r
-            OptionString[Count] = CHAR_NULL;\r
+              for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) {\r
+                OptionString[Count] = OptionString[Index];\r
+                Count++;\r
+              }\r
 \r
+              OptionString[Count] = CHAR_NULL;\r
+            }\r
             Width               = (UINT16) gOptionBlockWidth;\r
 \r
             OriginalRow         = MenuOption->Row;\r
@@ -1980,7 +1975,7 @@ Returns:
                 MenuOption->Row++;\r
               }\r
 \r
-              gBS->FreePool (OutputString);\r
+              FreePool (OutputString);\r
             }\r
 \r
             MenuOption->Row = OriginalRow;\r
@@ -2001,7 +1996,7 @@ Returns:
                   MenuOption->Row++;\r
                 }\r
 \r
-                gBS->FreePool (OutputString);\r
+                FreePool (OutputString);\r
               }\r
 \r
               MenuOption->Row = OriginalRow;\r
@@ -2033,10 +2028,10 @@ Returns:
     case CfUpdateHelpString:\r
       ControlFlag = CfPrepareToReadKey;\r
 \r
-        if (SubMenu && \r
-            (Repaint || NewLine || \r
+        if (SubMenu &&\r
+            (Repaint || NewLine ||\r
              (MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) ||\r
-             (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) && \r
+             (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) &&\r
             !(gClassOfVfr == EFI_GENERAL_APPLICATION_SUBCLASS)) {\r
         //\r
         // Don't print anything if it is a NULL help token\r
@@ -2055,14 +2050,14 @@ Returns:
           //\r
           // Pad String with spaces to simulate a clearing of the previous line\r
           //\r
-          for (; GetStringWidth (&FormattedString[Index * gHelpBlockWidth]) / 2 < gHelpBlockWidth;) {\r
-            StrCat (&FormattedString[Index * gHelpBlockWidth], (CHAR16 *) L" ");\r
+          for (; GetStringWidth (&FormattedString[Index * gHelpBlockWidth * 2]) / 2 < gHelpBlockWidth;) {\r
+            StrCat (&FormattedString[Index * gHelpBlockWidth * 2], (CHAR16 *) L" ");\r
           }\r
 \r
           PrintStringAt (\r
             LocalScreen.RightColumn - gHelpBlockWidth,\r
             Index + TopRow,\r
-            &FormattedString[Index * gHelpBlockWidth]\r
+            &FormattedString[Index * gHelpBlockWidth * 2]\r
             );\r
         }\r
       }\r
@@ -2316,7 +2311,7 @@ Returns:
       while (gMenuRefreshHead != NULL) {\r
         OldMenuRefreshEntry = gMenuRefreshHead->Next;\r
 \r
-        gBS->FreePool (gMenuRefreshHead);\r
+        FreePool (gMenuRefreshHead);\r
 \r
         gMenuRefreshHead = OldMenuRefreshEntry;\r
       }\r
@@ -2339,7 +2334,7 @@ Returns:
       ExtractRequestedNvMap (FileFormTags, MenuOption->ThisTag->VariableNumber, &VariableDefinition);\r
 \r
       if (SubMenu) {\r
-        if ((MenuOption->ThisTag->Operand == EFI_IFR_TEXT_OP && \r
+        if ((MenuOption->ThisTag->Operand == EFI_IFR_TEXT_OP &&\r
             !(MenuOption->ThisTag->Flags & EFI_IFR_FLAG_INTERACTIVE)) ||\r
             (MenuOption->ThisTag->GrayOut) ||\r
             (MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) ||\r
@@ -2977,9 +2972,9 @@ Returns:
 \r
       if (!EFI_ERROR (Status)) {\r
         ASSERT_EFI_ERROR (NULL != NvMapListHead);\r
-        \r
+\r
         NvMapListNode = NvMapListHead;\r
-        \r
+\r
         while (NULL != NvMapListNode) {\r
           if (FileFormTags->VariableDefinitions->VariableId == NvMapListNode->VariablePack->VariableId) {\r
             NvMap     = (VOID *) ((CHAR8 *) NvMapListNode->VariablePack + sizeof (EFI_HII_VARIABLE_PACK) + NvMapListNode->VariablePack->VariableNameLength);\r
@@ -2988,25 +2983,28 @@ Returns:
             }\r
           NvMapListNode = NvMapListNode->NextVariablePack;\r
         }\r
-        \r
+\r
         //\r
         // Free the buffer that was allocated.\r
         //\r
-        gBS->FreePool (FileFormTags->VariableDefinitions->NvRamMap);\r
-        gBS->FreePool (FileFormTags->VariableDefinitions->FakeNvRamMap);\r
-        \r
+        FreePool (FileFormTags->VariableDefinitions->NvRamMap);\r
+        FreePool (FileFormTags->VariableDefinitions->FakeNvRamMap);\r
+\r
         //\r
         // Allocate, copy the NvRamMap.\r
         //\r
         FileFormTags->VariableDefinitions->VariableFakeSize = (UINT16) (FileFormTags->VariableDefinitions->VariableFakeSize - FileFormTags->VariableDefinitions->VariableSize);\r
         FileFormTags->VariableDefinitions->VariableSize = (UINT16) NvMapSize;\r
         FileFormTags->VariableDefinitions->VariableFakeSize = (UINT16) (FileFormTags->VariableDefinitions->VariableFakeSize + FileFormTags->VariableDefinitions->VariableSize);\r
-        \r
+\r
         FileFormTags->VariableDefinitions->NvRamMap = AllocateZeroPool (FileFormTags->VariableDefinitions->VariableSize);\r
+        ASSERT (FileFormTags->VariableDefinitions->NvRamMap != NULL);\r
+\r
         FileFormTags->VariableDefinitions->FakeNvRamMap = AllocateZeroPool (NvMapSize + FileFormTags->VariableDefinitions->VariableFakeSize);\r
+        ASSERT (FileFormTags->VariableDefinitions->FakeNvRamMap != NULL);\r
 \r
         CopyMem (FileFormTags->VariableDefinitions->NvRamMap, NvMap, NvMapSize);\r
-        gBS->FreePool (NvMapListHead);\r
+        FreePool (NvMapListHead);\r
       }\r
 \r
       UpdateStatusBar (NV_UPDATE_REQUIRED, MenuOption->ThisTag->Flags, TRUE);\r
@@ -3025,7 +3023,7 @@ Returns:
       while (gMenuRefreshHead != NULL) {\r
         OldMenuRefreshEntry = gMenuRefreshHead->Next;\r
 \r
-        gBS->FreePool (gMenuRefreshHead);\r
+        FreePool (gMenuRefreshHead);\r
 \r
         gMenuRefreshHead = OldMenuRefreshEntry;\r
       }\r
@@ -3051,11 +3049,11 @@ ValueIsScroll (
 /*++\r
 \r
 Routine Description:\r
-  Determine if the menu is the last menu that can be selected. \r
+  Determine if the menu is the last menu that can be selected.\r
 \r
 Arguments:\r
   Direction - the scroll direction. False is down. True is up.\r
-           \r
+\r
 Returns:\r
   FALSE -- the menu isn't the last menu that can be selected.\r
   TRUE  -- the menu is the last menu that can be selected.\r
@@ -3095,9 +3093,9 @@ Routine Description:
 Arguments:\r
   Direction - the up or down direction. False is down. True is up.\r
   CurrentPos - Current position.\r
-           \r
+\r
 Returns:\r
-  Return line number to pad. It is possible that we stand on a zero-advance \r
+  Return line number to pad. It is possible that we stand on a zero-advance\r
   data or time opcode, so pad one line when we judge if we are going to scroll outside.\r
 --*/\r
 {\r