VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c@ 77662

Last change on this file since 77662 was 77662, checked in by vboxsync, 6 years ago

EFI: First step in UDK2018 merge. Does not build yet.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette