]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
Update the HiiConfigToBlock to follow spec.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / IfrParse.c
index 564a246a1b1c5e4b3ca2b60c635fb668964b532c..7221c42fa3110db8d7c69c4b1ad2394c42a00620 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Parser for IFR binary encoding.\r
 \r
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2012, 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
@@ -18,13 +18,6 @@ UINT16           mStatementIndex;
 UINT16           mExpressionOpCodeIndex;\r
 \r
 BOOLEAN          mInScopeSubtitle;\r
-BOOLEAN          mInScopeSuppress;\r
-BOOLEAN          mInScopeGrayOut;\r
-BOOLEAN          mInScopeDisable;\r
-FORM_EXPRESSION  *mSuppressExpression;\r
-FORM_EXPRESSION  *mGrayOutExpression;\r
-FORM_EXPRESSION  *mDisableExpression;\r
-\r
 /**\r
   Initialize Statement header members.\r
 \r
@@ -44,6 +37,7 @@ CreateStatement (
 {\r
   FORM_BROWSER_STATEMENT    *Statement;\r
   EFI_IFR_STATEMENT_HEADER  *StatementHdr;\r
+  INTN                      ConditionalExprCount; \r
 \r
   if (Form == NULL) {\r
     //\r
@@ -68,17 +62,18 @@ CreateStatement (
   CopyMem (&Statement->Prompt, &StatementHdr->Prompt, sizeof (EFI_STRING_ID));\r
   CopyMem (&Statement->Help, &StatementHdr->Help, sizeof (EFI_STRING_ID));\r
 \r
-  if (mInScopeSuppress) {\r
-    Statement->SuppressExpression = mSuppressExpression;\r
-  }\r
-\r
-  if (mInScopeGrayOut) {\r
-    Statement->GrayOutExpression = mGrayOutExpression;\r
-  }\r
-\r
-\r
-  if (mInScopeDisable) {\r
-    Statement->DisableExpression = mDisableExpression;\r
+  ConditionalExprCount = GetConditionalExpressionCount(ExpressStatement);\r
+  if (ConditionalExprCount > 0) {\r
+    //\r
+    // Form is inside of suppressif\r
+    //\r
+    \r
+    Statement->Expression = (FORM_EXPRESSION_LIST *) AllocatePool( \r
+                                             (UINTN) (sizeof(FORM_EXPRESSION_LIST) + ((ConditionalExprCount -1) * sizeof(FORM_EXPRESSION *))));\r
+    ASSERT (Statement->Expression != NULL);\r
+    Statement->Expression->Count     = (UINTN) ConditionalExprCount;\r
+    Statement->Expression->Signature = FORM_EXPRESSION_LIST_SIGNATURE;\r
+    CopyMem (Statement->Expression->Expression, GetConditionalExpressionList(ExpressStatement), (UINTN) (sizeof (FORM_EXPRESSION *) * ConditionalExprCount));\r
   }\r
 \r
   Statement->InSubtitle = mInScopeSubtitle;\r
@@ -329,7 +324,8 @@ InitializeConfigHdr (
 {\r
   CHAR16      *Name;\r
 \r
-  if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {\r
+  if (Storage->Type == EFI_HII_VARSTORE_BUFFER || \r
+      Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {\r
     Name = Storage->Name;\r
   } else {\r
     Name = NULL;\r
@@ -395,7 +391,8 @@ InitializeRequestElement (
   //\r
   // Prepare <RequestElement>\r
   //\r
-  if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {\r
+  if (Storage->Type == EFI_HII_VARSTORE_BUFFER || \r
+      Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {\r
     StrLen = UnicodeSPrint (\r
                RequestElement,\r
                30 * sizeof (CHAR16),\r
@@ -457,6 +454,7 @@ InitializeRequestElement (
 \r
   if (!Find) {\r
     ConfigInfo = AllocateZeroPool(sizeof (FORM_BROWSER_CONFIG_REQUEST));\r
+    ASSERT (ConfigInfo != NULL);\r
     ConfigInfo->Signature     = FORM_BROWSER_CONFIG_REQUEST_SIGNATURE;\r
     ConfigInfo->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigHdr), Storage->ConfigHdr);\r
     ConfigInfo->SpareStrLen   = 0;\r
@@ -626,6 +624,9 @@ DestroyStatement (
   while (!IsListEmpty (&Statement->OptionListHead)) {\r
     Link = GetFirstNode (&Statement->OptionListHead);\r
     Option = QUESTION_OPTION_FROM_LINK (Link);\r
+    if (Option->SuppressExpression != NULL) {\r
+      FreePool (Option->SuppressExpression);\r
+    }\r
     RemoveEntryList (&Option->Link);\r
 \r
     FreePool (Option);\r
@@ -653,6 +654,10 @@ DestroyStatement (
     DestroyExpression (Expression);\r
   }\r
 \r
+  if (Statement->Expression != NULL) {\r
+    FreePool (Statement->Expression);\r
+  }\r
+\r
   if (Statement->VariableName != NULL) {\r
     FreePool (Statement->VariableName);\r
   }\r
@@ -720,6 +725,10 @@ DestroyForm (
     FreePool (ConfigInfo);\r
   }\r
 \r
+  if (Form->SuppressExpression != NULL) {\r
+    FreePool (Form->SuppressExpression);\r
+  }\r
+\r
   //\r
   // Free this Form\r
   //\r
@@ -928,10 +937,6 @@ ParseOpCodes (
   EFI_IMAGE_ID            *ImageId;\r
   BOOLEAN                 SuppressForQuestion;\r
   BOOLEAN                 SuppressForOption;\r
-  BOOLEAN                 InScopeOptionSuppress;\r
-  FORM_EXPRESSION         *OptionSuppressExpression;\r
-  BOOLEAN                 InScopeFormSuppress;\r
-  FORM_EXPRESSION         *FormSuppressExpression;\r
   UINT16                  DepthOfDisable;\r
   BOOLEAN                 OpCodeDisabled;\r
   BOOLEAN                 SingleOpCodeExpression;\r
@@ -943,15 +948,13 @@ ParseOpCodes (
   FORMSET_STORAGE         *VarStorage;\r
   LIST_ENTRY              *MapExpressionList;\r
   EFI_VARSTORE_ID         TempVarstoreId;\r
+  BOOLEAN                 InScopeDisable;\r
+  INTN                    ConditionalExprCount;\r
 \r
   mInScopeSubtitle         = FALSE;\r
   SuppressForQuestion      = FALSE;\r
   SuppressForOption        = FALSE;\r
-  InScopeFormSuppress      = FALSE;\r
-  mInScopeSuppress         = FALSE;\r
-  InScopeOptionSuppress    = FALSE;\r
-  mInScopeGrayOut          = FALSE;\r
-  mInScopeDisable          = FALSE;\r
+  InScopeDisable           = FALSE;\r
   DepthOfDisable           = 0;\r
   OpCodeDisabled           = FALSE;\r
   SingleOpCodeExpression   = FALSE;\r
@@ -959,8 +962,6 @@ ParseOpCodes (
   CurrentExpression        = NULL;\r
   CurrentDefault           = NULL;\r
   CurrentOption            = NULL;\r
-  OptionSuppressExpression = NULL;\r
-  FormSuppressExpression   = NULL;\r
   ImageId                  = NULL;\r
   MapMethod                = NULL;\r
   MapScopeDepth            = 0;\r
@@ -968,6 +969,7 @@ ParseOpCodes (
   VarStorage               = NULL;\r
   MapExpressionList        = NULL;\r
   TempVarstoreId           = 0;\r
+  ConditionalExprCount     = 0;\r
 \r
   //\r
   // Get the number of Statements and Expressions\r
@@ -989,6 +991,7 @@ ParseOpCodes (
   InitializeListHead (&FormSet->StorageListHead);\r
   InitializeListHead (&FormSet->DefaultStoreListHead);\r
   InitializeListHead (&FormSet->FormListHead);\r
+  InitializeListHead (&FormSet->ExpressionListHead);\r
   ResetCurrentExpressionStack ();\r
   ResetMapExpressionListStack ();\r
 \r
@@ -1028,7 +1031,7 @@ ParseOpCodes (
 \r
         if (ScopeOpCode == EFI_IFR_DISABLE_IF_OP) {\r
           if (DepthOfDisable == 0) {\r
-            mInScopeDisable = FALSE;\r
+            InScopeDisable = FALSE;\r
             OpCodeDisabled = FALSE;\r
           } else {\r
             DepthOfDisable--;\r
@@ -1059,7 +1062,7 @@ ParseOpCodes (
         CopyMem (&ExpressionOpCode->QuestionId2, &((EFI_IFR_EQ_ID_ID *) OpCodeData)->QuestionId2, sizeof (EFI_QUESTION_ID));\r
         break;\r
 \r
-      case EFI_IFR_EQ_ID_LIST_OP:\r
+      case EFI_IFR_EQ_ID_VAL_LIST_OP:\r
         CopyMem (&ExpressionOpCode->QuestionId, &((EFI_IFR_EQ_ID_VAL_LIST *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));\r
         CopyMem (&ExpressionOpCode->ListLength, &((EFI_IFR_EQ_ID_VAL_LIST *) OpCodeData)->ListLength, sizeof (UINT16));\r
         ExpressionOpCode->ValueList = AllocateCopyPool (ExpressionOpCode->ListLength * sizeof (UINT16), &((EFI_IFR_EQ_ID_VAL_LIST *) OpCodeData)->ValueList);\r
@@ -1142,6 +1145,10 @@ ParseOpCodes (
           ExpressionOpCode->ValueWidth = (UINT8) sizeof (EFI_IFR_TIME);\r
           break;\r
 \r
+        case EFI_IFR_TYPE_REF:\r
+          ExpressionOpCode->ValueWidth = (UINT8) sizeof (EFI_IFR_REF);\r
+          break;\r
+\r
         case EFI_IFR_TYPE_OTHER:\r
         case EFI_IFR_TYPE_UNDEFINED:\r
         case EFI_IFR_TYPE_ACTION:\r
@@ -1280,7 +1287,7 @@ ParseOpCodes (
         //\r
         SingleOpCodeExpression = FALSE;\r
 \r
-        if (mInScopeDisable && CurrentForm == NULL) {\r
+        if (InScopeDisable && CurrentForm == NULL) {\r
           //\r
           // This is DisableIf expression for Form, it should be a constant expression\r
           //\r
@@ -1325,8 +1332,6 @@ ParseOpCodes (
         FormSet->NumberOfClassGuid = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);\r
         CopyMem (FormSet->ClassGuid, OpCodeData + sizeof (EFI_IFR_FORM_SET), FormSet->NumberOfClassGuid * sizeof (EFI_GUID));\r
       }\r
-\r
-      InitializeListHead (&FormSet->ExpressionListHead);\r
       break;\r
 \r
     case EFI_IFR_FORM_OP:\r
@@ -1345,11 +1350,17 @@ ParseOpCodes (
       CopyMem (&CurrentForm->FormId,    &((EFI_IFR_FORM *) OpCodeData)->FormId,    sizeof (UINT16));\r
       CopyMem (&CurrentForm->FormTitle, &((EFI_IFR_FORM *) OpCodeData)->FormTitle, sizeof (EFI_STRING_ID));\r
 \r
-      if (InScopeFormSuppress) {\r
+      ConditionalExprCount = GetConditionalExpressionCount(ExpressForm);\r
+      if ( ConditionalExprCount > 0) {\r
         //\r
         // Form is inside of suppressif\r
         //\r
-        CurrentForm->SuppressExpression = FormSuppressExpression;\r
+        CurrentForm->SuppressExpression = (FORM_EXPRESSION_LIST *) AllocatePool( \r
+                                                 (UINTN) (sizeof(FORM_EXPRESSION_LIST) + ((ConditionalExprCount -1) * sizeof(FORM_EXPRESSION *))));\r
+        ASSERT (CurrentForm->SuppressExpression != NULL);\r
+        CurrentForm->SuppressExpression->Count     = (UINTN) ConditionalExprCount;\r
+        CurrentForm->SuppressExpression->Signature = FORM_EXPRESSION_LIST_SIGNATURE;\r
+        CopyMem (CurrentForm->SuppressExpression->Expression, GetConditionalExpressionList(ExpressForm), (UINTN) (sizeof (FORM_EXPRESSION *) * ConditionalExprCount));\r
       }\r
 \r
       if (Scope != 0) {\r
@@ -1404,11 +1415,17 @@ ParseOpCodes (
         CopyMem (&CurrentForm->FormTitle, &MapMethod->MethodTitle, sizeof (EFI_STRING_ID));\r
       }\r
 \r
-      if (InScopeFormSuppress) {\r
+      ConditionalExprCount = GetConditionalExpressionCount(ExpressForm);\r
+      if ( ConditionalExprCount > 0) {\r
         //\r
         // Form is inside of suppressif\r
         //\r
-        CurrentForm->SuppressExpression = FormSuppressExpression;\r
+        CurrentForm->SuppressExpression = (FORM_EXPRESSION_LIST *) AllocatePool( \r
+                                                 (UINTN) (sizeof(FORM_EXPRESSION_LIST) + ((ConditionalExprCount -1) * sizeof(FORM_EXPRESSION *))));\r
+        ASSERT (CurrentForm->SuppressExpression != NULL);\r
+        CurrentForm->SuppressExpression->Count     = (UINTN) ConditionalExprCount;\r
+        CurrentForm->SuppressExpression->Signature = FORM_EXPRESSION_LIST_SIGNATURE;\r
+        CopyMem (CurrentForm->SuppressExpression->Expression, GetConditionalExpressionList(ExpressForm), (UINTN) (sizeof (FORM_EXPRESSION *) * ConditionalExprCount));\r
       }\r
 \r
       if (Scope != 0) {\r
@@ -1475,11 +1492,32 @@ ParseOpCodes (
       // Create a EFI variable Storage for this FormSet\r
       //\r
       Storage = CreateStorage (FormSet);\r
-      Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE;\r
 \r
       CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));\r
       CopyMem (&Storage->Guid,       &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Guid,       sizeof (EFI_GUID));\r
       CopyMem (&Storage->Attributes, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Attributes, sizeof (UINT32));\r
+      CopyMem (&Storage->Size,       &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Size,       sizeof (UINT16));\r
+\r
+      if (OpCodeLength < sizeof (EFI_IFR_VARSTORE_EFI)) {\r
+        Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE;\r
+        break;\r
+      } \r
+\r
+      Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER;\r
+      Storage->Buffer = AllocateZeroPool (Storage->Size);\r
+      Storage->EditBuffer = AllocateZeroPool (Storage->Size);\r
+\r
+      AsciiString = (CHAR8 *) ((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Name;\r
+      Storage->Name = AllocateZeroPool (AsciiStrSize (AsciiString) * 2);\r
+      ASSERT (Storage->Name != NULL);\r
+      for (Index = 0; AsciiString[Index] != 0; Index++) {\r
+        Storage->Name[Index] = (CHAR16) AsciiString[Index];\r
+      }\r
+\r
+      //\r
+      // Initialize <ConfigHdr>\r
+      //\r
+      InitializeConfigHdr (FormSet, Storage);\r
       break;\r
 \r
     //\r
@@ -1547,19 +1585,25 @@ ParseOpCodes (
     case EFI_IFR_REF_OP:\r
       CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);\r
       ASSERT (CurrentStatement != NULL);\r
-      CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_UNDEFINED;\r
-      CopyMem (&CurrentStatement->RefFormId, &((EFI_IFR_REF *) OpCodeData)->FormId, sizeof (EFI_FORM_ID));\r
-      if (OpCodeLength >= sizeof (EFI_IFR_REF2)) {\r
-        CopyMem (&CurrentStatement->RefQuestionId, &((EFI_IFR_REF2 *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));\r
+      Value = &CurrentStatement->HiiValue;\r
+      Value->Type = EFI_IFR_TYPE_REF;\r
+      if (OpCodeLength >= sizeof (EFI_IFR_REF)) {\r
+        CopyMem (&Value->Value.ref.FormId, &((EFI_IFR_REF *) OpCodeData)->FormId, sizeof (EFI_FORM_ID));\r
+\r
+        if (OpCodeLength >= sizeof (EFI_IFR_REF2)) {\r
+          CopyMem (&Value->Value.ref.QuestionId, &((EFI_IFR_REF2 *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));\r
 \r
-        if (OpCodeLength >= sizeof (EFI_IFR_REF3)) {\r
-          CopyMem (&CurrentStatement->RefFormSetId, &((EFI_IFR_REF3 *) OpCodeData)->FormSetId, sizeof (EFI_GUID));\r
+          if (OpCodeLength >= sizeof (EFI_IFR_REF3)) {\r
+            CopyMem (&Value->Value.ref.FormSetGuid, &((EFI_IFR_REF3 *) OpCodeData)->FormSetId, sizeof (EFI_GUID));\r
 \r
-          if (OpCodeLength >= sizeof (EFI_IFR_REF4)) {\r
-            CopyMem (&CurrentStatement->RefDevicePath, &((EFI_IFR_REF4 *) OpCodeData)->DevicePath, sizeof (EFI_STRING_ID));\r
+            if (OpCodeLength >= sizeof (EFI_IFR_REF4)) {\r
+              CopyMem (&Value->Value.ref.DevicePath, &((EFI_IFR_REF4 *) OpCodeData)->DevicePath, sizeof (EFI_STRING_ID));\r
+            }\r
           }\r
         }\r
       }\r
+      CurrentStatement->StorageWidth = (UINT16) sizeof (EFI_HII_REF);        \r
+      InitializeRequestElement (FormSet, CurrentStatement, CurrentForm);\r
       break;\r
 \r
     case EFI_IFR_ONE_OF_OP:\r
@@ -1735,8 +1779,10 @@ ParseOpCodes (
 \r
       CurrentDefault->Value.Type = ((EFI_IFR_DEFAULT *) OpCodeData)->Type;\r
       CopyMem (&CurrentDefault->DefaultId, &((EFI_IFR_DEFAULT *) OpCodeData)->DefaultId, sizeof (UINT16));\r
-      CopyMem (&CurrentDefault->Value.Value, &((EFI_IFR_DEFAULT *) OpCodeData)->Value, sizeof (EFI_IFR_TYPE_VALUE));\r
-      ExtendValueToU64 (&CurrentDefault->Value);\r
+      if (OpCodeLength == sizeof (EFI_IFR_DEFAULT)) {\r
+        CopyMem (&CurrentDefault->Value.Value, &((EFI_IFR_DEFAULT *) OpCodeData)->Value, sizeof (EFI_IFR_TYPE_VALUE));\r
+        ExtendValueToU64 (&CurrentDefault->Value);\r
+      }\r
 \r
       //\r
       // Insert to Default Value list of current Question\r
@@ -1766,8 +1812,17 @@ ParseOpCodes (
       CopyMem (&CurrentOption->Value.Value, &((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Value, sizeof (EFI_IFR_TYPE_VALUE));\r
       ExtendValueToU64 (&CurrentOption->Value);\r
 \r
-      if (InScopeOptionSuppress) {\r
-        CurrentOption->SuppressExpression = OptionSuppressExpression;\r
+      ConditionalExprCount = GetConditionalExpressionCount(ExpressOption);\r
+      if ( ConditionalExprCount > 0) {\r
+        //\r
+        // Form is inside of suppressif\r
+        //\r
+        CurrentOption->SuppressExpression = (FORM_EXPRESSION_LIST *) AllocatePool( \r
+                                                 (UINTN) (sizeof(FORM_EXPRESSION_LIST) + ((ConditionalExprCount -1) * sizeof(FORM_EXPRESSION *))));\r
+        ASSERT (CurrentOption->SuppressExpression != NULL);\r
+        CurrentOption->SuppressExpression->Count     = (UINTN) ConditionalExprCount;\r
+        CurrentOption->SuppressExpression->Signature = FORM_EXPRESSION_LIST_SIGNATURE;\r
+        CopyMem (CurrentOption->SuppressExpression->Expression, GetConditionalExpressionList(ExpressOption), (UINTN) (sizeof (FORM_EXPRESSION *) * ConditionalExprCount));\r
       }\r
 \r
       //\r
@@ -1808,6 +1863,10 @@ ParseOpCodes (
         CurrentStatement->StorageWidth = (UINT16) (CurrentStatement->MaxContainers * Width);\r
         CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth);\r
         CurrentStatement->ValueType = CurrentOption->Value.Type;\r
+        if (CurrentStatement->HiiValue.Type == EFI_IFR_TYPE_BUFFER) {\r
+          CurrentStatement->HiiValue.Buffer = CurrentStatement->BufferValue;\r
+          CurrentStatement->HiiValue.BufferLen = CurrentStatement->StorageWidth;\r
+        }\r
 \r
         InitializeRequestElement (FormSet, CurrentStatement, CurrentForm);\r
       }\r
@@ -1855,14 +1914,11 @@ ParseOpCodes (
       }\r
 \r
       if (SuppressForOption) {\r
-        InScopeOptionSuppress = TRUE;\r
-        OptionSuppressExpression = CurrentExpression;\r
+        PushConditionalExpression(CurrentExpression, ExpressOption);       \r
       } else if (SuppressForQuestion) {\r
-        mInScopeSuppress = TRUE;\r
-        mSuppressExpression = CurrentExpression;\r
+        PushConditionalExpression(CurrentExpression, ExpressStatement);  \r
       } else {\r
-        InScopeFormSuppress = TRUE;\r
-        FormSuppressExpression = CurrentExpression;\r
+        PushConditionalExpression(CurrentExpression, ExpressForm);  \r
       }\r
 \r
       //\r
@@ -1881,9 +1937,7 @@ ParseOpCodes (
       CurrentExpression = CreateExpression (CurrentForm);\r
       CurrentExpression->Type = EFI_HII_EXPRESSION_GRAY_OUT_IF;\r
       InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);\r
-\r
-      mInScopeGrayOut = TRUE;\r
-      mGrayOutExpression = CurrentExpression;\r
+      PushConditionalExpression(CurrentExpression, ExpressStatement);\r
 \r
       //\r
       // Take a look at next OpCode to see whether current expression consists\r
@@ -1910,12 +1964,11 @@ ParseOpCodes (
         // This is DisableIf for Question, enqueue it to Form expression list\r
         //\r
         InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);\r
+        PushConditionalExpression(CurrentExpression, ExpressStatement);\r
       }\r
 \r
-      mDisableExpression = CurrentExpression;\r
-      mInScopeDisable    = TRUE;\r
-      OpCodeDisabled     = FALSE;\r
-\r
+      OpCodeDisabled  = FALSE;\r
+      InScopeDisable  = TRUE;\r
       //\r
       // Take a look at next OpCode to see whether current expression consists\r
       // of single OpCode\r
@@ -2068,6 +2121,44 @@ ParseOpCodes (
       CurrentStatement->RefreshInterval = ((EFI_IFR_REFRESH *) OpCodeData)->RefreshInterval;\r
       break;\r
 \r
+    //\r
+    // Refresh guid.\r
+    //\r
+    case EFI_IFR_REFRESH_ID_OP:\r
+      ASSERT (CurrentStatement != NULL);\r
+      CopyMem (&CurrentStatement->RefreshGuid, &((EFI_IFR_REFRESH_ID *) OpCodeData)->RefreshEventGroupId, sizeof (EFI_GUID));\r
+      break;\r
+\r
+    //\r
+    // Modal tag\r
+    //\r
+    case EFI_IFR_MODAL_TAG_OP:\r
+      ASSERT (CurrentForm != NULL);\r
+      CurrentForm->ModalForm = TRUE;\r
+      break;\r
+\r
+    //\r
+    // Lock tag, used by form and statement.\r
+    //\r
+    case EFI_IFR_LOCKED_OP:\r
+      //\r
+      // Get ScopeOpcode from top of stack\r
+      //\r
+      PopScope (&ScopeOpCode);\r
+      PushScope (ScopeOpCode);\r
+      switch (ScopeOpCode) {\r
+      case EFI_IFR_FORM_OP:\r
+      case EFI_IFR_FORM_MAP_OP:\r
+        ASSERT (CurrentForm != NULL);\r
+        CurrentForm->Locked = TRUE;\r
+        break;\r
+\r
+      default:\r
+        ASSERT (CurrentStatement != NULL);\r
+        CurrentStatement->Locked = TRUE;\r
+      }      \r
+      break;\r
+\r
     //\r
     // Vendor specific\r
     //\r
@@ -2160,20 +2251,23 @@ ParseOpCodes (
 \r
       case EFI_IFR_SUPPRESS_IF_OP:\r
         if (SuppressForOption) {\r
-          InScopeOptionSuppress = FALSE;\r
+          PopConditionalExpression(ExpressOption);      \r
         } else if (SuppressForQuestion) {\r
-          mInScopeSuppress = FALSE;\r
+          PopConditionalExpression(ExpressStatement);\r
         } else {\r
-          InScopeFormSuppress = FALSE;\r
+          PopConditionalExpression(ExpressForm);\r
         }\r
         break;\r
 \r
       case EFI_IFR_GRAY_OUT_IF_OP:\r
-        mInScopeGrayOut = FALSE;\r
+        PopConditionalExpression(ExpressStatement);\r
         break;\r
 \r
       case EFI_IFR_DISABLE_IF_OP:\r
-        mInScopeDisable = FALSE;\r
+        if (CurrentForm != NULL) {\r
+          PopConditionalExpression(ExpressStatement);\r
+        }\r
+        InScopeDisable = FALSE;\r
         OpCodeDisabled = FALSE;\r
         break;\r
 \r
@@ -2205,7 +2299,7 @@ ParseOpCodes (
 \r
       default:\r
         if (IsExpressionOpCode (ScopeOpCode)) {\r
-          if (mInScopeDisable && CurrentForm == NULL) {\r
+          if (InScopeDisable && CurrentForm == NULL) {\r
             //\r
             // This is DisableIf expression for Form, it should be a constant expression\r
             //\r