setup.c
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C语言 代码 · 共 1,957 行 · 第 1/5 页
C
1,957 行
IfrToFormTag (RawFormSet[Index], &FormTags->Tags[CurrTag], (VOID *) &RawFormSet[Index], NULL);
}
break;
case EFI_IFR_BANNER_OP:
if (gClassOfVfr == EFI_FRONT_PAGE_SUBCLASS) {
TempValue = 0;
EfiCopyMem (&TempValue, &((EFI_IFR_BANNER *) &RawFormSet[Index])->Alignment, sizeof (UINT8));
//
// If this is the special timeout value, we will dynamically figure out where to put it
// Also the least significant byte refers to the TimeOut desired.
//
if (TempValue == EFI_IFR_BANNER_TIMEOUT) {
EfiCopyMem (&FrontPageTimeOutTitle, &((EFI_IFR_BANNER *) &RawFormSet[Index])->Title, sizeof (UINT16));
if (FrontPageTimeOutValue != 0xFFFF) {
EfiCopyMem (&FrontPageTimeOutValue, &((EFI_IFR_BANNER *) &RawFormSet[Index])->LineNumber, sizeof (UINT16));
}
break;
}
EfiCopyMem (
&BannerData->Banner[((EFI_IFR_BANNER *) &RawFormSet[Index])->LineNumber][
((EFI_IFR_BANNER *) &RawFormSet[Index])->Alignment],
&((EFI_IFR_BANNER *) &RawFormSet[Index])->Title,
sizeof (STRING_REF)
);
}
break;
case EFI_IFR_INCONSISTENT_IF_OP:
EfiCopyMem (
&FormTags->Tags[CurrTag].Text,
&((EFI_IFR_INCONSISTENT *) &RawFormSet[Index])->Popup,
sizeof (UINT16)
);
gConsistencyId++;
InconsistentTags->Operand = ((EFI_IFR_INCONSISTENT *) &RawFormSet[Index])->Header.OpCode;
EfiCopyMem (&InconsistentTags->Popup, &((EFI_IFR_INCONSISTENT *) &RawFormSet[Index])->Popup, sizeof (UINT16));
//
// Since this op-code doesn't use the next field(s), initialize them with something invalid.
// Unfortunately 0 is a valid offset value for a QuestionId
//
InconsistentTags->QuestionId1 = INVALID_OFFSET_VALUE;
InconsistentTags->QuestionId2 = INVALID_OFFSET_VALUE;
InconsistentTags->VariableNumber = CurrentVariable;
//
// Test for an allocated buffer. If already allocated this is due to having called this routine
// once for sizing of the NV storage. We then loaded the NV variable and can correctly initialize
// the tag structure with current values from the NV
//
if (InconsistentTags->Next == NULL) {
AddNextInconsistentTag (&InconsistentTags);
break;
}
InconsistentTags = InconsistentTags->Next;
break;
case EFI_IFR_EQ_ID_VAL_OP:
IfrToFormTag (RawFormSet[Index], &FormTags->Tags[CurrTag], (VOID *) &RawFormSet[Index], NULL);
InconsistentTags->Operand = ((EFI_IFR_EQ_ID_VAL *) &RawFormSet[Index])->Header.OpCode;
EfiCopyMem (&InconsistentTags->Value, &((EFI_IFR_EQ_ID_VAL *) &RawFormSet[Index])->Value, sizeof (UINT16));
EfiCopyMem (
&InconsistentTags->QuestionId1,
&((EFI_IFR_EQ_ID_VAL *) &RawFormSet[Index])->QuestionId,
sizeof (UINT16)
);
//
// Since this op-code doesn't use the next field(s), initialize them with something invalid.
// Unfortunately 0 is a valid offset value for a QuestionId
//
InconsistentTags->Width = FormTags->Tags[CurrTag].StorageWidth;
InconsistentTags->QuestionId2 = INVALID_OFFSET_VALUE;
InconsistentTags->ConsistencyId = gConsistencyId;
FormTags->Tags[CurrTag].ConsistencyId = gConsistencyId;
InconsistentTags->VariableNumber = CurrentVariable;
//
// Test for an allocated buffer. If already allocated this is due to having called this routine
// once for sizing of the NV storage. We then loaded the NV variable and can correctly initialize
// the tag structure with current values from the NV
//
if (InconsistentTags->Next == NULL) {
AddNextInconsistentTag (&InconsistentTags);
break;
}
InconsistentTags = InconsistentTags->Next;
break;
case EFI_IFR_EQ_VAR_VAL_OP:
IfrToFormTag (RawFormSet[Index], &FormTags->Tags[CurrTag], (VOID *) &RawFormSet[Index], NULL);
InconsistentTags->Operand = ((EFI_IFR_EQ_VAR_VAL *) &RawFormSet[Index])->Header.OpCode;
EfiCopyMem (&InconsistentTags->Value, &((EFI_IFR_EQ_VAR_VAL *) &RawFormSet[Index])->Value, sizeof (UINT16));
EfiCopyMem (
&InconsistentTags->QuestionId1,
&((EFI_IFR_EQ_VAR_VAL *) &RawFormSet[Index])->VariableId,
sizeof (UINT16)
);
//
// Since this op-code doesn't use the next field(s), initialize them with something invalid.
// Unfortunately 0 is a valid offset value for a QuestionId
//
InconsistentTags->QuestionId2 = INVALID_OFFSET_VALUE;
InconsistentTags->ConsistencyId = gConsistencyId;
FormTags->Tags[CurrTag].ConsistencyId = gConsistencyId;
InconsistentTags->VariableNumber = CurrentVariable;
//
// Test for an allocated buffer. If already allocated this is due to having called this routine
// once for sizing of the NV storage. We then loaded the NV variable and can correctly initialize
// the tag structure with current values from the NV
//
if (InconsistentTags->Next == NULL) {
AddNextInconsistentTag (&InconsistentTags);
break;
}
InconsistentTags = InconsistentTags->Next;
break;
case EFI_IFR_EQ_ID_ID_OP:
IfrToFormTag (RawFormSet[Index], &FormTags->Tags[CurrTag], (VOID *) &RawFormSet[Index], NULL);
InconsistentTags->Operand = ((EFI_IFR_EQ_ID_ID *) &RawFormSet[Index])->Header.OpCode;
EfiCopyMem (
&InconsistentTags->QuestionId1,
&((EFI_IFR_EQ_ID_ID *) &RawFormSet[Index])->QuestionId1,
sizeof (UINT16)
);
EfiCopyMem (
&InconsistentTags->QuestionId2,
&((EFI_IFR_EQ_ID_ID *) &RawFormSet[Index])->QuestionId2,
sizeof (UINT16)
);
InconsistentTags->Width = FormTags->Tags[CurrTag].StorageWidth;
InconsistentTags->ConsistencyId = gConsistencyId;
FormTags->Tags[CurrTag].ConsistencyId = gConsistencyId;
InconsistentTags->VariableNumber = CurrentVariable;
InconsistentTags->VariableNumber2 = CurrentVariable2;
//
// Test for an allocated buffer. If already allocated this is due to having called this routine
// once for sizing of the NV storage. We then loaded the NV variable and can correctly initialize
// the tag structure with current values from the NV
//
if (InconsistentTags->Next == NULL) {
AddNextInconsistentTag (&InconsistentTags);
break;
}
InconsistentTags = InconsistentTags->Next;
break;
case EFI_IFR_AND_OP:
case EFI_IFR_OR_OP:
case EFI_IFR_NOT_OP:
case EFI_IFR_GT_OP:
case EFI_IFR_GE_OP:
case EFI_IFR_TRUE_OP:
case EFI_IFR_FALSE_OP:
InconsistentTags->Operand = ((EFI_IFR_NOT *) &RawFormSet[Index])->Header.OpCode;
//
// Since this op-code doesn't use the next field(s), initialize them with something invalid.
// Unfortunately 0 is a valid offset value for a QuestionId
//
//
// Reserve INVALID_OFFSET_VALUE - 1 for TRUE or FALSE because they are inconsistency tags also, but
// have no coresponding id. The examination of id is needed by evaluating boolean expression.
//
if (RawFormSet[Index] == EFI_IFR_TRUE_OP ||
RawFormSet[Index] == EFI_IFR_FALSE_OP) {
InconsistentTags->QuestionId1 = INVALID_OFFSET_VALUE - 1;
} else {
InconsistentTags->QuestionId1 = INVALID_OFFSET_VALUE;
}
InconsistentTags->QuestionId2 = INVALID_OFFSET_VALUE;
InconsistentTags->ConsistencyId = gConsistencyId;
FormTags->Tags[CurrTag].ConsistencyId = gConsistencyId;
//
// Test for an allocated buffer. If already allocated this is due to having called this routine
// once for sizing of the NV storage. We then loaded the NV variable and can correctly initialize
// the tag structure with current values from the NV
//
if (InconsistentTags->Next == NULL) {
AddNextInconsistentTag (&InconsistentTags);
break;
}
InconsistentTags = InconsistentTags->Next;
break;
case EFI_IFR_EQ_ID_LIST_OP:
IfrToFormTag (RawFormSet[Index], &FormTags->Tags[CurrTag], (VOID *) &RawFormSet[Index], NULL);
InconsistentTags->Operand = ((EFI_IFR_EQ_ID_LIST *) &RawFormSet[Index])->Header.OpCode;
EfiCopyMem (
&InconsistentTags->QuestionId1,
&((EFI_IFR_EQ_ID_LIST *) &RawFormSet[Index])->QuestionId,
sizeof (UINT16)
);
EfiCopyMem (
&InconsistentTags->ListLength,
&((EFI_IFR_EQ_ID_LIST *) &RawFormSet[Index])->ListLength,
sizeof (UINT16)
);
InconsistentTags->ValueList = FormTags->Tags[CurrTag].IntList;
//
// Since this op-code doesn't use the next field(s), initialize them with something invalid.
// Unfortunately 0 is a valid offset value for a QuestionId
//
InconsistentTags->Width = FormTags->Tags[CurrTag].StorageWidth;
InconsistentTags->QuestionId2 = INVALID_OFFSET_VALUE;
InconsistentTags->ConsistencyId = gConsistencyId;
FormTags->Tags[CurrTag].ConsistencyId = gConsistencyId;
//
// Test for an allocated buffer. If already allocated this is due to having called this routine
// once for sizing of the NV storage. We then loaded the NV variable and can correctly initialize
// the tag structure with current values from the NV
//
if (InconsistentTags->Next == NULL) {
AddNextInconsistentTag (&InconsistentTags);
break;
}
InconsistentTags = InconsistentTags->Next;
break;
case EFI_IFR_END_IF_OP:
InconsistentTags->Operand = ((EFI_IFR_END_IF *) &RawFormSet[Index])->Header.OpCode;
//
// Since this op-code doesn't use the next field(s), initialize them with something invalid.
// Unfortunately 0 is a valid offset value for a QuestionId
//
InconsistentTags->QuestionId1 = INVALID_OFFSET_VALUE;
InconsistentTags->QuestionId2 = INVALID_OFFSET_VALUE;
//
// Test for an allocated buffer. If already allocated this is due to having called this routine
// once for sizing of the NV storage. We then loaded the NV variable and can correctly initialize
// the tag structure with current values from the NV
//
if (InconsistentTags->Next == NULL) {
AddNextInconsistentTag (&InconsistentTags);
break;
}
InconsistentTags = InconsistentTags->Next;
break;
case EFI_IFR_END_ONE_OF_OP:
break;
default:
break;
}
//
// End of switch
//
// Per spec., we ignore ops that we don't know how to deal with. Skip to next tag
//
Index = (UINT16) (Index + TagLength);
}
//
// End of Index
//
// When we eventually exit, make sure we mark the last tag with an op-code
//
FormTags->Tags[CurrTag].Operand = RawFormSet[Index];
IfrToFormTag (RawFormSet[Index], &FormTags->Tags[CurrTag], (VOID *) &RawFormSet[Index], NULL);
//
// Place this as an end of the database marker
//
InconsistentTags->Operand = 0xFF;
//
// This is the Head of the linked list of pages. Each page is an array of tags
//
FormTags = &FileFormTags->FormTags;
InconsistentTags = FileFormTags->InconsistentTags;
for (; InconsistentTags->Operand != 0xFF;) {
if (InconsistentTags->QuestionId1 != INVALID_OFFSET_VALUE) {
//
// Search the tags for the tag which corresponds to this ID
//
for (CurrTag = 0; FormTags->Tags[0].Operand != EFI_IFR_END_FORM_SET_OP; CurrTag++) {
//
// If we hit the end of a form, go to the next set of Tags.
// Remember - EndFormSet op-codes sit on their own page after an end form.
//
if (FormTags->Tags[CurrTag].Operand == EFI_IFR_END_FORM_OP) {
//
// Reset the CurrTag value (it will be incremented, after this case statement
// so set to a negative one so that we get the desired effect.) Fish can beat me later.
//
CurrTag = -1;
FormTags = FormTags->Next;
continue;
}
if (FormTags->Tags[CurrTag].Id == InconsistentTags->QuestionId1) {
FormTags->Tags[CurrTag].Consistency++;
}
}
}
FormTags = &FileFormTags->FormTags;
if (InconsistentTags->QuestionId2 != INVALID_OFFSET_VALUE) {
//
// Search the tags for the tag which corresponds to this ID
//
for (CurrTag = 0; FormTags->Tags[CurrTag].Operand != EFI_IFR_END_FORM_SET_OP; CurrTag++) {
//
// If we hit the end of a form, go to the next set of Tags.
// Remember - EndFormSet op-codes sit on their own page after an end form.
//
if (FormTags->Tags[CurrTag].Operand == EFI_IFR_END_FORM_OP) {
//
// Reset the CurrTag value (it will be incremented, after this case statement
// so set to a negative one so that we get the desired effect.) Fish can beat me later.
//
CurrTag = -1;
FormTags = FormTags->Next;
continue;
}
if (FormTags->Tags[CurrTag].Id == InconsistentTags->QuestionId2) {
FormTags->Tags[CurrTag].Consistency++;
}
}
}
InconsistentTags = InconsistentTags->Next;
}
return Status;
}
VOID
InitPage (
VOID
)
{
CHAR16 *HomePageString;
CHAR16 *HomeEscapeString;
//
// Displays the Header and Footer borders
//
DisplayPageFrame ();
HomePageString = GetToken (STRING_TOKEN (HOME_PAGE_TITLE), gHiiHandle);
HomeEscapeString = GetToken (STRING_TOKEN (HOME_ESCAPE_STRING), gHiiHandle);
gST->ConOut->SetAttribute (gST->ConOut, EFI_YELLOW | EFI_BRIGHT);
//
// PrintStringAt ((gScreenDimensions.RightColumn - GetStringWidth(HomePageString)/2)/2, 1, HomePageString);
//
PrintStringAt (
(gScreenDimensions.RightColumn + gScreenDimensions.LeftColumn - GetStringWidth (HomePageString) / 2) / 2,
1,
HomePageString
);
PrintAt (
gScreenDimensions.LeftColumn + 2,
gScreenDimensions.BottomRow - 3,
L"%c%c%s",
ARROW_UP,
ARROW_DOWN,
gMoveHighlight
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?