]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c
MdeModulePkg BrotliLib: Rename function with the specific lib name
[mirror_edk2.git] / MdeModulePkg / Library / VarCheckHiiLib / VarCheckHiiLibNullClass.c
CommitLineData
1241af95
SZ
1/** @file\r
2 Var Check Hii handler.\r
3\r
16f69227 4Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
1241af95
SZ
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "VarCheckHii.h"\r
16\r
17GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckHiiHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};\r
18\r
19/**\r
20 Dump some hexadecimal data.\r
21\r
22 @param[in] Indent How many spaces to indent the output.\r
23 @param[in] Offset The offset of the dump.\r
24 @param[in] DataSize The size in bytes of UserData.\r
25 @param[in] UserData The data to dump.\r
26\r
27**/\r
28VOID\r
29VarCheckHiiInternalDumpHex (\r
30 IN UINTN Indent,\r
31 IN UINTN Offset,\r
32 IN UINTN DataSize,\r
33 IN VOID *UserData\r
34 )\r
35{\r
36 UINT8 *Data;\r
37\r
38 CHAR8 Val[50];\r
39\r
40 CHAR8 Str[20];\r
41\r
42 UINT8 TempByte;\r
43 UINTN Size;\r
44 UINTN Index;\r
45\r
46 Data = UserData;\r
47 while (DataSize != 0) {\r
48 Size = 16;\r
49 if (Size > DataSize) {\r
50 Size = DataSize;\r
51 }\r
52\r
53 for (Index = 0; Index < Size; Index += 1) {\r
54 TempByte = Data[Index];\r
55 Val[Index * 3 + 0] = mVarCheckHiiHex[TempByte >> 4];\r
56 Val[Index * 3 + 1] = mVarCheckHiiHex[TempByte & 0xF];\r
57 Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');\r
58 Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);\r
59 }\r
60\r
61 Val[Index * 3] = 0;\r
62 Str[Index] = 0;\r
c9a7f343 63 DEBUG ((DEBUG_INFO , "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str));\r
1241af95
SZ
64\r
65 Data += Size;\r
66 Offset += Size;\r
67 DataSize -= Size;\r
68 }\r
69}\r
70\r
71/**\r
72 Var Check Hii Question.\r
73\r
74 @param[in] HiiQuestion Pointer to Hii Question\r
75 @param[in] Data Data pointer.\r
76 @param[in] DataSize Size of Data to set.\r
77\r
78 @retval TRUE Check pass\r
79 @retval FALSE Check fail.\r
80\r
81**/\r
82BOOLEAN\r
83VarCheckHiiQuestion (\r
84 IN VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion,\r
85 IN VOID *Data,\r
86 IN UINTN DataSize\r
87 )\r
88{\r
89 UINT64 OneData;\r
90 UINT64 Minimum;\r
91 UINT64 Maximum;\r
92 UINT64 OneValue;\r
93 UINT8 *Ptr;\r
94 UINT8 Index;\r
95 UINT8 MaxContainers;\r
8182e9f4
DB
96 UINT8 StartBit;\r
97 UINT8 EndBit;\r
98 UINT8 TotalBits;\r
99 UINT16 VarOffsetByteLevel;\r
100 UINT8 StorageWidthByteLevel;\r
101\r
102 if (HiiQuestion->BitFieldStore) {\r
103 VarOffsetByteLevel = HiiQuestion->VarOffset / 8;\r
104 TotalBits = HiiQuestion->VarOffset % 8 + HiiQuestion->StorageWidth;\r
105 StorageWidthByteLevel = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);\r
106 } else {\r
107 VarOffsetByteLevel = HiiQuestion->VarOffset;\r
108 StorageWidthByteLevel = HiiQuestion->StorageWidth;\r
109 }\r
1241af95 110\r
8182e9f4
DB
111 if (((UINT32) VarOffsetByteLevel + StorageWidthByteLevel) > DataSize) {\r
112 DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", VarOffsetByteLevel, StorageWidthByteLevel, DataSize));\r
1241af95
SZ
113 return FALSE;\r
114 }\r
115\r
116 OneData = 0;\r
8182e9f4
DB
117 CopyMem (&OneData, (UINT8 *) Data + VarOffsetByteLevel, StorageWidthByteLevel);\r
118 if (HiiQuestion->BitFieldStore) {\r
119 //\r
120 // Get the value from the bit field.\r
121 //\r
122 StartBit = HiiQuestion->VarOffset % 8;\r
123 EndBit = StartBit + HiiQuestion->StorageWidth - 1;\r
124 OneData = BitFieldRead64 (OneData, StartBit, EndBit);\r
125 }\r
1241af95
SZ
126\r
127 switch (HiiQuestion->OpCode) {\r
128 case EFI_IFR_ONE_OF_OP:\r
129 Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1);\r
130 while ((UINTN) Ptr < (UINTN) HiiQuestion + HiiQuestion->Length) {\r
131 OneValue = 0;\r
8182e9f4
DB
132 if (HiiQuestion->BitFieldStore) {\r
133 //\r
134 // For OneOf stored in bit field, the value of options are saved as UINT32 type.\r
135 //\r
136 CopyMem (&OneValue, Ptr, sizeof (UINT32));\r
137 } else {\r
138 CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);\r
139 }\r
1241af95
SZ
140 if (OneData == OneValue) {\r
141 //\r
142 // Match\r
143 //\r
144 break;\r
145 }\r
8182e9f4
DB
146 if (HiiQuestion->BitFieldStore) {\r
147 Ptr += sizeof (UINT32);\r
148 } else {\r
149 Ptr += HiiQuestion->StorageWidth;\r
150 }\r
1241af95
SZ
151 }\r
152 if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) {\r
153 //\r
154 // No match\r
155 //\r
c9a7f343 156 DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: OneOf mismatch (0x%lx)\n", OneData));\r
1241af95
SZ
157 DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););\r
158 return FALSE;\r
159 }\r
160 break;\r
161\r
162 case EFI_IFR_CHECKBOX_OP:\r
163 if ((OneData != 0) && (OneData != 1)) {\r
c9a7f343 164 DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: CheckBox mismatch (0x%lx)\n", OneData));\r
1241af95
SZ
165 DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););\r
166 return FALSE;\r
167 }\r
168 break;\r
169\r
170 case EFI_IFR_NUMERIC_OP:\r
171 Minimum = 0;\r
172 Maximum = 0;\r
173 Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1);\r
8182e9f4
DB
174 if (HiiQuestion->BitFieldStore) {\r
175 //\r
176 // For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type.\r
177 //\r
178 CopyMem (&Minimum, Ptr, sizeof (UINT32));\r
179 Ptr += sizeof (UINT32);\r
180 CopyMem (&Maximum, Ptr, sizeof (UINT32));\r
181 Ptr += sizeof (UINT32);\r
182 } else {\r
183 CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth);\r
184 Ptr += HiiQuestion->StorageWidth;\r
185 CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth);\r
186 Ptr += HiiQuestion->StorageWidth;\r
187 }\r
1241af95
SZ
188\r
189 //\r
190 // No need to check Step, because it is ONLY for UI.\r
191 //\r
192 if ((OneData < Minimum) || (OneData > Maximum)) {\r
c9a7f343 193 DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: Numeric mismatch (0x%lx)\n", OneData));\r
1241af95
SZ
194 DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););\r
195 return FALSE;\r
196 }\r
197 break;\r
198\r
199 case EFI_IFR_ORDERED_LIST_OP:\r
200 MaxContainers = ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers;\r
16f69227 201 if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) {\r
c9a7f343 202 DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, MaxContainers, DataSize));\r
1241af95
SZ
203 return FALSE;\r
204 }\r
205 for (Index = 0; Index < MaxContainers; Index++) {\r
206 OneData = 0;\r
207 CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset + HiiQuestion->StorageWidth * Index, HiiQuestion->StorageWidth);\r
208 if (OneData == 0) {\r
209 //\r
210 // The value of 0 is used to determine if a particular "slot" in the array is empty.\r
211 //\r
212 continue;\r
213 }\r
214\r
215 Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion + 1);\r
216 while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) {\r
217 OneValue = 0;\r
218 CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);\r
219 if (OneData == OneValue) {\r
220 //\r
221 // Match\r
222 //\r
223 break;\r
224 }\r
225 Ptr += HiiQuestion->StorageWidth;\r
226 }\r
227 if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) {\r
228 //\r
229 // No match\r
230 //\r
c9a7f343 231 DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: OrderedList mismatch\n"));\r
1241af95
SZ
232 DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->StorageWidth * MaxContainers, (UINT8 *) Data + HiiQuestion->VarOffset););\r
233 DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););\r
234 return FALSE;\r
235 }\r
236 }\r
237 break;\r
238\r
239 default:\r
240 ASSERT (FALSE);\r
241 break;\r
242 }\r
243\r
244 return TRUE;\r
245}\r
246\r
247VAR_CHECK_HII_VARIABLE_HEADER *mVarCheckHiiBin = NULL;\r
248UINTN mVarCheckHiiBinSize = 0;\r
249\r
250/**\r
251 SetVariable check handler HII.\r
252\r
253 @param[in] VariableName Name of Variable to set.\r
254 @param[in] VendorGuid Variable vendor GUID.\r
255 @param[in] Attributes Attribute value of the variable.\r
256 @param[in] DataSize Size of Data to set.\r
257 @param[in] Data Data pointer.\r
258\r
259 @retval EFI_SUCCESS The SetVariable check result was success.\r
260 @retval EFI_SECURITY_VIOLATION Check fail.\r
261\r
262**/\r
263EFI_STATUS\r
264EFIAPI\r
265SetVariableCheckHandlerHii (\r
266 IN CHAR16 *VariableName,\r
267 IN EFI_GUID *VendorGuid,\r
268 IN UINT32 Attributes,\r
269 IN UINTN DataSize,\r
270 IN VOID *Data\r
271 )\r
272{\r
273 VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;\r
274 VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;\r
275\r
276 if (mVarCheckHiiBin == NULL) {\r
277 return EFI_SUCCESS;\r
278 }\r
279\r
280 if ((((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0) && (DataSize == 0)) || (Attributes == 0)) {\r
281 //\r
282 // Do not check delete variable.\r
283 //\r
284 return EFI_SUCCESS;\r
285 }\r
286\r
287 //\r
288 // For Hii Variable header align.\r
289 //\r
290 HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (mVarCheckHiiBin);\r
291 while ((UINTN) HiiVariable < ((UINTN) mVarCheckHiiBin + mVarCheckHiiBinSize)) {\r
292 if ((StrCmp ((CHAR16 *) (HiiVariable + 1), VariableName) == 0) &&\r
293 (CompareGuid (&HiiVariable->Guid, VendorGuid))) {\r
294 //\r
295 // Found the Hii Variable that could be used to do check.\r
296 //\r
c9a7f343 297 DEBUG ((DEBUG_INFO , "VarCheckHiiVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize));\r
1241af95 298 if (HiiVariable->Attributes != Attributes) {\r
c9a7f343 299 DEBUG ((DEBUG_INFO, "VarCheckHiiVariable fail for Attributes - 0x%08x\n", HiiVariable->Attributes));\r
1241af95
SZ
300 return EFI_SECURITY_VIOLATION;\r
301 }\r
302\r
303 if (DataSize == 0) {\r
c9a7f343 304 DEBUG ((DEBUG_INFO, "VarCheckHiiVariable - CHECK PASS with DataSize == 0 !\n"));\r
1241af95
SZ
305 return EFI_SUCCESS;\r
306 }\r
307\r
308 if (HiiVariable->Size != DataSize) {\r
c9a7f343 309 DEBUG ((DEBUG_INFO, "VarCheckHiiVariable fail for Size - 0x%x\n", HiiVariable->Size));\r
1241af95
SZ
310 return EFI_SECURITY_VIOLATION;\r
311 }\r
312\r
313 //\r
314 // Do the check.\r
315 // For Hii Question header align.\r
316 //\r
317 HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->HeaderLength));\r
318 while ((UINTN) HiiQuestion < ((UINTN) HiiVariable + HiiVariable->Length)) {\r
319 if (!VarCheckHiiQuestion (HiiQuestion, Data, DataSize)) {\r
320 return EFI_SECURITY_VIOLATION;\r
321 }\r
322 //\r
323 // For Hii Question header align.\r
324 //\r
325 HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiQuestion + HiiQuestion->Length));\r
326 }\r
327\r
c9a7f343 328 DEBUG ((DEBUG_INFO, "VarCheckHiiVariable - ALL CHECK PASS!\n"));\r
1241af95
SZ
329 return EFI_SUCCESS;\r
330 }\r
331 //\r
332 // For Hii Variable header align.\r
333 //\r
334 HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->Length));\r
335 }\r
336\r
337 // Not found, so pass.\r
338 return EFI_SUCCESS;\r
339}\r
340\r
341#ifdef DUMP_VAR_CHECK_HII\r
342GLOBAL_REMOVE_IF_UNREFERENCED VAR_CHECK_HII_OPCODE_STRING mHiiOpCodeStringTable[] = {\r
343 {EFI_IFR_VARSTORE_EFI_OP, "EfiVarStore"},\r
344 {EFI_IFR_ONE_OF_OP, "OneOf"},\r
345 {EFI_IFR_CHECKBOX_OP, "CheckBox"},\r
346 {EFI_IFR_NUMERIC_OP, "Numeric"},\r
347 {EFI_IFR_ORDERED_LIST_OP, "OrderedList"},\r
348};\r
349\r
350/**\r
351 HII opcode to string.\r
352\r
353 @param[in] HiiOpCode Hii OpCode.\r
354\r
355 @return Pointer to string.\r
356\r
357**/\r
358CHAR8 *\r
359HiiOpCodeToStr (\r
360 IN UINT8 HiiOpCode\r
361 )\r
362{\r
363 UINTN Index;\r
fe69b398 364 for (Index = 0; Index < ARRAY_SIZE (mHiiOpCodeStringTable); Index++) {\r
1241af95
SZ
365 if (mHiiOpCodeStringTable[Index].HiiOpCode == HiiOpCode) {\r
366 return mHiiOpCodeStringTable[Index].HiiOpCodeStr;\r
367 }\r
368 }\r
369\r
370 return "<UnknownHiiOpCode>";\r
371}\r
372\r
373/**\r
374 Dump Hii Question.\r
375\r
376 @param[in] HiiQuestion Pointer to Hii Question.\r
377\r
378**/\r
379VOID\r
380DumpHiiQuestion (\r
381 IN VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion\r
382 )\r
383{\r
384 UINT64 Minimum;\r
385 UINT64 Maximum;\r
386 UINT64 OneValue;\r
387 UINT8 *Ptr;\r
388\r
c9a7f343 389 DEBUG ((DEBUG_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n"));\r
8182e9f4 390 DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a) (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode), (HiiQuestion->BitFieldStore? "bit level": "byte level")));\r
c9a7f343 391 DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", HiiQuestion->Length));\r
8182e9f4
DB
392 DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x (%a)\n", HiiQuestion->VarOffset, (HiiQuestion->BitFieldStore? "bit level": "byte level")));\r
393 DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x (%a)\n", HiiQuestion->StorageWidth, (HiiQuestion->BitFieldStore? "bit level": "byte level")));\r
1241af95
SZ
394\r
395 switch (HiiQuestion->OpCode) {\r
396 case EFI_IFR_ONE_OF_OP:\r
397 Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1);\r
398 while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) {\r
399 OneValue = 0;\r
8182e9f4
DB
400 if (HiiQuestion->BitFieldStore) {\r
401 //\r
402 // For OneOf stored in bit field, the value of options are saved as UINT32 type.\r
403 //\r
404 CopyMem (&OneValue, Ptr, sizeof (UINT32));\r
405 DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue));\r
406 } else {\r
407 CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);\r
408 switch (HiiQuestion->StorageWidth) {\r
409 case sizeof (UINT8):\r
410 DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue));\r
411 break;\r
412 case sizeof (UINT16):\r
413 DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue));\r
414 break;\r
415 case sizeof (UINT32):\r
416 DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue));\r
417 break;\r
418 case sizeof (UINT64):\r
419 DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue));\r
420 break;\r
421 default:\r
422 ASSERT (FALSE);\r
423 break;\r
424 }\r
425 }\r
426 if (HiiQuestion->BitFieldStore) {\r
427 Ptr += sizeof (UINT32);\r
428 } else {\r
429 Ptr += HiiQuestion->StorageWidth;\r
430 }\r
431 }\r
432 break;\r
433\r
434 case EFI_IFR_CHECKBOX_OP:\r
435 break;\r
436\r
437 case EFI_IFR_NUMERIC_OP:\r
438 Minimum = 0;\r
439 Maximum = 0;\r
440 Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1);\r
441 if(HiiQuestion->BitFieldStore) {\r
442 //\r
443 // For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type.\r
444 //\r
445 CopyMem (&Minimum, Ptr, sizeof (UINT32));\r
446 Ptr += sizeof (UINT32);\r
447 CopyMem (&Maximum, Ptr, sizeof (UINT32));\r
448 Ptr += sizeof (UINT32);\r
449\r
450 DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum));\r
451 DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum));\r
452 } else {\r
453 CopyMem (&Minimum, Ptr, HiiQuestion->StorageWidth);\r
454 Ptr += HiiQuestion->StorageWidth;\r
455 CopyMem (&Maximum, Ptr, HiiQuestion->StorageWidth);\r
456 Ptr += HiiQuestion->StorageWidth;\r
457\r
1241af95
SZ
458 switch (HiiQuestion->StorageWidth) {\r
459 case sizeof (UINT8):\r
8182e9f4
DB
460 DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum));\r
461 DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum));\r
1241af95
SZ
462 break;\r
463 case sizeof (UINT16):\r
8182e9f4
DB
464 DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum));\r
465 DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum));\r
1241af95
SZ
466 break;\r
467 case sizeof (UINT32):\r
8182e9f4
DB
468 DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum));\r
469 DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum));\r
1241af95
SZ
470 break;\r
471 case sizeof (UINT64):\r
8182e9f4
DB
472 DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum));\r
473 DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum));\r
1241af95
SZ
474 break;\r
475 default:\r
476 ASSERT (FALSE);\r
477 break;\r
478 }\r
1241af95
SZ
479 }\r
480 break;\r
481\r
482 case EFI_IFR_ORDERED_LIST_OP:\r
c9a7f343 483 DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers));\r
1241af95
SZ
484 Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion + 1);\r
485 while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) {\r
486 OneValue = 0;\r
487 CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);\r
488 switch (HiiQuestion->StorageWidth) {\r
489 case sizeof (UINT8):\r
c9a7f343 490 DEBUG ((DEBUG_INFO, " OneOfOption - 0x%02x\n", OneValue));\r
1241af95
SZ
491 break;\r
492 case sizeof (UINT16):\r
c9a7f343 493 DEBUG ((DEBUG_INFO, " OneOfOption - 0x%04x\n", OneValue));\r
1241af95
SZ
494 break;\r
495 case sizeof (UINT32):\r
c9a7f343 496 DEBUG ((DEBUG_INFO, " OneOfOption - 0x%08x\n", OneValue));\r
1241af95
SZ
497 break;\r
498 case sizeof (UINT64):\r
c9a7f343 499 DEBUG ((DEBUG_INFO, " OneOfOption - 0x%016lx\n", OneValue));\r
1241af95
SZ
500 break;\r
501 default:\r
502 ASSERT (FALSE);\r
503 break;\r
504 }\r
505 Ptr += HiiQuestion->StorageWidth;\r
506 }\r
507 break;\r
508\r
509 default:\r
510 ASSERT (FALSE);\r
511 break;\r
512 }\r
513}\r
514\r
515/**\r
516 Dump Hii Variable.\r
517\r
518 @param[in] HiiVariable Pointer to Hii Variable.\r
519\r
520**/\r
521VOID\r
522DumpHiiVariable (\r
523 IN VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable\r
524 )\r
525{\r
526 VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;\r
527\r
c9a7f343
DB
528 DEBUG ((DEBUG_INFO, "VAR_CHECK_HII_VARIABLE_HEADER\n"));\r
529 DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", HiiVariable->Revision));\r
530 DEBUG ((DEBUG_INFO, " HeaderLength - 0x%04x\n", HiiVariable->HeaderLength));\r
531 DEBUG ((DEBUG_INFO, " Length - 0x%08x\n", HiiVariable->Length));\r
532 DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a)\n", HiiVariable->OpCode, HiiOpCodeToStr (HiiVariable->OpCode)));\r
533 DEBUG ((DEBUG_INFO, " Size - 0x%04x\n", HiiVariable->Size));\r
534 DEBUG ((DEBUG_INFO, " Attributes - 0x%08x\n", HiiVariable->Attributes));\r
535 DEBUG ((DEBUG_INFO, " Guid - %g\n", &HiiVariable->Guid));\r
536 DEBUG ((DEBUG_INFO, " Name - %s\n", HiiVariable + 1));\r
1241af95
SZ
537\r
538 //\r
539 // For Hii Question header align.\r
540 //\r
541 HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->HeaderLength));\r
542 while ((UINTN) HiiQuestion < ((UINTN) HiiVariable + HiiVariable->Length)) {\r
543 //\r
544 // Dump Hii Question related to the Hii Variable.\r
545 //\r
546 DumpHiiQuestion (HiiQuestion);\r
547 //\r
548 // For Hii Question header align.\r
549 //\r
550 HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiQuestion + HiiQuestion->Length));\r
551 }\r
552}\r
553\r
554/**\r
555 Dump Var Check HII.\r
556\r
557 @param[in] VarCheckHiiBin Pointer to VarCheckHiiBin.\r
558 @param[in] VarCheckHiiBinSize VarCheckHiiBin size.\r
559\r
560**/\r
561VOID\r
562DumpVarCheckHii (\r
563 IN VOID *VarCheckHiiBin,\r
564 IN UINTN VarCheckHiiBinSize\r
565 )\r
566{\r
567 VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;\r
568\r
c9a7f343 569 DEBUG ((DEBUG_INFO, "DumpVarCheckHii\n"));\r
1241af95
SZ
570\r
571 //\r
572 // For Hii Variable header align.\r
573 //\r
574 HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (VarCheckHiiBin);\r
575 while ((UINTN) HiiVariable < ((UINTN) VarCheckHiiBin + VarCheckHiiBinSize)) {\r
576 DumpHiiVariable (HiiVariable);\r
577 //\r
578 // For Hii Variable header align.\r
579 //\r
580 HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->Length));\r
581 }\r
582}\r
583#endif\r
584\r
585/**\r
586 Constructor function of VarCheckHiiLib to register var check HII handler.\r
587\r
588 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
589 @param[in] SystemTable A pointer to the EFI System Table.\r
590\r
591 @retval EFI_SUCCESS The constructor executed correctly.\r
592\r
593**/\r
594EFI_STATUS\r
595EFIAPI\r
596VarCheckHiiLibNullClassConstructor (\r
597 IN EFI_HANDLE ImageHandle,\r
598 IN EFI_SYSTEM_TABLE *SystemTable\r
599 )\r
600{\r
601 VarCheckLibRegisterEndOfDxeCallback (VarCheckHiiGen);\r
602 VarCheckLibRegisterAddressPointer ((VOID **) &mVarCheckHiiBin);\r
603 VarCheckLibRegisterSetVariableCheckHandler (SetVariableCheckHandlerHii);\r
604\r
605 return EFI_SUCCESS;\r
606}\r
607\r