2 Parser for IFR binary encoding.
4 Copyright (c) 2007 - 2015, 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 FORMSET_STORAGE
*Storage
328 if (Storage
->BrowserStorage
->Type
== EFI_HII_VARSTORE_BUFFER
||
329 Storage
->BrowserStorage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
330 Name
= Storage
->BrowserStorage
->Name
;
335 Storage
->ConfigHdr
= HiiConstructConfigHdr (
336 &Storage
->BrowserStorage
->Guid
,
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
;
563 BrowserStorage
->Initialized
= FALSE
;
566 Storage
->BrowserStorage
= BrowserStorage
;
567 InitializeConfigHdr (FormSet
, Storage
);
568 Storage
->ConfigRequest
= AllocateCopyPool (StrSize (Storage
->ConfigHdr
), Storage
->ConfigHdr
);
569 Storage
->SpareStrLen
= 0;
575 Get Formset_storage base on the input varstoreid info.
577 @param FormSet Pointer of the current FormSet.
578 @param VarStoreId Varstore ID info.
580 @return Pointer to a FORMSET_STORAGE data structure.
585 IN FORM_BROWSER_FORMSET
*FormSet
,
586 IN EFI_VARSTORE_ID VarStoreId
589 FORMSET_STORAGE
*FormsetStorage
;
594 FormsetStorage
= NULL
;
596 // Find Formset Storage for this Question
598 Link
= GetFirstNode (&FormSet
->StorageListHead
);
599 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
600 FormsetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
602 if (FormsetStorage
->VarStoreId
== VarStoreId
) {
607 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
610 return Found
? FormsetStorage
: NULL
;
614 Get Formset_storage base on the input browser storage.
616 More than one formsets may share the same browser storage,
617 this function just get the first formset storage which
618 share the browser storage.
620 @param Storage browser storage info.
622 @return Pointer to a FORMSET_STORAGE data structure.
627 GetFstStgFromBrsStg (
628 IN BROWSER_STORAGE
*Storage
631 FORMSET_STORAGE
*FormsetStorage
;
633 LIST_ENTRY
*FormsetLink
;
634 FORM_BROWSER_FORMSET
*FormSet
;
638 FormsetStorage
= NULL
;
640 FormsetLink
= GetFirstNode (&gBrowserFormSetList
);
641 while (!IsNull (&gBrowserFormSetList
, FormsetLink
)) {
642 FormSet
= FORM_BROWSER_FORMSET_FROM_LINK (FormsetLink
);
643 FormsetLink
= GetNextNode (&gBrowserFormSetList
, FormsetLink
);
645 Link
= GetFirstNode (&FormSet
->StorageListHead
);
646 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
647 FormsetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
648 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
650 if (FormsetStorage
->BrowserStorage
== Storage
) {
661 return Found
? FormsetStorage
: NULL
;
665 Initialize Request Element of a Question. <RequestElement> ::= '&'<BlockName> | '&'<Label>
667 @param FormSet Pointer of the current FormSet.
668 @param Question The Question to be initialized.
669 @param Form Pointer of the current form.
671 @retval EFI_SUCCESS Function success.
672 @retval EFI_INVALID_PARAMETER No storage associated with the Question.
676 InitializeRequestElement (
677 IN OUT FORM_BROWSER_FORMSET
*FormSet
,
678 IN OUT FORM_BROWSER_STATEMENT
*Question
,
679 IN OUT FORM_BROWSER_FORM
*Form
682 BROWSER_STORAGE
*Storage
;
683 FORMSET_STORAGE
*FormsetStorage
;
687 CHAR16 RequestElement
[30];
690 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
692 Storage
= Question
->Storage
;
693 if (Storage
== NULL
) {
694 return EFI_INVALID_PARAMETER
;
697 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
699 // <ConfigRequest> is unnecessary for EFI variable storage,
700 // GetVariable()/SetVariable() will be used to retrieve/save values
706 // Prepare <RequestElement>
708 if (Storage
->Type
== EFI_HII_VARSTORE_BUFFER
||
709 Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
710 StrLen
= UnicodeSPrint (
712 30 * sizeof (CHAR16
),
713 L
"&OFFSET=%04x&WIDTH=%04x",
714 Question
->VarStoreInfo
.VarOffset
,
715 Question
->StorageWidth
717 Question
->BlockName
= AllocateCopyPool ((StrLen
+ 1) * sizeof (CHAR16
), RequestElement
);
719 StrLen
= UnicodeSPrint (RequestElement
, 30 * sizeof (CHAR16
), L
"&%s", Question
->VariableName
);
722 if ((Question
->Operand
== EFI_IFR_PASSWORD_OP
) && ((Question
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
)) {
724 // Password with CALLBACK flag is stored in encoded format,
725 // so don't need to append it to <ConfigRequest>
731 // Find Formset Storage for this Question
733 FormsetStorage
= GetFstStgFromVarId(FormSet
, Question
->VarStoreId
);
734 ASSERT (FormsetStorage
!= NULL
);
737 // Append <RequestElement> to <ConfigRequest>
739 if (StrLen
> FormsetStorage
->SpareStrLen
) {
741 // Old String buffer is not sufficient for RequestElement, allocate a new one
743 StringSize
= (FormsetStorage
->ConfigRequest
!= NULL
) ? StrSize (FormsetStorage
->ConfigRequest
) : sizeof (CHAR16
);
744 NewStr
= AllocateZeroPool (StringSize
+ CONFIG_REQUEST_STRING_INCREMENTAL
* sizeof (CHAR16
));
745 ASSERT (NewStr
!= NULL
);
746 if (FormsetStorage
->ConfigRequest
!= NULL
) {
747 CopyMem (NewStr
, FormsetStorage
->ConfigRequest
, StringSize
);
748 FreePool (FormsetStorage
->ConfigRequest
);
750 FormsetStorage
->ConfigRequest
= NewStr
;
751 FormsetStorage
->SpareStrLen
= CONFIG_REQUEST_STRING_INCREMENTAL
;
754 StrCat (FormsetStorage
->ConfigRequest
, RequestElement
);
755 FormsetStorage
->ElementCount
++;
756 FormsetStorage
->SpareStrLen
-= StrLen
;
759 // Update the Config Request info saved in the form.
763 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
764 while (!IsNull (&Form
->ConfigRequestHead
, Link
)) {
765 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
767 if (ConfigInfo
!= NULL
&& ConfigInfo
->Storage
== FormsetStorage
->BrowserStorage
) {
772 Link
= GetNextNode (&Form
->ConfigRequestHead
, Link
);
776 ConfigInfo
= AllocateZeroPool(sizeof (FORM_BROWSER_CONFIG_REQUEST
));
777 ASSERT (ConfigInfo
!= NULL
);
778 ConfigInfo
->Signature
= FORM_BROWSER_CONFIG_REQUEST_SIGNATURE
;
779 ConfigInfo
->ConfigRequest
= AllocateCopyPool (StrSize (FormsetStorage
->ConfigHdr
), FormsetStorage
->ConfigHdr
);
780 ASSERT (ConfigInfo
->ConfigRequest
!= NULL
);
781 ConfigInfo
->SpareStrLen
= 0;
782 ConfigInfo
->Storage
= FormsetStorage
->BrowserStorage
;
783 InsertTailList(&Form
->ConfigRequestHead
, &ConfigInfo
->Link
);
787 // Append <RequestElement> to <ConfigRequest>
789 if (StrLen
> ConfigInfo
->SpareStrLen
) {
791 // Old String buffer is not sufficient for RequestElement, allocate a new one
793 StringSize
= (ConfigInfo
->ConfigRequest
!= NULL
) ? StrSize (ConfigInfo
->ConfigRequest
) : sizeof (CHAR16
);
794 NewStr
= AllocateZeroPool (StringSize
+ CONFIG_REQUEST_STRING_INCREMENTAL
* sizeof (CHAR16
));
795 ASSERT (NewStr
!= NULL
);
796 if (ConfigInfo
->ConfigRequest
!= NULL
) {
797 CopyMem (NewStr
, ConfigInfo
->ConfigRequest
, StringSize
);
798 FreePool (ConfigInfo
->ConfigRequest
);
800 ConfigInfo
->ConfigRequest
= NewStr
;
801 ConfigInfo
->SpareStrLen
= CONFIG_REQUEST_STRING_INCREMENTAL
;
804 StrCat (ConfigInfo
->ConfigRequest
, RequestElement
);
805 ConfigInfo
->ElementCount
++;
806 ConfigInfo
->SpareStrLen
-= StrLen
;
812 Free resources of a Expression.
814 @param FormSet Pointer of the Expression
819 IN FORM_EXPRESSION
*Expression
823 EXPRESSION_OPCODE
*OpCode
;
824 LIST_ENTRY
*SubExpressionLink
;
825 FORM_EXPRESSION
*SubExpression
;
827 while (!IsListEmpty (&Expression
->OpCodeListHead
)) {
828 Link
= GetFirstNode (&Expression
->OpCodeListHead
);
829 OpCode
= EXPRESSION_OPCODE_FROM_LINK (Link
);
830 RemoveEntryList (&OpCode
->Link
);
832 if (OpCode
->ValueList
!= NULL
) {
833 FreePool (OpCode
->ValueList
);
836 if (OpCode
->ValueName
!= NULL
) {
837 FreePool (OpCode
->ValueName
);
840 if (OpCode
->MapExpressionList
.ForwardLink
!= NULL
) {
841 while (!IsListEmpty (&OpCode
->MapExpressionList
)) {
842 SubExpressionLink
= GetFirstNode(&OpCode
->MapExpressionList
);
843 SubExpression
= FORM_EXPRESSION_FROM_LINK (SubExpressionLink
);
844 RemoveEntryList(&SubExpression
->Link
);
845 DestroyExpression (SubExpression
);
851 // Free this Expression
853 FreePool (Expression
);
857 Free resources of a storage.
859 @param Storage Pointer of the storage
864 IN FORMSET_STORAGE
*Storage
867 if (Storage
== NULL
) {
871 if (Storage
->ConfigRequest
!= NULL
) {
872 FreePool (Storage
->ConfigRequest
);
880 Free resources of a Statement.
882 @param FormSet Pointer of the FormSet
883 @param Statement Pointer of the Statement
888 IN FORM_BROWSER_FORMSET
*FormSet
,
889 IN OUT FORM_BROWSER_STATEMENT
*Statement
893 QUESTION_DEFAULT
*Default
;
894 QUESTION_OPTION
*Option
;
895 FORM_EXPRESSION
*Expression
;
898 // Free Default value List
900 while (!IsListEmpty (&Statement
->DefaultListHead
)) {
901 Link
= GetFirstNode (&Statement
->DefaultListHead
);
902 Default
= QUESTION_DEFAULT_FROM_LINK (Link
);
903 RemoveEntryList (&Default
->Link
);
905 if (Default
->Value
.Buffer
!= NULL
) {
906 FreePool (Default
->Value
.Buffer
);
914 while (!IsListEmpty (&Statement
->OptionListHead
)) {
915 Link
= GetFirstNode (&Statement
->OptionListHead
);
916 Option
= QUESTION_OPTION_FROM_LINK (Link
);
917 if (Option
->SuppressExpression
!= NULL
) {
918 FreePool (Option
->SuppressExpression
);
920 RemoveEntryList (&Option
->Link
);
926 // Free Inconsistent List
928 while (!IsListEmpty (&Statement
->InconsistentListHead
)) {
929 Link
= GetFirstNode (&Statement
->InconsistentListHead
);
930 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
931 RemoveEntryList (&Expression
->Link
);
933 DestroyExpression (Expression
);
937 // Free NoSubmit List
939 while (!IsListEmpty (&Statement
->NoSubmitListHead
)) {
940 Link
= GetFirstNode (&Statement
->NoSubmitListHead
);
941 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
942 RemoveEntryList (&Expression
->Link
);
944 DestroyExpression (Expression
);
948 // Free WarningIf List
950 while (!IsListEmpty (&Statement
->WarningListHead
)) {
951 Link
= GetFirstNode (&Statement
->WarningListHead
);
952 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
953 RemoveEntryList (&Expression
->Link
);
955 DestroyExpression (Expression
);
958 if (Statement
->Expression
!= NULL
) {
959 FreePool (Statement
->Expression
);
962 if (Statement
->VariableName
!= NULL
) {
963 FreePool (Statement
->VariableName
);
965 if (Statement
->BlockName
!= NULL
) {
966 FreePool (Statement
->BlockName
);
968 if (Statement
->BufferValue
!= NULL
) {
969 FreePool (Statement
->BufferValue
);
971 if (Statement
->Operand
== EFI_IFR_STRING_OP
|| Statement
->Operand
== EFI_IFR_PASSWORD_OP
) {
972 DeleteString(Statement
->HiiValue
.Value
.string
, FormSet
->HiiHandle
);
978 Free resources of a Form.
980 @param FormSet Pointer of the FormSet
981 @param Form Pointer of the Form.
986 IN FORM_BROWSER_FORMSET
*FormSet
,
987 IN OUT FORM_BROWSER_FORM
*Form
991 FORM_EXPRESSION
*Expression
;
992 FORM_BROWSER_STATEMENT
*Statement
;
993 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
996 // Free Form Expressions
998 while (!IsListEmpty (&Form
->ExpressionListHead
)) {
999 Link
= GetFirstNode (&Form
->ExpressionListHead
);
1000 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
1001 RemoveEntryList (&Expression
->Link
);
1003 DestroyExpression (Expression
);
1007 // Free Statements/Questions
1009 while (!IsListEmpty (&Form
->StatementListHead
)) {
1010 Link
= GetFirstNode (&Form
->StatementListHead
);
1011 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
1012 RemoveEntryList (&Statement
->Link
);
1014 DestroyStatement (FormSet
, Statement
);
1018 // Free ConfigRequest string.
1020 while (!IsListEmpty (&Form
->ConfigRequestHead
)) {
1021 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
1022 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
1023 RemoveEntryList (&ConfigInfo
->Link
);
1025 FreePool (ConfigInfo
->ConfigRequest
);
1026 FreePool (ConfigInfo
);
1029 if (Form
->SuppressExpression
!= NULL
) {
1030 FreePool (Form
->SuppressExpression
);
1033 UiFreeMenuList (&Form
->FormViewListHead
);
1043 Free resources allocated for a FormSet.
1045 @param FormSet Pointer of the FormSet
1050 IN OUT FORM_BROWSER_FORMSET
*FormSet
1054 FORMSET_STORAGE
*Storage
;
1055 FORMSET_DEFAULTSTORE
*DefaultStore
;
1056 FORM_EXPRESSION
*Expression
;
1057 FORM_BROWSER_FORM
*Form
;
1059 if (FormSet
->IfrBinaryData
== NULL
) {
1061 // Uninitialized FormSet
1068 // Free IFR binary buffer
1070 FreePool (FormSet
->IfrBinaryData
);
1073 // Free FormSet Storage
1075 if (FormSet
->StorageListHead
.ForwardLink
!= NULL
) {
1076 while (!IsListEmpty (&FormSet
->StorageListHead
)) {
1077 Link
= GetFirstNode (&FormSet
->StorageListHead
);
1078 Storage
= FORMSET_STORAGE_FROM_LINK (Link
);
1079 RemoveEntryList (&Storage
->Link
);
1081 DestroyStorage (Storage
);
1086 // Free FormSet Default Store
1088 if (FormSet
->DefaultStoreListHead
.ForwardLink
!= NULL
) {
1089 while (!IsListEmpty (&FormSet
->DefaultStoreListHead
)) {
1090 Link
= GetFirstNode (&FormSet
->DefaultStoreListHead
);
1091 DefaultStore
= FORMSET_DEFAULTSTORE_FROM_LINK (Link
);
1092 RemoveEntryList (&DefaultStore
->Link
);
1094 FreePool (DefaultStore
);
1099 // Free Formset Expressions
1101 while (!IsListEmpty (&FormSet
->ExpressionListHead
)) {
1102 Link
= GetFirstNode (&FormSet
->ExpressionListHead
);
1103 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
1104 RemoveEntryList (&Expression
->Link
);
1106 DestroyExpression (Expression
);
1112 if (FormSet
->FormListHead
.ForwardLink
!= NULL
) {
1113 while (!IsListEmpty (&FormSet
->FormListHead
)) {
1114 Link
= GetFirstNode (&FormSet
->FormListHead
);
1115 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
1116 RemoveEntryList (&Form
->Link
);
1118 DestroyForm (FormSet
, Form
);
1122 if (FormSet
->StatementBuffer
!= NULL
) {
1123 FreePool (FormSet
->StatementBuffer
);
1125 if (FormSet
->ExpressionBuffer
!= NULL
) {
1126 FreePool (FormSet
->ExpressionBuffer
);
1134 Tell whether this Operand is an Expression OpCode or not
1136 @param Operand Operand of an IFR OpCode.
1138 @retval TRUE This is an Expression OpCode.
1139 @retval FALSE Not an Expression OpCode.
1143 IsExpressionOpCode (
1147 if (((Operand
>= EFI_IFR_EQ_ID_VAL_OP
) && (Operand
<= EFI_IFR_NOT_OP
)) ||
1148 ((Operand
>= EFI_IFR_MATCH_OP
) && (Operand
<= EFI_IFR_SET_OP
)) ||
1149 ((Operand
>= EFI_IFR_EQUAL_OP
) && (Operand
<= EFI_IFR_SPAN_OP
)) ||
1150 (Operand
== EFI_IFR_CATENATE_OP
) ||
1151 (Operand
== EFI_IFR_TO_LOWER_OP
) ||
1152 (Operand
== EFI_IFR_TO_UPPER_OP
) ||
1153 (Operand
== EFI_IFR_MAP_OP
) ||
1154 (Operand
== EFI_IFR_VERSION_OP
) ||
1155 (Operand
== EFI_IFR_SECURITY_OP
)) {
1163 Tell whether this Operand is an Statement OpCode.
1165 @param Operand Operand of an IFR OpCode.
1167 @retval TRUE This is an Statement OpCode.
1168 @retval FALSE Not an Statement OpCode.
1176 if ((Operand
== EFI_IFR_SUBTITLE_OP
) ||
1177 (Operand
== EFI_IFR_TEXT_OP
) ||
1178 (Operand
== EFI_IFR_RESET_BUTTON_OP
) ||
1179 (Operand
== EFI_IFR_REF_OP
) ||
1180 (Operand
== EFI_IFR_ACTION_OP
) ||
1181 (Operand
== EFI_IFR_NUMERIC_OP
) ||
1182 (Operand
== EFI_IFR_ORDERED_LIST_OP
) ||
1183 (Operand
== EFI_IFR_CHECKBOX_OP
) ||
1184 (Operand
== EFI_IFR_STRING_OP
) ||
1185 (Operand
== EFI_IFR_PASSWORD_OP
) ||
1186 (Operand
== EFI_IFR_DATE_OP
) ||
1187 (Operand
== EFI_IFR_TIME_OP
) ||
1188 (Operand
== EFI_IFR_GUID_OP
) ||
1189 (Operand
== EFI_IFR_ONE_OF_OP
)) {
1197 Tell whether this Operand is an known OpCode.
1199 @param Operand Operand of an IFR OpCode.
1201 @retval TRUE This is an Statement OpCode.
1202 @retval FALSE Not an Statement OpCode.
1210 return Operand
> EFI_IFR_WARNING_IF_OP
? TRUE
: FALSE
;
1214 Calculate number of Statemens(Questions) and Expression OpCodes.
1216 @param FormSet The FormSet to be counted.
1217 @param NumberOfStatement Number of Statemens(Questions)
1218 @param NumberOfExpression Number of Expression OpCodes
1223 IN FORM_BROWSER_FORMSET
*FormSet
,
1224 IN OUT UINT16
*NumberOfStatement
,
1225 IN OUT UINT16
*NumberOfExpression
1228 UINT16 StatementCount
;
1229 UINT16 ExpressionCount
;
1236 ExpressionCount
= 0;
1238 while (Offset
< FormSet
->IfrBinaryLength
) {
1239 OpCodeData
= FormSet
->IfrBinaryData
+ Offset
;
1240 OpCodeLen
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
1241 Offset
+= OpCodeLen
;
1243 if (IsExpressionOpCode (((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
)) {
1250 *NumberOfStatement
= StatementCount
;
1251 *NumberOfExpression
= ExpressionCount
;
1257 Parse opcodes in the formset IFR binary.
1259 @param FormSet Pointer of the FormSet data structure.
1261 @retval EFI_SUCCESS Opcode parse success.
1262 @retval Other Opcode parse fail.
1267 IN FORM_BROWSER_FORMSET
*FormSet
1271 FORM_BROWSER_FORM
*CurrentForm
;
1272 FORM_BROWSER_STATEMENT
*CurrentStatement
;
1273 FORM_BROWSER_STATEMENT
*ParentStatement
;
1274 EXPRESSION_OPCODE
*ExpressionOpCode
;
1275 FORM_EXPRESSION
*CurrentExpression
;
1282 FORMSET_STORAGE
*Storage
;
1283 FORMSET_DEFAULTSTORE
*DefaultStore
;
1284 QUESTION_DEFAULT
*CurrentDefault
;
1285 QUESTION_OPTION
*CurrentOption
;
1287 UINT16 NumberOfStatement
;
1288 UINT16 NumberOfExpression
;
1289 EFI_IMAGE_ID
*ImageId
;
1290 BOOLEAN SuppressForQuestion
;
1291 BOOLEAN SuppressForOption
;
1292 UINT16 DepthOfDisable
;
1293 BOOLEAN OpCodeDisabled
;
1294 BOOLEAN SingleOpCodeExpression
;
1295 BOOLEAN InScopeDefault
;
1296 EFI_HII_VALUE
*Value
;
1297 EFI_IFR_FORM_MAP_METHOD
*MapMethod
;
1298 UINT8 MapScopeDepth
;
1300 FORMSET_STORAGE
*VarStorage
;
1301 LIST_ENTRY
*MapExpressionList
;
1302 EFI_VARSTORE_ID TempVarstoreId
;
1303 BOOLEAN InScopeDisable
;
1304 INTN ConditionalExprCount
;
1305 BOOLEAN InUnknownScope
;
1308 SuppressForQuestion
= FALSE
;
1309 SuppressForOption
= FALSE
;
1310 InScopeDisable
= FALSE
;
1312 OpCodeDisabled
= FALSE
;
1313 SingleOpCodeExpression
= FALSE
;
1314 InScopeDefault
= FALSE
;
1315 CurrentExpression
= NULL
;
1316 CurrentDefault
= NULL
;
1317 CurrentOption
= NULL
;
1323 MapExpressionList
= NULL
;
1325 ConditionalExprCount
= 0;
1326 InUnknownScope
= FALSE
;
1330 // Get the number of Statements and Expressions
1332 CountOpCodes (FormSet
, &NumberOfStatement
, &NumberOfExpression
);
1334 mStatementIndex
= 0;
1335 mUsedQuestionId
= 1;
1336 FormSet
->StatementBuffer
= AllocateZeroPool (NumberOfStatement
* sizeof (FORM_BROWSER_STATEMENT
));
1337 if (FormSet
->StatementBuffer
== NULL
) {
1338 return EFI_OUT_OF_RESOURCES
;
1341 mExpressionOpCodeIndex
= 0;
1342 FormSet
->ExpressionBuffer
= AllocateZeroPool (NumberOfExpression
* sizeof (EXPRESSION_OPCODE
));
1343 if (FormSet
->ExpressionBuffer
== NULL
) {
1344 return EFI_OUT_OF_RESOURCES
;
1347 InitializeListHead (&FormSet
->StatementListOSF
);
1348 InitializeListHead (&FormSet
->StorageListHead
);
1349 InitializeListHead (&FormSet
->SaveFailStorageListHead
);
1350 InitializeListHead (&FormSet
->DefaultStoreListHead
);
1351 InitializeListHead (&FormSet
->FormListHead
);
1352 InitializeListHead (&FormSet
->ExpressionListHead
);
1353 ResetCurrentExpressionStack ();
1354 ResetMapExpressionListStack ();
1357 CurrentStatement
= NULL
;
1358 ParentStatement
= NULL
;
1363 while (OpCodeOffset
< FormSet
->IfrBinaryLength
) {
1364 OpCodeData
= FormSet
->IfrBinaryData
+ OpCodeOffset
;
1366 OpCodeLength
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
1367 OpCodeOffset
+= OpCodeLength
;
1368 Operand
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
;
1369 Scope
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Scope
;
1371 if (InUnknownScope
) {
1372 if (Operand
== EFI_IFR_END_OP
) {
1375 if (UnknownDepth
== 0) {
1376 InUnknownScope
= FALSE
;
1387 if (IsUnKnownOpCode(Operand
)) {
1389 InUnknownScope
= TRUE
;
1397 // If scope bit set, push onto scope stack
1400 PushScope (Operand
);
1403 if (OpCodeDisabled
) {
1405 // DisableIf Expression is evaluated to be TRUE, try to find its end.
1406 // Here only cares the EFI_IFR_DISABLE_IF and EFI_IFR_END
1408 if (Operand
== EFI_IFR_DISABLE_IF_OP
) {
1410 } else if (Operand
== EFI_IFR_END_OP
) {
1411 Status
= PopScope (&ScopeOpCode
);
1412 if (EFI_ERROR (Status
)) {
1416 if (ScopeOpCode
== EFI_IFR_DISABLE_IF_OP
) {
1417 if (DepthOfDisable
== 0) {
1418 InScopeDisable
= FALSE
;
1419 OpCodeDisabled
= FALSE
;
1428 if (IsExpressionOpCode (Operand
)) {
1429 ExpressionOpCode
= &FormSet
->ExpressionBuffer
[mExpressionOpCodeIndex
];
1430 mExpressionOpCodeIndex
++;
1432 ExpressionOpCode
->Signature
= EXPRESSION_OPCODE_SIGNATURE
;
1433 ExpressionOpCode
->Operand
= Operand
;
1434 Value
= &ExpressionOpCode
->Value
;
1437 case EFI_IFR_EQ_ID_VAL_OP
:
1438 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1440 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1441 CopyMem (&Value
->Value
.u16
, &((EFI_IFR_EQ_ID_VAL
*) OpCodeData
)->Value
, sizeof (UINT16
));
1444 case EFI_IFR_EQ_ID_ID_OP
:
1445 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_ID
*) OpCodeData
)->QuestionId1
, sizeof (EFI_QUESTION_ID
));
1446 CopyMem (&ExpressionOpCode
->QuestionId2
, &((EFI_IFR_EQ_ID_ID
*) OpCodeData
)->QuestionId2
, sizeof (EFI_QUESTION_ID
));
1449 case EFI_IFR_EQ_ID_VAL_LIST_OP
:
1450 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1451 CopyMem (&ExpressionOpCode
->ListLength
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->ListLength
, sizeof (UINT16
));
1452 ExpressionOpCode
->ValueList
= AllocateCopyPool (ExpressionOpCode
->ListLength
* sizeof (UINT16
), &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->ValueList
);
1455 case EFI_IFR_TO_STRING_OP
:
1456 case EFI_IFR_FIND_OP
:
1457 ExpressionOpCode
->Format
= (( EFI_IFR_TO_STRING
*) OpCodeData
)->Format
;
1460 case EFI_IFR_STRING_REF1_OP
:
1461 Value
->Type
= EFI_IFR_TYPE_STRING
;
1462 CopyMem (&Value
->Value
.string
, &(( EFI_IFR_STRING_REF1
*) OpCodeData
)->StringId
, sizeof (EFI_STRING_ID
));
1465 case EFI_IFR_RULE_REF_OP
:
1466 ExpressionOpCode
->RuleId
= (( EFI_IFR_RULE_REF
*) OpCodeData
)->RuleId
;
1469 case EFI_IFR_SPAN_OP
:
1470 ExpressionOpCode
->Flags
= (( EFI_IFR_SPAN
*) OpCodeData
)->Flags
;
1473 case EFI_IFR_THIS_OP
:
1474 ASSERT (ParentStatement
!= NULL
);
1475 ExpressionOpCode
->QuestionId
= ParentStatement
->QuestionId
;
1478 case EFI_IFR_SECURITY_OP
:
1479 CopyMem (&ExpressionOpCode
->Guid
, &((EFI_IFR_SECURITY
*) OpCodeData
)->Permissions
, sizeof (EFI_GUID
));
1482 case EFI_IFR_GET_OP
:
1483 case EFI_IFR_SET_OP
:
1484 CopyMem (&TempVarstoreId
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreId
, sizeof (TempVarstoreId
));
1485 if (TempVarstoreId
!= 0) {
1486 if (FormSet
->StorageListHead
.ForwardLink
!= NULL
) {
1487 Link
= GetFirstNode (&FormSet
->StorageListHead
);
1488 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
1489 VarStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
1490 if (VarStorage
->VarStoreId
== ((EFI_IFR_GET
*) OpCodeData
)->VarStoreId
) {
1491 ExpressionOpCode
->VarStorage
= VarStorage
->BrowserStorage
;
1494 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
1497 if (ExpressionOpCode
->VarStorage
== NULL
) {
1499 // VarStorage is not found.
1501 return EFI_INVALID_PARAMETER
;
1504 ExpressionOpCode
->ValueType
= ((EFI_IFR_GET
*) OpCodeData
)->VarStoreType
;
1505 switch (ExpressionOpCode
->ValueType
) {
1506 case EFI_IFR_TYPE_BOOLEAN
:
1507 case EFI_IFR_TYPE_NUM_SIZE_8
:
1508 ExpressionOpCode
->ValueWidth
= 1;
1511 case EFI_IFR_TYPE_NUM_SIZE_16
:
1512 case EFI_IFR_TYPE_STRING
:
1513 ExpressionOpCode
->ValueWidth
= 2;
1516 case EFI_IFR_TYPE_NUM_SIZE_32
:
1517 ExpressionOpCode
->ValueWidth
= 4;
1520 case EFI_IFR_TYPE_NUM_SIZE_64
:
1521 ExpressionOpCode
->ValueWidth
= 8;
1524 case EFI_IFR_TYPE_DATE
:
1525 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_DATE
);
1528 case EFI_IFR_TYPE_TIME
:
1529 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_TIME
);
1532 case EFI_IFR_TYPE_REF
:
1533 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_REF
);
1536 case EFI_IFR_TYPE_OTHER
:
1537 case EFI_IFR_TYPE_UNDEFINED
:
1538 case EFI_IFR_TYPE_ACTION
:
1539 case EFI_IFR_TYPE_BUFFER
:
1542 // Invalid value type for Get/Set opcode.
1544 return EFI_INVALID_PARAMETER
;
1546 CopyMem (&ExpressionOpCode
->VarStoreInfo
.VarName
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreInfo
.VarName
, sizeof (EFI_STRING_ID
));
1547 CopyMem (&ExpressionOpCode
->VarStoreInfo
.VarOffset
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreInfo
.VarOffset
, sizeof (UINT16
));
1548 if ((ExpressionOpCode
->VarStorage
!= NULL
) &&
1549 (ExpressionOpCode
->VarStorage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
||
1550 ExpressionOpCode
->VarStorage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
)) {
1551 ExpressionOpCode
->ValueName
= GetToken (ExpressionOpCode
->VarStoreInfo
.VarName
, FormSet
->HiiHandle
);
1552 if (ExpressionOpCode
->ValueName
== NULL
) {
1554 // String ID is invalid.
1556 return EFI_INVALID_PARAMETER
;
1561 case EFI_IFR_QUESTION_REF1_OP
:
1562 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1565 case EFI_IFR_QUESTION_REF3_OP
:
1566 if (OpCodeLength
>= sizeof (EFI_IFR_QUESTION_REF3_2
)) {
1567 CopyMem (&ExpressionOpCode
->DevicePath
, &(( EFI_IFR_QUESTION_REF3_2
*) OpCodeData
)->DevicePath
, sizeof (EFI_STRING_ID
));
1569 if (OpCodeLength
>= sizeof (EFI_IFR_QUESTION_REF3_3
)) {
1570 CopyMem (&ExpressionOpCode
->Guid
, &(( EFI_IFR_QUESTION_REF3_3
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
1578 case EFI_IFR_TRUE_OP
:
1579 Value
->Type
= EFI_IFR_TYPE_BOOLEAN
;
1580 Value
->Value
.b
= TRUE
;
1583 case EFI_IFR_FALSE_OP
:
1584 Value
->Type
= EFI_IFR_TYPE_BOOLEAN
;
1585 Value
->Value
.b
= FALSE
;
1588 case EFI_IFR_ONE_OP
:
1589 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1590 Value
->Value
.u8
= 1;
1593 case EFI_IFR_ZERO_OP
:
1594 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1595 Value
->Value
.u8
= 0;
1598 case EFI_IFR_ONES_OP
:
1599 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1600 Value
->Value
.u64
= 0xffffffffffffffffULL
;
1603 case EFI_IFR_UINT8_OP
:
1604 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1605 Value
->Value
.u8
= (( EFI_IFR_UINT8
*) OpCodeData
)->Value
;
1608 case EFI_IFR_UINT16_OP
:
1609 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1610 CopyMem (&Value
->Value
.u16
, &(( EFI_IFR_UINT16
*) OpCodeData
)->Value
, sizeof (UINT16
));
1613 case EFI_IFR_UINT32_OP
:
1614 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_32
;
1615 CopyMem (&Value
->Value
.u32
, &(( EFI_IFR_UINT32
*) OpCodeData
)->Value
, sizeof (UINT32
));
1618 case EFI_IFR_UINT64_OP
:
1619 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1620 CopyMem (&Value
->Value
.u64
, &(( EFI_IFR_UINT64
*) OpCodeData
)->Value
, sizeof (UINT64
));
1623 case EFI_IFR_UNDEFINED_OP
:
1624 Value
->Type
= EFI_IFR_TYPE_UNDEFINED
;
1627 case EFI_IFR_VERSION_OP
:
1628 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1629 Value
->Value
.u16
= EFI_IFR_SPECIFICATION_VERSION
;
1636 // Create sub expression nested in MAP opcode
1638 if (CurrentExpression
== NULL
&& MapScopeDepth
> 0) {
1639 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
1640 ASSERT (MapExpressionList
!= NULL
);
1641 InsertTailList (MapExpressionList
, &CurrentExpression
->Link
);
1643 SingleOpCodeExpression
= TRUE
;
1646 ASSERT (CurrentExpression
!= NULL
);
1647 InsertTailList (&CurrentExpression
->OpCodeListHead
, &ExpressionOpCode
->Link
);
1648 if (Operand
== EFI_IFR_MAP_OP
) {
1650 // Store current Map Expression List.
1652 if (MapExpressionList
!= NULL
) {
1653 PushMapExpressionList (MapExpressionList
);
1656 // Initialize new Map Expression List.
1658 MapExpressionList
= &ExpressionOpCode
->MapExpressionList
;
1659 InitializeListHead (MapExpressionList
);
1661 // Store current expression.
1663 PushCurrentExpression (CurrentExpression
);
1664 CurrentExpression
= NULL
;
1666 } else if (SingleOpCodeExpression
) {
1668 // There are two cases to indicate the end of an Expression:
1669 // for single OpCode expression: one Expression OpCode
1670 // for expression consists of more than one OpCode: EFI_IFR_END
1672 SingleOpCodeExpression
= FALSE
;
1674 if (InScopeDisable
&& CurrentForm
== NULL
) {
1676 // This is DisableIf expression for Form, it should be a constant expression
1678 Status
= EvaluateExpression (FormSet
, CurrentForm
, CurrentExpression
);
1679 if (EFI_ERROR (Status
)) {
1683 OpCodeDisabled
= IsTrue(&CurrentExpression
->Result
);
1686 CurrentExpression
= NULL
;
1697 case EFI_IFR_FORM_SET_OP
:
1699 // Check the formset GUID
1701 if (CompareMem (&FormSet
->Guid
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
)) != 0) {
1702 return EFI_INVALID_PARAMETER
;
1705 CopyMem (&FormSet
->FormSetTitle
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->FormSetTitle
, sizeof (EFI_STRING_ID
));
1706 CopyMem (&FormSet
->Help
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->Help
, sizeof (EFI_STRING_ID
));
1708 if (OpCodeLength
> OFFSET_OF (EFI_IFR_FORM_SET
, Flags
)) {
1710 // The formset OpCode contains ClassGuid
1712 FormSet
->NumberOfClassGuid
= (UINT8
) (((EFI_IFR_FORM_SET
*) OpCodeData
)->Flags
& 0x3);
1713 CopyMem (FormSet
->ClassGuid
, OpCodeData
+ sizeof (EFI_IFR_FORM_SET
), FormSet
->NumberOfClassGuid
* sizeof (EFI_GUID
));
1717 case EFI_IFR_FORM_OP
:
1719 // Create a new Form for this FormSet
1721 CurrentForm
= AllocateZeroPool (sizeof (FORM_BROWSER_FORM
));
1722 ASSERT (CurrentForm
!= NULL
);
1723 CurrentForm
->Signature
= FORM_BROWSER_FORM_SIGNATURE
;
1724 InitializeListHead (&CurrentForm
->ExpressionListHead
);
1725 InitializeListHead (&CurrentForm
->StatementListHead
);
1726 InitializeListHead (&CurrentForm
->ConfigRequestHead
);
1727 InitializeListHead (&CurrentForm
->FormViewListHead
);
1729 CurrentForm
->FormType
= STANDARD_MAP_FORM_TYPE
;
1730 CopyMem (&CurrentForm
->FormId
, &((EFI_IFR_FORM
*) OpCodeData
)->FormId
, sizeof (UINT16
));
1731 CopyMem (&CurrentForm
->FormTitle
, &((EFI_IFR_FORM
*) OpCodeData
)->FormTitle
, sizeof (EFI_STRING_ID
));
1733 ConditionalExprCount
= GetConditionalExpressionCount(ExpressForm
);
1734 if ( ConditionalExprCount
> 0) {
1736 // Form is inside of suppressif
1738 CurrentForm
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
1739 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
1740 ASSERT (CurrentForm
->SuppressExpression
!= NULL
);
1741 CurrentForm
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
1742 CurrentForm
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
1743 CopyMem (CurrentForm
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressForm
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
1748 // Enter scope of a Form, suppressif will be used for Question or Option
1750 SuppressForQuestion
= TRUE
;
1754 // Insert into Form list of this FormSet
1756 InsertTailList (&FormSet
->FormListHead
, &CurrentForm
->Link
);
1759 case EFI_IFR_FORM_MAP_OP
:
1761 // Create a new Form for this FormSet
1763 CurrentForm
= AllocateZeroPool (sizeof (FORM_BROWSER_FORM
));
1764 ASSERT (CurrentForm
!= NULL
);
1765 CurrentForm
->Signature
= FORM_BROWSER_FORM_SIGNATURE
;
1766 InitializeListHead (&CurrentForm
->ExpressionListHead
);
1767 InitializeListHead (&CurrentForm
->StatementListHead
);
1768 InitializeListHead (&CurrentForm
->ConfigRequestHead
);
1769 InitializeListHead (&CurrentForm
->FormViewListHead
);
1771 CopyMem (&CurrentForm
->FormId
, &((EFI_IFR_FORM
*) OpCodeData
)->FormId
, sizeof (UINT16
));
1773 MapMethod
= (EFI_IFR_FORM_MAP_METHOD
*) (OpCodeData
+ sizeof (EFI_IFR_FORM_MAP
));
1775 // FormMap Form must contain at least one Map Method.
1777 if (((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
< ((UINTN
) (UINT8
*) (MapMethod
+ 1) - (UINTN
) OpCodeData
)) {
1778 return EFI_INVALID_PARAMETER
;
1781 // Try to find the standard form map method.
1783 while (((UINTN
) (UINT8
*) MapMethod
- (UINTN
) OpCodeData
) < ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
) {
1784 if (CompareGuid ((EFI_GUID
*) (VOID
*) &MapMethod
->MethodIdentifier
, &gEfiHiiStandardFormGuid
)) {
1785 CopyMem (&CurrentForm
->FormTitle
, &MapMethod
->MethodTitle
, sizeof (EFI_STRING_ID
));
1786 CurrentForm
->FormType
= STANDARD_MAP_FORM_TYPE
;
1792 // If the standard form map method is not found, the first map method title will be used.
1794 if (CurrentForm
->FormTitle
== 0) {
1795 MapMethod
= (EFI_IFR_FORM_MAP_METHOD
*) (OpCodeData
+ sizeof (EFI_IFR_FORM_MAP
));
1796 CopyMem (&CurrentForm
->FormTitle
, &MapMethod
->MethodTitle
, sizeof (EFI_STRING_ID
));
1799 ConditionalExprCount
= GetConditionalExpressionCount(ExpressForm
);
1800 if ( ConditionalExprCount
> 0) {
1802 // Form is inside of suppressif
1804 CurrentForm
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
1805 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
1806 ASSERT (CurrentForm
->SuppressExpression
!= NULL
);
1807 CurrentForm
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
1808 CurrentForm
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
1809 CopyMem (CurrentForm
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressForm
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
1814 // Enter scope of a Form, suppressif will be used for Question or Option
1816 SuppressForQuestion
= TRUE
;
1820 // Insert into Form list of this FormSet
1822 InsertTailList (&FormSet
->FormListHead
, &CurrentForm
->Link
);
1828 case EFI_IFR_VARSTORE_OP
:
1830 // Create a buffer Storage for this FormSet
1832 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_BUFFER
, OpCodeData
);
1833 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1836 case EFI_IFR_VARSTORE_NAME_VALUE_OP
:
1838 // Create a name/value Storage for this FormSet
1840 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_NAME_VALUE
, OpCodeData
);
1841 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE_NAME_VALUE
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1844 case EFI_IFR_VARSTORE_EFI_OP
:
1846 // Create a EFI variable Storage for this FormSet
1848 if (OpCodeLength
< sizeof (EFI_IFR_VARSTORE_EFI
)) {
1850 // Create efi varstore with format follow UEFI spec before 2.3.1.
1852 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_EFI_VARIABLE
, OpCodeData
);
1855 // Create efi varstore with format follow UEFI spec 2.3.1 and later.
1857 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
, OpCodeData
);
1859 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1865 case EFI_IFR_DEFAULTSTORE_OP
:
1866 DefaultStore
= AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE
));
1867 ASSERT (DefaultStore
!= NULL
);
1868 DefaultStore
->Signature
= FORMSET_DEFAULTSTORE_SIGNATURE
;
1870 CopyMem (&DefaultStore
->DefaultId
, &((EFI_IFR_DEFAULTSTORE
*) OpCodeData
)->DefaultId
, sizeof (UINT16
));
1871 CopyMem (&DefaultStore
->DefaultName
, &((EFI_IFR_DEFAULTSTORE
*) OpCodeData
)->DefaultName
, sizeof (EFI_STRING_ID
));
1874 // Insert to DefaultStore list of this Formset
1876 InsertTailList (&FormSet
->DefaultStoreListHead
, &DefaultStore
->Link
);
1882 case EFI_IFR_SUBTITLE_OP
:
1883 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1884 ASSERT (CurrentStatement
!= NULL
);
1886 CurrentStatement
->Flags
= ((EFI_IFR_SUBTITLE
*) OpCodeData
)->Flags
;
1887 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1890 case EFI_IFR_TEXT_OP
:
1891 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1892 ASSERT (CurrentStatement
!= NULL
);
1893 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1894 CopyMem (&CurrentStatement
->TextTwo
, &((EFI_IFR_TEXT
*) OpCodeData
)->TextTwo
, sizeof (EFI_STRING_ID
));
1897 case EFI_IFR_RESET_BUTTON_OP
:
1898 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1899 ASSERT (CurrentStatement
!= NULL
);
1900 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1901 CopyMem (&CurrentStatement
->DefaultId
, &((EFI_IFR_RESET_BUTTON
*) OpCodeData
)->DefaultId
, sizeof (EFI_DEFAULT_ID
));
1907 case EFI_IFR_ACTION_OP
:
1908 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1909 ASSERT (CurrentStatement
!= NULL
);
1910 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_ACTION
;
1912 if (OpCodeLength
== sizeof (EFI_IFR_ACTION_1
)) {
1914 // No QuestionConfig present, so no configuration string will be processed
1916 CurrentStatement
->QuestionConfig
= 0;
1918 CopyMem (&CurrentStatement
->QuestionConfig
, &((EFI_IFR_ACTION
*) OpCodeData
)->QuestionConfig
, sizeof (EFI_STRING_ID
));
1922 case EFI_IFR_REF_OP
:
1923 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1924 ASSERT (CurrentStatement
!= NULL
);
1925 Value
= &CurrentStatement
->HiiValue
;
1926 Value
->Type
= EFI_IFR_TYPE_REF
;
1927 if (OpCodeLength
>= sizeof (EFI_IFR_REF
)) {
1928 CopyMem (&Value
->Value
.ref
.FormId
, &((EFI_IFR_REF
*) OpCodeData
)->FormId
, sizeof (EFI_FORM_ID
));
1930 if (OpCodeLength
>= sizeof (EFI_IFR_REF2
)) {
1931 CopyMem (&Value
->Value
.ref
.QuestionId
, &((EFI_IFR_REF2
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1933 if (OpCodeLength
>= sizeof (EFI_IFR_REF3
)) {
1934 CopyMem (&Value
->Value
.ref
.FormSetGuid
, &((EFI_IFR_REF3
*) OpCodeData
)->FormSetId
, sizeof (EFI_GUID
));
1936 if (OpCodeLength
>= sizeof (EFI_IFR_REF4
)) {
1937 CopyMem (&Value
->Value
.ref
.DevicePath
, &((EFI_IFR_REF4
*) OpCodeData
)->DevicePath
, sizeof (EFI_STRING_ID
));
1942 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_REF
);
1943 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1946 case EFI_IFR_ONE_OF_OP
:
1947 case EFI_IFR_NUMERIC_OP
:
1948 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1949 ASSERT(CurrentStatement
!= NULL
);
1951 CurrentStatement
->Flags
= ((EFI_IFR_ONE_OF
*) OpCodeData
)->Flags
;
1952 Value
= &CurrentStatement
->HiiValue
;
1954 switch (CurrentStatement
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1955 case EFI_IFR_NUMERIC_SIZE_1
:
1956 CurrentStatement
->Minimum
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.MinValue
;
1957 CurrentStatement
->Maximum
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.MaxValue
;
1958 CurrentStatement
->Step
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.Step
;
1959 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT8
);
1960 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1963 case EFI_IFR_NUMERIC_SIZE_2
:
1964 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.MinValue
, sizeof (UINT16
));
1965 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.MaxValue
, sizeof (UINT16
));
1966 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.Step
, sizeof (UINT16
));
1967 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT16
);
1968 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1971 case EFI_IFR_NUMERIC_SIZE_4
:
1972 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MinValue
, sizeof (UINT32
));
1973 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MaxValue
, sizeof (UINT32
));
1974 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.Step
, sizeof (UINT32
));
1975 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT32
);
1976 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_32
;
1979 case EFI_IFR_NUMERIC_SIZE_8
:
1980 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.MinValue
, sizeof (UINT64
));
1981 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.MaxValue
, sizeof (UINT64
));
1982 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.Step
, sizeof (UINT64
));
1983 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT64
);
1984 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1991 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1993 if ((Operand
== EFI_IFR_ONE_OF_OP
) && Scope
!= 0) {
1994 SuppressForOption
= TRUE
;
1998 case EFI_IFR_ORDERED_LIST_OP
:
1999 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2000 ASSERT(CurrentStatement
!= NULL
);
2002 CurrentStatement
->Flags
= ((EFI_IFR_ORDERED_LIST
*) OpCodeData
)->Flags
;
2003 CurrentStatement
->MaxContainers
= ((EFI_IFR_ORDERED_LIST
*) OpCodeData
)->MaxContainers
;
2005 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_BUFFER
;
2006 CurrentStatement
->BufferValue
= NULL
;
2009 SuppressForOption
= TRUE
;
2013 case EFI_IFR_CHECKBOX_OP
:
2014 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2015 ASSERT(CurrentStatement
!= NULL
);
2017 CurrentStatement
->Flags
= ((EFI_IFR_CHECKBOX
*) OpCodeData
)->Flags
;
2018 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (BOOLEAN
);
2019 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_BOOLEAN
;
2021 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2025 case EFI_IFR_STRING_OP
:
2026 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2027 ASSERT (CurrentStatement
!= NULL
);
2029 // MinSize is the minimum number of characters that can be accepted for this opcode,
2030 // MaxSize is the maximum number of characters that can be accepted for this opcode.
2031 // The characters are stored as Unicode, so the storage width should multiply 2.
2033 CurrentStatement
->Minimum
= ((EFI_IFR_STRING
*) OpCodeData
)->MinSize
;
2034 CurrentStatement
->Maximum
= ((EFI_IFR_STRING
*) OpCodeData
)->MaxSize
;
2035 CurrentStatement
->StorageWidth
= (UINT16
)((UINTN
) CurrentStatement
->Maximum
* sizeof (CHAR16
));
2036 CurrentStatement
->Flags
= ((EFI_IFR_STRING
*) OpCodeData
)->Flags
;
2038 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_STRING
;
2039 CurrentStatement
->BufferValue
= AllocateZeroPool (CurrentStatement
->StorageWidth
+ sizeof (CHAR16
));
2040 CurrentStatement
->HiiValue
.Value
.string
= NewString ((CHAR16
*) CurrentStatement
->BufferValue
, FormSet
->HiiHandle
);
2042 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2045 case EFI_IFR_PASSWORD_OP
:
2046 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2047 ASSERT (CurrentStatement
!= NULL
);
2049 // MinSize is the minimum number of characters that can be accepted for this opcode,
2050 // MaxSize is the maximum number of characters that can be accepted for this opcode.
2051 // The characters are stored as Unicode, so the storage width should multiply 2.
2053 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_PASSWORD
*) OpCodeData
)->MinSize
, sizeof (UINT16
));
2054 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_PASSWORD
*) OpCodeData
)->MaxSize
, sizeof (UINT16
));
2055 CurrentStatement
->StorageWidth
= (UINT16
)((UINTN
) CurrentStatement
->Maximum
* sizeof (CHAR16
));
2057 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_STRING
;
2058 CurrentStatement
->BufferValue
= AllocateZeroPool ((CurrentStatement
->StorageWidth
+ sizeof (CHAR16
)));
2059 CurrentStatement
->HiiValue
.Value
.string
= NewString ((CHAR16
*) CurrentStatement
->BufferValue
, FormSet
->HiiHandle
);
2061 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2064 case EFI_IFR_DATE_OP
:
2065 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2066 ASSERT(CurrentStatement
!= NULL
);
2068 CurrentStatement
->Flags
= ((EFI_IFR_DATE
*) OpCodeData
)->Flags
;
2069 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_DATE
;
2071 if ((CurrentStatement
->Flags
& EFI_QF_DATE_STORAGE
) == QF_DATE_STORAGE_NORMAL
) {
2072 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_DATE
);
2074 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2077 // Don't assign storage for RTC type of date/time
2079 CurrentStatement
->Storage
= NULL
;
2080 CurrentStatement
->StorageWidth
= 0;
2084 case EFI_IFR_TIME_OP
:
2085 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2086 ASSERT(CurrentStatement
!= NULL
);
2088 CurrentStatement
->Flags
= ((EFI_IFR_TIME
*) OpCodeData
)->Flags
;
2089 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_TIME
;
2091 if ((CurrentStatement
->Flags
& QF_TIME_STORAGE
) == QF_TIME_STORAGE_NORMAL
) {
2092 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_TIME
);
2094 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2097 // Don't assign storage for RTC type of date/time
2099 CurrentStatement
->Storage
= NULL
;
2100 CurrentStatement
->StorageWidth
= 0;
2107 case EFI_IFR_DEFAULT_OP
:
2109 // EFI_IFR_DEFAULT appear in scope of a Question,
2110 // It creates a default value for the current question.
2111 // A Question may have more than one Default value which have different default types.
2113 CurrentDefault
= AllocateZeroPool (sizeof (QUESTION_DEFAULT
));
2114 ASSERT (CurrentDefault
!= NULL
);
2115 CurrentDefault
->Signature
= QUESTION_DEFAULT_SIGNATURE
;
2117 CurrentDefault
->Value
.Type
= ((EFI_IFR_DEFAULT
*) OpCodeData
)->Type
;
2118 CopyMem (&CurrentDefault
->DefaultId
, &((EFI_IFR_DEFAULT
*) OpCodeData
)->DefaultId
, sizeof (UINT16
));
2119 if (CurrentDefault
->Value
.Type
== EFI_IFR_TYPE_BUFFER
) {
2120 CurrentDefault
->Value
.BufferLen
= (UINT16
) (OpCodeLength
- OFFSET_OF (EFI_IFR_DEFAULT
, Value
));
2121 CurrentDefault
->Value
.Buffer
= AllocateCopyPool (CurrentDefault
->Value
.BufferLen
, &((EFI_IFR_DEFAULT
*) OpCodeData
)->Value
);
2122 ASSERT (CurrentDefault
->Value
.Buffer
!= NULL
);
2124 CopyMem (&CurrentDefault
->Value
.Value
, &((EFI_IFR_DEFAULT
*) OpCodeData
)->Value
, OpCodeLength
- OFFSET_OF (EFI_IFR_DEFAULT
, Value
));
2125 ExtendValueToU64 (&CurrentDefault
->Value
);
2129 // Insert to Default Value list of current Question
2131 InsertTailList (&ParentStatement
->DefaultListHead
, &CurrentDefault
->Link
);
2134 InScopeDefault
= TRUE
;
2141 case EFI_IFR_ONE_OF_OPTION_OP
:
2142 if (ParentStatement
->Operand
== EFI_IFR_ORDERED_LIST_OP
&& ((((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Flags
& (EFI_IFR_OPTION_DEFAULT
| EFI_IFR_OPTION_DEFAULT_MFG
)) != 0)) {
2144 // It's keep the default value for ordered list opcode.
2146 CurrentDefault
= AllocateZeroPool (sizeof (QUESTION_DEFAULT
));
2147 ASSERT (CurrentDefault
!= NULL
);
2148 CurrentDefault
->Signature
= QUESTION_DEFAULT_SIGNATURE
;
2150 CurrentDefault
->Value
.Type
= EFI_IFR_TYPE_BUFFER
;
2151 if ((((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Flags
& EFI_IFR_OPTION_DEFAULT
) != 0) {
2152 CurrentDefault
->DefaultId
= EFI_HII_DEFAULT_CLASS_STANDARD
;
2154 CurrentDefault
->DefaultId
= EFI_HII_DEFAULT_CLASS_MANUFACTURING
;
2157 CurrentDefault
->Value
.BufferLen
= (UINT16
) (OpCodeLength
- OFFSET_OF (EFI_IFR_ONE_OF_OPTION
, Value
));
2158 CurrentDefault
->Value
.Buffer
= AllocateCopyPool (CurrentDefault
->Value
.BufferLen
, &((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Value
);
2159 ASSERT (CurrentDefault
->Value
.Buffer
!= NULL
);
2162 // Insert to Default Value list of current Question
2164 InsertTailList (&ParentStatement
->DefaultListHead
, &CurrentDefault
->Link
);
2169 // EFI_IFR_ONE_OF_OPTION appear in scope of a Question.
2170 // It create a selection for use in current Question.
2172 CurrentOption
= AllocateZeroPool (sizeof (QUESTION_OPTION
));
2173 ASSERT (CurrentOption
!= NULL
);
2174 CurrentOption
->Signature
= QUESTION_OPTION_SIGNATURE
;
2175 CurrentOption
->OpCode
= (EFI_IFR_ONE_OF_OPTION
*) OpCodeData
;
2177 CurrentOption
->Flags
= ((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Flags
;
2178 CurrentOption
->Value
.Type
= ((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Type
;
2179 CopyMem (&CurrentOption
->Text
, &((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Option
, sizeof (EFI_STRING_ID
));
2180 CopyMem (&CurrentOption
->Value
.Value
, &((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Value
, OpCodeLength
- OFFSET_OF (EFI_IFR_ONE_OF_OPTION
, Value
));
2181 ExtendValueToU64 (&CurrentOption
->Value
);
2183 ConditionalExprCount
= GetConditionalExpressionCount(ExpressOption
);
2184 if ( ConditionalExprCount
> 0) {
2186 // Form is inside of suppressif
2188 CurrentOption
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
2189 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
2190 ASSERT (CurrentOption
->SuppressExpression
!= NULL
);
2191 CurrentOption
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
2192 CurrentOption
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
2193 CopyMem (CurrentOption
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressOption
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
2196 ASSERT (ParentStatement
!= NULL
);
2198 // Insert to Option list of current Question
2200 InsertTailList (&ParentStatement
->OptionListHead
, &CurrentOption
->Link
);
2202 // Now we know the Storage width of nested Ordered List
2204 if ((ParentStatement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) && (ParentStatement
->BufferValue
== NULL
)) {
2206 switch (CurrentOption
->Value
.Type
) {
2207 case EFI_IFR_TYPE_NUM_SIZE_8
:
2211 case EFI_IFR_TYPE_NUM_SIZE_16
:
2215 case EFI_IFR_TYPE_NUM_SIZE_32
:
2219 case EFI_IFR_TYPE_NUM_SIZE_64
:
2225 // Invalid type for Ordered List
2230 ParentStatement
->StorageWidth
= (UINT16
) (ParentStatement
->MaxContainers
* Width
);
2231 ParentStatement
->BufferValue
= AllocateZeroPool (ParentStatement
->StorageWidth
);
2232 ParentStatement
->ValueType
= CurrentOption
->Value
.Type
;
2233 if (ParentStatement
->HiiValue
.Type
== EFI_IFR_TYPE_BUFFER
) {
2234 ParentStatement
->HiiValue
.Buffer
= ParentStatement
->BufferValue
;
2235 ParentStatement
->HiiValue
.BufferLen
= ParentStatement
->StorageWidth
;
2238 InitializeRequestElement (FormSet
, ParentStatement
, CurrentForm
);
2245 case EFI_IFR_NO_SUBMIT_IF_OP
:
2246 case EFI_IFR_INCONSISTENT_IF_OP
:
2248 // Create an Expression node
2250 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2251 CopyMem (&CurrentExpression
->Error
, &((EFI_IFR_INCONSISTENT_IF
*) OpCodeData
)->Error
, sizeof (EFI_STRING_ID
));
2253 if (Operand
== EFI_IFR_NO_SUBMIT_IF_OP
) {
2254 CurrentExpression
->Type
= EFI_HII_EXPRESSION_NO_SUBMIT_IF
;
2255 InsertTailList (&ParentStatement
->NoSubmitListHead
, &CurrentExpression
->Link
);
2257 CurrentExpression
->Type
= EFI_HII_EXPRESSION_INCONSISTENT_IF
;
2258 InsertTailList (&ParentStatement
->InconsistentListHead
, &CurrentExpression
->Link
);
2262 // Take a look at next OpCode to see whether current expression consists
2265 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2266 SingleOpCodeExpression
= TRUE
;
2270 case EFI_IFR_WARNING_IF_OP
:
2272 // Create an Expression node
2274 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2275 CopyMem (&CurrentExpression
->Error
, &((EFI_IFR_WARNING_IF
*) OpCodeData
)->Warning
, sizeof (EFI_STRING_ID
));
2276 CurrentExpression
->TimeOut
= ((EFI_IFR_WARNING_IF
*) OpCodeData
)->TimeOut
;
2277 CurrentExpression
->Type
= EFI_HII_EXPRESSION_WARNING_IF
;
2278 InsertTailList (&ParentStatement
->WarningListHead
, &CurrentExpression
->Link
);
2281 // Take a look at next OpCode to see whether current expression consists
2284 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2285 SingleOpCodeExpression
= TRUE
;
2289 case EFI_IFR_SUPPRESS_IF_OP
:
2291 // Question and Option will appear in scope of this OpCode
2293 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2294 CurrentExpression
->Type
= EFI_HII_EXPRESSION_SUPPRESS_IF
;
2296 if (CurrentForm
== NULL
) {
2297 InsertTailList (&FormSet
->ExpressionListHead
, &CurrentExpression
->Link
);
2299 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2302 if (SuppressForOption
) {
2303 PushConditionalExpression(CurrentExpression
, ExpressOption
);
2304 } else if (SuppressForQuestion
) {
2305 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2307 PushConditionalExpression(CurrentExpression
, ExpressForm
);
2311 // Take a look at next OpCode to see whether current expression consists
2314 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2315 SingleOpCodeExpression
= TRUE
;
2319 case EFI_IFR_GRAY_OUT_IF_OP
:
2321 // Questions will appear in scope of this OpCode
2323 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2324 CurrentExpression
->Type
= EFI_HII_EXPRESSION_GRAY_OUT_IF
;
2325 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2326 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2329 // Take a look at next OpCode to see whether current expression consists
2332 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2333 SingleOpCodeExpression
= TRUE
;
2337 case EFI_IFR_DISABLE_IF_OP
:
2339 // The DisableIf expression should only rely on constant, so it could be
2340 // evaluated at initialization and it will not be queued
2342 CurrentExpression
= AllocateZeroPool (sizeof (FORM_EXPRESSION
));
2343 ASSERT (CurrentExpression
!= NULL
);
2344 CurrentExpression
->Signature
= FORM_EXPRESSION_SIGNATURE
;
2345 CurrentExpression
->Type
= EFI_HII_EXPRESSION_DISABLE_IF
;
2346 InitializeListHead (&CurrentExpression
->OpCodeListHead
);
2348 if (CurrentForm
!= NULL
) {
2350 // This is DisableIf for Question, enqueue it to Form expression list
2352 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2353 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2356 OpCodeDisabled
= FALSE
;
2357 InScopeDisable
= TRUE
;
2359 // Take a look at next OpCode to see whether current expression consists
2362 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2363 SingleOpCodeExpression
= TRUE
;
2370 case EFI_IFR_VALUE_OP
:
2371 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2372 CurrentExpression
->Type
= EFI_HII_EXPRESSION_VALUE
;
2373 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2375 if (InScopeDefault
) {
2377 // Used for default (EFI_IFR_DEFAULT)
2379 CurrentDefault
->ValueExpression
= CurrentExpression
;
2382 // If used for a question, then the question will be read-only
2385 // Make sure CurrentStatement is not NULL.
2386 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2387 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2389 ASSERT (ParentStatement
!= NULL
);
2390 ParentStatement
->ValueExpression
= CurrentExpression
;
2394 // Take a look at next OpCode to see whether current expression consists
2397 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2398 SingleOpCodeExpression
= TRUE
;
2402 case EFI_IFR_RULE_OP
:
2403 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2404 CurrentExpression
->Type
= EFI_HII_EXPRESSION_RULE
;
2406 CurrentExpression
->RuleId
= ((EFI_IFR_RULE
*) OpCodeData
)->RuleId
;
2407 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2410 // Take a look at next OpCode to see whether current expression consists
2413 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2414 SingleOpCodeExpression
= TRUE
;
2418 case EFI_IFR_READ_OP
:
2419 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2420 CurrentExpression
->Type
= EFI_HII_EXPRESSION_READ
;
2421 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2424 // Make sure CurrentStatement is not NULL.
2425 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2426 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2428 ASSERT (ParentStatement
!= NULL
);
2429 ParentStatement
->ReadExpression
= CurrentExpression
;
2432 // Take a look at next OpCode to see whether current expression consists
2435 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2436 SingleOpCodeExpression
= TRUE
;
2440 case EFI_IFR_WRITE_OP
:
2441 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2442 CurrentExpression
->Type
= EFI_HII_EXPRESSION_WRITE
;
2443 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2446 // Make sure CurrentStatement is not NULL.
2447 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2448 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2450 ASSERT (ParentStatement
!= NULL
);
2451 ParentStatement
->WriteExpression
= CurrentExpression
;
2454 // Take a look at next OpCode to see whether current expression consists
2457 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2458 SingleOpCodeExpression
= TRUE
;
2465 case EFI_IFR_IMAGE_OP
:
2467 // Get ScopeOpcode from top of stack
2469 PopScope (&ScopeOpCode
);
2470 PushScope (ScopeOpCode
);
2472 switch (ScopeOpCode
) {
2473 case EFI_IFR_FORM_SET_OP
:
2474 ImageId
= &FormSet
->ImageId
;
2477 case EFI_IFR_FORM_OP
:
2478 case EFI_IFR_FORM_MAP_OP
:
2479 ASSERT (CurrentForm
!= NULL
);
2480 ImageId
= &CurrentForm
->ImageId
;
2483 case EFI_IFR_ONE_OF_OPTION_OP
:
2484 ASSERT (CurrentOption
!= NULL
);
2485 ImageId
= &CurrentOption
->ImageId
;
2490 // Make sure CurrentStatement is not NULL.
2491 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2492 // file is wrongly generated by tools such as VFR Compiler.
2494 ASSERT (ParentStatement
!= NULL
);
2495 ImageId
= &ParentStatement
->ImageId
;
2499 ASSERT (ImageId
!= NULL
);
2500 CopyMem (ImageId
, &((EFI_IFR_IMAGE
*) OpCodeData
)->Id
, sizeof (EFI_IMAGE_ID
));
2506 case EFI_IFR_REFRESH_OP
:
2507 ASSERT (ParentStatement
!= NULL
);
2508 ParentStatement
->RefreshInterval
= ((EFI_IFR_REFRESH
*) OpCodeData
)->RefreshInterval
;
2514 case EFI_IFR_REFRESH_ID_OP
:
2516 // Get ScopeOpcode from top of stack
2518 PopScope (&ScopeOpCode
);
2519 PushScope (ScopeOpCode
);
2521 switch (ScopeOpCode
) {
2522 case EFI_IFR_FORM_OP
:
2523 case EFI_IFR_FORM_MAP_OP
:
2524 ASSERT (CurrentForm
!= NULL
);
2525 CopyMem (&CurrentForm
->RefreshGuid
, &((EFI_IFR_REFRESH_ID
*) OpCodeData
)->RefreshEventGroupId
, sizeof (EFI_GUID
));
2529 ASSERT (ParentStatement
!= NULL
);
2530 CopyMem (&ParentStatement
->RefreshGuid
, &((EFI_IFR_REFRESH_ID
*) OpCodeData
)->RefreshEventGroupId
, sizeof (EFI_GUID
));
2538 case EFI_IFR_MODAL_TAG_OP
:
2539 ASSERT (CurrentForm
!= NULL
);
2540 CurrentForm
->ModalForm
= TRUE
;
2544 // Lock tag, used by form and statement.
2546 case EFI_IFR_LOCKED_OP
:
2548 // Get ScopeOpcode from top of stack
2550 PopScope (&ScopeOpCode
);
2551 PushScope (ScopeOpCode
);
2552 switch (ScopeOpCode
) {
2553 case EFI_IFR_FORM_OP
:
2554 case EFI_IFR_FORM_MAP_OP
:
2555 ASSERT (CurrentForm
!= NULL
);
2556 CurrentForm
->Locked
= TRUE
;
2560 ASSERT (ParentStatement
!= NULL
);
2561 ParentStatement
->Locked
= TRUE
;
2568 case EFI_IFR_GUID_OP
:
2569 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
2575 case EFI_IFR_END_OP
:
2576 Status
= PopScope (&ScopeOpCode
);
2577 if (EFI_ERROR (Status
)) {
2583 // Parent statement end tag found, update ParentStatement info.
2585 if (IsStatementOpCode(ScopeOpCode
) && (ParentStatement
!= NULL
) && (ParentStatement
->Operand
== ScopeOpCode
)) {
2586 ParentStatement
= ParentStatement
->ParentStatement
;
2589 switch (ScopeOpCode
) {
2590 case EFI_IFR_FORM_SET_OP
:
2592 // End of FormSet, update FormSet IFR binary length
2593 // to stop parsing substantial OpCodes
2595 FormSet
->IfrBinaryLength
= OpCodeOffset
;
2598 case EFI_IFR_FORM_OP
:
2599 case EFI_IFR_FORM_MAP_OP
:
2604 SuppressForQuestion
= FALSE
;
2607 case EFI_IFR_ONE_OF_OPTION_OP
:
2611 CurrentOption
= NULL
;
2614 case EFI_IFR_NO_SUBMIT_IF_OP
:
2615 case EFI_IFR_INCONSISTENT_IF_OP
:
2616 case EFI_IFR_WARNING_IF_OP
:
2618 // Ignore end of EFI_IFR_NO_SUBMIT_IF and EFI_IFR_INCONSISTENT_IF
2622 case EFI_IFR_SUPPRESS_IF_OP
:
2623 if (SuppressForOption
) {
2624 PopConditionalExpression(ExpressOption
);
2625 } else if (SuppressForQuestion
) {
2626 PopConditionalExpression(ExpressStatement
);
2628 PopConditionalExpression(ExpressForm
);
2632 case EFI_IFR_GRAY_OUT_IF_OP
:
2633 PopConditionalExpression(ExpressStatement
);
2636 case EFI_IFR_DISABLE_IF_OP
:
2637 if (CurrentForm
!= NULL
) {
2638 PopConditionalExpression(ExpressStatement
);
2640 InScopeDisable
= FALSE
;
2641 OpCodeDisabled
= FALSE
;
2644 case EFI_IFR_ONE_OF_OP
:
2645 case EFI_IFR_ORDERED_LIST_OP
:
2646 SuppressForOption
= FALSE
;
2649 case EFI_IFR_DEFAULT_OP
:
2650 InScopeDefault
= FALSE
;
2653 case EFI_IFR_MAP_OP
:
2655 // Get current Map Expression List.
2657 Status
= PopMapExpressionList ((VOID
**) &MapExpressionList
);
2658 if (Status
== EFI_ACCESS_DENIED
) {
2659 MapExpressionList
= NULL
;
2662 // Get current expression.
2664 Status
= PopCurrentExpression ((VOID
**) &CurrentExpression
);
2665 ASSERT_EFI_ERROR (Status
);
2666 ASSERT (MapScopeDepth
> 0);
2671 if (IsExpressionOpCode (ScopeOpCode
)) {
2672 if (InScopeDisable
&& CurrentForm
== NULL
) {
2674 // This is DisableIf expression for Form, it should be a constant expression
2676 ASSERT (CurrentExpression
!= NULL
);
2677 Status
= EvaluateExpression (FormSet
, CurrentForm
, CurrentExpression
);
2678 if (EFI_ERROR (Status
)) {
2682 OpCodeDisabled
= IsTrue (&CurrentExpression
->Result
);
2685 // DisableIf Expression is only used once and not queued, free it
2687 DestroyExpression (CurrentExpression
);
2691 // End of current Expression
2693 CurrentExpression
= NULL
;
2703 if (IsStatementOpCode(Operand
)) {
2704 CurrentStatement
->ParentStatement
= ParentStatement
;
2707 // Scope != 0, other statements or options may nest in this statement.
2708 // Update the ParentStatement info.
2710 ParentStatement
= CurrentStatement
;