2 Parser for IFR binary encoding.
4 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 UINT16 mStatementIndex
;
18 UINT16 mExpressionOpCodeIndex
;
19 EFI_QUESTION_ID mUsedQuestionId
;
20 extern LIST_ENTRY gBrowserStorageList
;
22 Initialize Statement header members.
24 @param OpCodeData Pointer of the raw OpCode data.
25 @param FormSet Pointer of the current FormSe.
26 @param Form Pointer of the current Form.
28 @return The Statement.
31 FORM_BROWSER_STATEMENT
*
34 IN OUT FORM_BROWSER_FORMSET
*FormSet
,
35 IN OUT FORM_BROWSER_FORM
*Form
38 FORM_BROWSER_STATEMENT
*Statement
;
39 EFI_IFR_STATEMENT_HEADER
*StatementHdr
;
40 INTN ConditionalExprCount
;
44 // Only guid op may out side the form level.
46 ASSERT (((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
== EFI_IFR_GUID_OP
);
49 Statement
= &FormSet
->StatementBuffer
[mStatementIndex
];
52 InitializeListHead (&Statement
->DefaultListHead
);
53 InitializeListHead (&Statement
->OptionListHead
);
54 InitializeListHead (&Statement
->InconsistentListHead
);
55 InitializeListHead (&Statement
->NoSubmitListHead
);
56 InitializeListHead (&Statement
->WarningListHead
);
58 Statement
->Signature
= FORM_BROWSER_STATEMENT_SIGNATURE
;
60 Statement
->Operand
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
;
61 Statement
->OpCode
= (EFI_IFR_OP_HEADER
*) OpCodeData
;
63 StatementHdr
= (EFI_IFR_STATEMENT_HEADER
*) (OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
));
64 CopyMem (&Statement
->Prompt
, &StatementHdr
->Prompt
, sizeof (EFI_STRING_ID
));
65 CopyMem (&Statement
->Help
, &StatementHdr
->Help
, sizeof (EFI_STRING_ID
));
67 ConditionalExprCount
= GetConditionalExpressionCount(ExpressStatement
);
68 if (ConditionalExprCount
> 0) {
70 // Form is inside of suppressif
73 Statement
->Expression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
74 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
75 ASSERT (Statement
->Expression
!= NULL
);
76 Statement
->Expression
->Count
= (UINTN
) ConditionalExprCount
;
77 Statement
->Expression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
78 CopyMem (Statement
->Expression
->Expression
, GetConditionalExpressionList(ExpressStatement
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
82 // Insert this Statement into current Form
85 InsertTailList (&FormSet
->StatementListOSF
, &Statement
->Link
);
87 InsertTailList (&Form
->StatementListHead
, &Statement
->Link
);
93 Convert a numeric value to a Unicode String and insert it to String Package.
94 This string is used as the Unicode Name for the EFI Variable. This is to support
95 the deprecated vareqval opcode.
97 @param FormSet The FormSet.
98 @param Statement The numeric question whose VarStoreInfo.VarName is the
99 numeric value which is used to produce the Unicode Name
100 for the EFI Variable.
102 If the Statement is NULL, the ASSERT.
103 If the opcode is not Numeric, then ASSERT.
105 @retval EFI_SUCCESS The funtion always succeeds.
108 UpdateCheckBoxStringToken (
109 IN CONST FORM_BROWSER_FORMSET
*FormSet
,
110 IN FORM_BROWSER_STATEMENT
*Statement
113 CHAR16 Str
[MAXIMUM_VALUE_CHARACTERS
];
116 ASSERT (Statement
!= NULL
);
117 ASSERT (Statement
->Operand
== EFI_IFR_NUMERIC_OP
);
119 UnicodeValueToString (Str
, 0, Statement
->VarStoreInfo
.VarName
, MAXIMUM_VALUE_CHARACTERS
- 1);
121 Id
= HiiSetString (FormSet
->HiiHandle
, 0, Str
, NULL
);
123 return EFI_OUT_OF_RESOURCES
;
126 Statement
->VarStoreInfo
.VarName
= Id
;
132 Check if the next opcode is the EFI_IFR_EXTEND_OP_VAREQNAME.
134 @param OpCodeData The current opcode.
140 IsNextOpCodeGuidedVarEqName (
147 OpCodeData
+= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
148 if (*OpCodeData
== EFI_IFR_GUID_OP
) {
149 if (CompareGuid (&gEfiIfrFrameworkGuid
, (EFI_GUID
*)(OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
)))) {
151 // Specific GUIDed opcodes to support IFR generated from Framework HII VFR
153 if ((((EFI_IFR_GUID_VAREQNAME
*) OpCodeData
)->ExtendOpCode
) == EFI_IFR_EXTEND_OP_VAREQNAME
) {
163 Initialize Question's members.
165 @param OpCodeData Pointer of the raw OpCode data.
166 @param FormSet Pointer of the current FormSet.
167 @param Form Pointer of the current Form.
169 @return The Question.
172 FORM_BROWSER_STATEMENT
*
174 IN UINT8
*OpCodeData
,
175 IN OUT FORM_BROWSER_FORMSET
*FormSet
,
176 IN OUT FORM_BROWSER_FORM
*Form
179 FORM_BROWSER_STATEMENT
*Statement
;
180 EFI_IFR_QUESTION_HEADER
*QuestionHdr
;
182 FORMSET_STORAGE
*Storage
;
183 NAME_VALUE_NODE
*NameValueNode
;
187 Statement
= CreateStatement (OpCodeData
, FormSet
, Form
);
188 if (Statement
== NULL
) {
192 QuestionHdr
= (EFI_IFR_QUESTION_HEADER
*) (OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
));
193 CopyMem (&Statement
->QuestionId
, &QuestionHdr
->QuestionId
, sizeof (EFI_QUESTION_ID
));
194 CopyMem (&Statement
->VarStoreId
, &QuestionHdr
->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
195 CopyMem (&Statement
->VarStoreInfo
.VarOffset
, &QuestionHdr
->VarStoreInfo
.VarOffset
, sizeof (UINT16
));
197 Statement
->QuestionFlags
= QuestionHdr
->Flags
;
199 if (Statement
->VarStoreId
== 0) {
201 // VarStoreId of zero indicates no variable storage
207 // Take a look at next OpCode to see whether it is a GUIDed opcode to support
208 // Framework Compatibility
210 if (FeaturePcdGet (PcdFrameworkCompatibilitySupport
)) {
211 if ((*OpCodeData
== EFI_IFR_NUMERIC_OP
) && IsNextOpCodeGuidedVarEqName (OpCodeData
)) {
212 Status
= UpdateCheckBoxStringToken (FormSet
, Statement
);
213 if (EFI_ERROR (Status
)) {
220 // Find Storage for this Question
222 Link
= GetFirstNode (&FormSet
->StorageListHead
);
223 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
224 Storage
= FORMSET_STORAGE_FROM_LINK (Link
);
226 if (Storage
->VarStoreId
== Statement
->VarStoreId
) {
227 Statement
->Storage
= Storage
->BrowserStorage
;
231 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
233 ASSERT (Statement
->Storage
!= NULL
);
236 // Initialilze varname for Name/Value or EFI Variable
238 if ((Statement
->Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) ||
239 (Statement
->Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
)) {
240 Statement
->VariableName
= GetToken (Statement
->VarStoreInfo
.VarName
, FormSet
->HiiHandle
);
241 ASSERT (Statement
->VariableName
!= NULL
);
243 if (Statement
->Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
245 // Check whether old string node already exist.
248 if (!IsListEmpty(&Statement
->Storage
->NameValueListHead
)) {
249 Link
= GetFirstNode (&Statement
->Storage
->NameValueListHead
);
250 while (!IsNull (&Statement
->Storage
->NameValueListHead
, Link
)) {
251 NameValueNode
= NAME_VALUE_NODE_FROM_LINK (Link
);
253 if (StrCmp (Statement
->VariableName
, NameValueNode
->Name
) == 0) {
258 Link
= GetNextNode (&Statement
->Storage
->NameValueListHead
, Link
);
264 // Insert to Name/Value varstore list
266 NameValueNode
= AllocateZeroPool (sizeof (NAME_VALUE_NODE
));
267 ASSERT (NameValueNode
!= NULL
);
268 NameValueNode
->Signature
= NAME_VALUE_NODE_SIGNATURE
;
269 NameValueNode
->Name
= AllocateCopyPool (StrSize (Statement
->VariableName
), Statement
->VariableName
);
270 ASSERT (NameValueNode
->Name
!= NULL
);
271 NameValueNode
->Value
= AllocateZeroPool (0x10);
272 ASSERT (NameValueNode
->Value
!= NULL
);
273 NameValueNode
->EditValue
= AllocateZeroPool (0x10);
274 ASSERT (NameValueNode
->EditValue
!= NULL
);
276 InsertTailList (&Statement
->Storage
->NameValueListHead
, &NameValueNode
->Link
);
286 Allocate a FORM_EXPRESSION node.
288 @param Form The Form associated with this Expression
289 @param OpCode The binary opcode data.
291 @return Pointer to a FORM_EXPRESSION data structure.
296 IN OUT FORM_BROWSER_FORM
*Form
,
300 FORM_EXPRESSION
*Expression
;
302 Expression
= AllocateZeroPool (sizeof (FORM_EXPRESSION
));
303 ASSERT (Expression
!= NULL
);
304 Expression
->Signature
= FORM_EXPRESSION_SIGNATURE
;
305 InitializeListHead (&Expression
->OpCodeListHead
);
306 Expression
->OpCode
= (EFI_IFR_OP_HEADER
*) OpCode
;
312 Create ConfigHdr string for a storage.
314 @param FormSet Pointer of the current FormSet
315 @param Storage Pointer of the storage
317 @retval EFI_SUCCESS Initialize ConfigHdr success
321 InitializeConfigHdr (
322 IN FORM_BROWSER_FORMSET
*FormSet
,
323 IN OUT BROWSER_STORAGE
*Storage
328 if (Storage
->Type
== EFI_HII_VARSTORE_BUFFER
||
329 Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
330 Name
= Storage
->Name
;
335 Storage
->ConfigHdr
= HiiConstructConfigHdr (
338 FormSet
->DriverHandle
341 if (Storage
->ConfigHdr
== NULL
) {
342 return EFI_NOT_FOUND
;
349 Find the global storage link base on the input storate type, name and guid.
351 For EFI_HII_VARSTORE_EFI_VARIABLE and EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER,
352 same guid + name = same storage
354 For EFI_HII_VARSTORE_NAME_VALUE:
355 same guid + HiiHandle = same storage
357 For EFI_HII_VARSTORE_BUFFER:
358 same guid + name + HiiHandle = same storage
360 @param StorageType Storage type.
361 @param StorageGuid Storage guid.
362 @param StorageName Storage Name.
363 @param HiiHandle HiiHandle for this varstore.
365 @return Pointer to a GLOBAL_STORAGE data structure.
370 IN UINT8 StorageType
,
371 IN EFI_GUID
*StorageGuid
,
372 IN CHAR16
*StorageName
,
373 IN EFI_HII_HANDLE HiiHandle
377 BROWSER_STORAGE
*BrowserStorage
;
379 Link
= GetFirstNode (&gBrowserStorageList
);
380 while (!IsNull (&gBrowserStorageList
, Link
)) {
381 BrowserStorage
= BROWSER_STORAGE_FROM_LINK (Link
);
382 Link
= GetNextNode (&gBrowserStorageList
, Link
);
384 if ((BrowserStorage
->Type
== StorageType
) && CompareGuid (&BrowserStorage
->Guid
, StorageGuid
)) {
385 if (StorageType
== EFI_HII_VARSTORE_NAME_VALUE
) {
386 if (BrowserStorage
->HiiHandle
== HiiHandle
) {
387 return BrowserStorage
;
393 ASSERT (StorageName
!= NULL
);
394 if (StrCmp (BrowserStorage
->Name
, StorageName
) == 0) {
395 if (StorageType
== EFI_HII_VARSTORE_EFI_VARIABLE
|| StorageType
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
396 return BrowserStorage
;
397 } else if (StorageType
== EFI_HII_VARSTORE_BUFFER
&& BrowserStorage
->HiiHandle
== HiiHandle
) {
398 return BrowserStorage
;
408 Intialize the Global Storage.
410 @param BrowserStorage Pointer to the global storage.
411 @param StorageType Storage type.
412 @param OpCodeData Binary data for this opcode.
416 IntializeBrowserStorage (
417 IN BROWSER_STORAGE
*BrowserStorage
,
418 IN UINT8 StorageType
,
422 switch (StorageType
) {
423 case EFI_HII_VARSTORE_BUFFER
:
424 CopyMem (&BrowserStorage
->Guid
, &((EFI_IFR_VARSTORE
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
425 CopyMem (&BrowserStorage
->Size
, &((EFI_IFR_VARSTORE
*) OpCodeData
)->Size
, sizeof (UINT16
));
427 BrowserStorage
->Buffer
= AllocateZeroPool (BrowserStorage
->Size
);
428 BrowserStorage
->EditBuffer
= AllocateZeroPool (BrowserStorage
->Size
);
431 case EFI_HII_VARSTORE_EFI_VARIABLE
:
432 case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
:
433 CopyMem (&BrowserStorage
->Guid
, &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
434 CopyMem (&BrowserStorage
->Attributes
, &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Attributes
, sizeof (UINT32
));
435 CopyMem (&BrowserStorage
->Size
, &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Size
, sizeof (UINT16
));
437 if (StorageType
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
438 BrowserStorage
->Buffer
= AllocateZeroPool (BrowserStorage
->Size
);
439 BrowserStorage
->EditBuffer
= AllocateZeroPool (BrowserStorage
->Size
);
443 case EFI_HII_VARSTORE_NAME_VALUE
:
444 CopyMem (&BrowserStorage
->Guid
, &((EFI_IFR_VARSTORE_NAME_VALUE
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
446 InitializeListHead (&BrowserStorage
->NameValueListHead
);
455 Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List.
457 @param FormSet Pointer of the current FormSet
458 @param StorageType Storage type.
459 @param OpCodeData Binary data for this opcode.
461 @return Pointer to a FORMSET_STORAGE data structure.
466 IN FORM_BROWSER_FORMSET
*FormSet
,
467 IN UINT8 StorageType
,
471 FORMSET_STORAGE
*Storage
;
472 CHAR16
*UnicodeString
;
474 BROWSER_STORAGE
*BrowserStorage
;
475 EFI_GUID
*StorageGuid
;
478 UnicodeString
= NULL
;
480 switch (StorageType
) {
481 case EFI_HII_VARSTORE_BUFFER
:
482 StorageGuid
= (EFI_GUID
*) (CHAR8
*) &((EFI_IFR_VARSTORE
*) OpCodeData
)->Guid
;
483 StorageName
= (CHAR8
*) ((EFI_IFR_VARSTORE
*) OpCodeData
)->Name
;
486 case EFI_HII_VARSTORE_EFI_VARIABLE
:
487 case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
:
488 StorageGuid
= (EFI_GUID
*) (CHAR8
*) &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Guid
;
489 StorageName
= (CHAR8
*) ((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Name
;
493 ASSERT (StorageType
== EFI_HII_VARSTORE_NAME_VALUE
);
494 StorageGuid
= &((EFI_IFR_VARSTORE_NAME_VALUE
*) OpCodeData
)->Guid
;
498 if (StorageType
!= EFI_HII_VARSTORE_NAME_VALUE
) {
499 ASSERT (StorageName
!= NULL
);
501 UnicodeString
= AllocateZeroPool (AsciiStrSize (StorageName
) * 2);
502 ASSERT (UnicodeString
!= NULL
);
503 for (Index
= 0; StorageName
[Index
] != 0; Index
++) {
504 UnicodeString
[Index
] = (CHAR16
) StorageName
[Index
];
508 Storage
= AllocateZeroPool (sizeof (FORMSET_STORAGE
));
509 ASSERT (Storage
!= NULL
);
510 Storage
->Signature
= FORMSET_STORAGE_SIGNATURE
;
511 InsertTailList (&FormSet
->StorageListHead
, &Storage
->Link
);
513 BrowserStorage
= FindStorageInList(StorageType
, StorageGuid
, UnicodeString
, FormSet
->HiiHandle
);
514 if (BrowserStorage
== NULL
) {
515 BrowserStorage
= AllocateZeroPool (sizeof (BROWSER_STORAGE
));
516 ASSERT (BrowserStorage
!= NULL
);
518 BrowserStorage
->Signature
= BROWSER_STORAGE_SIGNATURE
;
519 InsertTailList (&gBrowserStorageList
, &BrowserStorage
->Link
);
521 IntializeBrowserStorage (BrowserStorage
, StorageType
, OpCodeData
);
522 BrowserStorage
->Type
= StorageType
;
523 if (StorageType
!= EFI_HII_VARSTORE_NAME_VALUE
) {
524 BrowserStorage
->Name
= UnicodeString
;
527 BrowserStorage
->HiiHandle
= FormSet
->HiiHandle
;
528 InitializeConfigHdr (FormSet
, BrowserStorage
);
530 BrowserStorage
->Initialized
= FALSE
;
533 Storage
->BrowserStorage
= BrowserStorage
;
534 Storage
->ConfigRequest
= AllocateCopyPool (StrSize (BrowserStorage
->ConfigHdr
), BrowserStorage
->ConfigHdr
);
535 Storage
->SpareStrLen
= 0;
541 Initialize Request Element of a Question. <RequestElement> ::= '&'<BlockName> | '&'<Label>
543 @param FormSet Pointer of the current FormSet.
544 @param Question The Question to be initialized.
545 @param Form Pointer of the current form.
547 @retval EFI_SUCCESS Function success.
548 @retval EFI_INVALID_PARAMETER No storage associated with the Question.
552 InitializeRequestElement (
553 IN OUT FORM_BROWSER_FORMSET
*FormSet
,
554 IN OUT FORM_BROWSER_STATEMENT
*Question
,
555 IN OUT FORM_BROWSER_FORM
*Form
558 BROWSER_STORAGE
*Storage
;
559 FORMSET_STORAGE
*FormsetStorage
;
563 CHAR16 RequestElement
[30];
566 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
568 Storage
= Question
->Storage
;
569 if (Storage
== NULL
) {
570 return EFI_INVALID_PARAMETER
;
573 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
575 // <ConfigRequest> is unnecessary for EFI variable storage,
576 // GetVariable()/SetVariable() will be used to retrieve/save values
582 // Prepare <RequestElement>
584 if (Storage
->Type
== EFI_HII_VARSTORE_BUFFER
||
585 Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
586 StrLen
= UnicodeSPrint (
588 30 * sizeof (CHAR16
),
589 L
"&OFFSET=%x&WIDTH=%x",
590 Question
->VarStoreInfo
.VarOffset
,
591 Question
->StorageWidth
593 Question
->BlockName
= AllocateCopyPool ((StrLen
+ 1) * sizeof (CHAR16
), RequestElement
);
595 StrLen
= UnicodeSPrint (RequestElement
, 30 * sizeof (CHAR16
), L
"&%s", Question
->VariableName
);
598 if ((Question
->Operand
== EFI_IFR_PASSWORD_OP
) && ((Question
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
)) {
600 // Password with CALLBACK flag is stored in encoded format,
601 // so don't need to append it to <ConfigRequest>
607 // Find Formset Storage for this Question
609 FormsetStorage
= NULL
;
610 Link
= GetFirstNode (&FormSet
->StorageListHead
);
611 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
612 FormsetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
614 if (FormsetStorage
->VarStoreId
== Question
->VarStoreId
) {
618 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
620 ASSERT (FormsetStorage
!= NULL
);
623 // Append <RequestElement> to <ConfigRequest>
625 if (StrLen
> FormsetStorage
->SpareStrLen
) {
627 // Old String buffer is not sufficient for RequestElement, allocate a new one
629 StringSize
= (FormsetStorage
->ConfigRequest
!= NULL
) ? StrSize (FormsetStorage
->ConfigRequest
) : sizeof (CHAR16
);
630 NewStr
= AllocateZeroPool (StringSize
+ CONFIG_REQUEST_STRING_INCREMENTAL
* sizeof (CHAR16
));
631 ASSERT (NewStr
!= NULL
);
632 if (FormsetStorage
->ConfigRequest
!= NULL
) {
633 CopyMem (NewStr
, FormsetStorage
->ConfigRequest
, StringSize
);
634 FreePool (FormsetStorage
->ConfigRequest
);
636 FormsetStorage
->ConfigRequest
= NewStr
;
637 FormsetStorage
->SpareStrLen
= CONFIG_REQUEST_STRING_INCREMENTAL
;
640 StrCat (FormsetStorage
->ConfigRequest
, RequestElement
);
641 FormsetStorage
->ElementCount
++;
642 FormsetStorage
->SpareStrLen
-= StrLen
;
645 // Update the Config Request info saved in the form.
649 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
650 while (!IsNull (&Form
->ConfigRequestHead
, Link
)) {
651 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
653 if (ConfigInfo
!= NULL
&& ConfigInfo
->Storage
== Storage
) {
658 Link
= GetNextNode (&Form
->ConfigRequestHead
, Link
);
662 ConfigInfo
= AllocateZeroPool(sizeof (FORM_BROWSER_CONFIG_REQUEST
));
663 ASSERT (ConfigInfo
!= NULL
);
664 ConfigInfo
->Signature
= FORM_BROWSER_CONFIG_REQUEST_SIGNATURE
;
665 ConfigInfo
->ConfigRequest
= AllocateCopyPool (StrSize (Storage
->ConfigHdr
), Storage
->ConfigHdr
);
666 ASSERT (ConfigInfo
->ConfigRequest
!= NULL
);
667 ConfigInfo
->SpareStrLen
= 0;
668 ConfigInfo
->Storage
= Storage
;
669 InsertTailList(&Form
->ConfigRequestHead
, &ConfigInfo
->Link
);
673 // Append <RequestElement> to <ConfigRequest>
675 if (StrLen
> ConfigInfo
->SpareStrLen
) {
677 // Old String buffer is not sufficient for RequestElement, allocate a new one
679 StringSize
= (ConfigInfo
->ConfigRequest
!= NULL
) ? StrSize (ConfigInfo
->ConfigRequest
) : sizeof (CHAR16
);
680 NewStr
= AllocateZeroPool (StringSize
+ CONFIG_REQUEST_STRING_INCREMENTAL
* sizeof (CHAR16
));
681 ASSERT (NewStr
!= NULL
);
682 if (ConfigInfo
->ConfigRequest
!= NULL
) {
683 CopyMem (NewStr
, ConfigInfo
->ConfigRequest
, StringSize
);
684 FreePool (ConfigInfo
->ConfigRequest
);
686 ConfigInfo
->ConfigRequest
= NewStr
;
687 ConfigInfo
->SpareStrLen
= CONFIG_REQUEST_STRING_INCREMENTAL
;
690 StrCat (ConfigInfo
->ConfigRequest
, RequestElement
);
691 ConfigInfo
->ElementCount
++;
692 ConfigInfo
->SpareStrLen
-= StrLen
;
698 Free resources of a Expression.
700 @param FormSet Pointer of the Expression
705 IN FORM_EXPRESSION
*Expression
709 EXPRESSION_OPCODE
*OpCode
;
710 LIST_ENTRY
*SubExpressionLink
;
711 FORM_EXPRESSION
*SubExpression
;
713 while (!IsListEmpty (&Expression
->OpCodeListHead
)) {
714 Link
= GetFirstNode (&Expression
->OpCodeListHead
);
715 OpCode
= EXPRESSION_OPCODE_FROM_LINK (Link
);
716 RemoveEntryList (&OpCode
->Link
);
718 if (OpCode
->ValueList
!= NULL
) {
719 FreePool (OpCode
->ValueList
);
722 if (OpCode
->ValueName
!= NULL
) {
723 FreePool (OpCode
->ValueName
);
726 if (OpCode
->MapExpressionList
.ForwardLink
!= NULL
) {
727 while (!IsListEmpty (&OpCode
->MapExpressionList
)) {
728 SubExpressionLink
= GetFirstNode(&OpCode
->MapExpressionList
);
729 SubExpression
= FORM_EXPRESSION_FROM_LINK (SubExpressionLink
);
730 RemoveEntryList(&SubExpression
->Link
);
731 DestroyExpression (SubExpression
);
737 // Free this Expression
739 FreePool (Expression
);
743 Free resources of a storage.
745 @param Storage Pointer of the storage
750 IN FORMSET_STORAGE
*Storage
753 if (Storage
== NULL
) {
757 if (Storage
->ConfigRequest
!= NULL
) {
758 FreePool (Storage
->ConfigRequest
);
766 Free resources of a Statement.
768 @param FormSet Pointer of the FormSet
769 @param Statement Pointer of the Statement
774 IN FORM_BROWSER_FORMSET
*FormSet
,
775 IN OUT FORM_BROWSER_STATEMENT
*Statement
779 QUESTION_DEFAULT
*Default
;
780 QUESTION_OPTION
*Option
;
781 FORM_EXPRESSION
*Expression
;
784 // Free Default value List
786 while (!IsListEmpty (&Statement
->DefaultListHead
)) {
787 Link
= GetFirstNode (&Statement
->DefaultListHead
);
788 Default
= QUESTION_DEFAULT_FROM_LINK (Link
);
789 RemoveEntryList (&Default
->Link
);
797 while (!IsListEmpty (&Statement
->OptionListHead
)) {
798 Link
= GetFirstNode (&Statement
->OptionListHead
);
799 Option
= QUESTION_OPTION_FROM_LINK (Link
);
800 if (Option
->SuppressExpression
!= NULL
) {
801 FreePool (Option
->SuppressExpression
);
803 RemoveEntryList (&Option
->Link
);
809 // Free Inconsistent List
811 while (!IsListEmpty (&Statement
->InconsistentListHead
)) {
812 Link
= GetFirstNode (&Statement
->InconsistentListHead
);
813 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
814 RemoveEntryList (&Expression
->Link
);
816 DestroyExpression (Expression
);
820 // Free NoSubmit List
822 while (!IsListEmpty (&Statement
->NoSubmitListHead
)) {
823 Link
= GetFirstNode (&Statement
->NoSubmitListHead
);
824 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
825 RemoveEntryList (&Expression
->Link
);
827 DestroyExpression (Expression
);
831 // Free WarningIf List
833 while (!IsListEmpty (&Statement
->WarningListHead
)) {
834 Link
= GetFirstNode (&Statement
->WarningListHead
);
835 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
836 RemoveEntryList (&Expression
->Link
);
838 DestroyExpression (Expression
);
841 if (Statement
->Expression
!= NULL
) {
842 FreePool (Statement
->Expression
);
845 if (Statement
->VariableName
!= NULL
) {
846 FreePool (Statement
->VariableName
);
848 if (Statement
->BlockName
!= NULL
) {
849 FreePool (Statement
->BlockName
);
851 if (Statement
->BufferValue
!= NULL
) {
852 FreePool (Statement
->BufferValue
);
854 if (Statement
->Operand
== EFI_IFR_STRING_OP
|| Statement
->Operand
== EFI_IFR_PASSWORD_OP
) {
855 DeleteString(Statement
->HiiValue
.Value
.string
, FormSet
->HiiHandle
);
861 Free resources of a Form.
863 @param FormSet Pointer of the FormSet
864 @param Form Pointer of the Form.
869 IN FORM_BROWSER_FORMSET
*FormSet
,
870 IN OUT FORM_BROWSER_FORM
*Form
874 FORM_EXPRESSION
*Expression
;
875 FORM_BROWSER_STATEMENT
*Statement
;
876 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
879 // Free Form Expressions
881 while (!IsListEmpty (&Form
->ExpressionListHead
)) {
882 Link
= GetFirstNode (&Form
->ExpressionListHead
);
883 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
884 RemoveEntryList (&Expression
->Link
);
886 DestroyExpression (Expression
);
890 // Free Statements/Questions
892 while (!IsListEmpty (&Form
->StatementListHead
)) {
893 Link
= GetFirstNode (&Form
->StatementListHead
);
894 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
895 RemoveEntryList (&Statement
->Link
);
897 DestroyStatement (FormSet
, Statement
);
901 // Free ConfigRequest string.
903 while (!IsListEmpty (&Form
->ConfigRequestHead
)) {
904 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
905 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
906 RemoveEntryList (&ConfigInfo
->Link
);
908 FreePool (ConfigInfo
->ConfigRequest
);
909 FreePool (ConfigInfo
);
912 if (Form
->SuppressExpression
!= NULL
) {
913 FreePool (Form
->SuppressExpression
);
924 Free resources allocated for a FormSet.
926 @param FormSet Pointer of the FormSet
931 IN OUT FORM_BROWSER_FORMSET
*FormSet
935 FORMSET_STORAGE
*Storage
;
936 FORMSET_DEFAULTSTORE
*DefaultStore
;
937 FORM_EXPRESSION
*Expression
;
938 FORM_BROWSER_FORM
*Form
;
940 if (FormSet
->IfrBinaryData
== NULL
) {
942 // Uninitialized FormSet
949 // Free IFR binary buffer
951 FreePool (FormSet
->IfrBinaryData
);
954 // Free FormSet Storage
956 if (FormSet
->StorageListHead
.ForwardLink
!= NULL
) {
957 while (!IsListEmpty (&FormSet
->StorageListHead
)) {
958 Link
= GetFirstNode (&FormSet
->StorageListHead
);
959 Storage
= FORMSET_STORAGE_FROM_LINK (Link
);
960 RemoveEntryList (&Storage
->Link
);
962 DestroyStorage (Storage
);
967 // Free FormSet Default Store
969 if (FormSet
->DefaultStoreListHead
.ForwardLink
!= NULL
) {
970 while (!IsListEmpty (&FormSet
->DefaultStoreListHead
)) {
971 Link
= GetFirstNode (&FormSet
->DefaultStoreListHead
);
972 DefaultStore
= FORMSET_DEFAULTSTORE_FROM_LINK (Link
);
973 RemoveEntryList (&DefaultStore
->Link
);
975 FreePool (DefaultStore
);
980 // Free Formset Expressions
982 while (!IsListEmpty (&FormSet
->ExpressionListHead
)) {
983 Link
= GetFirstNode (&FormSet
->ExpressionListHead
);
984 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
985 RemoveEntryList (&Expression
->Link
);
987 DestroyExpression (Expression
);
993 if (FormSet
->FormListHead
.ForwardLink
!= NULL
) {
994 while (!IsListEmpty (&FormSet
->FormListHead
)) {
995 Link
= GetFirstNode (&FormSet
->FormListHead
);
996 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
997 RemoveEntryList (&Form
->Link
);
999 DestroyForm (FormSet
, Form
);
1003 if (FormSet
->StatementBuffer
!= NULL
) {
1004 FreePool (FormSet
->StatementBuffer
);
1006 if (FormSet
->ExpressionBuffer
!= NULL
) {
1007 FreePool (FormSet
->ExpressionBuffer
);
1015 Tell whether this Operand is an Expression OpCode or not
1017 @param Operand Operand of an IFR OpCode.
1019 @retval TRUE This is an Expression OpCode.
1020 @retval FALSE Not an Expression OpCode.
1024 IsExpressionOpCode (
1028 if (((Operand
>= EFI_IFR_EQ_ID_VAL_OP
) && (Operand
<= EFI_IFR_NOT_OP
)) ||
1029 ((Operand
>= EFI_IFR_MATCH_OP
) && (Operand
<= EFI_IFR_SET_OP
)) ||
1030 ((Operand
>= EFI_IFR_EQUAL_OP
) && (Operand
<= EFI_IFR_SPAN_OP
)) ||
1031 (Operand
== EFI_IFR_CATENATE_OP
) ||
1032 (Operand
== EFI_IFR_TO_LOWER_OP
) ||
1033 (Operand
== EFI_IFR_TO_UPPER_OP
) ||
1034 (Operand
== EFI_IFR_MAP_OP
) ||
1035 (Operand
== EFI_IFR_VERSION_OP
) ||
1036 (Operand
== EFI_IFR_SECURITY_OP
)) {
1044 Tell whether this Operand is an Statement OpCode.
1046 @param Operand Operand of an IFR OpCode.
1048 @retval TRUE This is an Statement OpCode.
1049 @retval FALSE Not an Statement OpCode.
1057 if ((Operand
== EFI_IFR_SUBTITLE_OP
) ||
1058 (Operand
== EFI_IFR_TEXT_OP
) ||
1059 (Operand
== EFI_IFR_RESET_BUTTON_OP
) ||
1060 (Operand
== EFI_IFR_REF_OP
) ||
1061 (Operand
== EFI_IFR_ACTION_OP
) ||
1062 (Operand
== EFI_IFR_NUMERIC_OP
) ||
1063 (Operand
== EFI_IFR_ORDERED_LIST_OP
) ||
1064 (Operand
== EFI_IFR_CHECKBOX_OP
) ||
1065 (Operand
== EFI_IFR_STRING_OP
) ||
1066 (Operand
== EFI_IFR_PASSWORD_OP
) ||
1067 (Operand
== EFI_IFR_DATE_OP
) ||
1068 (Operand
== EFI_IFR_TIME_OP
) ||
1069 (Operand
== EFI_IFR_GUID_OP
) ||
1070 (Operand
== EFI_IFR_ONE_OF_OP
)) {
1078 Tell whether this Operand is an known OpCode.
1080 @param Operand Operand of an IFR OpCode.
1082 @retval TRUE This is an Statement OpCode.
1083 @retval FALSE Not an Statement OpCode.
1091 return Operand
> EFI_IFR_WARNING_IF_OP
? TRUE
: FALSE
;
1095 Calculate number of Statemens(Questions) and Expression OpCodes.
1097 @param FormSet The FormSet to be counted.
1098 @param NumberOfStatement Number of Statemens(Questions)
1099 @param NumberOfExpression Number of Expression OpCodes
1104 IN FORM_BROWSER_FORMSET
*FormSet
,
1105 IN OUT UINT16
*NumberOfStatement
,
1106 IN OUT UINT16
*NumberOfExpression
1109 UINT16 StatementCount
;
1110 UINT16 ExpressionCount
;
1117 ExpressionCount
= 0;
1119 while (Offset
< FormSet
->IfrBinaryLength
) {
1120 OpCodeData
= FormSet
->IfrBinaryData
+ Offset
;
1121 OpCodeLen
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
1122 Offset
+= OpCodeLen
;
1124 if (IsExpressionOpCode (((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
)) {
1131 *NumberOfStatement
= StatementCount
;
1132 *NumberOfExpression
= ExpressionCount
;
1138 Parse opcodes in the formset IFR binary.
1140 @param FormSet Pointer of the FormSet data structure.
1142 @retval EFI_SUCCESS Opcode parse success.
1143 @retval Other Opcode parse fail.
1148 IN FORM_BROWSER_FORMSET
*FormSet
1152 FORM_BROWSER_FORM
*CurrentForm
;
1153 FORM_BROWSER_STATEMENT
*CurrentStatement
;
1154 FORM_BROWSER_STATEMENT
*ParentStatement
;
1155 EXPRESSION_OPCODE
*ExpressionOpCode
;
1156 FORM_EXPRESSION
*CurrentExpression
;
1163 FORMSET_STORAGE
*Storage
;
1164 FORMSET_DEFAULTSTORE
*DefaultStore
;
1165 QUESTION_DEFAULT
*CurrentDefault
;
1166 QUESTION_OPTION
*CurrentOption
;
1168 UINT16 NumberOfStatement
;
1169 UINT16 NumberOfExpression
;
1170 EFI_IMAGE_ID
*ImageId
;
1171 BOOLEAN SuppressForQuestion
;
1172 BOOLEAN SuppressForOption
;
1173 UINT16 DepthOfDisable
;
1174 BOOLEAN OpCodeDisabled
;
1175 BOOLEAN SingleOpCodeExpression
;
1176 BOOLEAN InScopeDefault
;
1177 EFI_HII_VALUE
*Value
;
1178 EFI_IFR_FORM_MAP_METHOD
*MapMethod
;
1179 UINT8 MapScopeDepth
;
1181 FORMSET_STORAGE
*VarStorage
;
1182 LIST_ENTRY
*MapExpressionList
;
1183 EFI_VARSTORE_ID TempVarstoreId
;
1184 BOOLEAN InScopeDisable
;
1185 INTN ConditionalExprCount
;
1186 BOOLEAN InUnknownScope
;
1189 SuppressForQuestion
= FALSE
;
1190 SuppressForOption
= FALSE
;
1191 InScopeDisable
= FALSE
;
1193 OpCodeDisabled
= FALSE
;
1194 SingleOpCodeExpression
= FALSE
;
1195 InScopeDefault
= FALSE
;
1196 CurrentExpression
= NULL
;
1197 CurrentDefault
= NULL
;
1198 CurrentOption
= NULL
;
1204 MapExpressionList
= NULL
;
1206 ConditionalExprCount
= 0;
1207 InUnknownScope
= FALSE
;
1211 // Get the number of Statements and Expressions
1213 CountOpCodes (FormSet
, &NumberOfStatement
, &NumberOfExpression
);
1215 mStatementIndex
= 0;
1216 mUsedQuestionId
= 1;
1217 FormSet
->StatementBuffer
= AllocateZeroPool (NumberOfStatement
* sizeof (FORM_BROWSER_STATEMENT
));
1218 if (FormSet
->StatementBuffer
== NULL
) {
1219 return EFI_OUT_OF_RESOURCES
;
1222 mExpressionOpCodeIndex
= 0;
1223 FormSet
->ExpressionBuffer
= AllocateZeroPool (NumberOfExpression
* sizeof (EXPRESSION_OPCODE
));
1224 if (FormSet
->ExpressionBuffer
== NULL
) {
1225 return EFI_OUT_OF_RESOURCES
;
1228 InitializeListHead (&FormSet
->StatementListOSF
);
1229 InitializeListHead (&FormSet
->StorageListHead
);
1230 InitializeListHead (&FormSet
->DefaultStoreListHead
);
1231 InitializeListHead (&FormSet
->FormListHead
);
1232 InitializeListHead (&FormSet
->ExpressionListHead
);
1233 ResetCurrentExpressionStack ();
1234 ResetMapExpressionListStack ();
1237 CurrentStatement
= NULL
;
1238 ParentStatement
= NULL
;
1243 while (OpCodeOffset
< FormSet
->IfrBinaryLength
) {
1244 OpCodeData
= FormSet
->IfrBinaryData
+ OpCodeOffset
;
1246 OpCodeLength
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
1247 OpCodeOffset
+= OpCodeLength
;
1248 Operand
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
;
1249 Scope
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Scope
;
1251 if (InUnknownScope
) {
1252 if (Operand
== EFI_IFR_END_OP
) {
1255 if (UnknownDepth
== 0) {
1256 InUnknownScope
= FALSE
;
1267 if (IsUnKnownOpCode(Operand
)) {
1269 InUnknownScope
= TRUE
;
1277 // If scope bit set, push onto scope stack
1280 PushScope (Operand
);
1283 if (OpCodeDisabled
) {
1285 // DisableIf Expression is evaluated to be TRUE, try to find its end.
1286 // Here only cares the EFI_IFR_DISABLE_IF and EFI_IFR_END
1288 if (Operand
== EFI_IFR_DISABLE_IF_OP
) {
1290 } else if (Operand
== EFI_IFR_END_OP
) {
1291 Status
= PopScope (&ScopeOpCode
);
1292 if (EFI_ERROR (Status
)) {
1296 if (ScopeOpCode
== EFI_IFR_DISABLE_IF_OP
) {
1297 if (DepthOfDisable
== 0) {
1298 InScopeDisable
= FALSE
;
1299 OpCodeDisabled
= FALSE
;
1308 if (IsExpressionOpCode (Operand
)) {
1309 ExpressionOpCode
= &FormSet
->ExpressionBuffer
[mExpressionOpCodeIndex
];
1310 mExpressionOpCodeIndex
++;
1312 ExpressionOpCode
->Signature
= EXPRESSION_OPCODE_SIGNATURE
;
1313 ExpressionOpCode
->Operand
= Operand
;
1314 Value
= &ExpressionOpCode
->Value
;
1317 case EFI_IFR_EQ_ID_VAL_OP
:
1318 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1320 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1321 CopyMem (&Value
->Value
.u16
, &((EFI_IFR_EQ_ID_VAL
*) OpCodeData
)->Value
, sizeof (UINT16
));
1324 case EFI_IFR_EQ_ID_ID_OP
:
1325 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_ID
*) OpCodeData
)->QuestionId1
, sizeof (EFI_QUESTION_ID
));
1326 CopyMem (&ExpressionOpCode
->QuestionId2
, &((EFI_IFR_EQ_ID_ID
*) OpCodeData
)->QuestionId2
, sizeof (EFI_QUESTION_ID
));
1329 case EFI_IFR_EQ_ID_VAL_LIST_OP
:
1330 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1331 CopyMem (&ExpressionOpCode
->ListLength
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->ListLength
, sizeof (UINT16
));
1332 ExpressionOpCode
->ValueList
= AllocateCopyPool (ExpressionOpCode
->ListLength
* sizeof (UINT16
), &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->ValueList
);
1335 case EFI_IFR_TO_STRING_OP
:
1336 case EFI_IFR_FIND_OP
:
1337 ExpressionOpCode
->Format
= (( EFI_IFR_TO_STRING
*) OpCodeData
)->Format
;
1340 case EFI_IFR_STRING_REF1_OP
:
1341 Value
->Type
= EFI_IFR_TYPE_STRING
;
1342 CopyMem (&Value
->Value
.string
, &(( EFI_IFR_STRING_REF1
*) OpCodeData
)->StringId
, sizeof (EFI_STRING_ID
));
1345 case EFI_IFR_RULE_REF_OP
:
1346 ExpressionOpCode
->RuleId
= (( EFI_IFR_RULE_REF
*) OpCodeData
)->RuleId
;
1349 case EFI_IFR_SPAN_OP
:
1350 ExpressionOpCode
->Flags
= (( EFI_IFR_SPAN
*) OpCodeData
)->Flags
;
1353 case EFI_IFR_THIS_OP
:
1354 ASSERT (ParentStatement
!= NULL
);
1355 ExpressionOpCode
->QuestionId
= ParentStatement
->QuestionId
;
1358 case EFI_IFR_SECURITY_OP
:
1359 CopyMem (&ExpressionOpCode
->Guid
, &((EFI_IFR_SECURITY
*) OpCodeData
)->Permissions
, sizeof (EFI_GUID
));
1362 case EFI_IFR_GET_OP
:
1363 case EFI_IFR_SET_OP
:
1364 CopyMem (&TempVarstoreId
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreId
, sizeof (TempVarstoreId
));
1365 if (TempVarstoreId
!= 0) {
1366 if (FormSet
->StorageListHead
.ForwardLink
!= NULL
) {
1367 Link
= GetFirstNode (&FormSet
->StorageListHead
);
1368 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
1369 VarStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
1370 if (VarStorage
->VarStoreId
== ((EFI_IFR_GET
*) OpCodeData
)->VarStoreId
) {
1371 ExpressionOpCode
->VarStorage
= VarStorage
->BrowserStorage
;
1374 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
1377 if (ExpressionOpCode
->VarStorage
== NULL
) {
1379 // VarStorage is not found.
1381 return EFI_INVALID_PARAMETER
;
1384 ExpressionOpCode
->ValueType
= ((EFI_IFR_GET
*) OpCodeData
)->VarStoreType
;
1385 switch (ExpressionOpCode
->ValueType
) {
1386 case EFI_IFR_TYPE_BOOLEAN
:
1387 case EFI_IFR_TYPE_NUM_SIZE_8
:
1388 ExpressionOpCode
->ValueWidth
= 1;
1391 case EFI_IFR_TYPE_NUM_SIZE_16
:
1392 case EFI_IFR_TYPE_STRING
:
1393 ExpressionOpCode
->ValueWidth
= 2;
1396 case EFI_IFR_TYPE_NUM_SIZE_32
:
1397 ExpressionOpCode
->ValueWidth
= 4;
1400 case EFI_IFR_TYPE_NUM_SIZE_64
:
1401 ExpressionOpCode
->ValueWidth
= 8;
1404 case EFI_IFR_TYPE_DATE
:
1405 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_DATE
);
1408 case EFI_IFR_TYPE_TIME
:
1409 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_TIME
);
1412 case EFI_IFR_TYPE_REF
:
1413 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_REF
);
1416 case EFI_IFR_TYPE_OTHER
:
1417 case EFI_IFR_TYPE_UNDEFINED
:
1418 case EFI_IFR_TYPE_ACTION
:
1419 case EFI_IFR_TYPE_BUFFER
:
1422 // Invalid value type for Get/Set opcode.
1424 return EFI_INVALID_PARAMETER
;
1426 CopyMem (&ExpressionOpCode
->VarStoreInfo
.VarName
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreInfo
.VarName
, sizeof (EFI_STRING_ID
));
1427 CopyMem (&ExpressionOpCode
->VarStoreInfo
.VarOffset
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreInfo
.VarOffset
, sizeof (UINT16
));
1428 if ((ExpressionOpCode
->VarStorage
!= NULL
) &&
1429 (ExpressionOpCode
->VarStorage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
||
1430 ExpressionOpCode
->VarStorage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
)) {
1431 ExpressionOpCode
->ValueName
= GetToken (ExpressionOpCode
->VarStoreInfo
.VarName
, FormSet
->HiiHandle
);
1432 if (ExpressionOpCode
->ValueName
== NULL
) {
1434 // String ID is invalid.
1436 return EFI_INVALID_PARAMETER
;
1441 case EFI_IFR_QUESTION_REF1_OP
:
1442 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1445 case EFI_IFR_QUESTION_REF3_OP
:
1446 if (OpCodeLength
>= sizeof (EFI_IFR_QUESTION_REF3_2
)) {
1447 CopyMem (&ExpressionOpCode
->DevicePath
, &(( EFI_IFR_QUESTION_REF3_2
*) OpCodeData
)->DevicePath
, sizeof (EFI_STRING_ID
));
1449 if (OpCodeLength
>= sizeof (EFI_IFR_QUESTION_REF3_3
)) {
1450 CopyMem (&ExpressionOpCode
->Guid
, &(( EFI_IFR_QUESTION_REF3_3
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
1458 case EFI_IFR_TRUE_OP
:
1459 Value
->Type
= EFI_IFR_TYPE_BOOLEAN
;
1460 Value
->Value
.b
= TRUE
;
1463 case EFI_IFR_FALSE_OP
:
1464 Value
->Type
= EFI_IFR_TYPE_BOOLEAN
;
1465 Value
->Value
.b
= FALSE
;
1468 case EFI_IFR_ONE_OP
:
1469 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1470 Value
->Value
.u8
= 1;
1473 case EFI_IFR_ZERO_OP
:
1474 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1475 Value
->Value
.u8
= 0;
1478 case EFI_IFR_ONES_OP
:
1479 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1480 Value
->Value
.u64
= 0xffffffffffffffffULL
;
1483 case EFI_IFR_UINT8_OP
:
1484 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1485 Value
->Value
.u8
= (( EFI_IFR_UINT8
*) OpCodeData
)->Value
;
1488 case EFI_IFR_UINT16_OP
:
1489 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1490 CopyMem (&Value
->Value
.u16
, &(( EFI_IFR_UINT16
*) OpCodeData
)->Value
, sizeof (UINT16
));
1493 case EFI_IFR_UINT32_OP
:
1494 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_32
;
1495 CopyMem (&Value
->Value
.u32
, &(( EFI_IFR_UINT32
*) OpCodeData
)->Value
, sizeof (UINT32
));
1498 case EFI_IFR_UINT64_OP
:
1499 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1500 CopyMem (&Value
->Value
.u64
, &(( EFI_IFR_UINT64
*) OpCodeData
)->Value
, sizeof (UINT64
));
1503 case EFI_IFR_UNDEFINED_OP
:
1504 Value
->Type
= EFI_IFR_TYPE_UNDEFINED
;
1507 case EFI_IFR_VERSION_OP
:
1508 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1509 Value
->Value
.u16
= EFI_IFR_SPECIFICATION_VERSION
;
1516 // Create sub expression nested in MAP opcode
1518 if (CurrentExpression
== NULL
&& MapScopeDepth
> 0) {
1519 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
1520 ASSERT (MapExpressionList
!= NULL
);
1521 InsertTailList (MapExpressionList
, &CurrentExpression
->Link
);
1523 SingleOpCodeExpression
= TRUE
;
1526 ASSERT (CurrentExpression
!= NULL
);
1527 InsertTailList (&CurrentExpression
->OpCodeListHead
, &ExpressionOpCode
->Link
);
1528 if (Operand
== EFI_IFR_MAP_OP
) {
1530 // Store current Map Expression List.
1532 if (MapExpressionList
!= NULL
) {
1533 PushMapExpressionList (MapExpressionList
);
1536 // Initialize new Map Expression List.
1538 MapExpressionList
= &ExpressionOpCode
->MapExpressionList
;
1539 InitializeListHead (MapExpressionList
);
1541 // Store current expression.
1543 PushCurrentExpression (CurrentExpression
);
1544 CurrentExpression
= NULL
;
1546 } else if (SingleOpCodeExpression
) {
1548 // There are two cases to indicate the end of an Expression:
1549 // for single OpCode expression: one Expression OpCode
1550 // for expression consists of more than one OpCode: EFI_IFR_END
1552 SingleOpCodeExpression
= FALSE
;
1554 if (InScopeDisable
&& CurrentForm
== NULL
) {
1556 // This is DisableIf expression for Form, it should be a constant expression
1558 Status
= EvaluateExpression (FormSet
, CurrentForm
, CurrentExpression
);
1559 if (EFI_ERROR (Status
)) {
1563 OpCodeDisabled
= IsTrue(&CurrentExpression
->Result
);
1566 CurrentExpression
= NULL
;
1577 case EFI_IFR_FORM_SET_OP
:
1579 // Check the formset GUID
1581 if (CompareMem (&FormSet
->Guid
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
)) != 0) {
1582 return EFI_INVALID_PARAMETER
;
1585 CopyMem (&FormSet
->FormSetTitle
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->FormSetTitle
, sizeof (EFI_STRING_ID
));
1586 CopyMem (&FormSet
->Help
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->Help
, sizeof (EFI_STRING_ID
));
1588 if (OpCodeLength
> OFFSET_OF (EFI_IFR_FORM_SET
, Flags
)) {
1590 // The formset OpCode contains ClassGuid
1592 FormSet
->NumberOfClassGuid
= (UINT8
) (((EFI_IFR_FORM_SET
*) OpCodeData
)->Flags
& 0x3);
1593 CopyMem (FormSet
->ClassGuid
, OpCodeData
+ sizeof (EFI_IFR_FORM_SET
), FormSet
->NumberOfClassGuid
* sizeof (EFI_GUID
));
1597 case EFI_IFR_FORM_OP
:
1599 // Create a new Form for this FormSet
1601 CurrentForm
= AllocateZeroPool (sizeof (FORM_BROWSER_FORM
));
1602 ASSERT (CurrentForm
!= NULL
);
1603 CurrentForm
->Signature
= FORM_BROWSER_FORM_SIGNATURE
;
1604 InitializeListHead (&CurrentForm
->ExpressionListHead
);
1605 InitializeListHead (&CurrentForm
->StatementListHead
);
1606 InitializeListHead (&CurrentForm
->ConfigRequestHead
);
1608 CurrentForm
->FormType
= STANDARD_MAP_FORM_TYPE
;
1609 CopyMem (&CurrentForm
->FormId
, &((EFI_IFR_FORM
*) OpCodeData
)->FormId
, sizeof (UINT16
));
1610 CopyMem (&CurrentForm
->FormTitle
, &((EFI_IFR_FORM
*) OpCodeData
)->FormTitle
, sizeof (EFI_STRING_ID
));
1612 ConditionalExprCount
= GetConditionalExpressionCount(ExpressForm
);
1613 if ( ConditionalExprCount
> 0) {
1615 // Form is inside of suppressif
1617 CurrentForm
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
1618 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
1619 ASSERT (CurrentForm
->SuppressExpression
!= NULL
);
1620 CurrentForm
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
1621 CurrentForm
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
1622 CopyMem (CurrentForm
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressForm
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
1627 // Enter scope of a Form, suppressif will be used for Question or Option
1629 SuppressForQuestion
= TRUE
;
1633 // Insert into Form list of this FormSet
1635 InsertTailList (&FormSet
->FormListHead
, &CurrentForm
->Link
);
1638 case EFI_IFR_FORM_MAP_OP
:
1640 // Create a new Form for this FormSet
1642 CurrentForm
= AllocateZeroPool (sizeof (FORM_BROWSER_FORM
));
1643 ASSERT (CurrentForm
!= NULL
);
1644 CurrentForm
->Signature
= FORM_BROWSER_FORM_SIGNATURE
;
1645 InitializeListHead (&CurrentForm
->ExpressionListHead
);
1646 InitializeListHead (&CurrentForm
->StatementListHead
);
1647 InitializeListHead (&CurrentForm
->ConfigRequestHead
);
1648 CopyMem (&CurrentForm
->FormId
, &((EFI_IFR_FORM
*) OpCodeData
)->FormId
, sizeof (UINT16
));
1650 MapMethod
= (EFI_IFR_FORM_MAP_METHOD
*) (OpCodeData
+ sizeof (EFI_IFR_FORM_MAP
));
1652 // FormMap Form must contain at least one Map Method.
1654 if (((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
< ((UINTN
) (UINT8
*) (MapMethod
+ 1) - (UINTN
) OpCodeData
)) {
1655 return EFI_INVALID_PARAMETER
;
1658 // Try to find the standard form map method.
1660 while (((UINTN
) (UINT8
*) MapMethod
- (UINTN
) OpCodeData
) < ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
) {
1661 if (CompareGuid ((EFI_GUID
*) (VOID
*) &MapMethod
->MethodIdentifier
, &gEfiHiiStandardFormGuid
)) {
1662 CopyMem (&CurrentForm
->FormTitle
, &MapMethod
->MethodTitle
, sizeof (EFI_STRING_ID
));
1663 CurrentForm
->FormType
= STANDARD_MAP_FORM_TYPE
;
1669 // If the standard form map method is not found, the first map method title will be used.
1671 if (CurrentForm
->FormTitle
== 0) {
1672 MapMethod
= (EFI_IFR_FORM_MAP_METHOD
*) (OpCodeData
+ sizeof (EFI_IFR_FORM_MAP
));
1673 CopyMem (&CurrentForm
->FormTitle
, &MapMethod
->MethodTitle
, sizeof (EFI_STRING_ID
));
1676 ConditionalExprCount
= GetConditionalExpressionCount(ExpressForm
);
1677 if ( ConditionalExprCount
> 0) {
1679 // Form is inside of suppressif
1681 CurrentForm
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
1682 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
1683 ASSERT (CurrentForm
->SuppressExpression
!= NULL
);
1684 CurrentForm
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
1685 CurrentForm
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
1686 CopyMem (CurrentForm
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressForm
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
1691 // Enter scope of a Form, suppressif will be used for Question or Option
1693 SuppressForQuestion
= TRUE
;
1697 // Insert into Form list of this FormSet
1699 InsertTailList (&FormSet
->FormListHead
, &CurrentForm
->Link
);
1705 case EFI_IFR_VARSTORE_OP
:
1707 // Create a buffer Storage for this FormSet
1709 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_BUFFER
, OpCodeData
);
1710 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1713 case EFI_IFR_VARSTORE_NAME_VALUE_OP
:
1715 // Create a name/value Storage for this FormSet
1717 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_NAME_VALUE
, OpCodeData
);
1718 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE_NAME_VALUE
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1721 case EFI_IFR_VARSTORE_EFI_OP
:
1723 // Create a EFI variable Storage for this FormSet
1725 if (OpCodeLength
< sizeof (EFI_IFR_VARSTORE_EFI
)) {
1727 // Create efi varstore with format follow UEFI spec before 2.3.1.
1729 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_EFI_VARIABLE
, OpCodeData
);
1732 // Create efi varstore with format follow UEFI spec 2.3.1 and later.
1734 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
, OpCodeData
);
1736 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1742 case EFI_IFR_DEFAULTSTORE_OP
:
1743 DefaultStore
= AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE
));
1744 ASSERT (DefaultStore
!= NULL
);
1745 DefaultStore
->Signature
= FORMSET_DEFAULTSTORE_SIGNATURE
;
1747 CopyMem (&DefaultStore
->DefaultId
, &((EFI_IFR_DEFAULTSTORE
*) OpCodeData
)->DefaultId
, sizeof (UINT16
));
1748 CopyMem (&DefaultStore
->DefaultName
, &((EFI_IFR_DEFAULTSTORE
*) OpCodeData
)->DefaultName
, sizeof (EFI_STRING_ID
));
1751 // Insert to DefaultStore list of this Formset
1753 InsertTailList (&FormSet
->DefaultStoreListHead
, &DefaultStore
->Link
);
1759 case EFI_IFR_SUBTITLE_OP
:
1760 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1761 ASSERT (CurrentStatement
!= NULL
);
1763 CurrentStatement
->Flags
= ((EFI_IFR_SUBTITLE
*) OpCodeData
)->Flags
;
1764 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1767 case EFI_IFR_TEXT_OP
:
1768 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1769 ASSERT (CurrentStatement
!= NULL
);
1770 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1771 CopyMem (&CurrentStatement
->TextTwo
, &((EFI_IFR_TEXT
*) OpCodeData
)->TextTwo
, sizeof (EFI_STRING_ID
));
1774 case EFI_IFR_RESET_BUTTON_OP
:
1775 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1776 ASSERT (CurrentStatement
!= NULL
);
1777 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1778 CopyMem (&CurrentStatement
->DefaultId
, &((EFI_IFR_RESET_BUTTON
*) OpCodeData
)->DefaultId
, sizeof (EFI_DEFAULT_ID
));
1784 case EFI_IFR_ACTION_OP
:
1785 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1786 ASSERT (CurrentStatement
!= NULL
);
1787 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_ACTION
;
1789 if (OpCodeLength
== sizeof (EFI_IFR_ACTION_1
)) {
1791 // No QuestionConfig present, so no configuration string will be processed
1793 CurrentStatement
->QuestionConfig
= 0;
1795 CopyMem (&CurrentStatement
->QuestionConfig
, &((EFI_IFR_ACTION
*) OpCodeData
)->QuestionConfig
, sizeof (EFI_STRING_ID
));
1799 case EFI_IFR_REF_OP
:
1800 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1801 ASSERT (CurrentStatement
!= NULL
);
1802 Value
= &CurrentStatement
->HiiValue
;
1803 Value
->Type
= EFI_IFR_TYPE_REF
;
1804 if (OpCodeLength
>= sizeof (EFI_IFR_REF
)) {
1805 CopyMem (&Value
->Value
.ref
.FormId
, &((EFI_IFR_REF
*) OpCodeData
)->FormId
, sizeof (EFI_FORM_ID
));
1807 if (OpCodeLength
>= sizeof (EFI_IFR_REF2
)) {
1808 CopyMem (&Value
->Value
.ref
.QuestionId
, &((EFI_IFR_REF2
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1810 if (OpCodeLength
>= sizeof (EFI_IFR_REF3
)) {
1811 CopyMem (&Value
->Value
.ref
.FormSetGuid
, &((EFI_IFR_REF3
*) OpCodeData
)->FormSetId
, sizeof (EFI_GUID
));
1813 if (OpCodeLength
>= sizeof (EFI_IFR_REF4
)) {
1814 CopyMem (&Value
->Value
.ref
.DevicePath
, &((EFI_IFR_REF4
*) OpCodeData
)->DevicePath
, sizeof (EFI_STRING_ID
));
1819 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_REF
);
1820 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1823 case EFI_IFR_ONE_OF_OP
:
1824 case EFI_IFR_NUMERIC_OP
:
1825 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1826 ASSERT(CurrentStatement
!= NULL
);
1828 CurrentStatement
->Flags
= ((EFI_IFR_ONE_OF
*) OpCodeData
)->Flags
;
1829 Value
= &CurrentStatement
->HiiValue
;
1831 switch (CurrentStatement
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1832 case EFI_IFR_NUMERIC_SIZE_1
:
1833 CurrentStatement
->Minimum
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.MinValue
;
1834 CurrentStatement
->Maximum
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.MaxValue
;
1835 CurrentStatement
->Step
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.Step
;
1836 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT8
);
1837 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1840 case EFI_IFR_NUMERIC_SIZE_2
:
1841 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.MinValue
, sizeof (UINT16
));
1842 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.MaxValue
, sizeof (UINT16
));
1843 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.Step
, sizeof (UINT16
));
1844 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT16
);
1845 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1848 case EFI_IFR_NUMERIC_SIZE_4
:
1849 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MinValue
, sizeof (UINT32
));
1850 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MaxValue
, sizeof (UINT32
));
1851 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.Step
, sizeof (UINT32
));
1852 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT32
);
1853 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_32
;
1856 case EFI_IFR_NUMERIC_SIZE_8
:
1857 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.MinValue
, sizeof (UINT64
));
1858 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.MaxValue
, sizeof (UINT64
));
1859 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.Step
, sizeof (UINT64
));
1860 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT64
);
1861 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1868 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1870 if ((Operand
== EFI_IFR_ONE_OF_OP
) && Scope
!= 0) {
1871 SuppressForOption
= TRUE
;
1875 case EFI_IFR_ORDERED_LIST_OP
:
1876 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1877 ASSERT(CurrentStatement
!= NULL
);
1879 CurrentStatement
->Flags
= ((EFI_IFR_ORDERED_LIST
*) OpCodeData
)->Flags
;
1880 CurrentStatement
->MaxContainers
= ((EFI_IFR_ORDERED_LIST
*) OpCodeData
)->MaxContainers
;
1882 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_BUFFER
;
1883 CurrentStatement
->BufferValue
= NULL
;
1886 SuppressForOption
= TRUE
;
1890 case EFI_IFR_CHECKBOX_OP
:
1891 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1892 ASSERT(CurrentStatement
!= NULL
);
1894 CurrentStatement
->Flags
= ((EFI_IFR_CHECKBOX
*) OpCodeData
)->Flags
;
1895 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (BOOLEAN
);
1896 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_BOOLEAN
;
1898 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1902 case EFI_IFR_STRING_OP
:
1903 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1904 ASSERT (CurrentStatement
!= NULL
);
1906 // MinSize is the minimum number of characters that can be accepted for this opcode,
1907 // MaxSize is the maximum number of characters that can be accepted for this opcode.
1908 // The characters are stored as Unicode, so the storage width should multiply 2.
1910 CurrentStatement
->Minimum
= ((EFI_IFR_STRING
*) OpCodeData
)->MinSize
;
1911 CurrentStatement
->Maximum
= ((EFI_IFR_STRING
*) OpCodeData
)->MaxSize
;
1912 CurrentStatement
->StorageWidth
= (UINT16
)((UINTN
) CurrentStatement
->Maximum
* sizeof (CHAR16
));
1913 CurrentStatement
->Flags
= ((EFI_IFR_STRING
*) OpCodeData
)->Flags
;
1915 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_STRING
;
1916 CurrentStatement
->BufferValue
= AllocateZeroPool (CurrentStatement
->StorageWidth
+ sizeof (CHAR16
));
1917 CurrentStatement
->HiiValue
.Value
.string
= NewString ((CHAR16
*) CurrentStatement
->BufferValue
, FormSet
->HiiHandle
);
1919 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1922 case EFI_IFR_PASSWORD_OP
:
1923 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1924 ASSERT (CurrentStatement
!= NULL
);
1926 // MinSize is the minimum number of characters that can be accepted for this opcode,
1927 // MaxSize is the maximum number of characters that can be accepted for this opcode.
1928 // The characters are stored as Unicode, so the storage width should multiply 2.
1930 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_PASSWORD
*) OpCodeData
)->MinSize
, sizeof (UINT16
));
1931 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_PASSWORD
*) OpCodeData
)->MaxSize
, sizeof (UINT16
));
1932 CurrentStatement
->StorageWidth
= (UINT16
)((UINTN
) CurrentStatement
->Maximum
* sizeof (CHAR16
));
1934 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_STRING
;
1935 CurrentStatement
->BufferValue
= AllocateZeroPool ((CurrentStatement
->StorageWidth
+ sizeof (CHAR16
)));
1936 CurrentStatement
->HiiValue
.Value
.string
= NewString ((CHAR16
*) CurrentStatement
->BufferValue
, FormSet
->HiiHandle
);
1938 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1941 case EFI_IFR_DATE_OP
:
1942 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1943 ASSERT(CurrentStatement
!= NULL
);
1945 CurrentStatement
->Flags
= ((EFI_IFR_DATE
*) OpCodeData
)->Flags
;
1946 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_DATE
;
1948 if ((CurrentStatement
->Flags
& EFI_QF_DATE_STORAGE
) == QF_DATE_STORAGE_NORMAL
) {
1949 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_DATE
);
1951 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1954 // Don't assign storage for RTC type of date/time
1956 CurrentStatement
->Storage
= NULL
;
1957 CurrentStatement
->StorageWidth
= 0;
1961 case EFI_IFR_TIME_OP
:
1962 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1963 ASSERT(CurrentStatement
!= NULL
);
1965 CurrentStatement
->Flags
= ((EFI_IFR_TIME
*) OpCodeData
)->Flags
;
1966 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_TIME
;
1968 if ((CurrentStatement
->Flags
& QF_TIME_STORAGE
) == QF_TIME_STORAGE_NORMAL
) {
1969 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_TIME
);
1971 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1974 // Don't assign storage for RTC type of date/time
1976 CurrentStatement
->Storage
= NULL
;
1977 CurrentStatement
->StorageWidth
= 0;
1984 case EFI_IFR_DEFAULT_OP
:
1986 // EFI_IFR_DEFAULT appear in scope of a Question,
1987 // It creates a default value for the current question.
1988 // A Question may have more than one Default value which have different default types.
1990 CurrentDefault
= AllocateZeroPool (sizeof (QUESTION_DEFAULT
));
1991 ASSERT (CurrentDefault
!= NULL
);
1992 CurrentDefault
->Signature
= QUESTION_DEFAULT_SIGNATURE
;
1994 CurrentDefault
->Value
.Type
= ((EFI_IFR_DEFAULT
*) OpCodeData
)->Type
;
1995 CopyMem (&CurrentDefault
->DefaultId
, &((EFI_IFR_DEFAULT
*) OpCodeData
)->DefaultId
, sizeof (UINT16
));
1996 if (OpCodeLength
> OFFSET_OF (EFI_IFR_DEFAULT
, Value
)) {
1997 CopyMem (&CurrentDefault
->Value
.Value
, &((EFI_IFR_DEFAULT
*) OpCodeData
)->Value
, OpCodeLength
- OFFSET_OF (EFI_IFR_DEFAULT
, Value
));
1998 ExtendValueToU64 (&CurrentDefault
->Value
);
2002 // Insert to Default Value list of current Question
2004 InsertTailList (&ParentStatement
->DefaultListHead
, &CurrentDefault
->Link
);
2007 InScopeDefault
= TRUE
;
2014 case EFI_IFR_ONE_OF_OPTION_OP
:
2016 // EFI_IFR_ONE_OF_OPTION appear in scope of a Question.
2017 // It create a selection for use in current Question.
2019 CurrentOption
= AllocateZeroPool (sizeof (QUESTION_OPTION
));
2020 ASSERT (CurrentOption
!= NULL
);
2021 CurrentOption
->Signature
= QUESTION_OPTION_SIGNATURE
;
2022 CurrentOption
->OpCode
= (EFI_IFR_ONE_OF_OPTION
*) OpCodeData
;
2024 CurrentOption
->Flags
= ((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Flags
;
2025 CurrentOption
->Value
.Type
= ((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Type
;
2026 CopyMem (&CurrentOption
->Text
, &((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Option
, sizeof (EFI_STRING_ID
));
2027 CopyMem (&CurrentOption
->Value
.Value
, &((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Value
, OpCodeLength
- OFFSET_OF (EFI_IFR_ONE_OF_OPTION
, Value
));
2028 ExtendValueToU64 (&CurrentOption
->Value
);
2030 ConditionalExprCount
= GetConditionalExpressionCount(ExpressOption
);
2031 if ( ConditionalExprCount
> 0) {
2033 // Form is inside of suppressif
2035 CurrentOption
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
2036 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
2037 ASSERT (CurrentOption
->SuppressExpression
!= NULL
);
2038 CurrentOption
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
2039 CurrentOption
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
2040 CopyMem (CurrentOption
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressOption
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
2043 ASSERT (ParentStatement
!= NULL
);
2045 // Insert to Option list of current Question
2047 InsertTailList (&ParentStatement
->OptionListHead
, &CurrentOption
->Link
);
2049 // Now we know the Storage width of nested Ordered List
2051 if ((ParentStatement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) && (ParentStatement
->BufferValue
== NULL
)) {
2053 switch (CurrentOption
->Value
.Type
) {
2054 case EFI_IFR_TYPE_NUM_SIZE_8
:
2058 case EFI_IFR_TYPE_NUM_SIZE_16
:
2062 case EFI_IFR_TYPE_NUM_SIZE_32
:
2066 case EFI_IFR_TYPE_NUM_SIZE_64
:
2072 // Invalid type for Ordered List
2077 ParentStatement
->StorageWidth
= (UINT16
) (ParentStatement
->MaxContainers
* Width
);
2078 ParentStatement
->BufferValue
= AllocateZeroPool (ParentStatement
->StorageWidth
);
2079 ParentStatement
->ValueType
= CurrentOption
->Value
.Type
;
2080 if (ParentStatement
->HiiValue
.Type
== EFI_IFR_TYPE_BUFFER
) {
2081 ParentStatement
->HiiValue
.Buffer
= ParentStatement
->BufferValue
;
2082 ParentStatement
->HiiValue
.BufferLen
= ParentStatement
->StorageWidth
;
2085 InitializeRequestElement (FormSet
, ParentStatement
, CurrentForm
);
2092 case EFI_IFR_NO_SUBMIT_IF_OP
:
2093 case EFI_IFR_INCONSISTENT_IF_OP
:
2095 // Create an Expression node
2097 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2098 CopyMem (&CurrentExpression
->Error
, &((EFI_IFR_INCONSISTENT_IF
*) OpCodeData
)->Error
, sizeof (EFI_STRING_ID
));
2100 if (Operand
== EFI_IFR_NO_SUBMIT_IF_OP
) {
2101 CurrentExpression
->Type
= EFI_HII_EXPRESSION_NO_SUBMIT_IF
;
2102 InsertTailList (&ParentStatement
->NoSubmitListHead
, &CurrentExpression
->Link
);
2104 CurrentExpression
->Type
= EFI_HII_EXPRESSION_INCONSISTENT_IF
;
2105 InsertTailList (&ParentStatement
->InconsistentListHead
, &CurrentExpression
->Link
);
2109 // Take a look at next OpCode to see whether current expression consists
2112 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2113 SingleOpCodeExpression
= TRUE
;
2117 case EFI_IFR_WARNING_IF_OP
:
2119 // Create an Expression node
2121 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2122 CopyMem (&CurrentExpression
->Error
, &((EFI_IFR_WARNING_IF
*) OpCodeData
)->Warning
, sizeof (EFI_STRING_ID
));
2123 CurrentExpression
->TimeOut
= ((EFI_IFR_WARNING_IF
*) OpCodeData
)->TimeOut
;
2124 CurrentExpression
->Type
= EFI_HII_EXPRESSION_WARNING_IF
;
2125 InsertTailList (&ParentStatement
->WarningListHead
, &CurrentExpression
->Link
);
2128 // Take a look at next OpCode to see whether current expression consists
2131 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2132 SingleOpCodeExpression
= TRUE
;
2136 case EFI_IFR_SUPPRESS_IF_OP
:
2138 // Question and Option will appear in scope of this OpCode
2140 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2141 CurrentExpression
->Type
= EFI_HII_EXPRESSION_SUPPRESS_IF
;
2143 if (CurrentForm
== NULL
) {
2144 InsertTailList (&FormSet
->ExpressionListHead
, &CurrentExpression
->Link
);
2146 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2149 if (SuppressForOption
) {
2150 PushConditionalExpression(CurrentExpression
, ExpressOption
);
2151 } else if (SuppressForQuestion
) {
2152 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2154 PushConditionalExpression(CurrentExpression
, ExpressForm
);
2158 // Take a look at next OpCode to see whether current expression consists
2161 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2162 SingleOpCodeExpression
= TRUE
;
2166 case EFI_IFR_GRAY_OUT_IF_OP
:
2168 // Questions will appear in scope of this OpCode
2170 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2171 CurrentExpression
->Type
= EFI_HII_EXPRESSION_GRAY_OUT_IF
;
2172 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2173 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2176 // Take a look at next OpCode to see whether current expression consists
2179 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2180 SingleOpCodeExpression
= TRUE
;
2184 case EFI_IFR_DISABLE_IF_OP
:
2186 // The DisableIf expression should only rely on constant, so it could be
2187 // evaluated at initialization and it will not be queued
2189 CurrentExpression
= AllocateZeroPool (sizeof (FORM_EXPRESSION
));
2190 ASSERT (CurrentExpression
!= NULL
);
2191 CurrentExpression
->Signature
= FORM_EXPRESSION_SIGNATURE
;
2192 CurrentExpression
->Type
= EFI_HII_EXPRESSION_DISABLE_IF
;
2193 InitializeListHead (&CurrentExpression
->OpCodeListHead
);
2195 if (CurrentForm
!= NULL
) {
2197 // This is DisableIf for Question, enqueue it to Form expression list
2199 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2200 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2203 OpCodeDisabled
= FALSE
;
2204 InScopeDisable
= TRUE
;
2206 // Take a look at next OpCode to see whether current expression consists
2209 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2210 SingleOpCodeExpression
= TRUE
;
2217 case EFI_IFR_VALUE_OP
:
2218 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2219 CurrentExpression
->Type
= EFI_HII_EXPRESSION_VALUE
;
2220 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2222 if (InScopeDefault
) {
2224 // Used for default (EFI_IFR_DEFAULT)
2226 CurrentDefault
->ValueExpression
= CurrentExpression
;
2229 // If used for a question, then the question will be read-only
2232 // Make sure CurrentStatement is not NULL.
2233 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2234 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2236 ASSERT (ParentStatement
!= NULL
);
2237 ParentStatement
->ValueExpression
= CurrentExpression
;
2241 // Take a look at next OpCode to see whether current expression consists
2244 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2245 SingleOpCodeExpression
= TRUE
;
2249 case EFI_IFR_RULE_OP
:
2250 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2251 CurrentExpression
->Type
= EFI_HII_EXPRESSION_RULE
;
2253 CurrentExpression
->RuleId
= ((EFI_IFR_RULE
*) OpCodeData
)->RuleId
;
2254 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2257 // Take a look at next OpCode to see whether current expression consists
2260 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2261 SingleOpCodeExpression
= TRUE
;
2265 case EFI_IFR_READ_OP
:
2266 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2267 CurrentExpression
->Type
= EFI_HII_EXPRESSION_READ
;
2268 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2271 // Make sure CurrentStatement is not NULL.
2272 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2273 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2275 ASSERT (ParentStatement
!= NULL
);
2276 ParentStatement
->ReadExpression
= CurrentExpression
;
2279 // Take a look at next OpCode to see whether current expression consists
2282 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2283 SingleOpCodeExpression
= TRUE
;
2287 case EFI_IFR_WRITE_OP
:
2288 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2289 CurrentExpression
->Type
= EFI_HII_EXPRESSION_WRITE
;
2290 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2293 // Make sure CurrentStatement is not NULL.
2294 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2295 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2297 ASSERT (ParentStatement
!= NULL
);
2298 ParentStatement
->WriteExpression
= CurrentExpression
;
2301 // Take a look at next OpCode to see whether current expression consists
2304 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2305 SingleOpCodeExpression
= TRUE
;
2312 case EFI_IFR_IMAGE_OP
:
2314 // Get ScopeOpcode from top of stack
2316 PopScope (&ScopeOpCode
);
2317 PushScope (ScopeOpCode
);
2319 switch (ScopeOpCode
) {
2320 case EFI_IFR_FORM_SET_OP
:
2321 ImageId
= &FormSet
->ImageId
;
2324 case EFI_IFR_FORM_OP
:
2325 case EFI_IFR_FORM_MAP_OP
:
2326 ASSERT (CurrentForm
!= NULL
);
2327 ImageId
= &CurrentForm
->ImageId
;
2330 case EFI_IFR_ONE_OF_OPTION_OP
:
2331 ASSERT (CurrentOption
!= NULL
);
2332 ImageId
= &CurrentOption
->ImageId
;
2337 // Make sure CurrentStatement is not NULL.
2338 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2339 // file is wrongly generated by tools such as VFR Compiler.
2341 ASSERT (ParentStatement
!= NULL
);
2342 ImageId
= &ParentStatement
->ImageId
;
2346 ASSERT (ImageId
!= NULL
);
2347 CopyMem (ImageId
, &((EFI_IFR_IMAGE
*) OpCodeData
)->Id
, sizeof (EFI_IMAGE_ID
));
2353 case EFI_IFR_REFRESH_OP
:
2354 ASSERT (ParentStatement
!= NULL
);
2355 ParentStatement
->RefreshInterval
= ((EFI_IFR_REFRESH
*) OpCodeData
)->RefreshInterval
;
2361 case EFI_IFR_REFRESH_ID_OP
:
2362 ASSERT (ParentStatement
!= NULL
);
2363 CopyMem (&ParentStatement
->RefreshGuid
, &((EFI_IFR_REFRESH_ID
*) OpCodeData
)->RefreshEventGroupId
, sizeof (EFI_GUID
));
2369 case EFI_IFR_MODAL_TAG_OP
:
2370 ASSERT (CurrentForm
!= NULL
);
2371 CurrentForm
->ModalForm
= TRUE
;
2375 // Lock tag, used by form and statement.
2377 case EFI_IFR_LOCKED_OP
:
2379 // Get ScopeOpcode from top of stack
2381 PopScope (&ScopeOpCode
);
2382 PushScope (ScopeOpCode
);
2383 switch (ScopeOpCode
) {
2384 case EFI_IFR_FORM_OP
:
2385 case EFI_IFR_FORM_MAP_OP
:
2386 ASSERT (CurrentForm
!= NULL
);
2387 CurrentForm
->Locked
= TRUE
;
2391 ASSERT (ParentStatement
!= NULL
);
2392 ParentStatement
->Locked
= TRUE
;
2399 case EFI_IFR_GUID_OP
:
2400 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
2406 case EFI_IFR_END_OP
:
2407 Status
= PopScope (&ScopeOpCode
);
2408 if (EFI_ERROR (Status
)) {
2414 // Parent statement end tag found, update ParentStatement info.
2416 if (IsStatementOpCode(ScopeOpCode
) && (ParentStatement
!= NULL
) && (ParentStatement
->Operand
== ScopeOpCode
)) {
2417 ParentStatement
= ParentStatement
->ParentStatement
;
2420 switch (ScopeOpCode
) {
2421 case EFI_IFR_FORM_SET_OP
:
2423 // End of FormSet, update FormSet IFR binary length
2424 // to stop parsing substantial OpCodes
2426 FormSet
->IfrBinaryLength
= OpCodeOffset
;
2429 case EFI_IFR_FORM_OP
:
2430 case EFI_IFR_FORM_MAP_OP
:
2435 SuppressForQuestion
= FALSE
;
2438 case EFI_IFR_ONE_OF_OPTION_OP
:
2442 CurrentOption
= NULL
;
2445 case EFI_IFR_NO_SUBMIT_IF_OP
:
2446 case EFI_IFR_INCONSISTENT_IF_OP
:
2447 case EFI_IFR_WARNING_IF_OP
:
2449 // Ignore end of EFI_IFR_NO_SUBMIT_IF and EFI_IFR_INCONSISTENT_IF
2453 case EFI_IFR_SUPPRESS_IF_OP
:
2454 if (SuppressForOption
) {
2455 PopConditionalExpression(ExpressOption
);
2456 } else if (SuppressForQuestion
) {
2457 PopConditionalExpression(ExpressStatement
);
2459 PopConditionalExpression(ExpressForm
);
2463 case EFI_IFR_GRAY_OUT_IF_OP
:
2464 PopConditionalExpression(ExpressStatement
);
2467 case EFI_IFR_DISABLE_IF_OP
:
2468 if (CurrentForm
!= NULL
) {
2469 PopConditionalExpression(ExpressStatement
);
2471 InScopeDisable
= FALSE
;
2472 OpCodeDisabled
= FALSE
;
2475 case EFI_IFR_ONE_OF_OP
:
2476 case EFI_IFR_ORDERED_LIST_OP
:
2477 SuppressForOption
= FALSE
;
2480 case EFI_IFR_DEFAULT_OP
:
2481 InScopeDefault
= FALSE
;
2484 case EFI_IFR_MAP_OP
:
2486 // Get current Map Expression List.
2488 Status
= PopMapExpressionList ((VOID
**) &MapExpressionList
);
2489 if (Status
== EFI_ACCESS_DENIED
) {
2490 MapExpressionList
= NULL
;
2493 // Get current expression.
2495 Status
= PopCurrentExpression ((VOID
**) &CurrentExpression
);
2496 ASSERT_EFI_ERROR (Status
);
2497 ASSERT (MapScopeDepth
> 0);
2502 if (IsExpressionOpCode (ScopeOpCode
)) {
2503 if (InScopeDisable
&& CurrentForm
== NULL
) {
2505 // This is DisableIf expression for Form, it should be a constant expression
2507 ASSERT (CurrentExpression
!= NULL
);
2508 Status
= EvaluateExpression (FormSet
, CurrentForm
, CurrentExpression
);
2509 if (EFI_ERROR (Status
)) {
2513 OpCodeDisabled
= IsTrue (&CurrentExpression
->Result
);
2516 // DisableIf Expression is only used once and not queued, free it
2518 DestroyExpression (CurrentExpression
);
2522 // End of current Expression
2524 CurrentExpression
= NULL
;
2534 if (IsStatementOpCode(Operand
)) {
2535 CurrentStatement
->ParentStatement
= ParentStatement
;
2538 // Scope != 0, other statements or options may nest in this statement.
2539 // Update the ParentStatement info.
2541 ParentStatement
= CurrentStatement
;