From 790447b2a515cdce5b13b8bf6e49785aaa58723b Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Wed, 6 May 2015 09:29:39 +0000 Subject: [PATCH] MdeModluePkg: Enable refresh opcode to refresh the entire form. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17334 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/SetupBrowserDxe/IfrParse.c | 20 +++++- .../Universal/SetupBrowserDxe/Presentation.c | 68 +++++++++++++++++-- .../Universal/SetupBrowserDxe/Setup.h | 1 + 3 files changed, 83 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index 0e9c82363d..a4a2478c48 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -2479,8 +2479,24 @@ ParseOpCodes ( // Refresh guid. // case EFI_IFR_REFRESH_ID_OP: - ASSERT (ParentStatement != NULL); - CopyMem (&ParentStatement->RefreshGuid, &((EFI_IFR_REFRESH_ID *) OpCodeData)->RefreshEventGroupId, sizeof (EFI_GUID)); + // + // 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); + CopyMem (&CurrentForm->RefreshGuid, &((EFI_IFR_REFRESH_ID *) OpCodeData)->RefreshEventGroupId, sizeof (EFI_GUID)); + break; + + default: + ASSERT (ParentStatement != NULL); + CopyMem (&ParentStatement->RefreshGuid, &((EFI_IFR_REFRESH_ID *) OpCodeData)->RefreshEventGroupId, sizeof (EFI_GUID)); + break; + } break; // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index aa1fedc7b4..c86fdf5856 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -178,7 +178,7 @@ UpdateStatement ( **/ VOID EFIAPI -RefreshEventNotify( +RefreshEventNotifyForStatement( IN EFI_EVENT Event, IN VOID *Context ) @@ -190,6 +190,23 @@ RefreshEventNotify( gBS->SignalEvent (mValueChangedEvent); } +/** + Refresh the questions within this form. + + @param Event The event which has this function related. + @param Context The input context info related to this event or the status code return to the caller. +**/ +VOID +EFIAPI +RefreshEventNotifyForForm( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + gCurrentSelection->Action = UI_ACTION_REFRESH_FORMSET; + + gBS->SignalEvent (mValueChangedEvent); +} /** Create refresh hook event for statement which has refresh event or interval. @@ -198,7 +215,7 @@ RefreshEventNotify( **/ VOID -CreateRefreshEvent ( +CreateRefreshEventForStatement ( IN FORM_BROWSER_STATEMENT *Statement ) { @@ -212,7 +229,7 @@ CreateRefreshEvent ( Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - RefreshEventNotify, + RefreshEventNotifyForStatement, Statement, &Statement->RefreshGuid, &RefreshEvent); @@ -224,6 +241,39 @@ CreateRefreshEvent ( InsertTailList(&mRefreshEventList, &EventNode->Link); } +/** + Create refresh hook event for statement which has refresh event or interval. + + @param Statement The statement need to check. + +**/ +VOID +CreateRefreshEventForForm ( + IN FORM_BROWSER_FORM *Form + ) +{ + EFI_STATUS Status; + EFI_EVENT RefreshEvent; + FORM_BROWSER_REFRESH_EVENT_NODE *EventNode; + + // + // If question has refresh guid, create the notify function. + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + RefreshEventNotifyForForm, + Form, + &Form->RefreshGuid, + &RefreshEvent); + ASSERT_EFI_ERROR (Status); + + EventNode = AllocateZeroPool (sizeof (FORM_BROWSER_REFRESH_EVENT_NODE)); + ASSERT (EventNode != NULL); + EventNode->RefreshEvent = RefreshEvent; + InsertTailList(&mRefreshEventList, &EventNode->Link); +} + /** Initialize the Display statement structure data. @@ -308,7 +358,7 @@ InitializeDisplayStatement ( // Create the refresh event process function. // if (!CompareGuid (&Statement->RefreshGuid, &gZeroGuid)) { - CreateRefreshEvent (Statement); + CreateRefreshEventForStatement (Statement); } // @@ -559,6 +609,16 @@ AddStatementToDisplayForm ( InsertTailList(&mRefreshEventList, &EventNode->Link); } + // + // Create the refresh event process function for Form. + // + if (!CompareGuid (&gCurrentSelection->Form->RefreshGuid, &gZeroGuid)) { + CreateRefreshEventForForm (gCurrentSelection->Form); + if (gDisplayFormData.FormRefreshEvent == NULL) { + gDisplayFormData.FormRefreshEvent = mValueChangedEvent; + } + } + // // Update hotkey list field. // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h index 9a300fa966..0a935e80af 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -406,6 +406,7 @@ typedef struct { BOOLEAN ModalForm; // Whether this is a modal form. BOOLEAN Locked; // Whether this form is locked. + EFI_GUID RefreshGuid; // Form refresh event guid. LIST_ENTRY FormViewListHead; // List of type FORMID_INFO is Browser View Form History List. LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)