]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c
MdeModulePkg/PciBusDxe: Improve the flow of testing support attributes
[mirror_edk2.git] / MdeModulePkg / Application / BootManagerMenuApp / BootManagerMenu.c
index 6481d94732cdb54a6ee1549723d616c6342e894a..9e729074ece8152d86f3cd5008a4ddf745879637 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   The application to show the Boot Manager Menu.\r
 \r
-Copyright (c) 2011 - 2016, 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
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -57,7 +51,7 @@ PrintStringAt (
 }\r
 \r
 /**\r
-  Prints a chracter to the default console, at\r
+  Prints a character to the default console, at\r
   the supplied cursor position, using L"%c" format.\r
 \r
   @param  Column     The cursor position to print the string at.\r
@@ -79,7 +73,7 @@ PrintCharAt (
 }\r
 \r
 /**\r
-  Count the storage space of a Unicode string which uses current lanaguag to get \r
+  Count the storage space of a Unicode string which uses current language to get\r
   from input string ID.\r
 \r
   @param StringId          The input string to be counted.\r
@@ -91,19 +85,19 @@ UINTN
 GetLineWidth (\r
   IN EFI_STRING_ID       StringId\r
   )\r
-{  \r
+{\r
   UINTN        Index;\r
   UINTN        IncrementValue;\r
   EFI_STRING   String;\r
   UINTN        LineWidth;\r
-  \r
+\r
   LineWidth = 0;\r
-  String = HiiGetString (gStringPackHandle, StringId, NULL); \r
-  \r
+  String = HiiGetString (gStringPackHandle, StringId, NULL);\r
+\r
   if (String != NULL) {\r
     Index           = 0;\r
     IncrementValue  = 1;\r
-    \r
+\r
     do {\r
       //\r
       // Advance to the null-terminator or to the first width directive\r
@@ -113,7 +107,7 @@ GetLineWidth (
            Index++, LineWidth = LineWidth + IncrementValue\r
           )\r
         ;\r
-    \r
+\r
       //\r
       // We hit the null-terminator, we now have a count\r
       //\r
@@ -137,23 +131,23 @@ GetLineWidth (
         Index++;\r
         IncrementValue = 2;\r
       }\r
-    } while (String[Index] != 0);   \r
+    } while (String[Index] != 0);\r
     FreePool (String);\r
   }\r
-  \r
-  return LineWidth;  \r
+\r
+  return LineWidth;\r
 }\r
 \r
 /**\r
   This function uses calculate the boot menu location, size and scroll bar information.\r
 \r
-  @param  BootMenuData            The boot menu data to be proccessed.\r
+  @param  BootMenuData            The boot menu data to be processed.\r
 \r
   @return EFI_SUCCESS             calculate boot menu information successful.\r
-  @retval EFI_INVALID_PARAMETER   Input parameter is invalid   \r
+  @retval EFI_INVALID_PARAMETER   Input parameter is invalid\r
 \r
 **/\r
-EFI_STATUS \r
+EFI_STATUS\r
 InitializeBootMenuScreen (\r
   IN OUT  BOOT_MENU_POPUP_DATA  *BootMenuData\r
   )\r
@@ -172,21 +166,21 @@ InitializeBootMenuScreen (
   //\r
   // Get maximum string width\r
   //\r
-  MaxStrWidth = 0;  \r
-  for (Index = 0; Index < TITLE_TOKEN_COUNT; Index++) {    \r
+  MaxStrWidth = 0;\r
+  for (Index = 0; Index < TITLE_TOKEN_COUNT; Index++) {\r
     StrWidth = GetLineWidth (BootMenuData->TitleToken[Index]);\r
     MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth;\r
   }\r
-   \r
+\r
   for (Index = 0; Index < BootMenuData->ItemCount; Index++) {\r
     StrWidth = GetLineWidth (BootMenuData->PtrTokens[Index]);\r
-    MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth; \r
-  } \r
-  \r
-  for (Index = 0; Index < HELP_TOKEN_COUNT; Index++) {    \r
+    MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth;\r
+  }\r
+\r
+  for (Index = 0; Index < HELP_TOKEN_COUNT; Index++) {\r
     StrWidth = GetLineWidth (BootMenuData->HelpToken[Index]);\r
     MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth;\r
-  }  \r
+  }\r
   //\r
   // query current row and column to calculate boot menu location\r
   //\r
@@ -195,10 +189,10 @@ InitializeBootMenuScreen (
                  gST->ConOut->Mode->Mode,\r
                  &Column,\r
                  &Row\r
-                 ); \r
-                 \r
-  MaxPrintRows = Row - 6;    \r
-  UnSelectableItmes = TITLE_TOKEN_COUNT + 2 + HELP_TOKEN_COUNT + 2;           \r
+                 );\r
+\r
+  MaxPrintRows = Row - 6;\r
+  UnSelectableItmes = TITLE_TOKEN_COUNT + 2 + HELP_TOKEN_COUNT + 2;\r
   BootMenuData->MenuScreen.Width = MaxStrWidth + 8;\r
   if (BootMenuData->ItemCount + UnSelectableItmes > MaxPrintRows) {\r
     BootMenuData->MenuScreen.Height = MaxPrintRows;\r
@@ -211,18 +205,18 @@ InitializeBootMenuScreen (
     BootMenuData->ScrollBarControl.HasScrollBar = FALSE;\r
     BootMenuData->ScrollBarControl.ItemCountPerScreen = BootMenuData->ItemCount;\r
     BootMenuData->ScrollBarControl.FirstItem = 0;\r
-    BootMenuData->ScrollBarControl.LastItem = BootMenuData->ItemCount - 1;    \r
+    BootMenuData->ScrollBarControl.LastItem = BootMenuData->ItemCount - 1;\r
   }\r
-  BootMenuData->MenuScreen.StartCol = (Column -  BootMenuData->MenuScreen.Width) / 2;              \r
-  BootMenuData->MenuScreen.StartRow = (Row -  BootMenuData->MenuScreen.Height) / 2;  \r
+  BootMenuData->MenuScreen.StartCol = (Column -  BootMenuData->MenuScreen.Width) / 2;\r
+  BootMenuData->MenuScreen.StartRow = (Row -  BootMenuData->MenuScreen.Height) / 2;\r
 \r
   return EFI_SUCCESS;\r
 }\r
 /**\r
-  This funciton uses check boot option is wheher setup application or no\r
+  This function uses check boot option is wheher setup application or no\r
 \r
   @param   BootOption   Pointer to EFI_BOOT_MANAGER_LOAD_OPTION array.\r
-  \r
+\r
   @retval  TRUE         This boot option is setup application.\r
   @retval  FALSE        This boot options isn't setup application\r
 \r
@@ -248,7 +242,7 @@ IsBootManagerMenu (
 \r
   @param BootOption  Pointer to EFI_BOOT_MANAGER_LOAD_OPTION to check.\r
 \r
-  @retval TRUE  Ignore the boot optin.\r
+  @retval TRUE  Ignore the boot option.\r
   @retval FALSE Do not ignore the boot option.\r
 **/\r
 BOOLEAN\r
@@ -286,14 +280,14 @@ IgnoreBootOption (
 }\r
 \r
 /**\r
-  This funciton uses to initialize boot menu data\r
+  This function uses to initialize boot menu data\r
 \r
   @param   BootOption             Pointer to EFI_BOOT_MANAGER_LOAD_OPTION array.\r
   @param   BootOptionCount        Number of boot option.\r
   @param   BootMenuData           The Input BootMenuData to be initialized.\r
-  \r
+\r
   @retval  EFI_SUCCESS            Initialize boot menu data successful.\r
-  @retval  EFI_INVALID_PARAMETER  Input parameter is invalid.   \r
+  @retval  EFI_INVALID_PARAMETER  Input parameter is invalid.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -305,7 +299,7 @@ InitializeBootMenuData (
 {\r
   UINTN                         Index;\r
   UINTN                         StrIndex;\r
-      \r
+\r
   if (BootOption == NULL || BootMenuData == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -324,32 +318,32 @@ InitializeBootMenuData (
 \r
     ASSERT (BootOption[Index].Description != NULL);\r
     BootMenuData->PtrTokens[StrIndex++] = HiiSetString (\r
-                                            gStringPackHandle, \r
+                                            gStringPackHandle,\r
                                             0,\r
                                             BootOption[Index].Description,\r
                                             NULL\r
                                             );\r
   }\r
 \r
-  BootMenuData->ItemCount           = StrIndex;   \r
+  BootMenuData->ItemCount           = StrIndex;\r
   BootMenuData->HelpToken[0] = STRING_TOKEN (STR_BOOT_POPUP_MENU_HELP1_STRING);\r
   BootMenuData->HelpToken[1] = STRING_TOKEN (STR_BOOT_POPUP_MENU_HELP2_STRING);\r
   BootMenuData->HelpToken[2] = STRING_TOKEN (STR_BOOT_POPUP_MENU_HELP3_STRING);\r
   InitializeBootMenuScreen (BootMenuData);\r
   BootMenuData->SelectItem = 0;\r
   return EFI_SUCCESS;\r
-}    \r
+}\r
 \r
 /**\r
   This function uses input select item to highlight selected item\r
   and set current selected item in BootMenuData\r
 \r
   @param  WantSelectItem          The user wants to select item.\r
-  @param  BootMenuData            The boot menu data to be proccessed\r
+  @param  BootMenuData            The boot menu data to be processed\r
 \r
-  @return EFI_SUCCESS             Highlight selected item and update current selected \r
-                                  item successful \r
-  @retval EFI_INVALID_PARAMETER   Input parameter is invalid   \r
+  @return EFI_SUCCESS             Highlight selected item and update current selected\r
+                                  item successful\r
+  @retval EFI_INVALID_PARAMETER   Input parameter is invalid\r
 **/\r
 EFI_STATUS\r
 BootMenuSelectItem (\r
@@ -359,7 +353,7 @@ BootMenuSelectItem (
 {\r
   INT32                 SavedAttribute;\r
   EFI_STRING            String;\r
-  UINTN                 StartCol;  \r
+  UINTN                 StartCol;\r
   UINTN                 StartRow;\r
   UINTN                 PrintCol;\r
   UINTN                 PrintRow;\r
@@ -370,30 +364,31 @@ BootMenuSelectItem (
   UINTN                 ItemCountPerScreen;\r
   UINTN                 Index;\r
   BOOLEAN               RePaintItems;\r
-  \r
+\r
   if (BootMenuData == NULL || WantSelectItem >= BootMenuData->ItemCount) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
+  ASSERT (BootMenuData->ItemCount != 0);\r
   SavedAttribute = gST->ConOut->Mode->Attribute;\r
   RePaintItems = FALSE;\r
   StartCol = BootMenuData->MenuScreen.StartCol;\r
   StartRow = BootMenuData->MenuScreen.StartRow;\r
   //\r
   // print selectable items again and adjust scroll bar if need\r
-  //         \r
+  //\r
   if (BootMenuData->ScrollBarControl.HasScrollBar &&\r
       (WantSelectItem < BootMenuData->ScrollBarControl.FirstItem ||\r
       WantSelectItem > BootMenuData->ScrollBarControl.LastItem ||\r
-      WantSelectItem == BootMenuData->SelectItem)) {          \r
+      WantSelectItem == BootMenuData->SelectItem)) {\r
     ItemCountPerScreen   = BootMenuData->ScrollBarControl.ItemCountPerScreen;\r
     //\r
     // Set first item and last item\r
-    //     \r
+    //\r
     if (WantSelectItem < BootMenuData->ScrollBarControl.FirstItem) {\r
       BootMenuData->ScrollBarControl.FirstItem = WantSelectItem;\r
-      BootMenuData->ScrollBarControl.LastItem = WantSelectItem + ItemCountPerScreen - 1;  \r
+      BootMenuData->ScrollBarControl.LastItem = WantSelectItem + ItemCountPerScreen - 1;\r
     } else if (WantSelectItem > BootMenuData->ScrollBarControl.LastItem) {\r
-      BootMenuData->ScrollBarControl.FirstItem = WantSelectItem - ItemCountPerScreen + 1; \r
+      BootMenuData->ScrollBarControl.FirstItem = WantSelectItem - ItemCountPerScreen + 1;\r
       BootMenuData->ScrollBarControl.LastItem = WantSelectItem;\r
     }\r
     gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLUE);\r
@@ -406,7 +401,7 @@ BootMenuSelectItem (
         TopShadeNum++;\r
       }\r
       PrintCol = StartCol  + BootMenuData->MenuScreen.Width - 2;\r
-      PrintRow = StartRow + TITLE_TOKEN_COUNT + 2;  \r
+      PrintRow = StartRow + TITLE_TOKEN_COUNT + 2;\r
       for (Index = 0; Index < TopShadeNum; Index++, PrintRow++) {\r
         PrintCharAt (PrintCol, PrintRow, BLOCKELEMENT_LIGHT_SHADE);\r
       }\r
@@ -418,98 +413,98 @@ BootMenuSelectItem (
         LowShadeNum++;\r
       }\r
       PrintCol = StartCol  + BootMenuData->MenuScreen.Width - 2;\r
-      PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + ItemCountPerScreen - LowShadeNum;  \r
+      PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + ItemCountPerScreen - LowShadeNum;\r
       for (Index = 0; Index < LowShadeNum; Index++, PrintRow++) {\r
         PrintCharAt (PrintCol, PrintRow, BLOCKELEMENT_LIGHT_SHADE);\r
-      } \r
+      }\r
     }\r
     PrintCol = StartCol  + BootMenuData->MenuScreen.Width - 2;\r
-    PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + TopShadeNum;  \r
+    PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + TopShadeNum;\r
     for (Index = TopShadeNum; Index < ItemCountPerScreen - LowShadeNum; Index++, PrintRow++) {\r
       PrintCharAt (PrintCol, PrintRow, BLOCKELEMENT_FULL_BLOCK);\r
-    }      \r
+    }\r
 \r
 \r
     //\r
     // Clear selectable items first\r
     //\r
     PrintCol = StartCol  + 1;\r
-    PrintRow = StartRow + TITLE_TOKEN_COUNT + 2;  \r
+    PrintRow = StartRow + TITLE_TOKEN_COUNT + 2;\r
     String = AllocateZeroPool ((BootMenuData->MenuScreen.Width - 2) * sizeof (CHAR16));\r
     ASSERT (String != NULL);\r
     for (Index = 0; Index < BootMenuData->MenuScreen.Width - 3; Index++) {\r
       String[Index] = 0x20;\r
-    }      \r
-    for (Index = 0; Index < ItemCountPerScreen; Index++) {        \r
-      PrintStringAt (PrintCol, PrintRow + Index, String); \r
+    }\r
+    for (Index = 0; Index < ItemCountPerScreen; Index++) {\r
+      PrintStringAt (PrintCol, PrintRow + Index, String);\r
     }\r
     FreePool (String);\r
     //\r
-    // print selectable items  \r
+    // print selectable items\r
     //\r
     for (Index = 0; Index < ItemCountPerScreen; Index++, PrintRow++) {\r
       String = HiiGetString (gStringPackHandle, BootMenuData->PtrTokens[Index + FirstItem], NULL);\r
       PrintStringAt (PrintCol, PrintRow, String);\r
-      FreePool (String); \r
+      FreePool (String);\r
     }\r
     RePaintItems = TRUE;\r
   }\r
-  \r
-  //\r
-  // Print want to select item \r
-  //\r
-  FirstItem = BootMenuData->ScrollBarControl.FirstItem;\r
-  gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLACK);\r
-  String = HiiGetString (gStringPackHandle, BootMenuData->PtrTokens[WantSelectItem], NULL);\r
-  PrintCol = StartCol  + 1;  \r
-  PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + WantSelectItem - FirstItem;  \r
-  PrintStringAt (PrintCol, PrintRow, String);\r
-  FreePool (String);\r
-  \r
+\r
   //\r
-  // if Want Select and selected item isn't the same and doesn't re-draw selectable \r
+  // if Want Select and selected item isn't the same and doesn't re-draw selectable\r
   // items, clear select item\r
   //\r
+  FirstItem = BootMenuData->ScrollBarControl.FirstItem;\r
   if (WantSelectItem != BootMenuData->SelectItem && !RePaintItems) {\r
     gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLUE);\r
     String = HiiGetString (gStringPackHandle, BootMenuData->PtrTokens[BootMenuData->SelectItem], NULL);\r
-    PrintCol = StartCol  + 1;  \r
-    PrintRow = StartRow + 3 + BootMenuData->SelectItem - FirstItem;  \r
+    PrintCol = StartCol  + 1;\r
+    PrintRow = StartRow + 3 + BootMenuData->SelectItem - FirstItem;\r
     PrintStringAt (PrintCol, PrintRow, String);\r
-    FreePool (String);    \r
+    FreePool (String);\r
   }\r
 \r
+  //\r
+  // Print want to select item\r
+  //\r
+  gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLACK);\r
+  String = HiiGetString (gStringPackHandle, BootMenuData->PtrTokens[WantSelectItem], NULL);\r
+  PrintCol = StartCol  + 1;\r
+  PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + WantSelectItem - FirstItem;\r
+  PrintStringAt (PrintCol, PrintRow, String);\r
+  FreePool (String);\r
+\r
   gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute);\r
   BootMenuData->SelectItem = WantSelectItem;\r
   return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
-  This funciton uses to draw boot popup menu\r
+  This function uses to draw boot popup menu\r
 \r
   @param   BootMenuData           The Input BootMenuData to be processed.\r
-  \r
+\r
   @retval  EFI_SUCCESS            Draw boot popup menu successful.\r
 \r
 **/\r
-EFI_STATUS \r
+EFI_STATUS\r
 DrawBootPopupMenu (\r
   IN  BOOT_MENU_POPUP_DATA  *BootMenuData\r
   )\r
 {\r
   EFI_STRING            String;\r
   UINTN                 Index;\r
-  UINTN                 Width;  \r
+  UINTN                 Width;\r
   UINTN                 StartCol;\r
   UINTN                 StartRow;\r
   UINTN                 PrintRow;\r
   UINTN                 PrintCol;\r
   UINTN                 LineWidth;\r
-  INT32                 SavedAttribute; \r
-  UINTN                 ItemCountPerScreen;  \r
+  INT32                 SavedAttribute;\r
+  UINTN                 ItemCountPerScreen;\r
 \r
   gST->ConOut->ClearScreen (gST->ConOut);\r
-  \r
+\r
   SavedAttribute = gST->ConOut->Mode->Attribute;\r
   gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLUE);\r
   Width    = BootMenuData->MenuScreen.Width;\r
@@ -517,17 +512,17 @@ DrawBootPopupMenu (
   StartRow = BootMenuData->MenuScreen.StartRow;\r
   ItemCountPerScreen = BootMenuData->ScrollBarControl.ItemCountPerScreen;\r
   PrintRow = StartRow;\r
\r
+\r
   gST->ConOut->EnableCursor (gST->ConOut, FALSE);\r
   //\r
   // Draw Boot popup menu screen\r
   //\r
   PrintCharAt (StartCol, PrintRow, BOXDRAW_DOWN_RIGHT);\r
   for (Index = 1; Index < Width - 1; Index++) {\r
-    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL); \r
+    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);\r
   }\r
   PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_DOWN_LEFT);\r
-  \r
+\r
   //\r
   // Draw the screen for title\r
   //\r
@@ -539,18 +534,18 @@ DrawBootPopupMenu (
 \r
   for (Index = 0; Index < TITLE_TOKEN_COUNT; Index++) {\r
     PrintRow++;\r
-    PrintCharAt (StartCol, PrintRow, BOXDRAW_VERTICAL);  \r
+    PrintCharAt (StartCol, PrintRow, BOXDRAW_VERTICAL);\r
     PrintStringAt (StartCol + 1, PrintRow, String);\r
     PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL);\r
   }\r
-  \r
+\r
   PrintRow++;\r
   PrintCharAt (StartCol, PrintRow, BOXDRAW_VERTICAL_RIGHT);\r
   for (Index = 1; Index < Width - 1; Index++) {\r
-    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL); \r
+    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);\r
   }\r
-  PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL_LEFT);  \r
-  \r
+  PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL_LEFT);\r
+\r
   //\r
   // Draw screen for selectable items\r
   //\r
@@ -559,15 +554,15 @@ DrawBootPopupMenu (
     PrintCharAt (StartCol, PrintRow, BOXDRAW_VERTICAL);\r
     PrintStringAt (StartCol + 1, PrintRow, String);\r
     PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL);\r
-  }  \r
+  }\r
 \r
   PrintRow++;\r
   PrintCharAt (StartCol, PrintRow, BOXDRAW_VERTICAL_RIGHT);\r
   for (Index = 1; Index < Width - 1; Index++) {\r
-    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL); \r
+    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);\r
   }\r
   PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL_LEFT);\r
-  \r
+\r
   //\r
   // Draw screen for Help\r
   //\r
@@ -577,39 +572,39 @@ DrawBootPopupMenu (
     PrintStringAt (StartCol + 1, PrintRow, String);\r
     PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL);\r
   }\r
-  FreePool (String);  \r
-    \r
-  PrintRow++;  \r
+  FreePool (String);\r
+\r
+  PrintRow++;\r
   PrintCharAt (StartCol, PrintRow, BOXDRAW_UP_RIGHT);\r
   for (Index = 1; Index < Width - 1; Index++) {\r
-    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL); \r
+    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);\r
   }\r
-  PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_UP_LEFT);        \r
-  \r
-  \r
+  PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_UP_LEFT);\r
+\r
+\r
   //\r
   // print title strings\r
   //\r
   PrintRow = StartRow + 1;\r
   for (Index = 0; Index < TITLE_TOKEN_COUNT; Index++, PrintRow++) {\r
     String = HiiGetString (gStringPackHandle, BootMenuData->TitleToken[Index], NULL);\r
-    LineWidth = GetLineWidth (BootMenuData->TitleToken[Index]);      \r
+    LineWidth = GetLineWidth (BootMenuData->TitleToken[Index]);\r
     PrintCol = StartCol + (Width - LineWidth) / 2;\r
     PrintStringAt (PrintCol, PrintRow, String);\r
     FreePool (String);\r
   }\r
-  \r
+\r
   //\r
   // print selectable items\r
   //\r
   PrintCol = StartCol + 1;\r
-  PrintRow = StartRow + TITLE_TOKEN_COUNT + 2;  \r
+  PrintRow = StartRow + TITLE_TOKEN_COUNT + 2;\r
   for (Index = 0; Index < ItemCountPerScreen; Index++, PrintRow++) {\r
     String = HiiGetString (gStringPackHandle, BootMenuData->PtrTokens[Index], NULL);\r
     PrintStringAt (PrintCol, PrintRow, String);\r
-    FreePool (String); \r
+    FreePool (String);\r
   }\r
-  \r
+\r
   //\r
   // Print Help strings\r
   //\r
@@ -621,20 +616,20 @@ DrawBootPopupMenu (
     PrintStringAt (PrintCol, PrintRow, String);\r
     FreePool (String);\r
   }\r
-  \r
+\r
   //\r
   // Print scroll bar if has scroll bar\r
   //\r
   if (BootMenuData->ScrollBarControl.HasScrollBar) {\r
     PrintCol = StartCol + Width - 2;\r
-    PrintRow = StartRow + 2; \r
-    PrintCharAt (PrintCol, PrintRow, GEOMETRICSHAPE_UP_TRIANGLE); \r
-    PrintCharAt (PrintCol + 1, PrintRow, BOXDRAW_VERTICAL); \r
-    PrintRow += (ItemCountPerScreen + 1);    \r
+    PrintRow = StartRow + 2;\r
+    PrintCharAt (PrintCol, PrintRow, GEOMETRICSHAPE_UP_TRIANGLE);\r
+    PrintCharAt (PrintCol + 1, PrintRow, BOXDRAW_VERTICAL);\r
+    PrintRow += (ItemCountPerScreen + 1);\r
     PrintCharAt (PrintCol, PrintRow, GEOMETRICSHAPE_DOWN_TRIANGLE);\r
-    PrintCharAt (PrintCol + 1, PrintRow, BOXDRAW_VERTICAL); \r
-  }  \r
-    \r
+    PrintCharAt (PrintCol + 1, PrintRow, BOXDRAW_VERTICAL);\r
+  }\r
+\r
   gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute);\r
   //\r
   // Print Selected item\r
@@ -644,7 +639,7 @@ DrawBootPopupMenu (
 }\r
 \r
 /**\r
-  This funciton uses to boot from selected item \r
+  This function uses to boot from selected item\r
 \r
   @param   BootOptions            Pointer to EFI_BOOT_MANAGER_LOAD_OPTION array.\r
   @param   BootOptionCount        Number of boot option.\r
@@ -653,7 +648,7 @@ DrawBootPopupMenu (
 VOID\r
 BootFromSelectOption (\r
   IN   EFI_BOOT_MANAGER_LOAD_OPTION  *BootOptions,\r
-  IN   UINTN                         BootOptionCount, \r
+  IN   UINTN                         BootOptionCount,\r
   IN   UINTN                         SelectItem\r
   )\r
 {\r
@@ -676,9 +671,9 @@ BootFromSelectOption (
 \r
 /**\r
   This function will change video resolution and text mode\r
-  according to defined setup mode or defined boot mode  \r
+  according to defined setup mode or defined boot mode\r
 \r
-  @param  IsSetupMode   Indicate mode is changed to setup mode or boot mode. \r
+  @param  IsSetupMode   Indicate mode is changed to setup mode or boot mode.\r
 \r
   @retval  EFI_SUCCESS  Mode is changed successfully.\r
   @retval  Others             Mode failed to be changed.\r
@@ -706,13 +701,13 @@ BdsSetConsoleMode (
   EFI_STATUS                            Status;\r
   UINTN                                 Index;\r
   UINTN                                 CurrentColumn;\r
-  UINTN                                 CurrentRow;  \r
+  UINTN                                 CurrentRow;\r
 \r
   MaxGopMode  = 0;\r
   MaxTextMode = 0;\r
 \r
   //\r
-  // Get current video resolution and text mode \r
+  // Get current video resolution and text mode\r
   //\r
   Status = gBS->HandleProtocol (\r
                   gST->ConsoleOutHandle,\r
@@ -730,7 +725,7 @@ BdsSetConsoleMode (
                   );\r
   if (EFI_ERROR (Status)) {\r
     SimpleTextOut = NULL;\r
-  }  \r
+  }\r
 \r
   if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {\r
     return EFI_UNSUPPORTED;\r
@@ -751,12 +746,12 @@ BdsSetConsoleMode (
     NewHorizontalResolution = mBootHorizontalResolution;\r
     NewVerticalResolution   = mBootVerticalResolution;\r
     NewColumns              = mBootTextModeColumn;\r
-    NewRows                 = mBootTextModeRow;   \r
+    NewRows                 = mBootTextModeRow;\r
   }\r
-  \r
+\r
   if (GraphicsOutput != NULL) {\r
     MaxGopMode  = GraphicsOutput->Mode->MaxMode;\r
-  } \r
+  }\r
 \r
   if (SimpleTextOut != NULL) {\r
     MaxTextMode = SimpleTextOut->Mode->MaxMode;\r
@@ -860,7 +855,7 @@ BdsSetConsoleMode (
   ASSERT_EFI_ERROR (Status);\r
   Status = PcdSet32S (PcdConOutRow, NewRows);\r
   ASSERT_EFI_ERROR (Status);\r
-  \r
+\r
   //\r
   // Video mode is changed, so restart graphics console driver and higher level driver.\r
   // Reconnect graphics console driver and higher level driver.\r
@@ -893,10 +888,10 @@ BdsSetConsoleMode (
 \r
   @param   ImageHandle     The image handle.\r
   @param   SystemTable     The system table.\r
-  \r
+\r
   @retval  EFI_SUCCESS          Boot from selected boot option, and return success from boot option\r
   @retval  EFI_NOT_FOUND        User select to enter setup or can not find boot option\r
-  \r
+\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -906,7 +901,7 @@ BootManagerMenuEntry (
   )\r
 {\r
   EFI_BOOT_MANAGER_LOAD_OPTION    *BootOption;\r
-  UINTN                           BootOptionCount;  \r
+  UINTN                           BootOptionCount;\r
   EFI_STATUS                      Status;\r
   BOOT_MENU_POPUP_DATA            BootMenuData;\r
   UINTN                           Index;\r
@@ -949,7 +944,7 @@ BootManagerMenuEntry (
 \r
   if (!mModeInitialized) {\r
     //\r
-    // After the console is ready, get current video resolution \r
+    // After the console is ready, get current video resolution\r
     // and text mode before launching setup at first time.\r
     //\r
     Status = gBS->HandleProtocol (\r
@@ -960,7 +955,7 @@ BootManagerMenuEntry (
     if (EFI_ERROR (Status)) {\r
       GraphicsOutput = NULL;\r
     }\r
-    \r
+\r
     Status = gBS->HandleProtocol (\r
                     gST->ConsoleOutHandle,\r
                     &gEfiSimpleTextOutProtocolGuid,\r
@@ -968,7 +963,7 @@ BootManagerMenuEntry (
                     );\r
     if (EFI_ERROR (Status)) {\r
       SimpleTextOut = NULL;\r
-    }  \r
+    }\r
 \r
     if (GraphicsOutput != NULL) {\r
       //\r
@@ -991,14 +986,14 @@ BootManagerMenuEntry (
 \r
     //\r
     // Get user defined text mode for setup.\r
-    //  \r
+    //\r
     mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
-    mSetupVerticalResolution   = PcdGet32 (PcdSetupVideoVerticalResolution);      \r
+    mSetupVerticalResolution   = PcdGet32 (PcdSetupVideoVerticalResolution);\r
     mSetupTextModeColumn       = PcdGet32 (PcdSetupConOutColumn);\r
     mSetupTextModeRow          = PcdGet32 (PcdSetupConOutRow);\r
     mModeInitialized           = TRUE;\r
   }\r
-  \r
+\r
   //\r
   // Set back to conventional setup resolution\r
   //\r
@@ -1012,7 +1007,7 @@ BootManagerMenuEntry (
   // According to boot menu data to draw boot popup menu\r
   //\r
   DrawBootPopupMenu (&BootMenuData);\r
-  \r
+\r
   //\r
   // check user input to determine want to re-draw or boot from user selected item\r
   //\r
@@ -1022,18 +1017,18 @@ BootManagerMenuEntry (
     Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
     if (!EFI_ERROR (Status)) {\r
       switch (Key.UnicodeChar) {\r
-      \r
-      case CHAR_NULL:        \r
-        switch (Key.ScanCode) {          \r
-          \r
+\r
+      case CHAR_NULL:\r
+        switch (Key.ScanCode) {\r
+\r
         case SCAN_UP:\r
           SelectItem = BootMenuData.SelectItem == 0 ? BootMenuData.ItemCount - 1 : BootMenuData.SelectItem - 1;\r
-          BootMenuSelectItem (SelectItem, &BootMenuData); \r
+          BootMenuSelectItem (SelectItem, &BootMenuData);\r
           break;\r
-        \r
+\r
         case SCAN_DOWN:\r
           SelectItem = BootMenuData.SelectItem == BootMenuData.ItemCount - 1 ? 0 : BootMenuData.SelectItem + 1;\r
-          BootMenuSelectItem (SelectItem, &BootMenuData); \r
+          BootMenuSelectItem (SelectItem, &BootMenuData);\r
           break;\r
 \r
         case SCAN_ESC:\r
@@ -1044,12 +1039,12 @@ BootManagerMenuEntry (
           //\r
           BdsSetConsoleMode (FALSE);\r
           break;\r
-          \r
+\r
         default:\r
           break;\r
         }\r
         break;\r
-        \r
+\r
       case CHAR_CARRIAGE_RETURN:\r
         gST->ConOut->ClearScreen (gST->ConOut);\r
         //\r
@@ -1063,7 +1058,7 @@ BootManagerMenuEntry (
         BdsSetConsoleMode (TRUE);\r
         DrawBootPopupMenu (&BootMenuData);\r
         break;\r
-        \r
+\r
       default:\r
         break;\r
       }\r
@@ -1075,5 +1070,5 @@ BootManagerMenuEntry (
   HiiRemovePackages (gStringPackHandle);\r
 \r
   return Status;\r
-  \r
+\r
 }\r