Check whether numericFlags matches the var data type when varstore is bufferstore...
authorlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 24 Dec 2009 05:50:23 +0000 (05:50 +0000)
committerlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 24 Dec 2009 05:50:23 +0000 (05:50 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1781 7335b38e-4728-0410-8992-fb3ffe349368

Source/C/VfrCompile/VfrFormPkg.h
Source/C/VfrCompile/VfrSyntax.g

index 3318ef3..609b434 100644 (file)
@@ -1005,6 +1005,10 @@ public:
     }\r
     return VFR_RETURN_SUCCESS;\r
   }\r
+\r
+  UINT8 GetDataTypeFlags() {\r
+    return mNumeric->Flags & EFI_IFR_NUMERIC_SIZE;\r
+  }\r
 };\r
 \r
 class CIfrOneOf : public CIfrObj, public CIfrOpHeader, public CIfrQuestionHeader, public CIfrMinMaxStepData {\r
@@ -1041,6 +1045,10 @@ public:
     }\r
     return VFR_RETURN_SUCCESS;\r
   }\r
+\r
+  UINT8 GetDataTypeFlags() {\r
+    return mOneOf->Flags & EFI_IFR_NUMERIC_SIZE;\r
+  }\r
 };\r
 \r
 class CIfrString : public CIfrObj, public CIfrOpHeader, public CIfrQuestionHeader {\r
index b00e866..805d75c 100644 (file)
@@ -1718,7 +1718,7 @@ vfrStatementNumericType :
   vfrStatementOneOf\r
   ;\r
 \r
-vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :\r
+vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj, UINT8 DataTypeFlags] :\r
   <<\r
      UINT64 MaxU8 = 0, MinU8 = 0, StepU8 = 0;\r
      UINT32 MaxU4 = 0, MinU4 = 0, StepU4 = 0;\r
@@ -1727,7 +1727,7 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
   >>\r
   Minimum   "=" I:Number ","\r
                                                        <<\r
-                                                          switch (_GET_CURRQEST_DATATYPE ()) {\r
+                                                          switch (DataTypeFlags) {\r
                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : MinU8 = _STOU64(I->getText()); break;\r
                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : MinU4 = _STOU32(I->getText()); break;\r
                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : MinU2 = _STOU16(I->getText()); break;\r
@@ -1736,7 +1736,7 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
                                                        >>\r
   Maximum   "=" A:Number ","\r
                                                        <<\r
-                                                          switch (_GET_CURRQEST_DATATYPE ()) {\r
+                                                          switch (DataTypeFlags) {\r
                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : \r
                                                             MaxU8 = _STOU64(A->getText()); \r
                                                             if (MaxU8 < MinU8) {\r
@@ -1766,7 +1766,7 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
   {\r
     STEP    "=" S:Number ","\r
                                                        <<\r
-                                                          switch (_GET_CURRQEST_DATATYPE ()) {\r
+                                                          switch (DataTypeFlags) {\r
                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : StepU8 = _STOU64(S->getText()); break;\r
                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : StepU4 = _STOU32(S->getText()); break;\r
                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : StepU2 = _STOU16(S->getText()); break;\r
@@ -1775,7 +1775,7 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
                                                        >>\r
   }\r
                                                        <<\r
-                                                          switch (_GET_CURRQEST_DATATYPE ()) {\r
+                                                          switch (DataTypeFlags) {\r
                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : $MMSDObj.SetMinMaxStepData (MinU8, MaxU8, StepU8); break;\r
                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : $MMSDObj.SetMinMaxStepData (MinU4, MaxU4, StepU4); break;\r
                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : $MMSDObj.SetMinMaxStepData (MinU2, MaxU2, StepU2); break;\r
@@ -1801,7 +1801,7 @@ vfrStatementNumeric :
   {\r
     Key   "=" KN:Number ","                            << AssignQuestionKey (NObj, KN); >>\r
   }\r
-  vfrSetMinMaxStep[NObj]\r
+  vfrSetMinMaxStep[NObj, NObj.GetDataTypeFlags()]\r
   vfrStatementQuestionOptionList\r
   E:EndNumeric                                         << CRT_END_OP (E); >>\r
   ";"\r
@@ -1813,7 +1813,17 @@ vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] :
      UINT8 HFlags = 0;\r
   >>\r
   numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*\r
-                                                       << _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum); >>\r
+                                                       <<\r
+                                                          //check data type flag\r
+                                                          EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;\r
+                                                          VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);\r
+                                                          if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {\r
+                                                            if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {\r
+                                                              _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");\r
+                                                            }\r
+                                                          }\r
+                                                          _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum);\r
+                                                       >>\r
   ;\r
 \r
 numericFlagsField [UINT8 & HFlags, UINT8 & LFlags] :\r
@@ -1843,7 +1853,7 @@ vfrStatementOneOf :
                                                        >>\r
   { F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }\r
   {\r
-    vfrSetMinMaxStep[OObj]\r
+    vfrSetMinMaxStep[OObj, OObj.GetDataTypeFlags()]\r
   }\r
   vfrStatementQuestionOptionList\r
   E:EndOneOf                                           << CRT_END_OP (E); >>\r
@@ -1852,11 +1862,21 @@ vfrStatementOneOf :
 \r
 vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] :\r
   <<\r
-     UINT8 LFlags = _GET_CURRQEST_DATATYPE();\r
+     UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;\r
      UINT8 HFlags = 0;\r
   >>\r
   numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*\r
-                                                       << _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum); >>\r
+                                                       <<\r
+                                                          //check data type flag\r
+                                                          EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;\r
+                                                          VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);\r
+                                                          if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {\r
+                                                            if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {\r
+                                                              _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");\r
+                                                            }\r
+                                                          }\r
+                                                          _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum);\r
+                                                       >>\r
   ;\r
 \r
 vfrStatementStringType :\r