X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FBdsDxe%2FFrontPage.c;h=efecf7bec6018828e765cccb55f49fa0a7152806;hp=48cd70f2f885259f97f76e4c0eaf04736dadfe23;hb=847240774030f9da79140a9d515a64ec817eb6eb;hpb=59aefb7e0dc811a3e66ae23c1730028365354361 diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c index 48cd70f2f8..efecf7bec6 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c @@ -1,8 +1,8 @@ /** @file FrontPage routines to handle the callbacks and browser calls -Copyright (c) 2004 - 2009, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -15,8 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Bds.h" #include "FrontPage.h" #include "Language.h" +#include "Hotkey.h" -EFI_GUID mFrontPageGuid = FRONT_PAGE_FORMSET_GUID; +BOOLEAN mSetupModeInitialized = FALSE; +UINT32 mSetupTextModeColumn; +UINT32 mSetupTextModeRow; +UINT32 mSetupHorizontalResolution; +UINT32 mSetupVerticalResolution; BOOLEAN gConnectAllHappened = FALSE; UINTN gCallbackKey; @@ -45,10 +50,7 @@ HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = { (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) } }, - // - // {8E6D99EE-7531-48f8-8745-7F6144468FF2} - // - { 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 } } + FRONT_PAGE_FORMSET_GUID }, { END_DEVICE_PATH_TYPE, @@ -127,8 +129,8 @@ FakeRouteConfig ( } *Progress = Configuration; - if (!HiiIsConfigHdrMatch (Configuration, &mBootMaintGuid, mBootMaintStorageName) - && !HiiIsConfigHdrMatch (Configuration, &mFileExplorerGuid, mFileExplorerStorageName)) { + if (!HiiIsConfigHdrMatch (Configuration, &gBootMaintFormSetGuid, mBootMaintStorageName) + && !HiiIsConfigHdrMatch (Configuration, &gFileExploreFormSetGuid, mFileExplorerStorageName)) { return EFI_NOT_FOUND; } @@ -173,111 +175,130 @@ FrontPageCallback ( CHAR8 *PlatformSupportedLanguages; CHAR8 *BestLanguage; - if ((Value == NULL) || (ActionRequest == NULL)) { - return EFI_INVALID_PARAMETER; + if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) { + // + // All other action return unsupported. + // + return EFI_UNSUPPORTED; } - + gCallbackKey = QuestionId; - // - // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can - // describe to their customers in documentation how to find their setup information (namely - // under the device manager and specific buckets) - // - switch (QuestionId) { - case FRONT_PAGE_KEY_CONTINUE: - // - // This is the continue - clear the screen and return an error to get out of FrontPage loop - // - break; + if (Action == EFI_BROWSER_ACTION_CHANGED) { + if ((Value == NULL) || (ActionRequest == NULL)) { + return EFI_INVALID_PARAMETER; + } - case FRONT_PAGE_KEY_LANGUAGE: - // - // Collect the languages from what our current Language support is based on our VFR - // - LanguageString = HiiGetSupportedLanguages (gFrontPagePrivate.HiiHandle); - ASSERT (LanguageString != NULL); - // - // Allocate working buffer for RFC 4646 language in supported LanguageString. - // - Lang = AllocatePool (AsciiStrSize (LanguageString)); - ASSERT (Lang != NULL); + switch (QuestionId) { + case FRONT_PAGE_KEY_CONTINUE: + // + // This is the continue - clear the screen and return an error to get out of FrontPage loop + // + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + break; - Index = 0; - LangCode = LanguageString; - while (*LangCode != 0) { - GetNextLanguage (&LangCode, Lang); + case FRONT_PAGE_KEY_LANGUAGE: + // + // Collect the languages from what our current Language support is based on our VFR + // + LanguageString = HiiGetSupportedLanguages (gFrontPagePrivate.HiiHandle); + ASSERT (LanguageString != NULL); + // + // Allocate working buffer for RFC 4646 language in supported LanguageString. + // + Lang = AllocatePool (AsciiStrSize (LanguageString)); + ASSERT (Lang != NULL); + + Index = 0; + LangCode = LanguageString; + while (*LangCode != 0) { + GetNextLanguage (&LangCode, Lang); + + if (Index == Value->u8) { + break; + } - if (Index == Value->u8) { - break; + Index++; } - Index++; - } + PlatformSupportedLanguages = GetEfiGlobalVariable (L"PlatformLangCodes"); + if (PlatformSupportedLanguages == NULL) { + PlatformSupportedLanguages = AllocateCopyPool ( + AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)), + (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes) + ); + ASSERT (PlatformSupportedLanguages != NULL); + } - PlatformSupportedLanguages = GetEfiGlobalVariable (L"PlatformLangCodes"); - if (PlatformSupportedLanguages == NULL) { - PlatformSupportedLanguages = AllocateCopyPool ( - AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)), - (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes) - ); - ASSERT (PlatformSupportedLanguages != NULL); - } + // + // Select the best language in platform supported Language. + // + BestLanguage = GetBestLanguage ( + PlatformSupportedLanguages, + FALSE, + Lang, + NULL + ); + if (BestLanguage != NULL) { + Status = gRT->SetVariable ( + L"PlatformLang", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + AsciiStrSize (BestLanguage), + Lang + ); + ASSERT_EFI_ERROR(Status); + FreePool (BestLanguage); + } else { + ASSERT (FALSE); + } - // - // Select the best language in platform supported Language. - // - BestLanguage = GetBestLanguage ( - PlatformSupportedLanguages, - FALSE, - Lang, - NULL - ); - if (BestLanguage != NULL) { - Status = gRT->SetVariable ( - L"PlatformLang", - &gEfiGlobalVariableGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - AsciiStrSize (BestLanguage), - Lang - ); - ASSERT_EFI_ERROR(Status); - FreePool (BestLanguage); - } else { - ASSERT (FALSE); - } + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; - FreePool (PlatformSupportedLanguages); - FreePool (Lang); - FreePool (LanguageString); - break; + FreePool (PlatformSupportedLanguages); + FreePool (Lang); + FreePool (LanguageString); + break; - case FRONT_PAGE_KEY_BOOT_MANAGER: - // - // Boot Manager - // - break; + default: + break; + } + } else if (Action == EFI_BROWSER_ACTION_CHANGING) { + if (Value == NULL) { + return EFI_INVALID_PARAMETER; + } - case FRONT_PAGE_KEY_DEVICE_MANAGER: // - // Device Manager + // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can + // describe to their customers in documentation how to find their setup information (namely + // under the device manager and specific buckets) // - break; + switch (QuestionId) { + case FRONT_PAGE_KEY_BOOT_MANAGER: + // + // Boot Manager + // + break; - case FRONT_PAGE_KEY_BOOT_MAINTAIN: - // - // Boot Maintenance Manager - // - break; + case FRONT_PAGE_KEY_DEVICE_MANAGER: + // + // Device Manager + // + break; - default: - gCallbackKey = 0; - break; - } + case FRONT_PAGE_KEY_BOOT_MAINTAIN: + // + // Boot Maintenance Manager + // + break; - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + default: + gCallbackKey = 0; + break; + } + } - return EFI_SUCCESS; + return EFI_SUCCESS; } /** @@ -310,7 +331,6 @@ InitializeFrontPage ( EFI_IFR_GUID_LABEL *StartLabel; EFI_IFR_GUID_LABEL *EndLabel; BOOLEAN FirstFlag; - EFI_STRING_ID Temp; if (InitializeHiiData) { // @@ -350,7 +370,7 @@ InitializeFrontPage ( // Publish our HII data // gFrontPagePrivate.HiiHandle = HiiAddPackages ( - &mFrontPageGuid, + &gFrontPageFormSetGuid, gFrontPagePrivate.DriverHandle, FrontPageVfrBin, BdsDxeStrings, @@ -425,13 +445,11 @@ InitializeFrontPage ( GetNextLanguage (&LangCode, Lang); OptionCount ++; } - gFrontPagePrivate.LanguageToken = AllocatePool ((OptionCount + 1) * sizeof (EFI_STRING_ID)); + gFrontPagePrivate.LanguageToken = AllocatePool (OptionCount * sizeof (EFI_STRING_ID)); ASSERT (gFrontPagePrivate.LanguageToken != NULL); FirstFlag = TRUE; } - Status = gHiiString->NewString (gHiiString, HiiHandle, &Temp, "de-DE", L"Dedede", L"TEST", NULL); - OptionCount = 0; LangCode = LanguageString; while (*LangCode != 0) { @@ -439,7 +457,7 @@ InitializeFrontPage ( if (FirstFlag) { StringBuffer = HiiGetString (HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, Lang); - ASSERT_EFI_ERROR (StringBuffer != NULL); + ASSERT (StringBuffer != NULL); // // Save the string Id for each language @@ -491,7 +509,7 @@ InitializeFrontPage ( Status = HiiUpdateForm ( HiiHandle, - &mFrontPageGuid, + &gFrontPageFormSetGuid, FRONT_PAGE_FORM_ID, StartOpCodeHandle, // LABEL_SELECT_LANGUAGE EndOpCodeHandle // LABEL_END @@ -531,7 +549,7 @@ CallFrontPage ( gFormBrowser2, &gFrontPagePrivate.HiiHandle, 1, - &mFrontPageGuid, + &gFrontPageFormSetGuid, 0, NULL, &ActionRequest @@ -659,51 +677,31 @@ GetOptionalStringByIndex ( OUT CHAR16 **String ) { - UINT8 StrNum; - UINTN CurrentStrLen; - CHAR8* CharInStr; - EFI_STATUS Status; + UINTN StrSize; - StrNum = 0; - Status = EFI_NOT_FOUND; - CharInStr = OptionalStrStart; + if (Index == 0) { + *String = AllocateZeroPool (sizeof (CHAR16)); + return EFI_SUCCESS; + } - if (Index != 1) { - CurrentStrLen = 0; + StrSize = 0; + do { + Index--; + OptionalStrStart += StrSize; + StrSize = AsciiStrSize (OptionalStrStart); + } while (OptionalStrStart[StrSize] != 0 && Index != 0); + + if ((Index != 0) || (StrSize == 1)) { // - // look for the two consecutive zeros, check the string limit by the way. + // Meet the end of strings set but Index is non-zero, or + // Find an empty string // - while (*CharInStr != 0 || *(CharInStr+1) != 0) { - if (*CharInStr == 0) { - StrNum += 1; - CharInStr++; - } - - if (StrNum == Index) { - Status = EFI_SUCCESS; - break; - } - - CurrentStrLen = AsciiStrLen(CharInStr); - - // - // forward the pointer - // - OptionalStrStart = CharInStr; - CharInStr += CurrentStrLen; - } - - if (EFI_ERROR (Status)) { - *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING)); - return Status; - } + *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING)); } else { - CurrentStrLen = AsciiStrLen(CharInStr); + *String = AllocatePool (StrSize * sizeof (CHAR16)); + AsciiStrToUnicodeStr (OptionalStrStart, *String); } - *String = AllocatePool((CurrentStrLen + 1)*sizeof(CHAR16)); - AsciiStrToUnicodeStr(OptionalStrStart, *String); - return EFI_SUCCESS; } @@ -742,7 +740,7 @@ UpdateFrontPageStrings ( ); ASSERT_EFI_ERROR (Status); - SmbiosHandle = 0; + SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; do { Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL); if (EFI_ERROR(Status)) { @@ -959,6 +957,186 @@ ShowProgress ( return EFI_SUCCESS; } +/** + This function will change video resolution and text mode for setup when setup is launched. + + @param None. + + @retval EFI_SUCCESS Mode is changed successfully. + @retval Others Mode failed to changed. + +**/ +EFI_STATUS +EFIAPI +ChangeModeForSetup ( + VOID + ) +{ + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut; + UINTN SizeOfInfo; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; + UINT32 MaxGopMode; + UINT32 MaxTextMode; + UINT32 ModeNumber; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + EFI_STATUS Status; + UINTN Index; + UINTN CurrentColumn; + UINTN CurrentRow; + + Status = gBS->HandleProtocol ( + gST->ConsoleOutHandle, + &gEfiGraphicsOutputProtocolGuid, + (VOID**)&GraphicsOutput + ); + if (EFI_ERROR (Status)) { + GraphicsOutput = NULL; + } + + Status = gBS->HandleProtocol ( + gST->ConsoleOutHandle, + &gEfiSimpleTextOutProtocolGuid, + (VOID**)&SimpleTextOut + ); + if (EFI_ERROR (Status)) { + SimpleTextOut = NULL; + } + + if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) { + return EFI_UNSUPPORTED; + } + + // + // Get user defined text mode for setup only once. + // + if (!mSetupModeInitialized) { + mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution); + mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution); + mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn); + mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow); + mSetupModeInitialized = TRUE; + } + + MaxGopMode = GraphicsOutput->Mode->MaxMode; + MaxTextMode = SimpleTextOut->Mode->MaxMode; + + // + // 1. If current video resolution is same with setup video resolution, + // video resolution need not be changed. + // 1.1. If current text mode is same with setup text mode, text mode need not be changed. + // 1.2. If current text mode is different with setup text mode, text mode need be changed to setup text mode. + // 2. If current video resolution is different with setup video resolution, we need restart whole console drivers. + // + for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) { + Status = GraphicsOutput->QueryMode ( + GraphicsOutput, + ModeNumber, + &SizeOfInfo, + &Info + ); + if (!EFI_ERROR (Status)) { + if ((Info->HorizontalResolution == mSetupHorizontalResolution) && + (Info->VerticalResolution == mSetupVerticalResolution)) { + if ((GraphicsOutput->Mode->Info->HorizontalResolution == mSetupHorizontalResolution) && + (GraphicsOutput->Mode->Info->VerticalResolution == mSetupVerticalResolution)) { + // + // If current video resolution is same with setup video resolution, + // then check if current text mode is same with setup text mode. + // + Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow); + ASSERT_EFI_ERROR (Status); + if (CurrentColumn == mSetupTextModeColumn && CurrentRow == mSetupTextModeRow) { + // + // Current text mode is same with setup text mode, text mode need not be change. + // + FreePool (Info); + return EFI_SUCCESS; + } else { + // + // Current text mode is different with setup text mode, text mode need be change to new text mode. + // + for (Index = 0; Index < MaxTextMode; Index++) { + Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow); + if (!EFI_ERROR(Status)) { + if ((CurrentColumn == mSetupTextModeColumn) && (CurrentRow == mSetupTextModeRow)) { + // + // setup text mode is supported, set it. + // + Status = SimpleTextOut->SetMode (SimpleTextOut, Index); + ASSERT_EFI_ERROR (Status); + // + // Update text mode PCD. + // + PcdSet32 (PcdConOutColumn, mSetupTextModeColumn); + PcdSet32 (PcdConOutRow, mSetupTextModeRow); + FreePool (Info); + return EFI_SUCCESS; + } + } + } + if (Index == MaxTextMode) { + // + // If setup text mode is not supported, return error. + // + FreePool (Info); + return EFI_UNSUPPORTED; + } + } + } else { + FreePool (Info); + // + // If current video resolution is not same with the setup video resolution, set new video resolution. + // In this case, the drivers which produce simple text out need be restarted. + // + Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber); + if (!EFI_ERROR (Status)) { + // + // Set PCD to restart GraphicsConsole and Consplitter to change video resolution + // and produce new text mode based on new resolution. + // + PcdSet32 (PcdVideoHorizontalResolution, mSetupHorizontalResolution); + PcdSet32 (PcdVideoVerticalResolution, mSetupVerticalResolution); + PcdSet32 (PcdConOutColumn, mSetupTextModeColumn); + PcdSet32 (PcdConOutRow, mSetupTextModeRow); + + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiSimpleTextOutProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer + ); + if (!EFI_ERROR (Status)) { + for (Index = 0; Index < HandleCount; Index++) { + gBS->DisconnectController (HandleBuffer[Index], NULL, NULL); + } + for (Index = 0; Index < HandleCount; Index++) { + gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE); + } + if (HandleBuffer != NULL) { + FreePool (HandleBuffer); + } + break; + } + } + } + } + FreePool (Info); + } + } + + if (ModeNumber == MaxGopMode) { + // + // If the new resolution is not supported, return error. + // + return EFI_UNSUPPORTED; + } + + return EFI_SUCCESS; +} + /** This function is the main entry of the platform setup entry. The function will present the main menu of the system setup, @@ -978,6 +1156,7 @@ PlatformBdsEnterFrontPage ( ) { EFI_STATUS Status; + EFI_BOOT_LOGO_PROTOCOL *BootLogo; PERF_START (NULL, "BdsTimeOut", "BDS", 0); // @@ -987,8 +1166,10 @@ PlatformBdsEnterFrontPage ( gConnectAllHappened = TRUE; } + HotkeyBoot (); if (TimeoutDefault != 0xffff) { Status = ShowProgress (TimeoutDefault); + HotkeyBoot (); // // Ensure screen is clear when switch Console from Graphics mode to Text mode @@ -1004,8 +1185,21 @@ PlatformBdsEnterFrontPage ( } } - do { + // + // Boot Logo is corrupted, report it using Boot Logo protocol. + // + Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo); + if (!EFI_ERROR (Status) && (BootLogo != NULL)) { + BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0); + } + Status = EFI_SUCCESS; + do { + // + // Set proper video resolution and text mode for setup + // + ChangeModeForSetup (); + InitializeFrontPage (FALSE); // @@ -1014,7 +1208,7 @@ PlatformBdsEnterFrontPage ( UpdateFrontPageStrings (); gCallbackKey = 0; - Status = CallFrontPage (); + CallFrontPage (); // // If gCallbackKey is greater than 1 and less or equal to 5,