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 Check whether exist device path info in the ConfigHdr string.
457 @param String UEFI configuration string
459 @retval TRUE Device Path exist.
460 @retval FALSE Not exist device path info.
470 for (; (*String
!= 0 && StrnCmp (String
, L
"PATH=", StrLen (L
"PATH=")) != 0); String
++);
475 String
+= StrLen (L
"PATH=");
480 for (Length
= 0; *String
!= 0 && *String
!= L
'&'; String
++, Length
++);
481 if (((Length
+ 1) / 2) < sizeof (EFI_DEVICE_PATH_PROTOCOL
)) {
489 Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List.
491 @param FormSet Pointer of the current FormSet
492 @param StorageType Storage type.
493 @param OpCodeData Binary data for this opcode.
495 @return Pointer to a FORMSET_STORAGE data structure.
500 IN FORM_BROWSER_FORMSET
*FormSet
,
501 IN UINT8 StorageType
,
505 FORMSET_STORAGE
*Storage
;
506 CHAR16
*UnicodeString
;
508 BROWSER_STORAGE
*BrowserStorage
;
509 EFI_GUID
*StorageGuid
;
512 UnicodeString
= NULL
;
514 switch (StorageType
) {
515 case EFI_HII_VARSTORE_BUFFER
:
516 StorageGuid
= (EFI_GUID
*) (CHAR8
*) &((EFI_IFR_VARSTORE
*) OpCodeData
)->Guid
;
517 StorageName
= (CHAR8
*) ((EFI_IFR_VARSTORE
*) OpCodeData
)->Name
;
520 case EFI_HII_VARSTORE_EFI_VARIABLE
:
521 case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
:
522 StorageGuid
= (EFI_GUID
*) (CHAR8
*) &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Guid
;
523 StorageName
= (CHAR8
*) ((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Name
;
527 ASSERT (StorageType
== EFI_HII_VARSTORE_NAME_VALUE
);
528 StorageGuid
= &((EFI_IFR_VARSTORE_NAME_VALUE
*) OpCodeData
)->Guid
;
532 if (StorageType
!= EFI_HII_VARSTORE_NAME_VALUE
) {
533 ASSERT (StorageName
!= NULL
);
535 UnicodeString
= AllocateZeroPool (AsciiStrSize (StorageName
) * 2);
536 ASSERT (UnicodeString
!= NULL
);
537 for (Index
= 0; StorageName
[Index
] != 0; Index
++) {
538 UnicodeString
[Index
] = (CHAR16
) StorageName
[Index
];
542 Storage
= AllocateZeroPool (sizeof (FORMSET_STORAGE
));
543 ASSERT (Storage
!= NULL
);
544 Storage
->Signature
= FORMSET_STORAGE_SIGNATURE
;
545 InsertTailList (&FormSet
->StorageListHead
, &Storage
->Link
);
547 BrowserStorage
= FindStorageInList(StorageType
, StorageGuid
, UnicodeString
, FormSet
->HiiHandle
);
548 if (BrowserStorage
== NULL
) {
549 BrowserStorage
= AllocateZeroPool (sizeof (BROWSER_STORAGE
));
550 ASSERT (BrowserStorage
!= NULL
);
552 BrowserStorage
->Signature
= BROWSER_STORAGE_SIGNATURE
;
553 InsertTailList (&gBrowserStorageList
, &BrowserStorage
->Link
);
555 IntializeBrowserStorage (BrowserStorage
, StorageType
, OpCodeData
);
556 BrowserStorage
->Type
= StorageType
;
557 if (StorageType
!= EFI_HII_VARSTORE_NAME_VALUE
) {
558 BrowserStorage
->Name
= UnicodeString
;
561 BrowserStorage
->HiiHandle
= FormSet
->HiiHandle
;
562 InitializeConfigHdr (FormSet
, BrowserStorage
);
564 BrowserStorage
->Initialized
= FALSE
;
566 if ((StorageType
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) &&
567 (FormSet
->DriverHandle
!= NULL
) &&
568 (!IsDevicePathExist (BrowserStorage
->ConfigHdr
))) {
570 // If this storage not has device path info but new formset has,
571 // update the device path info.
573 FreePool (BrowserStorage
->ConfigHdr
);
574 InitializeConfigHdr (FormSet
, BrowserStorage
);
578 Storage
->BrowserStorage
= BrowserStorage
;
579 Storage
->ConfigRequest
= AllocateCopyPool (StrSize (BrowserStorage
->ConfigHdr
), BrowserStorage
->ConfigHdr
);
580 Storage
->SpareStrLen
= 0;
586 Initialize Request Element of a Question. <RequestElement> ::= '&'<BlockName> | '&'<Label>
588 @param FormSet Pointer of the current FormSet.
589 @param Question The Question to be initialized.
590 @param Form Pointer of the current form.
592 @retval EFI_SUCCESS Function success.
593 @retval EFI_INVALID_PARAMETER No storage associated with the Question.
597 InitializeRequestElement (
598 IN OUT FORM_BROWSER_FORMSET
*FormSet
,
599 IN OUT FORM_BROWSER_STATEMENT
*Question
,
600 IN OUT FORM_BROWSER_FORM
*Form
603 BROWSER_STORAGE
*Storage
;
604 FORMSET_STORAGE
*FormsetStorage
;
608 CHAR16 RequestElement
[30];
611 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
613 Storage
= Question
->Storage
;
614 if (Storage
== NULL
) {
615 return EFI_INVALID_PARAMETER
;
618 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
620 // <ConfigRequest> is unnecessary for EFI variable storage,
621 // GetVariable()/SetVariable() will be used to retrieve/save values
627 // Prepare <RequestElement>
629 if (Storage
->Type
== EFI_HII_VARSTORE_BUFFER
||
630 Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
631 StrLen
= UnicodeSPrint (
633 30 * sizeof (CHAR16
),
634 L
"&OFFSET=%04x&WIDTH=%04x",
635 Question
->VarStoreInfo
.VarOffset
,
636 Question
->StorageWidth
638 Question
->BlockName
= AllocateCopyPool ((StrLen
+ 1) * sizeof (CHAR16
), RequestElement
);
640 StrLen
= UnicodeSPrint (RequestElement
, 30 * sizeof (CHAR16
), L
"&%s", Question
->VariableName
);
643 if ((Question
->Operand
== EFI_IFR_PASSWORD_OP
) && ((Question
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
)) {
645 // Password with CALLBACK flag is stored in encoded format,
646 // so don't need to append it to <ConfigRequest>
652 // Find Formset Storage for this Question
654 FormsetStorage
= NULL
;
655 Link
= GetFirstNode (&FormSet
->StorageListHead
);
656 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
657 FormsetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
659 if (FormsetStorage
->VarStoreId
== Question
->VarStoreId
) {
663 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
665 ASSERT (FormsetStorage
!= NULL
);
668 // Append <RequestElement> to <ConfigRequest>
670 if (StrLen
> FormsetStorage
->SpareStrLen
) {
672 // Old String buffer is not sufficient for RequestElement, allocate a new one
674 StringSize
= (FormsetStorage
->ConfigRequest
!= NULL
) ? StrSize (FormsetStorage
->ConfigRequest
) : sizeof (CHAR16
);
675 NewStr
= AllocateZeroPool (StringSize
+ CONFIG_REQUEST_STRING_INCREMENTAL
* sizeof (CHAR16
));
676 ASSERT (NewStr
!= NULL
);
677 if (FormsetStorage
->ConfigRequest
!= NULL
) {
678 CopyMem (NewStr
, FormsetStorage
->ConfigRequest
, StringSize
);
679 FreePool (FormsetStorage
->ConfigRequest
);
681 FormsetStorage
->ConfigRequest
= NewStr
;
682 FormsetStorage
->SpareStrLen
= CONFIG_REQUEST_STRING_INCREMENTAL
;
685 StrCat (FormsetStorage
->ConfigRequest
, RequestElement
);
686 FormsetStorage
->ElementCount
++;
687 FormsetStorage
->SpareStrLen
-= StrLen
;
690 // Update the Config Request info saved in the form.
694 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
695 while (!IsNull (&Form
->ConfigRequestHead
, Link
)) {
696 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
698 if (ConfigInfo
!= NULL
&& ConfigInfo
->Storage
== Storage
) {
703 Link
= GetNextNode (&Form
->ConfigRequestHead
, Link
);
707 ConfigInfo
= AllocateZeroPool(sizeof (FORM_BROWSER_CONFIG_REQUEST
));
708 ASSERT (ConfigInfo
!= NULL
);
709 ConfigInfo
->Signature
= FORM_BROWSER_CONFIG_REQUEST_SIGNATURE
;
710 ConfigInfo
->ConfigRequest
= AllocateCopyPool (StrSize (Storage
->ConfigHdr
), Storage
->ConfigHdr
);
711 ASSERT (ConfigInfo
->ConfigRequest
!= NULL
);
712 ConfigInfo
->SpareStrLen
= 0;
713 ConfigInfo
->Storage
= Storage
;
714 InsertTailList(&Form
->ConfigRequestHead
, &ConfigInfo
->Link
);
718 // Append <RequestElement> to <ConfigRequest>
720 if (StrLen
> ConfigInfo
->SpareStrLen
) {
722 // Old String buffer is not sufficient for RequestElement, allocate a new one
724 StringSize
= (ConfigInfo
->ConfigRequest
!= NULL
) ? StrSize (ConfigInfo
->ConfigRequest
) : sizeof (CHAR16
);
725 NewStr
= AllocateZeroPool (StringSize
+ CONFIG_REQUEST_STRING_INCREMENTAL
* sizeof (CHAR16
));
726 ASSERT (NewStr
!= NULL
);
727 if (ConfigInfo
->ConfigRequest
!= NULL
) {
728 CopyMem (NewStr
, ConfigInfo
->ConfigRequest
, StringSize
);
729 FreePool (ConfigInfo
->ConfigRequest
);
731 ConfigInfo
->ConfigRequest
= NewStr
;
732 ConfigInfo
->SpareStrLen
= CONFIG_REQUEST_STRING_INCREMENTAL
;
735 StrCat (ConfigInfo
->ConfigRequest
, RequestElement
);
736 ConfigInfo
->ElementCount
++;
737 ConfigInfo
->SpareStrLen
-= StrLen
;
743 Free resources of a Expression.
745 @param FormSet Pointer of the Expression
750 IN FORM_EXPRESSION
*Expression
754 EXPRESSION_OPCODE
*OpCode
;
755 LIST_ENTRY
*SubExpressionLink
;
756 FORM_EXPRESSION
*SubExpression
;
758 while (!IsListEmpty (&Expression
->OpCodeListHead
)) {
759 Link
= GetFirstNode (&Expression
->OpCodeListHead
);
760 OpCode
= EXPRESSION_OPCODE_FROM_LINK (Link
);
761 RemoveEntryList (&OpCode
->Link
);
763 if (OpCode
->ValueList
!= NULL
) {
764 FreePool (OpCode
->ValueList
);
767 if (OpCode
->ValueName
!= NULL
) {
768 FreePool (OpCode
->ValueName
);
771 if (OpCode
->MapExpressionList
.ForwardLink
!= NULL
) {
772 while (!IsListEmpty (&OpCode
->MapExpressionList
)) {
773 SubExpressionLink
= GetFirstNode(&OpCode
->MapExpressionList
);
774 SubExpression
= FORM_EXPRESSION_FROM_LINK (SubExpressionLink
);
775 RemoveEntryList(&SubExpression
->Link
);
776 DestroyExpression (SubExpression
);
782 // Free this Expression
784 FreePool (Expression
);
788 Free resources of a storage.
790 @param Storage Pointer of the storage
795 IN FORMSET_STORAGE
*Storage
798 if (Storage
== NULL
) {
802 if (Storage
->ConfigRequest
!= NULL
) {
803 FreePool (Storage
->ConfigRequest
);
811 Free resources of a Statement.
813 @param FormSet Pointer of the FormSet
814 @param Statement Pointer of the Statement
819 IN FORM_BROWSER_FORMSET
*FormSet
,
820 IN OUT FORM_BROWSER_STATEMENT
*Statement
824 QUESTION_DEFAULT
*Default
;
825 QUESTION_OPTION
*Option
;
826 FORM_EXPRESSION
*Expression
;
829 // Free Default value List
831 while (!IsListEmpty (&Statement
->DefaultListHead
)) {
832 Link
= GetFirstNode (&Statement
->DefaultListHead
);
833 Default
= QUESTION_DEFAULT_FROM_LINK (Link
);
834 RemoveEntryList (&Default
->Link
);
842 while (!IsListEmpty (&Statement
->OptionListHead
)) {
843 Link
= GetFirstNode (&Statement
->OptionListHead
);
844 Option
= QUESTION_OPTION_FROM_LINK (Link
);
845 if (Option
->SuppressExpression
!= NULL
) {
846 FreePool (Option
->SuppressExpression
);
848 RemoveEntryList (&Option
->Link
);
854 // Free Inconsistent List
856 while (!IsListEmpty (&Statement
->InconsistentListHead
)) {
857 Link
= GetFirstNode (&Statement
->InconsistentListHead
);
858 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
859 RemoveEntryList (&Expression
->Link
);
861 DestroyExpression (Expression
);
865 // Free NoSubmit List
867 while (!IsListEmpty (&Statement
->NoSubmitListHead
)) {
868 Link
= GetFirstNode (&Statement
->NoSubmitListHead
);
869 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
870 RemoveEntryList (&Expression
->Link
);
872 DestroyExpression (Expression
);
876 // Free WarningIf List
878 while (!IsListEmpty (&Statement
->WarningListHead
)) {
879 Link
= GetFirstNode (&Statement
->WarningListHead
);
880 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
881 RemoveEntryList (&Expression
->Link
);
883 DestroyExpression (Expression
);
886 if (Statement
->Expression
!= NULL
) {
887 FreePool (Statement
->Expression
);
890 if (Statement
->VariableName
!= NULL
) {
891 FreePool (Statement
->VariableName
);
893 if (Statement
->BlockName
!= NULL
) {
894 FreePool (Statement
->BlockName
);
896 if (Statement
->BufferValue
!= NULL
) {
897 FreePool (Statement
->BufferValue
);
899 if (Statement
->Operand
== EFI_IFR_STRING_OP
|| Statement
->Operand
== EFI_IFR_PASSWORD_OP
) {
900 DeleteString(Statement
->HiiValue
.Value
.string
, FormSet
->HiiHandle
);
906 Free resources of a Form.
908 @param FormSet Pointer of the FormSet
909 @param Form Pointer of the Form.
914 IN FORM_BROWSER_FORMSET
*FormSet
,
915 IN OUT FORM_BROWSER_FORM
*Form
919 FORM_EXPRESSION
*Expression
;
920 FORM_BROWSER_STATEMENT
*Statement
;
921 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
924 // Free Form Expressions
926 while (!IsListEmpty (&Form
->ExpressionListHead
)) {
927 Link
= GetFirstNode (&Form
->ExpressionListHead
);
928 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
929 RemoveEntryList (&Expression
->Link
);
931 DestroyExpression (Expression
);
935 // Free Statements/Questions
937 while (!IsListEmpty (&Form
->StatementListHead
)) {
938 Link
= GetFirstNode (&Form
->StatementListHead
);
939 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
940 RemoveEntryList (&Statement
->Link
);
942 DestroyStatement (FormSet
, Statement
);
946 // Free ConfigRequest string.
948 while (!IsListEmpty (&Form
->ConfigRequestHead
)) {
949 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
950 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
951 RemoveEntryList (&ConfigInfo
->Link
);
953 FreePool (ConfigInfo
->ConfigRequest
);
954 FreePool (ConfigInfo
);
957 if (Form
->SuppressExpression
!= NULL
) {
958 FreePool (Form
->SuppressExpression
);
961 UiFreeMenuList (&Form
->FormViewListHead
);
971 Free resources allocated for a FormSet.
973 @param FormSet Pointer of the FormSet
978 IN OUT FORM_BROWSER_FORMSET
*FormSet
982 FORMSET_STORAGE
*Storage
;
983 FORMSET_DEFAULTSTORE
*DefaultStore
;
984 FORM_EXPRESSION
*Expression
;
985 FORM_BROWSER_FORM
*Form
;
987 if (FormSet
->IfrBinaryData
== NULL
) {
989 // Uninitialized FormSet
996 // Free IFR binary buffer
998 FreePool (FormSet
->IfrBinaryData
);
1001 // Free FormSet Storage
1003 if (FormSet
->StorageListHead
.ForwardLink
!= NULL
) {
1004 while (!IsListEmpty (&FormSet
->StorageListHead
)) {
1005 Link
= GetFirstNode (&FormSet
->StorageListHead
);
1006 Storage
= FORMSET_STORAGE_FROM_LINK (Link
);
1007 RemoveEntryList (&Storage
->Link
);
1009 DestroyStorage (Storage
);
1014 // Free FormSet Default Store
1016 if (FormSet
->DefaultStoreListHead
.ForwardLink
!= NULL
) {
1017 while (!IsListEmpty (&FormSet
->DefaultStoreListHead
)) {
1018 Link
= GetFirstNode (&FormSet
->DefaultStoreListHead
);
1019 DefaultStore
= FORMSET_DEFAULTSTORE_FROM_LINK (Link
);
1020 RemoveEntryList (&DefaultStore
->Link
);
1022 FreePool (DefaultStore
);
1027 // Free Formset Expressions
1029 while (!IsListEmpty (&FormSet
->ExpressionListHead
)) {
1030 Link
= GetFirstNode (&FormSet
->ExpressionListHead
);
1031 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
1032 RemoveEntryList (&Expression
->Link
);
1034 DestroyExpression (Expression
);
1040 if (FormSet
->FormListHead
.ForwardLink
!= NULL
) {
1041 while (!IsListEmpty (&FormSet
->FormListHead
)) {
1042 Link
= GetFirstNode (&FormSet
->FormListHead
);
1043 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
1044 RemoveEntryList (&Form
->Link
);
1046 DestroyForm (FormSet
, Form
);
1050 if (FormSet
->StatementBuffer
!= NULL
) {
1051 FreePool (FormSet
->StatementBuffer
);
1053 if (FormSet
->ExpressionBuffer
!= NULL
) {
1054 FreePool (FormSet
->ExpressionBuffer
);
1062 Tell whether this Operand is an Expression OpCode or not
1064 @param Operand Operand of an IFR OpCode.
1066 @retval TRUE This is an Expression OpCode.
1067 @retval FALSE Not an Expression OpCode.
1071 IsExpressionOpCode (
1075 if (((Operand
>= EFI_IFR_EQ_ID_VAL_OP
) && (Operand
<= EFI_IFR_NOT_OP
)) ||
1076 ((Operand
>= EFI_IFR_MATCH_OP
) && (Operand
<= EFI_IFR_SET_OP
)) ||
1077 ((Operand
>= EFI_IFR_EQUAL_OP
) && (Operand
<= EFI_IFR_SPAN_OP
)) ||
1078 (Operand
== EFI_IFR_CATENATE_OP
) ||
1079 (Operand
== EFI_IFR_TO_LOWER_OP
) ||
1080 (Operand
== EFI_IFR_TO_UPPER_OP
) ||
1081 (Operand
== EFI_IFR_MAP_OP
) ||
1082 (Operand
== EFI_IFR_VERSION_OP
) ||
1083 (Operand
== EFI_IFR_SECURITY_OP
)) {
1091 Tell whether this Operand is an Statement OpCode.
1093 @param Operand Operand of an IFR OpCode.
1095 @retval TRUE This is an Statement OpCode.
1096 @retval FALSE Not an Statement OpCode.
1104 if ((Operand
== EFI_IFR_SUBTITLE_OP
) ||
1105 (Operand
== EFI_IFR_TEXT_OP
) ||
1106 (Operand
== EFI_IFR_RESET_BUTTON_OP
) ||
1107 (Operand
== EFI_IFR_REF_OP
) ||
1108 (Operand
== EFI_IFR_ACTION_OP
) ||
1109 (Operand
== EFI_IFR_NUMERIC_OP
) ||
1110 (Operand
== EFI_IFR_ORDERED_LIST_OP
) ||
1111 (Operand
== EFI_IFR_CHECKBOX_OP
) ||
1112 (Operand
== EFI_IFR_STRING_OP
) ||
1113 (Operand
== EFI_IFR_PASSWORD_OP
) ||
1114 (Operand
== EFI_IFR_DATE_OP
) ||
1115 (Operand
== EFI_IFR_TIME_OP
) ||
1116 (Operand
== EFI_IFR_GUID_OP
) ||
1117 (Operand
== EFI_IFR_ONE_OF_OP
)) {
1125 Tell whether this Operand is an known OpCode.
1127 @param Operand Operand of an IFR OpCode.
1129 @retval TRUE This is an Statement OpCode.
1130 @retval FALSE Not an Statement OpCode.
1138 return Operand
> EFI_IFR_WARNING_IF_OP
? TRUE
: FALSE
;
1142 Calculate number of Statemens(Questions) and Expression OpCodes.
1144 @param FormSet The FormSet to be counted.
1145 @param NumberOfStatement Number of Statemens(Questions)
1146 @param NumberOfExpression Number of Expression OpCodes
1151 IN FORM_BROWSER_FORMSET
*FormSet
,
1152 IN OUT UINT16
*NumberOfStatement
,
1153 IN OUT UINT16
*NumberOfExpression
1156 UINT16 StatementCount
;
1157 UINT16 ExpressionCount
;
1164 ExpressionCount
= 0;
1166 while (Offset
< FormSet
->IfrBinaryLength
) {
1167 OpCodeData
= FormSet
->IfrBinaryData
+ Offset
;
1168 OpCodeLen
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
1169 Offset
+= OpCodeLen
;
1171 if (IsExpressionOpCode (((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
)) {
1178 *NumberOfStatement
= StatementCount
;
1179 *NumberOfExpression
= ExpressionCount
;
1185 Parse opcodes in the formset IFR binary.
1187 @param FormSet Pointer of the FormSet data structure.
1189 @retval EFI_SUCCESS Opcode parse success.
1190 @retval Other Opcode parse fail.
1195 IN FORM_BROWSER_FORMSET
*FormSet
1199 FORM_BROWSER_FORM
*CurrentForm
;
1200 FORM_BROWSER_STATEMENT
*CurrentStatement
;
1201 FORM_BROWSER_STATEMENT
*ParentStatement
;
1202 EXPRESSION_OPCODE
*ExpressionOpCode
;
1203 FORM_EXPRESSION
*CurrentExpression
;
1210 FORMSET_STORAGE
*Storage
;
1211 FORMSET_DEFAULTSTORE
*DefaultStore
;
1212 QUESTION_DEFAULT
*CurrentDefault
;
1213 QUESTION_OPTION
*CurrentOption
;
1215 UINT16 NumberOfStatement
;
1216 UINT16 NumberOfExpression
;
1217 EFI_IMAGE_ID
*ImageId
;
1218 BOOLEAN SuppressForQuestion
;
1219 BOOLEAN SuppressForOption
;
1220 UINT16 DepthOfDisable
;
1221 BOOLEAN OpCodeDisabled
;
1222 BOOLEAN SingleOpCodeExpression
;
1223 BOOLEAN InScopeDefault
;
1224 EFI_HII_VALUE
*Value
;
1225 EFI_IFR_FORM_MAP_METHOD
*MapMethod
;
1226 UINT8 MapScopeDepth
;
1228 FORMSET_STORAGE
*VarStorage
;
1229 LIST_ENTRY
*MapExpressionList
;
1230 EFI_VARSTORE_ID TempVarstoreId
;
1231 BOOLEAN InScopeDisable
;
1232 INTN ConditionalExprCount
;
1233 BOOLEAN InUnknownScope
;
1236 SuppressForQuestion
= FALSE
;
1237 SuppressForOption
= FALSE
;
1238 InScopeDisable
= FALSE
;
1240 OpCodeDisabled
= FALSE
;
1241 SingleOpCodeExpression
= FALSE
;
1242 InScopeDefault
= FALSE
;
1243 CurrentExpression
= NULL
;
1244 CurrentDefault
= NULL
;
1245 CurrentOption
= NULL
;
1251 MapExpressionList
= NULL
;
1253 ConditionalExprCount
= 0;
1254 InUnknownScope
= FALSE
;
1258 // Get the number of Statements and Expressions
1260 CountOpCodes (FormSet
, &NumberOfStatement
, &NumberOfExpression
);
1262 mStatementIndex
= 0;
1263 mUsedQuestionId
= 1;
1264 FormSet
->StatementBuffer
= AllocateZeroPool (NumberOfStatement
* sizeof (FORM_BROWSER_STATEMENT
));
1265 if (FormSet
->StatementBuffer
== NULL
) {
1266 return EFI_OUT_OF_RESOURCES
;
1269 mExpressionOpCodeIndex
= 0;
1270 FormSet
->ExpressionBuffer
= AllocateZeroPool (NumberOfExpression
* sizeof (EXPRESSION_OPCODE
));
1271 if (FormSet
->ExpressionBuffer
== NULL
) {
1272 return EFI_OUT_OF_RESOURCES
;
1275 InitializeListHead (&FormSet
->StatementListOSF
);
1276 InitializeListHead (&FormSet
->StorageListHead
);
1277 InitializeListHead (&FormSet
->SaveFailStorageListHead
);
1278 InitializeListHead (&FormSet
->DefaultStoreListHead
);
1279 InitializeListHead (&FormSet
->FormListHead
);
1280 InitializeListHead (&FormSet
->ExpressionListHead
);
1281 ResetCurrentExpressionStack ();
1282 ResetMapExpressionListStack ();
1285 CurrentStatement
= NULL
;
1286 ParentStatement
= NULL
;
1291 while (OpCodeOffset
< FormSet
->IfrBinaryLength
) {
1292 OpCodeData
= FormSet
->IfrBinaryData
+ OpCodeOffset
;
1294 OpCodeLength
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
1295 OpCodeOffset
+= OpCodeLength
;
1296 Operand
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
;
1297 Scope
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Scope
;
1299 if (InUnknownScope
) {
1300 if (Operand
== EFI_IFR_END_OP
) {
1303 if (UnknownDepth
== 0) {
1304 InUnknownScope
= FALSE
;
1315 if (IsUnKnownOpCode(Operand
)) {
1317 InUnknownScope
= TRUE
;
1325 // If scope bit set, push onto scope stack
1328 PushScope (Operand
);
1331 if (OpCodeDisabled
) {
1333 // DisableIf Expression is evaluated to be TRUE, try to find its end.
1334 // Here only cares the EFI_IFR_DISABLE_IF and EFI_IFR_END
1336 if (Operand
== EFI_IFR_DISABLE_IF_OP
) {
1338 } else if (Operand
== EFI_IFR_END_OP
) {
1339 Status
= PopScope (&ScopeOpCode
);
1340 if (EFI_ERROR (Status
)) {
1344 if (ScopeOpCode
== EFI_IFR_DISABLE_IF_OP
) {
1345 if (DepthOfDisable
== 0) {
1346 InScopeDisable
= FALSE
;
1347 OpCodeDisabled
= FALSE
;
1356 if (IsExpressionOpCode (Operand
)) {
1357 ExpressionOpCode
= &FormSet
->ExpressionBuffer
[mExpressionOpCodeIndex
];
1358 mExpressionOpCodeIndex
++;
1360 ExpressionOpCode
->Signature
= EXPRESSION_OPCODE_SIGNATURE
;
1361 ExpressionOpCode
->Operand
= Operand
;
1362 Value
= &ExpressionOpCode
->Value
;
1365 case EFI_IFR_EQ_ID_VAL_OP
:
1366 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1368 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1369 CopyMem (&Value
->Value
.u16
, &((EFI_IFR_EQ_ID_VAL
*) OpCodeData
)->Value
, sizeof (UINT16
));
1372 case EFI_IFR_EQ_ID_ID_OP
:
1373 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_ID
*) OpCodeData
)->QuestionId1
, sizeof (EFI_QUESTION_ID
));
1374 CopyMem (&ExpressionOpCode
->QuestionId2
, &((EFI_IFR_EQ_ID_ID
*) OpCodeData
)->QuestionId2
, sizeof (EFI_QUESTION_ID
));
1377 case EFI_IFR_EQ_ID_VAL_LIST_OP
:
1378 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1379 CopyMem (&ExpressionOpCode
->ListLength
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->ListLength
, sizeof (UINT16
));
1380 ExpressionOpCode
->ValueList
= AllocateCopyPool (ExpressionOpCode
->ListLength
* sizeof (UINT16
), &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->ValueList
);
1383 case EFI_IFR_TO_STRING_OP
:
1384 case EFI_IFR_FIND_OP
:
1385 ExpressionOpCode
->Format
= (( EFI_IFR_TO_STRING
*) OpCodeData
)->Format
;
1388 case EFI_IFR_STRING_REF1_OP
:
1389 Value
->Type
= EFI_IFR_TYPE_STRING
;
1390 CopyMem (&Value
->Value
.string
, &(( EFI_IFR_STRING_REF1
*) OpCodeData
)->StringId
, sizeof (EFI_STRING_ID
));
1393 case EFI_IFR_RULE_REF_OP
:
1394 ExpressionOpCode
->RuleId
= (( EFI_IFR_RULE_REF
*) OpCodeData
)->RuleId
;
1397 case EFI_IFR_SPAN_OP
:
1398 ExpressionOpCode
->Flags
= (( EFI_IFR_SPAN
*) OpCodeData
)->Flags
;
1401 case EFI_IFR_THIS_OP
:
1402 ASSERT (ParentStatement
!= NULL
);
1403 ExpressionOpCode
->QuestionId
= ParentStatement
->QuestionId
;
1406 case EFI_IFR_SECURITY_OP
:
1407 CopyMem (&ExpressionOpCode
->Guid
, &((EFI_IFR_SECURITY
*) OpCodeData
)->Permissions
, sizeof (EFI_GUID
));
1410 case EFI_IFR_GET_OP
:
1411 case EFI_IFR_SET_OP
:
1412 CopyMem (&TempVarstoreId
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreId
, sizeof (TempVarstoreId
));
1413 if (TempVarstoreId
!= 0) {
1414 if (FormSet
->StorageListHead
.ForwardLink
!= NULL
) {
1415 Link
= GetFirstNode (&FormSet
->StorageListHead
);
1416 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
1417 VarStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
1418 if (VarStorage
->VarStoreId
== ((EFI_IFR_GET
*) OpCodeData
)->VarStoreId
) {
1419 ExpressionOpCode
->VarStorage
= VarStorage
->BrowserStorage
;
1422 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
1425 if (ExpressionOpCode
->VarStorage
== NULL
) {
1427 // VarStorage is not found.
1429 return EFI_INVALID_PARAMETER
;
1432 ExpressionOpCode
->ValueType
= ((EFI_IFR_GET
*) OpCodeData
)->VarStoreType
;
1433 switch (ExpressionOpCode
->ValueType
) {
1434 case EFI_IFR_TYPE_BOOLEAN
:
1435 case EFI_IFR_TYPE_NUM_SIZE_8
:
1436 ExpressionOpCode
->ValueWidth
= 1;
1439 case EFI_IFR_TYPE_NUM_SIZE_16
:
1440 case EFI_IFR_TYPE_STRING
:
1441 ExpressionOpCode
->ValueWidth
= 2;
1444 case EFI_IFR_TYPE_NUM_SIZE_32
:
1445 ExpressionOpCode
->ValueWidth
= 4;
1448 case EFI_IFR_TYPE_NUM_SIZE_64
:
1449 ExpressionOpCode
->ValueWidth
= 8;
1452 case EFI_IFR_TYPE_DATE
:
1453 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_DATE
);
1456 case EFI_IFR_TYPE_TIME
:
1457 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_TIME
);
1460 case EFI_IFR_TYPE_REF
:
1461 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_REF
);
1464 case EFI_IFR_TYPE_OTHER
:
1465 case EFI_IFR_TYPE_UNDEFINED
:
1466 case EFI_IFR_TYPE_ACTION
:
1467 case EFI_IFR_TYPE_BUFFER
:
1470 // Invalid value type for Get/Set opcode.
1472 return EFI_INVALID_PARAMETER
;
1474 CopyMem (&ExpressionOpCode
->VarStoreInfo
.VarName
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreInfo
.VarName
, sizeof (EFI_STRING_ID
));
1475 CopyMem (&ExpressionOpCode
->VarStoreInfo
.VarOffset
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreInfo
.VarOffset
, sizeof (UINT16
));
1476 if ((ExpressionOpCode
->VarStorage
!= NULL
) &&
1477 (ExpressionOpCode
->VarStorage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
||
1478 ExpressionOpCode
->VarStorage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
)) {
1479 ExpressionOpCode
->ValueName
= GetToken (ExpressionOpCode
->VarStoreInfo
.VarName
, FormSet
->HiiHandle
);
1480 if (ExpressionOpCode
->ValueName
== NULL
) {
1482 // String ID is invalid.
1484 return EFI_INVALID_PARAMETER
;
1489 case EFI_IFR_QUESTION_REF1_OP
:
1490 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1493 case EFI_IFR_QUESTION_REF3_OP
:
1494 if (OpCodeLength
>= sizeof (EFI_IFR_QUESTION_REF3_2
)) {
1495 CopyMem (&ExpressionOpCode
->DevicePath
, &(( EFI_IFR_QUESTION_REF3_2
*) OpCodeData
)->DevicePath
, sizeof (EFI_STRING_ID
));
1497 if (OpCodeLength
>= sizeof (EFI_IFR_QUESTION_REF3_3
)) {
1498 CopyMem (&ExpressionOpCode
->Guid
, &(( EFI_IFR_QUESTION_REF3_3
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
1506 case EFI_IFR_TRUE_OP
:
1507 Value
->Type
= EFI_IFR_TYPE_BOOLEAN
;
1508 Value
->Value
.b
= TRUE
;
1511 case EFI_IFR_FALSE_OP
:
1512 Value
->Type
= EFI_IFR_TYPE_BOOLEAN
;
1513 Value
->Value
.b
= FALSE
;
1516 case EFI_IFR_ONE_OP
:
1517 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1518 Value
->Value
.u8
= 1;
1521 case EFI_IFR_ZERO_OP
:
1522 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1523 Value
->Value
.u8
= 0;
1526 case EFI_IFR_ONES_OP
:
1527 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1528 Value
->Value
.u64
= 0xffffffffffffffffULL
;
1531 case EFI_IFR_UINT8_OP
:
1532 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1533 Value
->Value
.u8
= (( EFI_IFR_UINT8
*) OpCodeData
)->Value
;
1536 case EFI_IFR_UINT16_OP
:
1537 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1538 CopyMem (&Value
->Value
.u16
, &(( EFI_IFR_UINT16
*) OpCodeData
)->Value
, sizeof (UINT16
));
1541 case EFI_IFR_UINT32_OP
:
1542 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_32
;
1543 CopyMem (&Value
->Value
.u32
, &(( EFI_IFR_UINT32
*) OpCodeData
)->Value
, sizeof (UINT32
));
1546 case EFI_IFR_UINT64_OP
:
1547 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1548 CopyMem (&Value
->Value
.u64
, &(( EFI_IFR_UINT64
*) OpCodeData
)->Value
, sizeof (UINT64
));
1551 case EFI_IFR_UNDEFINED_OP
:
1552 Value
->Type
= EFI_IFR_TYPE_UNDEFINED
;
1555 case EFI_IFR_VERSION_OP
:
1556 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1557 Value
->Value
.u16
= EFI_IFR_SPECIFICATION_VERSION
;
1564 // Create sub expression nested in MAP opcode
1566 if (CurrentExpression
== NULL
&& MapScopeDepth
> 0) {
1567 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
1568 ASSERT (MapExpressionList
!= NULL
);
1569 InsertTailList (MapExpressionList
, &CurrentExpression
->Link
);
1571 SingleOpCodeExpression
= TRUE
;
1574 ASSERT (CurrentExpression
!= NULL
);
1575 InsertTailList (&CurrentExpression
->OpCodeListHead
, &ExpressionOpCode
->Link
);
1576 if (Operand
== EFI_IFR_MAP_OP
) {
1578 // Store current Map Expression List.
1580 if (MapExpressionList
!= NULL
) {
1581 PushMapExpressionList (MapExpressionList
);
1584 // Initialize new Map Expression List.
1586 MapExpressionList
= &ExpressionOpCode
->MapExpressionList
;
1587 InitializeListHead (MapExpressionList
);
1589 // Store current expression.
1591 PushCurrentExpression (CurrentExpression
);
1592 CurrentExpression
= NULL
;
1594 } else if (SingleOpCodeExpression
) {
1596 // There are two cases to indicate the end of an Expression:
1597 // for single OpCode expression: one Expression OpCode
1598 // for expression consists of more than one OpCode: EFI_IFR_END
1600 SingleOpCodeExpression
= FALSE
;
1602 if (InScopeDisable
&& CurrentForm
== NULL
) {
1604 // This is DisableIf expression for Form, it should be a constant expression
1606 Status
= EvaluateExpression (FormSet
, CurrentForm
, CurrentExpression
);
1607 if (EFI_ERROR (Status
)) {
1611 OpCodeDisabled
= IsTrue(&CurrentExpression
->Result
);
1614 CurrentExpression
= NULL
;
1625 case EFI_IFR_FORM_SET_OP
:
1627 // Check the formset GUID
1629 if (CompareMem (&FormSet
->Guid
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
)) != 0) {
1630 return EFI_INVALID_PARAMETER
;
1633 CopyMem (&FormSet
->FormSetTitle
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->FormSetTitle
, sizeof (EFI_STRING_ID
));
1634 CopyMem (&FormSet
->Help
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->Help
, sizeof (EFI_STRING_ID
));
1636 if (OpCodeLength
> OFFSET_OF (EFI_IFR_FORM_SET
, Flags
)) {
1638 // The formset OpCode contains ClassGuid
1640 FormSet
->NumberOfClassGuid
= (UINT8
) (((EFI_IFR_FORM_SET
*) OpCodeData
)->Flags
& 0x3);
1641 CopyMem (FormSet
->ClassGuid
, OpCodeData
+ sizeof (EFI_IFR_FORM_SET
), FormSet
->NumberOfClassGuid
* sizeof (EFI_GUID
));
1645 case EFI_IFR_FORM_OP
:
1647 // Create a new Form for this FormSet
1649 CurrentForm
= AllocateZeroPool (sizeof (FORM_BROWSER_FORM
));
1650 ASSERT (CurrentForm
!= NULL
);
1651 CurrentForm
->Signature
= FORM_BROWSER_FORM_SIGNATURE
;
1652 InitializeListHead (&CurrentForm
->ExpressionListHead
);
1653 InitializeListHead (&CurrentForm
->StatementListHead
);
1654 InitializeListHead (&CurrentForm
->ConfigRequestHead
);
1655 InitializeListHead (&CurrentForm
->FormViewListHead
);
1657 CurrentForm
->FormType
= STANDARD_MAP_FORM_TYPE
;
1658 CopyMem (&CurrentForm
->FormId
, &((EFI_IFR_FORM
*) OpCodeData
)->FormId
, sizeof (UINT16
));
1659 CopyMem (&CurrentForm
->FormTitle
, &((EFI_IFR_FORM
*) OpCodeData
)->FormTitle
, sizeof (EFI_STRING_ID
));
1661 ConditionalExprCount
= GetConditionalExpressionCount(ExpressForm
);
1662 if ( ConditionalExprCount
> 0) {
1664 // Form is inside of suppressif
1666 CurrentForm
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
1667 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
1668 ASSERT (CurrentForm
->SuppressExpression
!= NULL
);
1669 CurrentForm
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
1670 CurrentForm
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
1671 CopyMem (CurrentForm
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressForm
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
1676 // Enter scope of a Form, suppressif will be used for Question or Option
1678 SuppressForQuestion
= TRUE
;
1682 // Insert into Form list of this FormSet
1684 InsertTailList (&FormSet
->FormListHead
, &CurrentForm
->Link
);
1687 case EFI_IFR_FORM_MAP_OP
:
1689 // Create a new Form for this FormSet
1691 CurrentForm
= AllocateZeroPool (sizeof (FORM_BROWSER_FORM
));
1692 ASSERT (CurrentForm
!= NULL
);
1693 CurrentForm
->Signature
= FORM_BROWSER_FORM_SIGNATURE
;
1694 InitializeListHead (&CurrentForm
->ExpressionListHead
);
1695 InitializeListHead (&CurrentForm
->StatementListHead
);
1696 InitializeListHead (&CurrentForm
->ConfigRequestHead
);
1697 InitializeListHead (&CurrentForm
->FormViewListHead
);
1699 CopyMem (&CurrentForm
->FormId
, &((EFI_IFR_FORM
*) OpCodeData
)->FormId
, sizeof (UINT16
));
1701 MapMethod
= (EFI_IFR_FORM_MAP_METHOD
*) (OpCodeData
+ sizeof (EFI_IFR_FORM_MAP
));
1703 // FormMap Form must contain at least one Map Method.
1705 if (((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
< ((UINTN
) (UINT8
*) (MapMethod
+ 1) - (UINTN
) OpCodeData
)) {
1706 return EFI_INVALID_PARAMETER
;
1709 // Try to find the standard form map method.
1711 while (((UINTN
) (UINT8
*) MapMethod
- (UINTN
) OpCodeData
) < ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
) {
1712 if (CompareGuid ((EFI_GUID
*) (VOID
*) &MapMethod
->MethodIdentifier
, &gEfiHiiStandardFormGuid
)) {
1713 CopyMem (&CurrentForm
->FormTitle
, &MapMethod
->MethodTitle
, sizeof (EFI_STRING_ID
));
1714 CurrentForm
->FormType
= STANDARD_MAP_FORM_TYPE
;
1720 // If the standard form map method is not found, the first map method title will be used.
1722 if (CurrentForm
->FormTitle
== 0) {
1723 MapMethod
= (EFI_IFR_FORM_MAP_METHOD
*) (OpCodeData
+ sizeof (EFI_IFR_FORM_MAP
));
1724 CopyMem (&CurrentForm
->FormTitle
, &MapMethod
->MethodTitle
, sizeof (EFI_STRING_ID
));
1727 ConditionalExprCount
= GetConditionalExpressionCount(ExpressForm
);
1728 if ( ConditionalExprCount
> 0) {
1730 // Form is inside of suppressif
1732 CurrentForm
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
1733 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
1734 ASSERT (CurrentForm
->SuppressExpression
!= NULL
);
1735 CurrentForm
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
1736 CurrentForm
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
1737 CopyMem (CurrentForm
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressForm
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
1742 // Enter scope of a Form, suppressif will be used for Question or Option
1744 SuppressForQuestion
= TRUE
;
1748 // Insert into Form list of this FormSet
1750 InsertTailList (&FormSet
->FormListHead
, &CurrentForm
->Link
);
1756 case EFI_IFR_VARSTORE_OP
:
1758 // Create a buffer Storage for this FormSet
1760 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_BUFFER
, OpCodeData
);
1761 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1764 case EFI_IFR_VARSTORE_NAME_VALUE_OP
:
1766 // Create a name/value Storage for this FormSet
1768 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_NAME_VALUE
, OpCodeData
);
1769 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE_NAME_VALUE
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1772 case EFI_IFR_VARSTORE_EFI_OP
:
1774 // Create a EFI variable Storage for this FormSet
1776 if (OpCodeLength
< sizeof (EFI_IFR_VARSTORE_EFI
)) {
1778 // Create efi varstore with format follow UEFI spec before 2.3.1.
1780 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_EFI_VARIABLE
, OpCodeData
);
1783 // Create efi varstore with format follow UEFI spec 2.3.1 and later.
1785 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
, OpCodeData
);
1787 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1793 case EFI_IFR_DEFAULTSTORE_OP
:
1794 DefaultStore
= AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE
));
1795 ASSERT (DefaultStore
!= NULL
);
1796 DefaultStore
->Signature
= FORMSET_DEFAULTSTORE_SIGNATURE
;
1798 CopyMem (&DefaultStore
->DefaultId
, &((EFI_IFR_DEFAULTSTORE
*) OpCodeData
)->DefaultId
, sizeof (UINT16
));
1799 CopyMem (&DefaultStore
->DefaultName
, &((EFI_IFR_DEFAULTSTORE
*) OpCodeData
)->DefaultName
, sizeof (EFI_STRING_ID
));
1802 // Insert to DefaultStore list of this Formset
1804 InsertTailList (&FormSet
->DefaultStoreListHead
, &DefaultStore
->Link
);
1810 case EFI_IFR_SUBTITLE_OP
:
1811 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1812 ASSERT (CurrentStatement
!= NULL
);
1814 CurrentStatement
->Flags
= ((EFI_IFR_SUBTITLE
*) OpCodeData
)->Flags
;
1815 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1818 case EFI_IFR_TEXT_OP
:
1819 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1820 ASSERT (CurrentStatement
!= NULL
);
1821 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1822 CopyMem (&CurrentStatement
->TextTwo
, &((EFI_IFR_TEXT
*) OpCodeData
)->TextTwo
, sizeof (EFI_STRING_ID
));
1825 case EFI_IFR_RESET_BUTTON_OP
:
1826 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1827 ASSERT (CurrentStatement
!= NULL
);
1828 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1829 CopyMem (&CurrentStatement
->DefaultId
, &((EFI_IFR_RESET_BUTTON
*) OpCodeData
)->DefaultId
, sizeof (EFI_DEFAULT_ID
));
1835 case EFI_IFR_ACTION_OP
:
1836 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1837 ASSERT (CurrentStatement
!= NULL
);
1838 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_ACTION
;
1840 if (OpCodeLength
== sizeof (EFI_IFR_ACTION_1
)) {
1842 // No QuestionConfig present, so no configuration string will be processed
1844 CurrentStatement
->QuestionConfig
= 0;
1846 CopyMem (&CurrentStatement
->QuestionConfig
, &((EFI_IFR_ACTION
*) OpCodeData
)->QuestionConfig
, sizeof (EFI_STRING_ID
));
1850 case EFI_IFR_REF_OP
:
1851 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1852 ASSERT (CurrentStatement
!= NULL
);
1853 Value
= &CurrentStatement
->HiiValue
;
1854 Value
->Type
= EFI_IFR_TYPE_REF
;
1855 if (OpCodeLength
>= sizeof (EFI_IFR_REF
)) {
1856 CopyMem (&Value
->Value
.ref
.FormId
, &((EFI_IFR_REF
*) OpCodeData
)->FormId
, sizeof (EFI_FORM_ID
));
1858 if (OpCodeLength
>= sizeof (EFI_IFR_REF2
)) {
1859 CopyMem (&Value
->Value
.ref
.QuestionId
, &((EFI_IFR_REF2
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1861 if (OpCodeLength
>= sizeof (EFI_IFR_REF3
)) {
1862 CopyMem (&Value
->Value
.ref
.FormSetGuid
, &((EFI_IFR_REF3
*) OpCodeData
)->FormSetId
, sizeof (EFI_GUID
));
1864 if (OpCodeLength
>= sizeof (EFI_IFR_REF4
)) {
1865 CopyMem (&Value
->Value
.ref
.DevicePath
, &((EFI_IFR_REF4
*) OpCodeData
)->DevicePath
, sizeof (EFI_STRING_ID
));
1870 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_REF
);
1871 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1874 case EFI_IFR_ONE_OF_OP
:
1875 case EFI_IFR_NUMERIC_OP
:
1876 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1877 ASSERT(CurrentStatement
!= NULL
);
1879 CurrentStatement
->Flags
= ((EFI_IFR_ONE_OF
*) OpCodeData
)->Flags
;
1880 Value
= &CurrentStatement
->HiiValue
;
1882 switch (CurrentStatement
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1883 case EFI_IFR_NUMERIC_SIZE_1
:
1884 CurrentStatement
->Minimum
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.MinValue
;
1885 CurrentStatement
->Maximum
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.MaxValue
;
1886 CurrentStatement
->Step
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.Step
;
1887 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT8
);
1888 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1891 case EFI_IFR_NUMERIC_SIZE_2
:
1892 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.MinValue
, sizeof (UINT16
));
1893 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.MaxValue
, sizeof (UINT16
));
1894 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.Step
, sizeof (UINT16
));
1895 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT16
);
1896 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1899 case EFI_IFR_NUMERIC_SIZE_4
:
1900 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MinValue
, sizeof (UINT32
));
1901 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MaxValue
, sizeof (UINT32
));
1902 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.Step
, sizeof (UINT32
));
1903 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT32
);
1904 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_32
;
1907 case EFI_IFR_NUMERIC_SIZE_8
:
1908 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.MinValue
, sizeof (UINT64
));
1909 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.MaxValue
, sizeof (UINT64
));
1910 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.Step
, sizeof (UINT64
));
1911 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT64
);
1912 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1919 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1921 if ((Operand
== EFI_IFR_ONE_OF_OP
) && Scope
!= 0) {
1922 SuppressForOption
= TRUE
;
1926 case EFI_IFR_ORDERED_LIST_OP
:
1927 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1928 ASSERT(CurrentStatement
!= NULL
);
1930 CurrentStatement
->Flags
= ((EFI_IFR_ORDERED_LIST
*) OpCodeData
)->Flags
;
1931 CurrentStatement
->MaxContainers
= ((EFI_IFR_ORDERED_LIST
*) OpCodeData
)->MaxContainers
;
1933 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_BUFFER
;
1934 CurrentStatement
->BufferValue
= NULL
;
1937 SuppressForOption
= TRUE
;
1941 case EFI_IFR_CHECKBOX_OP
:
1942 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1943 ASSERT(CurrentStatement
!= NULL
);
1945 CurrentStatement
->Flags
= ((EFI_IFR_CHECKBOX
*) OpCodeData
)->Flags
;
1946 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (BOOLEAN
);
1947 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_BOOLEAN
;
1949 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1953 case EFI_IFR_STRING_OP
:
1954 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1955 ASSERT (CurrentStatement
!= NULL
);
1957 // MinSize is the minimum number of characters that can be accepted for this opcode,
1958 // MaxSize is the maximum number of characters that can be accepted for this opcode.
1959 // The characters are stored as Unicode, so the storage width should multiply 2.
1961 CurrentStatement
->Minimum
= ((EFI_IFR_STRING
*) OpCodeData
)->MinSize
;
1962 CurrentStatement
->Maximum
= ((EFI_IFR_STRING
*) OpCodeData
)->MaxSize
;
1963 CurrentStatement
->StorageWidth
= (UINT16
)((UINTN
) CurrentStatement
->Maximum
* sizeof (CHAR16
));
1964 CurrentStatement
->Flags
= ((EFI_IFR_STRING
*) OpCodeData
)->Flags
;
1966 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_STRING
;
1967 CurrentStatement
->BufferValue
= AllocateZeroPool (CurrentStatement
->StorageWidth
+ sizeof (CHAR16
));
1968 CurrentStatement
->HiiValue
.Value
.string
= NewString ((CHAR16
*) CurrentStatement
->BufferValue
, FormSet
->HiiHandle
);
1970 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1973 case EFI_IFR_PASSWORD_OP
:
1974 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1975 ASSERT (CurrentStatement
!= NULL
);
1977 // MinSize is the minimum number of characters that can be accepted for this opcode,
1978 // MaxSize is the maximum number of characters that can be accepted for this opcode.
1979 // The characters are stored as Unicode, so the storage width should multiply 2.
1981 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_PASSWORD
*) OpCodeData
)->MinSize
, sizeof (UINT16
));
1982 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_PASSWORD
*) OpCodeData
)->MaxSize
, sizeof (UINT16
));
1983 CurrentStatement
->StorageWidth
= (UINT16
)((UINTN
) CurrentStatement
->Maximum
* sizeof (CHAR16
));
1985 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_STRING
;
1986 CurrentStatement
->BufferValue
= AllocateZeroPool ((CurrentStatement
->StorageWidth
+ sizeof (CHAR16
)));
1987 CurrentStatement
->HiiValue
.Value
.string
= NewString ((CHAR16
*) CurrentStatement
->BufferValue
, FormSet
->HiiHandle
);
1989 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1992 case EFI_IFR_DATE_OP
:
1993 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1994 ASSERT(CurrentStatement
!= NULL
);
1996 CurrentStatement
->Flags
= ((EFI_IFR_DATE
*) OpCodeData
)->Flags
;
1997 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_DATE
;
1999 if ((CurrentStatement
->Flags
& EFI_QF_DATE_STORAGE
) == QF_DATE_STORAGE_NORMAL
) {
2000 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_DATE
);
2002 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2005 // Don't assign storage for RTC type of date/time
2007 CurrentStatement
->Storage
= NULL
;
2008 CurrentStatement
->StorageWidth
= 0;
2012 case EFI_IFR_TIME_OP
:
2013 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2014 ASSERT(CurrentStatement
!= NULL
);
2016 CurrentStatement
->Flags
= ((EFI_IFR_TIME
*) OpCodeData
)->Flags
;
2017 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_TIME
;
2019 if ((CurrentStatement
->Flags
& QF_TIME_STORAGE
) == QF_TIME_STORAGE_NORMAL
) {
2020 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_TIME
);
2022 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2025 // Don't assign storage for RTC type of date/time
2027 CurrentStatement
->Storage
= NULL
;
2028 CurrentStatement
->StorageWidth
= 0;
2035 case EFI_IFR_DEFAULT_OP
:
2037 // EFI_IFR_DEFAULT appear in scope of a Question,
2038 // It creates a default value for the current question.
2039 // A Question may have more than one Default value which have different default types.
2041 CurrentDefault
= AllocateZeroPool (sizeof (QUESTION_DEFAULT
));
2042 ASSERT (CurrentDefault
!= NULL
);
2043 CurrentDefault
->Signature
= QUESTION_DEFAULT_SIGNATURE
;
2045 CurrentDefault
->Value
.Type
= ((EFI_IFR_DEFAULT
*) OpCodeData
)->Type
;
2046 CopyMem (&CurrentDefault
->DefaultId
, &((EFI_IFR_DEFAULT
*) OpCodeData
)->DefaultId
, sizeof (UINT16
));
2047 if (OpCodeLength
> OFFSET_OF (EFI_IFR_DEFAULT
, Value
)) {
2048 CopyMem (&CurrentDefault
->Value
.Value
, &((EFI_IFR_DEFAULT
*) OpCodeData
)->Value
, OpCodeLength
- OFFSET_OF (EFI_IFR_DEFAULT
, Value
));
2049 ExtendValueToU64 (&CurrentDefault
->Value
);
2053 // Insert to Default Value list of current Question
2055 InsertTailList (&ParentStatement
->DefaultListHead
, &CurrentDefault
->Link
);
2058 InScopeDefault
= TRUE
;
2065 case EFI_IFR_ONE_OF_OPTION_OP
:
2067 // EFI_IFR_ONE_OF_OPTION appear in scope of a Question.
2068 // It create a selection for use in current Question.
2070 CurrentOption
= AllocateZeroPool (sizeof (QUESTION_OPTION
));
2071 ASSERT (CurrentOption
!= NULL
);
2072 CurrentOption
->Signature
= QUESTION_OPTION_SIGNATURE
;
2073 CurrentOption
->OpCode
= (EFI_IFR_ONE_OF_OPTION
*) OpCodeData
;
2075 CurrentOption
->Flags
= ((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Flags
;
2076 CurrentOption
->Value
.Type
= ((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Type
;
2077 CopyMem (&CurrentOption
->Text
, &((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Option
, sizeof (EFI_STRING_ID
));
2078 CopyMem (&CurrentOption
->Value
.Value
, &((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Value
, OpCodeLength
- OFFSET_OF (EFI_IFR_ONE_OF_OPTION
, Value
));
2079 ExtendValueToU64 (&CurrentOption
->Value
);
2081 ConditionalExprCount
= GetConditionalExpressionCount(ExpressOption
);
2082 if ( ConditionalExprCount
> 0) {
2084 // Form is inside of suppressif
2086 CurrentOption
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
2087 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
2088 ASSERT (CurrentOption
->SuppressExpression
!= NULL
);
2089 CurrentOption
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
2090 CurrentOption
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
2091 CopyMem (CurrentOption
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressOption
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
2094 ASSERT (ParentStatement
!= NULL
);
2096 // Insert to Option list of current Question
2098 InsertTailList (&ParentStatement
->OptionListHead
, &CurrentOption
->Link
);
2100 // Now we know the Storage width of nested Ordered List
2102 if ((ParentStatement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) && (ParentStatement
->BufferValue
== NULL
)) {
2104 switch (CurrentOption
->Value
.Type
) {
2105 case EFI_IFR_TYPE_NUM_SIZE_8
:
2109 case EFI_IFR_TYPE_NUM_SIZE_16
:
2113 case EFI_IFR_TYPE_NUM_SIZE_32
:
2117 case EFI_IFR_TYPE_NUM_SIZE_64
:
2123 // Invalid type for Ordered List
2128 ParentStatement
->StorageWidth
= (UINT16
) (ParentStatement
->MaxContainers
* Width
);
2129 ParentStatement
->BufferValue
= AllocateZeroPool (ParentStatement
->StorageWidth
);
2130 ParentStatement
->ValueType
= CurrentOption
->Value
.Type
;
2131 if (ParentStatement
->HiiValue
.Type
== EFI_IFR_TYPE_BUFFER
) {
2132 ParentStatement
->HiiValue
.Buffer
= ParentStatement
->BufferValue
;
2133 ParentStatement
->HiiValue
.BufferLen
= ParentStatement
->StorageWidth
;
2136 InitializeRequestElement (FormSet
, ParentStatement
, CurrentForm
);
2143 case EFI_IFR_NO_SUBMIT_IF_OP
:
2144 case EFI_IFR_INCONSISTENT_IF_OP
:
2146 // Create an Expression node
2148 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2149 CopyMem (&CurrentExpression
->Error
, &((EFI_IFR_INCONSISTENT_IF
*) OpCodeData
)->Error
, sizeof (EFI_STRING_ID
));
2151 if (Operand
== EFI_IFR_NO_SUBMIT_IF_OP
) {
2152 CurrentExpression
->Type
= EFI_HII_EXPRESSION_NO_SUBMIT_IF
;
2153 InsertTailList (&ParentStatement
->NoSubmitListHead
, &CurrentExpression
->Link
);
2155 CurrentExpression
->Type
= EFI_HII_EXPRESSION_INCONSISTENT_IF
;
2156 InsertTailList (&ParentStatement
->InconsistentListHead
, &CurrentExpression
->Link
);
2160 // Take a look at next OpCode to see whether current expression consists
2163 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2164 SingleOpCodeExpression
= TRUE
;
2168 case EFI_IFR_WARNING_IF_OP
:
2170 // Create an Expression node
2172 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2173 CopyMem (&CurrentExpression
->Error
, &((EFI_IFR_WARNING_IF
*) OpCodeData
)->Warning
, sizeof (EFI_STRING_ID
));
2174 CurrentExpression
->TimeOut
= ((EFI_IFR_WARNING_IF
*) OpCodeData
)->TimeOut
;
2175 CurrentExpression
->Type
= EFI_HII_EXPRESSION_WARNING_IF
;
2176 InsertTailList (&ParentStatement
->WarningListHead
, &CurrentExpression
->Link
);
2179 // Take a look at next OpCode to see whether current expression consists
2182 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2183 SingleOpCodeExpression
= TRUE
;
2187 case EFI_IFR_SUPPRESS_IF_OP
:
2189 // Question and Option will appear in scope of this OpCode
2191 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2192 CurrentExpression
->Type
= EFI_HII_EXPRESSION_SUPPRESS_IF
;
2194 if (CurrentForm
== NULL
) {
2195 InsertTailList (&FormSet
->ExpressionListHead
, &CurrentExpression
->Link
);
2197 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2200 if (SuppressForOption
) {
2201 PushConditionalExpression(CurrentExpression
, ExpressOption
);
2202 } else if (SuppressForQuestion
) {
2203 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2205 PushConditionalExpression(CurrentExpression
, ExpressForm
);
2209 // Take a look at next OpCode to see whether current expression consists
2212 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2213 SingleOpCodeExpression
= TRUE
;
2217 case EFI_IFR_GRAY_OUT_IF_OP
:
2219 // Questions will appear in scope of this OpCode
2221 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2222 CurrentExpression
->Type
= EFI_HII_EXPRESSION_GRAY_OUT_IF
;
2223 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2224 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2227 // Take a look at next OpCode to see whether current expression consists
2230 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2231 SingleOpCodeExpression
= TRUE
;
2235 case EFI_IFR_DISABLE_IF_OP
:
2237 // The DisableIf expression should only rely on constant, so it could be
2238 // evaluated at initialization and it will not be queued
2240 CurrentExpression
= AllocateZeroPool (sizeof (FORM_EXPRESSION
));
2241 ASSERT (CurrentExpression
!= NULL
);
2242 CurrentExpression
->Signature
= FORM_EXPRESSION_SIGNATURE
;
2243 CurrentExpression
->Type
= EFI_HII_EXPRESSION_DISABLE_IF
;
2244 InitializeListHead (&CurrentExpression
->OpCodeListHead
);
2246 if (CurrentForm
!= NULL
) {
2248 // This is DisableIf for Question, enqueue it to Form expression list
2250 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2251 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2254 OpCodeDisabled
= FALSE
;
2255 InScopeDisable
= TRUE
;
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
;
2268 case EFI_IFR_VALUE_OP
:
2269 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2270 CurrentExpression
->Type
= EFI_HII_EXPRESSION_VALUE
;
2271 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2273 if (InScopeDefault
) {
2275 // Used for default (EFI_IFR_DEFAULT)
2277 CurrentDefault
->ValueExpression
= CurrentExpression
;
2280 // If used for a question, then the question will be read-only
2283 // Make sure CurrentStatement is not NULL.
2284 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2285 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2287 ASSERT (ParentStatement
!= NULL
);
2288 ParentStatement
->ValueExpression
= CurrentExpression
;
2292 // Take a look at next OpCode to see whether current expression consists
2295 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2296 SingleOpCodeExpression
= TRUE
;
2300 case EFI_IFR_RULE_OP
:
2301 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2302 CurrentExpression
->Type
= EFI_HII_EXPRESSION_RULE
;
2304 CurrentExpression
->RuleId
= ((EFI_IFR_RULE
*) OpCodeData
)->RuleId
;
2305 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2308 // Take a look at next OpCode to see whether current expression consists
2311 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2312 SingleOpCodeExpression
= TRUE
;
2316 case EFI_IFR_READ_OP
:
2317 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2318 CurrentExpression
->Type
= EFI_HII_EXPRESSION_READ
;
2319 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2322 // Make sure CurrentStatement is not NULL.
2323 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2324 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2326 ASSERT (ParentStatement
!= NULL
);
2327 ParentStatement
->ReadExpression
= CurrentExpression
;
2330 // Take a look at next OpCode to see whether current expression consists
2333 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2334 SingleOpCodeExpression
= TRUE
;
2338 case EFI_IFR_WRITE_OP
:
2339 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2340 CurrentExpression
->Type
= EFI_HII_EXPRESSION_WRITE
;
2341 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2344 // Make sure CurrentStatement is not NULL.
2345 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2346 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2348 ASSERT (ParentStatement
!= NULL
);
2349 ParentStatement
->WriteExpression
= CurrentExpression
;
2352 // Take a look at next OpCode to see whether current expression consists
2355 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2356 SingleOpCodeExpression
= TRUE
;
2363 case EFI_IFR_IMAGE_OP
:
2365 // Get ScopeOpcode from top of stack
2367 PopScope (&ScopeOpCode
);
2368 PushScope (ScopeOpCode
);
2370 switch (ScopeOpCode
) {
2371 case EFI_IFR_FORM_SET_OP
:
2372 ImageId
= &FormSet
->ImageId
;
2375 case EFI_IFR_FORM_OP
:
2376 case EFI_IFR_FORM_MAP_OP
:
2377 ASSERT (CurrentForm
!= NULL
);
2378 ImageId
= &CurrentForm
->ImageId
;
2381 case EFI_IFR_ONE_OF_OPTION_OP
:
2382 ASSERT (CurrentOption
!= NULL
);
2383 ImageId
= &CurrentOption
->ImageId
;
2388 // Make sure CurrentStatement is not NULL.
2389 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2390 // file is wrongly generated by tools such as VFR Compiler.
2392 ASSERT (ParentStatement
!= NULL
);
2393 ImageId
= &ParentStatement
->ImageId
;
2397 ASSERT (ImageId
!= NULL
);
2398 CopyMem (ImageId
, &((EFI_IFR_IMAGE
*) OpCodeData
)->Id
, sizeof (EFI_IMAGE_ID
));
2404 case EFI_IFR_REFRESH_OP
:
2405 ASSERT (ParentStatement
!= NULL
);
2406 ParentStatement
->RefreshInterval
= ((EFI_IFR_REFRESH
*) OpCodeData
)->RefreshInterval
;
2412 case EFI_IFR_REFRESH_ID_OP
:
2413 ASSERT (ParentStatement
!= NULL
);
2414 CopyMem (&ParentStatement
->RefreshGuid
, &((EFI_IFR_REFRESH_ID
*) OpCodeData
)->RefreshEventGroupId
, sizeof (EFI_GUID
));
2420 case EFI_IFR_MODAL_TAG_OP
:
2421 ASSERT (CurrentForm
!= NULL
);
2422 CurrentForm
->ModalForm
= TRUE
;
2426 // Lock tag, used by form and statement.
2428 case EFI_IFR_LOCKED_OP
:
2430 // Get ScopeOpcode from top of stack
2432 PopScope (&ScopeOpCode
);
2433 PushScope (ScopeOpCode
);
2434 switch (ScopeOpCode
) {
2435 case EFI_IFR_FORM_OP
:
2436 case EFI_IFR_FORM_MAP_OP
:
2437 ASSERT (CurrentForm
!= NULL
);
2438 CurrentForm
->Locked
= TRUE
;
2442 ASSERT (ParentStatement
!= NULL
);
2443 ParentStatement
->Locked
= TRUE
;
2450 case EFI_IFR_GUID_OP
:
2451 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
2457 case EFI_IFR_END_OP
:
2458 Status
= PopScope (&ScopeOpCode
);
2459 if (EFI_ERROR (Status
)) {
2465 // Parent statement end tag found, update ParentStatement info.
2467 if (IsStatementOpCode(ScopeOpCode
) && (ParentStatement
!= NULL
) && (ParentStatement
->Operand
== ScopeOpCode
)) {
2468 ParentStatement
= ParentStatement
->ParentStatement
;
2471 switch (ScopeOpCode
) {
2472 case EFI_IFR_FORM_SET_OP
:
2474 // End of FormSet, update FormSet IFR binary length
2475 // to stop parsing substantial OpCodes
2477 FormSet
->IfrBinaryLength
= OpCodeOffset
;
2480 case EFI_IFR_FORM_OP
:
2481 case EFI_IFR_FORM_MAP_OP
:
2486 SuppressForQuestion
= FALSE
;
2489 case EFI_IFR_ONE_OF_OPTION_OP
:
2493 CurrentOption
= NULL
;
2496 case EFI_IFR_NO_SUBMIT_IF_OP
:
2497 case EFI_IFR_INCONSISTENT_IF_OP
:
2498 case EFI_IFR_WARNING_IF_OP
:
2500 // Ignore end of EFI_IFR_NO_SUBMIT_IF and EFI_IFR_INCONSISTENT_IF
2504 case EFI_IFR_SUPPRESS_IF_OP
:
2505 if (SuppressForOption
) {
2506 PopConditionalExpression(ExpressOption
);
2507 } else if (SuppressForQuestion
) {
2508 PopConditionalExpression(ExpressStatement
);
2510 PopConditionalExpression(ExpressForm
);
2514 case EFI_IFR_GRAY_OUT_IF_OP
:
2515 PopConditionalExpression(ExpressStatement
);
2518 case EFI_IFR_DISABLE_IF_OP
:
2519 if (CurrentForm
!= NULL
) {
2520 PopConditionalExpression(ExpressStatement
);
2522 InScopeDisable
= FALSE
;
2523 OpCodeDisabled
= FALSE
;
2526 case EFI_IFR_ONE_OF_OP
:
2527 case EFI_IFR_ORDERED_LIST_OP
:
2528 SuppressForOption
= FALSE
;
2531 case EFI_IFR_DEFAULT_OP
:
2532 InScopeDefault
= FALSE
;
2535 case EFI_IFR_MAP_OP
:
2537 // Get current Map Expression List.
2539 Status
= PopMapExpressionList ((VOID
**) &MapExpressionList
);
2540 if (Status
== EFI_ACCESS_DENIED
) {
2541 MapExpressionList
= NULL
;
2544 // Get current expression.
2546 Status
= PopCurrentExpression ((VOID
**) &CurrentExpression
);
2547 ASSERT_EFI_ERROR (Status
);
2548 ASSERT (MapScopeDepth
> 0);
2553 if (IsExpressionOpCode (ScopeOpCode
)) {
2554 if (InScopeDisable
&& CurrentForm
== NULL
) {
2556 // This is DisableIf expression for Form, it should be a constant expression
2558 ASSERT (CurrentExpression
!= NULL
);
2559 Status
= EvaluateExpression (FormSet
, CurrentForm
, CurrentExpression
);
2560 if (EFI_ERROR (Status
)) {
2564 OpCodeDisabled
= IsTrue (&CurrentExpression
->Result
);
2567 // DisableIf Expression is only used once and not queued, free it
2569 DestroyExpression (CurrentExpression
);
2573 // End of current Expression
2575 CurrentExpression
= NULL
;
2585 if (IsStatementOpCode(Operand
)) {
2586 CurrentStatement
->ParentStatement
= ParentStatement
;
2589 // Scope != 0, other statements or options may nest in this statement.
2590 // Update the ParentStatement info.
2592 ParentStatement
= CurrentStatement
;