]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
Update Base type SecPeiDxeTimerLibUefiCpu to support all module type.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Expression.c
index 90fdc7462ffa17dfab6f7c41ce3615c5c1b0d02c..60a23f1822e450778d6305cbe7df6e1612f98639 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
 Utility functions for expression evaluation.\r
 \r
-Copyright (c) 2007 - 2010, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007 - 2011, 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
@@ -1528,7 +1528,7 @@ CheckUserPrivilege (
     RemainSize = UserInfo->InfoSize - sizeof (EFI_USER_INFO);\r
     AccessControl = (EFI_USER_INFO_ACCESS_CONTROL *)(UserInfo + 1);\r
     while (RemainSize >= sizeof (EFI_USER_INFO_ACCESS_CONTROL)) {\r
-      if (RemainSize < AccessControl->Size || AccessControl->Size <= sizeof (EFI_USER_INFO_ACCESS_CONTROL)) {\r
+      if (RemainSize < AccessControl->Size || AccessControl->Size < sizeof (EFI_USER_INFO_ACCESS_CONTROL)) {\r
         break;\r
       }\r
       if (AccessControl->Type == EFI_USER_INFO_ACCESS_SETUP) {\r
@@ -1716,6 +1716,7 @@ EvaluateExpression (
       if (OpCode->VarStorage != NULL) {\r
         switch (OpCode->VarStorage->Type) {\r
         case EFI_HII_VARSTORE_BUFFER:\r
+        case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:\r
           //\r
           // Get value from Edit Buffer\r
           //\r
@@ -1729,6 +1730,7 @@ EvaluateExpression (
             //\r
             Status = GetValueByName (OpCode->VarStorage, OpCode->ValueName, &StrPtr);\r
             if (!EFI_ERROR (Status)) {\r
+              ASSERT (StrPtr != NULL);\r
               TempLength = StrLen (StrPtr);\r
               if (OpCode->ValueWidth >= ((TempLength + 1) / 2)) {\r
                 Value->Type = OpCode->ValueType;\r
@@ -1740,7 +1742,7 @@ EvaluateExpression (
                   if ((Index & 1) == 0) {\r
                     TempBuffer [Index/2] = DigitUint8;\r
                   } else {\r
-                    TempBuffer [Index/2] = (UINT8) ((DigitUint8 << 4) + TempStr [Index/2]);\r
+                    TempBuffer [Index/2] = (UINT8) ((DigitUint8 << 4) + TempBuffer [Index/2]);\r
                   }\r
                 }\r
               }                \r
@@ -1764,6 +1766,7 @@ EvaluateExpression (
             Value->Type = EFI_IFR_TYPE_UNDEFINED;\r
             Value->Value.u8 = 0;\r
           }\r
+          break;\r
         default:\r
           //\r
           // Not recognize storage.\r
@@ -2031,18 +2034,23 @@ EvaluateExpression (
         //\r
         // When converting from a string, if case-insensitive compare\r
         // with "true" is True, then push True. If a case-insensitive compare\r
-        // with "false" is True, then push False.\r
+        // with "false" is True, then push False. Otherwise, push Undefined. \r
         //\r
         StrPtr = GetToken (Value->Value.string, FormSet->HiiHandle);\r
         if (StrPtr == NULL) {\r
           Status = EFI_INVALID_PARAMETER;\r
           goto Done;\r
         }\r
-\r
-        if ((StrCmp (StrPtr, L"true") == 0) || (StrCmp (StrPtr, L"false") == 0)){\r
+        \r
+        IfrStrToUpper (StrPtr);\r
+        if (StrCmp (StrPtr, L"TRUE") == 0){\r
           Value->Value.b = TRUE;\r
-        } else {\r
+        } else if (StrCmp (StrPtr, L"FALSE") == 0) {\r
           Value->Value.b = FALSE;\r
+        } else {\r
+          Status = EFI_INVALID_PARAMETER;\r
+          FreePool (StrPtr);\r
+          goto Done;\r
         }\r
         FreePool (StrPtr);\r
         Value->Type = EFI_IFR_TYPE_BOOLEAN;\r
@@ -2122,6 +2130,7 @@ EvaluateExpression (
       if (OpCode->VarStorage != NULL) {\r
         switch (OpCode->VarStorage->Type) {\r
         case EFI_HII_VARSTORE_BUFFER:\r
+        case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:\r
           CopyMem (OpCode->VarStorage->EditBuffer + OpCode->VarStoreInfo.VarOffset, &Value->Value, OpCode->ValueWidth);\r
           Data1.Value.b = TRUE;\r
           break;\r
@@ -2137,7 +2146,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);\r
+            Status = SetValueByName (OpCode->VarStorage, OpCode->ValueName, NameValue, TRUE);\r
             FreePool (NameValue);\r
             if (!EFI_ERROR (Status)) {\r
               Data1.Value.b = TRUE;\r