X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FC%2FVfrCompile%2FVfrFormPkg.cpp;h=090ee13ef9da2e1b2402294d4d1908d50e5f8999;hp=aa27ce0be72e0682bbda0e9183eaa7bfb3969079;hb=5397bd425eba0cd00c5f76c8d35f328ca625db0e;hpb=9b78c54a09280ca852130b3ef76272a5d31d5035 diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp index aa27ce0be7..090ee13ef9 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 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, 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 @@ -56,13 +56,13 @@ SPendingAssign::~SPendingAssign ( ) { if (mKey != NULL) { - delete mKey; + delete[] mKey; } mAddr = NULL; mLen = 0; mLineNo = 0; if (mMsg != NULL) { - delete mMsg; + delete[] mMsg; } mNext = NULL; } @@ -104,8 +104,13 @@ CFormPkg::CFormPkg ( SBufferNode *Node; mPkgLength = 0; + mBufferSize = 0; mBufferNodeQueueHead = NULL; + mBufferNodeQueueTail = NULL; mCurrBufferNode = NULL; + mReadBufferNode = NULL; + mReadBufferOffset = 0; + PendingAssignList = NULL; Node = new SBufferNode; if (Node == NULL) { @@ -113,6 +118,7 @@ CFormPkg::CFormPkg ( } BufferStart = new CHAR8[BufferSize]; if (BufferStart == NULL) { + delete Node; return; } BufferEnd = BufferStart + BufferSize; @@ -825,10 +831,12 @@ CFormPkg::DeclarePendingQuestion ( CHAR8 FName[MAX_NAME_LEN]; CHAR8 *SName; CHAR8 *NewStr; - UINT32 ShrinkSize; + UINT32 ShrinkSize = 0; EFI_VFR_RETURN_CODE ReturnCode; EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID; - EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID; + UINT8 LFlags; + UINT32 MaxValue; + CIfrGuid *GuidObj = NULL; // // Declare all questions as Numeric in DisableIf True @@ -836,7 +844,7 @@ CFormPkg::DeclarePendingQuestion ( // DisableIf CIfrDisableIf DIObj; DIObj.SetLineNo (LineNo); - *InsertOpcodeAddr = DIObj.GetObjBinAddr (); + *InsertOpcodeAddr = DIObj.GetObjBinAddr(); //TrueOpcode CIfrTrue TObj (LineNo); @@ -844,14 +852,8 @@ CFormPkg::DeclarePendingQuestion ( // Declare Numeric qeustion for each undefined question. for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) { if (pNode->mFlag == PENDING) { - CIfrNumeric CNObj; EFI_VARSTORE_INFO Info; EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID; - - CNObj.SetLineNo (LineNo); - CNObj.SetPrompt (0x0); - CNObj.SetHelp (0x0); - // // Register this question, assume it is normal question, not date or time question // @@ -888,7 +890,7 @@ CFormPkg::DeclarePendingQuestion ( } else { if (VarStoreType == EFI_VFR_VARSTORE_EFI) { ReturnCode = lCVfrDataStorage.GetEfiVarStoreInfo (&Info); - } else if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) { + } else if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_BUFFER_BITS) { VarStr = pNode->mKey; //convert VarStr with store name to VarStr with structure name ReturnCode = lCVfrDataStorage.GetBufferVarStoreDataTypeName (Info.mVarStoreId, &SName); @@ -897,8 +899,8 @@ CFormPkg::DeclarePendingQuestion ( NewStr[0] = '\0'; strcpy (NewStr, SName); strcat (NewStr, VarStr + strlen (FName)); - ReturnCode = lCVfrVarDataTypeDB.GetDataFieldInfo (NewStr, Info.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize); - delete NewStr; + ReturnCode = lCVfrVarDataTypeDB.GetDataFieldInfo (NewStr, Info.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize, Info.mIsBitVar); + delete[] NewStr; } } else { ReturnCode = VFR_RETURN_UNSUPPORTED; @@ -908,39 +910,63 @@ CFormPkg::DeclarePendingQuestion ( gCVfrErrorHandle.HandleError (ReturnCode, pNode->mLineNo, pNode->mKey); return ReturnCode; } - - CNObj.SetQuestionId (QId); - CNObj.SetVarStoreInfo (&Info); // - // Numeric doesn't support BOOLEAN data type. - // BOOLEAN type has the same data size to UINT8. + // If the storage is bit fields, create Guid opcode to wrap the numeric opcode. // - if (Info.mVarType == EFI_IFR_TYPE_BOOLEAN) { - Info.mVarType = EFI_IFR_TYPE_NUM_SIZE_8; + if (Info.mIsBitVar) { + GuidObj = new CIfrGuid(0); + GuidObj->SetGuid (&gEdkiiIfrBitVarGuid); + GuidObj->SetLineNo(LineNo); } - CNObj.SetFlags (0, Info.mVarType); + + CIfrNumeric CNObj; + CNObj.SetLineNo (LineNo); + CNObj.SetPrompt (0x0); + CNObj.SetHelp (0x0); + CNObj.SetQuestionId (QId); + CNObj.SetVarStoreInfo (&Info); + // - // Use maximum value not to limit the vaild value for the undefined question. + // Set Min/Max/Step Data and flags for the question with bit fields.Min/Max/Step Data are saved as UINT32 type for bit question. // - switch (Info.mVarType) { - case EFI_IFR_TYPE_NUM_SIZE_64: - CNObj.SetMinMaxStepData ((UINT64) 0, (UINT64) -1 , (UINT64) 0); - ShrinkSize = 0; - break; - case EFI_IFR_TYPE_NUM_SIZE_32: - CNObj.SetMinMaxStepData ((UINT32) 0, (UINT32) -1 , (UINT32) 0); + if (Info.mIsBitVar) { + MaxValue = (1 << Info.mVarTotalSize) -1; + CNObj.SetMinMaxStepData ((UINT32) 0, MaxValue, (UINT32) 0); ShrinkSize = 12; - break; - case EFI_IFR_TYPE_NUM_SIZE_16: - CNObj.SetMinMaxStepData ((UINT16) 0, (UINT16) -1 , (UINT16) 0); - ShrinkSize = 18; - break; - case EFI_IFR_TYPE_NUM_SIZE_8: - CNObj.SetMinMaxStepData ((UINT8) 0, (UINT8) -1 , (UINT8) 0); - ShrinkSize = 21; - break; - default: - break; + LFlags = (EDKII_IFR_NUMERIC_SIZE_BIT & Info.mVarTotalSize); + CNObj.SetFlagsForBitField (0, LFlags); + } else { + // + // Numeric doesn't support BOOLEAN data type. + // BOOLEAN type has the same data size to UINT8. + // + if (Info.mVarType == EFI_IFR_TYPE_BOOLEAN) { + Info.mVarType = EFI_IFR_TYPE_NUM_SIZE_8; + } + CNObj.SetFlags (0, Info.mVarType); + // + // Use maximum value not to limit the vaild value for the undefined question. + // + switch (Info.mVarType) { + case EFI_IFR_TYPE_NUM_SIZE_64: + CNObj.SetMinMaxStepData ((UINT64) 0, (UINT64) -1 , (UINT64) 0); + ShrinkSize = 0; + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + CNObj.SetMinMaxStepData ((UINT32) 0, (UINT32) -1 , (UINT32) 0); + ShrinkSize = 12; + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + CNObj.SetMinMaxStepData ((UINT16) 0, (UINT16) -1 , (UINT16) 0); + ShrinkSize = 18; + break; + case EFI_IFR_TYPE_NUM_SIZE_8: + CNObj.SetMinMaxStepData ((UINT8) 0, (UINT8) -1 , (UINT8) 0); + ShrinkSize = 21; + break; + default: + break; + } } CNObj.ShrinkBinSize (ShrinkSize); @@ -956,8 +982,18 @@ CFormPkg::DeclarePendingQuestion ( // // End for Numeric // - CIfrEnd CEObj; + CIfrEnd CEObj; CEObj.SetLineNo (LineNo); + // + // End for Guided opcode + // + if (GuidObj != NULL) { + CIfrEnd CEObjGuid; + CEObjGuid.SetLineNo (LineNo); + GuidObj->SetScope(1); + delete GuidObj; + GuidObj = NULL; + } } } @@ -1297,6 +1333,7 @@ CIfrRecordInfoDB::IfrAdjustDynamicOpcodeInRecords ( SIfrRecord *pAdjustNode, *pNodeBeforeAdjust; SIfrRecord *pNodeBeforeDynamic; + pPreNode = NULL; pAdjustNode = NULL; pNodeBeforeDynamic = NULL; OpcodeOffset = 0; @@ -1364,7 +1401,7 @@ CIfrRecordInfoDB::IfrUpdateRecordInfoForDynamicOpcode ( // Base on the original offset info to update the record list. // if (!IfrAdjustDynamicOpcodeInRecords(CreateOpcodeAfterParsingVfr)) { - gCVfrErrorHandle.PrintMsg (0, "Error", "Can not find the adjust offset in the record."); + gCVfrErrorHandle.PrintMsg (0, (CHAR8 *)"Error", (CHAR8 *)"Can not find the adjust offset in the record."); } // @@ -1409,7 +1446,6 @@ CIfrRecordInfoDB::IfrRecordAdjust ( EFI_QUESTION_ID QuestionId; UINT32 StackCount; UINT32 QuestionScope; - UINT32 OpcodeOffset; CHAR8 ErrorMsg[MAX_STRING_LEN] = {0, }; EFI_VFR_RETURN_CODE Status; @@ -1845,6 +1881,7 @@ CIfrRecordInfoDB::IfrCreateDefaultForQuestion ( // Point to the first expression opcode. // pSNode = pDefaultNode->mNext; + pENode = NULL; ScopeCount++; // // Get opcode number behind the EFI_IFR_DEFAULT_2 until reach its END opcode (including the END opcode of EFI_IFR_DEFAULT_2) @@ -1888,7 +1925,7 @@ CIfrRecordInfoDB::IfrCreateDefaultForQuestion ( Obj = new CIfrObj (pOpHead->OpCode, NULL, pSNode->mBinBufLen, FALSE); assert (Obj != NULL); Obj->SetLineNo (pSNode->mLineNo); - ObjBinBuf = Obj->GetObjBinAddr(); + ObjBinBuf = Obj->GetObjBinAddr(); memcpy (ObjBinBuf, pSNode->mIfrBinBuf, (UINTN)pSNode->mBinBufLen); delete Obj; pSNode = pSNode->mNext; @@ -2389,6 +2426,7 @@ CIfrObj::CIfrObj ( mObjBinLen = (ObjBinLen == 0) ? gOpcodeSizesScopeTable[OpCode].mSize : ObjBinLen; mObjBinBuf = ((DelayEmit == FALSE) && (gCreateOp == TRUE)) ? gCFormPkg.IfrBinBufferGet (mObjBinLen) : new CHAR8[EFI_IFR_MAX_LENGTH]; mRecordIdx = (gCreateOp == TRUE) ? gCIfrRecordInfoDB.IfrRecordRegister (0xFFFFFFFF, mObjBinBuf, mObjBinLen, mPkgOffset) : EFI_IFR_RECORDINFO_IDX_INVALUD; + mLineNo = 0; assert (mObjBinBuf != NULL);