Invoke EFI_BROWSER_ACTION_RETRIEVE callback when read EfiVarstore question.
authorlgao4 <lgao4@de2fecce-e211-0410-80a6-f3fac2684e05>
Fri, 13 Nov 2009 06:46:59 +0000 (06:46 +0000)
committerlgao4 <lgao4@de2fecce-e211-0410-80a6-f3fac2684e05>
Fri, 13 Nov 2009 06:46:59 +0000 (06:46 +0000)
git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@9425 de2fecce-e211-0410-80a6-f3fac2684e05

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

index 3f81032..08e830b 100644 (file)
@@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include "Ui.h"\r
 #include "Setup.h"\r
 \r
 //\r
index 7f6ff67..c0b2de7 100644 (file)
@@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 #include "Setup.h"\r
-#include "Ui.h"\r
 \r
 UINT16           mStatementIndex;\r
 UINT16           mExpressionOpCodeIndex;\r
index 1a8af2e..3e7979f 100644 (file)
@@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include "Ui.h"\r
 #include "Setup.h"\r
 \r
 \r
index c880c8a..69c0496 100644 (file)
@@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 #include "Setup.h"\r
-#include "Ui.h"\r
 \r
 BOOLEAN            mHiiPackageListUpdated;\r
 UI_MENU_SELECTION  *gCurrentSelection;\r
@@ -982,14 +981,28 @@ SetupBrowser (
       }\r
     }\r
     \r
+    //\r
+    // Reset FormPackage update flag\r
+    //\r
+    mHiiPackageListUpdated = FALSE;\r
+\r
     //\r
     // Load Questions' Value for display\r
     //\r
-    Status = LoadFormSetConfig (Selection->FormSet);\r
+    Status = LoadFormSetConfig (Selection, Selection->FormSet);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
 \r
+    //\r
+    // IFR is updated during callback of read value, force to reparse the IFR binary\r
+    //\r
+    if (mHiiPackageListUpdated) {\r
+      Selection->Action = UI_ACTION_REFRESH_FORMSET;\r
+      mHiiPackageListUpdated = FALSE;\r
+      goto Done;\r
+    }\r
+\r
     //\r
     // Displays the Header and Footer borders\r
     //\r
index cebe126..639c04d 100644 (file)
@@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include "Ui.h"\r
 #include "Setup.h"\r
 \r
 \r
index 0bc2d1b..f52e69c 100644 (file)
@@ -13,8 +13,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 #include "Setup.h"\r
-#include "Ui.h"\r
-\r
 \r
 SETUP_DRIVER_PRIVATE_DATA  mPrivateData = {\r
   SETUP_DRIVER_SIGNATURE,\r
@@ -2000,10 +1998,12 @@ ExtractFormDefault (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Initialize Question's Edit copy from Storage.\r
 \r
+  @param  Selection              Selection contains the information about \r
+                                 the Selection, form and formset to be displayed.\r
+                                 Selection action may be updated in retrieve callback.\r
   @param  FormSet                FormSet data structure.\r
   @param  Form                   Form data structure.\r
 \r
@@ -2012,14 +2012,19 @@ ExtractFormDefault (
 **/\r
 EFI_STATUS\r
 LoadFormConfig (\r
-  IN FORM_BROWSER_FORMSET             *FormSet,\r
-  IN FORM_BROWSER_FORM                *Form\r
+  IN OUT UI_MENU_SELECTION    *Selection,\r
+  IN FORM_BROWSER_FORMSET     *FormSet,\r
+  IN FORM_BROWSER_FORM        *Form\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
-  LIST_ENTRY              *Link;\r
-  FORM_BROWSER_STATEMENT  *Question;\r
-\r
+  EFI_STATUS                  Status;\r
+  LIST_ENTRY                  *Link;\r
+  FORM_BROWSER_STATEMENT      *Question;\r
+  UINT8                       *BufferValue;\r
+  UINTN                       StorageWidth;\r
+  EFI_HII_VALUE               *HiiValue;\r
+  EFI_BROWSER_ACTION_REQUEST  ActionRequest;\r
+  \r
   Link = GetFirstNode (&Form->StatementListHead);\r
   while (!IsNull (&Form->StatementListHead, Link)) {\r
     Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);\r
@@ -2031,6 +2036,87 @@ LoadFormConfig (
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
+    \r
+    //\r
+    // Check whether EfiVarstore with CallBack can be got.\r
+    //\r
+    if ((Question->QuestionId != 0) && (Question->Storage != NULL) &&\r
+        (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) && \r
+        ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK)) {\r
+      //\r
+      // ConfigAccess can't be NULL.\r
+      //\r
+      if (FormSet->ConfigAccess == NULL) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+      //\r
+      // Check QuestionValue does exist.\r
+      //\r
+      StorageWidth = Question->StorageWidth;\r
+      if (Question->BufferValue != NULL) {\r
+        BufferValue  = Question->BufferValue;\r
+      } 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
+        ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
+        HiiValue = &Question->HiiValue;\r
+        BufferValue = (UINT8 *) &Question->HiiValue.Value;\r
+        if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
+          //\r
+          // Create String in HII database for Configuration Driver to retrieve\r
+          //\r
+          HiiValue->Value.string = NewString ((CHAR16 *) Question->BufferValue, FormSet->HiiHandle);\r
+        } else if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {\r
+          BufferValue = Question->BufferValue;\r
+        }\r
+\r
+        Status = FormSet->ConfigAccess->Callback (\r
+                                 FormSet->ConfigAccess,\r
+                                 EFI_BROWSER_ACTION_RETRIEVE,\r
+                                 Question->QuestionId,\r
+                                 HiiValue->Type,\r
+                                 (EFI_IFR_TYPE_VALUE *) BufferValue,\r
+                                 &ActionRequest\r
+                                 );\r
+\r
+        if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
+          //\r
+          // Clean the String in HII Database\r
+          //\r
+          DeleteString (HiiValue->Value.string, FormSet->HiiHandle);\r
+        }\r
+\r
+        if (!EFI_ERROR (Status)) {\r
+          switch (ActionRequest) {\r
+          case EFI_BROWSER_ACTION_REQUEST_RESET:\r
+            gResetRequired = TRUE;\r
+            break;\r
+\r
+          case EFI_BROWSER_ACTION_REQUEST_SUBMIT:\r
+            //\r
+            // Till now there is no uncommitted data, so ignore this request\r
+            //\r
+            break;\r
+\r
+          case EFI_BROWSER_ACTION_REQUEST_EXIT:\r
+            Selection->Action = UI_ACTION_EXIT;\r
+            break;\r
+\r
+          default:\r
+            break;\r
+          }\r
+        }\r
+      }\r
+    }\r
 \r
     Link = GetNextNode (&Form->StatementListHead, Link);\r
   }\r
@@ -2038,10 +2124,12 @@ LoadFormConfig (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Initialize Question's Edit copy from Storage for the whole Formset.\r
 \r
+  @param  Selection              Selection contains the information about \r
+                                 the Selection, form and formset to be displayed.\r
+                                 Selection action may be updated in retrieve callback.\r
   @param  FormSet                FormSet data structure.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
@@ -2049,12 +2137,13 @@ LoadFormConfig (
 **/\r
 EFI_STATUS\r
 LoadFormSetConfig (\r
-  IN FORM_BROWSER_FORMSET             *FormSet\r
+  IN OUT UI_MENU_SELECTION    *Selection,\r
+  IN     FORM_BROWSER_FORMSET *FormSet\r
   )\r
 {\r
-  EFI_STATUS          Status;\r
-  LIST_ENTRY          *Link;\r
-  FORM_BROWSER_FORM   *Form;\r
+  EFI_STATUS            Status;\r
+  LIST_ENTRY            *Link;\r
+  FORM_BROWSER_FORM     *Form;\r
 \r
   Link = GetFirstNode (&FormSet->FormListHead);\r
   while (!IsNull (&FormSet->FormListHead, Link)) {\r
@@ -2063,7 +2152,7 @@ LoadFormSetConfig (
     //\r
     // Initialize local copy of Value for each Form\r
     //\r
-    Status = LoadFormConfig (FormSet, Form);\r
+    Status = LoadFormConfig (Selection, FormSet, Form);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
@@ -2074,7 +2163,6 @@ LoadFormSetConfig (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Fill storage's edit copy with settings requested from Configuration Driver.\r
 \r
index 310d3e6..a55195d 100644 (file)
@@ -561,6 +561,7 @@ extern CHAR16            gHelpBlockWidth;
 extern EFI_GUID          gZeroGuid;\r
 extern EFI_GUID          gTianoHiiIfrGuid;\r
 \r
+#include "Ui.h"\r
 //\r
 // Global Procedure Defines\r
 //\r
@@ -938,6 +939,9 @@ ExtractFormDefault (
 /**\r
   Initialize Question's Edit copy from Storage.\r
 \r
+  @param  Selection              Selection contains the information about \r
+                                 the Selection, form and formset to be displayed.\r
+                                 Selection action may be updated in retrieve callback.\r
   @param  FormSet                FormSet data structure.\r
   @param  Form                   Form data structure.\r
 \r
@@ -946,13 +950,17 @@ ExtractFormDefault (
 **/\r
 EFI_STATUS\r
 LoadFormConfig (\r
-  IN FORM_BROWSER_FORMSET             *FormSet,\r
-  IN FORM_BROWSER_FORM                *Form\r
+  IN OUT UI_MENU_SELECTION    *Selection,\r
+  IN FORM_BROWSER_FORMSET     *FormSet,\r
+  IN FORM_BROWSER_FORM        *Form\r
   );\r
 \r
 /**\r
   Initialize Question's Edit copy from Storage for the whole Formset.\r
 \r
+  @param  Selection              Selection contains the information about \r
+                                 the Selection, form and formset to be displayed.\r
+                                 Selection action may be updated in retrieve callback.\r
   @param  FormSet                FormSet data structure.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
@@ -960,7 +968,8 @@ LoadFormConfig (
 **/\r
 EFI_STATUS\r
 LoadFormSetConfig (\r
-  IN FORM_BROWSER_FORMSET             *FormSet\r
+  IN OUT UI_MENU_SELECTION    *Selection,\r
+  IN     FORM_BROWSER_FORMSET *FormSet\r
   );\r
 \r
 /**\r
index 5deb301..5b1f361 100644 (file)
@@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include "Ui.h"\r
 #include "Setup.h"\r
 \r
 LIST_ENTRY          gMenuOption;\r
index 44cae88..bd75714 100644 (file)
@@ -15,8 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _UI_H_\r
 #define _UI_H_\r
 \r
-#include "Setup.h"\r
-\r
 //\r
 // Globals\r
 //\r