Enhance the browser parse opcode logic, skip the opcode which is not defined in UEFI spec.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Gao, Liming <liming,gao@intel.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15475 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Eric Dong 2014-04-18 03:17:54 +00:00 committed by ydong10
parent 147113644f
commit 7e2f32894b
1 changed files with 46 additions and 0 deletions

View File

@ -1073,6 +1073,23 @@ IsStatementOpCode (
} }
} }
/**
Tell whether this Operand is an known OpCode.
@param Operand Operand of an IFR OpCode.
@retval TRUE This is an Statement OpCode.
@retval FALSE Not an Statement OpCode.
**/
BOOLEAN
IsUnKnownOpCode (
IN UINT8 Operand
)
{
return Operand > EFI_IFR_WARNING_IF_OP ? TRUE : FALSE;
}
/** /**
Calculate number of Statemens(Questions) and Expression OpCodes. Calculate number of Statemens(Questions) and Expression OpCodes.
@ -1165,6 +1182,8 @@ ParseOpCodes (
EFI_VARSTORE_ID TempVarstoreId; EFI_VARSTORE_ID TempVarstoreId;
BOOLEAN InScopeDisable; BOOLEAN InScopeDisable;
INTN ConditionalExprCount; INTN ConditionalExprCount;
BOOLEAN InUnknownScope;
UINT8 UnknownDepth;
SuppressForQuestion = FALSE; SuppressForQuestion = FALSE;
SuppressForOption = FALSE; SuppressForOption = FALSE;
@ -1184,6 +1203,8 @@ ParseOpCodes (
MapExpressionList = NULL; MapExpressionList = NULL;
TempVarstoreId = 0; TempVarstoreId = 0;
ConditionalExprCount = 0; ConditionalExprCount = 0;
InUnknownScope = FALSE;
UnknownDepth = 0;
// //
// Get the number of Statements and Expressions // Get the number of Statements and Expressions
@ -1226,6 +1247,31 @@ ParseOpCodes (
Operand = ((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode; Operand = ((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode;
Scope = ((EFI_IFR_OP_HEADER *) OpCodeData)->Scope; Scope = ((EFI_IFR_OP_HEADER *) OpCodeData)->Scope;
if (InUnknownScope) {
if (Operand == EFI_IFR_END_OP) {
UnknownDepth --;
if (UnknownDepth == 0) {
InUnknownScope = FALSE;
}
} else {
if (Scope != 0) {
UnknownDepth ++;
}
}
continue;
}
if (IsUnKnownOpCode(Operand)) {
if (Scope != 0) {
InUnknownScope = TRUE;
UnknownDepth ++;
}
continue;
}
// //
// If scope bit set, push onto scope stack // If scope bit set, push onto scope stack
// //