13UINTN mVarCheckHiiBinSize = 0;
16#define VAR_CHECK_HII_VARIABLE_NODE_SIGNATURE SIGNATURE_32 ('V', 'C', 'H', 'V')
22 EFI_VARSTORE_ID VarStoreId;
27#define VAR_CHECK_HII_VARIABLE_FROM_LINK(a) CR (a, VAR_CHECK_HII_VARIABLE_NODE, Link, VAR_CHECK_HII_VARIABLE_NODE_SIGNATURE)
29CHAR16 *mVarName =
NULL;
30UINTN mMaxVarNameSize = 0;
34 { EFI_IFR_VARSTORE_OP,
"EFI_IFR_VARSTORE_OP" },
35 { EFI_IFR_VARSTORE_EFI_OP,
"EFI_IFR_VARSTORE_EFI_OP" },
36 { EFI_IFR_ONE_OF_OP,
"EFI_IFR_ONE_OF_OP" },
37 { EFI_IFR_CHECKBOX_OP,
"EFI_IFR_CHECKBOX_OP" },
38 { EFI_IFR_NUMERIC_OP,
"EFI_IFR_NUMERIC_OP" },
39 { EFI_IFR_ORDERED_LIST_OP,
"EFI_IFR_ORDERED_LIST_OP" },
40 { EFI_IFR_ONE_OF_OPTION_OP,
"EFI_IFR_ONE_OF_OPTION_OP" },
58 for (Index = 0; Index <
ARRAY_SIZE (mIfrOpCodeStringTable); Index++) {
59 if (mIfrOpCodeStringTable[Index].HiiOpCode == IfrOpCode) {
60 return mIfrOpCodeStringTable[Index].HiiOpCodeStr;
64 return "<UnknownIfrOpCode>";
68 { EFI_HII_PACKAGE_TYPE_ALL,
"EFI_HII_PACKAGE_TYPE_ALL" },
69 { EFI_HII_PACKAGE_TYPE_GUID,
"EFI_HII_PACKAGE_TYPE_GUID" },
70 { EFI_HII_PACKAGE_FORMS,
"EFI_HII_PACKAGE_FORMS" },
71 { EFI_HII_PACKAGE_STRINGS,
"EFI_HII_PACKAGE_STRINGS" },
72 { EFI_HII_PACKAGE_FONTS,
"EFI_HII_PACKAGE_FONTS" },
73 { EFI_HII_PACKAGE_IMAGES,
"EFI_HII_PACKAGE_IMAGES" },
74 { EFI_HII_PACKAGE_SIMPLE_FONTS,
"EFI_HII_PACKAGE_SIMPLE_FONTS" },
75 { EFI_HII_PACKAGE_DEVICE_PATH,
"EFI_HII_PACKAGE_DEVICE_PATH" },
76 { EFI_HII_PACKAGE_KEYBOARD_LAYOUT,
"EFI_HII_PACKAGE_KEYBOARD_LAYOUT" },
77 { EFI_HII_PACKAGE_ANIMATIONS,
"EFI_HII_PACKAGE_ANIMATIONS" },
78 { EFI_HII_PACKAGE_END,
"EFI_HII_PACKAGE_END" },
79 { EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN,
"EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN" },
80 { EFI_HII_PACKAGE_TYPE_SYSTEM_END,
"EFI_HII_PACKAGE_TYPE_SYSTEM_END" },
98 for (Index = 0; Index <
ARRAY_SIZE (mPackageTypeStringTable); Index++) {
99 if (mPackageTypeStringTable[Index].PackageType == PackageType) {
100 return mPackageTypeStringTable[Index].PackageTypeStr;
104 return "<UnknownPackageType>";
122 BOOLEAN QuestionStoredInBitField;
125 QuestionStoredInBitField =
FALSE;
127 DEBUG ((DEBUG_INFO,
" HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPackageHeader->Type, HiiPackageTypeToStr ((UINT8)HiiPackageHeader->Type)));
128 DEBUG ((DEBUG_INFO,
" HiiPackageHeader->Length - 0x%06x\n", HiiPackageHeader->Length));
130 switch (HiiPackageHeader->Type) {
131 case EFI_HII_PACKAGE_FORMS:
134 while ((
UINTN)IfrOpCodeHeader < ((
UINTN)HiiPackageHeader + HiiPackageHeader->Length)) {
135 switch (IfrOpCodeHeader->OpCode) {
136 case EFI_IFR_VARSTORE_OP:
138 DEBUG ((DEBUG_INFO,
" IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode)));
139 DEBUG ((DEBUG_INFO,
" IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length));
140 DEBUG ((DEBUG_INFO,
" IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope));
141 DEBUG ((DEBUG_INFO,
" Guid - %g\n", &IfrVarStore->Guid));
142 DEBUG ((DEBUG_INFO,
" VarStoreId - 0x%04x\n", IfrVarStore->VarStoreId));
143 DEBUG ((DEBUG_INFO,
" Size - 0x%04x\n", IfrVarStore->Size));
144 DEBUG ((DEBUG_INFO,
" Name - %a\n", IfrVarStore->Name));
147 case EFI_IFR_VARSTORE_EFI_OP:
150 DEBUG ((DEBUG_INFO,
" IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode)));
151 DEBUG ((DEBUG_INFO,
" IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length));
152 DEBUG ((DEBUG_INFO,
" IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope));
153 DEBUG ((DEBUG_INFO,
" Guid - %g\n", &IfrEfiVarStore->Guid));
154 DEBUG ((DEBUG_INFO,
" VarStoreId - 0x%04x\n", IfrEfiVarStore->VarStoreId));
155 DEBUG ((DEBUG_INFO,
" Size - 0x%04x\n", IfrEfiVarStore->Size));
156 DEBUG ((DEBUG_INFO,
" Attributes - 0x%08x\n", IfrEfiVarStore->Attributes));
157 DEBUG ((DEBUG_INFO,
" Name - %a\n", IfrEfiVarStore->Name));
162 case EFI_IFR_GUID_OP:
164 QuestionStoredInBitField =
TRUE;
169 case EFI_IFR_ONE_OF_OP:
170 case EFI_IFR_CHECKBOX_OP:
171 case EFI_IFR_NUMERIC_OP:
172 case EFI_IFR_ORDERED_LIST_OP:
173 DEBUG ((DEBUG_INFO,
" IfrOpCodeHeader->OpCode - 0x%02x (%a) (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode), (QuestionStoredInBitField ?
"bit level" :
"byte level")));
174 DEBUG ((DEBUG_INFO,
" IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length));
175 DEBUG ((DEBUG_INFO,
" IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope));
176 DEBUG ((DEBUG_INFO,
" Prompt - 0x%04x\n", ((
EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.Header.Prompt));
177 DEBUG ((DEBUG_INFO,
" Help - 0x%04x\n", ((
EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.Header.Help));
178 DEBUG ((DEBUG_INFO,
" QuestionId - 0x%04x\n", ((
EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.QuestionId));
179 DEBUG ((DEBUG_INFO,
" VarStoreId - 0x%04x\n", ((
EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.VarStoreId));
180 DEBUG ((DEBUG_INFO,
" VarStoreInfo - 0x%04x (%a)\n", ((
EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset, (QuestionStoredInBitField ?
"bit level" :
"byte level")));
187 switch (IfrOpCodeHeader->OpCode) {
188 case EFI_IFR_ONE_OF_OP:
190 DEBUG ((DEBUG_INFO,
" Flags - 0x%02x\n", IfrOneOf->Flags));
191 if (QuestionStoredInBitField) {
195 DEBUG ((DEBUG_INFO,
" MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue));
196 DEBUG ((DEBUG_INFO,
" MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue));
197 DEBUG ((DEBUG_INFO,
" Step - 0x%08x\n", IfrOneOf->data.u32.Step));
199 switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) {
200 case EFI_IFR_NUMERIC_SIZE_1:
201 DEBUG ((DEBUG_INFO,
" MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue));
202 DEBUG ((DEBUG_INFO,
" MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue));
203 DEBUG ((DEBUG_INFO,
" Step - 0x%02x\n", IfrOneOf->data.u8.Step));
205 case EFI_IFR_NUMERIC_SIZE_2:
206 DEBUG ((DEBUG_INFO,
" MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue));
207 DEBUG ((DEBUG_INFO,
" MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue));
208 DEBUG ((DEBUG_INFO,
" Step - 0x%04x\n", IfrOneOf->data.u16.Step));
210 case EFI_IFR_NUMERIC_SIZE_4:
211 DEBUG ((DEBUG_INFO,
" MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue));
212 DEBUG ((DEBUG_INFO,
" MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue));
213 DEBUG ((DEBUG_INFO,
" Step - 0x%08x\n", IfrOneOf->data.u32.Step));
215 case EFI_IFR_NUMERIC_SIZE_8:
216 DEBUG ((DEBUG_INFO,
" MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue));
217 DEBUG ((DEBUG_INFO,
" MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue));
218 DEBUG ((DEBUG_INFO,
" Step - 0x%016lx\n", IfrOneOf->data.u64.Step));
224 case EFI_IFR_CHECKBOX_OP:
226 DEBUG ((DEBUG_INFO,
" Flags - 0x%02x\n", IfrCheckBox->Flags));
228 case EFI_IFR_NUMERIC_OP:
230 DEBUG ((DEBUG_INFO,
" Flags - 0x%02x\n", IfrNumeric->Flags));
231 if (QuestionStoredInBitField) {
235 DEBUG ((DEBUG_INFO,
" MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue));
236 DEBUG ((DEBUG_INFO,
" MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue));
237 DEBUG ((DEBUG_INFO,
" Step - 0x%08x\n", IfrNumeric->data.u32.Step));
239 switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
240 case EFI_IFR_NUMERIC_SIZE_1:
241 DEBUG ((DEBUG_INFO,
" MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue));
242 DEBUG ((DEBUG_INFO,
" MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue));
243 DEBUG ((DEBUG_INFO,
" Step - 0x%02x\n", IfrNumeric->data.u8.Step));
245 case EFI_IFR_NUMERIC_SIZE_2:
246 DEBUG ((DEBUG_INFO,
" MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue));
247 DEBUG ((DEBUG_INFO,
" MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue));
248 DEBUG ((DEBUG_INFO,
" Step - 0x%04x\n", IfrNumeric->data.u16.Step));
250 case EFI_IFR_NUMERIC_SIZE_4:
251 DEBUG ((DEBUG_INFO,
" MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue));
252 DEBUG ((DEBUG_INFO,
" MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue));
253 DEBUG ((DEBUG_INFO,
" Step - 0x%08x\n", IfrNumeric->data.u32.Step));
255 case EFI_IFR_NUMERIC_SIZE_8:
256 DEBUG ((DEBUG_INFO,
" MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue));
257 DEBUG ((DEBUG_INFO,
" MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue));
258 DEBUG ((DEBUG_INFO,
" Step - 0x%016lx\n", IfrNumeric->data.u64.Step));
264 case EFI_IFR_ORDERED_LIST_OP:
266 DEBUG ((DEBUG_INFO,
" MaxContainers - 0x%02x\n", IfrOrderedList->MaxContainers));
267 DEBUG ((DEBUG_INFO,
" Flags - 0x%02x\n", IfrOrderedList->Flags));
273 if (IfrOpCodeHeader->Scope != 0) {
280 switch (IfrOpCodeHeader->OpCode) {
281 case EFI_IFR_ONE_OF_OPTION_OP:
283 DEBUG ((DEBUG_INFO,
"!!!! IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", (
UINTN)IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode)));
284 DEBUG ((DEBUG_INFO,
"!!!! IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope));
285 DEBUG ((DEBUG_INFO,
"!!!! Option - 0x%04x\n", IfrOneOfOption->Option));
286 DEBUG ((DEBUG_INFO,
"!!!! Flags - 0x%02x\n", IfrOneOfOption->Flags));
287 DEBUG ((DEBUG_INFO,
"!!!! Type - 0x%02x\n", IfrOneOfOption->Type));
288 switch (IfrOneOfOption->Type) {
289 case EFI_IFR_TYPE_NUM_SIZE_8:
290 DEBUG ((DEBUG_INFO,
"!!!! Value - 0x%02x\n", IfrOneOfOption->Value.u8));
292 case EFI_IFR_TYPE_NUM_SIZE_16:
293 DEBUG ((DEBUG_INFO,
"!!!! Value - 0x%04x\n", IfrOneOfOption->Value.u16));
295 case EFI_IFR_TYPE_NUM_SIZE_32:
296 DEBUG ((DEBUG_INFO,
"!!!! Value - 0x%08x\n", IfrOneOfOption->Value.u32));
298 case EFI_IFR_TYPE_NUM_SIZE_64:
299 DEBUG ((DEBUG_INFO,
"!!!! Value - 0x%016lx\n", IfrOneOfOption->Value.u64));
301 case EFI_IFR_TYPE_BOOLEAN:
302 DEBUG ((DEBUG_INFO,
"!!!! Value - 0x%02x\n", IfrOneOfOption->Value.b));
311 if (IfrOpCodeHeader->OpCode == EFI_IFR_END_OP) {
312 QuestionStoredInBitField =
FALSE;
318 }
else if (IfrOpCodeHeader->Scope != 0) {
348 IN VOID *HiiDatabase,
355 DEBUG ((DEBUG_INFO,
"HiiDatabaseSize - 0x%x\n", HiiDatabaseSize));
358 while ((
UINTN)HiiPackageListHeader < ((
UINTN)HiiDatabase + HiiDatabaseSize)) {
359 DEBUG ((DEBUG_INFO,
"HiiPackageListHeader->PackageListGuid - %g\n", &HiiPackageListHeader->PackageListGuid));
360 DEBUG ((DEBUG_INFO,
"HiiPackageListHeader->PackageLength - 0x%x\n", (
UINTN)HiiPackageListHeader->PackageLength));
363 while ((
UINTN)HiiPackageHeader < (
UINTN)HiiPackageListHeader + HiiPackageListHeader->PackageLength) {
399 Status =
gBS->AllocatePool (MemoryType, AllocationSize, &Memory);
400 if (EFI_ERROR (Status)) {
428 if (Memory !=
NULL) {
429 Memory =
ZeroMem (Memory, AllocationSize);
457 Status =
gBS->FreePool (Buffer);
486 IN VOID *OldBuffer OPTIONAL
492 if ((NewBuffer !=
NULL) && (OldBuffer !=
NULL)) {
493 CopyMem (NewBuffer, OldBuffer,
MIN (OldSize, NewSize));
539 if (HiiQuestion->BitFieldStore) {
540 ArrayIndex = HiiQuestion->VarOffset;
542 ArrayIndex = HiiQuestion->VarOffset * 8;
545 HiiQuestion1 = HiiVariableNode->HiiQuestionArray[ArrayIndex];
546 HiiQuestion2 = HiiQuestion;
548 ASSERT ((HiiQuestion1->OpCode == HiiQuestion2->OpCode) && (HiiQuestion1->StorageWidth == HiiQuestion2->StorageWidth));
550 switch (HiiQuestion1->OpCode) {
551 case EFI_IFR_ONE_OF_OP:
552 DEBUG ((DEBUG_INFO,
"MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore ?
"bit level" :
"byte level")));
556 NewLength = HiiQuestion1->Length;
562 while ((
UINTN)Ptr2 < (
UINTN)HiiQuestion2 + HiiQuestion2->Length) {
564 CopyMem (&OneValue2, Ptr2, HiiQuestion2->StorageWidth);
567 while ((
UINTN)Ptr1 < (
UINTN)HiiQuestion1 + HiiQuestion1->Length) {
569 CopyMem (&OneValue1, Ptr1, HiiQuestion1->StorageWidth);
570 if (OneValue2 == OneValue1) {
577 Ptr1 += HiiQuestion1->StorageWidth;
580 if ((
UINTN)Ptr1 >= ((
UINTN)HiiQuestion1 + HiiQuestion1->Length)) {
584 NewLength = (UINT8)(NewLength + HiiQuestion1->StorageWidth);
587 Ptr2 += HiiQuestion2->StorageWidth;
590 if (NewLength > HiiQuestion1->Length) {
595 ASSERT (NewHiiQuestion !=
NULL);
596 CopyMem (NewHiiQuestion, HiiQuestion1, HiiQuestion1->Length);
600 NewHiiQuestion->Length = NewLength;
601 Ptr = (UINT8 *)NewHiiQuestion + HiiQuestion1->Length;
604 while ((
UINTN)Ptr2 < (
UINTN)HiiQuestion2 + HiiQuestion2->Length) {
606 CopyMem (&OneValue2, Ptr2, HiiQuestion2->StorageWidth);
609 while ((
UINTN)Ptr1 < (
UINTN)HiiQuestion1 + HiiQuestion1->Length) {
611 CopyMem (&OneValue1, Ptr1, HiiQuestion1->StorageWidth);
612 if (OneValue2 == OneValue1) {
619 Ptr1 += HiiQuestion1->StorageWidth;
622 if ((
UINTN)Ptr1 >= ((
UINTN)HiiQuestion1 + HiiQuestion1->Length)) {
626 CopyMem (Ptr, &OneValue2, HiiQuestion1->StorageWidth);
627 Ptr += HiiQuestion1->StorageWidth;
630 Ptr2 += HiiQuestion2->StorageWidth;
633 HiiVariableNode->HiiQuestionArray[ArrayIndex] = NewHiiQuestion;
639 case EFI_IFR_CHECKBOX_OP:
640 DEBUG ((DEBUG_INFO,
"MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore ?
"bit level" :
"byte level")));
643 case EFI_IFR_NUMERIC_OP:
644 DEBUG ((DEBUG_INFO,
"MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore ?
"bit level" :
"byte level")));
651 CopyMem (&Minimum1, Ptr, HiiQuestion1->StorageWidth);
652 Ptr += HiiQuestion1->StorageWidth;
653 CopyMem (&Maximum1, Ptr, HiiQuestion1->StorageWidth);
661 CopyMem (&Minimum2, Ptr, HiiQuestion2->StorageWidth);
662 Ptr += HiiQuestion2->StorageWidth;
663 CopyMem (&Maximum2, Ptr, HiiQuestion2->StorageWidth);
669 if (Minimum2 < Minimum1) {
671 CopyMem (Ptr, &Minimum1, HiiQuestion1->StorageWidth);
677 Ptr += HiiQuestion1->StorageWidth;
678 if (Maximum2 > Maximum1) {
680 CopyMem (Ptr, &Maximum1, HiiQuestion1->StorageWidth);
685 case EFI_IFR_ORDERED_LIST_OP:
686 DEBUG ((DEBUG_INFO,
"MergeHiiQuestion - EFI_IFR_ORDERED_LIST_OP VarOffset = 0x%04x\n", HiiQuestion1->VarOffset));
690 NewLength = HiiQuestion1->Length;
696 while ((
UINTN)Ptr2 < (
UINTN)HiiQuestion2 + HiiQuestion2->Length) {
698 CopyMem (&OneValue2, Ptr2, HiiQuestion2->StorageWidth);
701 while ((
UINTN)Ptr1 < (
UINTN)HiiQuestion1 + HiiQuestion1->Length) {
703 CopyMem (&OneValue1, Ptr1, HiiQuestion1->StorageWidth);
704 if (OneValue2 == OneValue1) {
711 Ptr1 += HiiQuestion1->StorageWidth;
714 if ((
UINTN)Ptr1 >= ((
UINTN)HiiQuestion1 + HiiQuestion1->Length)) {
718 NewLength = (UINT8)(NewLength + HiiQuestion1->StorageWidth);
721 Ptr2 += HiiQuestion2->StorageWidth;
724 if (NewLength > HiiQuestion1->Length) {
729 ASSERT (NewHiiQuestion !=
NULL);
730 CopyMem (NewHiiQuestion, HiiQuestion1, HiiQuestion1->Length);
734 NewHiiQuestion->Length = NewLength;
735 Ptr = (UINT8 *)NewHiiQuestion + HiiQuestion1->Length;
738 while ((
UINTN)Ptr2 < (
UINTN)HiiQuestion2 + HiiQuestion2->Length) {
740 CopyMem (&OneValue2, Ptr2, HiiQuestion2->StorageWidth);
743 while ((
UINTN)Ptr1 < (
UINTN)HiiQuestion1 + HiiQuestion1->Length) {
745 CopyMem (&OneValue1, Ptr1, HiiQuestion1->StorageWidth);
746 if (OneValue2 == OneValue1) {
753 Ptr1 += HiiQuestion1->StorageWidth;
756 if ((
UINTN)Ptr1 >= ((
UINTN)HiiQuestion1 + HiiQuestion1->Length)) {
760 CopyMem (Ptr, &OneValue2, HiiQuestion1->StorageWidth);
761 Ptr += HiiQuestion1->StorageWidth;
764 Ptr2 += HiiQuestion2->StorageWidth;
767 HiiVariableNode->HiiQuestionArray[ArrayIndex] = NewHiiQuestion;
800 OUT VOID *OptionBuffer OPTIONAL
811 if (IfrOpCodeHeader->Scope != 0) {
818 switch (IfrOpCodeHeader->OpCode) {
819 case EFI_IFR_ONE_OF_OPTION_OP:
821 switch (IfrOneOfOption->Type) {
822 case EFI_IFR_TYPE_NUM_SIZE_8:
824 *Width =
sizeof (UINT8);
825 if (OptionBuffer !=
NULL) {
826 CopyMem (OptionBuffer, &IfrOneOfOption->Value.u8, sizeof (UINT8));
827 OptionBuffer = (UINT8 *)OptionBuffer + 1;
831 case EFI_IFR_TYPE_NUM_SIZE_16:
833 *Width =
sizeof (UINT16);
834 if (OptionBuffer !=
NULL) {
835 CopyMem (OptionBuffer, &IfrOneOfOption->Value.u16, sizeof (UINT16));
836 OptionBuffer = (UINT16 *)OptionBuffer + 1;
840 case EFI_IFR_TYPE_NUM_SIZE_32:
842 *Width =
sizeof (UINT32);
843 if (OptionBuffer !=
NULL) {
844 CopyMem (OptionBuffer, &IfrOneOfOption->Value.u32, sizeof (UINT32));
845 OptionBuffer = (UINT32 *)OptionBuffer + 1;
849 case EFI_IFR_TYPE_NUM_SIZE_64:
851 *Width =
sizeof (UINT64);
852 if (OptionBuffer !=
NULL) {
853 CopyMem (OptionBuffer, &IfrOneOfOption->Value.u64, sizeof (UINT64));
854 OptionBuffer = (UINT64 *)OptionBuffer + 1;
858 case EFI_IFR_TYPE_BOOLEAN:
860 *Width =
sizeof (BOOLEAN);
861 if (OptionBuffer !=
NULL) {
862 CopyMem (OptionBuffer, &IfrOneOfOption->Value.b, sizeof (BOOLEAN));
863 OptionBuffer = (BOOLEAN *)OptionBuffer + 1;
877 if (IfrOpCodeHeader->OpCode == EFI_IFR_END_OP) {
883 }
else if (IfrOpCodeHeader->Scope != 0) {
909 IN BOOLEAN StoredInBitField
923 if (StoredInBitField) {
928 BitWidth = IfrOneOf->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
929 Width =
sizeof (UINT32);
931 Width = (UINT8)(1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
935 ASSERT (Width == OptionWidth);
937 Length =
sizeof (*OneOf) + OptionCount * Width;
940 ASSERT (OneOf !=
NULL);
941 OneOf->OpCode = EFI_IFR_ONE_OF_OP;
942 OneOf->Length = (UINT8)Length;
943 OneOf->VarOffset = IfrOneOf->Question.VarStoreInfo.VarOffset;
944 OneOf->BitFieldStore = StoredInBitField;
945 if (StoredInBitField) {
946 OneOf->StorageWidth = BitWidth;
948 OneOf->StorageWidth = Width;
951 GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OneOf + 1);
968 IN BOOLEAN StoredInBitField
977 ASSERT (CheckBox !=
NULL);
978 CheckBox->OpCode = EFI_IFR_CHECKBOX_OP;
979 CheckBox->Length = (UINT8)
sizeof (*CheckBox);
980 CheckBox->VarOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
981 CheckBox->BitFieldStore = StoredInBitField;
982 if (StoredInBitField) {
983 CheckBox->StorageWidth = 1;
985 CheckBox->StorageWidth = (UINT8)
sizeof (BOOLEAN);
1003 IN BOOLEAN StoredInBitField
1015 ASSERT (Numeric !=
NULL);
1017 if (StoredInBitField) {
1022 BitWidth = IfrNumeric->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
1023 Width =
sizeof (UINT32);
1025 Width = (UINT8)(1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE));
1028 Numeric->OpCode = EFI_IFR_NUMERIC_OP;
1030 Numeric->VarOffset = IfrNumeric->Question.VarStoreInfo.VarOffset;
1031 Numeric->BitFieldStore = StoredInBitField;
1032 if (StoredInBitField) {
1033 Numeric->StorageWidth = BitWidth;
1035 Numeric->StorageWidth = Width;
1038 CopyMem (Numeric + 1, &IfrNumeric->data, Width * 2);
1066 Length =
sizeof (*OrderedList) + OptionCount * OptionWidth;
1069 ASSERT (OrderedList !=
NULL);
1070 OrderedList->OpCode = EFI_IFR_ORDERED_LIST_OP;
1071 OrderedList->Length = (UINT8)Length;
1072 OrderedList->VarOffset = IfrOrderedList->Question.VarStoreInfo.VarOffset;
1073 OrderedList->StorageWidth = OptionWidth;
1074 OrderedList->MaxContainers = IfrOrderedList->MaxContainers;
1075 OrderedList->BitFieldStore =
FALSE;
1077 GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OrderedList + 1);
1096 IN BOOLEAN StoredInBitField
1105 switch (IfrOpCodeHeader->OpCode) {
1106 case EFI_IFR_ONE_OF_OP:
1110 case EFI_IFR_CHECKBOX_OP:
1114 case EFI_IFR_NUMERIC_OP:
1118 case EFI_IFR_ORDERED_LIST_OP:
1128 if (StoredInBitField) {
1129 ArrayIndex = HiiQuestion->VarOffset;
1131 ArrayIndex = HiiQuestion->VarOffset * 8;
1134 if (HiiVariableNode->HiiQuestionArray[ArrayIndex] !=
NULL) {
1137 HiiVariableNode->HiiQuestionArray[ArrayIndex] = HiiQuestion;
1159 for (Link = mVarCheckHiiList.ForwardLink
1160 ; Link != &mVarCheckHiiList
1161 ; Link = Link->ForwardLink)
1163 HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (Link);
1165 if ((
StrCmp (Name, (CHAR16 *)(HiiVariableNode->HiiVariable + 1)) == 0) &&
1166 CompareGuid (Guid, &HiiVariableNode->HiiVariable->Guid))
1168 return HiiVariableNode;
1185 IN EFI_VARSTORE_ID VarStoreId
1191 if (VarStoreId == 0) {
1199 for (Link = mVarCheckHiiList.ForwardLink
1200 ; Link != &mVarCheckHiiList
1201 ; Link = Link->ForwardLink)
1203 HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (Link);
1207 if (VarStoreId == HiiVariableNode->VarStoreId) {
1208 return HiiVariableNode;
1227 for (Link = mVarCheckHiiList.ForwardLink
1228 ; Link != &mVarCheckHiiList
1229 ; Link = Link->ForwardLink)
1231 HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (Link);
1236 HiiVariableNode->VarStoreId = 0;
1260 VarNameSize =
AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) *
sizeof (CHAR16);
1261 if (VarNameSize > mMaxVarNameSize) {
1263 ASSERT (mVarName !=
NULL);
1264 mMaxVarNameSize = VarNameSize;
1272 &IfrEfiVarStore->Guid
1274 if (HiiVariableNode ==
NULL) {
1278 HeaderLength =
sizeof (*HiiVariable) + VarNameSize;
1280 ASSERT (HiiVariable !=
NULL);
1281 HiiVariable->Revision = VAR_CHECK_HII_REVISION;
1282 HiiVariable->OpCode = EFI_IFR_VARSTORE_EFI_OP;
1283 HiiVariable->HeaderLength = (UINT16)HeaderLength;
1284 HiiVariable->Size = IfrEfiVarStore->Size;
1285 HiiVariable->Attributes = IfrEfiVarStore->Attributes;
1286 CopyGuid (&HiiVariable->Guid, &IfrEfiVarStore->Guid);
1287 StrCpyS ((CHAR16 *)(HiiVariable + 1), VarNameSize /
sizeof (CHAR16), VarName);
1290 ASSERT (HiiVariableNode !=
NULL);
1291 HiiVariableNode->Signature = VAR_CHECK_HII_VARIABLE_NODE_SIGNATURE;
1292 HiiVariableNode->HiiVariable = HiiVariable;
1296 HiiVariableNode->VarStoreId = IfrEfiVarStore->VarStoreId;
1301 HiiVariableNode->VarStoreId = IfrEfiVarStore->VarStoreId;
1322 switch (HiiPackageHeader->Type) {
1323 case EFI_HII_PACKAGE_FORMS:
1326 while ((
UINTN)IfrOpCodeHeader < (
UINTN)HiiPackageHeader + HiiPackageHeader->Length) {
1327 switch (IfrOpCodeHeader->OpCode) {
1328 case EFI_IFR_VARSTORE_EFI_OP:
1367 IN VOID *HiiPackage,
1374 BOOLEAN QuestionStoredInBitField;
1383 QuestionStoredInBitField =
FALSE;
1385 switch (HiiPackageHeader->Type) {
1386 case EFI_HII_PACKAGE_FORMS:
1389 while ((
UINTN)IfrOpCodeHeader < (
UINTN)HiiPackageHeader + HiiPackageHeader->Length) {
1390 switch (IfrOpCodeHeader->OpCode) {
1391 case EFI_IFR_GUID_OP:
1393 QuestionStoredInBitField =
TRUE;
1398 case EFI_IFR_END_OP:
1399 QuestionStoredInBitField =
FALSE;
1402 case EFI_IFR_ONE_OF_OP:
1403 case EFI_IFR_CHECKBOX_OP:
1404 case EFI_IFR_NUMERIC_OP:
1405 case EFI_IFR_ORDERED_LIST_OP:
1407 if ((HiiVariableNode ==
NULL) ||
1411 ((((
EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.Header.Prompt == 0) && (((
EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.Header.Help == 0)))
1420 ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, FromFv, QuestionStoredInBitField);
1448 IN VOID *HiiDatabase,
1457 while ((
UINTN)HiiPackageListHeader < ((
UINTN)HiiDatabase + HiiDatabaseSize)) {
1460 while ((
UINTN)HiiPackageHeader < ((
UINTN)HiiPackageListHeader + HiiPackageListHeader->PackageLength)) {
1486 while (mVarCheckHiiList.ForwardLink != &mVarCheckHiiList) {
1487 HiiVariableLink = mVarCheckHiiList.ForwardLink;
1488 HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink);
1495 for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (
UINTN)8; Index++) {
1496 if (HiiVariableNode->HiiQuestionArray[Index] !=
NULL) {
1526 UINT32 HiiVariableLength;
1533 for (HiiVariableLink = mVarCheckHiiList.ForwardLink
1534 ; HiiVariableLink != &mVarCheckHiiList
1535 ; HiiVariableLink = HiiVariableLink->ForwardLink)
1540 BinSize = (UINT32)HEADER_ALIGN (BinSize);
1542 HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink);
1543 HiiVariableLength = HiiVariableNode->HiiVariable->HeaderLength;
1545 for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (
UINTN)8; Index++) {
1546 if (HiiVariableNode->HiiQuestionArray[Index] !=
NULL) {
1550 HiiVariableLength = (UINT32)HEADER_ALIGN (HiiVariableLength);
1551 HiiVariableLength += HiiVariableNode->HiiQuestionArray[Index]->Length;
1555 HiiVariableNode->HiiVariable->Length = HiiVariableLength;
1556 BinSize += HiiVariableLength;
1559 DEBUG ((DEBUG_INFO,
"VarCheckHiiBin - size = 0x%x\n", BinSize));
1571 ASSERT (Data !=
NULL);
1576 DEBUG ((DEBUG_INFO,
"VarCheckHiiBin - built at 0x%x\n", Data));
1582 for (HiiVariableLink = mVarCheckHiiList.ForwardLink
1583 ; HiiVariableLink != &mVarCheckHiiList
1584 ; HiiVariableLink = HiiVariableLink->ForwardLink)
1589 Ptr = (UINT8 *)HEADER_ALIGN (Ptr);
1591 HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink);
1592 CopyMem (Ptr, HiiVariableNode->HiiVariable, HiiVariableNode->HiiVariable->HeaderLength);
1593 Ptr += HiiVariableNode->HiiVariable->HeaderLength;
1595 for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (
UINTN)8; Index++) {
1596 if (HiiVariableNode->HiiQuestionArray[Index] !=
NULL) {
1600 Ptr = (UINT8 *)HEADER_ALIGN (Ptr);
1601 CopyMem (Ptr, HiiVariableNode->HiiQuestionArray[Index], HiiVariableNode->HiiQuestionArray[Index]->Length);
1602 Ptr += HiiVariableNode->HiiQuestionArray[Index]->Length;
1625 if (mVarCheckHiiBin ==
NULL) {
1626 DEBUG ((DEBUG_INFO,
"[VarCheckHii] This driver could be removed from *.dsc and *.fdf\n"));
1631 if (mVarName !=
NULL) {
1635 #ifdef DUMP_VAR_CHECK_HII
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)
RETURN_STATUS EFIAPI AsciiStrToUnicodeStrS(IN CONST CHAR8 *Source, OUT CHAR16 *Destination, IN UINTN DestMax)
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateRuntimeZeroPool(IN UINTN AllocationSize)
#define ARRAY_SIZE(Array)
#define GLOBAL_REMOVE_IF_UNREFERENCED
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
#define EFI_VARIABLE_NON_VOLATILE
VOID DumpVarCheckHii(IN VOID *VarCheckHiiBin, IN UINTN VarCheckHiiBinSize)
VOID ParseHiiVariable(IN VOID *HiiPackage)
VOID CreateHiiVariableNode(IN EFI_IFR_VARSTORE_EFI *IfrEfiVarStore)
VAR_CHECK_HII_QUESTION_HEADER * ParseHiiQuestionOneOf(IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, IN BOOLEAN StoredInBitField)
VAR_CHECK_HII_QUESTION_HEADER * ParseHiiQuestionOrderedList(IN EFI_IFR_OP_HEADER *IfrOpCodeHeader)
VOID EFIAPI VarCheckHiiGen(VOID)
VOID DestroyHiiVariableNode(VOID)
VAR_CHECK_HII_VARIABLE_NODE * FindHiiVariableNodeByVarStoreId(IN EFI_VARSTORE_ID VarStoreId)
VOID GetOneOfOption(IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, OUT UINTN *Count, OUT UINT8 *Width, OUT VOID *OptionBuffer OPTIONAL)
VOID * BuildVarCheckHiiBin(IN OUT UINTN *Size)
VOID ParseHiiQuestion(IN VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode, IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, IN BOOLEAN FromFv, IN BOOLEAN StoredInBitField)
VOID EFIAPI InternalVarCheckFreePool(IN VOID *Buffer)
VOID VarCheckParseHiiPackage(IN VOID *HiiPackage, IN BOOLEAN FromFv)
VAR_CHECK_HII_VARIABLE_NODE * FindHiiVariableNode(IN CHAR16 *Name, IN EFI_GUID *Guid)
VAR_CHECK_HII_QUESTION_HEADER * ParseHiiQuestionNumeric(IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, IN BOOLEAN StoredInBitField)
VOID * InternalVarCheckReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID * InternalVarCheckAllocatePool(IN EFI_MEMORY_TYPE MemoryType, IN UINTN AllocationSize)
VOID * InternalVarCheckAllocateZeroPool(IN UINTN AllocationSize)
VOID MergeHiiQuestion(IN OUT VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode, IN VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion, IN BOOLEAN FromFv)
VOID VarCheckParseHiiDatabase(IN VOID *HiiDatabase, IN UINTN HiiDatabaseSize)
VOID DestroyVarStoreId(VOID)
VAR_CHECK_HII_QUESTION_HEADER * ParseHiiQuestionCheckBox(IN EFI_IFR_OP_HEADER *IfrOpCodeHeader, IN BOOLEAN StoredInBitField)
VOID VarCheckHiiGenFromFv(VOID)
VOID DumpHiiDatabase(IN VOID *HiiDatabase, IN UINTN HiiDatabaseSize)
VOID DumpHiiPackage(IN VOID *HiiPackage)
VOID VarCheckHiiGenFromHiiDatabase(VOID)