]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Patch includes:
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 21 Aug 2012 08:23:20 +0000 (08:23 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 21 Aug 2012 08:23:20 +0000 (08:23 +0000)
1.Enable Retrieve callback type for all questions before show these questions.
2.Enable retrieve callback type for all questions without storage when initial these questions.

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@13655 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
MdeModulePkg/Universal/SetupBrowserDxe/Ui.c

index 6e46e0e9610df8926ab5149bc9258ef5a4973cae..b8612e8c42d0630d83a931379be35fb14e7eff1b 100644 (file)
@@ -1322,6 +1322,57 @@ ProcessCallBackFunction (
   return Status;\r
 }\r
 \r
+/**\r
+  Call the retrieve type call back function for one question to get the initialize data.\r
+  \r
+  This function only used when in the initialize stage, because in this stage, the \r
+  Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.\r
+\r
+  @param ConfigAccess          The config access protocol produced by the hii driver.\r
+  @param Statement             The Question which need to call.\r
+\r
+  @retval EFI_SUCCESS          The call back function excutes successfully.\r
+  @return Other value if the call back function failed to excute.  \r
+**/\r
+EFI_STATUS \r
+ProcessRetrieveForQuestion (\r
+  IN     EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess,\r
+  IN     FORM_BROWSER_STATEMENT          *Statement\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_BROWSER_ACTION_REQUEST      ActionRequest;\r
+  EFI_HII_VALUE                   *HiiValue;\r
+  EFI_IFR_TYPE_VALUE              *TypeValue;\r
+\r
+  Status                = EFI_SUCCESS;\r
+  ActionRequest         = EFI_BROWSER_ACTION_REQUEST_NONE;\r
+    \r
+  if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  HiiValue  = &Statement->HiiValue;\r
+  TypeValue = &HiiValue->Value;\r
+  if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {\r
+    //\r
+    // For OrderedList, passing in the value buffer to Callback()\r
+    //\r
+    TypeValue = (EFI_IFR_TYPE_VALUE *) Statement->BufferValue;\r
+  }\r
+    \r
+  ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
+  Status = ConfigAccess->Callback (\r
+                           ConfigAccess,\r
+                           EFI_BROWSER_ACTION_RETRIEVE,\r
+                           Statement->QuestionId,\r
+                           HiiValue->Type,\r
+                           TypeValue,\r
+                           &ActionRequest\r
+                           );\r
+  return Status;\r
+}\r
+\r
 /**\r
   The worker function that send the displays to the screen. On output,\r
   the selection made by user is returned.\r
index 79829e6643dc58acfb170aeab7b6021e35e5ae2e..c471a232a0e394f450e90a45d2263ff84149f588 100644 (file)
@@ -3119,7 +3119,7 @@ GetQuestionDefault (
 \r
 \r
 /**\r
-  Reset Questions to their default value in a Form, Formset or System.\r
+  Reset Questions to their initial value or default value in a Form, Formset or System.\r
 \r
   GetDefaultValueScope parameter decides which questions will reset \r
   to its default value.\r
@@ -3130,6 +3130,9 @@ GetQuestionDefault (
   @param  SettingScope           Setting Scope for Default action.\r
   @param  GetDefaultValueScope   Get default value scope.\r
   @param  Storage                Get default value only for this storage.\r
+  @param  RetrieveValueFirst     Whether call the retrieve call back to\r
+                                 get the initial value before get default\r
+                                 value.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
   @retval EFI_UNSUPPORTED        Unsupport SettingScope.\r
@@ -3142,7 +3145,8 @@ ExtractDefault (
   IN UINT16                           DefaultId,\r
   IN BROWSER_SETTING_SCOPE            SettingScope,\r
   IN BROWSER_GET_DEFAULT_VALUE        GetDefaultValueScope,\r
-  IN FORMSET_STORAGE                  *Storage OPTIONAL\r
+  IN FORMSET_STORAGE                  *Storage OPTIONAL,\r
+  IN BOOLEAN                          RetrieveValueFirst\r
   )\r
 {\r
   EFI_STATUS              Status;\r
@@ -3155,6 +3159,8 @@ ExtractDefault (
   UINTN                   Index;\r
   EFI_GUID                ZeroGuid;\r
 \r
+  Status = EFI_SUCCESS;\r
+\r
   //\r
   // Check the supported setting level.\r
   //\r
@@ -3197,15 +3203,24 @@ ExtractDefault (
           continue;\r
         }\r
       }\r
-  \r
+\r
+      if (RetrieveValueFirst) {\r
+        //\r
+        // Call the Retrieve call back to get the initial question value.\r
+        //\r
+        Status = ProcessRetrieveForQuestion(FormSet->ConfigAccess, Question);\r
+      }\r
+\r
       //\r
-      // Reset Question to its default value\r
+      // If not request to get the initial value or get initial value fail, then get default value.\r
       //\r
-      Status = GetQuestionDefault (FormSet, Form, Question, DefaultId);\r
-      if (EFI_ERROR (Status)) {\r
-        continue;\r
+      if (!RetrieveValueFirst || EFI_ERROR (Status)) {\r
+        Status = GetQuestionDefault (FormSet, Form, Question, DefaultId);\r
+        if (EFI_ERROR (Status)) {\r
+          continue;\r
+        }\r
       }\r
-  \r
+\r
       //\r
       // Synchronize Buffer storage's Edit buffer\r
       //\r
@@ -3222,7 +3237,7 @@ ExtractDefault (
     FormLink = GetFirstNode (&FormSet->FormListHead);\r
     while (!IsNull (&FormSet->FormListHead, FormLink)) {\r
       Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);\r
-      ExtractDefault (FormSet, Form, DefaultId, FormLevel, GetDefaultValueScope, Storage);\r
+      ExtractDefault (FormSet, Form, DefaultId, FormLevel, GetDefaultValueScope, Storage, RetrieveValueFirst);\r
       FormLink = GetNextNode (&FormSet->FormListHead, FormLink);\r
     }\r
   } else if (SettingScope == SystemLevel) {\r
@@ -3293,7 +3308,7 @@ ExtractDefault (
     Link = GetFirstNode (&gBrowserFormSetList);\r
     while (!IsNull (&gBrowserFormSetList, Link)) {\r
       LocalFormSet = FORM_BROWSER_FORMSET_FROM_LINK (Link);\r
-      ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage);\r
+      ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage, RetrieveValueFirst);\r
       Link = GetNextNode (&gBrowserFormSetList, Link);\r
     }\r
   }\r
@@ -3344,26 +3359,10 @@ LoadFormConfig (
     }\r
 \r
     //\r
-    // According the spec, ref opcode try to get value from call back with "retrieve" type.\r
-    //\r
-    if ((Question->Operand == EFI_IFR_REF_OP) && (FormSet->ConfigAccess != NULL) && (Selection != NULL)) {\r
-      Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE);\r
-      if (EFI_ERROR (Status)) {\r
-        return Status;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Check whether EfiVarstore with CallBack can be got.\r
+    // Call the Retrieve call back function for all questions.\r
     //\r
-    if ((FormSet->ConfigAccess != NULL) &&\r
-        (Selection != NULL) &&\r
-        (Selection->Action != UI_ACTION_REFRESH_FORMSET) &&\r
-        (Question->QuestionId != 0) && \r
-        (Question->Storage != NULL) &&\r
-        (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) && \r
+    if ((FormSet->ConfigAccess != NULL) && (Selection != NULL) &&\r
         ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK)) {\r
-\r
       //\r
       // Check QuestionValue does exist.\r
       //\r
@@ -3373,17 +3372,21 @@ LoadFormConfig (
       } else {\r
         BufferValue = (UINT8 *) &Question->HiiValue.Value;\r
       }\r
-      Status = gRT->GetVariable (\r
-                       Question->VariableName,\r
-                       &Question->Storage->Guid,\r
-                       NULL,\r
-                       &StorageWidth,\r
-                       BufferValue\r
-                       );\r
 \r
-      if (!EFI_ERROR (Status)) {\r
-        Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE);\r
+      //\r
+      // For efivarstore storage, initial question value first.\r
+      //\r
+      if ((Question->Storage != NULL) && (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE)) {\r
+        Status = gRT->GetVariable (\r
+                         Question->VariableName,\r
+                         &Question->Storage->Guid,\r
+                         NULL,\r
+                         &StorageWidth,\r
+                         BufferValue\r
+                         );\r
       }\r
+\r
+      Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE);\r
     }\r
 \r
     Link = GetNextNode (&Form->StatementListHead, Link);\r
@@ -3555,6 +3558,79 @@ CopyStorage (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Get old question value from the saved formset.\r
+\r
+  @param  Statement              The question which need to get old question value.\r
+  @param  OldFormSet             FormSet data structure saved in the list.\r
+\r
+**/\r
+VOID \r
+GetOldQuestionValue (\r
+  IN OUT FORM_BROWSER_STATEMENT  *Statement,\r
+  IN     FORM_BROWSER_FORMSET    *OldFormSet\r
+  )\r
+{\r
+  LIST_ENTRY              *FormLink;\r
+  LIST_ENTRY              *Link;\r
+  FORM_BROWSER_STATEMENT  *Question;\r
+  FORM_BROWSER_FORM       *Form;\r
+\r
+  FormLink = GetFirstNode (&OldFormSet->FormListHead);\r
+  while (!IsNull (&OldFormSet->FormListHead, FormLink)) {\r
+    Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);\r
+    FormLink = GetNextNode (&OldFormSet->FormListHead, FormLink);\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->QuestionId != Statement->QuestionId) {\r
+        continue;\r
+      }\r
+\r
+      CopyMem (&Statement->HiiValue, &Question->HiiValue, sizeof (EFI_HII_VALUE));\r
+      return;\r
+    }\r
+  }\r
+}\r
+\r
+/**\r
+  Get old question value from the saved formset, all these questions not have\r
+  storage.\r
+\r
+  @param  FormSet                FormSet data structure which is used now.\r
+  @param  OldFormSet             FormSet data structure saved in the list.\r
+\r
+**/\r
+VOID\r
+CopyOldValueForNoStorageQst (\r
+  IN OUT FORM_BROWSER_FORMSET             *FormSet,\r
+  IN     FORM_BROWSER_FORMSET             *OldFormSet\r
+  )\r
+{\r
+  LIST_ENTRY              *FormLink;\r
+  LIST_ENTRY              *Link;\r
+  FORM_BROWSER_STATEMENT  *Question;\r
+  FORM_BROWSER_FORM       *Form;\r
+\r
+  FormLink = GetFirstNode (&FormSet->FormListHead);\r
+  while (!IsNull (&FormSet->FormListHead, FormLink)) {\r
+    Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);\r
+    FormLink = GetNextNode (&FormSet->FormListHead, FormLink);\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) {\r
+        GetOldQuestionValue (Question, OldFormSet);\r
+      }\r
+    }\r
+  }\r
+}\r
 \r
 /**\r
   Get current setting of Questions.\r
@@ -3578,11 +3654,6 @@ InitializeCurrentSetting (
   FORM_BROWSER_FORM       *Form2;\r
   EFI_STATUS              Status;\r
 \r
-  //\r
-  // Extract default from IFR binary for no storage questions.\r
-  //\r
-  ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForNoStorage, NULL);\r
-\r
   //\r
   // Request current settings from Configuration Driver\r
   //\r
@@ -3618,7 +3689,7 @@ InitializeCurrentSetting (
         //\r
         // If get last time changed value failed, extract default from IFR binary\r
         //\r
-        ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage);\r
+        ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage, TRUE);\r
         //\r
         // ExtractDefault will set the NV flag to TRUE, so need this function to clean the flag\r
         // in current situation.\r
@@ -3645,23 +3716,33 @@ InitializeCurrentSetting (
   // If has old formset, get the old nv update status.\r
   //\r
   if (gOldFormSet != NULL) {\r
-      Link = GetFirstNode (&FormSet->FormListHead);\r
-      while (!IsNull (&FormSet->FormListHead, Link)) {\r
-        Form = FORM_BROWSER_FORM_FROM_LINK (Link);\r
+    //\r
+    // Restore question value for questions without storage.\r
+    //\r
+    CopyOldValueForNoStorageQst (FormSet, gOldFormSet);\r
 \r
-        Link2 = GetFirstNode (&gOldFormSet->FormListHead);\r
-        while (!IsNull (&gOldFormSet->FormListHead, Link2)) {\r
-          Form2 = FORM_BROWSER_FORM_FROM_LINK (Link2);\r
+    Link = GetFirstNode (&FormSet->FormListHead);\r
+    while (!IsNull (&FormSet->FormListHead, Link)) {\r
+      Form = FORM_BROWSER_FORM_FROM_LINK (Link);\r
 \r
-          if (Form->FormId == Form2->FormId) {\r
-            Form->NvUpdateRequired = Form2->NvUpdateRequired;\r
-            break;\r
-          }\r
+      Link2 = GetFirstNode (&gOldFormSet->FormListHead);\r
+      while (!IsNull (&gOldFormSet->FormListHead, Link2)) {\r
+        Form2 = FORM_BROWSER_FORM_FROM_LINK (Link2);\r
 \r
-          Link2 = GetNextNode (&gOldFormSet->FormListHead, Link2);\r
+        if (Form->FormId == Form2->FormId) {\r
+          Form->NvUpdateRequired = Form2->NvUpdateRequired;\r
+          break;\r
         }\r
-          Link = GetNextNode (&FormSet->FormListHead, Link);\r
+\r
+        Link2 = GetNextNode (&gOldFormSet->FormListHead, Link2);\r
       }\r
+      Link = GetNextNode (&FormSet->FormListHead, Link);\r
+    }\r
+  } else {\r
+    //\r
+    // Extract default from IFR binary for no storage questions.\r
+    //  \r
+    ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForNoStorage, NULL, TRUE);\r
   }\r
 \r
   return EFI_SUCCESS;\r
index 12ffc523f89eb7b46b6c936842c4d287c3b0aac5..e11cdc16d76b5c217d9a0ccbe5fdc259cb126aca 100644 (file)
@@ -1081,7 +1081,7 @@ InitializeFormSet (
   );\r
 \r
 /**\r
-  Reset Questions to their default value in a Form, Formset or System.\r
+  Reset Questions to their initial value or default value in a Form, Formset or System.\r
 \r
   GetDefaultValueScope parameter decides which questions will reset \r
   to its default value.\r
@@ -1092,6 +1092,9 @@ InitializeFormSet (
   @param  SettingScope           Setting Scope for Default action.\r
   @param  GetDefaultValueScope   Get default value scope.\r
   @param  Storage                Get default value only for this storage.\r
+  @param  RetrieveValueFirst     Whether call the retrieve call back to\r
+                                 get the initial value before get default\r
+                                 value.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
   @retval EFI_UNSUPPORTED        Unsupport SettingScope.\r
@@ -1104,7 +1107,8 @@ ExtractDefault (
   IN UINT16                           DefaultId,\r
   IN BROWSER_SETTING_SCOPE            SettingScope,\r
   IN BROWSER_GET_DEFAULT_VALUE        GetDefaultValueScope,\r
-  IN FORMSET_STORAGE                  *Storage OPTIONAL\r
+  IN FORMSET_STORAGE                  *Storage,\r
+  IN BOOLEAN                          RetrieveValueFirst\r
   );\r
 \r
 /**\r
@@ -1384,6 +1388,24 @@ ProcessCallBackFunction (
   IN     EFI_BROWSER_ACTION              Action,\r
   IN     BOOLEAN                         SkipSaveOrDiscard\r
   );\r
+  \r
+/**\r
+  Call the retrieve type call back function for one question to get the initialize data.\r
+  \r
+  This function only used when in the initialize stage, because in this stage, the \r
+  Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.\r
+\r
+  @param ConfigAccess          The config access protocol produced by the hii driver.\r
+  @param Statement             The Question which need to call.\r
+\r
+  @retval EFI_SUCCESS          The call back function excutes successfully.\r
+  @return Other value if the call back function failed to excute.  \r
+**/\r
+EFI_STATUS \r
+ProcessRetrieveForQuestion (\r
+  IN     EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess,\r
+  IN     FORM_BROWSER_STATEMENT          *Statement\r
+  );\r
 \r
 /**\r
   Find the matched FormSet context in the backup maintain list based on HiiHandle.\r
index f3019a84084b2a5d261ff522d75c7cb011061198..1b39ed7f2acdc7e157369142cd8cf051e9879513 100644 (file)
@@ -3809,7 +3809,7 @@ UiDisplayMenu (
       // Reterieve default setting. After it. NV flag will be showed.\r
       //\r
       if ((HotKey->Action & BROWSER_ACTION_DEFAULT) == BROWSER_ACTION_DEFAULT) {\r
-        Status = ExtractDefault (Selection->FormSet, Selection->Form, HotKey->DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL);\r
+        Status = ExtractDefault (Selection->FormSet, Selection->Form, HotKey->DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL, FALSE);\r
         if (!EFI_ERROR (Status)) {\r
           Selection->Action = UI_ACTION_REFRESH_FORM;\r
           Selection->Statement = NULL;\r
@@ -3887,7 +3887,7 @@ UiDisplayMenu (
       //\r
       // Reset to default value for all forms in the whole system.\r
       //\r
-      Status = ExtractDefault (Selection->FormSet, NULL, DefaultId, FormSetLevel, GetDefaultForAll, NULL);\r
+      Status = ExtractDefault (Selection->FormSet, NULL, DefaultId, FormSetLevel, GetDefaultForAll, NULL, FALSE);\r
 \r
       if (!EFI_ERROR (Status)) {\r
         Selection->Action = UI_ACTION_REFRESH_FORM;\r