]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
Use Numeric Opcode to host the backward compatibility as the VarEqVal in Framework...
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / IfrParse.c
index 9108acb473ea6ded418216d2e23f1675ea62ee8d..3a9a8bc3b9c6b686148ee6f6a9c1e39c0583872e 100644 (file)
@@ -1,4 +1,6 @@
 /** @file
+Parser for IFR binary encoding.
+
 Copyright (c) 2007 - 2008, Intel Corporation
 All rights reserved. This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
@@ -8,15 +10,6 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
-Module Name:
-
-  IfrParse.c
-
-Abstract:
-
-  Parser for IFR binary encoding.
-
-
 **/
 
 #include "Setup.h"
@@ -32,6 +25,7 @@ FORM_EXPRESSION  *mSuppressExpression;
 FORM_EXPRESSION  *mGrayOutExpression;
 
 EFI_GUID  gTianoHiiIfrGuid = EFI_IFR_TIANO_GUID;
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID  mFrameworkHiiCompatibilityGuid = EFI_IFR_FRAMEWORK_GUID;
 
 
 /**
@@ -95,6 +89,54 @@ CreateStatement (
   return Statement;
 }
 
+EFI_STATUS
+UpdateCheckBoxStringToken (
+  IN CONST FORM_BROWSER_FORMSET *FormSet,
+  IN       FORM_BROWSER_STATEMENT *Statement
+  )
+{
+  CHAR16                  Str[MAXIMUM_VALUE_CHARACTERS];
+  EFI_STRING_ID           Id;
+  EFI_STATUS              Status;
+
+  ASSERT (Statement != NULL);
+  ASSERT (Statement->Operand == EFI_IFR_NUMERIC_OP);
+  
+  UnicodeValueToString (Str, 0, Statement->VarStoreInfo.VarName, MAXIMUM_VALUE_CHARACTERS - 1);
+  
+  Status = HiiLibNewString (FormSet->HiiHandle, &Id, Str);
+
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  Statement->VarStoreInfo.VarName = Id;
+    
+  return EFI_SUCCESS;
+}
+
+BOOLEAN
+IsNextOpCodeGuidedVarEqName (
+  UINT8 *OpCodeData
+  )
+{
+  //
+  // Get next opcode
+  //
+  OpCodeData += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
+  if (*OpCodeData == EFI_IFR_GUID_OP) {
+    if (CompareGuid (&mFrameworkHiiCompatibilityGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
+      //
+      // Specific GUIDed opcodes to support IFR generated from Framework HII VFR 
+      //
+      if ((((EFI_IFR_GUID_VAREQNAME *) OpCodeData)->ExtendOpCode) == EFI_IFR_EXTEND_OP_VAREQNAME) {
+        return TRUE;
+      }
+    }
+  }
+
+  return FALSE;
+}
 
 /**
   Initialize Question's members.
@@ -118,6 +160,7 @@ CreateQuestion (
   LIST_ENTRY               *Link;
   FORMSET_STORAGE          *Storage;
   NAME_VALUE_NODE          *NameValueNode;
+  EFI_STATUS               Status;
 
   Statement = CreateStatement (OpCodeData, FormSet, Form);
   if (Statement == NULL) {
@@ -138,6 +181,19 @@ CreateQuestion (
     return Statement;
   }
 
+  //
+  // Take a look at next OpCode to see whether it is a GUIDed opcode to support
+  // Framework Compatibility
+  //
+  if (FeaturePcdGet (PcdFrameworkHiiCompatibilitySupport)) {
+    if ((*OpCodeData == EFI_IFR_NUMERIC_OP) && IsNextOpCodeGuidedVarEqName (OpCodeData)) {
+      Status = UpdateCheckBoxStringToken (FormSet, Statement);
+      if (EFI_ERROR (Status)) {
+        return NULL;
+      }
+    }
+  }
+
   //
   // Find Storage for this Question
   //
@@ -337,7 +393,7 @@ InitializeRequestElement (
     StrLen = UnicodeSPrint (RequestElement, 30 * sizeof (CHAR16), L"&%s", Question->VariableName);
   }
 
-  if ((Question->Operand == EFI_IFR_PASSWORD_OP) && (Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK)) {
+  if ((Question->Operand == EFI_IFR_PASSWORD_OP) && ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK)) {
     //
     // Password with CALLBACK flag is stored in encoded format,
     // so don't need to append it to <ConfigRequest>
@@ -371,12 +427,10 @@ InitializeRequestElement (
 
 
 /**
-  Free resources of a Expression
+  Free resources of a Expression.
 
   @param  FormSet                Pointer of the Expression
 
-  @return None.
-
 **/
 VOID
 DestroyExpression (
@@ -402,12 +456,10 @@ DestroyExpression (
 
 
 /**
-  Free resources of a storage
+  Free resources of a storage.
 
   @param  Storage                Pointer of the storage
 
-  @return None.
-
 **/
 VOID
 DestroyStorage (
@@ -444,12 +496,10 @@ DestroyStorage (
 
 
 /**
-  Free resources of a Statement
+  Free resources of a Statement.
 
   @param  Statement              Pointer of the Statement
 
-  @return None.
-
 **/
 VOID
 DestroyStatement (
@@ -511,11 +561,9 @@ DestroyStatement (
 
 
 /**
-  Free resources of a Form
-
-  @param  Form                   Pointer of the Form
+  Free resources of a Form.
 
-  @return None.
+  @param  Form                   Pointer of the Form.
 
 **/
 VOID
@@ -557,12 +605,10 @@ DestroyForm (
 
 
 /**
-  Free resources allocated for a FormSet
+  Free resources allocated for a FormSet.
 
   @param  FormSet                Pointer of the FormSet
 
-  @return None.
-
 **/
 VOID
 DestroyFormSet (
@@ -641,7 +687,10 @@ IsExpressionOpCode (
 {
   if (((Operand >= EFI_IFR_EQ_ID_VAL_OP) && (Operand <= EFI_IFR_NOT_OP)) ||
       ((Operand >= EFI_IFR_MATCH_OP) && (Operand <= EFI_IFR_SPAN_OP)) ||
-      (Operand == EFI_IFR_CATENATE_OP)
+      (Operand == EFI_IFR_CATENATE_OP) ||
+      (Operand == EFI_IFR_TO_LOWER_OP) ||
+      (Operand == EFI_IFR_TO_UPPER_OP) ||
+      (Operand == EFI_IFR_VERSION_OP)
      ) {
     return TRUE;
   } else {
@@ -657,8 +706,6 @@ IsExpressionOpCode (
   @param  NumberOfStatement      Number of Statemens(Questions)
   @param  NumberOfExpression     Number of Expression OpCodes
 
-  @return None.
-
 **/
 VOID
 CountOpCodes (
@@ -694,6 +741,7 @@ CountOpCodes (
 }
 
 
+
 /**
   Parse opcodes in the formset IFR binary.
 
@@ -791,7 +839,7 @@ ParseOpCodes (
     //
     // If scope bit set, push onto scope stack
     //
-    if (Scope) {
+    if (Scope != 0) {
       PushScope (Operand);
     }
 
@@ -1091,7 +1139,7 @@ ParseOpCodes (
       CurrentStatement = CreateStatement (OpCodeData, FormSet, CurrentForm);
       CurrentStatement->Flags = ((EFI_IFR_SUBTITLE *) OpCodeData)->Flags;
 
-      if (Scope) {
+      if (Scope != 0) {
         mInScopeSubtitle = TRUE;
       }
       break;
@@ -1187,7 +1235,7 @@ ParseOpCodes (
 
       InitializeRequestElement (FormSet, CurrentStatement);
 
-      if ((Operand == EFI_IFR_ONE_OF_OP) && Scope) {
+      if ((Operand == EFI_IFR_ONE_OF_OP) && Scope != 0) {
         SuppressForOption = TRUE;
       }
       break;
@@ -1208,7 +1256,7 @@ ParseOpCodes (
       CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_OTHER;
       CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth);
 
-      if (Scope) {
+      if (Scope != 0) {
         SuppressForOption = TRUE;
       }
       break;
@@ -1221,6 +1269,7 @@ ParseOpCodes (
       CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_BOOLEAN;
 
       InitializeRequestElement (FormSet, CurrentStatement);
+
       break;
 
     case EFI_IFR_STRING_OP:
@@ -1320,7 +1369,7 @@ ParseOpCodes (
       //
       InsertTailList (&CurrentStatement->DefaultListHead, &CurrentDefault->Link);
 
-      if (Scope) {
+      if (Scope != 0) {
         InScopeDefault = TRUE;
       }
       break;
@@ -1528,6 +1577,7 @@ ParseOpCodes (
           break;
         }
       }
+
       break;
 
     //