]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
Enhance SetupBrowser to support new UEFI HiiFormMap feature
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Setup.c
index 81de737a03a9301671f49c19b6f0edb51c6253af..d50071e5506215c299a2b8506824ca3ca9ad172f 100644 (file)
@@ -661,6 +661,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 +1045,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
@@ -1369,6 +1387,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