]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
Add BootlogoOnly feature in BDS for BGRT
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / FrontPage.c
index efecf7bec6018828e765cccb55f49fa0a7152806..53dcf82ea91999bdd94a84ec4deec0ae94df0152 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   FrontPage routines to handle the callbacks and browser calls\r
 \r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\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
@@ -17,15 +17,26 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Language.h"\r
 #include "Hotkey.h"\r
 \r
-BOOLEAN   mSetupModeInitialized = FALSE;\r
-UINT32    mSetupTextModeColumn;\r
-UINT32    mSetupTextModeRow;\r
-UINT32    mSetupHorizontalResolution;\r
-UINT32    mSetupVerticalResolution;\r
+BOOLEAN   mModeInitialized = FALSE;\r
 \r
 BOOLEAN   gConnectAllHappened = FALSE;\r
 UINTN     gCallbackKey;\r
 \r
+//\r
+// Boot video resolution and text mode.\r
+//\r
+UINT32    mBootHorizontalResolution    = 0;\r
+UINT32    mBootVerticalResolution      = 0;\r
+UINT32    mBootTextModeColumn          = 0;\r
+UINT32    mBootTextModeRow             = 0;\r
+//\r
+// BIOS setup video resolution and text mode.\r
+//\r
+UINT32    mSetupTextModeColumn         = 0;\r
+UINT32    mSetupTextModeRow            = 0;\r
+UINT32    mSetupHorizontalResolution   = 0;\r
+UINT32    mSetupVerticalResolution     = 0;\r
+\r
 EFI_FORM_BROWSER2_PROTOCOL      *gFormBrowser2;\r
 \r
 FRONT_PAGE_CALLBACK_DATA  gFrontPagePrivate = {\r
@@ -891,20 +902,24 @@ ShowProgress (
   if (TimeoutDefault == 0) {\r
     return EFI_TIMEOUT;\r
   }\r
-\r
+  \r
   DEBUG ((EFI_D_INFO, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));\r
 \r
   SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
   SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
   SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
-\r
-  //\r
-  // Clear the progress status bar first\r
-  //\r
+  \r
   TmpStr = GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION));\r
-  if (TmpStr != NULL) {\r
-    PlatformBdsShowProgress (Foreground, Background, TmpStr, Color, 0, 0);\r
+\r
+  if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
+    //\r
+    // Clear the progress status bar first\r
+    //\r
+    if (TmpStr != NULL) {\r
+      PlatformBdsShowProgress (Foreground, Background, TmpStr, Color, 0, 0);\r
+    }\r
   }\r
+  \r
 \r
   TimeoutRemain = TimeoutDefault;\r
   while (TimeoutRemain != 0) {\r
@@ -915,22 +930,27 @@ ShowProgress (
       break;\r
     }\r
     TimeoutRemain--;\r
-\r
-    //\r
-    // Show progress\r
-    //\r
-    if (TmpStr != NULL) {\r
-      PlatformBdsShowProgress (\r
-        Foreground,\r
-        Background,\r
-        TmpStr,\r
-        Color,\r
-        ((TimeoutDefault - TimeoutRemain) * 100 / TimeoutDefault),\r
-        0\r
-        );\r
+    \r
+    if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
+      //\r
+      // Show progress\r
+      //\r
+      if (TmpStr != NULL) {\r
+        PlatformBdsShowProgress (\r
+          Foreground,\r
+          Background,\r
+          TmpStr,\r
+          Color,\r
+          ((TimeoutDefault - TimeoutRemain) * 100 / TimeoutDefault),\r
+          0\r
+          );\r
+      }\r
     }\r
   }\r
-  gBS->FreePool (TmpStr);\r
+  \r
+  if (TmpStr != NULL) {\r
+    gBS->FreePool (TmpStr);\r
+  }\r
 \r
   //\r
   // Timeout expired\r
@@ -957,186 +977,6 @@ ShowProgress (
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  This function will change video resolution and text mode for setup when setup is launched.\r
-\r
-  @param   None.\r
-\r
-  @retval  EFI_SUCCESS  Mode is changed successfully.\r
-  @retval  Others       Mode failed to changed.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ChangeModeForSetup (\r
-  VOID\r
-  )\r
-{\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL          *GraphicsOutput;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL       *SimpleTextOut;\r
-  UINTN                                 SizeOfInfo;\r
-  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info;\r
-  UINT32                                MaxGopMode;\r
-  UINT32                                MaxTextMode;\r
-  UINT32                                ModeNumber;\r
-  UINTN                                 HandleCount;\r
-  EFI_HANDLE                            *HandleBuffer;\r
-  EFI_STATUS                            Status;\r
-  UINTN                                 Index;\r
-  UINTN                                 CurrentColumn;\r
-  UINTN                                 CurrentRow;  \r
-\r
-  Status = gBS->HandleProtocol (\r
-                  gST->ConsoleOutHandle,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  (VOID**)&GraphicsOutput\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    GraphicsOutput = NULL;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  gST->ConsoleOutHandle,\r
-                  &gEfiSimpleTextOutProtocolGuid,\r
-                  (VOID**)&SimpleTextOut\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    SimpleTextOut = NULL;\r
-  }  \r
-\r
-  if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Get user defined text mode for setup only once.\r
-  //  \r
-  if (!mSetupModeInitialized) {\r
-    mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
-    mSetupVerticalResolution   = PcdGet32 (PcdSetupVideoVerticalResolution);      \r
-    mSetupTextModeColumn       = PcdGet32 (PcdSetupConOutColumn);\r
-    mSetupTextModeRow          = PcdGet32 (PcdSetupConOutRow);\r
-    mSetupModeInitialized     = TRUE;\r
-  }\r
-\r
-  MaxGopMode  = GraphicsOutput->Mode->MaxMode;\r
-  MaxTextMode = SimpleTextOut->Mode->MaxMode;\r
-\r
-  //\r
-  // 1. If current video resolution is same with setup video resolution,\r
-  //    video resolution need not be changed.\r
-  //    1.1. If current text mode is same with setup text mode, text mode need not be changed.\r
-  //    1.2. If current text mode is different with setup text mode, text mode need be changed to setup text mode.\r
-  // 2. If current video resolution is different with setup video resolution, we need restart whole console drivers.\r
-  //\r
-  for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {\r
-    Status = GraphicsOutput->QueryMode (\r
-                       GraphicsOutput,\r
-                       ModeNumber,\r
-                       &SizeOfInfo,\r
-                       &Info\r
-                       );\r
-    if (!EFI_ERROR (Status)) {\r
-      if ((Info->HorizontalResolution == mSetupHorizontalResolution) &&\r
-          (Info->VerticalResolution == mSetupVerticalResolution)) {\r
-        if ((GraphicsOutput->Mode->Info->HorizontalResolution == mSetupHorizontalResolution) &&\r
-            (GraphicsOutput->Mode->Info->VerticalResolution == mSetupVerticalResolution)) {\r
-          //\r
-          // If current video resolution is same with setup video resolution, \r
-          // then check if current text mode is same with setup text mode.\r
-          //\r
-          Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);\r
-          ASSERT_EFI_ERROR (Status);\r
-          if (CurrentColumn == mSetupTextModeColumn && CurrentRow == mSetupTextModeRow) {\r
-            //\r
-            // Current text mode is same with setup text mode, text mode need not be change.\r
-            //\r
-            FreePool (Info);\r
-            return EFI_SUCCESS;\r
-          } else {\r
-            //\r
-            // Current text mode is different with setup text mode, text mode need be change to new text mode.\r
-            //\r
-            for (Index = 0; Index < MaxTextMode; Index++) {\r
-              Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);\r
-              if (!EFI_ERROR(Status)) {\r
-                if ((CurrentColumn == mSetupTextModeColumn) && (CurrentRow == mSetupTextModeRow)) {\r
-                  //\r
-                  // setup text mode is supported, set it.\r
-                  //\r
-                  Status = SimpleTextOut->SetMode (SimpleTextOut, Index);\r
-                  ASSERT_EFI_ERROR (Status);\r
-                  //\r
-                  // Update text mode PCD.\r
-                  //\r
-                  PcdSet32 (PcdConOutColumn, mSetupTextModeColumn);\r
-                  PcdSet32 (PcdConOutRow, mSetupTextModeRow);\r
-                  FreePool (Info);\r
-                  return EFI_SUCCESS;\r
-                }\r
-              }\r
-            }\r
-            if (Index == MaxTextMode) {\r
-              //\r
-              // If setup text mode is not supported, return error.\r
-              //\r
-              FreePool (Info);\r
-              return EFI_UNSUPPORTED;\r
-            }\r
-          }\r
-        } else {\r
-          FreePool (Info);\r
-          //\r
-          // If current video resolution is not same with the setup video resolution, set new video resolution.\r
-          // In this case, the drivers which produce simple text out need be restarted.\r
-          //\r
-          Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);\r
-          if (!EFI_ERROR (Status)) {\r
-            //\r
-            // Set PCD to restart GraphicsConsole and Consplitter to change video resolution \r
-            // and produce new text mode based on new resolution.\r
-            //\r
-            PcdSet32 (PcdVideoHorizontalResolution, mSetupHorizontalResolution);\r
-            PcdSet32 (PcdVideoVerticalResolution, mSetupVerticalResolution);\r
-            PcdSet32 (PcdConOutColumn, mSetupTextModeColumn);\r
-            PcdSet32 (PcdConOutRow, mSetupTextModeRow);\r
-            \r
-            Status = gBS->LocateHandleBuffer (\r
-                             ByProtocol,\r
-                             &gEfiSimpleTextOutProtocolGuid,\r
-                             NULL,\r
-                             &HandleCount,\r
-                             &HandleBuffer\r
-                             );\r
-            if (!EFI_ERROR (Status)) {\r
-              for (Index = 0; Index < HandleCount; Index++) {\r
-                gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
-              }\r
-              for (Index = 0; Index < HandleCount; Index++) {\r
-                gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
-              }\r
-              if (HandleBuffer != NULL) {\r
-                FreePool (HandleBuffer);\r
-              }\r
-              break;\r
-            }\r
-          }\r
-        }\r
-      }\r
-      FreePool (Info);\r
-    }\r
-  }\r
-\r
-  if (ModeNumber == MaxGopMode) {\r
-    //\r
-    // If the new resolution is not supported, return error.\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
 /**\r
   This function is the main entry of the platform setup entry.\r
   The function will present the main menu of the system setup,\r
@@ -1155,8 +995,16 @@ PlatformBdsEnterFrontPage (
   IN BOOLEAN                      ConnectAllHappened\r
   )\r
 {\r
-  EFI_STATUS                    Status;\r
-  EFI_BOOT_LOGO_PROTOCOL        *BootLogo;\r
+  EFI_STATUS                         Status;\r
+  EFI_STATUS                         StatusHotkey; \r
+  EFI_BOOT_LOGO_PROTOCOL             *BootLogo;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL       *GraphicsOutput;\r
+  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL    *SimpleTextOut;\r
+  UINTN                              BootTextColumn;\r
+  UINTN                              BootTextRow;\r
+  \r
+  GraphicsOutput = NULL;\r
+  SimpleTextOut = NULL;\r
 \r
   PERF_START (NULL, "BdsTimeOut", "BDS", 0);\r
   //\r
@@ -1165,17 +1013,75 @@ PlatformBdsEnterFrontPage (
   if (ConnectAllHappened) {\r
     gConnectAllHappened = TRUE;\r
   }\r
+  \r
+  if (!mModeInitialized) {\r
+    //\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
+                    gST->ConsoleOutHandle,\r
+                    &gEfiGraphicsOutputProtocolGuid,\r
+                    (VOID**)&GraphicsOutput\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      GraphicsOutput = NULL;\r
+    }\r
+    \r
+    Status = gBS->HandleProtocol (\r
+                    gST->ConsoleOutHandle,\r
+                    &gEfiSimpleTextOutProtocolGuid,\r
+                    (VOID**)&SimpleTextOut\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      SimpleTextOut = NULL;\r
+    }  \r
+\r
+    if (GraphicsOutput != NULL) {\r
+      //\r
+      // Get current video resolution and text mode.\r
+      //\r
+      mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+      mBootVerticalResolution   = GraphicsOutput->Mode->Info->VerticalResolution;\r
+    }\r
+\r
+    if (SimpleTextOut != NULL) {\r
+      Status = SimpleTextOut->QueryMode (\r
+                                SimpleTextOut,\r
+                                SimpleTextOut->Mode->Mode,\r
+                                &BootTextColumn,\r
+                                &BootTextRow\r
+                                );\r
+      mBootTextModeColumn = (UINT32)BootTextColumn;\r
+      mBootTextModeRow    = (UINT32)BootTextRow;\r
+    }\r
+\r
+    //\r
+    // Get user defined text mode for setup.\r
+    //  \r
+    mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
+    mSetupVerticalResolution   = PcdGet32 (PcdSetupVideoVerticalResolution);      \r
+    mSetupTextModeColumn       = PcdGet32 (PcdSetupConOutColumn);\r
+    mSetupTextModeRow          = PcdGet32 (PcdSetupConOutRow);\r
+\r
+    mModeInitialized           = TRUE;\r
+  }\r
+\r
\r
 \r
   HotkeyBoot ();\r
   if (TimeoutDefault != 0xffff) {\r
     Status = ShowProgress (TimeoutDefault);\r
-    HotkeyBoot ();\r
+    StatusHotkey = HotkeyBoot ();\r
 \r
-    //\r
-    // Ensure screen is clear when switch Console from Graphics mode to Text mode\r
-    //\r
-    gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
-    gST->ConOut->ClearScreen (gST->ConOut);\r
+    if (!FeaturePcdGet(PcdBootlogoOnlyEnable) || !EFI_ERROR(StatusHotkey)){\r
+      //\r
+      // Ensure screen is clear when switch Console from Graphics mode to Text mode\r
+      // Skip it in normal boot \r
+      //\r
+      gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
+      gST->ConOut->ClearScreen (gST->ConOut);\r
+    }\r
 \r
     if (EFI_ERROR (Status)) {\r
       //\r
@@ -1198,7 +1104,7 @@ PlatformBdsEnterFrontPage (
     //\r
     // Set proper video resolution and text mode for setup\r
     //\r
-    ChangeModeForSetup ();\r
+    BdsSetConsoleMode (TRUE);\r
     \r
     InitializeFrontPage (FALSE);\r
 \r
@@ -1286,3 +1192,213 @@ Exit:
   //\r
   PERF_END (NULL, "BdsTimeOut", "BDS", 0);\r
 }\r
+\r
+/**\r
+  This function will change video resolution and text 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
+\r
+  @retval  EFI_SUCCESS  Mode is changed successfully.\r
+  @retval  Others             Mode failed to be changed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsSetConsoleMode (\r
+  BOOLEAN  IsSetupMode\r
+  )\r
+{\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL          *GraphicsOutput;\r
+  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL       *SimpleTextOut;\r
+  UINTN                                 SizeOfInfo;\r
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info;\r
+  UINT32                                MaxGopMode;\r
+  UINT32                                MaxTextMode;\r
+  UINT32                                ModeNumber;\r
+  UINT32                                NewHorizontalResolution;\r
+  UINT32                                NewVerticalResolution;\r
+  UINT32                                NewColumns;\r
+  UINT32                                NewRows;\r
+  UINTN                                 HandleCount;\r
+  EFI_HANDLE                            *HandleBuffer;\r
+  EFI_STATUS                            Status;\r
+  UINTN                                 Index;\r
+  UINTN                                 CurrentColumn;\r
+  UINTN                                 CurrentRow;  \r
+\r
+  MaxGopMode  = 0;\r
+  MaxTextMode = 0;\r
+\r
+  //\r
+  // Get current video resolution and text mode \r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  gST->ConsoleOutHandle,\r
+                  &gEfiGraphicsOutputProtocolGuid,\r
+                  (VOID**)&GraphicsOutput\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    GraphicsOutput = NULL;\r
+  }\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  gST->ConsoleOutHandle,\r
+                  &gEfiSimpleTextOutProtocolGuid,\r
+                  (VOID**)&SimpleTextOut\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    SimpleTextOut = NULL;\r
+  }  \r
+\r
+  if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (IsSetupMode) {\r
+    //\r
+    // The requried resolution and text mode is setup mode.\r
+    //\r
+    NewHorizontalResolution = mSetupHorizontalResolution;\r
+    NewVerticalResolution   = mSetupVerticalResolution;\r
+    NewColumns              = mSetupTextModeColumn;\r
+    NewRows                 = mSetupTextModeRow;\r
+  } else {\r
+    //\r
+    // The required resolution and text mode is boot mode.\r
+    //\r
+    NewHorizontalResolution = mBootHorizontalResolution;\r
+    NewVerticalResolution   = mBootVerticalResolution;\r
+    NewColumns              = mBootTextModeColumn;\r
+    NewRows                 = mBootTextModeRow;   \r
+  }\r
+  \r
+  if (GraphicsOutput != NULL) {\r
+    MaxGopMode  = GraphicsOutput->Mode->MaxMode;\r
+  } \r
+\r
+  if (SimpleTextOut != NULL) {\r
+    MaxTextMode = SimpleTextOut->Mode->MaxMode;\r
+  }\r
+\r
+  //\r
+  // 1. If current video resolution is same with required video resolution,\r
+  //    video resolution need not be changed.\r
+  //    1.1. If current text mode is same with required text mode, text mode need not be changed.\r
+  //    1.2. If current text mode is different from required text mode, text mode need be changed.\r
+  // 2. If current video resolution is different from required video resolution, we need restart whole console drivers.\r
+  //\r
+  for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {\r
+    Status = GraphicsOutput->QueryMode (\r
+                       GraphicsOutput,\r
+                       ModeNumber,\r
+                       &SizeOfInfo,\r
+                       &Info\r
+                       );\r
+    if (!EFI_ERROR (Status)) {\r
+      if ((Info->HorizontalResolution == NewHorizontalResolution) &&\r
+          (Info->VerticalResolution == NewVerticalResolution)) {\r
+        if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&\r
+            (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {\r
+          //\r
+          // Current resolution is same with required resolution, check if text mode need be set\r
+          //\r
+          Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);\r
+          ASSERT_EFI_ERROR (Status);\r
+          if (CurrentColumn == NewColumns && CurrentRow == NewRows) {\r
+            //\r
+            // If current text mode is same with required text mode. Do nothing\r
+            //\r
+            FreePool (Info);\r
+            return EFI_SUCCESS;\r
+          } else {\r
+            //\r
+            // If current text mode is different from requried text mode.  Set new video mode\r
+            //\r
+            for (Index = 0; Index < MaxTextMode; Index++) {\r
+              Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);\r
+              if (!EFI_ERROR(Status)) {\r
+                if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {\r
+                  //\r
+                  // Required text mode is supported, set it.\r
+                  //\r
+                  Status = SimpleTextOut->SetMode (SimpleTextOut, Index);\r
+                  ASSERT_EFI_ERROR (Status);\r
+                  //\r
+                  // Update text mode PCD.\r
+                  //\r
+                  PcdSet32 (PcdConOutColumn, mSetupTextModeColumn);\r
+                  PcdSet32 (PcdConOutRow, mSetupTextModeRow);\r
+                  FreePool (Info);\r
+                  return EFI_SUCCESS;\r
+                }\r
+              }\r
+            }\r
+            if (Index == MaxTextMode) {\r
+              //\r
+              // If requried text mode is not supported, return error.\r
+              //\r
+              FreePool (Info);\r
+              return EFI_UNSUPPORTED;\r
+            }\r
+          }\r
+        } else {\r
+          //\r
+          // If current video resolution is not same with the new one, set new video resolution.\r
+          // In this case, the driver which produces simple text out need be restarted.\r
+          //\r
+          Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);\r
+          if (!EFI_ERROR (Status)) {\r
+            FreePool (Info);\r
+            break;\r
+          }\r
+        }\r
+      }\r
+      FreePool (Info);\r
+    }\r
+  }\r
+\r
+  if (ModeNumber == MaxGopMode) {\r
+    //\r
+    // If the resolution is not supported, return error.\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Set PCD to Inform GraphicsConsole to change video resolution.\r
+  // Set PCD to Inform Consplitter to change text mode.\r
+  //\r
+  PcdSet32 (PcdVideoHorizontalResolution, NewHorizontalResolution);\r
+  PcdSet32 (PcdVideoVerticalResolution, NewVerticalResolution);\r
+  PcdSet32 (PcdConOutColumn, NewColumns);\r
+  PcdSet32 (PcdConOutRow, NewRows);\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
+  // Locate all the handles with GOP protocol and reconnect it.\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                   ByProtocol,\r
+                   &gEfiSimpleTextOutProtocolGuid,\r
+                   NULL,\r
+                   &HandleCount,\r
+                   &HandleBuffer\r
+                   );\r
+  if (!EFI_ERROR (Status)) {\r
+    for (Index = 0; Index < HandleCount; Index++) {\r
+      gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
+    }\r
+    for (Index = 0; Index < HandleCount; Index++) {\r
+      gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
+    }\r
+    if (HandleBuffer != NULL) {\r
+      FreePool (HandleBuffer);\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r