Skip to content

Commit

Permalink
Update VfrCompiler to fix the following incompatible and check issues.
Browse files Browse the repository at this point in the history
     1. First structure name will be declared as the default buffer varstore if no any buffer varstore is declared.
     2. Use numeric IFR type to declare the undefined question in order to support the different data type.
     3. Array check for CheckBox, Nemeric and Oneof Type, because they don't support the array as their question.
     4. Check the index in array for UEFI and Framework VFR question.

git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1320 7335b38e-4728-0410-8992-fb3ffe349368
  • Loading branch information
lgao4 committed Sep 2, 2008
1 parent 0d5e5e7 commit d4d27a6
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Source/C/VfrCompile/VfrError.cpp
Expand Up @@ -40,7 +40,7 @@ static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
{ VFR_RETURN_GET_NVVARSTORE_ERROR, "get name value varstore error" },
{ VFR_RETURN_QVAR_REUSE, "variable reused by more than one question" },
{ VFR_RETURN_FLAGS_UNSUPPORTED, "flags unsupported" },
{ VFR_RETURN_ERROR_ARRARY_NUM, "array number error" },
{ VFR_RETURN_ERROR_ARRARY_NUM, "array number error, the valid value is in (0 ~ MAX_INDEX-1) for UEFI vfr and in (1 ~ MAX_INDEX) for Framework Vfr" },
{ VFR_RETURN_DATA_STRING_ERROR, "data field string error or not support"},
{ VFR_RETURN_DEFAULT_VALUE_REDEFINED, "Default value re-defined with different value"},
{ VFR_RETURN_CODEUNDEFINED, "Undefined Error Code" }
Expand Down
70 changes: 52 additions & 18 deletions Source/C/VfrCompile/VfrFormPkg.cpp
Expand Up @@ -541,6 +541,7 @@ CFormPkg::DeclarePendingQuestion (
IN CVfrVarDataTypeDB &lCVfrVarDataTypeDB,
IN CVfrDataStorage &lCVfrDataStorage,
IN CVfrQuestionDB &lCVfrQuestionDB,
IN EFI_GUID *LocalFormSetGuid,
IN UINT32 LineNo
)
{
Expand All @@ -554,7 +555,7 @@ CFormPkg::DeclarePendingQuestion (
for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mFlag == PENDING) {
//
// declare this question as checkbox in SuppressIf True
// declare this question as Numeric in SuppressIf True
//
// SuppressIf
CIfrSuppressIf SIObj;
Expand All @@ -563,21 +564,22 @@ CFormPkg::DeclarePendingQuestion (
//TrueOpcode
CIfrTrue TObj (LineNo);

//CheckBox qeustion
CIfrCheckBox CBObj;
//Numeric qeustion
CIfrNumeric CNObj;
EFI_VARSTORE_INFO Info;
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;

CBObj.SetLineNo (LineNo);
CBObj.SetPrompt (0x0);
CBObj.SetHelp (0x0);
CNObj.SetLineNo (LineNo);
CNObj.SetPrompt (0x0);
CNObj.SetHelp (0x0);

//
// Register this question, assume it is normal question, not date or time question
//
VarStr = pNode->mKey;
ReturnCode = lCVfrQuestionDB.RegisterQuestion (NULL, VarStr, QId);
if (ReturnCode != VFR_RETURN_SUCCESS) {
gCVfrErrorHandle.HandleError (ReturnCode, pNode->mLineNo, pNode->mKey);
return ReturnCode;
}

Expand All @@ -589,26 +591,55 @@ CFormPkg::DeclarePendingQuestion (
//
ReturnCode = lCVfrVarDataTypeDB.ExtractFieldNameAndArrary (VarStr, FName, ArrayIdx);
if (ReturnCode != VFR_RETURN_SUCCESS) {
gCVfrErrorHandle.PrintMsg (pNode->mLineNo, pNode->mKey, "Error", "Var string is not the valid C variable");
return ReturnCode;
}
//
// Get VarStoreType
//
ReturnCode = lCVfrDataStorage.GetVarStoreType (FName, VarStoreType);
if (ReturnCode == VFR_RETURN_UNDEFINED) {
lCVfrDataStorage.DeclareBufferVarStore (
FName,
LocalFormSetGuid,
&lCVfrVarDataTypeDB,
FName,
EFI_VARSTORE_ID_INVALID,
FALSE
);
ReturnCode = lCVfrDataStorage.GetVarStoreType (FName, VarStoreType);
}
if (ReturnCode != VFR_RETURN_SUCCESS) {
gCVfrErrorHandle.PrintMsg (pNode->mLineNo, FName, "Error", "Var Store Type is not defined");
return ReturnCode;
}

ReturnCode = lCVfrDataStorage.GetVarStoreId (FName, &Info.mVarStoreId);
if (ReturnCode != VFR_RETURN_SUCCESS) {
gCVfrErrorHandle.PrintMsg (pNode->mLineNo, FName, "Error", "Var Store Type is not defined");
return ReturnCode;
}
lCVfrDataStorage.GetVarStoreType (FName, VarStoreType);
lCVfrDataStorage.GetVarStoreId (FName, &Info.mVarStoreId);

if (*VarStr == '\0' && ArrayIdx != INVALID_ARRAY_INDEX) {
lCVfrDataStorage.GetNameVarStoreInfo (&Info, ArrayIdx);
ReturnCode = lCVfrDataStorage.GetNameVarStoreInfo (&Info, ArrayIdx);
} else {
if (VarStoreType == EFI_VFR_VARSTORE_EFI) {
lCVfrDataStorage.GetEfiVarStoreInfo (&Info);
ReturnCode = lCVfrDataStorage.GetEfiVarStoreInfo (&Info);
} else if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {
VarStr = pNode->mKey;
lCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, Info.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize);
ReturnCode = lCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, Info.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize);
} else {
return VFR_RETURN_UNSUPPORTED;
ReturnCode = VFR_RETURN_UNSUPPORTED;
}
}
if (ReturnCode != VFR_RETURN_SUCCESS) {
gCVfrErrorHandle.HandleError (ReturnCode, pNode->mLineNo, pNode->mKey);
return ReturnCode;
}

CBObj.SetQuestionId (QId);
CBObj.SetVarStoreInfo (&Info);
CNObj.SetQuestionId (QId);
CNObj.SetVarStoreInfo (&Info);
CNObj.SetFlags (0, Info.mVarType);

//
// For undefined Efi VarStore type question
Expand All @@ -620,7 +651,7 @@ CFormPkg::DeclarePendingQuestion (
}

//
// End for checkbox
// End for Numeric
//
CIfrEnd CEObj;
CEObj.SetLineNo (LineNo);
Expand Down Expand Up @@ -904,6 +935,7 @@ CIfrRecordInfoDB::IfrRecordAdjust (
UINT32 StackCount;
UINT32 QuestionScope;
UINT32 OpcodeOffset;
CHAR8 ErrorMsg[MAX_STRING_LEN] = {0, };
EFI_VFR_RETURN_CODE Status;

//
Expand Down Expand Up @@ -965,7 +997,8 @@ CIfrRecordInfoDB::IfrRecordAdjust (
//
// report error; not found
//
printf ("Inconsistent OpCode Record list invalid QuestionId is 0x%X\n", QuestionId);
sprintf (ErrorMsg, "Inconsistent OpCode Record list invalid QuestionId is 0x%X", QuestionId);
gCVfrErrorHandle.PrintMsg (0, NULL, "Error", ErrorMsg);
Status = VFR_RETURN_MISMATCHED;
break;
}
Expand Down Expand Up @@ -1016,7 +1049,8 @@ CIfrRecordInfoDB::IfrRecordAdjust (
//
// not found matched question id, report error
//
printf ("QuestionId required by Inconsistent OpCode is not found. QuestionId is 0x%X\n", QuestionId);
sprintf (ErrorMsg, "QuestionId required by Inconsistent OpCode is not found. QuestionId is 0x%X", QuestionId);
gCVfrErrorHandle.PrintMsg (0, NULL, "Error", ErrorMsg);
Status = VFR_RETURN_MISMATCHED;
break;
}
Expand All @@ -1039,7 +1073,7 @@ CIfrRecordInfoDB::IfrRecordAdjust (
//
// invalid IfrCode, IfrCode end by EndOpCode
//
printf ("No found End Opcode in the end\n");
gCVfrErrorHandle.PrintMsg (0, NULL, "Error", "No found End Opcode in the end");
Status = VFR_RETURN_MISMATCHED;
break;
}
Expand Down
1 change: 1 addition & 0 deletions Source/C/VfrCompile/VfrFormPkg.h
Expand Up @@ -139,6 +139,7 @@ class CFormPkg {
IN CVfrVarDataTypeDB &lCVfrVarDataTypeDB,
IN CVfrDataStorage &lCVfrDataStorage,
IN CVfrQuestionDB &lCVfrQuestionDB,
IN EFI_GUID *LocalFormSetGuid,
IN UINT32 LineNo
);
};
Expand Down

0 comments on commit d4d27a6

Please sign in to comment.