]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
Fix AutoUpdateLangVariable() logic to handle the case PlatformLang/Lang is set before...
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Setup.c
index ab98ada1c800838aab73f023e208677e5502d28b..740ee50d0b82a3a29c8db96d77ae1242b71f6bac 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
 Entry and initialization module for the browser.\r
 \r
-Copyright (c) 2007 - 2010, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -269,7 +269,8 @@ SendForm (
 \r
   gOptionBlockWidth = (CHAR16) ((gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3);\r
   gHelpBlockWidth   = gOptionBlockWidth;\r
-  gPromptBlockWidth = gOptionBlockWidth;\r
+  gPromptBlockWidth = (CHAR16) (gOptionBlockWidth + LEFT_SKIPPED_COLUMNS);\r
+  gOptionBlockWidth = (CHAR16) (gOptionBlockWidth - LEFT_SKIPPED_COLUMNS);\r
 \r
   //\r
   // Initialize the strings for the browser, upon exit of the browser, the strings will be freed\r
@@ -661,6 +662,10 @@ GetToken (
 {\r
   EFI_STRING  String;\r
 \r
+  if (HiiHandle == NULL) {\r
+    return NULL;\r
+  }\r
+\r
   String = HiiGetString (HiiHandle, Token, NULL);\r
   if (String == NULL) {\r
     String = AllocateCopyPool (sizeof (mUnknownString), mUnknownString);\r
@@ -1041,6 +1046,20 @@ GetQuestionValue (
     }\r
     return Status;\r
   }\r
+  \r
+  //\r
+  // Get question value by read expression.\r
+  //\r
+  if (Question->ReadExpression != NULL && Form->FormType == STANDARD_MAP_FORM_TYPE) {\r
+    Status = EvaluateExpression (FormSet, Form, Question->ReadExpression);\r
+    if (!EFI_ERROR (Status) && (Question->ReadExpression->Result.Type < EFI_IFR_TYPE_OTHER)) {\r
+      //\r
+      // Only update question value to the valid result.\r
+      //\r
+      CopyMem (&Question->HiiValue, &Question->ReadExpression->Result, sizeof (EFI_HII_VALUE));\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
 \r
   //\r
   // Question value is provided by RTC\r
@@ -1138,11 +1157,13 @@ GetQuestionValue (
       //\r
       CopyMem (Dst, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth);\r
     } else {\r
+      Value = NULL;\r
       Status = GetValueByName (Storage, Question->VariableName, &Value);\r
       if (EFI_ERROR (Status)) {\r
         return Status;\r
       }\r
 \r
+      ASSERT (Value != NULL);\r
       LengthStr = StrLen (Value);\r
       Status    = EFI_SUCCESS;\r
       if (IsString) {\r
@@ -1367,6 +1388,16 @@ SetQuestionValue (
   if (Question->ValueExpression != NULL) {\r
     return Status;\r
   }\r
+  \r
+  //\r
+  // Before set question value, evaluate its write expression.\r
+  //\r
+  if (Question->WriteExpression != NULL && Form->FormType == STANDARD_MAP_FORM_TYPE) {\r
+    Status = EvaluateExpression (FormSet, Form, Question->WriteExpression);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
 \r
   //\r
   // Question value is provided by RTC\r
@@ -1649,10 +1680,9 @@ ValidateQuestion (
 \r
 \r
 /**\r
-  Perform NoSubmit check for a Form.\r
+  Perform NoSubmit check for each Form in FormSet.\r
 \r
   @param  FormSet                FormSet data structure.\r
-  @param  Form                   Form data structure.\r
 \r
   @retval EFI_SUCCESS            Form validation pass.\r
   @retval other                  Form validation failed.\r
@@ -1660,24 +1690,32 @@ ValidateQuestion (
 **/\r
 EFI_STATUS\r
 NoSubmitCheck (\r
-  IN  FORM_BROWSER_FORMSET            *FormSet,\r
-  IN  FORM_BROWSER_FORM               *Form\r
+  IN  FORM_BROWSER_FORMSET            *FormSet\r
   )\r
 {\r
   EFI_STATUS              Status;\r
   LIST_ENTRY              *Link;\r
   FORM_BROWSER_STATEMENT  *Question;\r
+  FORM_BROWSER_FORM       *Form;\r
+  LIST_ENTRY              *LinkForm;\r
 \r
-  Link = GetFirstNode (&Form->StatementListHead);\r
-  while (!IsNull (&Form->StatementListHead, Link)) {\r
-    Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);\r
+  LinkForm = GetFirstNode (&FormSet->FormListHead);\r
+  while (!IsNull (&FormSet->FormListHead, LinkForm)) {\r
+    Form = FORM_BROWSER_FORM_FROM_LINK (LinkForm);\r
 \r
-    Status = ValidateQuestion (FormSet, Form, Question, EFI_HII_EXPRESSION_NO_SUBMIT_IF);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
+    Link = GetFirstNode (&Form->StatementListHead);\r
+    while (!IsNull (&Form->StatementListHead, Link)) {\r
+      Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);\r
+\r
+      Status = ValidateQuestion (FormSet, Form, Question, EFI_HII_EXPRESSION_NO_SUBMIT_IF);\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+\r
+      Link = GetNextNode (&Form->StatementListHead, Link);\r
     }\r
 \r
-    Link = GetNextNode (&Form->StatementListHead, Link);\r
+    LinkForm = GetNextNode (&FormSet->FormListHead, LinkForm);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -1708,7 +1746,7 @@ SubmitForm (
   //\r
   // Validate the Form by NoSubmit check\r
   //\r
-  Status = NoSubmitCheck (FormSet, Form);\r
+  Status = NoSubmitCheck (FormSet);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -2043,15 +2081,13 @@ LoadFormConfig (
     //\r
     // Check whether EfiVarstore with CallBack can be got.\r
     //\r
-    if ((Question->QuestionId != 0) && (Question->Storage != NULL) &&\r
+    if ((FormSet->ConfigAccess != 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
         ((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
       //\r
       // Check QuestionValue does exist.\r
       //\r