]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Introduce video resolution and text mode PCDs for BIOS setup in BDS module. User...
authorli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 8 Nov 2011 07:34:56 +0000 (07:34 +0000)
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 8 Nov 2011 07:34:56 +0000 (07:34 +0000)
Signed-off-by: li-elvin
Reviewed-by: niruiyu
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12671 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/FileExplorer.c
IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.h

index 709b2bd33b69db0624ff4d4a37ff1b81bd9c4230..c5b2da847c9c66a3729076f82ae112e098e4268e 100644 (file)
   ## The PCD is used to specify the high PMM (Post Memory Manager) size with bytes above 1MB.\r
   #  The value should be a multiple of 4KB.\r
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdHighPmmMemorySize|0x400000|UINT32|0x3000000a\r
+\r
+  ## The 4 PCDs below are used to specify the video resolution and text mode of text setup.\r
+  #  To make text setup work in this resolution, PcdVideoHorizontalResolution, PcdVideoVerticalResolution,\r
+  #  PcdConOutColumn and PcdConOutRow in MdeModulePkg.dec should be created as PcdsDynamic or PcdsDynamicEx\r
+  #  in platform DSC file. Then BDS setup will update these PCDs defined in MdeModulePkg.dec and reconnect\r
+  #  console drivers (GraphicsConsole, Terminal, Consplitter) to make the video resolution and text mode work\r
+  #  for text setup.\r
+\r
+  ## The PCD is used to specify the video horizontal resolution of text setup.   \r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|800|UINT32|0x3000000b\r
+  \r
+  ## The PCD is used to specify the video vertical resolution of text setup.\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|600|UINT32|0x3000000c\r
+\r
+  ## The PCD is used to specify the console output column of text setup.\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupConOutColumn|80|UINT32|0x3000000d\r
+  \r
+  ## The PCD is used to specify the console output column of text setup.\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupConOutRow|25|UINT32|0x3000000e
\ No newline at end of file
index 30c48f48eeae3b9d5fa7674e6009d49003eac1ce..efe881bf2f2e7066b62e03556ff1ee2071801d49 100644 (file)
@@ -654,24 +654,6 @@ BdsLibBootViaBootOption (
     }\r
   }\r
 \r
-  //\r
-  // Signal the EVT_SIGNAL_READY_TO_BOOT event\r
-  //\r
-  EfiSignalEventReadyToBoot();\r
-\r
-  //\r
-  // Expand USB Class or USB WWID device path node to be full device path of a USB\r
-  // device in platform then load the boot file on this full device path and get the\r
-  // image handle.\r
-  //\r
-  ImageHandle = BdsExpandUsbShortFormDevicePath (DevicePath);\r
-\r
-  //\r
-  // Adjust the different type memory page number just before booting\r
-  // and save the updated info into the variable for next boot to use\r
-  //\r
-  BdsSetMemoryTypeInformationVariable ();\r
-\r
   //\r
   // Set Boot Current\r
   //\r
@@ -690,6 +672,24 @@ BdsLibBootViaBootOption (
           );\r
   }\r
 \r
+  //\r
+  // Signal the EVT_SIGNAL_READY_TO_BOOT event\r
+  //\r
+  EfiSignalEventReadyToBoot();\r
+\r
+  //\r
+  // Expand USB Class or USB WWID device path node to be full device path of a USB\r
+  // device in platform then load the boot file on this full device path and get the\r
+  // image handle.\r
+  //\r
+  ImageHandle = BdsExpandUsbShortFormDevicePath (DevicePath);\r
+\r
+  //\r
+  // Adjust the different type memory page number just before booting\r
+  // and save the updated info into the variable for next boot to use\r
+  //\r
+  BdsSetMemoryTypeInformationVariable ();\r
+\r
   //\r
   // By expanding the USB Class or WWID device path, the ImageHandle has returnned.\r
   // Here get the ImageHandle for the non USB class or WWID device path.\r
index bb9775343ffa381e6bd8e906ff339f14df57ba1c..ed5a240d6af5adbb012bb9b817fcbcf789eefb18 100644 (file)
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBootState\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupConOutColumn\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupConOutRow\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile\r
 \r
 [Depex]\r
   TRUE\r
index 8ff5fa0a16f9ea9e53d05b89465cb1806021d00d..b77e909ad538d7a4d92356ef5ee3d419d84fce82 100644 (file)
@@ -161,6 +161,10 @@ UpdateFileExplorer (
         // Here boot from file\r
         //\r
         BootThisFile (NewFileContext);\r
+        //\r
+        // Set proper video resolution and text mode for setup.\r
+        //\r
+        ChangeModeForSetup ();\r
         ExitFileExplorer = TRUE;\r
         break;\r
 \r
index 4cd0691b91e33c7aaa077ea40b8f61f455d2e605..125ba63ea08311464a6df18a3c2a8a1cf1b645fe 100644 (file)
@@ -939,6 +939,187 @@ 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
+  UINT32                                SetupTextModeColumn;\r
+  UINT32                                SetupTextModeRow;\r
+  UINT32                                SetupHorizontalResolution;\r
+  UINT32                                SetupVerticalResolution;\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.\r
+  //  \r
+  SetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
+  SetupVerticalResolution   = PcdGet32 (PcdSetupVideoVerticalResolution);      \r
+  SetupTextModeColumn       = PcdGet32 (PcdSetupConOutColumn);\r
+  SetupTextModeRow          = PcdGet32 (PcdSetupConOutRow);\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 == SetupHorizontalResolution) &&\r
+          (Info->VerticalResolution == SetupVerticalResolution)) {\r
+        if ((GraphicsOutput->Mode->Info->HorizontalResolution == SetupHorizontalResolution) &&\r
+            (GraphicsOutput->Mode->Info->VerticalResolution == SetupVerticalResolution)) {\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 == SetupTextModeColumn && CurrentRow == SetupTextModeRow) {\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 == SetupTextModeColumn) && (CurrentRow == SetupTextModeRow)) {\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, SetupTextModeColumn);\r
+                  PcdSet32 (PcdConOutRow, SetupTextModeRow);\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, SetupHorizontalResolution);\r
+            PcdSet32 (PcdVideoVerticalResolution, SetupVerticalResolution);\r
+            PcdSet32 (PcdConOutColumn, SetupTextModeColumn);\r
+            PcdSet32 (PcdConOutRow, SetupTextModeRow);\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
@@ -996,7 +1177,11 @@ PlatformBdsEnterFrontPage (
   }\r
 \r
   do {\r
-\r
+    //\r
+    // Set proper video resolution and text mode for setup\r
+    //\r
+    ChangeModeForSetup ();\r
+    \r
     InitializeFrontPage (FALSE);\r
 \r
     //\r
index a68eed9dbff33c32b4957ae36d11246b090e1950..a118f91269728de9623828662cd5dedbe006ee57 100644 (file)
@@ -236,5 +236,20 @@ PlatformBdsEnterFrontPage (
   IN BOOLEAN                ConnectAllHappened\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
 #endif // _FRONT_PAGE_H_\r
 \r