X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FBdsDxe%2FFrontPage.c;h=efecf7bec6018828e765cccb55f49fa0a7152806;hp=9443a65bcdfe9404bcebde3eb42b432e26e9c949;hb=847240774030f9da79140a9d515a64ec817eb6eb;hpb=cdcc36ae921c4c1e157907ec44bb98a67d3be96f diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c index 9443a65bcd..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,16 +15,18 @@ 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; -EFI_HII_DATABASE_PROTOCOL *gHiiDatabase; -EFI_HII_STRING_PROTOCOL *gHiiString; EFI_FORM_BROWSER2_PROTOCOL *gFormBrowser2; -EFI_HII_CONFIG_ROUTING_PROTOCOL *gHiiConfigRouting; FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate = { FRONT_PAGE_CALLBACK_DATA_SIGNATURE, @@ -48,15 +50,12 @@ 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, END_ENTIRE_DEVICE_PATH_SUBTYPE, - { + { (UINT8) (END_DEVICE_PATH_LENGTH), (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) } @@ -81,7 +80,7 @@ HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = { @retval EFI_SUCCESS The Results is filled with the requested values. @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results. - @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name. + @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name. @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver. **/ @@ -94,6 +93,9 @@ FakeExtractConfig ( OUT EFI_STRING *Results ) { + if (Progress == NULL || Results == NULL) { + return EFI_INVALID_PARAMETER; + } *Progress = Request; return EFI_NOT_FOUND; } @@ -122,15 +124,18 @@ FakeRouteConfig ( OUT EFI_STRING *Progress ) { - if (Configuration == NULL) { + if (Configuration == NULL || Progress == NULL) { return EFI_INVALID_PARAMETER; } - if (Progress == NULL) { - return EFI_INVALID_PARAMETER; + *Progress = Configuration; + if (!HiiIsConfigHdrMatch (Configuration, &gBootMaintFormSetGuid, mBootMaintStorageName) + && !HiiIsConfigHdrMatch (Configuration, &gFileExploreFormSetGuid, mFileExplorerStorageName)) { + return EFI_NOT_FOUND; } - return EFI_NOT_FOUND; + *Progress = Configuration + StrLen (Configuration); + return EFI_SUCCESS; } /** @@ -170,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); - - Index = 0; - LangCode = LanguageString; - while (*LangCode != 0) { - GetNextLanguage (&LangCode, Lang); + 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; - if (Index == Value->u8) { - break; + 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; + } + + Index++; } - Index++; - } + 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); + } + + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; - PlatformSupportedLanguages = GetEfiGlobalVariable (L"PlatformLangCodes"); - if (PlatformSupportedLanguages == NULL) { - PlatformSupportedLanguages = AllocateCopyPool ( - AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)), - (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes) - ); - ASSERT (PlatformSupportedLanguages != NULL); + FreePool (PlatformSupportedLanguages); + FreePool (Lang); + FreePool (LanguageString); + break; + + default: + break; } - - // - // 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); + } else if (Action == EFI_BROWSER_ACTION_CHANGING) { + if (Value == NULL) { + return EFI_INVALID_PARAMETER; } - FreePool (PlatformSupportedLanguages); - FreePool (Lang); - FreePool (LanguageString); - break; - - case FRONT_PAGE_KEY_BOOT_MANAGER: // - // Boot 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_DEVICE_MANAGER: - // - // Device Manager - // - break; + case FRONT_PAGE_KEY_DEVICE_MANAGER: + // + // Device Manager + // + break; - case FRONT_PAGE_KEY_BOOT_MAINTAIN: - // - // Boot Maintenance Manager - // - break; + case FRONT_PAGE_KEY_BOOT_MAINTAIN: + // + // Boot Maintenance Manager + // + break; - default: - gCallbackKey = 0; - break; + default: + gCallbackKey = 0; + break; + } } - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; - - return EFI_SUCCESS; + return EFI_SUCCESS; } /** @@ -300,7 +324,6 @@ InitializeFrontPage ( CHAR8 *BestLanguage; UINTN OptionCount; CHAR16 *StringBuffer; - UINTN BufferSize; EFI_HII_HANDLE HiiHandle; VOID *OptionsOpCodeHandle; VOID *StartOpCodeHandle; @@ -325,26 +348,11 @@ InitializeFrontPage ( // // Locate Hii relative protocols // - Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &gHiiDatabase); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gHiiString); - if (EFI_ERROR (Status)) { - return Status; - } - Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &gFormBrowser2); if (EFI_ERROR (Status)) { return Status; } - Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &gHiiConfigRouting); - if (EFI_ERROR (Status)) { - return Status; - } - // // Install Device Path Protocol and Config Access protocol to driver handle // @@ -362,7 +370,7 @@ InitializeFrontPage ( // Publish our HII data // gFrontPagePrivate.HiiHandle = HiiAddPackages ( - &mFrontPageGuid, + &gFrontPageFormSetGuid, gFrontPagePrivate.DriverHandle, FrontPageVfrBin, BdsDxeStrings, @@ -431,7 +439,7 @@ InitializeFrontPage ( OptionCount = 0; LangCode = LanguageString; FirstFlag = FALSE; - + if (gFrontPagePrivate.LanguageToken == NULL) { while (*LangCode != 0) { GetNextLanguage (&LangCode, Lang); @@ -448,35 +456,8 @@ InitializeFrontPage ( GetNextLanguage (&LangCode, Lang); if (FirstFlag) { - // - // Get Language Name from String Package. The StringId of Printable Language - // Name is always 1 which is generated by StringGather Tool. - // - BufferSize = 0x100; - StringBuffer = AllocatePool (BufferSize); - Status = gHiiString->GetString ( - gHiiString, - Lang, - HiiHandle, - PRINTABLE_LANGUAGE_NAME_STRING_ID, - StringBuffer, - &BufferSize, - NULL - ); - if (Status == EFI_BUFFER_TOO_SMALL) { - FreePool (StringBuffer); - StringBuffer = AllocatePool (BufferSize); - Status = gHiiString->GetString ( - gHiiString, - Lang, - HiiHandle, - PRINTABLE_LANGUAGE_NAME_STRING_ID, - StringBuffer, - &BufferSize, - NULL - ); - } - ASSERT_EFI_ERROR (Status); + StringBuffer = HiiGetString (HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, Lang); + ASSERT (StringBuffer != NULL); // // Save the string Id for each language @@ -528,7 +509,7 @@ InitializeFrontPage ( Status = HiiUpdateForm ( HiiHandle, - &mFrontPageGuid, + &gFrontPageFormSetGuid, FRONT_PAGE_FORM_ID, StartOpCodeHandle, // LABEL_SELECT_LANGUAGE EndOpCodeHandle // LABEL_END @@ -568,13 +549,13 @@ CallFrontPage ( gFormBrowser2, &gFrontPagePrivate.HiiHandle, 1, - &mFrontPageGuid, + &gFrontPageFormSetGuid, 0, NULL, &ActionRequest ); // - // Check whether user change any option setting which needs a reset to be effective + // Check whether user change any option setting which needs a reset to be effective // if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) { EnableResetRequired (); @@ -614,25 +595,27 @@ GetProducerString ( } /** - Convert Processor Frequency Data to a string + Convert Processor Frequency Data to a string. @param ProcessorFrequency The frequency data to process + @param Base10Exponent The exponent based on 10 @param String The string that is created **/ VOID ConvertProcessorToString ( - IN EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency, - OUT CHAR16 **String + IN UINT16 ProcessorFrequency, + IN UINT16 Base10Exponent, + OUT CHAR16 **String ) { CHAR16 *StringBuffer; UINTN Index; UINT32 FreqMhz; - if (ProcessorFrequency->Exponent >= 6) { - FreqMhz = ProcessorFrequency->Value; - for (Index = 0; Index < (UINTN) (ProcessorFrequency->Exponent - 6); Index++) { + if (Base10Exponent >= 6) { + FreqMhz = ProcessorFrequency; + for (Index = 0; Index < (UINTN) (Base10Exponent - 6); Index++) { FreqMhz *= 10; } } else { @@ -645,12 +628,11 @@ ConvertProcessorToString ( StrCat (StringBuffer, L"."); UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2); StrCat (StringBuffer, L" GHz"); - *String = (CHAR16 *) StringBuffer; - return ; } + /** Convert Memory Size to a string. @@ -676,6 +658,54 @@ ConvertMemorySizeToString ( return ; } +/** + + Acquire the string associated with the Index from smbios structure and return it. + The caller is responsible for free the string buffer. + + @param OptionalStrStart The start position to search the string + @param Index The index of the string to extract + @param String The string that is extracted + + @retval EFI_SUCCESS The function returns EFI_SUCCESS always. + +**/ +EFI_STATUS +GetOptionalStringByIndex ( + IN CHAR8 *OptionalStrStart, + IN UINT8 Index, + OUT CHAR16 **String + ) +{ + UINTN StrSize; + + if (Index == 0) { + *String = AllocateZeroPool (sizeof (CHAR16)); + return EFI_SUCCESS; + } + + StrSize = 0; + do { + Index--; + OptionalStrStart += StrSize; + StrSize = AsciiStrSize (OptionalStrStart); + } while (OptionalStrStart[StrSize] != 0 && Index != 0); + + if ((Index != 0) || (StrSize == 1)) { + // + // Meet the end of strings set but Index is non-zero, or + // Find an empty string + // + *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING)); + } else { + *String = AllocatePool (StrSize * sizeof (CHAR16)); + AsciiStrToUnicodeStr (OptionalStrStart, *String); + } + + return EFI_SUCCESS; +} + + /** Update the banner information for the Front Page based on DataHub information. @@ -685,19 +715,18 @@ UpdateFrontPageStrings ( VOID ) { - EFI_STATUS Status; - EFI_STRING_ID TokenToUpdate; + UINT8 StrIndex; CHAR16 *NewString; - UINT64 MonotonicCount; - EFI_DATA_HUB_PROTOCOL *DataHub; - EFI_DATA_RECORD_HEADER *Record; - EFI_SUBCLASS_TYPE1_HEADER *DataHeader; - EFI_MISC_BIOS_VENDOR_DATA *BiosVendor; - EFI_MISC_SYSTEM_MANUFACTURER_DATA *SystemManufacturer; - EFI_PROCESSOR_VERSION_DATA *ProcessorVersion; - EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency; - EFI_MEMORY_ARRAY_START_ADDRESS_DATA *MemoryArray; BOOLEAN Find[5]; + EFI_STATUS Status; + EFI_STRING_ID TokenToUpdate; + EFI_SMBIOS_HANDLE SmbiosHandle; + EFI_SMBIOS_PROTOCOL *Smbios; + SMBIOS_TABLE_TYPE0 *Type0Record; + SMBIOS_TABLE_TYPE1 *Type1Record; + SMBIOS_TABLE_TYPE4 *Type4Record; + SMBIOS_TABLE_TYPE19 *Type19Record; + EFI_SMBIOS_TABLE_HEADER *Record; ZeroMem (Find, sizeof (Find)); @@ -705,86 +734,79 @@ UpdateFrontPageStrings ( // Update Front Page strings // Status = gBS->LocateProtocol ( - &gEfiDataHubProtocolGuid, + &gEfiSmbiosProtocolGuid, NULL, - (VOID **) &DataHub + (VOID **) &Smbios ); ASSERT_EFI_ERROR (Status); - MonotonicCount = 0; - Record = NULL; + SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; do { - Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record); - if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) { - DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1); - if (CompareGuid (&Record->DataRecordGuid, &gEfiMiscSubClassGuid) && - (DataHeader->RecordType == EFI_MISC_BIOS_VENDOR_RECORD_NUMBER) - ) { - BiosVendor = (EFI_MISC_BIOS_VENDOR_DATA *) (DataHeader + 1); - GetProducerString (&Record->ProducerName, BiosVendor->BiosVersion, &NewString); - TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION); - HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); - FreePool (NewString); - Find[0] = TRUE; - } - - if (CompareGuid (&Record->DataRecordGuid, &gEfiMiscSubClassGuid) && - (DataHeader->RecordType == EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER) - ) { - SystemManufacturer = (EFI_MISC_SYSTEM_MANUFACTURER_DATA *) (DataHeader + 1); - GetProducerString (&Record->ProducerName, SystemManufacturer->SystemProductName, &NewString); - TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL); - HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); - FreePool (NewString); - Find[1] = TRUE; - } - - if (CompareGuid (&Record->DataRecordGuid, &gEfiProcessorSubClassGuid) && - (DataHeader->RecordType == ProcessorVersionRecordType) - ) { - ProcessorVersion = (EFI_PROCESSOR_VERSION_DATA *) (DataHeader + 1); - GetProducerString (&Record->ProducerName, *ProcessorVersion, &NewString); - TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL); - HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); - FreePool (NewString); - Find[2] = TRUE; - } - - if (CompareGuid (&Record->DataRecordGuid, &gEfiProcessorSubClassGuid) && - (DataHeader->RecordType == ProcessorCoreFrequencyRecordType) - ) { - ProcessorFrequency = (EFI_PROCESSOR_CORE_FREQUENCY_DATA *) (DataHeader + 1); - ConvertProcessorToString (ProcessorFrequency, &NewString); - TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED); - HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); - FreePool (NewString); - Find[3] = TRUE; - } - - if (CompareGuid (&Record->DataRecordGuid, &gEfiMemorySubClassGuid) && - (DataHeader->RecordType == EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER) - ) { - MemoryArray = (EFI_MEMORY_ARRAY_START_ADDRESS_DATA *) (DataHeader + 1); - ConvertMemorySizeToString ( - (UINT32)(RShiftU64((MemoryArray->MemoryArrayEndAddress - MemoryArray->MemoryArrayStartAddress + 1), 20)), - &NewString - ); - TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE); - HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); - FreePool (NewString); - Find[4] = TRUE; - } + Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL); + if (EFI_ERROR(Status)) { + break; } - } while (!EFI_ERROR (Status) && (MonotonicCount != 0) && !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4])); + if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) { + Type0Record = (SMBIOS_TABLE_TYPE0 *) Record; + StrIndex = Type0Record->BiosVersion; + GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString); + TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION); + HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); + FreePool (NewString); + Find[0] = TRUE; + } + + if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) { + Type1Record = (SMBIOS_TABLE_TYPE1 *) Record; + StrIndex = Type1Record->ProductName; + GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString); + TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL); + HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); + FreePool (NewString); + Find[1] = TRUE; + } + + if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) { + Type4Record = (SMBIOS_TABLE_TYPE4 *) Record; + StrIndex = Type4Record->ProcessorVersion; + GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString); + TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL); + HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); + FreePool (NewString); + Find[2] = TRUE; + } + + if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) { + Type4Record = (SMBIOS_TABLE_TYPE4 *) Record; + ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString); + TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED); + HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); + FreePool (NewString); + Find[3] = TRUE; + } + + if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) { + Type19Record = (SMBIOS_TABLE_TYPE19 *) Record; + ConvertMemorySizeToString ( + (UINT32)(RShiftU64((Type19Record->EndingAddress - Type19Record->StartingAddress + 1), 10)), + &NewString + ); + TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE); + HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); + FreePool (NewString); + Find[4] = TRUE; + } + } while ( !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4])); return ; } + /** Function waits for a given event to fire, or for an optional timeout to expire. - @param Event The event to wait for - @param Timeout An optional timeout value in 100 ns units. + @param Event The event to wait for + @param Timeout An optional timeout value in 100 ns units. @retval EFI_SUCCESS Event fired before Timeout expired. @retval EFI_TIME_OUT Timout expired before Event fired.. @@ -796,8 +818,8 @@ WaitForSingleEvent ( IN UINT64 Timeout OPTIONAL ) { - EFI_STATUS Status; UINTN Index; + EFI_STATUS Status; EFI_EVENT TimerEvent; EFI_EVENT WaitList[2]; @@ -811,10 +833,10 @@ WaitForSingleEvent ( // Set the timer event // gBS->SetTimer ( - TimerEvent, - TimerRelative, - Timeout - ); + TimerEvent, + TimerRelative, + Timeout + ); // // Wait for the original event or the timer @@ -847,10 +869,10 @@ WaitForSingleEvent ( Function show progress bar to wait for user input. - @param TimeoutDefault The fault time out value before the system continue to boot. + @param TimeoutDefault The fault time out value before the system continue to boot. @retval EFI_SUCCESS User pressed some key except "Enter" - @retval EFI_TIME_OUT Timout expired or user press "Enter" + @retval EFI_TIME_OUT Timeout expired or user press "Enter" **/ EFI_STATUS @@ -858,20 +880,20 @@ ShowProgress ( IN UINT16 TimeoutDefault ) { - EFI_STATUS Status; CHAR16 *TmpStr; + UINT16 TimeoutRemain; + EFI_STATUS Status; + EFI_INPUT_KEY Key; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color; - EFI_INPUT_KEY Key; - UINT16 TimeoutRemain; if (TimeoutDefault == 0) { return EFI_TIMEOUT; } DEBUG ((EFI_D_INFO, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n")); - + SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff); SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0); SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff); @@ -887,7 +909,7 @@ ShowProgress ( TimeoutRemain = TimeoutDefault; while (TimeoutRemain != 0) { DEBUG ((EFI_D_INFO, "Showing progress bar...Remaining %d second!\n", TimeoutRemain)); - + Status = WaitForSingleEvent (gST->ConIn->WaitForKey, ONE_SECOND); if (Status != EFI_TIMEOUT) { break; @@ -935,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, @@ -944,7 +1146,7 @@ ShowProgress ( @param TimeoutDefault The fault time out value before the system continue to boot. @param ConnectAllHappened The indicater to check if the connect all have - already happended. + already happened. **/ VOID @@ -954,8 +1156,9 @@ PlatformBdsEnterFrontPage ( ) { EFI_STATUS Status; + EFI_BOOT_LOGO_PROTOCOL *BootLogo; - PERF_START (0, "BdsTimeOut", "BDS", 0); + PERF_START (NULL, "BdsTimeOut", "BDS", 0); // // Indicate if we need connect all in the platform setup // @@ -963,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 @@ -980,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); // @@ -990,15 +1208,15 @@ PlatformBdsEnterFrontPage ( UpdateFrontPageStrings (); gCallbackKey = 0; - Status = CallFrontPage (); + CallFrontPage (); // // If gCallbackKey is greater than 1 and less or equal to 5, - // it will lauch configuration utilities. + // it will launch configuration utilities. // 2 = set language // 3 = boot manager // 4 = device manager - // 5 = boot maintainenance manager + // 5 = boot maintenance manager // if (gCallbackKey != 0) { REPORT_STATUS_CODE ( @@ -1041,7 +1259,7 @@ PlatformBdsEnterFrontPage ( // Display the Device Manager // do { - CallDeviceManager(); + CallDeviceManager (); } while (gCallbackKey == FRONT_PAGE_KEY_DEVICE_MANAGER); break; @@ -1066,5 +1284,5 @@ Exit: // Note: The following lines of code only execute when Auto boot // takes affect // - PERF_END (0, "BdsTimeOut", "BDS", 0); + PERF_END (NULL, "BdsTimeOut", "BDS", 0); }