## 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
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
}\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