X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FC%2FVfrCompile%2FVfrUtilityLib.cpp;h=0d0f926f82660a4fa498480094fce1a32b294fe6;hp=d795ef01bda11778bac7233e45dcde7683426e44;hb=fb0b35e05f772bd415fe264267bbbcde2e0accda;hpb=7ac4250e872424307c87a1565449a52f3e280953 diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp index d795ef01bd..0d0f926f82 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -1,15 +1,15 @@ /** @file - + Vfr common library functions. Copyright (c) 2004 - 2018, 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 -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. +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 +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. **/ @@ -72,9 +72,9 @@ CVfrBinaryOutput::WriteEnd ( } SConfigInfo::SConfigInfo ( - IN UINT8 Type, - IN UINT16 Offset, - IN UINT32 Width, + IN UINT8 Type, + IN UINT16 Offset, + IN UINT32 Width, IN EFI_IFR_TYPE_VALUE Value ) { @@ -553,7 +553,7 @@ _STR2U32 ( // // BUG: does not handle overflow here // - (IsHex == TRUE) ? (Value <<= 4) : (Value *= 10); + (IsHex == TRUE) ? (Value <<= 4) : (Value *= 10); if ((IsHex == TRUE) && (c >= 'a') && (c <= 'f')) { Value += (c - 'a' + 10); @@ -764,7 +764,7 @@ CVfrVarDataTypeDB::GetFieldOffset ( if (Field == NULL) { return VFR_RETURN_FATAL_ERROR; } - + // // Framework Vfr file Array Index is from 1. // But Uefi Vfr file Array Index is from 0. @@ -779,7 +779,7 @@ CVfrVarDataTypeDB::GetFieldOffset ( if ((ArrayIdx != INVALID_ARRAY_INDEX) && ((Field->mArrayNum == 0) || (Field->mArrayNum <= ArrayIdx))) { return VFR_RETURN_ERROR_ARRARY_NUM; } - + // // Be compatible with the current usage // If ArraryIdx is not specified, the first one is used. @@ -983,7 +983,7 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB ( pType->mMembers = pType->mMembers->mNext; delete pField; } - delete pType; + delete pType; } while (mPackStack != NULL) { @@ -1177,7 +1177,7 @@ CVfrVarDataTypeDB::DataTypeAddBitField ( } } else { // - // Check whether the bit fileds can be contained within one FieldType. + // Check whether the bit fields can be contained within one FieldType. // if (pTmp != NULL && pTmp->mIsBitField && strcmp (pTmp->mFieldType->mTypeName, pNewField->mFieldType->mTypeName) == 0 && (pTmp->mBitOffset - pTmp->mOffset * 8) + pTmp->mBitWidth + pNewField->mBitWidth <= pNewField->mFieldType->mTotalSize * 8) { @@ -1505,10 +1505,10 @@ CVfrVarDataTypeDB::Dump ( fprintf (File, "\t\tstruct %s {\n", pTNode->mTypeName); for (pFNode = pTNode->mMembers; pFNode != NULL; pFNode = pFNode->mNext) { if (pFNode->mArrayNum > 0) { - fprintf (File, "\t\t\t+%08d[%08x] %s[%d] <%s>\n", pFNode->mOffset, pFNode->mOffset, + fprintf (File, "\t\t\t+%08d[%08x] %s[%d] <%s>\n", pFNode->mOffset, pFNode->mOffset, pFNode->mFieldName, pFNode->mArrayNum, pFNode->mFieldType->mTypeName); } else { - fprintf (File, "\t\t\t+%08d[%08x] %s <%s>\n", pFNode->mOffset, pFNode->mOffset, + fprintf (File, "\t\t\t+%08d[%08x] %s <%s>\n", pFNode->mOffset, pFNode->mOffset, pFNode->mFieldName, pFNode->mFieldType->mTypeName); } } @@ -1536,7 +1536,7 @@ CVfrVarDataTypeDB::ParserDB ( printf ("\t\t\t%s\t%s\n", pFNode->mFieldType->mTypeName, pFNode->mFieldName); } printf ("\t\t};\n"); - printf ("---------------------------------------------------------------\n"); + printf ("---------------------------------------------------------------\n"); } printf ("***************************************************************\n"); } @@ -1688,7 +1688,7 @@ CVfrDataStorage::GetFreeVarStoreId ( ) { UINT32 Index, Mask, Offset; - + // // Assign the different ID range for the different type VarStore to support Framework Vfr // @@ -1770,7 +1770,7 @@ CVfrDataStorage::DeclareNameVarStoreBegin ( if (GetVarStoreId (StoreName, &TmpVarStoreId) == VFR_RETURN_SUCCESS) { return VFR_RETURN_REDEFINED; } - + if (VarStoreId == EFI_VARSTORE_ID_INVALID) { VarStoreId = GetFreeVarStoreId (EFI_VFR_VARSTORE_NAME); } else { @@ -1828,10 +1828,10 @@ CVfrDataStorage::DeclareNameVarStoreEnd ( return VFR_RETURN_SUCCESS; } -EFI_VFR_RETURN_CODE +EFI_VFR_RETURN_CODE CVfrDataStorage::DeclareEfiVarStore ( - IN CHAR8 *StoreName, - IN EFI_GUID *Guid, + IN CHAR8 *StoreName, + IN EFI_GUID *Guid, IN EFI_STRING_ID NameStrId, IN UINT32 VarSize, IN BOOLEAN Flag @@ -1863,10 +1863,10 @@ CVfrDataStorage::DeclareEfiVarStore ( return VFR_RETURN_SUCCESS; } -EFI_VFR_RETURN_CODE +EFI_VFR_RETURN_CODE CVfrDataStorage::DeclareBufferVarStore ( - IN CHAR8 *StoreName, - IN EFI_GUID *Guid, + IN CHAR8 *StoreName, + IN EFI_GUID *Guid, IN CVfrVarDataTypeDB *DataTypeDB, IN CHAR8 *TypeName, IN EFI_VARSTORE_ID VarStoreId, @@ -1911,7 +1911,7 @@ CVfrDataStorage::DeclareBufferVarStore ( return VFR_RETURN_SUCCESS; } -EFI_VFR_RETURN_CODE +EFI_VFR_RETURN_CODE CVfrDataStorage::GetVarStoreByDataType ( IN CHAR8 *DataTypeName, OUT SVfrVarStorageNode **VarNode, @@ -1920,7 +1920,7 @@ CVfrDataStorage::GetVarStoreByDataType ( { SVfrVarStorageNode *pNode; SVfrVarStorageNode *MatchNode; - + // // Framework VFR uses Data type name as varstore name, so don't need check again. // @@ -1950,7 +1950,7 @@ CVfrDataStorage::GetVarStoreByDataType ( } } } - + if (MatchNode == NULL) { return VFR_RETURN_UNDEFINED; } @@ -1959,7 +1959,7 @@ CVfrDataStorage::GetVarStoreByDataType ( return VFR_RETURN_SUCCESS; } -EFI_VARSTORE_ID +EFI_VARSTORE_ID CVfrDataStorage::CheckGuidField ( IN SVfrVarStorageNode *pNode, IN EFI_GUID *StoreGuid, @@ -1999,7 +1999,7 @@ CVfrDataStorage::CheckGuidField ( } /** - Base on the input store name and guid to find the varstore id. + Base on the input store name and guid to find the varstore id. If both name and guid are inputed, base on the name and guid to found the varstore. If only name inputed, base on the name to @@ -2007,10 +2007,10 @@ CVfrDataStorage::CheckGuidField ( has the same name. If only has found one varstore, return this varstore; if more than one varstore has same name, return varstore name redefined error. If no varstore found by varstore name, call - function GetVarStoreByDataType and use inputed varstore name as + function GetVarStoreByDataType and use inputed varstore name as data type name to search. **/ -EFI_VFR_RETURN_CODE +EFI_VFR_RETURN_CODE CVfrDataStorage::GetVarStoreId ( IN CHAR8 *StoreName, OUT EFI_VARSTORE_ID *VarStoreId, @@ -2058,14 +2058,14 @@ CVfrDataStorage::GetVarStoreId ( *VarStoreId = EFI_VARSTORE_ID_INVALID; // - // Assume that Data strucutre name is used as StoreName, and check again. + // Assume that Data structure name is used as StoreName, and check again. // ReturnCode = GetVarStoreByDataType (StoreName, &pNode, StoreGuid); if (pNode != NULL) { mCurrVarStorageNode = pNode; *VarStoreId = pNode->mVarStoreId; } - + return ReturnCode; } @@ -2169,7 +2169,7 @@ CVfrDataStorage::GetVarStoreGuid ( EFI_VFR_RETURN_CODE CVfrDataStorage::GetVarStoreName ( - IN EFI_VARSTORE_ID VarStoreId, + IN EFI_VARSTORE_ID VarStoreId, OUT CHAR8 **VarStoreName ) { @@ -2294,7 +2294,7 @@ CVfrDataStorage::GetNameVarStoreInfo ( if (mCurrVarStorageNode == NULL) { return VFR_RETURN_GET_NVVARSTORE_ERROR; } - + // // Framework Vfr file Index is from 1, but Uefi Vfr file Index is from 0. // @@ -2312,8 +2312,8 @@ CVfrDataStorage::GetNameVarStoreInfo ( SVfrDefaultStoreNode::SVfrDefaultStoreNode ( IN EFI_IFR_DEFAULTSTORE *ObjBinAddr, - IN CHAR8 *RefName, - IN EFI_STRING_ID DefaultStoreNameId, + IN CHAR8 *RefName, + IN EFI_STRING_ID DefaultStoreNameId, IN UINT16 DefaultId ) { @@ -2391,7 +2391,7 @@ CVfrDefaultStore::RegisterDefaultStore ( } /* - * assign new reference name or new default store name id only if + * assign new reference name or new default store name id only if * the original is invalid */ EFI_VFR_RETURN_CODE @@ -2507,7 +2507,7 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd ( goto WriteError; } } - + gCVfrBufferConfig.Close (); return VFR_RETURN_SUCCESS; @@ -2649,7 +2649,7 @@ EFI_VARSTORE_INFO::operator == ( ) { if ((mVarStoreId == Info->mVarStoreId) && - (mInfo.mVarName == Info->mInfo.mVarName) && + (mInfo.mVarName == Info->mInfo.mVarName) && (mInfo.mVarOffset == Info->mInfo.mVarOffset) && (mVarType == Info->mVarType) && (mVarTotalSize == Info->mVarTotalSize) && @@ -2832,7 +2832,7 @@ CVfrQuestionDB::ResetInit( // Question ID 0 is reserved. mFreeQIdBitMap[0] = 0x80000000; - mQuestionList = NULL; + mQuestionList = NULL; } VOID @@ -2843,7 +2843,7 @@ CVfrQuestionDB::PrintAllQuestion ( SVfrQuestionNode *pNode = NULL; for (pNode = mQuestionList; pNode != NULL; pNode = pNode->mNext) { - printf ("Question VarId is %s and QuesitonId is 0x%x\n", pNode->mVarIdStr, pNode->mQuestionId); + printf ("Question VarId is %s and QuestionId is 0x%x\n", pNode->mVarIdStr, pNode->mQuestionId); } } @@ -3242,7 +3242,7 @@ Err: } } -VOID +VOID CVfrQuestionDB::RegisterRefQuestion ( IN CHAR8 *Name, IN CHAR8 *BaseVarId, @@ -3331,15 +3331,15 @@ CVfrQuestionDB::RegisterRefQuestion ( pNode[0]->mQuestionId = QuestionId; pNode[1]->mQuestionId = QuestionId; pNode[2]->mQuestionId = QuestionId; - pNode[3]->mQuestionId = QuestionId; + pNode[3]->mQuestionId = QuestionId; pNode[0]->mQtype = QUESTION_REF; pNode[1]->mQtype = QUESTION_REF; pNode[2]->mQtype = QUESTION_REF; - pNode[3]->mQtype = QUESTION_REF; + pNode[3]->mQtype = QUESTION_REF; pNode[0]->mNext = pNode[1]; pNode[1]->mNext = pNode[2]; pNode[2]->mNext = pNode[3]; - pNode[3]->mNext = mQuestionList; + pNode[3]->mNext = mQuestionList; mQuestionList = pNode[0]; gCFormPkg.DoPendingAssign (VarIdStr[0], (VOID *)&QuestionId, sizeof(EFI_QUESTION_ID)); @@ -3368,15 +3368,15 @@ CVfrQuestionDB::UpdateQuestionId ( ) { SVfrQuestionNode *pNode = NULL; - + if (QId == NewQId) { // don't update return VFR_RETURN_SUCCESS; } - + // // For Framework Vfr, don't check question ID conflict. - // + // if (!VfrCompatibleMode && ChekQuestionIdFree (NewQId) == FALSE) { return VFR_RETURN_REDEFINED; } @@ -3432,7 +3432,7 @@ CVfrQuestionDB::GetQuestionId ( if (strcmp (pNode->mVarIdStr, VarIdStr) != 0) { continue; } - } + } QuestionId = pNode->mQuestionId; BitMask = pNode->mBitMask; @@ -3499,7 +3499,7 @@ CVfrStringDB::~CVfrStringDB () } -VOID +VOID CVfrStringDB::SetStringFileName(IN CHAR8 *StringFileName) { UINT32 FileLen = 0; @@ -3524,7 +3524,7 @@ CVfrStringDB::SetStringFileName(IN CHAR8 *StringFileName) /** - Returns TRUE or FALSE whether SupportedLanguages contains the best matching language + Returns TRUE or FALSE whether SupportedLanguages contains the best matching language from a set of supported languages. @param[in] SupportedLanguages A pointer to a Null-terminated ASCII string that @@ -3587,13 +3587,13 @@ CVfrStringDB::GetBestLanguage ( } // - // Trim Language from the right to the next '-' character + // Trim Language from the right to the next '-' character // for (LanguageLength--; LanguageLength > 0 && Language[LanguageLength] != '-'; LanguageLength--); } // - // No matches were found + // No matches were found // return FALSE; } @@ -3617,7 +3617,7 @@ CVfrStringDB::GetVarStoreNameFormStringId ( CHAR8 LineBuf[EFI_IFR_MAX_LENGTH]; UINT8 BlockType; EFI_HII_STRING_PACKAGE_HDR *PkgHeader; - + if (mStringFileName == NULL) { return NULL; }