]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
Fix GCC build fail.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / IfrParse.c
index ed06f1c9cd0811706a8e4ca51cd7a9ce3eb78959..e806b504b2934fdc4079d02b928dd862f48db7ca 100644 (file)
@@ -286,13 +286,15 @@ CreateQuestion (
   Allocate a FORM_EXPRESSION node.\r
 \r
   @param  Form                   The Form associated with this Expression\r
+  @param  OpCode                 The binary opcode data.\r
 \r
   @return Pointer to a FORM_EXPRESSION data structure.\r
 \r
 **/\r
 FORM_EXPRESSION *\r
 CreateExpression (\r
-  IN OUT FORM_BROWSER_FORM        *Form\r
+  IN OUT FORM_BROWSER_FORM        *Form,\r
+  IN     UINT8                    *OpCode\r
   )\r
 {\r
   FORM_EXPRESSION  *Expression;\r
@@ -301,6 +303,7 @@ CreateExpression (
   ASSERT (Expression != NULL);\r
   Expression->Signature = FORM_EXPRESSION_SIGNATURE;\r
   InitializeListHead (&Expression->OpCodeListHead);\r
+  Expression->OpCode = (EFI_IFR_OP_HEADER *) OpCode;\r
 \r
   return Expression;\r
 }\r
@@ -1070,6 +1073,23 @@ IsStatementOpCode (
   }\r
 }\r
 \r
+/**\r
+  Tell whether this Operand is an known OpCode.\r
+\r
+  @param  Operand                Operand of an IFR OpCode.\r
+\r
+  @retval TRUE                   This is an Statement OpCode.\r
+  @retval FALSE                  Not an Statement OpCode.\r
+\r
+**/\r
+BOOLEAN\r
+IsUnKnownOpCode (\r
+  IN UINT8              Operand\r
+  )\r
+{\r
+  return Operand > EFI_IFR_WARNING_IF_OP ? TRUE : FALSE;\r
+}\r
+\r
 /**\r
   Calculate number of Statemens(Questions) and Expression OpCodes.\r
 \r
@@ -1162,6 +1182,8 @@ ParseOpCodes (
   EFI_VARSTORE_ID         TempVarstoreId;\r
   BOOLEAN                 InScopeDisable;\r
   INTN                    ConditionalExprCount;\r
+  BOOLEAN                 InUnknownScope;\r
+  UINT8                   UnknownDepth;\r
 \r
   SuppressForQuestion      = FALSE;\r
   SuppressForOption        = FALSE;\r
@@ -1181,6 +1203,8 @@ ParseOpCodes (
   MapExpressionList        = NULL;\r
   TempVarstoreId           = 0;\r
   ConditionalExprCount     = 0;\r
+  InUnknownScope           = FALSE;\r
+  UnknownDepth             = 0;\r
 \r
   //\r
   // Get the number of Statements and Expressions\r
@@ -1223,6 +1247,31 @@ ParseOpCodes (
     Operand = ((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode;\r
     Scope = ((EFI_IFR_OP_HEADER *) OpCodeData)->Scope;\r
 \r
+    if (InUnknownScope) {\r
+      if (Operand == EFI_IFR_END_OP) {\r
+        UnknownDepth --;\r
+\r
+        if (UnknownDepth == 0) {\r
+          InUnknownScope = FALSE;\r
+        }\r
+      } else {\r
+        if (Scope != 0) {\r
+          UnknownDepth ++;\r
+        }\r
+      }\r
+\r
+      continue;\r
+    }\r
+\r
+    if (IsUnKnownOpCode(Operand)) {\r
+      if (Scope != 0) {\r
+        InUnknownScope = TRUE;\r
+        UnknownDepth ++;\r
+      }\r
+\r
+      continue;\r
+    }\r
+\r
     //\r
     // If scope bit set, push onto scope stack\r
     //\r
@@ -1466,7 +1515,7 @@ ParseOpCodes (
       // Create sub expression nested in MAP opcode\r
       //\r
       if (CurrentExpression == NULL && MapScopeDepth > 0) {\r
-        CurrentExpression = CreateExpression (CurrentForm);\r
+        CurrentExpression = CreateExpression (CurrentForm, OpCodeData);\r
         ASSERT (MapExpressionList != NULL);\r
         InsertTailList (MapExpressionList, &CurrentExpression->Link);\r
         if (Scope == 0) {\r
@@ -1510,11 +1559,7 @@ ParseOpCodes (
             return Status;\r
           }\r
 \r
-          if (CurrentExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN) {\r
-            return EFI_INVALID_PARAMETER;\r
-          }\r
-\r
-          OpCodeDisabled = CurrentExpression->Result.Value.b;\r
+          OpCodeDisabled = IsTrue(&CurrentExpression->Result);\r
         }\r
 \r
         CurrentExpression = NULL;\r
@@ -2048,7 +2093,7 @@ ParseOpCodes (
       //\r
       // Create an Expression node\r
       //\r
-      CurrentExpression = CreateExpression (CurrentForm);\r
+      CurrentExpression = CreateExpression (CurrentForm, OpCodeData);\r
       CopyMem (&CurrentExpression->Error, &((EFI_IFR_INCONSISTENT_IF *) OpCodeData)->Error, sizeof (EFI_STRING_ID));\r
 \r
       if (Operand == EFI_IFR_NO_SUBMIT_IF_OP) {\r
@@ -2072,7 +2117,7 @@ ParseOpCodes (
       //\r
       // Create an Expression node\r
       //\r
-      CurrentExpression = CreateExpression (CurrentForm);\r
+      CurrentExpression = CreateExpression (CurrentForm, OpCodeData);\r
       CopyMem (&CurrentExpression->Error, &((EFI_IFR_WARNING_IF *) OpCodeData)->Warning, sizeof (EFI_STRING_ID));\r
       CurrentExpression->TimeOut = ((EFI_IFR_WARNING_IF *) OpCodeData)->TimeOut;\r
       CurrentExpression->Type    = EFI_HII_EXPRESSION_WARNING_IF;\r
@@ -2091,7 +2136,7 @@ ParseOpCodes (
       //\r
       // Question and Option will appear in scope of this OpCode\r
       //\r
-      CurrentExpression = CreateExpression (CurrentForm);\r
+      CurrentExpression = CreateExpression (CurrentForm, OpCodeData);\r
       CurrentExpression->Type = EFI_HII_EXPRESSION_SUPPRESS_IF;\r
 \r
       if (CurrentForm == NULL) {\r
@@ -2121,7 +2166,7 @@ ParseOpCodes (
       //\r
       // Questions will appear in scope of this OpCode\r
       //\r
-      CurrentExpression = CreateExpression (CurrentForm);\r
+      CurrentExpression = CreateExpression (CurrentForm, OpCodeData);\r
       CurrentExpression->Type = EFI_HII_EXPRESSION_GRAY_OUT_IF;\r
       InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);\r
       PushConditionalExpression(CurrentExpression, ExpressStatement);\r
@@ -2169,7 +2214,7 @@ ParseOpCodes (
     // Expression\r
     //\r
     case EFI_IFR_VALUE_OP:\r
-      CurrentExpression = CreateExpression (CurrentForm);\r
+      CurrentExpression = CreateExpression (CurrentForm, OpCodeData);\r
       CurrentExpression->Type = EFI_HII_EXPRESSION_VALUE;\r
       InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);\r
 \r
@@ -2201,7 +2246,7 @@ ParseOpCodes (
       break;\r
 \r
     case EFI_IFR_RULE_OP:\r
-      CurrentExpression = CreateExpression (CurrentForm);\r
+      CurrentExpression = CreateExpression (CurrentForm, OpCodeData);\r
       CurrentExpression->Type = EFI_HII_EXPRESSION_RULE;\r
 \r
       CurrentExpression->RuleId = ((EFI_IFR_RULE *) OpCodeData)->RuleId;\r
@@ -2217,7 +2262,7 @@ ParseOpCodes (
       break;\r
 \r
     case EFI_IFR_READ_OP:\r
-      CurrentExpression = CreateExpression (CurrentForm);\r
+      CurrentExpression = CreateExpression (CurrentForm, OpCodeData);\r
       CurrentExpression->Type = EFI_HII_EXPRESSION_READ;\r
       InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);\r
 \r
@@ -2239,7 +2284,7 @@ ParseOpCodes (
       break;\r
 \r
     case EFI_IFR_WRITE_OP:\r
-      CurrentExpression = CreateExpression (CurrentForm);\r
+      CurrentExpression = CreateExpression (CurrentForm, OpCodeData);\r
       CurrentExpression->Type = EFI_HII_EXPRESSION_WRITE;\r
       InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);\r
 \r
@@ -2366,7 +2411,7 @@ ParseOpCodes (
       //\r
       // Parent statement end tag found, update ParentStatement info.\r
       //\r
-      if (IsStatementOpCode(ScopeOpCode) && ParentStatement->Operand == ScopeOpCode) {\r
+      if (IsStatementOpCode(ScopeOpCode) && (ParentStatement != NULL) && (ParentStatement->Operand == ScopeOpCode)) {\r
         ParentStatement  = ParentStatement->ParentStatement;\r
       }\r
 \r
@@ -2463,11 +2508,8 @@ ParseOpCodes (
               return Status;\r
             }\r
 \r
-            if (CurrentExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN) {\r
-              return EFI_INVALID_PARAMETER;\r
-            }\r
+            OpCodeDisabled = IsTrue (&CurrentExpression->Result);\r
 \r
-            OpCodeDisabled = CurrentExpression->Result.Value.b;\r
             //\r
             // DisableIf Expression is only used once and not queued, free it\r
             //\r