From f67c4382ed24928b181160ed32119ac1039ddeb7 Mon Sep 17 00:00:00 2001 From: ydong10 Date: Wed, 16 Nov 2011 05:23:38 +0000 Subject: [PATCH] Enable lock attribute for statement and form; show this attribute same as grayout. Signed-off-by: ydong10 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12721 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/DriverSampleDxe/Vfr.vfr | 1 + .../Universal/SetupBrowserDxe/IfrParse.c | 22 +++++++++++++++++++ .../Universal/SetupBrowserDxe/Presentation.c | 2 +- .../Universal/SetupBrowserDxe/Setup.h | 3 ++- MdeModulePkg/Universal/SetupBrowserDxe/Ui.c | 9 ++++++++ MdeModulePkg/Universal/SetupBrowserDxe/Ui.h | 2 ++ 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr index e3710acd1b..f5e3193c29 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -358,6 +358,7 @@ formset minimum = 0, maximum = 0xff, step = 0, + locked, endnumeric; numeric varid = MyNameValueVar[1], // This numeric take NameValueVar1 as storage diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index 50ae87d92e..87924792a7 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -2117,6 +2117,28 @@ ParseOpCodes ( CurrentForm->ModalForm = TRUE; break; + // + // Lock tag, used by form and statement. + // + case EFI_IFR_LOCKED_OP: + // + // Get ScopeOpcode from top of stack + // + PopScope (&ScopeOpCode); + PushScope (ScopeOpCode); + switch (ScopeOpCode) { + case EFI_IFR_FORM_OP: + case EFI_IFR_FORM_MAP_OP: + ASSERT (CurrentForm != NULL); + CurrentForm->Locked = TRUE; + break; + + default: + ASSERT (CurrentStatement != NULL); + CurrentStatement->Locked = TRUE; + } + break; + // // Vendor specific // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index 80e3a71edd..a6be2bbcee 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -554,7 +554,7 @@ DisplayForm ( // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do // it in UiFreeMenu. // - MenuOption = UiAddMenuOption (StringPtr, Selection->Handle, Statement, NumberOfLines, MenuItemCount); + MenuOption = UiAddMenuOption (StringPtr, Selection->Handle, Selection->Form, Statement, NumberOfLines, MenuItemCount); MenuItemCount++; if (MenuOption->IsQuestion && !MenuOption->ReadOnly) { diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h index 8f71e7cc38..eaf409b8e6 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -374,7 +374,7 @@ typedef struct { EFI_DEFAULT_ID DefaultId; // for EFI_IFR_RESET_BUTTON EFI_GUID RefreshGuid; // for EFI_IFR_REFRESH_ID - + BOOLEAN Locked; // Whether this statement is locked. // // Get from IFR parsing // @@ -425,6 +425,7 @@ typedef struct { EFI_IMAGE_ID ImageId; BOOLEAN ModalForm; // Whether this is a modal form. + BOOLEAN Locked; // Whether this form is locked. BOOLEAN NvUpdateRequired; // Whether this form has NV update request. diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c index baf36a213b..93399c4028 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c @@ -577,6 +577,7 @@ UiWaitForSingleEvent ( @param String String description for this option. @param Handle Hii handle for the package list. + @param Form The form this statement belong to. @param Statement Statement of this Menu Option. @param NumberOfLines Display lines for this Menu Option. @param MenuItemCount The index for this Option in the Menu. @@ -588,6 +589,7 @@ UI_MENU_OPTION * UiAddMenuOption ( IN CHAR16 *String, IN EFI_HII_HANDLE Handle, + IN FORM_BROWSER_FORM *Form, IN FORM_BROWSER_STATEMENT *Statement, IN UINT16 NumberOfLines, IN UINT16 MenuItemCount @@ -643,6 +645,13 @@ UiAddMenuOption ( MenuOption->GrayOut = Statement->GrayOutExpression->Result.Value.b; } + // + // If the form or the question has the lock attribute, deal same as grayout. + // + if (Form->Locked || Statement->Locked) { + MenuOption->GrayOut = TRUE; + } + switch (Statement->Operand) { case EFI_IFR_ORDERED_LIST_OP: case EFI_IFR_ONE_OF_OP: diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h index f8797725e9..92783182f9 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h @@ -295,6 +295,7 @@ UiFreeRefreshList ( @param String String description for this option. @param Handle Hii handle for the package list. + @param Form The form this statement belong to. @param Statement Statement of this Menu Option. @param NumberOfLines Display lines for this Menu Option. @param MenuItemCount The index for this Option in the Menu. @@ -306,6 +307,7 @@ UI_MENU_OPTION * UiAddMenuOption ( IN CHAR16 *String, IN EFI_HII_HANDLE Handle, + IN FORM_BROWSER_FORM *Form, IN FORM_BROWSER_STATEMENT *Statement, IN UINT16 NumberOfLines, IN UINT16 MenuItemCount