summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal
diff options
context:
space:
mode:
authorxdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-10-26 03:03:12 +0000
committerxdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-10-26 03:03:12 +0000
commitd66e6c168749f686f3be04809923da74f153f340 (patch)
tree74b3325b78d8baf7f602b40f7672537026f03169 /MdeModulePkg/Universal
parent0ce94f384e29bee048477e4f2e5cebe46314cced (diff)
downloadedk2-platforms-d66e6c168749f686f3be04809923da74f153f340.tar.xz
Change the FormBrowser behavior of "Pressing ESC":
The old behavior is: if press ESC, it will exit the whole Formset. The new behavior is: if press ESC, it will return to the parent Form; if current Form is the root Form of a FormSet, it will exit the whole FormSet. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9359 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal')
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c76
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.c153
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.h23
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserStr.unibin12926 -> 12744 bytes
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Ui.c338
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Ui.h76
6 files changed, 427 insertions, 239 deletions
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
index 6425bea28c..364bc9d021 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
@@ -106,7 +106,7 @@ NewStrCat (
This function handles the Unicode string with NARROW_CHAR
and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
- does not count in the resultant output. If a WIDE_CHAR is
+ does not count in the resultant output. If a WIDE_CHAR is
hit, then 2 Unicode character will consume an output storage
space with size of CHAR16 till a NARROW_CHAR is hit.
@@ -236,7 +236,7 @@ DisplayPageFrame (
ASSERT (RowIdx < BANNER_HEIGHT);
ASSERT (ColumnIdx < BANNER_COLUMNS);
-
+
if (gBannerData->Banner[RowIdx][ColumnIdx] != 0x0000) {
StrFrontPageBanner = GetToken (
gBannerData->Banner[RowIdx][ColumnIdx],
@@ -406,7 +406,7 @@ EvaluateFormExpressions (
/*
+------------------------------------------------------------------------------+
-?F2=Previous Page Setup Page ?
+? Setup Page ?
+------------------------------------------------------------------------------+
@@ -433,9 +433,9 @@ EvaluateFormExpressions (
/**
-
+
Display form and wait for user to select one menu option, then return it.
-
+
@param Selection On input, Selection tell setup browser the information
about the Selection, form and formset to be displayed.
On output, Selection return the screen item that is selected
@@ -481,16 +481,6 @@ DisplayForm (
);
}
- if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
- gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_TEXT | KEYHELP_BACKGROUND);
-
- //
- // Display the infrastructure strings
- //
- if (!IsListEmpty (&gMenuList)) {
- PrintStringAt (LocalScreen.LeftColumn + 2, LocalScreen.TopRow + 1, gFunctionTwoString);
- }
- }
//
// Remove Buffer allocated for StringPtr after it has been used.
//
@@ -564,7 +554,6 @@ InitializeBrowserStrings (
)
{
gFunctionOneString = GetToken (STRING_TOKEN (FUNCTION_ONE_STRING), gHiiHandle);
- gFunctionTwoString = GetToken (STRING_TOKEN (FUNCTION_TWO_STRING), gHiiHandle);
gFunctionNineString = GetToken (STRING_TOKEN (FUNCTION_NINE_STRING), gHiiHandle);
gFunctionTenString = GetToken (STRING_TOKEN (FUNCTION_TEN_STRING), gHiiHandle);
gEnterString = GetToken (STRING_TOKEN (ENTER_STRING), gHiiHandle);
@@ -608,7 +597,6 @@ FreeBrowserStrings (
)
{
FreePool (gFunctionOneString);
- FreePool (gFunctionTwoString);
FreePool (gFunctionNineString);
FreePool (gFunctionTenString);
FreePool (gEnterString);
@@ -857,15 +845,11 @@ SetupBrowser (
EFI_HII_VALUE *HiiValue;
FORM_BROWSER_STATEMENT *Statement;
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
- EFI_INPUT_KEY Key;
- CHAR16 YesResponse;
- CHAR16 NoResponse;
+ FORM_BROWSER_FORMSET *FormSet;
gMenuRefreshHead = NULL;
gResetRequired = FALSE;
- gNvUpdateRequired = FALSE;
-
- UiInitMenuList ();
+ FormSet = Selection->FormSet;
//
// Register notify for Form package update
@@ -882,6 +866,15 @@ SetupBrowser (
return Status;
}
+ //
+ // Initialize current settings of Questions in this FormSet
+ //
+ Status = InitializeCurrentSetting (Selection->FormSet);
+ if (EFI_ERROR (Status)) {
+ Selection->Action = UI_ACTION_EXIT;
+ goto Done;
+ }
+
do {
//
// Displays the Header and Footer borders
@@ -913,7 +906,7 @@ SetupBrowser (
//
// Load Questions' Value for display
//
- Status = LoadFormConfig (Selection->FormSet, Selection->Form);
+ Status = LoadFormSetConfig (Selection->FormSet);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1000,37 +993,20 @@ SetupBrowser (
// Force to reparse IFR binary of target Formset
//
Selection->Action = UI_ACTION_REFRESH_FORMSET;
-
- //
- // Uncommitted data will be lost after IFR binary re-pasing, so confirm on whether to save
- //
- if (gNvUpdateRequired) {
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
-
- YesResponse = gYesResponse[0];
- NoResponse = gNoResponse[0];
-
- do {
- CreateDialog (3, TRUE, 0, NULL, &Key, gEmptyString, gSaveChanges, gEmptyString);
- } while
- (
- (Key.ScanCode != SCAN_ESC) &&
- ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (NoResponse | UPPER_LOWER_CASE_OFFSET)) &&
- ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (YesResponse | UPPER_LOWER_CASE_OFFSET))
- );
-
- if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (YesResponse | UPPER_LOWER_CASE_OFFSET)) {
- //
- // If the user hits the YesResponse key
- //
- SubmitForm (Selection->FormSet, Selection->Form);
- }
- }
}
}
} while (Selection->Action == UI_ACTION_REFRESH_FORM);
//
+ // Record the old formset
+ //
+ if (gOldFormSet != NULL) {
+ DestroyFormSet (gOldFormSet);
+ }
+ gOldFormSet = FormSet;
+
+Done:
+ //
// Unregister notify for Form package update
//
Status = mHiiDatabase->UnregisterPackageNotify (
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 4f2c92c818..a8393aa502 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -1,7 +1,7 @@
/** @file
Entry and initialization module for the browser.
-Copyright (c) 2007 - 2008, Intel Corporation
+Copyright (c) 2007 - 2009, 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
@@ -45,7 +45,6 @@ BOOLEAN gDownArrow;
// Browser Global Strings
//
CHAR16 *gFunctionOneString;
-CHAR16 *gFunctionTwoString;
CHAR16 *gFunctionNineString;
CHAR16 *gFunctionTenString;
CHAR16 *gEnterString;
@@ -87,6 +86,8 @@ EFI_GUID gSetupBrowserGuid = {
0xab368524, 0xb60c, 0x495b, {0xa0, 0x9, 0x12, 0xe8, 0x5b, 0x1a, 0xea, 0x32}
};
+FORM_BROWSER_FORMSET *gOldFormSet = NULL;
+
FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = {
//
// Boot Manager
@@ -190,7 +191,7 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = {
@param FormId This field specifies which EFI_IFR_FORM to render as the first
displayable page. If this field has a value of 0x0000, then
the forms browser will render the specified forms in their encoded order.
- @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
+ @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
characters.
@param ActionRequest Points to the action recommended by the form.
@@ -287,6 +288,8 @@ SendForm (
Selection->FormId = FormId;
}
+ gNvUpdateRequired = FALSE;
+
do {
FormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET));
ASSERT (FormSet != NULL);
@@ -302,15 +305,6 @@ SendForm (
Selection->FormSet = FormSet;
//
- // Initialize current settings of Questions in this FormSet
- //
- Status = InitializeCurrentSetting (FormSet);
- if (EFI_ERROR (Status)) {
- DestroyFormSet (FormSet);
- break;
- }
-
- //
// Display this formset
//
gCurrentSelection = Selection;
@@ -318,7 +312,6 @@ SendForm (
Status = SetupBrowser (Selection);
gCurrentSelection = NULL;
- DestroyFormSet (FormSet);
if (EFI_ERROR (Status)) {
break;
@@ -326,6 +319,11 @@ SendForm (
} while (Selection->Action == UI_ACTION_REFRESH_FORMSET);
+ if (gOldFormSet != NULL) {
+ DestroyFormSet (gOldFormSet);
+ gOldFormSet = NULL;
+ }
+
FreePool (Selection);
}
@@ -1128,7 +1126,7 @@ GetQuestionValue (
if (EFI_ERROR (Status)) {
return Status;
}
-
+
LengthStr = StrLen (Value);
Status = EFI_SUCCESS;
if (IsString) {
@@ -1529,7 +1527,7 @@ SetQuestionValue (
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
}
}
-
+
//
// Convert to lower char.
//
@@ -1893,7 +1891,7 @@ GetQuestionDefault (
//
// Take first oneof option as oneof's default value
//
- if (ValueToOption (Question, HiiValue) == NULL) {
+ if (ValueToOption (Question, HiiValue) == NULL) {
Link = GetFirstNode (&Question->OptionListHead);
if (!IsNull (&Question->OptionListHead, Link)) {
Option = QUESTION_OPTION_FROM_LINK (Link);
@@ -2027,6 +2025,42 @@ LoadFormConfig (
/**
+ Initialize Question's Edit copy from Storage for the whole Formset.
+
+ @param FormSet FormSet data structure.
+
+ @retval EFI_SUCCESS The function completed successfully.
+
+**/
+EFI_STATUS
+LoadFormSetConfig (
+ IN FORM_BROWSER_FORMSET *FormSet
+ )
+{
+ EFI_STATUS Status;
+ LIST_ENTRY *Link;
+ FORM_BROWSER_FORM *Form;
+
+ Link = GetFirstNode (&FormSet->FormListHead);
+ while (!IsNull (&FormSet->FormListHead, Link)) {
+ Form = FORM_BROWSER_FORM_FROM_LINK (Link);
+
+ //
+ // Initialize local copy of Value for each Form
+ //
+ Status = LoadFormConfig (FormSet, Form);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Link = GetNextNode (&FormSet->FormListHead, Link);
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+/**
Fill storage's edit copy with settings requested from Configuration Driver.
@param FormSet FormSet data structure.
@@ -2089,6 +2123,54 @@ LoadStorage (
/**
+ Copy uncommitted data from source Storage to destination Storage.
+
+ @param Dst Target Storage for uncommitted data.
+ @param Src Source Storage for uncommitted data.
+
+ @retval EFI_SUCCESS The function completed successfully.
+ @retval EFI_INVALID_PARAMETER Source and destination Storage is not the same type.
+
+**/
+EFI_STATUS
+CopyStorage (
+ IN OUT FORMSET_STORAGE *Dst,
+ IN FORMSET_STORAGE *Src
+ )
+{
+ LIST_ENTRY *Link;
+ NAME_VALUE_NODE *Node;
+
+ if ((Dst->Type != Src->Type) || (Dst->Size != Src->Size)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ switch (Src->Type) {
+ case EFI_HII_VARSTORE_BUFFER:
+ CopyMem (Dst->EditBuffer, Src->EditBuffer, Src->Size);
+ break;
+
+ case EFI_HII_VARSTORE_NAME_VALUE:
+ Link = GetFirstNode (&Src->NameValueListHead);
+ while (!IsNull (&Src->NameValueListHead, Link)) {
+ Node = NAME_VALUE_NODE_FROM_LINK (Link);
+
+ SetValueByName (Dst, Node->Name, Node->EditValue);
+
+ Link = GetNextNode (&Src->NameValueListHead, Link);
+ }
+ break;
+
+ case EFI_HII_VARSTORE_EFI_VARIABLE:
+ default:
+ break;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+/**
Get current setting of Questions.
@param FormSet FormSet data structure.
@@ -2102,7 +2184,10 @@ InitializeCurrentSetting (
)
{
LIST_ENTRY *Link;
+ LIST_ENTRY *Link2;
FORMSET_STORAGE *Storage;
+ FORMSET_STORAGE *StorageSrc;
+ FORMSET_STORAGE *OldStorage;
FORM_BROWSER_FORM *Form;
EFI_STATUS Status;
@@ -2125,7 +2210,35 @@ InitializeCurrentSetting (
while (!IsNull (&FormSet->StorageListHead, Link)) {
Storage = FORMSET_STORAGE_FROM_LINK (Link);
- Status = LoadStorage (FormSet, Storage);
+ OldStorage = NULL;
+ if (gOldFormSet != NULL) {
+ //
+ // Try to find the Storage in backup formset gOldFormSet
+ //
+ Link2 = GetFirstNode (&gOldFormSet->StorageListHead);
+ while (!IsNull (&gOldFormSet->StorageListHead, Link2)) {
+ StorageSrc = FORMSET_STORAGE_FROM_LINK (Link2);
+
+ if (StorageSrc->VarStoreId == Storage->VarStoreId) {
+ OldStorage = StorageSrc;
+ break;
+ }
+
+ Link2 = GetNextNode (&gOldFormSet->StorageListHead, Link2);
+ }
+ }
+
+ if (OldStorage == NULL) {
+ //
+ // Storage is not found in backup formset, request it from ConfigDriver
+ //
+ Status = LoadStorage (FormSet, Storage);
+ } else {
+ //
+ // Storage found in backup formset, use it
+ //
+ Status = CopyStorage (Storage, OldStorage);
+ }
//
// Now Edit Buffer is filled with default values(lower priority) and current
@@ -2211,7 +2324,7 @@ GetIfrBinaryData (
return Status;
}
ASSERT (HiiPackageList != NULL);
-
+
//
// Get Form package from this HII package List
//
@@ -2391,10 +2504,6 @@ InitializeFormSet (
gFunctionOneString = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle);
}
- if ((gFunctionKeySetting & FUNCTION_TWO) != FUNCTION_TWO) {
- gFunctionTwoString = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle);
- }
-
if ((gFunctionKeySetting & FUNCTION_NINE) != FUNCTION_NINE) {
gFunctionNineString = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle);
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
index 21b289126b..91b5aaee40 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
@@ -1,5 +1,5 @@
/** @file
-Private MACRO, structure and function definitions for Setup Browser module.
+Private MACRO, structure and function definitions for Setup Browser module.
Copyright (c) 2007 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials
@@ -71,10 +71,9 @@ extern UINT8 SetupBrowserStrings[];
// Definition for function key setting
//
#define NONE_FUNCTION_KEY_SETTING 0
-#define DEFAULT_FUNCTION_KEY_SETTING (FUNCTION_ONE | FUNCTION_TWO | FUNCTION_NINE | FUNCTION_TEN)
+#define DEFAULT_FUNCTION_KEY_SETTING (FUNCTION_ONE | FUNCTION_NINE | FUNCTION_TEN)
#define FUNCTION_ONE (1 << 0)
-#define FUNCTION_TWO (1 << 1)
#define FUNCTION_NINE (1 << 2)
#define FUNCTION_TEN (1 << 3)
@@ -461,11 +460,12 @@ extern EFI_SCREEN_DESCRIPTOR gScreenDimensions;
extern BOOLEAN gUpArrow;
extern BOOLEAN gDownArrow;
+extern FORM_BROWSER_FORMSET *gOldFormSet;
+
//
// Browser Global Strings
//
extern CHAR16 *gFunctionOneString;
-extern CHAR16 *gFunctionTwoString;
extern CHAR16 *gFunctionNineString;
extern CHAR16 *gFunctionTenString;
extern CHAR16 *gEnterString;
@@ -893,6 +893,19 @@ LoadFormConfig (
);
/**
+ Initialize Question's Edit copy from Storage for the whole Formset.
+
+ @param FormSet FormSet data structure.
+
+ @retval EFI_SUCCESS The function completed successfully.
+
+**/
+EFI_STATUS
+LoadFormSetConfig (
+ IN FORM_BROWSER_FORMSET *FormSet
+ );
+
+/**
Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
@param Storage The Storage to be conveted.
@@ -983,7 +996,7 @@ GetIfrBinaryData (
ScreenDimenions - This allows the browser to be called so that it occupies a
portion of the physical screen instead of dynamically determining the screen dimensions.
ActionRequest - Points to the action recommended by the form.
- @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
+ @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
characters.
@param ActionRequest Points to the action recommended by the form.
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserStr.uni b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserStr.uni
index e25368052b..8339e1fa6f 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserStr.uni
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserStr.uni
Binary files differ
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
index d744c90f19..66dc208bbe 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
@@ -1,7 +1,7 @@
/** @file
Utility functions for User Interface functions.
-Copyright (c) 2004 - 2008, Intel Corporation
+Copyright (c) 2004 - 2009, 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
@@ -16,7 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Setup.h"
LIST_ENTRY Menu;
-LIST_ENTRY gMenuList;
+LIST_ENTRY gMenuList = INITIALIZE_LIST_HEAD_VARIABLE (gMenuList);
MENU_REFRESH_ENTRY *gMenuRefreshHead;
//
@@ -44,10 +44,6 @@ SCAN_CODE_TO_SCREEN_OPERATION gScanCodeToOperation[] = {
UiReset,
},
{
- SCAN_F2,
- UiPrevious,
- },
- {
SCAN_LEFT,
UiLeft,
},
@@ -103,10 +99,6 @@ SCREEN_OPERATION_T0_CONTROL_FLAG gScreenOperationToControlFlag[] = {
CfUiSave,
},
{
- UiPrevious,
- CfUiPrevious,
- },
- {
UiPageUp,
CfUiPageUp,
},
@@ -127,8 +119,6 @@ BOOLEAN GetLineByWidthFinished = FALSE;
@param Size Number of bytes to set
@param Value Value of the set operation.
- @return Value.
-
**/
VOID
SetUnicodeMem (
@@ -160,113 +150,157 @@ UiInitMenu (
/**
- Initialize Menu option list.
+ Free Menu option linked list.
**/
VOID
-UiInitMenuList (
+UiFreeMenu (
VOID
)
{
- InitializeListHead (&gMenuList);
+ UI_MENU_OPTION *MenuOption;
+
+ while (!IsListEmpty (&Menu)) {
+ MenuOption = MENU_OPTION_FROM_LINK (Menu.ForwardLink);
+ RemoveEntryList (&MenuOption->Link);
+
+ //
+ // We allocated space for this description when we did a GetToken, free it here
+ //
+ if (MenuOption->Skip != 0) {
+ //
+ // For date/time, MenuOption->Description is shared by three Menu Options
+ // Data format : [01/02/2004] [11:22:33]
+ // Line number : 0 0 1 0 0 1
+ //
+ FreePool (MenuOption->Description);
+ }
+ FreePool (MenuOption);
+ }
}
/**
- Remove a Menu in list, and return FormId/QuestionId for previous Menu.
+ Create a menu with specified formset GUID and form ID, and add it as a child
+ of the given parent menu.
- @param Selection Menu selection.
+ @param Parent The parent of menu to be added.
+ @param FormSetGuid The Formset Guid of menu to be added.
+ @param FormId The Form ID of menu to be added.
+
+ @return A pointer to the newly added menu or NULL if memory is insufficient.
**/
-VOID
-UiRemoveMenuListEntry (
- OUT UI_MENU_SELECTION *Selection
+UI_MENU_LIST *
+UiAddMenuList (
+ IN OUT UI_MENU_LIST *Parent,
+ IN EFI_GUID *FormSetGuid,
+ IN UINT16 FormId
)
{
- UI_MENU_LIST *UiMenuList;
+ UI_MENU_LIST *MenuList;
- if (!IsListEmpty (&gMenuList)) {
- UiMenuList = CR (gMenuList.ForwardLink, UI_MENU_LIST, MenuLink, UI_MENU_LIST_SIGNATURE);
-
- Selection->FormId = UiMenuList->FormId;
- Selection->QuestionId = UiMenuList->QuestionId;
- RemoveEntryList (&UiMenuList->MenuLink);
- FreePool (UiMenuList);
+ MenuList = AllocateZeroPool (sizeof (UI_MENU_LIST));
+ if (MenuList == NULL) {
+ return NULL;
}
-}
+ MenuList->Signature = UI_MENU_LIST_SIGNATURE;
+ InitializeListHead (&MenuList->ChildListHead);
-/**
- Free Menu option linked list.
+ CopyMem (&MenuList->FormSetGuid, FormSetGuid, sizeof (EFI_GUID));
+ MenuList->FormId = FormId;
+ MenuList->Parent = Parent;
-**/
-VOID
-UiFreeMenuList (
- VOID
- )
-{
- UI_MENU_LIST *UiMenuList;
-
- while (!IsListEmpty (&gMenuList)) {
- UiMenuList = CR (gMenuList.ForwardLink, UI_MENU_LIST, MenuLink, UI_MENU_LIST_SIGNATURE);
- RemoveEntryList (&UiMenuList->MenuLink);
- FreePool (UiMenuList);
+ if (Parent == NULL) {
+ //
+ // If parent is not specified, it is the root Form of a Formset
+ //
+ InsertTailList (&gMenuList, &MenuList->Link);
+ } else {
+ InsertTailList (&Parent->ChildListHead, &MenuList->Link);
}
+
+ return MenuList;
}
/**
- Add one menu entry to the linked lst
+ Search Menu with given FormId in the parent menu and all its child menus.
- @param Selection Menu selection.
+ @param Parent The parent of menu to search.
+ @param FormId The Form ID of menu to search.
+
+ @return A pointer to menu found or NULL if not found.
**/
-VOID
-UiAddMenuListEntry (
- IN UI_MENU_SELECTION *Selection
+UI_MENU_LIST *
+UiFindChildMenuList (
+ IN UI_MENU_LIST *Parent,
+ IN UINT16 FormId
)
{
- UI_MENU_LIST *UiMenuList;
+ LIST_ENTRY *Link;
+ UI_MENU_LIST *Child;
+ UI_MENU_LIST *MenuList;
+
+ if (Parent->FormId == FormId) {
+ return Parent;
+ }
- UiMenuList = AllocateZeroPool (sizeof (UI_MENU_LIST));
- ASSERT (UiMenuList != NULL);
+ Link = GetFirstNode (&Parent->ChildListHead);
+ while (!IsNull (&Parent->ChildListHead, Link)) {
+ Child = UI_MENU_LIST_FROM_LINK (Link);
- UiMenuList->Signature = UI_MENU_LIST_SIGNATURE;
- UiMenuList->FormId = Selection->FormId;
- UiMenuList->QuestionId = Selection->QuestionId;
+ MenuList = UiFindChildMenuList (Child, FormId);
+ if (MenuList != NULL) {
+ return MenuList;
+ }
+
+ Link = GetNextNode (&Parent->ChildListHead, Link);
+ }
- InsertHeadList (&gMenuList, &UiMenuList->MenuLink);
+ return NULL;
}
/**
- Free Menu option linked list.
+ Search Menu with given FormSetGuid and FormId in all cached menu list.
+
+ @param FormSetGuid The Formset GUID of the menu to search.
+ @param FormId The Form ID of menu to search.
+
+ @return A pointer to menu found or NULL if not found.
**/
-VOID
-UiFreeMenu (
- VOID
+UI_MENU_LIST *
+UiFindMenuList (
+ IN EFI_GUID *FormSetGuid,
+ IN UINT16 FormId
)
{
- UI_MENU_OPTION *MenuOption;
+ LIST_ENTRY *Link;
+ UI_MENU_LIST *MenuList;
+ UI_MENU_LIST *Child;
- while (!IsListEmpty (&Menu)) {
- MenuOption = MENU_OPTION_FROM_LINK (Menu.ForwardLink);
- RemoveEntryList (&MenuOption->Link);
+ Link = GetFirstNode (&gMenuList);
+ while (!IsNull (&gMenuList, Link)) {
+ MenuList = UI_MENU_LIST_FROM_LINK (Link);
- //
- // We allocated space for this description when we did a GetToken, free it here
- //
- if (MenuOption->Skip != 0) {
+ if (CompareGuid (FormSetGuid, &MenuList->FormSetGuid)) {
//
- // For date/time, MenuOption->Description is shared by three Menu Options
- // Data format : [01/02/2004] [11:22:33]
- // Line number : 0 0 1 0 0 1
+ // This is the formset we are looking for, find the form in this formset
//
- FreePool (MenuOption->Description);
+ Child = UiFindChildMenuList (MenuList, FormId);
+ if (Child != NULL) {
+ return Child;
+ }
}
- FreePool (MenuOption);
+
+ Link = GetNextNode (&gMenuList, Link);
}
+
+ return NULL;
}
@@ -929,7 +963,7 @@ CreateMultiStringPopUp (
VA_LIST Marker;
VA_START (Marker, NumberOfLines);
-
+
CreateSharedPopUp (RequestedWidth, NumberOfLines, Marker);
VA_END (Marker);
@@ -1275,7 +1309,7 @@ IsSelectable (
Determine if the menu is the last menu that can be selected.
This is an internal function.
-
+
@param Direction The scroll direction. False is down. True is up.
@param CurrentPos The current focus.
@@ -1311,9 +1345,9 @@ ValueIsScroll (
/**
Move to next selectable statement.
-
+
This is an internal function.
-
+
@param GoUp The navigation direction. TRUE: up, FALSE: down.
@param CurrentPosition Current position.
@@ -1379,7 +1413,7 @@ MoveToNextStatement (
Adjust Data and Time position accordingly.
Data format : [01/02/2004] [11:22:33]
Line number : 0 0 1 0 0 1
-
+
This is an internal function.
@param DirectionUp the up or down direction. False is down. True is
@@ -1606,6 +1640,8 @@ UiDisplayMenu (
CHAR16 TemStr[2];
UINT8 *DevicePathBuffer;
UINT8 DigitUint8;
+ UI_MENU_LIST *CurrentMenu;
+ UI_MENU_LIST *MenuList;
CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
@@ -1652,6 +1688,25 @@ UiDisplayMenu (
MenuOption = NULL;
//
+ // Find current Menu
+ //
+ CurrentMenu = UiFindMenuList (&Selection->FormSetGuid, Selection->FormId);
+ if (CurrentMenu == NULL) {
+ //
+ // Current menu not found, add it to the menu tree
+ //
+ CurrentMenu = UiAddMenuList (NULL, &Selection->FormSetGuid, Selection->FormId);
+ }
+ ASSERT (CurrentMenu != NULL);
+
+ if (Selection->QuestionId == 0) {
+ //
+ // Highlight not specified, fetch it from cached menu
+ //
+ Selection->QuestionId = CurrentMenu->QuestionId;
+ }
+
+ //
// Get user's selection
//
NewPos = Menu.ForwardLink;
@@ -2103,6 +2158,10 @@ UiDisplayMenu (
//
Statement = MenuOption->ThisTag;
Selection->Statement = Statement;
+ //
+ // Record highlight for current menu
+ //
+ CurrentMenu->QuestionId = Statement->QuestionId;
//
// Set reverse attribute
@@ -2258,27 +2317,19 @@ UiDisplayMenu (
//
// IFR is updated in Callback of refresh opcode, re-parse it
//
- ControlFlag = CfUiReset;
Selection->Statement = NULL;
- break;
+ return EFI_SUCCESS;
}
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
//
- // if we encounter error, continue to read another key in.
+ // If we encounter error, continue to read another key in.
//
if (EFI_ERROR (Status)) {
ControlFlag = CfReadKey;
break;
}
- if (IsListEmpty (&Menu) && Key.UnicodeChar != CHAR_NULL) {
- //
- // If the screen has no menu items, and the user didn't select UiPrevious, or UiReset
- //
- break;
- }
-
switch (Key.UnicodeChar) {
case CHAR_CARRIAGE_RETURN:
ScreenOperation = UiSelect;
@@ -2334,7 +2385,6 @@ UiDisplayMenu (
case CHAR_NULL:
if (((Key.ScanCode == SCAN_F1) && ((gFunctionKeySetting & FUNCTION_ONE) != FUNCTION_ONE)) ||
- ((Key.ScanCode == SCAN_F2) && ((gFunctionKeySetting & FUNCTION_TWO) != FUNCTION_TWO)) ||
((Key.ScanCode == SCAN_F9) && ((gFunctionKeySetting & FUNCTION_NINE) != FUNCTION_NINE)) ||
((Key.ScanCode == SCAN_F10) && ((gFunctionKeySetting & FUNCTION_TEN) != FUNCTION_TEN))
) {
@@ -2360,9 +2410,9 @@ UiDisplayMenu (
break;
case CfScreenOperation:
- if (ScreenOperation != UiPrevious && ScreenOperation != UiReset) {
+ if (ScreenOperation != UiReset) {
//
- // If the screen has no menu items, and the user didn't select UiPrevious, or UiReset
+ // If the screen has no menu items, and the user didn't select UiReset
// ignore the selection and go back to reading keys.
//
if (IsListEmpty (&Menu)) {
@@ -2383,12 +2433,6 @@ UiDisplayMenu (
ControlFlag = CfPrepareToReadKey;
break;
}
- } else if (ScreenOperation == UiReset) {
- //
- // Press ESC to exit FormSet
- //
- Selection->Action = UI_ACTION_EXIT;
- Selection->Statement = NULL;
}
for (Index = 0;
@@ -2402,26 +2446,6 @@ UiDisplayMenu (
}
break;
- case CfUiPrevious:
- ControlFlag = CfCheckSelection;
-
- if (IsListEmpty (&gMenuList)) {
- Selection->Action = UI_ACTION_NONE;
- if (IsListEmpty (&Menu)) {
- ControlFlag = CfReadKey;
- }
- break;
- }
-
- //
- // Remove the Cached page entry
- //
- UiRemoveMenuListEntry (Selection);
-
- Selection->Action = UI_ACTION_REFRESH_FORM;
- Selection->Statement = NULL;
- break;
-
case CfUiSelect:
ControlFlag = CfCheckSelection;
@@ -2444,7 +2468,7 @@ UiDisplayMenu (
//
// Goto another Hii Package list
//
- ControlFlag = CfUiReset;
+ ControlFlag = CfCheckSelection;
Selection->Action = UI_ACTION_REFRESH_FORMSET;
StringPtr = GetToken (Statement->RefDevicePath, Selection->FormSet->HiiHandle);
@@ -2458,7 +2482,7 @@ UiDisplayMenu (
}
BufferSize = StrLen (StringPtr) / 2;
DevicePath = AllocatePool (BufferSize);
-
+
//
// Convert from Device Path String to DevicePath Buffer in the reverse order.
//
@@ -2499,7 +2523,7 @@ UiDisplayMenu (
//
// Goto another Formset, check for uncommitted data
//
- ControlFlag = CfUiReset;
+ ControlFlag = CfCheckSelection;
Selection->Action = UI_ACTION_REFRESH_FORMSET;
CopyMem (&Selection->FormSetGuid, &Statement->RefFormSetId, sizeof (EFI_GUID));
@@ -2512,9 +2536,12 @@ UiDisplayMenu (
Selection->Action = UI_ACTION_REFRESH_FORM;
//
- // Link current form so that we can always go back when someone hits the UiPrevious
+ // Link current form so that we can always go back when someone hits the ESC
//
- UiAddMenuListEntry (Selection);
+ MenuList = UiFindMenuList (&Selection->FormSetGuid, Statement->RefFormId);
+ if (MenuList == NULL) {
+ MenuList = UiAddMenuList (CurrentMenu, &Selection->FormSetGuid, Statement->RefFormId);
+ }
Selection->FormId = Statement->RefFormId;
Selection->QuestionId = Statement->RefQuestionId;
@@ -2582,21 +2609,44 @@ UiDisplayMenu (
case CfUiReset:
//
- // We are going to leave current FormSet, so check uncommited data in this FormSet
+ // We come here when someone press ESC
//
ControlFlag = CfCheckSelection;
+ if (CurrentMenu->Parent != NULL) {
+ //
+ // we have a parent, so go to the parent menu
+ //
+ if (CompareGuid (&CurrentMenu->FormSetGuid, &CurrentMenu->Parent->FormSetGuid)) {
+ //
+ // The parent menu and current menu are in the same formset
+ //
+ Selection->Action = UI_ACTION_REFRESH_FORM;
+ } else {
+ Selection->Action = UI_ACTION_REFRESH_FORMSET;
+ }
+ Selection->Statement = NULL;
+
+ Selection->FormId = CurrentMenu->Parent->FormId;
+ Selection->QuestionId = CurrentMenu->Parent->QuestionId;
+
+ //
+ // Clear highlight record for this menu
+ //
+ CurrentMenu->QuestionId = 0;
+ break;
+ }
+
if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) {
//
- // There is no parent menu for FrontPage
+ // We never exit FrontPage, so skip the ESC
//
Selection->Action = UI_ACTION_NONE;
- Selection->Statement = MenuOption->ThisTag;
break;
}
//
- // If NV flag is up, prompt user
+ // We are going to leave current FormSet, so check uncommited data in this FormSet
//
if (gNvUpdateRequired) {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
@@ -2604,8 +2654,11 @@ UiDisplayMenu (
YesResponse = gYesResponse[0];
NoResponse = gNoResponse[0];
+ //
+ // If NV flag is up, prompt user
+ //
do {
- CreateDialog (3, TRUE, 0, NULL, &Key, gEmptyString, gAreYouSure, gEmptyString);
+ CreateDialog (4, TRUE, 0, NULL, &Key, gEmptyString, gSaveChanges, gAreYouSure, gEmptyString);
} while
(
(Key.ScanCode != SCAN_ESC) &&
@@ -2613,24 +2666,29 @@ UiDisplayMenu (
((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (YesResponse | UPPER_LOWER_CASE_OFFSET))
);
- //
- // If the user hits the YesResponse key
- //
- if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (YesResponse | UPPER_LOWER_CASE_OFFSET)) {
- } else {
+ if (Key.ScanCode == SCAN_ESC) {
+ //
+ // User hits the ESC key
+ //
Repaint = TRUE;
NewLine = TRUE;
Selection->Action = UI_ACTION_NONE;
break;
}
+
+ //
+ // If the user hits the YesResponse key
+ //
+ if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (YesResponse | UPPER_LOWER_CASE_OFFSET)) {
+ Status = SubmitForm (Selection->FormSet, Selection->Form);
+ }
}
- gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
+ Selection->Action = UI_ACTION_EXIT;
+ Selection->Statement = NULL;
+ CurrentMenu->QuestionId = 0;
- UiFreeMenuList ();
- gST->ConOut->ClearScreen (gST->ConOut);
return EFI_SUCCESS;
case CfUiLeft:
@@ -2696,19 +2754,19 @@ UiDisplayMenu (
TopOfScreen = NewPos;
}
- Difference = MoveToNextStatement (TRUE, &NewPos);
+ Difference = MoveToNextStatement (TRUE, &NewPos);
PreviousMenuOption = MENU_OPTION_FROM_LINK (NewPos);
DistanceValue += PreviousMenuOption->Skip;
-
- if ((INTN) MenuOption->Row - (INTN) DistanceValue < (INTN) TopRow) {
+
+ if ((INTN) MenuOption->Row - (INTN) DistanceValue < (INTN) TopRow) {
if (Difference > 0) {
//
// Previous focus MenuOption is above the TopOfScreen, so we need to scroll
//
TopOfScreen = NewPos;
Repaint = TRUE;
- SkipValue = 0;
- OldSkipValue = 0;
+ SkipValue = 0;
+ OldSkipValue = 0;
}
}
if (Difference < 0) {
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h
index 2c144486dd..f7d4ad1d7f 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h
@@ -1,7 +1,7 @@
/** @file
Private structure, MACRO and function definitions for User Interface related functionalities.
-Copyright (c) 2004 - 2008, Intel Corporation
+Copyright (c) 2004 - 2009, 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
@@ -58,7 +58,6 @@ typedef enum {
CfPrepareToReadKey,
CfReadKey,
CfScreenOperation,
- CfUiPrevious,
CfUiSelect,
CfUiReset,
CfUiLeft,
@@ -145,13 +144,21 @@ typedef struct {
#define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
-typedef struct {
+typedef struct _UI_MENU_LIST UI_MENU_LIST;
+
+struct _UI_MENU_LIST {
UINTN Signature;
- LIST_ENTRY MenuLink;
+ LIST_ENTRY Link;
+ EFI_GUID FormSetGuid;
UINT16 FormId;
UINT16 QuestionId;
-} UI_MENU_LIST;
+
+ UI_MENU_LIST *Parent;
+ LIST_ENTRY ChildListHead;
+};
+
+#define UI_MENU_LIST_FROM_LINK(a) CR (a, UI_MENU_LIST, Link, UI_MENU_LIST_SIGNATURE)
typedef struct _MENU_REFRESH_ENTRY {
struct _MENU_REFRESH_ENTRY *Next;
@@ -173,7 +180,6 @@ typedef struct {
} SCREEN_OPERATION_T0_CONTROL_FLAG;
-extern LIST_ENTRY gMenuList;
extern MENU_REFRESH_ENTRY *gMenuRefreshHead;
extern UI_MENU_SELECTION *gCurrentSelection;
extern BOOLEAN mHiiPackageListUpdated;
@@ -200,34 +206,60 @@ UiInitMenuList (
);
/**
- Remove a Menu in list, and return FormId/QuestionId for previous Menu.
-
- @param Selection Menu selection.
+ Free Menu option linked list.
**/
VOID
-UiRemoveMenuListEntry (
- OUT UI_MENU_SELECTION *Selection
+UiFreeMenu (
+ VOID
);
/**
- Free Menu option linked list.
+ Create a menu with specified formset GUID and form ID, and add it as a child
+ of the given parent menu.
+
+ @param Parent The parent of menu to be added.
+ @param FormSetGuid The Formset Guid of menu to be added.
+ @param FormId The Form ID of menu to be added.
+
+ @return A pointer to the newly added menu or NULL if memory is insufficient.
**/
-VOID
-UiFreeMenuList (
- VOID
+UI_MENU_LIST *
+UiAddMenuList (
+ IN OUT UI_MENU_LIST *Parent,
+ IN EFI_GUID *FormSetGuid,
+ IN UINT16 FormId
);
/**
- Add one menu entry to the linked lst
+ Search Menu with given FormId in the parent menu and all its child menus.
- @param Selection Menu selection.
+ @param Parent The parent of menu to search.
+ @param FormId The Form ID of menu to search.
+
+ @return A pointer to menu found or NULL if not found.
**/
-VOID
-UiAddMenuListEntry (
- IN UI_MENU_SELECTION *Selection
+UI_MENU_LIST *
+UiFindChildMenuList (
+ IN UI_MENU_LIST *Parent,
+ IN UINT16 FormId
+ );
+
+/**
+ Search Menu with given FormSetGuid and FormId in all cached menu list.
+
+ @param FormSetGuid The Formset GUID of the menu to search.
+ @param FormId The Form ID of menu to search.
+
+ @return A pointer to menu found or NULL if not found.
+
+**/
+UI_MENU_LIST *
+UiFindMenuList (
+ IN EFI_GUID *FormSetGuid,
+ IN UINT16 FormId
);
/**
@@ -235,7 +267,7 @@ UiAddMenuListEntry (
**/
VOID
-UiFreeMenu (
+UiFreeRefreshList (
VOID
);
@@ -557,7 +589,7 @@ ClearLines (
This function handles the Unicode string with NARROW_CHAR
and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
- does not count in the resultant output. If a WIDE_CHAR is
+ does not count in the resultant output. If a WIDE_CHAR is
hit, then 2 Unicode character will consume an output storage
space with size of CHAR16 till a NARROW_CHAR is hit.