diff --git a/MdeModulePkg/Application/UiApp/FrontPage.c b/MdeModulePkg/Application/UiApp/FrontPage.c index d6207b6fa3..8efe4d137b 100644 --- a/MdeModulePkg/Application/UiApp/FrontPage.c +++ b/MdeModulePkg/Application/UiApp/FrontPage.c @@ -13,8 +13,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "FrontPage.h" -#include "Language.h" -#define MAX_STRING_LEN 200 +#include "FrontPageCustomizedUi.h" + +#define MAX_STRING_LEN 200 EFI_GUID mFrontPageGuid = FRONT_PAGE_FORMSET_GUID; @@ -82,7 +83,7 @@ HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = { **/ VOID -UpdateFrontPageStrings ( +UpdateFrontPageBannerStrings ( VOID ); @@ -155,190 +156,6 @@ FakeRouteConfig ( return EFI_NOT_FOUND; } -/** - Create oneof options for language. - -**/ -VOID -InitializeLanguage ( - VOID - ) -{ - EFI_STATUS Status; - CHAR8 *LangCode; - CHAR8 *Lang; - CHAR8 *CurrentLang; - UINTN OptionCount; - CHAR16 *StringBuffer; - EFI_HII_HANDLE HiiHandle; - VOID *OptionsOpCodeHandle; - VOID *StartOpCodeHandle; - VOID *EndOpCodeHandle; - EFI_IFR_GUID_LABEL *StartLabel; - EFI_IFR_GUID_LABEL *EndLabel; - EFI_HII_STRING_PROTOCOL *HiiString; - UINTN StringSize; - - Lang = NULL; - StringBuffer = NULL; - - // - // Init OpCode Handle and Allocate space for creation of UpdateData Buffer - // - StartOpCodeHandle = HiiAllocateOpCodeHandle (); - ASSERT (StartOpCodeHandle != NULL); - - EndOpCodeHandle = HiiAllocateOpCodeHandle (); - ASSERT (EndOpCodeHandle != NULL); - - OptionsOpCodeHandle = HiiAllocateOpCodeHandle (); - ASSERT (OptionsOpCodeHandle != NULL); - // - // Create Hii Extend Label OpCode as the start opcode - // - StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); - StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; - StartLabel->Number = LABEL_SELECT_LANGUAGE; - - // - // Create Hii Extend Label OpCode as the end opcode - // - EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); - EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; - EndLabel->Number = LABEL_END; - // - // Collect the languages from what our current Language support is based on our VFR - // - HiiHandle = gFrontPagePrivate.HiiHandle; - - GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLang, NULL); - - if (mLanguageString == NULL) { - // - // Get Support language list from variable. - // - GetEfiGlobalVariable2 (L"PlatformLangCodes", (VOID**)&mLanguageString, NULL); - if (mLanguageString == NULL) { - mLanguageString = AllocateCopyPool ( - AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)), - (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes) - ); - ASSERT (mLanguageString != NULL); - } - } - - if (gFrontPagePrivate.LanguageToken == NULL) { - // - // Count the language list number. - // - LangCode = mLanguageString; - Lang = AllocatePool (AsciiStrSize (mLanguageString)); - ASSERT (Lang != NULL); - OptionCount = 0; - while (*LangCode != 0) { - GetNextLanguage (&LangCode, Lang); - OptionCount ++; - } - - // - // Allocate extra 1 as the end tag. - // - gFrontPagePrivate.LanguageToken = AllocateZeroPool ((OptionCount + 1) * sizeof (EFI_STRING_ID)); - ASSERT (gFrontPagePrivate.LanguageToken != NULL); - - Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString); - ASSERT_EFI_ERROR (Status); - - LangCode = mLanguageString; - OptionCount = 0; - while (*LangCode != 0) { - GetNextLanguage (&LangCode, Lang); - - StringSize = 0; - Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL); - if (Status == EFI_BUFFER_TOO_SMALL) { - StringBuffer = AllocateZeroPool (StringSize); - ASSERT (StringBuffer != NULL); - Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL); - ASSERT_EFI_ERROR (Status); - } - - if (EFI_ERROR (Status)) { - StringBuffer = AllocatePool (AsciiStrSize (Lang) * sizeof (CHAR16)); - ASSERT (StringBuffer != NULL); - AsciiStrToUnicodeStr (Lang, StringBuffer); - } - - ASSERT (StringBuffer != NULL); - gFrontPagePrivate.LanguageToken[OptionCount] = HiiSetString (HiiHandle, 0, StringBuffer, NULL); - FreePool (StringBuffer); - - OptionCount++; - } - } - - ASSERT (gFrontPagePrivate.LanguageToken != NULL); - LangCode = mLanguageString; - OptionCount = 0; - if (Lang == NULL) { - Lang = AllocatePool (AsciiStrSize (mLanguageString)); - ASSERT (Lang != NULL); - } - while (*LangCode != 0) { - GetNextLanguage (&LangCode, Lang); - - if (CurrentLang != NULL && AsciiStrCmp (Lang, CurrentLang) == 0) { - HiiCreateOneOfOptionOpCode ( - OptionsOpCodeHandle, - gFrontPagePrivate.LanguageToken[OptionCount], - EFI_IFR_OPTION_DEFAULT, - EFI_IFR_NUMERIC_SIZE_1, - (UINT8) OptionCount - ); - } else { - HiiCreateOneOfOptionOpCode ( - OptionsOpCodeHandle, - gFrontPagePrivate.LanguageToken[OptionCount], - 0, - EFI_IFR_NUMERIC_SIZE_1, - (UINT8) OptionCount - ); - } - - OptionCount++; - } - - if (CurrentLang != NULL) { - FreePool (CurrentLang); - } - FreePool (Lang); - - HiiCreateOneOfOpCode ( - StartOpCodeHandle, - FRONT_PAGE_KEY_LANGUAGE, - 0, - 0, - STRING_TOKEN (STR_LANGUAGE_SELECT), - STRING_TOKEN (STR_LANGUAGE_SELECT_HELP), - EFI_IFR_FLAG_CALLBACK, - EFI_IFR_NUMERIC_SIZE_1, - OptionsOpCodeHandle, - NULL - ); - - Status = HiiUpdateForm ( - HiiHandle, - &mFrontPageGuid, - FRONT_PAGE_FORM_ID, - StartOpCodeHandle, // LABEL_SELECT_LANGUAGE - EndOpCodeHandle // LABEL_END - ); - - HiiFreeOpCodeHandle (StartOpCodeHandle); - HiiFreeOpCodeHandle (EndOpCodeHandle); - HiiFreeOpCodeHandle (OptionsOpCodeHandle); -} - /** This function processes the results of changes in configuration. @@ -368,82 +185,12 @@ FrontPageCallback ( OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest ) { - CHAR8 *LangCode; - CHAR8 *Lang; - UINTN Index; - EFI_STATUS Status; - - if (Action != EFI_BROWSER_ACTION_CHANGED) { - // - // Do nothing for other UEFI Action. Only do call back when data is changed. - // - return EFI_UNSUPPORTED; - } - - if (Action == EFI_BROWSER_ACTION_CHANGED) { - if ((Value == NULL) || (ActionRequest == NULL)) { - return EFI_INVALID_PARAMETER; - } - - 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; - - case FRONT_PAGE_KEY_LANGUAGE: - // - // Allocate working buffer for RFC 4646 language in supported LanguageString. - // - Lang = AllocatePool (AsciiStrSize (mLanguageString)); - ASSERT (Lang != NULL); - - Index = 0; - LangCode = mLanguageString; - while (*LangCode != 0) { - GetNextLanguage (&LangCode, Lang); - - if (Index == Value->u8) { - break; - } - - Index++; - } - - if (Index == Value->u8) { - Status = gRT->SetVariable ( - L"PlatformLang", - &gEfiGlobalVariableGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - AsciiStrSize (Lang), - Lang - ); - if (EFI_ERROR (Status)) { - FreePool (Lang); - return EFI_DEVICE_ERROR; - } - } else { - ASSERT (FALSE); - } - FreePool (Lang); - // - //Current language of platform is changed,recreate oneof options for language. - // - InitializeLanguage(); - break; - - default: - break; - } - } - - return EFI_SUCCESS; + return UiFrontPageCallbackHandler (gFrontPagePrivate.HiiHandle, Action, QuestionId, Type, Value, ActionRequest); } /** -Update front page form base on the ClassGuid in the formset in other modules. + + Update the menus in the front page. **/ VOID @@ -451,32 +198,10 @@ UpdateFrontPageForm ( VOID ) { - EFI_STATUS Status; - EFI_HII_HANDLE HiiHandle; VOID *StartOpCodeHandle; VOID *EndOpCodeHandle; - EFI_IFR_GUID_LABEL *StartLabel; - EFI_IFR_GUID_LABEL *EndLabel; - UINTN Index; - EFI_STRING String; - EFI_STRING_ID Token; - EFI_STRING_ID TokenHelp; - EFI_HII_HANDLE *HiiHandles; - EFI_GUID FormSetGuid; - CHAR16 *DevicePathStr; - EFI_STRING_ID DevicePathId; - EFI_IFR_FORM_SET *Buffer; - UINTN BufferSize; - UINT8 ClassGuidNum; - EFI_GUID *ClassGuid; - UINTN TempSize; - UINT8 *Ptr; - - TempSize =0; - BufferSize = 0; - Buffer = NULL; - - HiiHandle = gFrontPagePrivate.HiiHandle; + EFI_IFR_GUID_LABEL *StartGuidLabel; + EFI_IFR_GUID_LABEL *EndGuidLabel; // // Allocate space for creation of UpdateData Buffer @@ -489,99 +214,26 @@ UpdateFrontPageForm ( // // Create Hii Extend Label OpCode as the start opcode // - StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); - StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; - StartLabel->Number = LABEL_PLATFORM_INFORMATION; + StartGuidLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + StartGuidLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; + StartGuidLabel->Number = LABEL_FRANTPAGE_INFORMATION; // // Create Hii Extend Label OpCode as the end opcode // - EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); - EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; - EndLabel->Number = LABEL_END; + EndGuidLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + EndGuidLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; + EndGuidLabel->Number = LABEL_END; // - // Get all the Hii handles + //Updata Front Page form // - HiiHandles = HiiGetHiiHandles (NULL); - ASSERT (HiiHandles != NULL); - // - // Search for formset of each class type - // - for (Index = 0; HiiHandles[Index] != NULL; Index++) { - Status = HiiGetFormSetFromHiiHandle(HiiHandles[Index], &Buffer,&BufferSize); - if (EFI_ERROR (Status)) { - continue; - } - - Ptr = (UINT8 *)Buffer; - while(TempSize < BufferSize) { - TempSize += ((EFI_IFR_OP_HEADER *) Ptr)->Length; - - if (((EFI_IFR_OP_HEADER *) Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)){ - Ptr += ((EFI_IFR_OP_HEADER *) Ptr)->Length; - continue; - } - - // - // Find Class Guid - // - ClassGuidNum = (UINT8) (((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3); - ClassGuid = (EFI_GUID *) (VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET)); - while (ClassGuidNum-- > 0) { - if (CompareGuid (&gEfiIfrFrontPageGuid, ClassGuid) == 0){ - ClassGuid ++; - continue; - } - - String = HiiGetString (HiiHandles[Index], ((EFI_IFR_FORM_SET *)Ptr)->FormSetTitle, NULL); - if (String == NULL) { - String = HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL); - ASSERT (String != NULL); - } - Token = HiiSetString (HiiHandle, 0, String, NULL); - FreePool (String); - - String = HiiGetString (HiiHandles[Index], ((EFI_IFR_FORM_SET *)Ptr)->Help, NULL); - - if (String == NULL) { - String = HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL); - ASSERT (String != NULL); - } - TokenHelp = HiiSetString (HiiHandle, 0, String, NULL); - FreePool (String); - - FormSetGuid = ((EFI_IFR_FORM_SET *)Ptr)->Guid; - - DevicePathStr = ExtractDevicePathFromHiiHandle(HiiHandles[Index]); - DevicePathId = 0; - if (DevicePathStr != NULL){ - DevicePathId = HiiSetString (HiiHandle, 0, DevicePathStr, NULL); - FreePool (DevicePathStr); - } - HiiCreateGotoExOpCode ( - StartOpCodeHandle, - 0, - Token, - TokenHelp, - 0, - (EFI_QUESTION_ID) (Index + FRONT_PAGE_KEY_OFFSET), - 0, - &FormSetGuid, - DevicePathId - ); - break; - } - Ptr += ((EFI_IFR_OP_HEADER *) Ptr)->Length; - } - - FreePool(Buffer); - Buffer = NULL; - TempSize = 0; - BufferSize = 0; - } + UiCustomizeFrontPage ( + gFrontPagePrivate.HiiHandle, + StartOpCodeHandle + ); HiiUpdateForm ( - HiiHandle, + gFrontPagePrivate.HiiHandle, &mFrontPageGuid, FRONT_PAGE_FORM_ID, StartOpCodeHandle, @@ -590,7 +242,6 @@ UpdateFrontPageForm ( HiiFreeOpCodeHandle (StartOpCodeHandle); HiiFreeOpCodeHandle (EndOpCodeHandle); - FreePool (HiiHandles); } /** @@ -642,17 +293,12 @@ InitializeFrontPage ( ASSERT (gFrontPagePrivate.HiiHandle != NULL); // - //Updata Front Page strings + //Updata Front Page banner strings // - UpdateFrontPageStrings (); + UpdateFrontPageBannerStrings (); // - // Initialize laguage options - // - InitializeLanguage (); - - // - //Updata Front Page form + // Update front page menus. // UpdateFrontPageForm(); @@ -846,10 +492,12 @@ GetOptionalStringByIndex ( /** + Update the banner information for the Front Page based on Smbios information. + **/ VOID -UpdateFrontPageStrings ( +UpdateFrontPageBannerStrings ( VOID ) { @@ -857,7 +505,6 @@ UpdateFrontPageStrings ( CHAR16 *NewString; CHAR16 *FirmwareVersionString; EFI_STATUS Status; - EFI_STRING_ID TokenToUpdate; EFI_SMBIOS_HANDLE SmbiosHandle; EFI_SMBIOS_PROTOCOL *Smbios; SMBIOS_TABLE_TYPE0 *Type0Record; @@ -872,92 +519,143 @@ UpdateFrontPageStrings ( FoundCpu = 0; // - // Update Front Page strings + // Update default banner string. // - Status = gBS->LocateProtocol ( - &gEfiSmbiosProtocolGuid, - NULL, - (VOID **) &Smbios - ); - if (!EFI_ERROR (Status)) { - SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; - Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL); - while (!EFI_ERROR(Status)) { - 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); - FirmwareVersionString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString); - if (*FirmwareVersionString != 0x0000 ) { - FreePool (NewString); - NewString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString); - HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); - } else { - HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); - FreePool (NewString); - } - } + NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NULL); + UiCustomizeFrontPageBanner (4, TRUE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NewString, NULL); + FreePool (NewString); - 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); - } + NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NULL); + UiCustomizeFrontPageBanner (4, FALSE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NewString, NULL); + FreePool (NewString); - if ((Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) { - Type4Record = (SMBIOS_TABLE_TYPE4 *) Record; - // - // The information in the record should be only valid when the CPU Socket is populated. - // - if ((Type4Record->Status & SMBIOS_TYPE4_CPU_SOCKET_POPULATED) == SMBIOS_TYPE4_CPU_SOCKET_POPULATED) { - 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); + NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NULL); + UiCustomizeFrontPageBanner (5, TRUE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NewString, NULL); + FreePool (NewString); - ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString); - TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED); - HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); - FreePool (NewString); + NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NULL); + UiCustomizeFrontPageBanner (5, FALSE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NewString, NULL); + FreePool (NewString); - FoundCpu = TRUE; - } - } - - if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) { - Type19Record = (SMBIOS_TABLE_TYPE19 *) Record; - if (Type19Record->StartingAddress != 0xFFFFFFFF ) { - InstalledMemory += RShiftU64(Type19Record->EndingAddress - - Type19Record->StartingAddress + 1, 10); - } else { - InstalledMemory += RShiftU64(Type19Record->ExtendedEndingAddress - - Type19Record->ExtendedStartingAddress + 1, 20); - } - } - - Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL); - } - - // now update the total installed RAM size - ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString ); - TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE); - HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); + // + // Update Front Page banner strings base on SmBios Table. + // + Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **) &Smbios); + if (EFI_ERROR (Status)) { + // + // Smbios protocol not found, get the default value. + // + NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NULL); + UiCustomizeFrontPageBanner (1, TRUE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL); FreePool (NewString); + + NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NULL); + UiCustomizeFrontPageBanner (2, TRUE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL); + FreePool (NewString); + + NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NULL); + UiCustomizeFrontPageBanner (2, FALSE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL); + FreePool (NewString); + + NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NULL); + UiCustomizeFrontPageBanner (3, TRUE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL); + FreePool (NewString); + + NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NULL); + UiCustomizeFrontPageBanner (3, FALSE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL); + FreePool (NewString); + + return; } - return ; + SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; + Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL); + while (!EFI_ERROR(Status)) { + 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); + + FirmwareVersionString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString); + if (*FirmwareVersionString != 0x0000 ) { + FreePool (NewString); + NewString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString); + UiCustomizeFrontPageBanner (3, TRUE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL); + } else { + UiCustomizeFrontPageBanner (3, TRUE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL); + FreePool (NewString); + } + } + + 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); + UiCustomizeFrontPageBanner (1, TRUE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL); + FreePool (NewString); + } + + if ((Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) { + Type4Record = (SMBIOS_TABLE_TYPE4 *) Record; + // + // The information in the record should be only valid when the CPU Socket is populated. + // + if ((Type4Record->Status & SMBIOS_TYPE4_CPU_SOCKET_POPULATED) == SMBIOS_TYPE4_CPU_SOCKET_POPULATED) { + StrIndex = Type4Record->ProcessorVersion; + GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString); + UiCustomizeFrontPageBanner (2, TRUE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL); + FreePool (NewString); + + ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString); + UiCustomizeFrontPageBanner (2, FALSE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL); + FreePool (NewString); + + FoundCpu = TRUE; + } + } + + if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) { + Type19Record = (SMBIOS_TABLE_TYPE19 *) Record; + if (Type19Record->StartingAddress != 0xFFFFFFFF ) { + InstalledMemory += RShiftU64(Type19Record->EndingAddress - + Type19Record->StartingAddress + 1, 10); + } else { + InstalledMemory += RShiftU64(Type19Record->ExtendedEndingAddress - + Type19Record->ExtendedStartingAddress + 1, 20); + } + } + + Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL); + } + + // + // Now update the total installed RAM size + // + ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString ); + UiCustomizeFrontPageBanner (3, FALSE, &NewString); + HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL); + FreePool (NewString); } /** This function will change video resolution and text mode - according to defined setup mode or defined boot mode + according to defined setup mode or defined boot mode - @param IsSetupMode Indicate mode is changed to setup mode or boot mode. + @param IsSetupMode Indicate mode is changed to setup mode or boot mode. @retval EFI_SUCCESS Mode is changed successfully. @retval Others Mode failed to be changed. @@ -985,13 +683,13 @@ BdsSetConsoleMode ( EFI_STATUS Status; UINTN Index; UINTN CurrentColumn; - UINTN CurrentRow; + UINTN CurrentRow; MaxGopMode = 0; MaxTextMode = 0; // - // Get current video resolution and text mode + // Get current video resolution and text mode // Status = gBS->HandleProtocol ( gST->ConsoleOutHandle, @@ -1009,7 +707,7 @@ BdsSetConsoleMode ( ); if (EFI_ERROR (Status)) { SimpleTextOut = NULL; - } + } if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) { return EFI_UNSUPPORTED; @@ -1030,12 +728,12 @@ BdsSetConsoleMode ( NewHorizontalResolution = mBootHorizontalResolution; NewVerticalResolution = mBootVerticalResolution; NewColumns = mBootTextModeColumn; - NewRows = mBootTextModeRow; + NewRows = mBootTextModeRow; } - + if (GraphicsOutput != NULL) { MaxGopMode = GraphicsOutput->Mode->MaxMode; - } + } if (SimpleTextOut != NULL) { MaxTextMode = SimpleTextOut->Mode->MaxMode; @@ -1139,8 +837,7 @@ BdsSetConsoleMode ( ASSERT_EFI_ERROR (Status); Status = PcdSet32S (PcdConOutRow, NewRows); ASSERT_EFI_ERROR (Status); - - + // // Video mode is changed, so restart graphics console driver and higher level driver. // Reconnect graphics console driver and higher level driver. @@ -1170,12 +867,12 @@ BdsSetConsoleMode ( /** The user Entry Point for Application. The user code starts with this function - as the real entry point for the image goes into a library that calls this + as the real entry point for the image goes into a library that calls this function. - @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. - + @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. @@ -1196,7 +893,7 @@ InitializeUserInterface ( if (!mModeInitialized) { // - // After the console is ready, get current video resolution + // After the console is ready, get current video resolution // and text mode before launching setup at first time. // Status = gBS->HandleProtocol ( @@ -1207,7 +904,7 @@ InitializeUserInterface ( if (EFI_ERROR (Status)) { GraphicsOutput = NULL; } - + Status = gBS->HandleProtocol ( gST->ConsoleOutHandle, &gEfiSimpleTextOutProtocolGuid, @@ -1215,7 +912,7 @@ InitializeUserInterface ( ); if (EFI_ERROR (Status)) { SimpleTextOut = NULL; - } + } if (GraphicsOutput != NULL) { // @@ -1238,9 +935,9 @@ InitializeUserInterface ( // // Get user defined text mode for setup. - // + // mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution); - mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution); + mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution); mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn); mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow); @@ -1249,11 +946,10 @@ InitializeUserInterface ( gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL); gST->ConOut->ClearScreen (gST->ConOut); - + // // Install customized fonts needed by Front Page // - HiiHandle = ExportFonts (); ASSERT (HiiHandle != NULL); @@ -1322,38 +1018,6 @@ UiEntry ( SetupResetReminder (); } -/** - Extract device path for given HII handle and class guid. - - @param Handle The HII handle. - - @retval NULL Fail to get the device path string. - @return PathString Get the device path string. - -**/ -CHAR16 * -ExtractDevicePathFromHiiHandle ( - IN EFI_HII_HANDLE Handle - ) -{ - EFI_STATUS Status; - EFI_HANDLE DriverHandle; - - ASSERT (Handle != NULL); - - if (Handle == NULL) { - return NULL; - } - - Status = gHiiDatabase->GetPackageListHandle (gHiiDatabase, Handle, &DriverHandle); - if (EFI_ERROR (Status)) { - return NULL; - } - - return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle), FALSE, FALSE); - -} - // // Following are BDS Lib functions which contain all the code about setup browser reset reminder feature. // Setup Browser reset reminder feature is that an reset reminder will be given before user leaves the setup browser if diff --git a/MdeModulePkg/Application/UiApp/FrontPage.h b/MdeModulePkg/Application/UiApp/FrontPage.h index a42253f401..1da56aced2 100644 --- a/MdeModulePkg/Application/UiApp/FrontPage.h +++ b/MdeModulePkg/Application/UiApp/FrontPage.h @@ -41,12 +41,7 @@ extern BOOLEAN gConnectAllHappened; // #define FRONT_PAGE_FORM_ID 0x1000 -#define FRONT_PAGE_KEY_OFFSET 0x4000 -#define FRONT_PAGE_KEY_CONTINUE 0x1000 -#define FRONT_PAGE_KEY_LANGUAGE 0x1234 - -#define LABEL_SELECT_LANGUAGE 0x1000 -#define LABEL_PLATFORM_INFORMATION 0x1001 +#define LABEL_FRANTPAGE_INFORMATION 0x1000 #define LABEL_END 0xffff #define FRONT_PAGE_FORMSET_GUID \ diff --git a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUi.c b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUi.c new file mode 100644 index 0000000000..6e4f7b5c22 --- /dev/null +++ b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUi.c @@ -0,0 +1,132 @@ +/** @file + + This library class defines a set of interfaces to customize Ui module + +Copyright (c) 2016, 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 that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +#include +#include +#include +#include +#include "FrontPageCustomizedUiSupport.h" + +/** + Customize menus in the page. + + @param[in] HiiHandle The HII Handle of the form to update. + @param[in] StartOpCodeHandle The context used to insert opcode. + @param[in] CustomizePageType The page type need to be customized. + +**/ +VOID +UiCustomizeFrontPage ( + IN EFI_HII_HANDLE HiiHandle, + IN VOID *StartOpCodeHandle + ) +{ + // + // Create "Select Language" menu with Oneof opcode. + // + UiCreateLanguageMenu (HiiHandle, StartOpCodeHandle); + + // + // Create empty line. + // + UiCreateEmptyLine(HiiHandle, StartOpCodeHandle); + + // + // Find third party drivers which need to be shown in the front page. + // + UiListThirdPartyDrivers (HiiHandle, &gEfiIfrFrontPageGuid, NULL, StartOpCodeHandle); + + // + // Create empty line. + // + UiCreateEmptyLine(HiiHandle, StartOpCodeHandle); + + // + // Create "Continue" menu. + // + UiCreateContinueMenu(HiiHandle, StartOpCodeHandle); + + // + // Create reset menu. + // + UiCreateResetMenu(HiiHandle, StartOpCodeHandle); +} + +/** + This function processes the results of changes in configuration. + + + @param HiiHandle Points to the hii handle for this formset. + @param Action Specifies the type of action taken by the browser. + @param QuestionId A unique value which is sent to the original exporting driver + so that it can identify the type of data to expect. + @param Type The type of value for the question. + @param Value A pointer to the data being sent to the original exporting driver. + @param ActionRequest On return, points to the action requested by the callback function. + + @retval EFI_SUCCESS The callback successfully handled the action. + @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data. + @retval EFI_DEVICE_ERROR The variable could not be saved. + @retval EFI_UNSUPPORTED The specified Action is not supported by the callback. + +**/ +EFI_STATUS +UiFrontPageCallbackHandler ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_BROWSER_ACTION Action, + IN EFI_QUESTION_ID QuestionId, + IN UINT8 Type, + IN EFI_IFR_TYPE_VALUE *Value, + OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest + ) +{ + EFI_STATUS Status; + + if (UiSupportLibCallbackHandler (HiiHandle, Action, QuestionId, Type, Value, ActionRequest, &Status)) { + return Status; + } + + return EFI_UNSUPPORTED; +} + +/** + Update the banner string in the front page. + + Current layout for the banner string like below: + PS: Totally only 5 lines of banner supported. + + Line 1: Left BannerStr RightBannerStr + Line 2: Left BannerStr RightBannerStr + Line 3: Left BannerStr RightBannerStr + Line 4: Left BannerStr RightBannerStr + Line 5: Left BannerStr RightBannerStr + + First menu in front page. + ... + + @param LineIndex The line index of the banner need to check. + @param LeftOrRight The left or right banner need to check. + @param BannerStr Banner string need to update. + Input the current string and user can update + it and return the new string. + +**/ +VOID +UiCustomizeFrontPageBanner ( + IN UINTN LineIndex, + IN BOOLEAN LeftOrRight, + IN OUT EFI_STRING *BannerStr + ) +{ +} diff --git a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUi.h b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUi.h new file mode 100644 index 0000000000..6df0d139d5 --- /dev/null +++ b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUi.h @@ -0,0 +1,88 @@ +/** @file + This library class defines a set of interfaces to customize Ui module + +Copyright (c) 2016, 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 that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __FRONTPAGE_CUSTOMIZED_UI_H__ +#define __FRONTPAGE_CUSTOMIZED_UI_H__ + +/** + Update the banner string in the front page. + + Current layout for the banner string like below: + PS: Totally only 5 lines of banner supported. + + Line 1: Left BannerStr RightBannerStr + Line 2: Left BannerStr RightBannerStr + Line 3: Left BannerStr RightBannerStr + Line 4: Left BannerStr RightBannerStr + Line 5: Left BannerStr RightBannerStr + + First menu in front page. + ... + + @param LineIndex The line index of the banner need to check. + @param LeftOrRight The left or right banner need to check. + @param BannerStr Banner string need to update. + Input the current string and user can update + it and return the new string. + +**/ +VOID +UiCustomizeFrontPageBanner ( + IN UINTN LineIndex, + IN BOOLEAN LeftOrRight, + IN OUT EFI_STRING *BannerStr + ); + +/** + Customize menus in the page. + + @param[in] HiiHandle The HII Handle of the form to update. + @param[in] StartOpCodeHandle The context used to insert opcode. + +**/ +VOID +UiCustomizeFrontPage ( + IN EFI_HII_HANDLE HiiHandle, + IN VOID *StartOpCodeHandle + ); + +/** + This function processes the results of changes in configuration. + + + @param HiiHandle Points to the hii handle for this formset. + @param Action Specifies the type of action taken by the browser. + @param QuestionId A unique value which is sent to the original exporting driver + so that it can identify the type of data to expect. + @param Type The type of value for the question. + @param Value A pointer to the data being sent to the original exporting driver. + @param ActionRequest On return, points to the action requested by the callback function. + + @retval EFI_SUCCESS The callback successfully handled the action. + @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data. + @retval EFI_DEVICE_ERROR The variable could not be saved. + @retval EFI_UNSUPPORTED The specified Action is not supported by the callback. + +**/ +EFI_STATUS +UiFrontPageCallbackHandler ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_BROWSER_ACTION Action, + IN EFI_QUESTION_ID QuestionId, + IN UINT8 Type, + IN EFI_IFR_TYPE_VALUE *Value, + OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest + ); + +#endif diff --git a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c new file mode 100644 index 0000000000..80450a5ac4 --- /dev/null +++ b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c @@ -0,0 +1,659 @@ +/** @file + + This library class defines a set of interfaces to customize Ui module + +Copyright (c) 2016, 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 that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FrontPageCustomizedUiSupport.h" + +// +// This is the VFR compiler generated header file which defines the +// string identifiers. +// +#define PRINTABLE_LANGUAGE_NAME_STRING_ID 0x0001 + +#define UI_HII_DRIVER_LIST_SIZE 0x8 + +#define FRONT_PAGE_KEY_CONTINUE 0x1000 +#define FRONT_PAGE_KEY_RESET 0x1001 +#define FRONT_PAGE_KEY_LANGUAGE 0x1002 + +typedef struct { + EFI_STRING_ID PromptId; + EFI_STRING_ID HelpId; + EFI_STRING_ID DevicePathId; + EFI_GUID FormSetGuid; + BOOLEAN EmptyLineAfter; +} UI_HII_DRIVER_INSTANCE; + +CHAR8 *gLanguageString; +EFI_STRING_ID *gLanguageToken; +UI_HII_DRIVER_INSTANCE *gHiiDriverList; +EFI_HII_HANDLE gHiiHandle; + + +/** + Get next language from language code list (with separator ';'). + + If LangCode is NULL, then ASSERT. + If Lang is NULL, then ASSERT. + + @param LangCode On input: point to first language in the list. On + output: point to next language in the list, or + NULL if no more language in the list. + @param Lang The first language in the list. + +**/ +VOID +GetNextLanguage ( + IN OUT CHAR8 **LangCode, + OUT CHAR8 *Lang + ) +{ + UINTN Index; + CHAR8 *StringPtr; + + ASSERT (LangCode != NULL); + ASSERT (*LangCode != NULL); + ASSERT (Lang != NULL); + + Index = 0; + StringPtr = *LangCode; + while (StringPtr[Index] != 0 && StringPtr[Index] != ';') { + Index++; + } + + CopyMem (Lang, StringPtr, Index); + Lang[Index] = 0; + + if (StringPtr[Index] == ';') { + Index++; + } + *LangCode = StringPtr + Index; +} + +/** + This function processes the language changes in configuration. + + @param Value A pointer to the data being sent to the original exporting driver. + + + @retval TRUE The callback successfully handled the action. + @retval FALSE The callback not supported in this handler. + +**/ +EFI_STATUS +LanguageChangeHandler ( + IN EFI_IFR_TYPE_VALUE *Value + ) +{ + CHAR8 *LangCode; + CHAR8 *Lang; + UINTN Index; + EFI_STATUS Status; + + // + // Allocate working buffer for RFC 4646 language in supported LanguageString. + // + Lang = AllocatePool (AsciiStrSize (gLanguageString)); + ASSERT (Lang != NULL); + + Index = 0; + LangCode = gLanguageString; + while (*LangCode != 0) { + GetNextLanguage (&LangCode, Lang); + + if (Index == Value->u8) { + break; + } + + Index++; + } + + if (Index == Value->u8) { + Status = gRT->SetVariable ( + L"PlatformLang", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + AsciiStrSize (Lang), + Lang + ); + if (EFI_ERROR (Status)) { + FreePool (Lang); + return EFI_DEVICE_ERROR; + } + } else { + ASSERT (FALSE); + } + FreePool (Lang); + + return EFI_SUCCESS; +} + +/** + This function processes the results of changes in configuration. + + + @param HiiHandle Points to the hii handle for this formset. + @param Action Specifies the type of action taken by the browser. + @param QuestionId A unique value which is sent to the original exporting driver + so that it can identify the type of data to expect. + @param Type The type of value for the question. + @param Value A pointer to the data being sent to the original exporting driver. + @param ActionRequest On return, points to the action requested by the callback function. + @param Status Return the handle status. + + @retval TRUE The callback successfully handled the action. + @retval FALSE The callback not supported in this handler. + +**/ +BOOLEAN +UiSupportLibCallbackHandler ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_BROWSER_ACTION Action, + IN EFI_QUESTION_ID QuestionId, + IN UINT8 Type, + IN EFI_IFR_TYPE_VALUE *Value, + OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest, + OUT EFI_STATUS *Status + ) +{ + if (QuestionId != FRONT_PAGE_KEY_CONTINUE && + QuestionId != FRONT_PAGE_KEY_RESET && + QuestionId != FRONT_PAGE_KEY_LANGUAGE) { + return FALSE; + } + + if (Action != EFI_BROWSER_ACTION_CHANGED) { + // + // Do nothing for other UEFI Action. Only do call back when data is changed. + // + *Status = EFI_UNSUPPORTED; + } + + if (Action == EFI_BROWSER_ACTION_CHANGED) { + if ((Value == NULL) || (ActionRequest == NULL)) { + *Status = EFI_INVALID_PARAMETER; + } + + *Status = EFI_SUCCESS; + 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; + + case FRONT_PAGE_KEY_LANGUAGE: + *Status = LanguageChangeHandler(Value); + break; + + case FRONT_PAGE_KEY_RESET: + // + // Reset + // + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + *Status = EFI_UNSUPPORTED; + + default: + break; + } + } + + return TRUE; +} + +/** + Create Select language menu in the front page with oneof opcode. + + @param[in] HiiHandle The hii handle for the Uiapp driver. + @param[in] QuestionId Question ID + @param[in] StartOpCodeHandle The opcode handle to save the new opcode. + + @retval EFI_SUCCESS Search the driver success + +**/ +VOID +UiCreateLanguageMenu ( + IN EFI_HII_HANDLE HiiHandle, + IN VOID *StartOpCodeHandle + ) +{ + CHAR8 *LangCode; + CHAR8 *Lang; + CHAR8 *CurrentLang; + UINTN OptionCount; + CHAR16 *StringBuffer; + VOID *OptionsOpCodeHandle; + UINTN StringSize; + EFI_STATUS Status; + EFI_HII_STRING_PROTOCOL *HiiString; + + Lang = NULL; + StringBuffer = NULL; + + // + // Init OpCode Handle and Allocate space for creation of UpdateData Buffer + // + OptionsOpCodeHandle = HiiAllocateOpCodeHandle (); + ASSERT (OptionsOpCodeHandle != NULL); + + GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLang, NULL); + + // + // Get Support language list from variable. + // + GetEfiGlobalVariable2 (L"PlatformLangCodes", (VOID**)&gLanguageString, NULL); + if (gLanguageString == NULL) { + gLanguageString = AllocateCopyPool ( + AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)), + (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes) + ); + ASSERT (gLanguageString != NULL); + } + + if (gLanguageToken == NULL) { + // + // Count the language list number. + // + LangCode = gLanguageString; + Lang = AllocatePool (AsciiStrSize (gLanguageString)); + ASSERT (Lang != NULL); + + OptionCount = 0; + while (*LangCode != 0) { + GetNextLanguage (&LangCode, Lang); + OptionCount ++; + } + + // + // Allocate extra 1 as the end tag. + // + gLanguageToken = AllocateZeroPool ((OptionCount + 1) * sizeof (EFI_STRING_ID)); + ASSERT (gLanguageToken != NULL); + + Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString); + ASSERT_EFI_ERROR (Status); + + LangCode = gLanguageString; + OptionCount = 0; + while (*LangCode != 0) { + GetNextLanguage (&LangCode, Lang); + + StringSize = 0; + Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL); + if (Status == EFI_BUFFER_TOO_SMALL) { + StringBuffer = AllocateZeroPool (StringSize); + ASSERT (StringBuffer != NULL); + Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL); + ASSERT_EFI_ERROR (Status); + } + + if (EFI_ERROR (Status)) { + StringBuffer = AllocatePool (AsciiStrSize (Lang) * sizeof (CHAR16)); + ASSERT (StringBuffer != NULL); + AsciiStrToUnicodeStr (Lang, StringBuffer); + } + + ASSERT (StringBuffer != NULL); + gLanguageToken[OptionCount] = HiiSetString (HiiHandle, 0, StringBuffer, NULL); + FreePool (StringBuffer); + + OptionCount++; + } + } + + ASSERT (gLanguageToken != NULL); + LangCode = gLanguageString; + OptionCount = 0; + if (Lang == NULL) { + Lang = AllocatePool (AsciiStrSize (gLanguageString)); + ASSERT (Lang != NULL); + } + while (*LangCode != 0) { + GetNextLanguage (&LangCode, Lang); + + if (CurrentLang != NULL && AsciiStrCmp (Lang, CurrentLang) == 0) { + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + gLanguageToken[OptionCount], + EFI_IFR_OPTION_DEFAULT, + EFI_IFR_NUMERIC_SIZE_1, + (UINT8) OptionCount + ); + } else { + HiiCreateOneOfOptionOpCode ( + OptionsOpCodeHandle, + gLanguageToken[OptionCount], + 0, + EFI_IFR_NUMERIC_SIZE_1, + (UINT8) OptionCount + ); + } + + OptionCount++; + } + + if (CurrentLang != NULL) { + FreePool (CurrentLang); + } + FreePool (Lang); + + HiiCreateOneOfOpCode ( + StartOpCodeHandle, + FRONT_PAGE_KEY_LANGUAGE, + 0, + 0, + STRING_TOKEN (STR_LANGUAGE_SELECT), + STRING_TOKEN (STR_LANGUAGE_SELECT_HELP), + EFI_IFR_FLAG_CALLBACK, + EFI_IFR_NUMERIC_SIZE_1, + OptionsOpCodeHandle, + NULL + ); +} + +/** + Create continue menu in the front page. + + @param[in] HiiHandle The hii handle for the Uiapp driver. + @param[in] StartOpCodeHandle The opcode handle to save the new opcode. + +**/ +VOID +UiCreateContinueMenu ( + IN EFI_HII_HANDLE HiiHandle, + IN VOID *StartOpCodeHandle + ) +{ + HiiCreateActionOpCode ( + StartOpCodeHandle, + FRONT_PAGE_KEY_CONTINUE, + STRING_TOKEN (STR_CONTINUE_PROMPT), + STRING_TOKEN (STR_CONTINUE_PROMPT), + EFI_IFR_FLAG_CALLBACK, + 0 + ); +} + +/** + Create empty line menu in the front page. + + @param HiiHandle The hii handle for the Uiapp driver. + @param StartOpCodeHandle The opcode handle to save the new opcode. + +**/ +VOID +UiCreateEmptyLine ( + IN EFI_HII_HANDLE HiiHandle, + IN VOID *StartOpCodeHandle + ) +{ + HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_NULL_STRING), 0, 0, 0); +} + +/** + Create Reset menu in the front page. + + @param[in] HiiHandle The hii handle for the Uiapp driver. + @param[in] StartOpCodeHandle The opcode handle to save the new opcode. + +**/ +VOID +UiCreateResetMenu ( + IN EFI_HII_HANDLE HiiHandle, + IN VOID *StartOpCodeHandle + ) +{ + HiiCreateActionOpCode ( + StartOpCodeHandle, + FRONT_PAGE_KEY_RESET, + STRING_TOKEN (STR_RESET_STRING), + STRING_TOKEN (STR_RESET_STRING), + EFI_IFR_FLAG_CALLBACK, + 0 + ); +} + +/** + Extract device path for given HII handle and class guid. + + @param Handle The HII handle. + + @retval NULL Fail to get the device path string. + @return PathString Get the device path string. + +**/ +CHAR16 * +ExtractDevicePathFromHiiHandle ( + IN EFI_HII_HANDLE Handle + ) +{ + EFI_STATUS Status; + EFI_HANDLE DriverHandle; + + ASSERT (Handle != NULL); + + if (Handle == NULL) { + return NULL; + } + + Status = gHiiDatabase->GetPackageListHandle (gHiiDatabase, Handle, &DriverHandle); + if (EFI_ERROR (Status)) { + return NULL; + } + + return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle), FALSE, FALSE); +} + +/** + Check whether this driver need to be shown in the front page. + + @param HiiHandle The hii handle for the driver. + @param Guid The special guid for the driver which is the target. + @param PromptId Return the prompt string id. + @param HelpId Return the help string id. + @param FormsetGuid Return the formset guid info. + + @retval EFI_SUCCESS Search the driver success + +**/ +BOOLEAN +RequiredDriver ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_GUID *Guid, + OUT EFI_STRING_ID *PromptId, + OUT EFI_STRING_ID *HelpId, + OUT VOID *FormsetGuid + ) +{ + EFI_STATUS Status; + UINT8 ClassGuidNum; + EFI_GUID *ClassGuid; + EFI_IFR_FORM_SET *Buffer; + UINTN BufferSize; + UINT8 *Ptr; + UINTN TempSize; + BOOLEAN RetVal; + + Status = HiiGetFormSetFromHiiHandle(HiiHandle, &Buffer,&BufferSize); + if (EFI_ERROR (Status)) { + return FALSE; + } + + RetVal = FALSE; + TempSize = 0; + Ptr = (UINT8 *) Buffer; + while(TempSize < BufferSize) { + TempSize += ((EFI_IFR_OP_HEADER *) Ptr)->Length; + + if (((EFI_IFR_OP_HEADER *) Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)){ + Ptr += ((EFI_IFR_OP_HEADER *) Ptr)->Length; + continue; + } + + ClassGuidNum = (UINT8) (((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3); + ClassGuid = (EFI_GUID *) (VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET)); + while (ClassGuidNum-- > 0) { + if (!CompareGuid (Guid, ClassGuid)){ + ClassGuid ++; + continue; + } + + *PromptId = ((EFI_IFR_FORM_SET *)Ptr)->FormSetTitle; + *HelpId = ((EFI_IFR_FORM_SET *)Ptr)->Help; + CopyMem (FormsetGuid, &((EFI_IFR_FORM_SET *) Ptr)->Guid, sizeof (EFI_GUID)); + RetVal = TRUE; + } + } + + FreePool (Buffer); + + return RetVal; +} + +/** + Search the drivers in the system which need to show in the front page + and insert the menu to the front page. + + @param HiiHandle The hii handle for the Uiapp driver. + @param ClassGuid The class guid for the driver which is the target. + @param StartOpCodeHandle The opcode handle to save the new opcode. + @param SpecialHandler The pointer to the specail handler function, if any. + + @retval EFI_SUCCESS Search the driver success + +**/ +EFI_STATUS +UiListThirdPartyDrivers ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_GUID *ClassGuid, + IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn, + IN VOID *StartOpCodeHandle + ) +{ + UINTN Index; + EFI_STRING String; + EFI_STRING_ID Token; + EFI_STRING_ID TokenHelp; + EFI_HII_HANDLE *HiiHandles; + CHAR16 *DevicePathStr; + UINTN Count; + UINTN CurrentSize; + UI_HII_DRIVER_INSTANCE *DriverListPtr; + EFI_STRING NewName; + BOOLEAN EmptyLineAfter; + + if (gHiiDriverList != NULL) { + FreePool (gHiiDriverList); + } + + HiiHandles = HiiGetHiiHandles (NULL); + ASSERT (HiiHandles != NULL); + + gHiiDriverList = AllocateZeroPool (UI_HII_DRIVER_LIST_SIZE * sizeof (UI_HII_DRIVER_INSTANCE)); + ASSERT (gHiiDriverList != NULL); + DriverListPtr = gHiiDriverList; + CurrentSize = UI_HII_DRIVER_LIST_SIZE; + + for (Index = 0, Count = 0; HiiHandles[Index] != NULL; Index++) { + if (!RequiredDriver (HiiHandles[Index], ClassGuid, &Token, &TokenHelp, &gHiiDriverList[Count].FormSetGuid)) { + continue; + } + + String = HiiGetString (HiiHandles[Index], Token, NULL); + if (String == NULL) { + String = HiiGetString (gHiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL); + ASSERT (String != NULL); + } else if (SpecialHandlerFn != NULL) { + // + // Check whether need to rename the driver name. + // + EmptyLineAfter = FALSE; + if (SpecialHandlerFn (String, &NewName, &EmptyLineAfter)) { + FreePool (String); + String = NewName; + DriverListPtr[Count].EmptyLineAfter = EmptyLineAfter; + } + } + DriverListPtr[Count].PromptId = HiiSetString (HiiHandle, 0, String, NULL); + FreePool (String); + + String = HiiGetString (HiiHandles[Index], TokenHelp, NULL); + if (String == NULL) { + String = HiiGetString (gHiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL); + ASSERT (String != NULL); + } + DriverListPtr[Count].HelpId = HiiSetString (HiiHandle, 0, String, NULL); + FreePool (String); + + DevicePathStr = ExtractDevicePathFromHiiHandle(HiiHandles[Index]); + if (DevicePathStr != NULL){ + DriverListPtr[Count].DevicePathId = HiiSetString (HiiHandle, 0, DevicePathStr, NULL); + FreePool (DevicePathStr); + } else { + DriverListPtr[Count].DevicePathId = 0; + } + + Count++; + if (Count >= CurrentSize) { + DriverListPtr = AllocateCopyPool ((Count + UI_HII_DRIVER_LIST_SIZE) * sizeof (UI_HII_DRIVER_INSTANCE), gHiiDriverList); + ASSERT (DriverListPtr != NULL); + FreePool (gHiiDriverList); + gHiiDriverList = DriverListPtr; + CurrentSize += UI_HII_DRIVER_LIST_SIZE; + } + } + + FreePool (HiiHandles); + + Index = 0; + while (gHiiDriverList[Index].PromptId != 0) { + HiiCreateGotoExOpCode ( + StartOpCodeHandle, + 0, + gHiiDriverList[Index].PromptId, + gHiiDriverList[Index].HelpId, + 0, + 0, + 0, + &gHiiDriverList[Index].FormSetGuid, + gHiiDriverList[Index].DevicePathId + ); + + if (gHiiDriverList[Index].EmptyLineAfter) { + UiCreateEmptyLine (HiiHandle, StartOpCodeHandle); + } + + Index ++; + } + + return EFI_SUCCESS; +} diff --git a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.h b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.h new file mode 100644 index 0000000000..ce3ecd5270 --- /dev/null +++ b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.h @@ -0,0 +1,144 @@ +/** @file + This library class defines a set of interfaces to be used by customize Ui module + +Copyright (c) 2016, 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 that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __FRONTPAGE_CUSTOMIZE_UI_SUPPORT_UI_H__ +#define __FRONTPAGE_CUSTOMIZE_UI_SUPPORT_UI_H__ + +/** + Create continue menu in the front page. + + @param[in] HiiHandle The hii handle for the Uiapp driver. + @param[in] StartOpCodeHandle The opcode handle to save the new opcode. + + @retval EFI_SUCCESS Search the driver success + +**/ +VOID +UiCreateContinueMenu ( + IN EFI_HII_HANDLE HiiHandle, + IN VOID *StartOpCodeHandle + ); + +/** + Create empty line menu. + + @param HiiHandle The hii handle for the Uiapp driver. + @param StartOpCodeHandle The opcode handle to save the new opcode. + + @retval EFI_SUCCESS Search the driver success + +**/ +VOID +UiCreateEmptyLine ( + IN EFI_HII_HANDLE HiiHandle, + IN VOID *StartOpCodeHandle + ); + +/** + Create Select language menu in the front page with oneof opcode. + + @param[in] HiiHandle The hii handle for the Uiapp driver. + @param[in] StartOpCodeHandle The opcode handle to save the new opcode. + + @retval EFI_SUCCESS Search the driver success + +**/ +VOID +UiCreateLanguageMenu ( + IN EFI_HII_HANDLE HiiHandle, + IN VOID *StartOpCodeHandle + ); + +/** + Create Reset menu. + + @param[in] HiiHandle The hii handle for the Uiapp driver. + @param[in] StartOpCodeHandle The opcode handle to save the new opcode. + + @retval EFI_SUCCESS Search the driver success + +**/ +VOID +UiCreateResetMenu ( + IN EFI_HII_HANDLE HiiHandle, + IN VOID *StartOpCodeHandle + ); + +/** + Rename the driver name if necessary. + + @param DriverName Input the driver name. + @param NewDriverName Return the new driver name. + @param EmptyLineAfter Whether need to insert empty line. + + @retval New driver name if compared, else NULL. + +**/ +typedef +BOOLEAN +(EFIAPI *DRIVER_SPECIAL_HANDLER)( + IN CHAR16 *DriverName, + OUT CHAR16 **NewName, + OUT BOOLEAN *EmptyLineAfter +); + +/** + Search the drivers in the system which need to show in the front page + and insert the menu to the front page. + + @param HiiHandle The hii handle for the Uiapp driver. + @param ClassGuid The class guid for the driver which is the target. + @param StartOpCodeHandle The opcode handle to save the new opcode. + @param SpecialHandler The pointer to the specail handler function, if any. + + @retval EFI_SUCCESS Search the driver success + +**/ +EFI_STATUS +UiListThirdPartyDrivers ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_GUID *ClassGuid, + IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn, + IN VOID *StartOpCodeHandle + ); + +/** + This function processes the results of changes in configuration. + + + @param HiiHandle Points to the hii handle for this formset. + @param Action Specifies the type of action taken by the browser. + @param QuestionId A unique value which is sent to the original exporting driver + so that it can identify the type of data to expect. + @param Type The type of value for the question. + @param Value A pointer to the data being sent to the original exporting driver. + @param ActionRequest On return, points to the action requested by the callback function. + @param Status Return the handle status. + + @retval TRUE The callback successfully handled the action. + @retval FALSE The callback not supported in this handler. + +**/ +BOOLEAN +UiSupportLibCallbackHandler ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_BROWSER_ACTION Action, + IN EFI_QUESTION_ID QuestionId, + IN UINT8 Type, + IN EFI_IFR_TYPE_VALUE *Value, + OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest, + OUT EFI_STATUS *Status + ); + +#endif diff --git a/MdeModulePkg/Application/UiApp/FrontPageStrings.uni b/MdeModulePkg/Application/UiApp/FrontPageStrings.uni index 43f379067a..71cb7887d1 100644 --- a/MdeModulePkg/Application/UiApp/FrontPageStrings.uni +++ b/MdeModulePkg/Application/UiApp/FrontPageStrings.uni @@ -1,16 +1,16 @@ ///** @file -// +// // String definitions for BdsPlatform formset. -// +// // Copyright (c) 2004 - 2015, 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 -// +// // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -// +// //**/ /=# @@ -52,8 +52,6 @@ #language fr-FR "Choisir la Langue" #string STR_LANGUAGE_SELECT_HELP #language en-US "This is the option one adjusts to change the language for the current system" #language fr-FR "Ceci est l'option que celui ajuste changer la langue pour le système actuel" -#string STR_TIME_OUT_PROMPT #language en-US "Boot process will continue in %d seconds" - #language fr-FR "Le procédé de botte continuera dans %d secondes" #string STR_MISSING_STRING #language en-US "Missing String" #language fr-FR "Missing String" #string STR_EMPTY_STRING #language en-US "" @@ -62,5 +60,13 @@ #language fr-FR "Reset" #string STR_RESET_STRING_HELP #language en-US "Reset the current setting." #language fr-FR "Reset the current setting." -#string STR_INTEL_COPYRIGHT #language en-US "Copyright (c) 2006-2015, Intel Corporation" - #language fr-FR "Copyright (c) 2006-2015, Intel Corporation" \ No newline at end of file +#string STR_CUSTOMIZE_BANNER_LINE4_LEFT #language en-US "" + #language fr-FR "" +#string STR_CUSTOMIZE_BANNER_LINE4_RIGHT #language en-US "" + #language fr-FR "" +#string STR_CUSTOMIZE_BANNER_LINE5_LEFT #language en-US "" + #language fr-FR "" +#string STR_CUSTOMIZE_BANNER_LINE5_RIGHT #language en-US "" + #language fr-FR "" +#string STR_NULL_STRING #language en-US " " + #language fr-FR " " diff --git a/MdeModulePkg/Application/UiApp/FrontPageVfr.Vfr b/MdeModulePkg/Application/UiApp/FrontPageVfr.Vfr index aa622c1697..6c59f82b97 100644 --- a/MdeModulePkg/Application/UiApp/FrontPageVfr.Vfr +++ b/MdeModulePkg/Application/UiApp/FrontPageVfr.Vfr @@ -17,11 +17,7 @@ #define FRONT_PAGE_FORM_ID 0x1000 -#define FRONT_PAGE_KEY_CONTINUE 0x1000 -#define FRONT_PAGE_KEY_LANGUAGE 0x1234 - -#define LABEL_SELECT_LANGUAGE 0x1000 -#define LABEL_PLATFORM_INFORMATION 0x1001 +#define LABEL_FRANTPAGE_INFORMATION 0x1000 #define LABEL_END 0xffff formset @@ -58,51 +54,27 @@ formset line 3, align right; -// banner -// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_0_LEFT), -// line 0, -// align left; + banner + title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE4_LEFT), + line 4, + align left; -// banner -// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_0_RIGHT), -// line 0, -// align right; + banner + title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE4_RIGHT), + line 4, + align right; -// banner -// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_1_LEFT), -// line 1, -// align left; + banner + title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE5_LEFT), + line 5, + align left; -// banner -// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_1_RIGHT), -// line 1, -// align right; + banner + title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE5_RIGHT), + line 5, + align right; -// banner -// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_2_LEFT), -// line 2, -// align left; - -// banner -// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_3_LEFT), -// line 3, -// align left; - - - text - help = STRING_TOKEN(STR_CONTINUE_HELP), - text = STRING_TOKEN(STR_CONTINUE_PROMPT), - flags = INTERACTIVE, - key = FRONT_PAGE_KEY_CONTINUE; - - label LABEL_SELECT_LANGUAGE; - // - // This is where we will dynamically add a OneOf type op-code to select - // Languages from the currently available choices - // - label LABEL_END; - - label LABEL_PLATFORM_INFORMATION; + label LABEL_FRANTPAGE_INFORMATION; // // This is where we will dynamically add a Action type op-code to show // the platform information. diff --git a/MdeModulePkg/Application/UiApp/Language.c b/MdeModulePkg/Application/UiApp/Language.c deleted file mode 100644 index df7a0b3561..0000000000 --- a/MdeModulePkg/Application/UiApp/Language.c +++ /dev/null @@ -1,309 +0,0 @@ -/** @file - Language settings - -Copyright (c) 2004 - 2015, 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 - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Language.h" -#include "FrontPage.h" - -EFI_GUID mFontPackageGuid = { - 0x78941450, 0x90ab, 0x4fb1, {0xb7, 0x5f, 0x58, 0x92, 0x14, 0xe2, 0x4a, 0xc} -}; - -#define NARROW_GLYPH_NUMBER 8 -#define WIDE_GLYPH_NUMBER 75 - -typedef struct { - /// - /// This 4-bytes total array length is required by HiiAddPackages() - /// - UINT32 Length; - - // - // This is the Font package definition - // - EFI_HII_PACKAGE_HEADER Header; - UINT16 NumberOfNarrowGlyphs; - UINT16 NumberOfWideGlyphs; - EFI_NARROW_GLYPH NarrowArray[NARROW_GLYPH_NUMBER]; - EFI_WIDE_GLYPH WideArray[WIDE_GLYPH_NUMBER]; -} FONT_PACK_BIN; - -FONT_PACK_BIN mFontBin = { - sizeof (FONT_PACK_BIN), - { - sizeof (FONT_PACK_BIN) - sizeof (UINT32), - EFI_HII_PACKAGE_SIMPLE_FONTS, - }, - NARROW_GLYPH_NUMBER, - 0, - { // Narrow Glyphs - { - 0x05d0, - 0x00, - { - 0x00, - 0x00, - 0x00, - 0x4E, - 0x6E, - 0x62, - 0x32, - 0x32, - 0x3C, - 0x68, - 0x4C, - 0x4C, - 0x46, - 0x76, - 0x72, - 0x00, - 0x00, - 0x00, - 0x00 - } - }, - { - 0x05d1, - 0x00, - { - 0x00, - 0x00, - 0x00, - 0x78, - 0x7C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x7E, - 0x7E, - 0x00, - 0x00, - 0x00, - 0x00 - } - }, - { - 0x05d2, - 0x00, - { - 0x00, - 0x00, - 0x00, - 0x78, - 0x7C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x1C, - 0x3E, - 0x66, - 0x66, - 0x00, - 0x00, - 0x00, - 0x00 - } - }, - { - 0x05d3, - 0x00, - { - 0x00, - 0x00, - 0x00, - 0x7E, - 0x7E, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x00, - 0x00, - 0x00, - 0x00 - } - }, - { - 0x05d4, - 0x00, - { - 0x00, - 0x00, - 0x00, - 0x7C, - 0x7E, - 0x06, - 0x06, - 0x06, - 0x06, - 0x66, - 0x66, - 0x66, - 0x66, - 0x66, - 0x66, - 0x00, - 0x00, - 0x00, - 0x00 - } - }, - { - 0x05d5, - 0x00, - { - 0x00, - 0x00, - 0x00, - 0x3C, - 0x3C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x0C, - 0x00, - 0x00, - 0x00, - 0x00 - } - }, - { - 0x05d6, - 0x00, - { - 0x00, - 0x00, - 0x00, - 0x38, - 0x38, - 0x1E, - 0x1E, - 0x18, - 0x18, - 0x18, - 0x18, - 0x18, - 0x18, - 0x18, - 0x18, - 0x00, - 0x00, - 0x00, - 0x00 - } - }, - { - 0x0000, - 0x00, - { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00 - } - } - } -}; - -/** - Routine to export glyphs to the HII database. This is in addition to whatever is defined in the Graphics Console driver. - -**/ -EFI_HII_HANDLE -ExportFonts ( - VOID - ) -{ - return HiiAddPackages ( - &mFontPackageGuid, - gImageHandle, - &mFontBin, - NULL - ); -} - -/** - Get next language from language code list (with separator ';'). - - If LangCode is NULL, then ASSERT. - If Lang is NULL, then ASSERT. - - @param LangCode On input: point to first language in the list. On - output: point to next language in the list, or - NULL if no more language in the list. - @param Lang The first language in the list. - -**/ -VOID -EFIAPI -GetNextLanguage ( - IN OUT CHAR8 **LangCode, - OUT CHAR8 *Lang - ) -{ - UINTN Index; - CHAR8 *StringPtr; - - ASSERT (LangCode != NULL); - ASSERT (*LangCode != NULL); - ASSERT (Lang != NULL); - - Index = 0; - StringPtr = *LangCode; - while (StringPtr[Index] != 0 && StringPtr[Index] != ';') { - Index++; - } - - CopyMem (Lang, StringPtr, Index); - Lang[Index] = 0; - - if (StringPtr[Index] == ';') { - Index++; - } - *LangCode = StringPtr + Index; -} \ No newline at end of file diff --git a/MdeModulePkg/Application/UiApp/Language.h b/MdeModulePkg/Application/UiApp/Language.h deleted file mode 100644 index 274de5ce2f..0000000000 --- a/MdeModulePkg/Application/UiApp/Language.h +++ /dev/null @@ -1,48 +0,0 @@ -/** @file - Language setting - -Copyright (c) 2004 - 2015, 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 - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _LANGUAGE_H_ -#define _LANGUAGE_H_ - -#include "String.h" - -/** - Get next language from language code list (with separator ';'). - - If LangCode is NULL, then ASSERT. - If Lang is NULL, then ASSERT. - - @param LangCode On input: point to first language in the list. On - output: point to next language in the list, or - NULL if no more language in the list. - @param Lang The first language in the list. - -**/ -VOID -EFIAPI -GetNextLanguage ( - IN OUT CHAR8 **LangCode, - OUT CHAR8 *Lang - ); - -/** - Routine to export glyphs to the HII database. This is in addition to whatever is defined in the Graphics Console driver. - -**/ -EFI_HII_HANDLE -ExportFonts ( - VOID - ); - -#endif // _LANGUAGE_H_ diff --git a/MdeModulePkg/Application/UiApp/String.c b/MdeModulePkg/Application/UiApp/String.c index 7884ae3fce..b6f22889ce 100644 --- a/MdeModulePkg/Application/UiApp/String.c +++ b/MdeModulePkg/Application/UiApp/String.c @@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "Ui.h" -#include "Language.h" #include "FrontPage.h" EFI_HII_HANDLE gStringPackHandle; @@ -22,6 +21,241 @@ EFI_GUID mUiStringPackGuid = { 0x136a3048, 0x752a, 0x4bf6, { 0xa7, 0x57, 0x9, 0x36, 0x11, 0x95, 0x38, 0xed } }; +EFI_GUID mFontPackageGuid = { + 0x78941450, 0x90ab, 0x4fb1, {0xb7, 0x5f, 0x58, 0x92, 0x14, 0xe2, 0x4a, 0xc} +}; + +#define NARROW_GLYPH_NUMBER 8 +#define WIDE_GLYPH_NUMBER 75 + +typedef struct { + /// + /// This 4-bytes total array length is required by HiiAddPackages() + /// + UINT32 Length; + + // + // This is the Font package definition + // + EFI_HII_PACKAGE_HEADER Header; + UINT16 NumberOfNarrowGlyphs; + UINT16 NumberOfWideGlyphs; + EFI_NARROW_GLYPH NarrowArray[NARROW_GLYPH_NUMBER]; + EFI_WIDE_GLYPH WideArray[WIDE_GLYPH_NUMBER]; +} FONT_PACK_BIN; + +FONT_PACK_BIN mFontBin = { + sizeof (FONT_PACK_BIN), + { + sizeof (FONT_PACK_BIN) - sizeof (UINT32), + EFI_HII_PACKAGE_SIMPLE_FONTS, + }, + NARROW_GLYPH_NUMBER, + 0, + { // Narrow Glyphs + { + 0x05d0, + 0x00, + { + 0x00, + 0x00, + 0x00, + 0x4E, + 0x6E, + 0x62, + 0x32, + 0x32, + 0x3C, + 0x68, + 0x4C, + 0x4C, + 0x46, + 0x76, + 0x72, + 0x00, + 0x00, + 0x00, + 0x00 + } + }, + { + 0x05d1, + 0x00, + { + 0x00, + 0x00, + 0x00, + 0x78, + 0x7C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x7E, + 0x7E, + 0x00, + 0x00, + 0x00, + 0x00 + } + }, + { + 0x05d2, + 0x00, + { + 0x00, + 0x00, + 0x00, + 0x78, + 0x7C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x1C, + 0x3E, + 0x66, + 0x66, + 0x00, + 0x00, + 0x00, + 0x00 + } + }, + { + 0x05d3, + 0x00, + { + 0x00, + 0x00, + 0x00, + 0x7E, + 0x7E, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x00, + 0x00, + 0x00, + 0x00 + } + }, + { + 0x05d4, + 0x00, + { + 0x00, + 0x00, + 0x00, + 0x7C, + 0x7E, + 0x06, + 0x06, + 0x06, + 0x06, + 0x66, + 0x66, + 0x66, + 0x66, + 0x66, + 0x66, + 0x00, + 0x00, + 0x00, + 0x00 + } + }, + { + 0x05d5, + 0x00, + { + 0x00, + 0x00, + 0x00, + 0x3C, + 0x3C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x0C, + 0x00, + 0x00, + 0x00, + 0x00 + } + }, + { + 0x05d6, + 0x00, + { + 0x00, + 0x00, + 0x00, + 0x38, + 0x38, + 0x1E, + 0x1E, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x00, + 0x00, + 0x00, + 0x00 + } + }, + { + 0x0000, + 0x00, + { + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00 + } + } + } +}; + /** Initialize HII global accessor for string support. @@ -69,3 +303,20 @@ GetStringById ( { return HiiGetString (gStringPackHandle, Id, NULL); } + +/** + Routine to export glyphs to the HII database. This is in addition to whatever is defined in the Graphics Console driver. + +**/ +EFI_HII_HANDLE +ExportFonts ( + VOID + ) +{ + return HiiAddPackages ( + &mFontPackageGuid, + gImageHandle, + &mFontBin, + NULL + ); +} diff --git a/MdeModulePkg/Application/UiApp/String.h b/MdeModulePkg/Application/UiApp/String.h index 386b92d15a..31c443875f 100644 --- a/MdeModulePkg/Application/UiApp/String.h +++ b/MdeModulePkg/Application/UiApp/String.h @@ -65,4 +65,13 @@ UninitializeStringSupport ( VOID ); +/** + Routine to export glyphs to the HII database. This is in addition to whatever is defined in the Graphics Console driver. + +**/ +EFI_HII_HANDLE +ExportFonts ( + VOID + ); + #endif // _STRING_H_ diff --git a/MdeModulePkg/Application/UiApp/UiApp.inf b/MdeModulePkg/Application/UiApp/UiApp.inf index 95c2d087f9..6df6e4739e 100644 --- a/MdeModulePkg/Application/UiApp/UiApp.inf +++ b/MdeModulePkg/Application/UiApp/UiApp.inf @@ -29,14 +29,16 @@ [Sources] FrontPage.h - Language.h String.h Ui.h FrontPageVfr.Vfr FrontPageStrings.uni FrontPage.c String.c - Language.c + FrontPageCustomizedUi.c + FrontPageCustomizedUiSupport.c + FrontPageCustomizedUi.h + FrontPageCustomizedUiSupport.h [Packages] MdePkg/MdePkg.dec