From b303ea726e1c8ed240dad2bce54821318567eab3 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Mon, 9 Nov 2009 11:47:35 +0000 Subject: Sync tool code to BuildTools project r1739. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9397 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/C/VfrCompile/VfrCompiler.cpp | 28 ++++++++++++---------- BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp | 4 ++-- BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 8 +++---- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 34 ++++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 19 deletions(-) (limited to 'BaseTools/Source/C/VfrCompile') diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp index 195727c2eb..e3c150cd3d 100644 --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp @@ -628,23 +628,27 @@ CVfrCompiler::GenCFile ( if (!IS_RUN_STATUS(STATUS_GENBINARY)) { goto Fail; } + + if (!mOptions.CreateIfrPkgFile || mOptions.CompatibleMode) { + if ((pFile = fopen (mOptions.COutputFileName, "w")) == NULL) { + Error (NULL, 0, 0001, "Error opening output C file", mOptions.COutputFileName); + goto Fail; + } - if ((pFile = fopen (mOptions.COutputFileName, "w")) == NULL) { - Error (NULL, 0, 0001, "Error opening output C file", mOptions.COutputFileName); - goto Fail; - } - - for (Index = 0; gSourceFileHeader[Index] != NULL; Index++) { - fprintf (pFile, "%s\n", gSourceFileHeader[Index]); - } + for (Index = 0; gSourceFileHeader[Index] != NULL; Index++) { + fprintf (pFile, "%s\n", gSourceFileHeader[Index]); + } - gCVfrBufferConfig.OutputCFile (pFile, mOptions.VfrBaseFileName); + if (mOptions.CompatibleMode) { + gCVfrBufferConfig.OutputCFile (pFile, mOptions.VfrBaseFileName); + } - if (gCFormPkg.GenCFile (mOptions.VfrBaseFileName, pFile, &gRBuffer) != VFR_RETURN_SUCCESS) { + if (gCFormPkg.GenCFile (mOptions.VfrBaseFileName, pFile, &gRBuffer) != VFR_RETURN_SUCCESS) { + fclose (pFile); + goto Fail; + } fclose (pFile); - goto Fail; } - fclose (pFile); SET_RUN_STATUS (STATUS_FINISHED); return; diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp index 298eb0289b..87da95af71 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp @@ -2,7 +2,7 @@ The definition of CFormPkg's member function -Copyright (c) 2004 - 2008, Intel Corporation +Copyright (c) 2004 - 2009, 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 which accompanies this distribution. The full text of the license may be found at @@ -1228,7 +1228,7 @@ static struct { { sizeof (EFI_IFR_INCONSISTENT_IF), 1 }, // EFI_IFR_INCONSISTENT_IF_OP { sizeof (EFI_IFR_EQ_ID_VAL), 0 }, // EFI_IFR_EQ_ID_VAL_OP { sizeof (EFI_IFR_EQ_ID_ID), 0 }, // EFI_IFR_EQ_ID_ID_OP - { sizeof (EFI_IFR_EQ_ID_LIST), 0 }, // EFI_IFR_EQ_ID_LIST_OP - 0x14 + { sizeof (EFI_IFR_EQ_ID_VAL_LIST), 0 }, // EFI_IFR_EQ_ID_LIST_OP - 0x14 { sizeof (EFI_IFR_AND), 0 }, // EFI_IFR_AND_OP { sizeof (EFI_IFR_OR), 0 }, // EFI_IFR_OR_OP { sizeof (EFI_IFR_NOT), 0 }, // EFI_IFR_NOT_OP diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h index fa671c1b1e..324078a148 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h @@ -2,7 +2,7 @@ The definition of CFormPkg's member function -Copyright (c) 2004 - 2008, Intel Corporation +Copyright (c) 2004 - 2009, 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 which accompanies this distribution. The full text of the license may be found at @@ -1568,12 +1568,12 @@ public: class CIfrEqIdList : public CIfrObj, public CIfrOpHeader { private: - EFI_IFR_EQ_ID_LIST *mEqIdVList; + EFI_IFR_EQ_ID_VAL_LIST *mEqIdVList; public: CIfrEqIdList ( IN UINT32 LineNo - ) : CIfrObj (EFI_IFR_EQ_ID_LIST_OP, (CHAR8 **)&mEqIdVList, sizeof (EFI_IFR_EQ_ID_LIST), TRUE), + ) : CIfrObj (EFI_IFR_EQ_ID_LIST_OP, (CHAR8 **)&mEqIdVList, sizeof (EFI_IFR_EQ_ID_VAL_LIST), TRUE), CIfrOpHeader (EFI_IFR_EQ_ID_LIST_OP, &mEqIdVList->Header) { SetLineNo (LineNo); mEqIdVList->QuestionId = EFI_QUESTION_ID_INVALID; @@ -1584,7 +1584,7 @@ public: VOID UpdateIfrBuffer ( ) { _EMIT_PENDING_OBJ(); - mEqIdVList = (EFI_IFR_EQ_ID_LIST *) GetObjBinAddr(); + mEqIdVList = (EFI_IFR_EQ_ID_VAL_LIST *) GetObjBinAddr(); UpdateHeader (&mEqIdVList->Header); } diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index c01f16e5d5..ea529a5e15 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -1911,7 +1911,7 @@ vfrStatementOrderedList : >> L:OrderedList << OLObj.SetLineNo(L->getLine()); >> vfrQuestionHeader[OLObj] "," - << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_VARSIZE()); >> + << OLObj.SetMaxContainers ((UINT8) _GET_CURRQEST_ARRAY_SIZE()); >> { MaxContainers "=" M:Number "," << OLObj.SetMaxContainers (_STOU8(M->getText())); >> } @@ -3179,6 +3179,7 @@ private: UINT8 _GET_CURRQEST_DATATYPE (); UINT32 _GET_CURRQEST_VARSIZE (); + UINT32 _GET_CURRQEST_ARRAY_SIZE(); public: VOID _PCATCH (IN INTN, IN INTN, IN ANTLRTokenPtr, IN CHAR8 *); @@ -3286,6 +3287,37 @@ EfiVfrParser::_GET_CURRQEST_VARTINFO ( return mCurrQestVarInfo; } +UINT32 +EfiVfrParser::_GET_CURRQEST_ARRAY_SIZE ( + VOID + ) +{ + UINT8 Size = 1; + + switch (mCurrQestVarInfo.mVarType) { + case EFI_IFR_TYPE_NUM_SIZE_8: + Size = 1; + break; + + case EFI_IFR_TYPE_NUM_SIZE_16: + Size = 2; + break; + + case EFI_IFR_TYPE_NUM_SIZE_32: + Size = 4; + break; + + case EFI_IFR_TYPE_NUM_SIZE_64: + Size = 8; + break; + + default: + break; + } + + return (mCurrQestVarInfo.mVarTotalSize / Size); +} + UINT8 EfiVfrParser::_GET_CURRQEST_DATATYPE ( VOID -- cgit v1.2.3