Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MdeModulePkg/Application/UiApp: Customize front page #115

Draft
wants to merge 1 commit into
base: dasharo-stable202002
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 51 additions & 44 deletions MdeModulePkg/Application/UiApp/FrontPage.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,21 +436,24 @@ ConvertMemoryInfoToString (
)
{
CHAR16 *StringBuffer;
CHAR16 RamBuffer[16];
CHAR16 SpeedBuffer[8];

StringBuffer = AllocateZeroPool (0x34);
StringBuffer = AllocateZeroPool (0x44);
ASSERT (StringBuffer != NULL);
UnicodeValueToStringS (StringBuffer, 0x34, LEFT_JUSTIFY, MemorySize, 10);
StrCatS (StringBuffer, 0x34 / sizeof (CHAR16), L" MB RAM");
UnicodeValueToStringS (RamBuffer, 16 * sizeof (CHAR16), LEFT_JUSTIFY, MemorySize, 10);
StrCatS (StringBuffer, 0x44 / sizeof (CHAR16), L"Memory: ");
StrCatS (StringBuffer, 0x44 / sizeof (CHAR16), RamBuffer);
StrCatS (StringBuffer, 0x44 / sizeof (CHAR16), L" MB");

//
// Some FSPs don't report speed in the memory HOB properly.
//
if (MemorySpeed != 0) {
UnicodeValueToStringS (SpeedBuffer, 8 * sizeof (CHAR16), LEFT_JUSTIFY, MemorySpeed, 10);
StrCatS (StringBuffer, 0x34 / sizeof (CHAR16), L" @ ");
StrCatS (StringBuffer, 0x34 / sizeof (CHAR16), SpeedBuffer);
StrCatS (StringBuffer, 0x34 / sizeof (CHAR16), L" MHz");
StrCatS (StringBuffer, 0x44 / sizeof (CHAR16), L" @ ");
StrCatS (StringBuffer, 0x44 / sizeof (CHAR16), SpeedBuffer);
StrCatS (StringBuffer, 0x44 / sizeof (CHAR16), L" MHz");
}

*String = (CHAR16 *) StringBuffer;
Expand Down Expand Up @@ -517,7 +520,9 @@ UpdateFrontPageBannerStrings (
)
{
UINT8 StrIndex;
UINTN StringSize;
CHAR16 *NewString;
CHAR16 *FinalString;
CHAR16 *FirmwareVersionString;
EFI_STATUS Status;
EFI_SMBIOS_HANDLE SmbiosHandle;
Expand All @@ -536,29 +541,6 @@ UpdateFrontPageBannerStrings (
MemorySpeed = 0;
FoundCpu = 0;

//
// Update default banner string.
//
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);

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);

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);

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);

//
// Update Front Page banner strings base on SmBios Table.
//
Expand All @@ -568,27 +550,22 @@ UpdateFrontPageBannerStrings (
// 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);

Expand All @@ -607,11 +584,18 @@ UpdateFrontPageBannerStrings (
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);
StringSize = StrLen(NewString) * sizeof(CHAR16) + StrLen(L"Version: ") * sizeof(CHAR16) + 2;
FinalString = AllocateZeroPool(StringSize);
if (FinalString) {
StrCatS(FinalString, StringSize, L"Version: ");
StrCatS(FinalString, StringSize, NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), FinalString, NULL);
FreePool (FinalString);
} else {
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);
}
FreePool (NewString);
}
}
Expand All @@ -620,8 +604,16 @@ UpdateFrontPageBannerStrings (
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);
StringSize = StrLen(NewString) * sizeof(CHAR16) + StrLen(L"System: ") * sizeof(CHAR16) + 2;
FinalString = AllocateZeroPool(StringSize);
if (FinalString) {
StrCatS(FinalString, StringSize, L"System: ");
StrCatS(FinalString, StringSize, NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), FinalString, NULL);
FreePool (FinalString);
} else {
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);
}
FreePool (NewString);
}

Expand All @@ -633,13 +625,29 @@ UpdateFrontPageBannerStrings (
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);
StringSize = StrLen(NewString) * sizeof(CHAR16) + StrLen(L"CPU: ") * sizeof(CHAR16) + 2;
FinalString = AllocateZeroPool(StringSize);
if (FinalString) {
StrCatS(FinalString, StringSize, L"CPU: ");
StrCatS(FinalString, StringSize, NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), FinalString, NULL);
FreePool (FinalString);
} else {
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);
StringSize = StrLen(NewString) * sizeof(CHAR16) + StrLen(L"CPU Speed: ") * sizeof(CHAR16) + 2;
FinalString = AllocateZeroPool(StringSize);
if (FinalString) {
StrCatS(FinalString, StringSize, L"CPU Speed: ");
StrCatS(FinalString, StringSize, NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), FinalString, NULL);
FreePool (FinalString);
} else {
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);
}
FreePool (NewString);

FoundCpu = TRUE;
Expand Down Expand Up @@ -671,7 +679,6 @@ UpdateFrontPageBannerStrings (
// Now update the total installed RAM size
//
ConvertMemoryInfoToString ((UINT32)InstalledMemory, MemorySpeed, &NewString);
UiCustomizeFrontPageBanner (3, FALSE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);
FreePool (NewString);
}
Expand Down
19 changes: 10 additions & 9 deletions MdeModulePkg/Application/UiApp/FrontPageCustomizedUi.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ UiCustomizeFrontPage (
//
UiCreateLanguageMenu (HiiHandle, StartOpCodeHandle);

//
// Create "System Date" menu with date opcode.
//
UiCreateDateMenu (HiiHandle, StartOpCodeHandle);

//
// Create "System Time" menu with time opcode.
//
UiCreateTimeMenu (HiiHandle, StartOpCodeHandle);

//
// Create empty line.
//
Expand Down Expand Up @@ -126,14 +136,5 @@ UiCustomizeFrontPageBanner (
IN OUT EFI_STRING *BannerStr
)
{
if ((LineIndex == 5) && LeftOrRight) {
// Update STR_CUSTOMIZE_BANNER_LINE5_LEFT
if (PcdGetBool(PcdTestKeyUsed)) {
if (BannerStr != NULL) {
FreePool(*BannerStr);
}
*BannerStr = HiiGetString(gFrontPagePrivate.HiiHandle, STRING_TOKEN(STR_TEST_KEY_USED), NULL);
}
}
return;
}
54 changes: 54 additions & 0 deletions MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define FRONT_PAGE_KEY_RESET 0x1001
#define FRONT_PAGE_KEY_LANGUAGE 0x1002
#define FRONT_PAGE_KEY_DRIVER 0x2000
#define FRONT_PAGE_KEY_DATE 0x8000
#define FRONT_PAGE_KEY_TIME 0x8001

typedef struct {
EFI_STRING_ID PromptId;
Expand Down Expand Up @@ -395,6 +397,58 @@ UiCreateLanguageMenu (
);
}

/**
Create date 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
UiCreateDateMenu (
IN EFI_HII_HANDLE HiiHandle,
IN VOID *StartOpCodeHandle
)
{
HiiCreateDateOpCode (
StartOpCodeHandle,
FRONT_PAGE_KEY_DATE,
0,
0,
STRING_TOKEN(STR_DATE_PROMPT),
STRING_TOKEN(STR_DATE_HELP),
0,
QF_DATE_STORAGE_TIME,
NULL
);
}

/**
Create time 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
UiCreateTimeMenu (
IN EFI_HII_HANDLE HiiHandle,
IN VOID *StartOpCodeHandle
)
{
HiiCreateTimeOpCode (
StartOpCodeHandle,
FRONT_PAGE_KEY_TIME,
0x0,
0x0,
STRING_TOKEN(STR_TIME_PROMPT),
STRING_TOKEN(STR_TIME_HELP),
0,
QF_TIME_STORAGE_TIME,
NULL
);
}

/**
Create continue menu in the front page.

Expand Down
28 changes: 28 additions & 0 deletions MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,34 @@ UiCreateLanguageMenu (
IN VOID *StartOpCodeHandle
);


/**
Create System Date menu in the front page with date opcode.

@param[in] HiiHandle The hii handle for the Uiapp driver.
@param[in] StartOpCodeHandle The opcode handle to save the new opcode.

**/
VOID
UiCreateDateMenu (
IN EFI_HII_HANDLE HiiHandle,
IN VOID *StartOpCodeHandle
);


/**
Create System Time menu in the front page with time opcode.

@param[in] HiiHandle The hii handle for the Uiapp driver.
@param[in] StartOpCodeHandle The opcode handle to save the new opcode.

**/
VOID
UiCreateTimeMenu (
IN EFI_HII_HANDLE HiiHandle,
IN VOID *StartOpCodeHandle
);

/**
Create Reset menu.

Expand Down
10 changes: 10 additions & 0 deletions MdeModulePkg/Application/UiApp/FrontPageStrings.uni
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#string STR_FRONT_PAGE_TITLE #language en-US "Front Page"
#language fr-FR "Front Page"
#string STR_FRONT_PAGE_BANNER_TITLE #language en-US "DASHARO SETUP"
#language fr-FR "DASHARO SETUP"
#string STR_FRONT_PAGE_COMPUTER_MODEL #language en-US ""
#language fr-FR ""
#string STR_FRONT_PAGE_CPU_MODEL #language en-US ""
Expand Down Expand Up @@ -46,6 +48,14 @@
#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 qu'on ajuste pour changer la langue pour le système actuel"
#string STR_DATE_PROMPT #language en-US "System Date"
#language fr-FR "Date du système"
#string STR_DATE_HELP #language en-US "This is the help for the Date (month/day/year)."
#language fr-FR "C'est l'aide pour la Date (mois/jour/année)."
#string STR_TIME_PROMPT #language en-US "System Time"
#language fr-FR "Le temps du système"
#string STR_TIME_HELP #language en-US "This is the help for the Time (hour/minute/second). Time is represented in local time zone."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help strings for time and date need an improvement ("This is the help" part for sure, "This is the option one adjusts" for "Select Language" always looked quite ridiculus).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, taken from SampleDriverDxe and didn't update it yet.

#language fr-FR "C'est l'aide pour l'heure (heure/minute/seconde). L'heure est représentée dans le fuseau horaire local."
#string STR_MISSING_STRING #language en-US "Missing String"
#language fr-FR "Missing String"
#string STR_EMPTY_STRING #language en-US ""
Expand Down
25 changes: 5 additions & 20 deletions MdeModulePkg/Application/UiApp/FrontPageVfr.Vfr
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ formset
form formid = FRONT_PAGE_FORM_ID,
title = STRING_TOKEN(STR_FRONT_PAGE_TITLE);

banner
title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_TITLE),
line 0,
align center;

banner
title = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL),
line 1,
Expand All @@ -48,26 +53,6 @@ formset
line 3,
align right;

banner
title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE4_LEFT),
line 4,
align left;

banner
title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE4_RIGHT),
line 4,
align right;

banner
title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE5_LEFT),
line 5,
align left;

banner
title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE5_RIGHT),
line 5,
align right;

label LABEL_FRANTPAGE_INFORMATION;
//
// This is where we will dynamically add a Action type op-code to show
Expand Down
Loading
Loading