]> git.proxmox.com Git - mirror_edk2.git/commitdiff
When do discard action, enable callback action for questions which have value changed.
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Jul 2012 02:27:33 +0000 (02:27 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Jul 2012 02:27:33 +0000 (02:27 +0000)
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13509 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
MdeModulePkg/Universal/SetupBrowserDxe/Ui.c

index b9034fa2e013b4502b1aaf638a5d12bdae4c5b36..ff46fcbc5a7df49a30eb39692baa7ac780f58cf6 100644 (file)
@@ -891,7 +891,7 @@ IdToQuestion (
       // to keep synchronous, always reload the Question Value.\r
       //\r
       if (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {\r
-        GetQuestionValue (FormSet, Form, Question, FALSE);\r
+        GetQuestionValue (FormSet, Form, Question, GetSetValueWithHiiDriver);\r
       }\r
 \r
       return Question;\r
@@ -2142,7 +2142,7 @@ GetQuestionValueFromForm (
   //\r
   // Get the question value.\r
   //\r
-  Status = GetQuestionValue(FormSet, Form, Question, FALSE);\r
+  Status = GetQuestionValue(FormSet, Form, Question, GetSetValueWithHiiDriver);\r
   if (EFI_ERROR (Status)) {\r
     GetTheVal = FALSE;\r
     goto Done;\r
@@ -2343,7 +2343,7 @@ EvaluateExpression (
             //\r
             // Get value from string except for STRING value.\r
             //\r
-            Status = GetValueByName (OpCode->VarStorage, OpCode->ValueName, &StrPtr);\r
+            Status = GetValueByName (OpCode->VarStorage, OpCode->ValueName, &StrPtr, GetSetValueWithEditBuffer);\r
             if (!EFI_ERROR (Status)) {\r
               ASSERT (StrPtr != NULL);\r
               TempLength = StrLen (StrPtr);\r
@@ -2796,7 +2796,7 @@ EvaluateExpression (
             for (Index = 0; Index < OpCode->ValueWidth; Index ++, TempBuffer --) {\r
               StrPtr += UnicodeValueToString (StrPtr, PREFIX_ZERO | RADIX_HEX, *TempBuffer, 2);\r
             }\r
-            Status = SetValueByName (OpCode->VarStorage, OpCode->ValueName, NameValue, TRUE);\r
+            Status = SetValueByName (OpCode->VarStorage, OpCode->ValueName, NameValue, GetSetValueWithEditBuffer);\r
             FreePool (NameValue);\r
             if (!EFI_ERROR (Status)) {\r
               Data1.Value.b = TRUE;\r
index dd022ce554f0268d26464020b0403337190f6b3d..81190464cb325aa4f4555813139f8593f9366a24 100644 (file)
@@ -799,9 +799,9 @@ EnterCarriageReturn:
         //\r
         // Input value is not valid, restore Question Value\r
         //\r
-        GetQuestionValue (FormSet, Form, Question, TRUE);\r
+        GetQuestionValue (FormSet, Form, Question, GetSetValueWithEditBuffer);\r
       } else {\r
-        SetQuestionValue (FormSet, Form, Question, TRUE);\r
+        SetQuestionValue (FormSet, Form, Question, GetSetValueWithEditBuffer);\r
         if (!DateOrTime || (Question->Storage != NULL)) {\r
           //\r
           // NV flag is unnecessary for RTC type of Date/Time\r
@@ -1351,9 +1351,9 @@ TheKey:
         //\r
         // Input value is not valid, restore Question Value\r
         //\r
-        GetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
+        GetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);\r
       } else {\r
-        SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
+        SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);\r
         UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
       }\r
 \r
index 7edbdb622999745b8e70bfedc43fe88debbda3c5..6e46e0e9610df8926ab5149bc9258ef5a4973cae 100644 (file)
@@ -1287,7 +1287,7 @@ ProcessCallBackFunction (
       // "retrieve" should update to the question's temp buffer.\r
       //\r
       if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) {\r
-        SetQuestionValue(Selection->FormSet, Selection->Form, Statement, TRUE);\r
+        SetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer);\r
       }\r
     } else {\r
       //\r
@@ -1295,7 +1295,7 @@ ProcessCallBackFunction (
       // "retrieve", should restore the question's value.\r
       //\r
       if (Action  == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) {\r
-        GetQuestionValue(Selection->FormSet, Selection->Form, Statement, TRUE);\r
+        GetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer);\r
       }\r
 \r
       if (Status == EFI_UNSUPPORTED) {\r
index 2a51af8e2f361eb0c63874a8aa9d7b8023d5ac4e..181afec16d836dd02b621880bdfa5fa1d356eba1 100644 (file)
@@ -482,7 +482,7 @@ ProcessOptions (
           }\r
           SetArrayData (ValueArray, ValueType, Index2, 0);\r
 \r
-          Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
+          Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);\r
           UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
 \r
           FreePool (*OptionString);\r
@@ -551,7 +551,7 @@ ProcessOptions (
           if ((Option->SuppressExpression == NULL) ||\r
               (EvaluateExpressionList(Option->SuppressExpression, FALSE, NULL, NULL) == ExpressFalse)) {\r
             CopyMem (QuestionValue, &Option->Value, sizeof (EFI_HII_VALUE));\r
-            SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
+            SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);\r
             UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
             break;\r
           }\r
@@ -587,7 +587,7 @@ ProcessOptions (
               (EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) == ExpressFalse)) {\r
             Suppress = FALSE;\r
             CopyMem (QuestionValue, &OneOfOption->Value, sizeof (EFI_HII_VALUE));\r
-            SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
+            SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);\r
             UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
             gST->ConOut->SetAttribute (gST->ConOut, PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND);\r
             break;\r
@@ -640,7 +640,7 @@ ProcessOptions (
       //\r
       // Save Question value\r
       //\r
-      Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
+      Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);\r
       UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
     }\r
 \r
@@ -753,7 +753,7 @@ ProcessOptions (
           HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);\r
         } else {\r
           CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));\r
-          SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
+          SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithEditBuffer);\r
 \r
           UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
         }\r
@@ -940,7 +940,7 @@ ProcessOptions (
             PasswordCallback (Selection, MenuOption, StringPtr);\r
           } else {\r
             CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));\r
-            SetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);\r
+            SetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithHiiDriver);\r
           }\r
         }\r
       } else {\r
index 1389f261aea3cc006cdcee5d18379a8d306834e3..8aced87c85e0febdfbaf7e55c70d967e9b1a5ffc 100644 (file)
@@ -933,6 +933,7 @@ SynchronizeStorage (
   @param  Storage                The NameValue Storage.\r
   @param  Name                   The Name.\r
   @param  Value                  The retured Value.\r
+  @param  GetValueFrom           Where to get source value, from EditValue or Value.\r
 \r
   @retval EFI_SUCCESS            Value found for given Name.\r
   @retval EFI_NOT_FOUND          No such Name found in NameValue storage.\r
@@ -940,14 +941,19 @@ SynchronizeStorage (
 **/\r
 EFI_STATUS\r
 GetValueByName (\r
-  IN FORMSET_STORAGE         *Storage,\r
-  IN CHAR16                  *Name,\r
-  IN OUT CHAR16              **Value\r
+  IN FORMSET_STORAGE             *Storage,\r
+  IN CHAR16                      *Name,\r
+  IN OUT CHAR16                  **Value,\r
+  IN GET_SET_QUESTION_VALUE_WITH GetValueFrom\r
   )\r
 {\r
   LIST_ENTRY              *Link;\r
   NAME_VALUE_NODE         *Node;\r
 \r
+  if (GetValueFrom != GetSetValueWithEditBuffer && GetValueFrom != GetSetValueWithBuffer) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   *Value = NULL;\r
 \r
   Link = GetFirstNode (&Storage->NameValueListHead);\r
@@ -955,7 +961,11 @@ GetValueByName (
     Node = NAME_VALUE_NODE_FROM_LINK (Link);\r
 \r
     if (StrCmp (Name, Node->Name) == 0) {\r
-      NewStringCpy (Value, Node->EditValue);\r
+      if (GetValueFrom == GetSetValueWithEditBuffer) {\r
+        NewStringCpy (Value, Node->EditValue);\r
+      } else {\r
+        NewStringCpy (Value, Node->Value);\r
+      }\r
       return EFI_SUCCESS;\r
     }\r
 \r
@@ -972,7 +982,7 @@ GetValueByName (
   @param  Storage                The NameValue Storage.\r
   @param  Name                   The Name.\r
   @param  Value                  The Value to set.\r
-  @param  Edit                   Whether update editValue or Value.\r
+  @param  SetValueTo             Whether update editValue or Value.\r
 \r
   @retval EFI_SUCCESS            Value found for given Name.\r
   @retval EFI_NOT_FOUND          No such Name found in NameValue storage.\r
@@ -983,19 +993,23 @@ SetValueByName (
   IN FORMSET_STORAGE         *Storage,\r
   IN CHAR16                  *Name,\r
   IN CHAR16                  *Value,\r
-  IN BOOLEAN                 Edit\r
+  IN GET_SET_QUESTION_VALUE_WITH SetValueTo\r
   )\r
 {\r
   LIST_ENTRY              *Link;\r
   NAME_VALUE_NODE         *Node;\r
   CHAR16                  *Buffer;\r
 \r
+  if (SetValueTo != GetSetValueWithEditBuffer && SetValueTo != GetSetValueWithBuffer) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   Link = GetFirstNode (&Storage->NameValueListHead);\r
   while (!IsNull (&Storage->NameValueListHead, Link)) {\r
     Node = NAME_VALUE_NODE_FROM_LINK (Link);\r
 \r
     if (StrCmp (Name, Node->Name) == 0) {\r
-      if (Edit) {\r
+      if (SetValueTo == GetSetValueWithEditBuffer) {\r
         Buffer = Node->EditValue;\r
       } else {\r
         Buffer = Node->Value;\r
@@ -1005,7 +1019,7 @@ SetValueByName (
       }\r
       Buffer = AllocateCopyPool (StrSize (Value), Value);\r
       ASSERT (Buffer != NULL);\r
-      if (Edit) {\r
+      if (SetValueTo == GetSetValueWithEditBuffer) {\r
         Node->EditValue = Buffer;\r
       } else {\r
         Node->Value = Buffer;\r
@@ -1162,7 +1176,7 @@ ConfigRespToStorage (
       if (StrPtr != NULL) {\r
         *StrPtr = 0;\r
       }\r
-      SetValueByName (Storage, Name, Value, TRUE);\r
+      SetValueByName (Storage, Name, Value, GetSetValueWithEditBuffer);\r
     }\r
     break;\r
 \r
@@ -1182,8 +1196,7 @@ ConfigRespToStorage (
   @param  FormSet                FormSet data structure.\r
   @param  Form                   Form data structure.\r
   @param  Question               Question to be initialized.\r
-  @param  Cached                 TRUE:  get from Edit copy FALSE: get from original\r
-                                 Storage\r
+  @param  GetValueFrom           Where to get value, may from editbuffer, buffer or hii driver.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
 \r
@@ -1193,7 +1206,7 @@ GetQuestionValue (
   IN FORM_BROWSER_FORMSET             *FormSet,\r
   IN FORM_BROWSER_FORM                *Form,\r
   IN OUT FORM_BROWSER_STATEMENT       *Question,\r
-  IN BOOLEAN                          Cached\r
+  IN GET_SET_QUESTION_VALUE_WITH      GetValueFrom\r
   )\r
 {\r
   EFI_STATUS          Status;\r
@@ -1222,6 +1235,10 @@ GetQuestionValue (
   Value  = NULL;\r
   Result = NULL;\r
 \r
+  if (GetValueFrom >= GetSetValueWithMax) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   //\r
   // Statement don't have storage, skip them\r
   //\r
@@ -1373,15 +1390,22 @@ GetQuestionValue (
     IsBufferStorage = FALSE;\r
   }\r
   IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ?  TRUE : FALSE);\r
-  if (Cached) {\r
+  if (GetValueFrom == GetSetValueWithEditBuffer || GetValueFrom == GetSetValueWithBuffer ) {\r
     if (IsBufferStorage) {\r
-      //\r
-      // Copy from storage Edit buffer\r
-      //\r
-      CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+      if (GetValueFrom == GetSetValueWithEditBuffer) {\r
+        //\r
+        // Copy from storage Edit buffer\r
+        //\r
+        CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+      } else {\r
+        //\r
+        // Copy from storage Edit buffer\r
+        //\r
+        CopyMem (Dst, Storage->Buffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
+      }\r
     } else {\r
       Value = NULL;\r
-      Status = GetValueByName (Storage, Question->VariableName, &Value);\r
+      Status = GetValueByName (Storage, Question->VariableName, &Value, GetValueFrom);\r
       if (EFI_ERROR (Status)) {\r
         return Status;\r
       }\r
@@ -1578,7 +1602,7 @@ GetQuestionValue (
     if (IsBufferStorage) {\r
       CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Dst, StorageWidth);\r
     } else {\r
-      SetValueByName (Storage, Question->VariableName, Value, TRUE);\r
+      SetValueByName (Storage, Question->VariableName, Value, GetSetValueWithEditBuffer);\r
     }\r
 \r
     if (Result != NULL) {\r
@@ -1596,8 +1620,7 @@ GetQuestionValue (
   @param  FormSet                FormSet data structure.\r
   @param  Form                   Form data structure.\r
   @param  Question               Pointer to the Question.\r
-  @param  Cached                 TRUE:  set to Edit copy FALSE: set to original\r
-                                 Storage\r
+  @param  SetValueTo             Update the question value to editbuffer , buffer or hii driver.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
 \r
@@ -1607,7 +1630,7 @@ SetQuestionValue (
   IN FORM_BROWSER_FORMSET             *FormSet,\r
   IN FORM_BROWSER_FORM                *Form,\r
   IN OUT FORM_BROWSER_STATEMENT       *Question,\r
-  IN BOOLEAN                          Cached\r
+  IN GET_SET_QUESTION_VALUE_WITH      SetValueTo\r
   )\r
 {\r
   EFI_STATUS          Status;\r
@@ -1632,6 +1655,10 @@ SetQuestionValue (
 \r
   Status = EFI_SUCCESS;\r
 \r
+  if (SetValueTo >= GetSetValueWithMax) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   //\r
   // Statement don't have storage, skip them\r
   //\r
@@ -1747,47 +1774,55 @@ SetQuestionValue (
     IsBufferStorage = FALSE;\r
   }\r
   IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ?  TRUE : FALSE);\r
-  if (IsBufferStorage) {\r
-    //\r
-    // Copy to storage edit buffer\r
-    //\r
-    CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
-  } else {\r
-    if (IsString) {\r
-      //\r
-      // Allocate enough string buffer.\r
-      //\r
-      Value = NULL;\r
-      BufferLen = ((StrLen ((CHAR16 *) Src) * 4) + 1) * sizeof (CHAR16);\r
-      Value = AllocateZeroPool (BufferLen);\r
-      ASSERT (Value != NULL);\r
-      //\r
-      // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"\r
-      //\r
-      TemName = (CHAR16 *) Src;\r
-      TemString = Value;\r
-      for (; *TemName != L'\0'; TemName++) {\r
-        TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);\r
+\r
+  if (SetValueTo == GetSetValueWithEditBuffer || SetValueTo == GetSetValueWithBuffer) {\r
+    if (IsBufferStorage) {\r
+      if (SetValueTo == GetSetValueWithEditBuffer) {\r
+        //\r
+        // Copy to storage edit buffer\r
+        //      \r
+        CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
+      } else if (SetValueTo == GetSetValueWithBuffer) {\r
+        //\r
+        // Copy to storage edit buffer\r
+        //     \r
+        CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth);\r
       }\r
     } else {\r
-      BufferLen = StorageWidth * 2 + 1;\r
-      Value = AllocateZeroPool (BufferLen * sizeof (CHAR16));\r
-      ASSERT (Value != NULL);\r
-      //\r
-      // Convert Buffer to Hex String\r
-      //\r
-      TemBuffer = Src + StorageWidth - 1;\r
-      TemString = Value;\r
-      for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {\r
-        TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);\r
+      if (IsString) {\r
+        //\r
+        // Allocate enough string buffer.\r
+        //\r
+        Value = NULL;\r
+        BufferLen = ((StrLen ((CHAR16 *) Src) * 4) + 1) * sizeof (CHAR16);\r
+        Value = AllocateZeroPool (BufferLen);\r
+        ASSERT (Value != NULL);\r
+        //\r
+        // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"\r
+        //\r
+        TemName = (CHAR16 *) Src;\r
+        TemString = Value;\r
+        for (; *TemName != L'\0'; TemName++) {\r
+          TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);\r
+        }\r
+      } else {\r
+        BufferLen = StorageWidth * 2 + 1;\r
+        Value = AllocateZeroPool (BufferLen * sizeof (CHAR16));\r
+        ASSERT (Value != NULL);\r
+        //\r
+        // Convert Buffer to Hex String\r
+        //\r
+        TemBuffer = Src + StorageWidth - 1;\r
+        TemString = Value;\r
+        for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {\r
+          TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);\r
+        }\r
       }\r
-    }\r
-\r
-    Status = SetValueByName (Storage, Question->VariableName, Value, TRUE);\r
-    FreePool (Value);\r
-  }\r
 \r
-  if (!Cached) {\r
+      Status = SetValueByName (Storage, Question->VariableName, Value, SetValueTo);\r
+      FreePool (Value);\r
+    }\r
+  } else if (SetValueTo == GetSetValueWithHiiDriver) {\r
     if (Storage->Type == EFI_HII_VARSTORE_BUFFER || Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {\r
       //\r
       // <ConfigResp> ::= <ConfigHdr> + <BlockName> + "&VALUE=" + "<HexCh>StorageWidth * 2" ||\r
@@ -2115,6 +2150,105 @@ SynchronizeStorageForForm (
   return Status;\r
 }\r
 \r
+/**\r
+  When discard the question value, call the callback function with Changed type\r
+  to inform the hii driver.\r
+\r
+  @param  FormSet                FormSet data structure.\r
+  @param  Form                   Form data structure.\r
+\r
+**/\r
+VOID\r
+SendDiscardInfoToDriver (\r
+  IN FORM_BROWSER_FORMSET             *FormSet,\r
+  IN FORM_BROWSER_FORM                *Form\r
+  )\r
+{\r
+  LIST_ENTRY                  *Link;\r
+  FORM_BROWSER_STATEMENT      *Question;\r
+  EFI_STATUS                  Status;\r
+  EFI_HII_VALUE               HiiValue;\r
+  UINT8                       *BufferValue;\r
+  BOOLEAN                     ValueChanged;\r
+  EFI_IFR_TYPE_VALUE          *TypeValue;\r
+  EFI_BROWSER_ACTION_REQUEST  ActionRequest;\r
+\r
+  ValueChanged = FALSE;\r
+  BufferValue  = NULL;\r
+\r
+  if(!Form->NvUpdateRequired) {\r
+    return;\r
+  }\r
+\r
+  Link = GetFirstNode (&Form->StatementListHead);\r
+  while (!IsNull (&Form->StatementListHead, Link)) {\r
+    Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);\r
+    Link = GetNextNode (&Form->StatementListHead, Link);\r
+\r
+    if (Question->Storage == NULL || Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {\r
+      continue;\r
+    }\r
+\r
+    if (Question->Operand == EFI_IFR_PASSWORD_OP) {\r
+      continue;\r
+    }\r
+\r
+    if (Question->BufferValue != NULL) {\r
+      BufferValue = AllocateZeroPool (Question->StorageWidth);\r
+      ASSERT (BufferValue != NULL);\r
+      CopyMem (BufferValue, Question->BufferValue, Question->StorageWidth);\r
+    } else {\r
+      HiiValue.Type = Question->HiiValue.Type;\r
+      CopyMem (&HiiValue.Value, &Question->HiiValue.Value, sizeof (EFI_IFR_TYPE_VALUE));\r
+    }\r
+\r
+    Status = GetQuestionValue (FormSet, Form, Question, GetSetValueWithBuffer);\r
+    if (EFI_ERROR (Status)) {\r
+      if (BufferValue != NULL) {\r
+        FreePool (BufferValue);\r
+        BufferValue = NULL;\r
+      }\r
+      continue;\r
+    }\r
+\r
+    if (Question->BufferValue != NULL) {\r
+      if (CompareMem (BufferValue, Question->BufferValue, Question->StorageWidth)) {\r
+        ValueChanged = TRUE;\r
+      }\r
+    } else {\r
+      if (CompareMem (&HiiValue.Value, &Question->HiiValue.Value, sizeof (EFI_IFR_TYPE_VALUE))) {\r
+        ValueChanged = TRUE;\r
+      }\r
+    }\r
+\r
+    if (BufferValue != NULL) {\r
+      FreePool (BufferValue);\r
+      BufferValue = NULL;\r
+    }\r
+\r
+    if (!ValueChanged) {\r
+      continue;\r
+    }\r
+\r
+    ValueChanged = FALSE;\r
+\r
+    if (Question->HiiValue.Type == EFI_IFR_TYPE_BUFFER) {\r
+      TypeValue = (EFI_IFR_TYPE_VALUE *) Question->BufferValue;\r
+    } else {\r
+      TypeValue = &Question->HiiValue.Value;\r
+    }\r
+\r
+    ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
+    FormSet->ConfigAccess->Callback (\r
+                             FormSet->ConfigAccess,\r
+                             EFI_BROWSER_ACTION_CHANGED,\r
+                             Question->QuestionId,\r
+                             Question->HiiValue.Type,\r
+                             TypeValue,\r
+                             &ActionRequest\r
+                             );\r
+  }\r
+}\r
 \r
 /**\r
   Discard data based on the input setting scope (Form, FormSet or System).\r
@@ -2164,6 +2298,11 @@ DiscardForm (
         continue;\r
       }\r
 \r
+      //\r
+      // Call callback with Changed type to inform the driver.\r
+      //\r
+      SendDiscardInfoToDriver (FormSet, Form);\r
+\r
       //\r
       // Prepare <ConfigResp>\r
       //\r
@@ -2172,6 +2311,18 @@ DiscardForm (
 \r
     Form->NvUpdateRequired = FALSE;\r
   } else if (SettingScope == FormSetLevel && IsNvUpdateRequired(FormSet)) {\r
+\r
+    Link = GetFirstNode (&FormSet->FormListHead);\r
+    while (!IsNull (&FormSet->FormListHead, Link)) {\r
+      Form = FORM_BROWSER_FORM_FROM_LINK (Link);\r
+      Link = GetNextNode (&FormSet->FormListHead, Link);\r
+      \r
+      //\r
+      // Call callback with Changed type to inform the driver.\r
+      //\r
+      SendDiscardInfoToDriver (FormSet, Form);\r
+    }\r
+\r
     //\r
     // Discard Buffer storage or Name/Value storage\r
     //\r
@@ -3060,7 +3211,7 @@ ExtractDefault (
       //\r
       if ((Question->Storage != NULL) &&\r
           (Question->Storage->Type != EFI_HII_VARSTORE_EFI_VARIABLE)) {\r
-        SetQuestionValue (FormSet, Form, Question, TRUE);\r
+        SetQuestionValue (FormSet, Form, Question, GetSetValueWithEditBuffer);\r
         //\r
         // Update Form NV flag.\r
         //\r
@@ -3183,7 +3334,7 @@ LoadFormConfig (
     //\r
     // Initialize local copy of Value for each Question\r
     //\r
-    Status = GetQuestionValue (FormSet, Form, Question, TRUE);\r
+    Status = GetQuestionValue (FormSet, Form, Question, GetSetValueWithEditBuffer);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
@@ -3389,8 +3540,8 @@ CopyStorage (
     while (!IsNull (&Src->NameValueListHead, Link)) {\r
       Node = NAME_VALUE_NODE_FROM_LINK (Link);\r
 \r
-      SetValueByName (Dst, Node->Name, Node->EditValue, TRUE);\r
-      SetValueByName (Dst, Node->Name, Node->Value, FALSE);\r
+      SetValueByName (Dst, Node->Name, Node->EditValue, GetSetValueWithEditBuffer);\r
+      SetValueByName (Dst, Node->Name, Node->Value, GetSetValueWithBuffer);\r
 \r
       Link = GetNextNode (&Src->NameValueListHead, Link);\r
     }\r
index fcc17254edfed2d2eecb94054db0b644fdb2798f..12ffc523f89eb7b46b6c936842c4d287c3b0aac5 100644 (file)
@@ -584,6 +584,16 @@ typedef enum {
   GetDefaultForMax              // Invalid value.\r
 } BROWSER_GET_DEFAULT_VALUE;\r
 \r
+//\r
+// Get/set question value from/to.\r
+//\r
+typedef enum {\r
+  GetSetValueWithEditBuffer,       // Get/Set question value from/to editbuffer in the storage.\r
+  GetSetValueWithBuffer,           // Get/Set question value from/to buffer in the storage.\r
+  GetSetValueWithHiiDriver,        // Get/Set question value from/to hii driver.\r
+  GetSetValueWithMax               // Invalid value.\r
+} GET_SET_QUESTION_VALUE_WITH;\r
+\r
 extern EFI_HII_DATABASE_PROTOCOL         *mHiiDatabase;\r
 extern EFI_HII_STRING_PROTOCOL           *mHiiString;\r
 extern EFI_HII_CONFIG_ROUTING_PROTOCOL   *mHiiConfigRouting;\r
@@ -887,6 +897,7 @@ CreateDialog (
   @param  Storage                The NameValue Storage.\r
   @param  Name                   The Name.\r
   @param  Value                  The retured Value.\r
+  @param  GetValueFrom           Where to get source value, from EditValue or Value.\r
 \r
   @retval EFI_SUCCESS            Value found for given Name.\r
   @retval EFI_NOT_FOUND          No such Name found in NameValue storage.\r
@@ -894,9 +905,10 @@ CreateDialog (
 **/\r
 EFI_STATUS\r
 GetValueByName (\r
-  IN FORMSET_STORAGE         *Storage,\r
-  IN CHAR16                  *Name,\r
-  IN OUT CHAR16              **Value\r
+  IN FORMSET_STORAGE             *Storage,\r
+  IN CHAR16                      *Name,\r
+  IN OUT CHAR16                  **Value,\r
+  IN GET_SET_QUESTION_VALUE_WITH GetValueFrom\r
   );\r
 \r
 /**\r
@@ -905,7 +917,7 @@ GetValueByName (
   @param  Storage                The NameValue Storage.\r
   @param  Name                   The Name.\r
   @param  Value                  The Value to set.\r
-  @param  Edit                   Whether update editValue or Value.\r
+  @param  SetValueTo             Whether update editValue or Value.\r
 \r
   @retval EFI_SUCCESS            Value found for given Name.\r
   @retval EFI_NOT_FOUND          No such Name found in NameValue storage.\r
@@ -913,10 +925,10 @@ GetValueByName (
 **/\r
 EFI_STATUS\r
 SetValueByName (\r
-  IN FORMSET_STORAGE         *Storage,\r
-  IN CHAR16                  *Name,\r
-  IN CHAR16                  *Value,\r
-  IN BOOLEAN                 Edit\r
+  IN FORMSET_STORAGE             *Storage,\r
+  IN CHAR16                      *Name,\r
+  IN CHAR16                      *Value,\r
+  IN GET_SET_QUESTION_VALUE_WITH SetValueTo\r
   );\r
 \r
 /**\r
@@ -925,8 +937,7 @@ SetValueByName (
   @param  FormSet                FormSet data structure.\r
   @param  Form                   Form data structure.\r
   @param  Question               Question to be initialized.\r
-  @param  Cached                 TRUE:  get from Edit copy FALSE: get from original\r
-                                 Storage\r
+  @param  GetValueFrom           Where to get value, may from editbuffer, buffer or hii driver.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
 \r
@@ -936,7 +947,7 @@ GetQuestionValue (
   IN FORM_BROWSER_FORMSET             *FormSet,\r
   IN FORM_BROWSER_FORM                *Form,\r
   IN OUT FORM_BROWSER_STATEMENT       *Question,\r
-  IN BOOLEAN                          Cached\r
+  IN GET_SET_QUESTION_VALUE_WITH      GetValueFrom\r
   );\r
 \r
 /**\r
@@ -945,8 +956,7 @@ GetQuestionValue (
   @param  FormSet                FormSet data structure.\r
   @param  Form                   Form data structure.\r
   @param  Question               Pointer to the Question.\r
-  @param  Cached                 TRUE:  set to Edit copy FALSE: set to original\r
-                                 Storage\r
+  @param  SetValueTo             Update the question value to editbuffer , buffer or hii driver.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
 \r
@@ -956,7 +966,7 @@ SetQuestionValue (
   IN FORM_BROWSER_FORMSET             *FormSet,\r
   IN FORM_BROWSER_FORM                *Form,\r
   IN OUT FORM_BROWSER_STATEMENT       *Question,\r
-  IN BOOLEAN                          Cached\r
+  IN GET_SET_QUESTION_VALUE_WITH      SetValueTo\r
   );\r
 \r
 /**\r
index 7e846a29268bf93714f1bfebbbaac5bcc792b029..a2f336c2a4bdd13d446bca0a1f2c8a1361cef9be 100644 (file)
@@ -439,7 +439,7 @@ RefreshQuestion (
   Selection = MenuRefreshEntry->Selection;\r
   Question = MenuRefreshEntry->MenuOption->ThisTag;\r
 \r
-  Status = GetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);\r
+  Status = GetQuestionValue (Selection->FormSet, Selection->Form, Question, GetSetValueWithHiiDriver);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r