]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
Update the logic, based on the device path and formset guid to find the HiiHandle.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Expression.c
index 1a47f2b0a901c063f46e6dc3a9edc829113b02ab..e717196dd4a29b33218cc0dac43c75640680bcfe 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Utility functions for expression evaluation.\r
 \r
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2013, 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
@@ -787,7 +787,7 @@ FORM_BROWSER_FORM *
 IdToForm (\r
   IN FORM_BROWSER_FORMSET  *FormSet,\r
   IN UINT16                FormId\r
-)\r
+  )\r
 {\r
   LIST_ENTRY         *Link;\r
   FORM_BROWSER_FORM  *Form;\r
@@ -1446,7 +1446,6 @@ IfrMid (
   UINTN          Base;\r
   UINTN          Length;\r
   CHAR16         *SubString;\r
-  UINT8          *Buffer;\r
   UINT16         BufferLen;\r
 \r
   ZeroMem (Value, sizeof (Value));\r
@@ -1502,7 +1501,6 @@ IfrMid (
 \r
     FreePool (String);\r
   } else {\r
-    Buffer    = Value[2].Buffer;\r
     BufferLen = Value[2].BufferLen;\r
     \r
     Result->Type = EFI_IFR_TYPE_BUFFER;\r
@@ -2038,11 +2036,7 @@ GetQuestionValueFromForm (
   )\r
 {\r
   EFI_STATUS                   Status;\r
-  EFI_HANDLE                   DriverHandle;\r
-  EFI_HANDLE                   Handle;\r
-  EFI_HII_HANDLE               *HiiHandles;\r
   EFI_HII_HANDLE               HiiHandle;\r
-  UINTN                        Index;\r
   FORM_BROWSER_STATEMENT       *Question;\r
   FORM_BROWSER_FORMSET         *FormSet;\r
   FORM_BROWSER_FORM            *Form;\r
@@ -2056,7 +2050,6 @@ GetQuestionValueFromForm (
           (DevicePath == NULL && InputHiiHandle != NULL) );\r
 \r
   GetTheVal    = TRUE;\r
-  DriverHandle = NULL;\r
   HiiHandle    = NULL;\r
   Question     = NULL;\r
   Form         = NULL;\r
@@ -2065,38 +2058,10 @@ GetQuestionValueFromForm (
   // Get HiiHandle.\r
   //\r
   if (DevicePath != NULL) {\r
-    //\r
-    // 1. Get Driver handle.\r
-    //\r
-    Status = gBS->LocateDevicePath (\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    &DevicePath,\r
-                    &DriverHandle\r
-                    );\r
-    if (EFI_ERROR (Status) || (DriverHandle == NULL)) {\r
+    HiiHandle = DevicePathToHiiHandle (DevicePath, FormSetGuid);\r
+    if (HiiHandle == NULL) {\r
       return FALSE;\r
     }\r
-\r
-    //\r
-    // 2. Get Hii handle\r
-    //\r
-    HiiHandles = HiiGetHiiHandles (NULL);\r
-    if (HiiHandles == NULL) {\r
-      return FALSE;\r
-    }\r
-\r
-    for (Index = 0; HiiHandles[Index] != NULL; Index++) {\r
-      Status = mHiiDatabase->GetPackageListHandle (\r
-                               mHiiDatabase,\r
-                               HiiHandles[Index],\r
-                               &Handle\r
-                               );\r
-      if (!EFI_ERROR (Status) && (Handle == DriverHandle)) {\r
-        HiiHandle = HiiHandles[Index];\r
-        break;\r
-      }\r
-    }\r
-    FreePool (HiiHandles);\r
   } else {\r
     HiiHandle = InputHiiHandle;\r
   } \r
@@ -2107,7 +2072,7 @@ GetQuestionValueFromForm (
   //\r
   FormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET));\r
   ASSERT (FormSet != NULL);\r
-  Status = InitializeFormSet(HiiHandle, FormSetGuid, FormSet, FALSE);\r
+  Status = InitializeFormSet(HiiHandle, FormSetGuid, FormSet);\r
   if (EFI_ERROR (Status)) {\r
     GetTheVal = FALSE;\r
     goto Done;\r
@@ -2470,22 +2435,21 @@ EvaluateExpression (
       }\r
 \r
       if (OpCode->DevicePath != 0) {\r
-        StrPtr = GetToken (OpCode->DevicePath, FormSet->HiiHandle);\r
-        if (StrPtr == NULL) {\r
-          Value->Type = EFI_IFR_TYPE_UNDEFINED;\r
-          break;\r
-        }\r
-\r
-        DevicePath = ConvertDevicePathFromText(StrPtr);\r
+        Value->Type = EFI_IFR_TYPE_UNDEFINED;\r
 \r
-        if (!GetQuestionValueFromForm(DevicePath, NULL, &OpCode->Guid, Value->Value.u16, &QuestionVal)){\r
-          Value->Type = EFI_IFR_TYPE_UNDEFINED;\r
-        } else {\r
-          Value = &QuestionVal;\r
+        StrPtr = GetToken (OpCode->DevicePath, FormSet->HiiHandle);\r
+        if (StrPtr != NULL && mPathFromText != NULL) {\r
+          DevicePath = mPathFromText->ConvertTextToDevicePath(StrPtr);\r
+          if (DevicePath != NULL && GetQuestionValueFromForm(DevicePath, NULL, &OpCode->Guid, Value->Value.u16, &QuestionVal)) {\r
+            Value = &QuestionVal;\r
+          }\r
+          if (DevicePath != NULL) {\r
+            FreePool (DevicePath);\r
+          }\r
         }\r
 \r
-        if (DevicePath != NULL) {\r
-          FreePool (DevicePath);\r
+        if (StrPtr != NULL) {\r
+          FreePool (StrPtr);\r
         }\r
       } else if (CompareGuid (&OpCode->Guid, &gZeroGuid) != 0) {\r
         if (!GetQuestionValueFromForm(NULL, FormSet->HiiHandle, &OpCode->Guid, Value->Value.u16, &QuestionVal)){\r
@@ -2803,7 +2767,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, GetSetValueWithEditBuffer);\r
+            Status = SetValueByName (OpCode->VarStorage, OpCode->ValueName, NameValue, GetSetValueWithEditBuffer, NULL);\r
             FreePool (NameValue);\r
             if (!EFI_ERROR (Status)) {\r
               Data1.Value.b = TRUE;\r