X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FBdsDxe%2FFrontPage.c;h=62ba39484306455382592a3039213a8f2d3e6a2c;hb=f515069c194f418b74915be4a2e021c2b3ae2c46;hp=2098602b2f729750e84eb436c2b70ab39d054bb2;hpb=13078b3fadb4aaae2d6975ab96a7ad649017589f;p=mirror_edk2.git diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c index 2098602b2f..62ba394843 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 - 2010, 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 @@ -21,10 +21,7 @@ EFI_GUID mFrontPageGuid = FRONT_PAGE_FORMSET_GUID; 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, @@ -56,7 +53,7 @@ HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = { { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, - { + { (UINT8) (END_DEVICE_PATH_LENGTH), (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) } @@ -81,7 +78,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,7 +91,7 @@ FakeExtractConfig ( OUT EFI_STRING *Results ) { - if (Request == NULL || Progress == NULL || Results == NULL) { + if (Progress == NULL || Results == NULL) { return EFI_INVALID_PARAMETER; } *Progress = Request; @@ -176,6 +173,13 @@ FrontPageCallback ( CHAR8 *PlatformSupportedLanguages; CHAR8 *BestLanguage; + if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) { + // + // Do nothing for UEFI OPEN/CLOSE Action + // + return EFI_SUCCESS; + } + if ((Value == NULL) || (ActionRequest == NULL)) { return EFI_INVALID_PARAMETER; } @@ -205,7 +209,7 @@ FrontPageCallback ( // Lang = AllocatePool (AsciiStrSize (LanguageString)); ASSERT (Lang != NULL); - + Index = 0; LangCode = LanguageString; while (*LangCode != 0) { @@ -226,7 +230,7 @@ FrontPageCallback ( ); ASSERT (PlatformSupportedLanguages != NULL); } - + // // Select the best language in platform supported Language. // @@ -306,7 +310,6 @@ InitializeFrontPage ( CHAR8 *BestLanguage; UINTN OptionCount; CHAR16 *StringBuffer; - UINTN BufferSize; EFI_HII_HANDLE HiiHandle; VOID *OptionsOpCodeHandle; VOID *StartOpCodeHandle; @@ -331,26 +334,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 // @@ -437,7 +425,7 @@ InitializeFrontPage ( OptionCount = 0; LangCode = LanguageString; FirstFlag = FALSE; - + if (gFrontPagePrivate.LanguageToken == NULL) { while (*LangCode != 0) { GetNextLanguage (&LangCode, Lang); @@ -454,35 +442,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 @@ -580,7 +541,7 @@ CallFrontPage ( &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 (); @@ -623,22 +584,24 @@ GetProducerString ( 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 { @@ -651,12 +614,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. @@ -682,6 +644,50 @@ 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) { + *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. @@ -691,19 +697,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)); @@ -711,86 +716,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 = 0; 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.. @@ -802,8 +800,8 @@ WaitForSingleEvent ( IN UINT64 Timeout OPTIONAL ) { - EFI_STATUS Status; UINTN Index; + EFI_STATUS Status; EFI_EVENT TimerEvent; EFI_EVENT WaitList[2]; @@ -817,10 +815,10 @@ WaitForSingleEvent ( // Set the timer event // gBS->SetTimer ( - TimerEvent, - TimerRelative, - Timeout - ); + TimerEvent, + TimerRelative, + Timeout + ); // // Wait for the original event or the timer @@ -853,10 +851,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 @@ -864,20 +862,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); @@ -893,7 +891,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; @@ -950,7 +948,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 @@ -961,7 +959,7 @@ PlatformBdsEnterFrontPage ( { EFI_STATUS Status; - PERF_START (0, "BdsTimeOut", "BDS", 0); + PERF_START (NULL, "BdsTimeOut", "BDS", 0); // // Indicate if we need connect all in the platform setup // @@ -1000,11 +998,11 @@ PlatformBdsEnterFrontPage ( // // 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 ( @@ -1047,7 +1045,7 @@ PlatformBdsEnterFrontPage ( // Display the Device Manager // do { - CallDeviceManager(); + CallDeviceManager (); } while (gCallbackKey == FRONT_PAGE_KEY_DEVICE_MANAGER); break; @@ -1072,5 +1070,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); }