Skip to content
Merged
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
73 changes: 73 additions & 0 deletions Application/ModernSetupApp/ModernSetupApp.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ UefiMain (
CHAR16 StatusMessage[96];
BOOLEAN Redraw;
BOOLEAN ResetConfirmationPending;
SETUP_PAGE OldPage;
SETUP_FOCUS OldFocus;
UINTN OldDashboardSelection;
UINTN OldBootSelection;
UINTN OldDeviceSelection;
UINTN OldPreferencesSelection;
UINTN OldExitSelection;
BOOLEAN OldLanguageDropdownOpen;
UINTN OldLanguageDropdownSelection;
BOOLEAN OldPreferencePopupOpen;
UINTN OldPreferencePopupRow;
UINTN OldPreferencePopupSelection;
MODERN_SETUP_PREFERENCE_POPUP_KIND OldPreferencePopupKind;
UINTN OldPreferenceInputLength;
BOOLEAN OldResetConfirmationPending;
MODERN_UI_PREFERENCES OldPreferences;
CHAR16 OldStatusMessage[96];

gBS->SetWatchdogTimer (0, 0, 0, NULL);
mModernSetupImageHandle = ImageHandle;
Expand Down Expand Up @@ -88,10 +105,35 @@ UefiMain (
continue;
}

OldPage = Page;
OldFocus = Focus;
OldDashboardSelection = DashboardSelection;
OldBootSelection = BootSelection;
OldDeviceSelection = DeviceSelection;
OldPreferencesSelection = PreferencesSelection;
OldExitSelection = ExitSelection;
OldLanguageDropdownOpen = mModernSetupLanguageDropdownOpen;
OldLanguageDropdownSelection = mModernSetupLanguageDropdownSelection;
OldPreferencePopupOpen = mModernSetupPreferencePopupOpen;
OldPreferencePopupRow = mModernSetupPreferencePopupRow;
OldPreferencePopupSelection = mModernSetupPreferencePopupSelection;
OldPreferencePopupKind = mModernSetupPreferencePopupKind;
OldPreferenceInputLength = mModernSetupPreferenceInputLength;
OldResetConfirmationPending = ResetConfirmationPending;
CopyMem (&OldPreferences, &mModernSetupPreferences, sizeof (OldPreferences));
CopyMem (OldStatusMessage, StatusMessage, sizeof (OldStatusMessage));

if ((Focus == SetupFocusContent) && (Page == PagePreferences) && mModernSetupPreferencePopupOpen && (Event.Type == ModernUiInputOther)) {
ModernSetupHandlePreferenceInputKey (&Event, StatusMessage, sizeof (StatusMessage));
ResetConfirmationPending = FALSE;
Redraw = TRUE;
if ((OldPreferenceInputLength == mModernSetupPreferenceInputLength) &&
(StrCmp (OldStatusMessage, StatusMessage) == 0) &&
(CompareMem (&OldPreferences, &mModernSetupPreferences, sizeof (OldPreferences)) == 0))
{
Redraw = FALSE;
}

continue;
}

Expand Down Expand Up @@ -277,5 +319,36 @@ UefiMain (
default:
break;
}

if (((OldPage == PageBoot) && (Page != PageBoot)) ||
((Event.Type == ModernUiInputEnter) &&
((OldPage == PageBoot) ||
(OldPage == PageDevices) ||
((OldPage == PageExit) && (OldExitSelection == 1)))))
{
ModernSetupInvalidateBootOptionsCache ();
}

if (Redraw && (Event.Type != ModernUiInputEnter) &&
(OldPage == Page) &&
(OldFocus == Focus) &&
(OldDashboardSelection == DashboardSelection) &&
(OldBootSelection == BootSelection) &&
(OldDeviceSelection == DeviceSelection) &&
(OldPreferencesSelection == PreferencesSelection) &&
(OldExitSelection == ExitSelection) &&
(OldLanguageDropdownOpen == mModernSetupLanguageDropdownOpen) &&
(OldLanguageDropdownSelection == mModernSetupLanguageDropdownSelection) &&
(OldPreferencePopupOpen == mModernSetupPreferencePopupOpen) &&
(OldPreferencePopupRow == mModernSetupPreferencePopupRow) &&
(OldPreferencePopupSelection == mModernSetupPreferencePopupSelection) &&
(OldPreferencePopupKind == mModernSetupPreferencePopupKind) &&
(OldPreferenceInputLength == mModernSetupPreferenceInputLength) &&
(OldResetConfirmationPending == ResetConfirmationPending) &&
(StrCmp (OldStatusMessage, StatusMessage) == 0) &&
(CompareMem (&OldPreferences, &mModernSetupPreferences, sizeof (OldPreferences)) == 0))
{
Redraw = FALSE;
}
}
}
78 changes: 65 additions & 13 deletions Application/ModernSetupApp/ModernSetupAppActions.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ STATIC CONST EFI_GUID mNativeFallbackAppGuid = { 0xEEC25BDC, 0x67F2, 0x4D95, {
STATIC CONST EFI_GUID mNativeFallbackAppGuid = { 0x462CAA21, 0x7614, 0x4503, { 0x83, 0x6E, 0x8A, 0xB6, 0xF4, 0x66, 0x23, 0x31 } };
#endif

STATIC MODERN_UI_BOOT_OPTION *mModernSetupBootOptionsCache;
STATIC UINTN mModernSetupBootOptionCountCache;
STATIC BOOLEAN mModernSetupBootOptionsCacheValid;

STATIC CONST MODERN_SETUP_DASHBOARD_ROUTE mDashboardCategoryRoutes[DASHBOARD_QUICK_CARD_COUNT] = {
{ PageBoot, SetupFocusContent },
{ PageDevices, SetupFocusContent },
Expand Down Expand Up @@ -283,8 +287,58 @@ ModernSetupSetPageSelection (
}


EFI_STATUS
ModernSetupGetCachedBootOptions (
OUT CONST MODERN_UI_BOOT_OPTION **Options,
OUT UINTN *OptionCount
)
{
EFI_STATUS Status;

if ((Options == NULL) || (OptionCount == NULL)) {
return EFI_INVALID_PARAMETER;
}

if (!mModernSetupBootOptionsCacheValid) {
ModernSetupInvalidateBootOptionsCache ();
Status = ModernUiBootDataGetOptions (
mModernSetupImageHandle,
&mModernSetupBootOptionsCache,
&mModernSetupBootOptionCountCache
);
if (EFI_ERROR (Status)) {
mModernSetupBootOptionsCache = NULL;
mModernSetupBootOptionCountCache = 0;
return Status;
}

mModernSetupBootOptionsCacheValid = TRUE;
}

*Options = mModernSetupBootOptionsCache;
*OptionCount = mModernSetupBootOptionCountCache;
return EFI_SUCCESS;
}

VOID
ModernSetupInvalidateBootOptionsCache (
VOID
)
{
if (mModernSetupBootOptionsCache != NULL) {
ModernUiBootDataFreeOptions (
mModernSetupBootOptionsCache,
mModernSetupBootOptionCountCache
);
}

mModernSetupBootOptionsCache = NULL;
mModernSetupBootOptionCountCache = 0;
mModernSetupBootOptionsCacheValid = FALSE;
}

/**
Count visible boot options from UefiBootManagerLib.
Count visible boot options from the cached Boot#### snapshot.

@return Number of visible Boot#### entries, or 0 when none are available.
**/
Expand All @@ -293,17 +347,16 @@ ModernSetupGetBootCount (
VOID
)
{
EFI_STATUS Status;
MODERN_UI_BOOT_OPTION *Options;
UINTN OptionCount;
EFI_STATUS Status;
CONST MODERN_UI_BOOT_OPTION *Options;
UINTN OptionCount;

Options = NULL;
Status = ModernUiBootDataGetOptions (mModernSetupImageHandle, &Options, &OptionCount);
Status = ModernSetupGetCachedBootOptions (&Options, &OptionCount);
if (EFI_ERROR (Status)) {
return 0;
}

ModernUiBootDataFreeOptions (Options, OptionCount);
return OptionCount;
}

Expand Down Expand Up @@ -395,24 +448,23 @@ ModernSetupLaunchSelectedBootOption (
IN UINTN Selection
)
{
EFI_STATUS Status;
MODERN_UI_BOOT_OPTION *Options;
UINTN OptionCount;
UINT16 OptionNumber;
EFI_STATUS Status;
CONST MODERN_UI_BOOT_OPTION *Options;
UINTN OptionCount;
UINT16 OptionNumber;

Options = NULL;
Status = ModernUiBootDataGetOptions (mModernSetupImageHandle, &Options, &OptionCount);
Status = ModernSetupGetCachedBootOptions (&Options, &OptionCount);
if (EFI_ERROR (Status)) {
return Status;
}

if ((Options == NULL) || (Selection >= OptionCount)) {
ModernUiBootDataFreeOptions (Options, OptionCount);
return EFI_NOT_FOUND;
}

OptionNumber = Options[Selection].OptionNumber;
ModernUiBootDataFreeOptions (Options, OptionCount);
ModernSetupInvalidateBootOptionsCache ();

return ModernUiBootDataBootOption (OptionNumber);
}
Expand Down
11 changes: 11 additions & 0 deletions Application/ModernSetupApp/ModernSetupAppInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,17 @@ ModernSetupGetDashboardCategoryRoute (
OUT MODERN_SETUP_DASHBOARD_ROUTE *Route
);

EFI_STATUS
ModernSetupGetCachedBootOptions (
OUT CONST MODERN_UI_BOOT_OPTION **Options,
OUT UINTN *OptionCount
);

VOID
ModernSetupInvalidateBootOptionsCache (
VOID
);

EFI_STATUS
ModernSetupLaunchSelectedBootOption (
IN UINTN Selection
Expand Down
6 changes: 2 additions & 4 deletions Application/ModernSetupApp/ModernSetupAppPages.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ DrawBoot (
)
{
EFI_STATUS Status;
MODERN_UI_BOOT_OPTION *BootOptions;
CONST MODERN_UI_BOOT_OPTION *BootOptions;
UINTN BootOptionCount;
UINTN Index;
UINTN Y;
Expand All @@ -274,7 +274,7 @@ DrawBoot (
ModernUiDrawText (Ui, Panel.X + 20, Panel.Y + 20, ModernUiGetString (ModernUiStringBootInstruction), Theme->MutedText, Theme->Surface);

BootOptions = NULL;
Status = ModernUiBootDataGetOptions (mModernSetupImageHandle, &BootOptions, &BootOptionCount);
Status = ModernSetupGetCachedBootOptions (&BootOptions, &BootOptionCount);
if (EFI_ERROR (Status) || (BootOptions == NULL)) {
ModernUiDrawText (Ui, Panel.X + 20, Panel.Y + 66, ModernUiGetString (ModernUiStringNoBootOptions), Theme->Warning, Theme->Surface);
return;
Expand Down Expand Up @@ -322,8 +322,6 @@ DrawBoot (
if (BootOptionCount == 0) {
ModernUiDrawText (Ui, Panel.X + 20, Panel.Y + 66, ModernUiGetString (ModernUiStringNoBootOptions), Theme->Warning, Theme->Surface);
}

ModernUiBootDataFreeOptions (BootOptions, BootOptionCount);
}

STATIC
Expand Down
Loading