]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
Update for IntelFrameworkModulePkg.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / FrontPage.c
index 807526cb582844696b1d6349a633763201aa7b46..efecf7bec6018828e765cccb55f49fa0a7152806 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   FrontPage routines to handle the callbacks and browser calls\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, 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
@@ -15,8 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Bds.h"\r
 #include "FrontPage.h"\r
 #include "Language.h"\r
+#include "Hotkey.h"\r
 \r
-EFI_GUID  mFrontPageGuid      = FRONT_PAGE_FORMSET_GUID;\r
+BOOLEAN   mSetupModeInitialized = FALSE;\r
+UINT32    mSetupTextModeColumn;\r
+UINT32    mSetupTextModeRow;\r
+UINT32    mSetupHorizontalResolution;\r
+UINT32    mSetupVerticalResolution;\r
 \r
 BOOLEAN   gConnectAllHappened = FALSE;\r
 UINTN     gCallbackKey;\r
@@ -45,10 +50,7 @@ HII_VENDOR_DEVICE_PATH  mFrontPageHiiVendorDevicePath = {
         (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
       }\r
     },\r
-    //\r
-    // {8E6D99EE-7531-48f8-8745-7F6144468FF2}\r
-    //\r
-    { 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 } }\r
+    FRONT_PAGE_FORMSET_GUID\r
   },\r
   {\r
     END_DEVICE_PATH_TYPE,\r
@@ -127,8 +129,8 @@ FakeRouteConfig (
   }\r
 \r
   *Progress = Configuration;\r
-  if (!HiiIsConfigHdrMatch (Configuration, &mBootMaintGuid, mBootMaintStorageName)\r
-      && !HiiIsConfigHdrMatch (Configuration, &mFileExplorerGuid, mFileExplorerStorageName)) {\r
+  if (!HiiIsConfigHdrMatch (Configuration, &gBootMaintFormSetGuid, mBootMaintStorageName)\r
+      && !HiiIsConfigHdrMatch (Configuration, &gFileExploreFormSetGuid, mFileExplorerStorageName)) {\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
@@ -173,118 +175,130 @@ FrontPageCallback (
   CHAR8                         *PlatformSupportedLanguages;\r
   CHAR8                         *BestLanguage;\r
 \r
-  if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {\r
+  if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {\r
     //\r
-    // Do nothing for UEFI OPEN/CLOSE Action\r
+    // All other action return unsupported.\r
     //\r
-    return EFI_SUCCESS;\r
+    return EFI_UNSUPPORTED;\r
   }\r
+  \r
+  gCallbackKey = QuestionId;\r
 \r
-  if ((Value == NULL) || (ActionRequest == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
+  if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
+    if ((Value == NULL) || (ActionRequest == NULL)) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
 \r
-  gCallbackKey = QuestionId;\r
+    switch (QuestionId) {\r
+    case FRONT_PAGE_KEY_CONTINUE:\r
+      //\r
+      // This is the continue - clear the screen and return an error to get out of FrontPage loop\r
+      //\r
+      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
+      break;\r
 \r
-  //\r
-  // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r
-  // describe to their customers in documentation how to find their setup information (namely\r
-  // under the device manager and specific buckets)\r
-  //\r
-  switch (QuestionId) {\r
-  case FRONT_PAGE_KEY_CONTINUE:\r
-    //\r
-    // This is the continue - clear the screen and return an error to get out of FrontPage loop\r
-    //\r
-    break;\r
+    case FRONT_PAGE_KEY_LANGUAGE:\r
+      //\r
+      // Collect the languages from what our current Language support is based on our VFR\r
+      //\r
+      LanguageString = HiiGetSupportedLanguages (gFrontPagePrivate.HiiHandle);\r
+      ASSERT (LanguageString != NULL);\r
+      //\r
+      // Allocate working buffer for RFC 4646 language in supported LanguageString.\r
+      //\r
+      Lang = AllocatePool (AsciiStrSize (LanguageString));\r
+      ASSERT (Lang != NULL);\r
 \r
-  case FRONT_PAGE_KEY_LANGUAGE:\r
-    //\r
-    // Collect the languages from what our current Language support is based on our VFR\r
-    //\r
-    LanguageString = HiiGetSupportedLanguages (gFrontPagePrivate.HiiHandle);\r
-    ASSERT (LanguageString != NULL);\r
-    //\r
-    // Allocate working buffer for RFC 4646 language in supported LanguageString.\r
-    //\r
-    Lang = AllocatePool (AsciiStrSize (LanguageString));\r
-    ASSERT (Lang != NULL);\r
+      Index = 0;\r
+      LangCode = LanguageString;\r
+      while (*LangCode != 0) {\r
+        GetNextLanguage (&LangCode, Lang);\r
 \r
-    Index = 0;\r
-    LangCode = LanguageString;\r
-    while (*LangCode != 0) {\r
-      GetNextLanguage (&LangCode, Lang);\r
+        if (Index == Value->u8) {\r
+          break;\r
+        }\r
 \r
-      if (Index == Value->u8) {\r
-        break;\r
+        Index++;\r
       }\r
 \r
-      Index++;\r
-    }\r
+      PlatformSupportedLanguages = GetEfiGlobalVariable (L"PlatformLangCodes");\r
+      if (PlatformSupportedLanguages == NULL) {\r
+        PlatformSupportedLanguages = AllocateCopyPool (\r
+                                       AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),\r
+                                       (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)\r
+                                       );\r
+        ASSERT (PlatformSupportedLanguages != NULL);\r
+      }\r
 \r
-    PlatformSupportedLanguages = GetEfiGlobalVariable (L"PlatformLangCodes");\r
-    if (PlatformSupportedLanguages == NULL) {\r
-      PlatformSupportedLanguages = AllocateCopyPool (\r
-                                     AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),\r
-                                     (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)\r
-                                     );\r
-      ASSERT (PlatformSupportedLanguages != NULL);\r
-    }\r
+      //\r
+      // Select the best language in platform supported Language.\r
+      //\r
+      BestLanguage = GetBestLanguage (\r
+                       PlatformSupportedLanguages,\r
+                       FALSE,\r
+                       Lang,\r
+                       NULL\r
+                       );\r
+      if (BestLanguage != NULL) {\r
+        Status = gRT->SetVariable (\r
+                        L"PlatformLang",\r
+                        &gEfiGlobalVariableGuid,\r
+                        EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                        AsciiStrSize (BestLanguage),\r
+                        Lang\r
+                        );\r
+        ASSERT_EFI_ERROR(Status);\r
+        FreePool (BestLanguage);\r
+      } else {\r
+        ASSERT (FALSE);\r
+      }\r
 \r
-    //\r
-    // Select the best language in platform supported Language.\r
-    //\r
-    BestLanguage = GetBestLanguage (\r
-                     PlatformSupportedLanguages,\r
-                     FALSE,\r
-                     Lang,\r
-                     NULL\r
-                     );\r
-    if (BestLanguage != NULL) {\r
-      Status = gRT->SetVariable (\r
-                      L"PlatformLang",\r
-                      &gEfiGlobalVariableGuid,\r
-                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                      AsciiStrSize (BestLanguage),\r
-                      Lang\r
-                      );\r
-      ASSERT_EFI_ERROR(Status);\r
-      FreePool (BestLanguage);\r
-    } else {\r
-      ASSERT (FALSE);\r
-    }\r
+      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
 \r
-    FreePool (PlatformSupportedLanguages);\r
-    FreePool (Lang);\r
-    FreePool (LanguageString);\r
-    break;\r
+      FreePool (PlatformSupportedLanguages);\r
+      FreePool (Lang);\r
+      FreePool (LanguageString);\r
+      break;\r
 \r
-  case FRONT_PAGE_KEY_BOOT_MANAGER:\r
-    //\r
-    // Boot Manager\r
-    //\r
-    break;\r
+    default:\r
+      break;\r
+    }\r
+  } else if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
+    if (Value == NULL) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
 \r
-  case FRONT_PAGE_KEY_DEVICE_MANAGER:\r
     //\r
-    // Device Manager\r
+    // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r
+    // describe to their customers in documentation how to find their setup information (namely\r
+    // under the device manager and specific buckets)\r
     //\r
-    break;\r
+    switch (QuestionId) {\r
+    case FRONT_PAGE_KEY_BOOT_MANAGER:\r
+      //\r
+      // Boot Manager\r
+      //\r
+      break;\r
 \r
-  case FRONT_PAGE_KEY_BOOT_MAINTAIN:\r
-    //\r
-    // Boot Maintenance Manager\r
-    //\r
-    break;\r
+    case FRONT_PAGE_KEY_DEVICE_MANAGER:\r
+      //\r
+      // Device Manager\r
+      //\r
+      break;\r
 \r
-  default:\r
-    gCallbackKey = 0;\r
-    break;\r
-  }\r
+    case FRONT_PAGE_KEY_BOOT_MAINTAIN:\r
+      //\r
+      // Boot Maintenance Manager\r
+      //\r
+      break;\r
 \r
-  *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
+    default:\r
+      gCallbackKey = 0;\r
+      break;\r
+    }\r
+  }\r
 \r
-  return EFI_SUCCESS;\r
+  return EFI_SUCCESS;  \r
 }\r
 \r
 /**\r
@@ -356,7 +370,7 @@ InitializeFrontPage (
     // Publish our HII data\r
     //\r
     gFrontPagePrivate.HiiHandle = HiiAddPackages (\r
-                                    &mFrontPageGuid,\r
+                                    &gFrontPageFormSetGuid,\r
                                     gFrontPagePrivate.DriverHandle,\r
                                     FrontPageVfrBin,\r
                                     BdsDxeStrings,\r
@@ -443,7 +457,7 @@ InitializeFrontPage (
 \r
     if (FirstFlag) {\r
       StringBuffer = HiiGetString (HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, Lang);\r
-      ASSERT_EFI_ERROR (StringBuffer != NULL);\r
+      ASSERT (StringBuffer != NULL);\r
 \r
       //\r
       // Save the string Id for each language\r
@@ -495,7 +509,7 @@ InitializeFrontPage (
 \r
   Status = HiiUpdateForm (\r
              HiiHandle,\r
-             &mFrontPageGuid,\r
+             &gFrontPageFormSetGuid,\r
              FRONT_PAGE_FORM_ID,\r
              StartOpCodeHandle, // LABEL_SELECT_LANGUAGE\r
              EndOpCodeHandle    // LABEL_END\r
@@ -535,7 +549,7 @@ CallFrontPage (
                             gFormBrowser2,\r
                             &gFrontPagePrivate.HiiHandle,\r
                             1,\r
-                            &mFrontPageGuid,\r
+                            &gFrontPageFormSetGuid,\r
                             0,\r
                             NULL,\r
                             &ActionRequest\r
@@ -663,51 +677,31 @@ GetOptionalStringByIndex (
   OUT     CHAR16                  **String\r
   )\r
 {\r
-  UINT8          StrNum;\r
-  UINTN          CurrentStrLen;\r
-  CHAR8*         CharInStr;\r
-  EFI_STATUS     Status;\r
+  UINTN          StrSize;\r
+\r
+  if (Index == 0) {\r
+    *String = AllocateZeroPool (sizeof (CHAR16));\r
+    return EFI_SUCCESS;\r
+  }\r
 \r
-  StrNum        = 0;\r
-  Status        = EFI_NOT_FOUND;\r
-  CharInStr     = OptionalStrStart;\r
+  StrSize = 0;\r
+  do {\r
+    Index--;\r
+    OptionalStrStart += StrSize;\r
+    StrSize           = AsciiStrSize (OptionalStrStart);\r
+  } while (OptionalStrStart[StrSize] != 0 && Index != 0);\r
 \r
-  if (Index != 1) {\r
-    CurrentStrLen = 0;\r
+  if ((Index != 0) || (StrSize == 1)) {\r
     //\r
-    // look for the two consecutive zeros, check the string limit by the way.\r
+    // Meet the end of strings set but Index is non-zero, or\r
+    // Find an empty string\r
     //\r
-    while (*CharInStr != 0 || *(CharInStr+1) != 0) { \r
-      if (*CharInStr == 0) {\r
-        StrNum += 1;\r
-        CharInStr++;\r
-      }\r
-  \r
-      if (StrNum == Index) {\r
-        Status = EFI_SUCCESS;\r
-        break;\r
-      }\r
-  \r
-      CurrentStrLen = AsciiStrLen(CharInStr);\r
-  \r
-      //\r
-      // forward the pointer\r
-      //\r
-      OptionalStrStart = CharInStr;\r
-      CharInStr += CurrentStrLen;\r
-    }\r
-  \r
-    if (EFI_ERROR (Status)) {\r
-      *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
-      return Status;\r
-    }\r
+    *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
   } else {\r
-    CurrentStrLen = AsciiStrLen(CharInStr);\r
+    *String = AllocatePool (StrSize * sizeof (CHAR16));\r
+    AsciiStrToUnicodeStr (OptionalStrStart, *String);\r
   }\r
 \r
-  *String = AllocatePool((CurrentStrLen + 1)*sizeof(CHAR16));\r
-  AsciiStrToUnicodeStr(OptionalStrStart, *String);\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -746,7 +740,7 @@ UpdateFrontPageStrings (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  SmbiosHandle = 0;\r
+  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
   do {\r
     Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);\r
     if (EFI_ERROR(Status)) {\r
@@ -963,6 +957,186 @@ 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
@@ -982,6 +1156,7 @@ PlatformBdsEnterFrontPage (
   )\r
 {\r
   EFI_STATUS                    Status;\r
+  EFI_BOOT_LOGO_PROTOCOL        *BootLogo;\r
 \r
   PERF_START (NULL, "BdsTimeOut", "BDS", 0);\r
   //\r
@@ -991,8 +1166,10 @@ PlatformBdsEnterFrontPage (
     gConnectAllHappened = TRUE;\r
   }\r
 \r
+  HotkeyBoot ();\r
   if (TimeoutDefault != 0xffff) {\r
     Status = ShowProgress (TimeoutDefault);\r
+    HotkeyBoot ();\r
 \r
     //\r
     // Ensure screen is clear when switch Console from Graphics mode to Text mode\r
@@ -1008,8 +1185,21 @@ PlatformBdsEnterFrontPage (
     }\r
   }\r
 \r
-  do {\r
+  //\r
+  // Boot Logo is corrupted, report it using Boot Logo protocol.\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);\r
+  if (!EFI_ERROR (Status) && (BootLogo != NULL)) {\r
+    BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);\r
+  }\r
 \r
+  Status = EFI_SUCCESS;\r
+  do {\r
+    //\r
+    // Set proper video resolution and text mode for setup\r
+    //\r
+    ChangeModeForSetup ();\r
+    \r
     InitializeFrontPage (FALSE);\r
 \r
     //\r
@@ -1018,7 +1208,7 @@ PlatformBdsEnterFrontPage (
     UpdateFrontPageStrings ();\r
 \r
     gCallbackKey = 0;\r
-    Status = CallFrontPage ();\r
+    CallFrontPage ();\r
 \r
     //\r
     // If gCallbackKey is greater than 1 and less or equal to 5,\r