Add new HII action type EFI_BROWSER_ACTION_SUBMITTED
to notify HII driver when its question values are submitted.

Cc: Liming Gao <liming....@intel.com>
Cc: Eric Dong <eric.d...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 170 ++++++++++++++++++++-----
 1 file changed, 136 insertions(+), 34 deletions(-)

diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c 
b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 89869ed..f9e7e80 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -2447,10 +2447,123 @@ SendDiscardInfoToDriver (
                              );
   }
 }
 
 /**
+  When submit the question value, call the callback function with Submitted 
type
+  to inform the hii driver. And update the reset and reconnect flag.
+
+  @param  FormSet                FormSet data structure.
+  @param  Form                   Form data structure.
+
+**/
+VOID
+SubmitCallbackAndFlageUpdateForForm (
+  IN FORM_BROWSER_FORMSET             *FormSet,
+  IN FORM_BROWSER_FORM                *Form
+  )
+{
+  LIST_ENTRY                  *Link;
+  FORM_BROWSER_STATEMENT      *Question;
+  EFI_IFR_TYPE_VALUE          *TypeValue;
+  EFI_BROWSER_ACTION_REQUEST  ActionRequest;
+
+  if (FormSet->ConfigAccess == NULL) {
+    return;
+  }
+
+  Link = GetFirstNode (&Form->StatementListHead);
+  while (!IsNull (&Form->StatementListHead, Link)) {
+    Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
+    Link = GetNextNode (&Form->StatementListHead, Link);
+
+    if (!Question->ValueChanged) {
+      continue;
+    }
+
+    //
+    //Compare the buffer and editbuffer data to see whether the data has been 
saved.
+    //
+    IsQuestionValueChanged(FormSet, Form, Question, GetSetValueWithBothBuffer);
+
+    if (Question->ValueChanged) {
+      continue;
+    }
+
+    //
+    // Only the changed data has been saved, then need to set the reset flag.
+    //
+    if ((Question->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0) {
+      gResetRequired = TRUE;
+    }
+
+    if ((Question->QuestionFlags & EFI_IFR_FLAG_RECONNECT_REQUIRED) != 0) {
+      gFlagReconnect = TRUE;
+    }
+
+    if (Question->Storage == NULL || Question->Storage->Type == 
EFI_HII_VARSTORE_EFI_VARIABLE) {
+      continue;
+    }
+
+    if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 
EFI_IFR_FLAG_CALLBACK) {
+       continue;
+    }
+
+    if (Question->Operand == EFI_IFR_PASSWORD_OP) {
+       continue;
+    }
+
+    if (Question->HiiValue.Type == EFI_IFR_TYPE_BUFFER) {
+      TypeValue = (EFI_IFR_TYPE_VALUE *) Question->BufferValue;
+    } else {
+      TypeValue = &Question->HiiValue.Value;
+    }
+
+    ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
+    FormSet->ConfigAccess->Callback (
+                             FormSet->ConfigAccess,
+                             EFI_BROWSER_ACTION_SUBMITTED,
+                             Question->QuestionId,
+                             Question->HiiValue.Type,
+                             TypeValue,
+                             &ActionRequest
+                             );
+  }
+}
+
+/**
+  When value set Success, call the submit callback function,
+  and update the reset and reconnect flag.
+
+  @param  FormSet                FormSet data structure.
+  @param  Form                   Form data structure.
+
+**/
+VOID
+SubmitCallbackAndFlageUpdate (
+  IN FORM_BROWSER_FORMSET             *FormSet,
+  IN FORM_BROWSER_FORM                *Form
+  )
+{
+  FORM_BROWSER_FORM       *CurrentForm;
+  LIST_ENTRY              *Link;
+
+  if (Form != NULL) {
+    SubmitCallbackAndFlageUpdateForForm(FormSet, Form);
+    return;
+  }
+
+  Link = GetFirstNode (&FormSet->FormListHead);
+  while (!IsNull (&FormSet->FormListHead, Link)) {
+    CurrentForm = FORM_BROWSER_FORM_FROM_LINK (Link);
+    Link = GetNextNode (&FormSet->FormListHead, Link);
+
+    SubmitCallbackAndFlageUpdateForForm(FormSet, CurrentForm);
+  }
+}
+
+/**
   Validate the HiiHandle.
 
   @param  HiiHandle              The input HiiHandle which need to validate.
 
   @retval TRUE                   The handle is validate.
@@ -2516,92 +2629,71 @@ ValidateFormSet (
   }
 
   return Find;
 }
 /**
-  Check whether need to enable the reset flag in form level.
-  Also clean all ValueChanged flag in question.
+  Clean all ValueChanged flag in question.
 
   @param  SetFlag                Whether need to set the Reset Flag.
   @param  FormSet                FormSet data structure.
   @param  Form                   Form data structure.
 
 **/
 VOID
 UpdateFlagForForm (
-  IN BOOLEAN                          SetFlag,
   IN FORM_BROWSER_FORMSET             *FormSet,
   IN FORM_BROWSER_FORM                *Form
   )
 {
   LIST_ENTRY              *Link;
   FORM_BROWSER_STATEMENT  *Question;
-  BOOLEAN                 OldValue;
 
   Link = GetFirstNode (&Form->StatementListHead);
   while (!IsNull (&Form->StatementListHead, Link)) {
     Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
     Link = GetNextNode (&Form->StatementListHead, Link);
 
     if (!Question->ValueChanged) {
       continue;
     }
 
-    OldValue = Question->ValueChanged;
-
-    //
-    // Compare the buffer and editbuffer data to see whether the data has been 
saved.
-    //
-    Question->ValueChanged = IsQuestionValueChanged(FormSet, Form, Question, 
GetSetValueWithBothBuffer);
-
     //
-    // Only the changed data has been saved, then need to set the reset flag.
+    // Clean all ValueChanged flag in question..
     //
-    if (SetFlag && OldValue && !Question->ValueChanged) {
-      if ((Question->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0) {
-        gResetRequired = TRUE;
-      }
-
-      if ((Question->QuestionFlags & EFI_IFR_FLAG_RECONNECT_REQUIRED) != 0) {
-        gFlagReconnect = TRUE;
-      }
-    } 
+    IsQuestionValueChanged(FormSet, Form, Question, GetSetValueWithBothBuffer);
   }
 }
 
 /**
-  Check whether need to enable the reset flag.
-  Also clean ValueChanged flag for all statements.
+  Clean ValueChanged flag for all statements.
 
   Form level or formset level, only one.
-  
-  @param  SetFlag                Whether need to set the Reset Flag.
+
   @param  FormSet                FormSet data structure.
   @param  Form                   Form data structure.
 
 **/
 VOID
-ValueChangeResetFlagUpdate (
-  IN BOOLEAN                          SetFlag,
+ValueChangeFlagUpdate (
   IN FORM_BROWSER_FORMSET             *FormSet,
   IN FORM_BROWSER_FORM                *Form  
   )
 {
   FORM_BROWSER_FORM       *CurrentForm;
   LIST_ENTRY              *Link;
 
   if (Form != NULL) {
-    UpdateFlagForForm(SetFlag, FormSet, Form);
+    UpdateFlagForForm(FormSet, Form);
     return;
   }
 
   Link = GetFirstNode (&FormSet->FormListHead);
   while (!IsNull (&FormSet->FormListHead, Link)) {
     CurrentForm = FORM_BROWSER_FORM_FROM_LINK (Link);
     Link = GetNextNode (&FormSet->FormListHead, Link);
 
-    UpdateFlagForForm(SetFlag, FormSet, CurrentForm);
+    UpdateFlagForForm(FormSet, CurrentForm);
   }
 }
 
 /**
   Base on the return Progress string to find the form. 
@@ -2895,11 +2987,11 @@ DiscardForm (
       // Call callback with Changed type to inform the driver.
       //
       SendDiscardInfoToDriver (FormSet, Form);
     }
 
-    ValueChangeResetFlagUpdate (FALSE, FormSet, Form);
+    ValueChangeFlagUpdate (FormSet, Form);
   } else if (SettingScope == FormSetLevel && IsNvUpdateRequiredForFormSet 
(FormSet)) {
 
     //
     // Discard Buffer storage or Name/Value storage
     //
@@ -2931,11 +3023,11 @@ DiscardForm (
       // Call callback with Changed type to inform the driver.
       //
       SendDiscardInfoToDriver (FormSet, Form);
     }
 
-    ValueChangeResetFlagUpdate(FALSE, FormSet, NULL);
+    ValueChangeFlagUpdate(FormSet, NULL);
   } else if (SettingScope == SystemLevel) {
     //
     // System Level Discard.
     //
     OldFormSet = mSystemLevelFormSet;
@@ -3047,10 +3139,15 @@ SubmitForForm (
     //
     SynchronizeStorage (ConfigInfo->Storage, ConfigInfo->ConfigRequest, TRUE);
   }
 
   //
+  // Call callback with Submitted type to inform the driver.
+  //
+  SubmitCallbackAndFlageUpdate (FormSet, Form);
+
+  //
   // 4. Process the save failed storage.
   //
   if (!IsListEmpty (&gBrowserSaveFailFormSetList)) {
     if (ConfirmSaveFail (Form->FormTitle, FormSet->HiiHandle) == 
BROWSER_ACTION_DISCARD) {
       Link = GetFirstNode (&gBrowserSaveFailFormSetList);
@@ -3077,11 +3174,11 @@ SubmitForForm (
   }
 
   //
   // 5. Update the NV flag.
   //
-  ValueChangeResetFlagUpdate(TRUE, FormSet, Form);
+  ValueChangeFlagUpdate(FormSet, Form);
 
   return Status;
 }
 
 /**
@@ -3202,10 +3299,15 @@ SubmitForFormSet (
     //
     SynchronizeStorage (Storage, FormSetStorage->ConfigRequest, TRUE);
   }
 
   //
+  // Call callback with Submitted type to inform the driver.
+  //
+  SubmitCallbackAndFlageUpdate (FormSet, NULL);
+
+  //
   // 4. Has save fail storage need to handle.
   //
   if (Form != NULL) {
     if (!SkipProcessFail) {
       //
@@ -3251,11 +3353,11 @@ SubmitForFormSet (
   }
 
   //
   // 5. Update the NV flag.
   // 
-  ValueChangeResetFlagUpdate(TRUE, FormSet, NULL);
+  ValueChangeFlagUpdate(FormSet, NULL);
 
   return Status;
 }
 
 /**
@@ -3356,11 +3458,11 @@ SubmitForSystem (
         CleanBrowserStorage(LocalFormSet);
         RemoveEntryList (&LocalFormSet->Link);
         RemoveEntryList (&LocalFormSet->SaveFailLink);
         DestroyFormSet (LocalFormSet);
       } else {
-        ValueChangeResetFlagUpdate(FALSE, LocalFormSet, NULL);
+        ValueChangeFlagUpdate(LocalFormSet, NULL);
       }
     } else {
       if (IsListEmpty (&LocalFormSet->SaveFailStorageListHead)) {
         NoSubmitCheck (LocalFormSet, &Form, &Question);
       }
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to