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