boolean.c
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C语言 代码 · 共 1,337 行 · 第 1/3 页
C
1,337 行
ExtractNvValue (FileFormTags, Iterator->VariableNumber2, Width, Iterator->QuestionId2, &MapBuffer2);
if (MapBuffer != NULL) {
if (Width == 2) {
MapValue = *MapBuffer;
} else {
MapValue = (UINT8) *MapBuffer;
}
gBS->FreePool (MapBuffer);
}
if (MapBuffer2 != NULL) {
if (Width == 2) {
MapValue2 = *MapBuffer2;
} else {
MapValue2 = (UINT8) *MapBuffer2;
}
gBS->FreePool (MapBuffer2);
}
}
switch (Iterator->Operand) {
case EFI_IFR_EQ_ID_VAL_OP:
//
// If Not - flip the results
//
if (NotOperator) {
Operator = (BOOLEAN)!(MapValue == Iterator->Value);
} else {
Operator = (BOOLEAN) (MapValue == Iterator->Value);
}
PushBool (&StackPtr, Operator);
break;
//
// In the case of external variable values, we must read the variable which is
// named by the human readable version of the OpCode->VariableId and the guid of the formset
//
case EFI_IFR_EQ_VAR_VAL_OP:
ValueToString (VariableName, FALSE, Iterator->QuestionId1);
SizeOfVariable = 0;
ExtractRequestedNvMap (FileFormTags, Iterator->VariableNumber, &VariableDefinition);
Status = BooleanVariableWorker (
VariableName,
VariableDefinition,
StackPtr,
&SizeOfVariable,
&VariableData
);
if (!EFI_ERROR (Status)) {
if (SizeOfVariable == 1) {
EfiCopyMem (&MapValue, VariableData, 1);
} else {
EfiCopyMem (&MapValue, VariableData, 2);
}
//
// If Not - flip the results
//
if (NotOperator) {
PushBool (&StackPtr, (BOOLEAN)!(MapValue == Iterator->Value));
} else {
PushBool (&StackPtr, (BOOLEAN) (MapValue == Iterator->Value));
}
}
break;
case EFI_IFR_EQ_ID_ID_OP:
//
// If Not - flip the results
//
if (NotOperator) {
Operator = (BOOLEAN)!(MapValue == MapValue2);
} else {
Operator = (BOOLEAN) (MapValue == MapValue2);
}
PushBool (&StackPtr, Operator);
break;
case EFI_IFR_EQ_ID_LIST_OP:
for (Index = 0; Index < Iterator->ListLength; Index++) {
//
// If Not - flip the results
//
if (NotOperator) {
Operator = (BOOLEAN)!(MapValue == Iterator->ValueList[Index]);
} else {
Operator = (BOOLEAN) (MapValue == Iterator->ValueList[Index]);
}
//
// If We are trying to make sure that MapValue != Item[x], keep looking through
// the list to make sure we don't equal any other items
//
if (Operator && NotOperator) {
continue;
}
//
// If MapValue == Item, then we have succeeded (first found is good enough)
//
if (Operator) {
break;
}
}
PushBool (&StackPtr, Operator);
break;
default:
return FALSE;
}
Operator = PopBool (&StackPtr);
Operator2 = PopBool (&StackPtr);
PushBool (&StackPtr, (BOOLEAN) (Operator && Operator2));
break;
case EFI_IFR_OR_OP:
Iterator++;
if (Iterator->Operand == EFI_IFR_NOT_OP) {
NotOperator = TRUE;
Iterator++;
}
if (Iterator->QuestionId1 != INVALID_OFFSET_VALUE) {
ExtractNvValue (FileFormTags, Iterator->VariableNumber, Width, Iterator->QuestionId1, &MapBuffer);
ExtractNvValue (FileFormTags, Iterator->VariableNumber2, Width, Iterator->QuestionId2, &MapBuffer2);
if (MapBuffer != NULL) {
if (Width == 2) {
MapValue = *MapBuffer;
} else {
MapValue = (UINT8) *MapBuffer;
}
gBS->FreePool (MapBuffer);
}
if (MapBuffer2 != NULL) {
if (Width == 2) {
MapValue2 = *MapBuffer2;
} else {
MapValue2 = (UINT8) *MapBuffer2;
}
gBS->FreePool (MapBuffer2);
}
}
switch (Iterator->Operand) {
case EFI_IFR_EQ_ID_VAL_OP:
//
// If Not - flip the results
//
if (NotOperator) {
Operator = (BOOLEAN)!(MapValue == Iterator->Value);
} else {
Operator = (BOOLEAN) (MapValue == Iterator->Value);
}
PushBool (&StackPtr, Operator);
break;
//
// In the case of external variable values, we must read the variable which is
// named by the human readable version of the OpCode->VariableId and the guid of the formset
//
case EFI_IFR_EQ_VAR_VAL_OP:
ValueToString (VariableName, FALSE, Iterator->QuestionId1);
SizeOfVariable = 0;
ExtractRequestedNvMap (FileFormTags, Iterator->VariableNumber, &VariableDefinition);
Status = BooleanVariableWorker (
VariableName,
VariableDefinition,
StackPtr,
&SizeOfVariable,
&VariableData
);
if (!EFI_ERROR (Status)) {
if (SizeOfVariable == 1) {
EfiCopyMem (&MapValue, VariableData, 1);
} else {
EfiCopyMem (&MapValue, VariableData, 2);
}
//
// If Not - flip the results
//
if (NotOperator) {
PushBool (&StackPtr, (BOOLEAN)!(MapValue == Iterator->Value));
} else {
PushBool (&StackPtr, (BOOLEAN) (MapValue == Iterator->Value));
}
}
break;
case EFI_IFR_EQ_ID_ID_OP:
//
// If Not - flip the results
//
if (NotOperator) {
Operator = (BOOLEAN)!(MapValue == MapValue2);
} else {
Operator = (BOOLEAN) (MapValue == MapValue2);
}
PushBool (&StackPtr, Operator);
break;
case EFI_IFR_EQ_ID_LIST_OP:
for (Index = 0; Index < Iterator->ListLength; Index++) {
//
// If Not - flip the results
//
if (NotOperator) {
Operator = (BOOLEAN)!(MapValue == Iterator->ValueList[Index]);
} else {
Operator = (BOOLEAN) (MapValue == Iterator->ValueList[Index]);
}
//
// If We are trying to make sure that MapValue != Item[x], keep looking through
// the list to make sure we don't equal any other items
//
if (Operator && NotOperator) {
continue;
}
//
// If MapValue == Item, then we have succeeded (first found is good enough)
//
if (Operator) {
break;
}
}
PushBool (&StackPtr, Operator);
break;
default:
return FALSE;
}
Operator = PopBool (&StackPtr);
Operator2 = PopBool (&StackPtr);
PushBool (&StackPtr, (BOOLEAN) (Operator || Operator2));
break;
case EFI_IFR_NOT_OP:
//
// To check whether Ifr is legacy. Once every boolean expression.
//
if (IsLegacy == 0) {
IsLegacy = PredicateIfrType (Iterator);
}
if (IsLegacy == 0x2) {
PostOrderEvaluate (FileFormTags, Width, &Iterator, &StackPtr);
break;
}
//
// I don't need to set the NotOperator (I know that I have to NOT this in this case
//
Iterator++;
if (Iterator->Operand == EFI_IFR_OR_OP) {
OrOperator = TRUE;
Iterator++;
}
if (Iterator->Operand == EFI_IFR_AND_OP) {
AndOperator = TRUE;
Iterator++;
}
if (Iterator->QuestionId1 != INVALID_OFFSET_VALUE) {
ExtractNvValue (FileFormTags, Iterator->VariableNumber, Width, Iterator->QuestionId1, &MapBuffer);
ExtractNvValue (FileFormTags, Iterator->VariableNumber2, Width, Iterator->QuestionId2, &MapBuffer2);
if (MapBuffer != NULL) {
if (Width == 2) {
MapValue = *MapBuffer;
} else {
MapValue = (UINT8) *MapBuffer;
}
gBS->FreePool (MapBuffer);
}
if (MapBuffer2 != NULL) {
if (Width == 2) {
MapValue2 = *MapBuffer2;
} else {
MapValue2 = (UINT8) *MapBuffer2;
}
gBS->FreePool (MapBuffer2);
}
}
switch (Iterator->Operand) {
case EFI_IFR_EQ_ID_VAL_OP:
Operator = (BOOLEAN)!(MapValue == Iterator->Value);
PushBool (&StackPtr, Operator);
break;
//
// In the case of external variable values, we must read the variable which is
// named by the human readable version of the OpCode->VariableId and the guid of the formset
//
case EFI_IFR_EQ_VAR_VAL_OP:
ValueToString (VariableName, FALSE, Iterator->QuestionId1);
SizeOfVariable = 0;
ExtractRequestedNvMap (FileFormTags, Iterator->VariableNumber, &VariableDefinition);
Status = BooleanVariableWorker (
VariableName,
VariableDefinition,
StackPtr,
&SizeOfVariable,
&VariableData
);
if (!EFI_ERROR (Status)) {
if (SizeOfVariable == 1) {
EfiCopyMem (&MapValue, VariableData, 1);
} else {
EfiCopyMem (&MapValue, VariableData, 2);
}
PushBool (&StackPtr, (BOOLEAN)!(MapValue == Iterator->Value));
}
break;
case EFI_IFR_EQ_ID_ID_OP:
Operator = (BOOLEAN)!(MapValue == MapValue2);
PushBool (&StackPtr, Operator);
break;
case EFI_IFR_EQ_ID_LIST_OP:
for (Index = 0; Index < Iterator->ListLength; Index++) {
Operator = (BOOLEAN)!(MapValue == Iterator->ValueList[Index]);
if (Operator) {
continue;
}
}
PushBool (&StackPtr, Operator);
break;
default:
return FALSE;
}
Operator = PopBool (&StackPtr);
Operator2 = PopBool (&StackPtr);
if (OrOperator) {
PushBool (&StackPtr, (BOOLEAN) (Operator || Operator2));
}
if (AndOperator) {
PushBool (&StackPtr, (BOOLEAN) (Operator && Operator2));
}
if (!OrOperator && !AndOperator) {
PushBool (&StackPtr, Operator);
}
break;
case EFI_IFR_TRUE_OP:
//
// To check whether Ifr is legacy. Once every boolean expression.
//
if (IsLegacy == 0) {
IsLegacy = PredicateIfrType (Iterator);
}
if (IsLegacy == 0x2) {
PostOrderEvaluate (FileFormTags, Width, &Iterator, &StackPtr);
break;
}
break;
case EFI_IFR_FALSE_OP:
//
// To check whether Ifr is legacy. Once every boolean expression.
//
if (IsLegacy == 0) {
IsLegacy = PredicateIfrType (Iterator);
}
if (IsLegacy == 0x2) {
PostOrderEvaluate (FileFormTags, Width, &Iterator, &StackPtr);
break;
}
break;
case EFI_IFR_END_IF_OP:
Operator = PopBool (&StackPtr);
//
// If there is an error, return, otherwise keep looking - there might
// be another test that causes an error
//
if (Operator) {
if (Complex && CosmeticConsistency) {
return EFI_SUCCESS;
} else {
return Operator;
}
} else {
//
// If not doing a global consistency check, the endif is the REAL terminator of this operation
// This is used for grayout/suppress operations. InconsistentIf is a global operation so the EndIf is
// not the end-all be-all of terminators.
//
if (!Complex) {
return Operator;
}
break;
}
default:
//
// Must have hit a non-consistency related op-code after a suppress/grayout
//
if (ArtificialEnd) {
ArtificialEnd = FALSE;
Operator = PopBool (&StackPtr);
return Operator;
}
return FALSE;
}
Iterator++;
}
return FALSE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?