2 Parser for IFR binary encoding.
4 Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 UINT16 mStatementIndex
;
12 UINT16 mExpressionOpCodeIndex
;
13 EFI_QUESTION_ID mUsedQuestionId
;
14 extern LIST_ENTRY gBrowserStorageList
;
16 Initialize Statement header members.
18 @param OpCodeData Pointer of the raw OpCode data.
19 @param FormSet Pointer of the current FormSet.
20 @param Form Pointer of the current Form.
22 @return The Statement.
25 FORM_BROWSER_STATEMENT
*
28 IN OUT FORM_BROWSER_FORMSET
*FormSet
,
29 IN OUT FORM_BROWSER_FORM
*Form
32 FORM_BROWSER_STATEMENT
*Statement
;
33 EFI_IFR_STATEMENT_HEADER
*StatementHdr
;
34 INTN ConditionalExprCount
;
38 // Only guid op may out side the form level.
40 ASSERT (((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
== EFI_IFR_GUID_OP
);
43 Statement
= &FormSet
->StatementBuffer
[mStatementIndex
];
46 InitializeListHead (&Statement
->DefaultListHead
);
47 InitializeListHead (&Statement
->OptionListHead
);
48 InitializeListHead (&Statement
->InconsistentListHead
);
49 InitializeListHead (&Statement
->NoSubmitListHead
);
50 InitializeListHead (&Statement
->WarningListHead
);
52 Statement
->Signature
= FORM_BROWSER_STATEMENT_SIGNATURE
;
54 Statement
->Operand
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
;
55 Statement
->OpCode
= (EFI_IFR_OP_HEADER
*) OpCodeData
;
56 Statement
->QuestionReferToBitField
= FALSE
;
58 StatementHdr
= (EFI_IFR_STATEMENT_HEADER
*) (OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
));
59 CopyMem (&Statement
->Prompt
, &StatementHdr
->Prompt
, sizeof (EFI_STRING_ID
));
60 CopyMem (&Statement
->Help
, &StatementHdr
->Help
, sizeof (EFI_STRING_ID
));
62 ConditionalExprCount
= GetConditionalExpressionCount(ExpressStatement
);
63 if (ConditionalExprCount
> 0) {
65 // Form is inside of suppressif
68 Statement
->Expression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
69 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
70 ASSERT (Statement
->Expression
!= NULL
);
71 Statement
->Expression
->Count
= (UINTN
) ConditionalExprCount
;
72 Statement
->Expression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
73 CopyMem (Statement
->Expression
->Expression
, GetConditionalExpressionList(ExpressStatement
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
77 // Insert this Statement into current Form
80 InsertTailList (&FormSet
->StatementListOSF
, &Statement
->Link
);
82 InsertTailList (&Form
->StatementListHead
, &Statement
->Link
);
88 Initialize Question's members.
90 @param OpCodeData Pointer of the raw OpCode data.
91 @param FormSet Pointer of the current FormSet.
92 @param Form Pointer of the current Form.
97 FORM_BROWSER_STATEMENT
*
100 IN OUT FORM_BROWSER_FORMSET
*FormSet
,
101 IN OUT FORM_BROWSER_FORM
*Form
104 FORM_BROWSER_STATEMENT
*Statement
;
105 EFI_IFR_QUESTION_HEADER
*QuestionHdr
;
107 FORMSET_STORAGE
*Storage
;
108 NAME_VALUE_NODE
*NameValueNode
;
111 Statement
= CreateStatement (OpCodeData
, FormSet
, Form
);
112 if (Statement
== NULL
) {
116 QuestionHdr
= (EFI_IFR_QUESTION_HEADER
*) (OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
));
117 CopyMem (&Statement
->QuestionId
, &QuestionHdr
->QuestionId
, sizeof (EFI_QUESTION_ID
));
118 CopyMem (&Statement
->VarStoreId
, &QuestionHdr
->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
119 CopyMem (&Statement
->VarStoreInfo
.VarOffset
, &QuestionHdr
->VarStoreInfo
.VarOffset
, sizeof (UINT16
));
121 Statement
->QuestionFlags
= QuestionHdr
->Flags
;
123 if (Statement
->VarStoreId
== 0) {
125 // VarStoreId of zero indicates no variable storage
131 // Find Storage for this Question
133 Link
= GetFirstNode (&FormSet
->StorageListHead
);
134 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
135 Storage
= FORMSET_STORAGE_FROM_LINK (Link
);
137 if (Storage
->VarStoreId
== Statement
->VarStoreId
) {
138 Statement
->Storage
= Storage
->BrowserStorage
;
142 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
144 ASSERT (Statement
->Storage
!= NULL
);
147 // Initialilze varname for Name/Value or EFI Variable
149 if ((Statement
->Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) ||
150 (Statement
->Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
)) {
151 Statement
->VariableName
= GetToken (Statement
->VarStoreInfo
.VarName
, FormSet
->HiiHandle
);
152 ASSERT (Statement
->VariableName
!= NULL
);
154 if (Statement
->Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
156 // Check whether old string node already exist.
159 if (!IsListEmpty(&Statement
->Storage
->NameValueListHead
)) {
160 Link
= GetFirstNode (&Statement
->Storage
->NameValueListHead
);
161 while (!IsNull (&Statement
->Storage
->NameValueListHead
, Link
)) {
162 NameValueNode
= NAME_VALUE_NODE_FROM_LINK (Link
);
164 if (StrCmp (Statement
->VariableName
, NameValueNode
->Name
) == 0) {
169 Link
= GetNextNode (&Statement
->Storage
->NameValueListHead
, Link
);
175 // Insert to Name/Value varstore list
177 NameValueNode
= AllocateZeroPool (sizeof (NAME_VALUE_NODE
));
178 ASSERT (NameValueNode
!= NULL
);
179 NameValueNode
->Signature
= NAME_VALUE_NODE_SIGNATURE
;
180 NameValueNode
->Name
= AllocateCopyPool (StrSize (Statement
->VariableName
), Statement
->VariableName
);
181 ASSERT (NameValueNode
->Name
!= NULL
);
182 NameValueNode
->Value
= AllocateZeroPool (0x10);
183 ASSERT (NameValueNode
->Value
!= NULL
);
184 NameValueNode
->EditValue
= AllocateZeroPool (0x10);
185 ASSERT (NameValueNode
->EditValue
!= NULL
);
187 InsertTailList (&Statement
->Storage
->NameValueListHead
, &NameValueNode
->Link
);
197 Allocate a FORM_EXPRESSION node.
199 @param Form The Form associated with this Expression
200 @param OpCode The binary opcode data.
202 @return Pointer to a FORM_EXPRESSION data structure.
207 IN OUT FORM_BROWSER_FORM
*Form
,
211 FORM_EXPRESSION
*Expression
;
213 Expression
= AllocateZeroPool (sizeof (FORM_EXPRESSION
));
214 ASSERT (Expression
!= NULL
);
215 Expression
->Signature
= FORM_EXPRESSION_SIGNATURE
;
216 InitializeListHead (&Expression
->OpCodeListHead
);
217 Expression
->OpCode
= (EFI_IFR_OP_HEADER
*) OpCode
;
223 Create ConfigHdr string for a storage.
225 @param FormSet Pointer of the current FormSet
226 @param Storage Pointer of the storage
228 @retval EFI_SUCCESS Initialize ConfigHdr success
232 InitializeConfigHdr (
233 IN FORM_BROWSER_FORMSET
*FormSet
,
234 IN OUT FORMSET_STORAGE
*Storage
239 if (Storage
->BrowserStorage
->Type
== EFI_HII_VARSTORE_BUFFER
||
240 Storage
->BrowserStorage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
241 Name
= Storage
->BrowserStorage
->Name
;
246 Storage
->ConfigHdr
= HiiConstructConfigHdr (
247 &Storage
->BrowserStorage
->Guid
,
249 FormSet
->DriverHandle
252 if (Storage
->ConfigHdr
== NULL
) {
253 return EFI_NOT_FOUND
;
260 Find the global storage link base on the input storate type, name and guid.
262 For EFI_HII_VARSTORE_EFI_VARIABLE and EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER,
263 same guid + name = same storage
265 For EFI_HII_VARSTORE_NAME_VALUE:
266 same guid + HiiHandle = same storage
268 For EFI_HII_VARSTORE_BUFFER:
269 same guid + name + HiiHandle = same storage
271 @param StorageType Storage type.
272 @param StorageGuid Storage guid.
273 @param StorageName Storage Name.
274 @param HiiHandle HiiHandle for this varstore.
276 @return Pointer to a GLOBAL_STORAGE data structure.
281 IN UINT8 StorageType
,
282 IN EFI_GUID
*StorageGuid
,
283 IN CHAR16
*StorageName
,
284 IN EFI_HII_HANDLE HiiHandle
288 BROWSER_STORAGE
*BrowserStorage
;
290 Link
= GetFirstNode (&gBrowserStorageList
);
291 while (!IsNull (&gBrowserStorageList
, Link
)) {
292 BrowserStorage
= BROWSER_STORAGE_FROM_LINK (Link
);
293 Link
= GetNextNode (&gBrowserStorageList
, Link
);
295 if ((BrowserStorage
->Type
== StorageType
) && CompareGuid (&BrowserStorage
->Guid
, StorageGuid
)) {
296 if (StorageType
== EFI_HII_VARSTORE_NAME_VALUE
) {
297 if (BrowserStorage
->HiiHandle
== HiiHandle
) {
298 return BrowserStorage
;
304 ASSERT (StorageName
!= NULL
);
305 if (StrCmp (BrowserStorage
->Name
, StorageName
) == 0) {
306 if (StorageType
== EFI_HII_VARSTORE_EFI_VARIABLE
|| StorageType
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
307 return BrowserStorage
;
308 } else if (StorageType
== EFI_HII_VARSTORE_BUFFER
&& BrowserStorage
->HiiHandle
== HiiHandle
) {
309 return BrowserStorage
;
319 Intialize the Global Storage.
321 @param BrowserStorage Pointer to the global storage.
322 @param StorageType Storage type.
323 @param OpCodeData Binary data for this opcode.
327 IntializeBrowserStorage (
328 IN BROWSER_STORAGE
*BrowserStorage
,
329 IN UINT8 StorageType
,
333 switch (StorageType
) {
334 case EFI_HII_VARSTORE_BUFFER
:
335 CopyMem (&BrowserStorage
->Guid
, &((EFI_IFR_VARSTORE
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
336 CopyMem (&BrowserStorage
->Size
, &((EFI_IFR_VARSTORE
*) OpCodeData
)->Size
, sizeof (UINT16
));
338 BrowserStorage
->Buffer
= AllocateZeroPool (BrowserStorage
->Size
);
339 BrowserStorage
->EditBuffer
= AllocateZeroPool (BrowserStorage
->Size
);
342 case EFI_HII_VARSTORE_EFI_VARIABLE
:
343 case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
:
344 CopyMem (&BrowserStorage
->Guid
, &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
345 CopyMem (&BrowserStorage
->Attributes
, &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Attributes
, sizeof (UINT32
));
346 CopyMem (&BrowserStorage
->Size
, &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Size
, sizeof (UINT16
));
348 if (StorageType
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
349 BrowserStorage
->Buffer
= AllocateZeroPool (BrowserStorage
->Size
);
350 BrowserStorage
->EditBuffer
= AllocateZeroPool (BrowserStorage
->Size
);
354 case EFI_HII_VARSTORE_NAME_VALUE
:
355 CopyMem (&BrowserStorage
->Guid
, &((EFI_IFR_VARSTORE_NAME_VALUE
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
357 InitializeListHead (&BrowserStorage
->NameValueListHead
);
367 Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List.
369 @param FormSet Pointer of the current FormSet
370 @param StorageType Storage type.
371 @param OpCodeData Binary data for this opcode.
373 @return Pointer to a FORMSET_STORAGE data structure.
378 IN FORM_BROWSER_FORMSET
*FormSet
,
379 IN UINT8 StorageType
,
383 FORMSET_STORAGE
*Storage
;
384 CHAR16
*UnicodeString
;
386 BROWSER_STORAGE
*BrowserStorage
;
387 EFI_GUID
*StorageGuid
;
390 UnicodeString
= NULL
;
392 switch (StorageType
) {
393 case EFI_HII_VARSTORE_BUFFER
:
394 StorageGuid
= (EFI_GUID
*) (CHAR8
*) &((EFI_IFR_VARSTORE
*) OpCodeData
)->Guid
;
395 StorageName
= (CHAR8
*) ((EFI_IFR_VARSTORE
*) OpCodeData
)->Name
;
398 case EFI_HII_VARSTORE_EFI_VARIABLE
:
399 case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
:
400 StorageGuid
= (EFI_GUID
*) (CHAR8
*) &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Guid
;
401 StorageName
= (CHAR8
*) ((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->Name
;
405 ASSERT (StorageType
== EFI_HII_VARSTORE_NAME_VALUE
);
406 StorageGuid
= &((EFI_IFR_VARSTORE_NAME_VALUE
*) OpCodeData
)->Guid
;
410 if (StorageType
!= EFI_HII_VARSTORE_NAME_VALUE
) {
411 ASSERT (StorageName
!= NULL
);
413 UnicodeString
= AllocateZeroPool (AsciiStrSize (StorageName
) * 2);
414 ASSERT (UnicodeString
!= NULL
);
415 for (Index
= 0; StorageName
[Index
] != 0; Index
++) {
416 UnicodeString
[Index
] = (CHAR16
) StorageName
[Index
];
420 Storage
= AllocateZeroPool (sizeof (FORMSET_STORAGE
));
421 ASSERT (Storage
!= NULL
);
422 Storage
->Signature
= FORMSET_STORAGE_SIGNATURE
;
423 InsertTailList (&FormSet
->StorageListHead
, &Storage
->Link
);
425 BrowserStorage
= FindStorageInList(StorageType
, StorageGuid
, UnicodeString
, FormSet
->HiiHandle
);
426 if (BrowserStorage
== NULL
) {
427 BrowserStorage
= AllocateZeroPool (sizeof (BROWSER_STORAGE
));
428 ASSERT (BrowserStorage
!= NULL
);
430 BrowserStorage
->Signature
= BROWSER_STORAGE_SIGNATURE
;
431 InsertTailList (&gBrowserStorageList
, &BrowserStorage
->Link
);
433 IntializeBrowserStorage (BrowserStorage
, StorageType
, OpCodeData
);
434 BrowserStorage
->Type
= StorageType
;
435 if (StorageType
!= EFI_HII_VARSTORE_NAME_VALUE
) {
436 BrowserStorage
->Name
= UnicodeString
;
439 BrowserStorage
->HiiHandle
= FormSet
->HiiHandle
;
441 BrowserStorage
->Initialized
= FALSE
;
444 Storage
->BrowserStorage
= BrowserStorage
;
445 InitializeConfigHdr (FormSet
, Storage
);
446 Storage
->ConfigRequest
= AllocateCopyPool (StrSize (Storage
->ConfigHdr
), Storage
->ConfigHdr
);
447 Storage
->SpareStrLen
= 0;
453 Get Formset_storage base on the input varstoreid info.
455 @param FormSet Pointer of the current FormSet.
456 @param VarStoreId Varstore ID info.
458 @return Pointer to a FORMSET_STORAGE data structure.
463 IN FORM_BROWSER_FORMSET
*FormSet
,
464 IN EFI_VARSTORE_ID VarStoreId
467 FORMSET_STORAGE
*FormsetStorage
;
472 FormsetStorage
= NULL
;
474 // Find Formset Storage for this Question
476 Link
= GetFirstNode (&FormSet
->StorageListHead
);
477 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
478 FormsetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
480 if (FormsetStorage
->VarStoreId
== VarStoreId
) {
485 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
488 return Found
? FormsetStorage
: NULL
;
492 Get Formset_storage base on the input browser storage.
494 More than one formsets may share the same browser storage,
495 this function just get the first formset storage which
496 share the browser storage.
498 @param Storage browser storage info.
500 @return Pointer to a FORMSET_STORAGE data structure.
505 GetFstStgFromBrsStg (
506 IN BROWSER_STORAGE
*Storage
509 FORMSET_STORAGE
*FormsetStorage
;
511 LIST_ENTRY
*FormsetLink
;
512 FORM_BROWSER_FORMSET
*FormSet
;
516 FormsetStorage
= NULL
;
518 FormsetLink
= GetFirstNode (&gBrowserFormSetList
);
519 while (!IsNull (&gBrowserFormSetList
, FormsetLink
)) {
520 FormSet
= FORM_BROWSER_FORMSET_FROM_LINK (FormsetLink
);
521 FormsetLink
= GetNextNode (&gBrowserFormSetList
, FormsetLink
);
523 Link
= GetFirstNode (&FormSet
->StorageListHead
);
524 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
525 FormsetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
526 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
528 if (FormsetStorage
->BrowserStorage
== Storage
) {
539 return Found
? FormsetStorage
: NULL
;
543 Initialize Request Element of a Question. <RequestElement> ::= '&'<BlockName> | '&'<Label>
545 @param FormSet Pointer of the current FormSet.
546 @param Question The Question to be initialized.
547 @param Form Pointer of the current form.
549 @retval EFI_SUCCESS Function success.
550 @retval EFI_INVALID_PARAMETER No storage associated with the Question.
554 InitializeRequestElement (
555 IN OUT FORM_BROWSER_FORMSET
*FormSet
,
556 IN OUT FORM_BROWSER_STATEMENT
*Question
,
557 IN OUT FORM_BROWSER_FORM
*Form
560 BROWSER_STORAGE
*Storage
;
561 FORMSET_STORAGE
*FormsetStorage
;
565 CHAR16 RequestElement
[30];
568 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
571 Storage
= Question
->Storage
;
572 if (Storage
== NULL
) {
573 return EFI_INVALID_PARAMETER
;
576 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
578 // <ConfigRequest> is unnecessary for EFI variable storage,
579 // GetVariable()/SetVariable() will be used to retrieve/save values
585 // Prepare <RequestElement>
587 if (Storage
->Type
== EFI_HII_VARSTORE_BUFFER
||
588 Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
589 StrLen
= UnicodeSPrint (
591 30 * sizeof (CHAR16
),
592 L
"&OFFSET=%04x&WIDTH=%04x",
593 Question
->VarStoreInfo
.VarOffset
,
594 Question
->StorageWidth
596 HiiToLower(RequestElement
);
597 Question
->BlockName
= AllocateCopyPool ((StrLen
+ 1) * sizeof (CHAR16
), RequestElement
);
599 StrLen
= UnicodeSPrint (RequestElement
, 30 * sizeof (CHAR16
), L
"&%s", Question
->VariableName
);
602 if ((Question
->Operand
== EFI_IFR_PASSWORD_OP
) && ((Question
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
)) {
604 // Password with CALLBACK flag is stored in encoded format,
605 // so don't need to append it to <ConfigRequest>
611 // Find Formset Storage for this Question
613 FormsetStorage
= GetFstStgFromVarId(FormSet
, Question
->VarStoreId
);
614 ASSERT (FormsetStorage
!= NULL
);
615 StringSize
= (FormsetStorage
->ConfigRequest
!= NULL
) ? StrSize (FormsetStorage
->ConfigRequest
) : sizeof (CHAR16
);
616 MaxLen
= StringSize
/ sizeof (CHAR16
) + FormsetStorage
->SpareStrLen
;
619 // Append <RequestElement> to <ConfigRequest>
621 if (StrLen
> FormsetStorage
->SpareStrLen
) {
623 // Old String buffer is not sufficient for RequestElement, allocate a new one
625 MaxLen
= StringSize
/ sizeof (CHAR16
) + CONFIG_REQUEST_STRING_INCREMENTAL
;
626 NewStr
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
627 ASSERT (NewStr
!= NULL
);
628 if (FormsetStorage
->ConfigRequest
!= NULL
) {
629 CopyMem (NewStr
, FormsetStorage
->ConfigRequest
, StringSize
);
630 FreePool (FormsetStorage
->ConfigRequest
);
632 FormsetStorage
->ConfigRequest
= NewStr
;
633 FormsetStorage
->SpareStrLen
= CONFIG_REQUEST_STRING_INCREMENTAL
;
636 StrCatS (FormsetStorage
->ConfigRequest
, MaxLen
, RequestElement
);
637 FormsetStorage
->ElementCount
++;
638 FormsetStorage
->SpareStrLen
-= StrLen
;
641 // Update the Config Request info saved in the form.
645 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
646 while (!IsNull (&Form
->ConfigRequestHead
, Link
)) {
647 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
649 if (ConfigInfo
!= NULL
&& ConfigInfo
->Storage
== FormsetStorage
->BrowserStorage
) {
654 Link
= GetNextNode (&Form
->ConfigRequestHead
, Link
);
658 ConfigInfo
= AllocateZeroPool(sizeof (FORM_BROWSER_CONFIG_REQUEST
));
659 ASSERT (ConfigInfo
!= NULL
);
660 ConfigInfo
->Signature
= FORM_BROWSER_CONFIG_REQUEST_SIGNATURE
;
661 ConfigInfo
->ConfigRequest
= AllocateCopyPool (StrSize (FormsetStorage
->ConfigHdr
), FormsetStorage
->ConfigHdr
);
662 ASSERT (ConfigInfo
->ConfigRequest
!= NULL
);
663 ConfigInfo
->SpareStrLen
= 0;
664 ConfigInfo
->Storage
= FormsetStorage
->BrowserStorage
;
665 InsertTailList(&Form
->ConfigRequestHead
, &ConfigInfo
->Link
);
667 StringSize
= (ConfigInfo
->ConfigRequest
!= NULL
) ? StrSize (ConfigInfo
->ConfigRequest
) : sizeof (CHAR16
);
668 MaxLen
= StringSize
/ sizeof (CHAR16
) + ConfigInfo
->SpareStrLen
;
671 // Append <RequestElement> to <ConfigRequest>
673 if (StrLen
> ConfigInfo
->SpareStrLen
) {
675 // Old String buffer is not sufficient for RequestElement, allocate a new one
677 MaxLen
= StringSize
/ sizeof (CHAR16
) + CONFIG_REQUEST_STRING_INCREMENTAL
;
678 NewStr
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
679 ASSERT (NewStr
!= NULL
);
680 if (ConfigInfo
->ConfigRequest
!= NULL
) {
681 CopyMem (NewStr
, ConfigInfo
->ConfigRequest
, StringSize
);
682 FreePool (ConfigInfo
->ConfigRequest
);
684 ConfigInfo
->ConfigRequest
= NewStr
;
685 ConfigInfo
->SpareStrLen
= CONFIG_REQUEST_STRING_INCREMENTAL
;
688 StrCatS (ConfigInfo
->ConfigRequest
, MaxLen
, RequestElement
);
689 ConfigInfo
->ElementCount
++;
690 ConfigInfo
->SpareStrLen
-= StrLen
;
696 Free resources of a Expression.
698 @param FormSet Pointer of the Expression
703 IN FORM_EXPRESSION
*Expression
707 EXPRESSION_OPCODE
*OpCode
;
708 LIST_ENTRY
*SubExpressionLink
;
709 FORM_EXPRESSION
*SubExpression
;
711 while (!IsListEmpty (&Expression
->OpCodeListHead
)) {
712 Link
= GetFirstNode (&Expression
->OpCodeListHead
);
713 OpCode
= EXPRESSION_OPCODE_FROM_LINK (Link
);
714 RemoveEntryList (&OpCode
->Link
);
716 if (OpCode
->ValueList
!= NULL
) {
717 FreePool (OpCode
->ValueList
);
720 if (OpCode
->ValueName
!= NULL
) {
721 FreePool (OpCode
->ValueName
);
724 if (OpCode
->MapExpressionList
.ForwardLink
!= NULL
) {
725 while (!IsListEmpty (&OpCode
->MapExpressionList
)) {
726 SubExpressionLink
= GetFirstNode(&OpCode
->MapExpressionList
);
727 SubExpression
= FORM_EXPRESSION_FROM_LINK (SubExpressionLink
);
728 RemoveEntryList(&SubExpression
->Link
);
729 DestroyExpression (SubExpression
);
735 // Free this Expression
737 FreePool (Expression
);
741 Free resources of a storage.
743 @param Storage Pointer of the storage
748 IN FORMSET_STORAGE
*Storage
751 if (Storage
== NULL
) {
755 if (Storage
->ConfigRequest
!= NULL
) {
756 FreePool (Storage
->ConfigRequest
);
764 Free resources of a Statement.
766 @param FormSet Pointer of the FormSet
767 @param Statement Pointer of the Statement
772 IN FORM_BROWSER_FORMSET
*FormSet
,
773 IN OUT FORM_BROWSER_STATEMENT
*Statement
777 QUESTION_DEFAULT
*Default
;
778 QUESTION_OPTION
*Option
;
779 FORM_EXPRESSION
*Expression
;
782 // Free Default value List
784 while (!IsListEmpty (&Statement
->DefaultListHead
)) {
785 Link
= GetFirstNode (&Statement
->DefaultListHead
);
786 Default
= QUESTION_DEFAULT_FROM_LINK (Link
);
787 RemoveEntryList (&Default
->Link
);
789 if (Default
->Value
.Buffer
!= NULL
) {
790 FreePool (Default
->Value
.Buffer
);
798 while (!IsListEmpty (&Statement
->OptionListHead
)) {
799 Link
= GetFirstNode (&Statement
->OptionListHead
);
800 Option
= QUESTION_OPTION_FROM_LINK (Link
);
801 if (Option
->SuppressExpression
!= NULL
) {
802 FreePool (Option
->SuppressExpression
);
804 RemoveEntryList (&Option
->Link
);
810 // Free Inconsistent List
812 while (!IsListEmpty (&Statement
->InconsistentListHead
)) {
813 Link
= GetFirstNode (&Statement
->InconsistentListHead
);
814 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
815 RemoveEntryList (&Expression
->Link
);
817 DestroyExpression (Expression
);
821 // Free NoSubmit List
823 while (!IsListEmpty (&Statement
->NoSubmitListHead
)) {
824 Link
= GetFirstNode (&Statement
->NoSubmitListHead
);
825 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
826 RemoveEntryList (&Expression
->Link
);
828 DestroyExpression (Expression
);
832 // Free WarningIf List
834 while (!IsListEmpty (&Statement
->WarningListHead
)) {
835 Link
= GetFirstNode (&Statement
->WarningListHead
);
836 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
837 RemoveEntryList (&Expression
->Link
);
839 DestroyExpression (Expression
);
842 if (Statement
->Expression
!= NULL
) {
843 FreePool (Statement
->Expression
);
846 if (Statement
->VariableName
!= NULL
) {
847 FreePool (Statement
->VariableName
);
849 if (Statement
->BlockName
!= NULL
) {
850 FreePool (Statement
->BlockName
);
852 if (Statement
->BufferValue
!= NULL
) {
853 FreePool (Statement
->BufferValue
);
855 if (Statement
->Operand
== EFI_IFR_STRING_OP
|| Statement
->Operand
== EFI_IFR_PASSWORD_OP
) {
856 DeleteString(Statement
->HiiValue
.Value
.string
, FormSet
->HiiHandle
);
862 Free resources of a Form.
864 @param FormSet Pointer of the FormSet
865 @param Form Pointer of the Form.
870 IN FORM_BROWSER_FORMSET
*FormSet
,
871 IN OUT FORM_BROWSER_FORM
*Form
875 FORM_EXPRESSION
*Expression
;
876 FORM_BROWSER_STATEMENT
*Statement
;
877 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
880 // Free Form Expressions
882 while (!IsListEmpty (&Form
->ExpressionListHead
)) {
883 Link
= GetFirstNode (&Form
->ExpressionListHead
);
884 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
885 RemoveEntryList (&Expression
->Link
);
887 DestroyExpression (Expression
);
891 // Free Statements/Questions
893 while (!IsListEmpty (&Form
->StatementListHead
)) {
894 Link
= GetFirstNode (&Form
->StatementListHead
);
895 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
896 RemoveEntryList (&Statement
->Link
);
898 DestroyStatement (FormSet
, Statement
);
902 // Free ConfigRequest string.
904 while (!IsListEmpty (&Form
->ConfigRequestHead
)) {
905 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
906 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
907 RemoveEntryList (&ConfigInfo
->Link
);
909 FreePool (ConfigInfo
->ConfigRequest
);
910 FreePool (ConfigInfo
);
913 if (Form
->SuppressExpression
!= NULL
) {
914 FreePool (Form
->SuppressExpression
);
917 UiFreeMenuList (&Form
->FormViewListHead
);
927 Free resources allocated for a FormSet.
929 @param FormSet Pointer of the FormSet
934 IN OUT FORM_BROWSER_FORMSET
*FormSet
938 FORMSET_STORAGE
*Storage
;
939 FORMSET_DEFAULTSTORE
*DefaultStore
;
940 FORM_EXPRESSION
*Expression
;
941 FORM_BROWSER_FORM
*Form
;
943 if (FormSet
->IfrBinaryData
== NULL
) {
945 // Uninitialized FormSet
952 // Free IFR binary buffer
954 FreePool (FormSet
->IfrBinaryData
);
957 // Free FormSet Storage
959 if (FormSet
->StorageListHead
.ForwardLink
!= NULL
) {
960 while (!IsListEmpty (&FormSet
->StorageListHead
)) {
961 Link
= GetFirstNode (&FormSet
->StorageListHead
);
962 Storage
= FORMSET_STORAGE_FROM_LINK (Link
);
963 RemoveEntryList (&Storage
->Link
);
965 DestroyStorage (Storage
);
970 // Free FormSet Default Store
972 if (FormSet
->DefaultStoreListHead
.ForwardLink
!= NULL
) {
973 while (!IsListEmpty (&FormSet
->DefaultStoreListHead
)) {
974 Link
= GetFirstNode (&FormSet
->DefaultStoreListHead
);
975 DefaultStore
= FORMSET_DEFAULTSTORE_FROM_LINK (Link
);
976 RemoveEntryList (&DefaultStore
->Link
);
978 FreePool (DefaultStore
);
983 // Free Formset Expressions
985 while (!IsListEmpty (&FormSet
->ExpressionListHead
)) {
986 Link
= GetFirstNode (&FormSet
->ExpressionListHead
);
987 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
988 RemoveEntryList (&Expression
->Link
);
990 DestroyExpression (Expression
);
996 if (FormSet
->FormListHead
.ForwardLink
!= NULL
) {
997 while (!IsListEmpty (&FormSet
->FormListHead
)) {
998 Link
= GetFirstNode (&FormSet
->FormListHead
);
999 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
1000 RemoveEntryList (&Form
->Link
);
1002 DestroyForm (FormSet
, Form
);
1006 if (FormSet
->StatementBuffer
!= NULL
) {
1007 FreePool (FormSet
->StatementBuffer
);
1009 if (FormSet
->ExpressionBuffer
!= NULL
) {
1010 FreePool (FormSet
->ExpressionBuffer
);
1018 Tell whether this Operand is an Expression OpCode or not
1020 @param Operand Operand of an IFR OpCode.
1022 @retval TRUE This is an Expression OpCode.
1023 @retval FALSE Not an Expression OpCode.
1027 IsExpressionOpCode (
1031 if (((Operand
>= EFI_IFR_EQ_ID_VAL_OP
) && (Operand
<= EFI_IFR_NOT_OP
)) ||
1032 ((Operand
>= EFI_IFR_MATCH_OP
) && (Operand
<= EFI_IFR_SET_OP
)) ||
1033 ((Operand
>= EFI_IFR_EQUAL_OP
) && (Operand
<= EFI_IFR_SPAN_OP
)) ||
1034 (Operand
== EFI_IFR_CATENATE_OP
) ||
1035 (Operand
== EFI_IFR_TO_LOWER_OP
) ||
1036 (Operand
== EFI_IFR_TO_UPPER_OP
) ||
1037 (Operand
== EFI_IFR_MAP_OP
) ||
1038 (Operand
== EFI_IFR_VERSION_OP
) ||
1039 (Operand
== EFI_IFR_SECURITY_OP
) ||
1040 (Operand
== EFI_IFR_MATCH2_OP
)) {
1048 Tell whether this Operand is an Statement OpCode.
1050 @param Operand Operand of an IFR OpCode.
1052 @retval TRUE This is an Statement OpCode.
1053 @retval FALSE Not an Statement OpCode.
1061 if ((Operand
== EFI_IFR_SUBTITLE_OP
) ||
1062 (Operand
== EFI_IFR_TEXT_OP
) ||
1063 (Operand
== EFI_IFR_RESET_BUTTON_OP
) ||
1064 (Operand
== EFI_IFR_REF_OP
) ||
1065 (Operand
== EFI_IFR_ACTION_OP
) ||
1066 (Operand
== EFI_IFR_NUMERIC_OP
) ||
1067 (Operand
== EFI_IFR_ORDERED_LIST_OP
) ||
1068 (Operand
== EFI_IFR_CHECKBOX_OP
) ||
1069 (Operand
== EFI_IFR_STRING_OP
) ||
1070 (Operand
== EFI_IFR_PASSWORD_OP
) ||
1071 (Operand
== EFI_IFR_DATE_OP
) ||
1072 (Operand
== EFI_IFR_TIME_OP
) ||
1073 (Operand
== EFI_IFR_GUID_OP
) ||
1074 (Operand
== EFI_IFR_ONE_OF_OP
)) {
1082 Tell whether this Operand is an known OpCode.
1084 @param Operand Operand of an IFR OpCode.
1086 @retval TRUE This is an Statement OpCode.
1087 @retval FALSE Not an Statement OpCode.
1095 return Operand
> EFI_IFR_MATCH2_OP
? TRUE
: FALSE
;
1099 Calculate number of Statemens(Questions) and Expression OpCodes.
1101 @param FormSet The FormSet to be counted.
1102 @param NumberOfStatement Number of Statemens(Questions)
1103 @param NumberOfExpression Number of Expression OpCodes
1108 IN FORM_BROWSER_FORMSET
*FormSet
,
1109 IN OUT UINT16
*NumberOfStatement
,
1110 IN OUT UINT16
*NumberOfExpression
1113 UINT16 StatementCount
;
1114 UINT16 ExpressionCount
;
1121 ExpressionCount
= 0;
1123 while (Offset
< FormSet
->IfrBinaryLength
) {
1124 OpCodeData
= FormSet
->IfrBinaryData
+ Offset
;
1125 OpCodeLen
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
1126 Offset
+= OpCodeLen
;
1128 if (IsExpressionOpCode (((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
)) {
1135 *NumberOfStatement
= StatementCount
;
1136 *NumberOfExpression
= ExpressionCount
;
1142 Parse opcodes in the formset IFR binary.
1144 @param FormSet Pointer of the FormSet data structure.
1146 @retval EFI_SUCCESS Opcode parse success.
1147 @retval Other Opcode parse fail.
1152 IN FORM_BROWSER_FORMSET
*FormSet
1156 FORM_BROWSER_FORM
*CurrentForm
;
1157 FORM_BROWSER_STATEMENT
*CurrentStatement
;
1158 FORM_BROWSER_STATEMENT
*ParentStatement
;
1159 EXPRESSION_OPCODE
*ExpressionOpCode
;
1160 FORM_EXPRESSION
*CurrentExpression
;
1167 FORMSET_STORAGE
*Storage
;
1168 FORMSET_DEFAULTSTORE
*DefaultStore
;
1169 QUESTION_DEFAULT
*CurrentDefault
;
1170 QUESTION_OPTION
*CurrentOption
;
1172 UINT16 NumberOfStatement
;
1173 UINT16 NumberOfExpression
;
1174 EFI_IMAGE_ID
*ImageId
;
1175 BOOLEAN SuppressForQuestion
;
1176 BOOLEAN SuppressForOption
;
1177 UINT16 DepthOfDisable
;
1178 BOOLEAN OpCodeDisabled
;
1179 BOOLEAN SingleOpCodeExpression
;
1180 BOOLEAN InScopeDefault
;
1181 EFI_HII_VALUE
*Value
;
1182 EFI_IFR_FORM_MAP_METHOD
*MapMethod
;
1183 UINT8 MapScopeDepth
;
1185 FORMSET_STORAGE
*VarStorage
;
1186 LIST_ENTRY
*MapExpressionList
;
1187 EFI_VARSTORE_ID TempVarstoreId
;
1188 BOOLEAN InScopeDisable
;
1189 INTN ConditionalExprCount
;
1190 BOOLEAN InUnknownScope
;
1192 FORMSET_DEFAULTSTORE
*PreDefaultStore
;
1193 LIST_ENTRY
*DefaultLink
;
1194 BOOLEAN HaveInserted
;
1196 BOOLEAN QuestionReferBitField
;
1198 SuppressForQuestion
= FALSE
;
1199 SuppressForOption
= FALSE
;
1200 InScopeDisable
= FALSE
;
1202 OpCodeDisabled
= FALSE
;
1203 SingleOpCodeExpression
= FALSE
;
1204 InScopeDefault
= FALSE
;
1205 CurrentExpression
= NULL
;
1206 CurrentDefault
= NULL
;
1207 CurrentOption
= NULL
;
1213 MapExpressionList
= NULL
;
1215 ConditionalExprCount
= 0;
1216 InUnknownScope
= FALSE
;
1218 QuestionReferBitField
= FALSE
;
1221 // Get the number of Statements and Expressions
1223 CountOpCodes (FormSet
, &NumberOfStatement
, &NumberOfExpression
);
1225 mStatementIndex
= 0;
1226 mUsedQuestionId
= 1;
1227 FormSet
->StatementBuffer
= AllocateZeroPool (NumberOfStatement
* sizeof (FORM_BROWSER_STATEMENT
));
1228 if (FormSet
->StatementBuffer
== NULL
) {
1229 return EFI_OUT_OF_RESOURCES
;
1232 mExpressionOpCodeIndex
= 0;
1233 FormSet
->ExpressionBuffer
= AllocateZeroPool (NumberOfExpression
* sizeof (EXPRESSION_OPCODE
));
1234 if (FormSet
->ExpressionBuffer
== NULL
) {
1235 return EFI_OUT_OF_RESOURCES
;
1238 InitializeListHead (&FormSet
->StatementListOSF
);
1239 InitializeListHead (&FormSet
->StorageListHead
);
1240 InitializeListHead (&FormSet
->SaveFailStorageListHead
);
1241 InitializeListHead (&FormSet
->DefaultStoreListHead
);
1242 InitializeListHead (&FormSet
->FormListHead
);
1243 InitializeListHead (&FormSet
->ExpressionListHead
);
1244 ResetCurrentExpressionStack ();
1245 ResetMapExpressionListStack ();
1248 CurrentStatement
= NULL
;
1249 ParentStatement
= NULL
;
1254 while (OpCodeOffset
< FormSet
->IfrBinaryLength
) {
1255 OpCodeData
= FormSet
->IfrBinaryData
+ OpCodeOffset
;
1257 OpCodeLength
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
1258 OpCodeOffset
+= OpCodeLength
;
1259 Operand
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
;
1260 Scope
= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Scope
;
1262 if (InUnknownScope
) {
1263 if (Operand
== EFI_IFR_END_OP
) {
1266 if (UnknownDepth
== 0) {
1267 InUnknownScope
= FALSE
;
1278 if (IsUnKnownOpCode(Operand
)) {
1280 InUnknownScope
= TRUE
;
1288 // If scope bit set, push onto scope stack
1291 PushScope (Operand
);
1294 if (OpCodeDisabled
) {
1296 // DisableIf Expression is evaluated to be TRUE, try to find its end.
1297 // Here only cares the EFI_IFR_DISABLE_IF and EFI_IFR_END
1299 if (Operand
== EFI_IFR_DISABLE_IF_OP
) {
1301 } else if (Operand
== EFI_IFR_END_OP
) {
1302 Status
= PopScope (&ScopeOpCode
);
1303 if (EFI_ERROR (Status
)) {
1307 if (ScopeOpCode
== EFI_IFR_DISABLE_IF_OP
) {
1308 if (DepthOfDisable
== 0) {
1309 InScopeDisable
= FALSE
;
1310 OpCodeDisabled
= FALSE
;
1319 if (IsExpressionOpCode (Operand
)) {
1320 ExpressionOpCode
= &FormSet
->ExpressionBuffer
[mExpressionOpCodeIndex
];
1321 mExpressionOpCodeIndex
++;
1323 ExpressionOpCode
->Signature
= EXPRESSION_OPCODE_SIGNATURE
;
1324 ExpressionOpCode
->Operand
= Operand
;
1325 Value
= &ExpressionOpCode
->Value
;
1328 case EFI_IFR_EQ_ID_VAL_OP
:
1329 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1331 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1332 CopyMem (&Value
->Value
.u16
, &((EFI_IFR_EQ_ID_VAL
*) OpCodeData
)->Value
, sizeof (UINT16
));
1335 case EFI_IFR_EQ_ID_ID_OP
:
1336 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_ID
*) OpCodeData
)->QuestionId1
, sizeof (EFI_QUESTION_ID
));
1337 CopyMem (&ExpressionOpCode
->QuestionId2
, &((EFI_IFR_EQ_ID_ID
*) OpCodeData
)->QuestionId2
, sizeof (EFI_QUESTION_ID
));
1340 case EFI_IFR_EQ_ID_VAL_LIST_OP
:
1341 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1342 CopyMem (&ExpressionOpCode
->ListLength
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->ListLength
, sizeof (UINT16
));
1343 ExpressionOpCode
->ValueList
= AllocateCopyPool (ExpressionOpCode
->ListLength
* sizeof (UINT16
), &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->ValueList
);
1346 case EFI_IFR_TO_STRING_OP
:
1347 case EFI_IFR_FIND_OP
:
1348 ExpressionOpCode
->Format
= (( EFI_IFR_TO_STRING
*) OpCodeData
)->Format
;
1351 case EFI_IFR_STRING_REF1_OP
:
1352 Value
->Type
= EFI_IFR_TYPE_STRING
;
1353 CopyMem (&Value
->Value
.string
, &(( EFI_IFR_STRING_REF1
*) OpCodeData
)->StringId
, sizeof (EFI_STRING_ID
));
1356 case EFI_IFR_RULE_REF_OP
:
1357 ExpressionOpCode
->RuleId
= (( EFI_IFR_RULE_REF
*) OpCodeData
)->RuleId
;
1360 case EFI_IFR_SPAN_OP
:
1361 ExpressionOpCode
->Flags
= (( EFI_IFR_SPAN
*) OpCodeData
)->Flags
;
1364 case EFI_IFR_THIS_OP
:
1365 ASSERT (ParentStatement
!= NULL
);
1366 ExpressionOpCode
->QuestionId
= ParentStatement
->QuestionId
;
1369 case EFI_IFR_SECURITY_OP
:
1370 CopyMem (&ExpressionOpCode
->Guid
, &((EFI_IFR_SECURITY
*) OpCodeData
)->Permissions
, sizeof (EFI_GUID
));
1373 case EFI_IFR_MATCH2_OP
:
1374 CopyMem (&ExpressionOpCode
->Guid
, &((EFI_IFR_MATCH2
*) OpCodeData
)->SyntaxType
, sizeof (EFI_GUID
));
1377 case EFI_IFR_GET_OP
:
1378 case EFI_IFR_SET_OP
:
1379 CopyMem (&TempVarstoreId
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreId
, sizeof (TempVarstoreId
));
1380 if (TempVarstoreId
!= 0) {
1381 if (FormSet
->StorageListHead
.ForwardLink
!= NULL
) {
1382 Link
= GetFirstNode (&FormSet
->StorageListHead
);
1383 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
1384 VarStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
1385 if (VarStorage
->VarStoreId
== ((EFI_IFR_GET
*) OpCodeData
)->VarStoreId
) {
1386 ExpressionOpCode
->VarStorage
= VarStorage
->BrowserStorage
;
1389 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
1392 if (ExpressionOpCode
->VarStorage
== NULL
) {
1394 // VarStorage is not found.
1396 return EFI_INVALID_PARAMETER
;
1399 ExpressionOpCode
->ValueType
= ((EFI_IFR_GET
*) OpCodeData
)->VarStoreType
;
1400 switch (ExpressionOpCode
->ValueType
) {
1401 case EFI_IFR_TYPE_BOOLEAN
:
1402 case EFI_IFR_TYPE_NUM_SIZE_8
:
1403 ExpressionOpCode
->ValueWidth
= 1;
1406 case EFI_IFR_TYPE_NUM_SIZE_16
:
1407 case EFI_IFR_TYPE_STRING
:
1408 ExpressionOpCode
->ValueWidth
= 2;
1411 case EFI_IFR_TYPE_NUM_SIZE_32
:
1412 ExpressionOpCode
->ValueWidth
= 4;
1415 case EFI_IFR_TYPE_NUM_SIZE_64
:
1416 ExpressionOpCode
->ValueWidth
= 8;
1419 case EFI_IFR_TYPE_DATE
:
1420 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_DATE
);
1423 case EFI_IFR_TYPE_TIME
:
1424 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_TIME
);
1427 case EFI_IFR_TYPE_REF
:
1428 ExpressionOpCode
->ValueWidth
= (UINT8
) sizeof (EFI_IFR_REF
);
1431 case EFI_IFR_TYPE_OTHER
:
1432 case EFI_IFR_TYPE_UNDEFINED
:
1433 case EFI_IFR_TYPE_ACTION
:
1434 case EFI_IFR_TYPE_BUFFER
:
1437 // Invalid value type for Get/Set opcode.
1439 return EFI_INVALID_PARAMETER
;
1441 CopyMem (&ExpressionOpCode
->VarStoreInfo
.VarName
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreInfo
.VarName
, sizeof (EFI_STRING_ID
));
1442 CopyMem (&ExpressionOpCode
->VarStoreInfo
.VarOffset
, &((EFI_IFR_GET
*) OpCodeData
)->VarStoreInfo
.VarOffset
, sizeof (UINT16
));
1443 if ((ExpressionOpCode
->VarStorage
!= NULL
) &&
1444 (ExpressionOpCode
->VarStorage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
||
1445 ExpressionOpCode
->VarStorage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
)) {
1446 ExpressionOpCode
->ValueName
= GetToken (ExpressionOpCode
->VarStoreInfo
.VarName
, FormSet
->HiiHandle
);
1447 if (ExpressionOpCode
->ValueName
== NULL
) {
1449 // String ID is invalid.
1451 return EFI_INVALID_PARAMETER
;
1456 case EFI_IFR_QUESTION_REF1_OP
:
1457 CopyMem (&ExpressionOpCode
->QuestionId
, &((EFI_IFR_EQ_ID_VAL_LIST
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1460 case EFI_IFR_QUESTION_REF3_OP
:
1461 if (OpCodeLength
>= sizeof (EFI_IFR_QUESTION_REF3_2
)) {
1462 CopyMem (&ExpressionOpCode
->DevicePath
, &(( EFI_IFR_QUESTION_REF3_2
*) OpCodeData
)->DevicePath
, sizeof (EFI_STRING_ID
));
1464 if (OpCodeLength
>= sizeof (EFI_IFR_QUESTION_REF3_3
)) {
1465 CopyMem (&ExpressionOpCode
->Guid
, &(( EFI_IFR_QUESTION_REF3_3
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
1473 case EFI_IFR_TRUE_OP
:
1474 Value
->Type
= EFI_IFR_TYPE_BOOLEAN
;
1475 Value
->Value
.b
= TRUE
;
1478 case EFI_IFR_FALSE_OP
:
1479 Value
->Type
= EFI_IFR_TYPE_BOOLEAN
;
1480 Value
->Value
.b
= FALSE
;
1483 case EFI_IFR_ONE_OP
:
1484 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1485 Value
->Value
.u8
= 1;
1488 case EFI_IFR_ZERO_OP
:
1489 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1490 Value
->Value
.u8
= 0;
1493 case EFI_IFR_ONES_OP
:
1494 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1495 Value
->Value
.u64
= 0xffffffffffffffffULL
;
1498 case EFI_IFR_UINT8_OP
:
1499 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1500 Value
->Value
.u8
= (( EFI_IFR_UINT8
*) OpCodeData
)->Value
;
1503 case EFI_IFR_UINT16_OP
:
1504 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1505 CopyMem (&Value
->Value
.u16
, &(( EFI_IFR_UINT16
*) OpCodeData
)->Value
, sizeof (UINT16
));
1508 case EFI_IFR_UINT32_OP
:
1509 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_32
;
1510 CopyMem (&Value
->Value
.u32
, &(( EFI_IFR_UINT32
*) OpCodeData
)->Value
, sizeof (UINT32
));
1513 case EFI_IFR_UINT64_OP
:
1514 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1515 CopyMem (&Value
->Value
.u64
, &(( EFI_IFR_UINT64
*) OpCodeData
)->Value
, sizeof (UINT64
));
1518 case EFI_IFR_UNDEFINED_OP
:
1519 Value
->Type
= EFI_IFR_TYPE_UNDEFINED
;
1522 case EFI_IFR_VERSION_OP
:
1523 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1524 Value
->Value
.u16
= EFI_IFR_SPECIFICATION_VERSION
;
1531 // Create sub expression nested in MAP opcode
1533 if (CurrentExpression
== NULL
&& MapScopeDepth
> 0) {
1534 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
1535 ASSERT (MapExpressionList
!= NULL
);
1536 InsertTailList (MapExpressionList
, &CurrentExpression
->Link
);
1538 SingleOpCodeExpression
= TRUE
;
1541 ASSERT (CurrentExpression
!= NULL
);
1542 InsertTailList (&CurrentExpression
->OpCodeListHead
, &ExpressionOpCode
->Link
);
1543 if (Operand
== EFI_IFR_MAP_OP
) {
1545 // Store current Map Expression List.
1547 if (MapExpressionList
!= NULL
) {
1548 PushMapExpressionList (MapExpressionList
);
1551 // Initialize new Map Expression List.
1553 MapExpressionList
= &ExpressionOpCode
->MapExpressionList
;
1554 InitializeListHead (MapExpressionList
);
1556 // Store current expression.
1558 PushCurrentExpression (CurrentExpression
);
1559 CurrentExpression
= NULL
;
1561 } else if (SingleOpCodeExpression
) {
1563 // There are two cases to indicate the end of an Expression:
1564 // for single OpCode expression: one Expression OpCode
1565 // for expression consists of more than one OpCode: EFI_IFR_END
1567 SingleOpCodeExpression
= FALSE
;
1569 if (InScopeDisable
&& CurrentForm
== NULL
) {
1571 // This is DisableIf expression for Form, it should be a constant expression
1573 Status
= EvaluateExpression (FormSet
, CurrentForm
, CurrentExpression
);
1574 if (EFI_ERROR (Status
)) {
1578 OpCodeDisabled
= IsTrue(&CurrentExpression
->Result
);
1581 CurrentExpression
= NULL
;
1592 case EFI_IFR_FORM_SET_OP
:
1594 // Check the formset GUID
1596 if (CompareMem (&FormSet
->Guid
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
)) != 0) {
1597 return EFI_INVALID_PARAMETER
;
1600 CopyMem (&FormSet
->FormSetTitle
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->FormSetTitle
, sizeof (EFI_STRING_ID
));
1601 CopyMem (&FormSet
->Help
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->Help
, sizeof (EFI_STRING_ID
));
1602 FormSet
->OpCode
= (EFI_IFR_OP_HEADER
*) OpCodeData
;//save the opcode address of formset
1604 if (OpCodeLength
> OFFSET_OF (EFI_IFR_FORM_SET
, Flags
)) {
1606 // The formset OpCode contains ClassGuid
1608 FormSet
->NumberOfClassGuid
= (UINT8
) (((EFI_IFR_FORM_SET
*) OpCodeData
)->Flags
& 0x3);
1609 CopyMem (FormSet
->ClassGuid
, OpCodeData
+ sizeof (EFI_IFR_FORM_SET
), FormSet
->NumberOfClassGuid
* sizeof (EFI_GUID
));
1613 case EFI_IFR_FORM_OP
:
1615 // Create a new Form for this FormSet
1617 CurrentForm
= AllocateZeroPool (sizeof (FORM_BROWSER_FORM
));
1618 ASSERT (CurrentForm
!= NULL
);
1619 CurrentForm
->Signature
= FORM_BROWSER_FORM_SIGNATURE
;
1620 InitializeListHead (&CurrentForm
->ExpressionListHead
);
1621 InitializeListHead (&CurrentForm
->StatementListHead
);
1622 InitializeListHead (&CurrentForm
->ConfigRequestHead
);
1623 InitializeListHead (&CurrentForm
->FormViewListHead
);
1625 CurrentForm
->FormType
= STANDARD_MAP_FORM_TYPE
;
1626 CopyMem (&CurrentForm
->FormId
, &((EFI_IFR_FORM
*) OpCodeData
)->FormId
, sizeof (UINT16
));
1627 CopyMem (&CurrentForm
->FormTitle
, &((EFI_IFR_FORM
*) OpCodeData
)->FormTitle
, sizeof (EFI_STRING_ID
));
1629 ConditionalExprCount
= GetConditionalExpressionCount(ExpressForm
);
1630 if ( ConditionalExprCount
> 0) {
1632 // Form is inside of suppressif
1634 CurrentForm
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
1635 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
1636 ASSERT (CurrentForm
->SuppressExpression
!= NULL
);
1637 CurrentForm
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
1638 CurrentForm
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
1639 CopyMem (CurrentForm
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressForm
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
1644 // Enter scope of a Form, suppressif will be used for Question or Option
1646 SuppressForQuestion
= TRUE
;
1650 // Insert into Form list of this FormSet
1652 InsertTailList (&FormSet
->FormListHead
, &CurrentForm
->Link
);
1655 case EFI_IFR_FORM_MAP_OP
:
1657 // Create a new Form for this FormSet
1659 CurrentForm
= AllocateZeroPool (sizeof (FORM_BROWSER_FORM
));
1660 ASSERT (CurrentForm
!= NULL
);
1661 CurrentForm
->Signature
= FORM_BROWSER_FORM_SIGNATURE
;
1662 InitializeListHead (&CurrentForm
->ExpressionListHead
);
1663 InitializeListHead (&CurrentForm
->StatementListHead
);
1664 InitializeListHead (&CurrentForm
->ConfigRequestHead
);
1665 InitializeListHead (&CurrentForm
->FormViewListHead
);
1667 CopyMem (&CurrentForm
->FormId
, &((EFI_IFR_FORM
*) OpCodeData
)->FormId
, sizeof (UINT16
));
1669 MapMethod
= (EFI_IFR_FORM_MAP_METHOD
*) (OpCodeData
+ sizeof (EFI_IFR_FORM_MAP
));
1671 // FormMap Form must contain at least one Map Method.
1673 if (((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
< ((UINTN
) (UINT8
*) (MapMethod
+ 1) - (UINTN
) OpCodeData
)) {
1674 return EFI_INVALID_PARAMETER
;
1677 // Try to find the standard form map method.
1679 while (((UINTN
) (UINT8
*) MapMethod
- (UINTN
) OpCodeData
) < ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
) {
1680 if (CompareGuid ((EFI_GUID
*) (VOID
*) &MapMethod
->MethodIdentifier
, &gEfiHiiStandardFormGuid
)) {
1681 CopyMem (&CurrentForm
->FormTitle
, &MapMethod
->MethodTitle
, sizeof (EFI_STRING_ID
));
1682 CurrentForm
->FormType
= STANDARD_MAP_FORM_TYPE
;
1688 // If the standard form map method is not found, the first map method title will be used.
1690 if (CurrentForm
->FormTitle
== 0) {
1691 MapMethod
= (EFI_IFR_FORM_MAP_METHOD
*) (OpCodeData
+ sizeof (EFI_IFR_FORM_MAP
));
1692 CopyMem (&CurrentForm
->FormTitle
, &MapMethod
->MethodTitle
, sizeof (EFI_STRING_ID
));
1695 ConditionalExprCount
= GetConditionalExpressionCount(ExpressForm
);
1696 if ( ConditionalExprCount
> 0) {
1698 // Form is inside of suppressif
1700 CurrentForm
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
1701 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
1702 ASSERT (CurrentForm
->SuppressExpression
!= NULL
);
1703 CurrentForm
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
1704 CurrentForm
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
1705 CopyMem (CurrentForm
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressForm
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
1710 // Enter scope of a Form, suppressif will be used for Question or Option
1712 SuppressForQuestion
= TRUE
;
1716 // Insert into Form list of this FormSet
1718 InsertTailList (&FormSet
->FormListHead
, &CurrentForm
->Link
);
1724 case EFI_IFR_VARSTORE_OP
:
1726 // Create a buffer Storage for this FormSet
1728 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_BUFFER
, OpCodeData
);
1729 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1732 case EFI_IFR_VARSTORE_NAME_VALUE_OP
:
1734 // Create a name/value Storage for this FormSet
1736 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_NAME_VALUE
, OpCodeData
);
1737 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE_NAME_VALUE
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1740 case EFI_IFR_VARSTORE_EFI_OP
:
1742 // Create a EFI variable Storage for this FormSet
1744 if (OpCodeLength
< sizeof (EFI_IFR_VARSTORE_EFI
)) {
1746 // Create efi varstore with format follow UEFI spec before 2.3.1.
1748 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_EFI_VARIABLE
, OpCodeData
);
1751 // Create efi varstore with format follow UEFI spec 2.3.1 and later.
1753 Storage
= CreateStorage (FormSet
, EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
, OpCodeData
);
1755 CopyMem (&Storage
->VarStoreId
, &((EFI_IFR_VARSTORE_EFI
*) OpCodeData
)->VarStoreId
, sizeof (EFI_VARSTORE_ID
));
1761 case EFI_IFR_DEFAULTSTORE_OP
:
1762 HaveInserted
= FALSE
;
1763 DefaultStore
= AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE
));
1764 ASSERT (DefaultStore
!= NULL
);
1765 DefaultStore
->Signature
= FORMSET_DEFAULTSTORE_SIGNATURE
;
1767 CopyMem (&DefaultStore
->DefaultId
, &((EFI_IFR_DEFAULTSTORE
*) OpCodeData
)->DefaultId
, sizeof (UINT16
));
1768 CopyMem (&DefaultStore
->DefaultName
, &((EFI_IFR_DEFAULTSTORE
*) OpCodeData
)->DefaultName
, sizeof (EFI_STRING_ID
));
1770 // Insert it to the DefaultStore list of this Formset with ascending order.
1772 if (!IsListEmpty (&FormSet
->DefaultStoreListHead
)) {
1773 DefaultLink
= GetFirstNode (&FormSet
->DefaultStoreListHead
);
1774 while (!IsNull (&FormSet
->DefaultStoreListHead
, DefaultLink
)) {
1775 PreDefaultStore
= FORMSET_DEFAULTSTORE_FROM_LINK(DefaultLink
);
1776 DefaultLink
= GetNextNode (&FormSet
->DefaultStoreListHead
, DefaultLink
);
1777 if (DefaultStore
->DefaultId
< PreDefaultStore
->DefaultId
) {
1778 InsertTailList (&PreDefaultStore
->Link
, &DefaultStore
->Link
);
1779 HaveInserted
= TRUE
;
1784 if (!HaveInserted
) {
1785 InsertTailList (&FormSet
->DefaultStoreListHead
, &DefaultStore
->Link
);
1792 case EFI_IFR_SUBTITLE_OP
:
1793 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1794 ASSERT (CurrentStatement
!= NULL
);
1796 CurrentStatement
->Flags
= ((EFI_IFR_SUBTITLE
*) OpCodeData
)->Flags
;
1797 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1800 case EFI_IFR_TEXT_OP
:
1801 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1802 ASSERT (CurrentStatement
!= NULL
);
1803 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1804 CopyMem (&CurrentStatement
->TextTwo
, &((EFI_IFR_TEXT
*) OpCodeData
)->TextTwo
, sizeof (EFI_STRING_ID
));
1807 case EFI_IFR_RESET_BUTTON_OP
:
1808 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
1809 ASSERT (CurrentStatement
!= NULL
);
1810 CurrentStatement
->FakeQuestionId
= mUsedQuestionId
++;
1811 CopyMem (&CurrentStatement
->DefaultId
, &((EFI_IFR_RESET_BUTTON
*) OpCodeData
)->DefaultId
, sizeof (EFI_DEFAULT_ID
));
1817 case EFI_IFR_ACTION_OP
:
1818 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1819 ASSERT (CurrentStatement
!= NULL
);
1820 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_ACTION
;
1822 if (OpCodeLength
== sizeof (EFI_IFR_ACTION_1
)) {
1824 // No QuestionConfig present, so no configuration string will be processed
1826 CurrentStatement
->QuestionConfig
= 0;
1828 CopyMem (&CurrentStatement
->QuestionConfig
, &((EFI_IFR_ACTION
*) OpCodeData
)->QuestionConfig
, sizeof (EFI_STRING_ID
));
1832 case EFI_IFR_REF_OP
:
1833 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1834 ASSERT (CurrentStatement
!= NULL
);
1835 Value
= &CurrentStatement
->HiiValue
;
1836 Value
->Type
= EFI_IFR_TYPE_REF
;
1837 if (OpCodeLength
>= sizeof (EFI_IFR_REF
)) {
1838 CopyMem (&Value
->Value
.ref
.FormId
, &((EFI_IFR_REF
*) OpCodeData
)->FormId
, sizeof (EFI_FORM_ID
));
1840 if (OpCodeLength
>= sizeof (EFI_IFR_REF2
)) {
1841 CopyMem (&Value
->Value
.ref
.QuestionId
, &((EFI_IFR_REF2
*) OpCodeData
)->QuestionId
, sizeof (EFI_QUESTION_ID
));
1843 if (OpCodeLength
>= sizeof (EFI_IFR_REF3
)) {
1844 CopyMem (&Value
->Value
.ref
.FormSetGuid
, &((EFI_IFR_REF3
*) OpCodeData
)->FormSetId
, sizeof (EFI_GUID
));
1846 if (OpCodeLength
>= sizeof (EFI_IFR_REF4
)) {
1847 CopyMem (&Value
->Value
.ref
.DevicePath
, &((EFI_IFR_REF4
*) OpCodeData
)->DevicePath
, sizeof (EFI_STRING_ID
));
1852 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_REF
);
1853 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1856 case EFI_IFR_ONE_OF_OP
:
1857 case EFI_IFR_NUMERIC_OP
:
1858 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1859 ASSERT(CurrentStatement
!= NULL
);
1861 CurrentStatement
->Flags
= ((EFI_IFR_ONE_OF
*) OpCodeData
)->Flags
;
1862 Value
= &CurrentStatement
->HiiValue
;
1864 if (QuestionReferBitField
) {
1866 // Get the bit var store info (bit/byte offset, bit/byte offset)
1868 CurrentStatement
->QuestionReferToBitField
= TRUE
;
1869 CurrentStatement
->BitStorageWidth
= CurrentStatement
->Flags
& EDKII_IFR_NUMERIC_SIZE_BIT
;
1870 CurrentStatement
->BitVarOffset
= CurrentStatement
->VarStoreInfo
.VarOffset
;
1871 CurrentStatement
->VarStoreInfo
.VarOffset
= CurrentStatement
->BitVarOffset
/ 8;
1872 TotalBits
= CurrentStatement
->BitVarOffset
% 8 + CurrentStatement
->BitStorageWidth
;
1873 CurrentStatement
->StorageWidth
= (TotalBits
% 8 == 0? TotalBits
/ 8: TotalBits
/ 8 + 1);
1876 // Get the Minimum/Maximum/Step value(Note: bit field type has been stored as UINT32 type)
1878 CurrentStatement
->Minimum
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MinValue
;
1879 CurrentStatement
->Maximum
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MaxValue
;
1880 CurrentStatement
->Step
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.Step
;
1883 // Update the Flag and type of Minimum/Maximum/Step according to the actual width of bit field,
1884 // in order to make Browser handle these question with bit varstore correctly.
1886 ((EFI_IFR_NUMERIC
*) OpCodeData
)->Flags
&= EDKII_IFR_DISPLAY_BIT
;
1887 ((EFI_IFR_NUMERIC
*) OpCodeData
)->Flags
>>= 2;
1888 switch (CurrentStatement
->StorageWidth
) {
1890 ((EFI_IFR_NUMERIC
*) OpCodeData
)->Flags
|= EFI_IFR_TYPE_NUM_SIZE_8
;
1891 ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.MinValue
= (UINT8
)CurrentStatement
->Minimum
;
1892 ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.MaxValue
= (UINT8
)CurrentStatement
->Maximum
;
1893 ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.Step
= (UINT8
)CurrentStatement
->Step
;
1894 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1897 ((EFI_IFR_NUMERIC
*) OpCodeData
)->Flags
|= EFI_IFR_TYPE_NUM_SIZE_16
;
1898 ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.MinValue
= (UINT16
)CurrentStatement
->Minimum
;
1899 ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.MaxValue
= (UINT16
)CurrentStatement
->Maximum
;
1900 ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.Step
= (UINT16
)CurrentStatement
->Step
;
1901 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1905 ((EFI_IFR_NUMERIC
*) OpCodeData
)->Flags
|= EFI_IFR_TYPE_NUM_SIZE_32
;
1906 ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MinValue
= (UINT32
)CurrentStatement
->Minimum
;
1907 ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MaxValue
= (UINT32
)CurrentStatement
->Maximum
;
1908 ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.Step
= (UINT32
)CurrentStatement
->Step
;
1909 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_32
;
1915 switch (CurrentStatement
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1916 case EFI_IFR_NUMERIC_SIZE_1
:
1917 CurrentStatement
->Minimum
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.MinValue
;
1918 CurrentStatement
->Maximum
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.MaxValue
;
1919 CurrentStatement
->Step
= ((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u8
.Step
;
1920 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT8
);
1921 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_8
;
1924 case EFI_IFR_NUMERIC_SIZE_2
:
1925 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.MinValue
, sizeof (UINT16
));
1926 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.MaxValue
, sizeof (UINT16
));
1927 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u16
.Step
, sizeof (UINT16
));
1928 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT16
);
1929 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_16
;
1932 case EFI_IFR_NUMERIC_SIZE_4
:
1933 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MinValue
, sizeof (UINT32
));
1934 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.MaxValue
, sizeof (UINT32
));
1935 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u32
.Step
, sizeof (UINT32
));
1936 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT32
);
1937 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_32
;
1940 case EFI_IFR_NUMERIC_SIZE_8
:
1941 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.MinValue
, sizeof (UINT64
));
1942 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.MaxValue
, sizeof (UINT64
));
1943 CopyMem (&CurrentStatement
->Step
, &((EFI_IFR_NUMERIC
*) OpCodeData
)->data
.u64
.Step
, sizeof (UINT64
));
1944 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (UINT64
);
1945 Value
->Type
= EFI_IFR_TYPE_NUM_SIZE_64
;
1952 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1954 if ((Operand
== EFI_IFR_ONE_OF_OP
) && Scope
!= 0) {
1955 SuppressForOption
= TRUE
;
1959 case EFI_IFR_ORDERED_LIST_OP
:
1960 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1961 ASSERT(CurrentStatement
!= NULL
);
1963 CurrentStatement
->Flags
= ((EFI_IFR_ORDERED_LIST
*) OpCodeData
)->Flags
;
1964 CurrentStatement
->MaxContainers
= ((EFI_IFR_ORDERED_LIST
*) OpCodeData
)->MaxContainers
;
1966 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_BUFFER
;
1967 CurrentStatement
->BufferValue
= NULL
;
1970 SuppressForOption
= TRUE
;
1974 case EFI_IFR_CHECKBOX_OP
:
1975 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
1976 ASSERT(CurrentStatement
!= NULL
);
1978 CurrentStatement
->Flags
= ((EFI_IFR_CHECKBOX
*) OpCodeData
)->Flags
;
1979 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (BOOLEAN
);
1980 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_BOOLEAN
;
1982 if (QuestionReferBitField
) {
1984 // Get the bit var store info (bit/byte offset, bit/byte offset)
1986 CurrentStatement
->QuestionReferToBitField
= TRUE
;
1987 CurrentStatement
->BitStorageWidth
= 1;
1988 CurrentStatement
->BitVarOffset
= CurrentStatement
->VarStoreInfo
.VarOffset
;
1989 CurrentStatement
->VarStoreInfo
.VarOffset
= CurrentStatement
->BitVarOffset
/ 8;
1990 TotalBits
= CurrentStatement
->BitVarOffset
% 8 + CurrentStatement
->BitStorageWidth
;
1991 CurrentStatement
->StorageWidth
= (TotalBits
% 8 == 0? TotalBits
/ 8: TotalBits
/ 8 + 1);
1994 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
1998 case EFI_IFR_STRING_OP
:
1999 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2000 ASSERT (CurrentStatement
!= NULL
);
2002 // MinSize is the minimum number of characters that can be accepted for this opcode,
2003 // MaxSize is the maximum number of characters that can be accepted for this opcode.
2004 // The characters are stored as Unicode, so the storage width should multiply 2.
2006 CurrentStatement
->Minimum
= ((EFI_IFR_STRING
*) OpCodeData
)->MinSize
;
2007 CurrentStatement
->Maximum
= ((EFI_IFR_STRING
*) OpCodeData
)->MaxSize
;
2008 CurrentStatement
->StorageWidth
= (UINT16
)((UINTN
) CurrentStatement
->Maximum
* sizeof (CHAR16
));
2009 CurrentStatement
->Flags
= ((EFI_IFR_STRING
*) OpCodeData
)->Flags
;
2011 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_STRING
;
2012 CurrentStatement
->BufferValue
= AllocateZeroPool (CurrentStatement
->StorageWidth
+ sizeof (CHAR16
));
2013 CurrentStatement
->HiiValue
.Value
.string
= NewString ((CHAR16
*) CurrentStatement
->BufferValue
, FormSet
->HiiHandle
);
2015 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2018 case EFI_IFR_PASSWORD_OP
:
2019 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2020 ASSERT (CurrentStatement
!= NULL
);
2022 // MinSize is the minimum number of characters that can be accepted for this opcode,
2023 // MaxSize is the maximum number of characters that can be accepted for this opcode.
2024 // The characters are stored as Unicode, so the storage width should multiply 2.
2026 CopyMem (&CurrentStatement
->Minimum
, &((EFI_IFR_PASSWORD
*) OpCodeData
)->MinSize
, sizeof (UINT16
));
2027 CopyMem (&CurrentStatement
->Maximum
, &((EFI_IFR_PASSWORD
*) OpCodeData
)->MaxSize
, sizeof (UINT16
));
2028 CurrentStatement
->StorageWidth
= (UINT16
)((UINTN
) CurrentStatement
->Maximum
* sizeof (CHAR16
));
2030 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_STRING
;
2031 CurrentStatement
->BufferValue
= AllocateZeroPool ((CurrentStatement
->StorageWidth
+ sizeof (CHAR16
)));
2032 CurrentStatement
->HiiValue
.Value
.string
= NewString ((CHAR16
*) CurrentStatement
->BufferValue
, FormSet
->HiiHandle
);
2034 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2037 case EFI_IFR_DATE_OP
:
2038 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2039 ASSERT(CurrentStatement
!= NULL
);
2041 CurrentStatement
->Flags
= ((EFI_IFR_DATE
*) OpCodeData
)->Flags
;
2042 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_DATE
;
2044 if ((CurrentStatement
->Flags
& EFI_QF_DATE_STORAGE
) == QF_DATE_STORAGE_NORMAL
) {
2045 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_DATE
);
2047 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2050 // Don't assign storage for RTC type of date/time
2052 CurrentStatement
->Storage
= NULL
;
2053 CurrentStatement
->StorageWidth
= 0;
2057 case EFI_IFR_TIME_OP
:
2058 CurrentStatement
= CreateQuestion (OpCodeData
, FormSet
, CurrentForm
);
2059 ASSERT(CurrentStatement
!= NULL
);
2061 CurrentStatement
->Flags
= ((EFI_IFR_TIME
*) OpCodeData
)->Flags
;
2062 CurrentStatement
->HiiValue
.Type
= EFI_IFR_TYPE_TIME
;
2064 if ((CurrentStatement
->Flags
& QF_TIME_STORAGE
) == QF_TIME_STORAGE_NORMAL
) {
2065 CurrentStatement
->StorageWidth
= (UINT16
) sizeof (EFI_HII_TIME
);
2067 InitializeRequestElement (FormSet
, CurrentStatement
, CurrentForm
);
2070 // Don't assign storage for RTC type of date/time
2072 CurrentStatement
->Storage
= NULL
;
2073 CurrentStatement
->StorageWidth
= 0;
2080 case EFI_IFR_DEFAULT_OP
:
2082 // EFI_IFR_DEFAULT appear in scope of a Question,
2083 // It creates a default value for the current question.
2084 // A Question may have more than one Default value which have different default types.
2086 CurrentDefault
= AllocateZeroPool (sizeof (QUESTION_DEFAULT
));
2087 ASSERT (CurrentDefault
!= NULL
);
2088 CurrentDefault
->Signature
= QUESTION_DEFAULT_SIGNATURE
;
2090 CurrentDefault
->Value
.Type
= ((EFI_IFR_DEFAULT
*) OpCodeData
)->Type
;
2091 CopyMem (&CurrentDefault
->DefaultId
, &((EFI_IFR_DEFAULT
*) OpCodeData
)->DefaultId
, sizeof (UINT16
));
2092 if (CurrentDefault
->Value
.Type
== EFI_IFR_TYPE_BUFFER
) {
2093 CurrentDefault
->Value
.BufferLen
= (UINT16
) (OpCodeLength
- OFFSET_OF (EFI_IFR_DEFAULT
, Value
));
2094 CurrentDefault
->Value
.Buffer
= AllocateCopyPool (CurrentDefault
->Value
.BufferLen
, &((EFI_IFR_DEFAULT
*) OpCodeData
)->Value
);
2095 ASSERT (CurrentDefault
->Value
.Buffer
!= NULL
);
2097 CopyMem (&CurrentDefault
->Value
.Value
, &((EFI_IFR_DEFAULT
*) OpCodeData
)->Value
, OpCodeLength
- OFFSET_OF (EFI_IFR_DEFAULT
, Value
));
2098 ExtendValueToU64 (&CurrentDefault
->Value
);
2102 // Insert to Default Value list of current Question
2104 InsertTailList (&ParentStatement
->DefaultListHead
, &CurrentDefault
->Link
);
2107 InScopeDefault
= TRUE
;
2114 case EFI_IFR_ONE_OF_OPTION_OP
:
2115 ASSERT (ParentStatement
!= NULL
);
2116 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)) {
2118 // It's keep the default value for ordered list opcode.
2120 CurrentDefault
= AllocateZeroPool (sizeof (QUESTION_DEFAULT
));
2121 ASSERT (CurrentDefault
!= NULL
);
2122 CurrentDefault
->Signature
= QUESTION_DEFAULT_SIGNATURE
;
2124 CurrentDefault
->Value
.Type
= EFI_IFR_TYPE_BUFFER
;
2125 if ((((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Flags
& EFI_IFR_OPTION_DEFAULT
) != 0) {
2126 CurrentDefault
->DefaultId
= EFI_HII_DEFAULT_CLASS_STANDARD
;
2128 CurrentDefault
->DefaultId
= EFI_HII_DEFAULT_CLASS_MANUFACTURING
;
2131 CurrentDefault
->Value
.BufferLen
= (UINT16
) (OpCodeLength
- OFFSET_OF (EFI_IFR_ONE_OF_OPTION
, Value
));
2132 CurrentDefault
->Value
.Buffer
= AllocateCopyPool (CurrentDefault
->Value
.BufferLen
, &((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Value
);
2133 ASSERT (CurrentDefault
->Value
.Buffer
!= NULL
);
2136 // Insert to Default Value list of current Question
2138 InsertTailList (&ParentStatement
->DefaultListHead
, &CurrentDefault
->Link
);
2143 // EFI_IFR_ONE_OF_OPTION appear in scope of a Question.
2144 // It create a selection for use in current Question.
2146 CurrentOption
= AllocateZeroPool (sizeof (QUESTION_OPTION
));
2147 ASSERT (CurrentOption
!= NULL
);
2148 CurrentOption
->Signature
= QUESTION_OPTION_SIGNATURE
;
2149 CurrentOption
->OpCode
= (EFI_IFR_ONE_OF_OPTION
*) OpCodeData
;
2151 CurrentOption
->Flags
= ((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Flags
;
2152 CurrentOption
->Value
.Type
= ((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Type
;
2153 CopyMem (&CurrentOption
->Text
, &((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Option
, sizeof (EFI_STRING_ID
));
2154 CopyMem (&CurrentOption
->Value
.Value
, &((EFI_IFR_ONE_OF_OPTION
*) OpCodeData
)->Value
, OpCodeLength
- OFFSET_OF (EFI_IFR_ONE_OF_OPTION
, Value
));
2155 ExtendValueToU64 (&CurrentOption
->Value
);
2157 ConditionalExprCount
= GetConditionalExpressionCount(ExpressOption
);
2158 if ( ConditionalExprCount
> 0) {
2160 // Form is inside of suppressif
2162 CurrentOption
->SuppressExpression
= (FORM_EXPRESSION_LIST
*) AllocatePool(
2163 (UINTN
) (sizeof(FORM_EXPRESSION_LIST
) + ((ConditionalExprCount
-1) * sizeof(FORM_EXPRESSION
*))));
2164 ASSERT (CurrentOption
->SuppressExpression
!= NULL
);
2165 CurrentOption
->SuppressExpression
->Count
= (UINTN
) ConditionalExprCount
;
2166 CurrentOption
->SuppressExpression
->Signature
= FORM_EXPRESSION_LIST_SIGNATURE
;
2167 CopyMem (CurrentOption
->SuppressExpression
->Expression
, GetConditionalExpressionList(ExpressOption
), (UINTN
) (sizeof (FORM_EXPRESSION
*) * ConditionalExprCount
));
2171 // Insert to Option list of current Question
2173 InsertTailList (&ParentStatement
->OptionListHead
, &CurrentOption
->Link
);
2175 // Now we know the Storage width of nested Ordered List
2177 if ((ParentStatement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) && (ParentStatement
->BufferValue
== NULL
)) {
2179 switch (CurrentOption
->Value
.Type
) {
2180 case EFI_IFR_TYPE_NUM_SIZE_8
:
2184 case EFI_IFR_TYPE_NUM_SIZE_16
:
2188 case EFI_IFR_TYPE_NUM_SIZE_32
:
2192 case EFI_IFR_TYPE_NUM_SIZE_64
:
2198 // Invalid type for Ordered List
2203 ParentStatement
->StorageWidth
= (UINT16
) (ParentStatement
->MaxContainers
* Width
);
2204 ParentStatement
->BufferValue
= AllocateZeroPool (ParentStatement
->StorageWidth
);
2205 ParentStatement
->ValueType
= CurrentOption
->Value
.Type
;
2206 if (ParentStatement
->HiiValue
.Type
== EFI_IFR_TYPE_BUFFER
) {
2207 ParentStatement
->HiiValue
.Buffer
= ParentStatement
->BufferValue
;
2208 ParentStatement
->HiiValue
.BufferLen
= ParentStatement
->StorageWidth
;
2211 InitializeRequestElement (FormSet
, ParentStatement
, CurrentForm
);
2218 case EFI_IFR_NO_SUBMIT_IF_OP
:
2219 case EFI_IFR_INCONSISTENT_IF_OP
:
2221 // Create an Expression node
2223 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2224 CopyMem (&CurrentExpression
->Error
, &((EFI_IFR_INCONSISTENT_IF
*) OpCodeData
)->Error
, sizeof (EFI_STRING_ID
));
2226 if (Operand
== EFI_IFR_NO_SUBMIT_IF_OP
) {
2227 CurrentExpression
->Type
= EFI_HII_EXPRESSION_NO_SUBMIT_IF
;
2228 InsertTailList (&ParentStatement
->NoSubmitListHead
, &CurrentExpression
->Link
);
2230 CurrentExpression
->Type
= EFI_HII_EXPRESSION_INCONSISTENT_IF
;
2231 InsertTailList (&ParentStatement
->InconsistentListHead
, &CurrentExpression
->Link
);
2235 // Take a look at next OpCode to see whether current expression consists
2238 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2239 SingleOpCodeExpression
= TRUE
;
2243 case EFI_IFR_WARNING_IF_OP
:
2245 // Create an Expression node
2247 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2248 CopyMem (&CurrentExpression
->Error
, &((EFI_IFR_WARNING_IF
*) OpCodeData
)->Warning
, sizeof (EFI_STRING_ID
));
2249 CurrentExpression
->TimeOut
= ((EFI_IFR_WARNING_IF
*) OpCodeData
)->TimeOut
;
2250 CurrentExpression
->Type
= EFI_HII_EXPRESSION_WARNING_IF
;
2251 InsertTailList (&ParentStatement
->WarningListHead
, &CurrentExpression
->Link
);
2254 // Take a look at next OpCode to see whether current expression consists
2257 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2258 SingleOpCodeExpression
= TRUE
;
2262 case EFI_IFR_SUPPRESS_IF_OP
:
2264 // Question and Option will appear in scope of this OpCode
2266 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2267 CurrentExpression
->Type
= EFI_HII_EXPRESSION_SUPPRESS_IF
;
2269 if (CurrentForm
== NULL
) {
2270 InsertTailList (&FormSet
->ExpressionListHead
, &CurrentExpression
->Link
);
2272 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2275 if (SuppressForOption
) {
2276 PushConditionalExpression(CurrentExpression
, ExpressOption
);
2277 } else if (SuppressForQuestion
) {
2278 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2280 PushConditionalExpression(CurrentExpression
, ExpressForm
);
2284 // Take a look at next OpCode to see whether current expression consists
2287 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2288 SingleOpCodeExpression
= TRUE
;
2292 case EFI_IFR_GRAY_OUT_IF_OP
:
2294 // Questions will appear in scope of this OpCode
2296 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2297 CurrentExpression
->Type
= EFI_HII_EXPRESSION_GRAY_OUT_IF
;
2298 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2299 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2302 // Take a look at next OpCode to see whether current expression consists
2305 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2306 SingleOpCodeExpression
= TRUE
;
2310 case EFI_IFR_DISABLE_IF_OP
:
2312 // The DisableIf expression should only rely on constant, so it could be
2313 // evaluated at initialization and it will not be queued
2315 CurrentExpression
= AllocateZeroPool (sizeof (FORM_EXPRESSION
));
2316 ASSERT (CurrentExpression
!= NULL
);
2317 CurrentExpression
->Signature
= FORM_EXPRESSION_SIGNATURE
;
2318 CurrentExpression
->Type
= EFI_HII_EXPRESSION_DISABLE_IF
;
2319 InitializeListHead (&CurrentExpression
->OpCodeListHead
);
2321 if (CurrentForm
!= NULL
) {
2323 // This is DisableIf for Question, enqueue it to Form expression list
2325 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2326 PushConditionalExpression(CurrentExpression
, ExpressStatement
);
2329 OpCodeDisabled
= FALSE
;
2330 InScopeDisable
= TRUE
;
2332 // Take a look at next OpCode to see whether current expression consists
2335 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2336 SingleOpCodeExpression
= TRUE
;
2343 case EFI_IFR_VALUE_OP
:
2344 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2345 CurrentExpression
->Type
= EFI_HII_EXPRESSION_VALUE
;
2346 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2348 if (InScopeDefault
) {
2350 // Used for default (EFI_IFR_DEFAULT)
2352 CurrentDefault
->ValueExpression
= CurrentExpression
;
2355 // If used for a question, then the question will be read-only
2358 // Make sure CurrentStatement is not NULL.
2359 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2360 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2362 ASSERT (ParentStatement
!= NULL
);
2363 ParentStatement
->ValueExpression
= CurrentExpression
;
2367 // Take a look at next OpCode to see whether current expression consists
2370 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2371 SingleOpCodeExpression
= TRUE
;
2375 case EFI_IFR_RULE_OP
:
2376 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2377 CurrentExpression
->Type
= EFI_HII_EXPRESSION_RULE
;
2379 CurrentExpression
->RuleId
= ((EFI_IFR_RULE
*) OpCodeData
)->RuleId
;
2380 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2383 // Take a look at next OpCode to see whether current expression consists
2386 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2387 SingleOpCodeExpression
= TRUE
;
2391 case EFI_IFR_READ_OP
:
2392 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2393 CurrentExpression
->Type
= EFI_HII_EXPRESSION_READ
;
2394 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2397 // Make sure CurrentStatement is not NULL.
2398 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2399 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2401 ASSERT (ParentStatement
!= NULL
);
2402 ParentStatement
->ReadExpression
= CurrentExpression
;
2405 // Take a look at next OpCode to see whether current expression consists
2408 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2409 SingleOpCodeExpression
= TRUE
;
2413 case EFI_IFR_WRITE_OP
:
2414 CurrentExpression
= CreateExpression (CurrentForm
, OpCodeData
);
2415 CurrentExpression
->Type
= EFI_HII_EXPRESSION_WRITE
;
2416 InsertTailList (&CurrentForm
->ExpressionListHead
, &CurrentExpression
->Link
);
2419 // Make sure CurrentStatement is not NULL.
2420 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2421 // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
2423 ASSERT (ParentStatement
!= NULL
);
2424 ParentStatement
->WriteExpression
= CurrentExpression
;
2427 // Take a look at next OpCode to see whether current expression consists
2430 if (((EFI_IFR_OP_HEADER
*) (OpCodeData
+ OpCodeLength
))->Scope
== 0) {
2431 SingleOpCodeExpression
= TRUE
;
2438 case EFI_IFR_IMAGE_OP
:
2440 // Get ScopeOpcode from top of stack
2442 PopScope (&ScopeOpCode
);
2443 PushScope (ScopeOpCode
);
2445 switch (ScopeOpCode
) {
2446 case EFI_IFR_FORM_SET_OP
:
2447 ImageId
= &FormSet
->ImageId
;
2450 case EFI_IFR_FORM_OP
:
2451 case EFI_IFR_FORM_MAP_OP
:
2452 ASSERT (CurrentForm
!= NULL
);
2453 ImageId
= &CurrentForm
->ImageId
;
2456 case EFI_IFR_ONE_OF_OPTION_OP
:
2457 ASSERT (CurrentOption
!= NULL
);
2458 ImageId
= &CurrentOption
->ImageId
;
2463 // Make sure CurrentStatement is not NULL.
2464 // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
2465 // file is wrongly generated by tools such as VFR Compiler.
2467 ASSERT (ParentStatement
!= NULL
);
2468 ImageId
= &ParentStatement
->ImageId
;
2472 ASSERT (ImageId
!= NULL
);
2473 CopyMem (ImageId
, &((EFI_IFR_IMAGE
*) OpCodeData
)->Id
, sizeof (EFI_IMAGE_ID
));
2479 case EFI_IFR_REFRESH_OP
:
2480 ASSERT (ParentStatement
!= NULL
);
2481 ParentStatement
->RefreshInterval
= ((EFI_IFR_REFRESH
*) OpCodeData
)->RefreshInterval
;
2487 case EFI_IFR_REFRESH_ID_OP
:
2489 // Get ScopeOpcode from top of stack
2491 PopScope (&ScopeOpCode
);
2492 PushScope (ScopeOpCode
);
2494 switch (ScopeOpCode
) {
2495 case EFI_IFR_FORM_OP
:
2496 case EFI_IFR_FORM_MAP_OP
:
2497 ASSERT (CurrentForm
!= NULL
);
2498 CopyMem (&CurrentForm
->RefreshGuid
, &((EFI_IFR_REFRESH_ID
*) OpCodeData
)->RefreshEventGroupId
, sizeof (EFI_GUID
));
2502 ASSERT (ParentStatement
!= NULL
);
2503 CopyMem (&ParentStatement
->RefreshGuid
, &((EFI_IFR_REFRESH_ID
*) OpCodeData
)->RefreshEventGroupId
, sizeof (EFI_GUID
));
2511 case EFI_IFR_MODAL_TAG_OP
:
2512 ASSERT (CurrentForm
!= NULL
);
2513 CurrentForm
->ModalForm
= TRUE
;
2517 // Lock tag, used by form and statement.
2519 case EFI_IFR_LOCKED_OP
:
2521 // Get ScopeOpcode from top of stack
2523 PopScope (&ScopeOpCode
);
2524 PushScope (ScopeOpCode
);
2525 switch (ScopeOpCode
) {
2526 case EFI_IFR_FORM_OP
:
2527 case EFI_IFR_FORM_MAP_OP
:
2528 ASSERT (CurrentForm
!= NULL
);
2529 CurrentForm
->Locked
= TRUE
;
2533 ASSERT (ParentStatement
!= NULL
);
2534 ParentStatement
->Locked
= TRUE
;
2541 case EFI_IFR_GUID_OP
:
2542 CurrentStatement
= CreateStatement (OpCodeData
, FormSet
, CurrentForm
);
2543 if (CompareGuid ((EFI_GUID
*)(OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
)), &gEdkiiIfrBitVarstoreGuid
)) {
2545 QuestionReferBitField
= TRUE
;
2552 case EFI_IFR_END_OP
:
2553 QuestionReferBitField
= FALSE
;
2554 Status
= PopScope (&ScopeOpCode
);
2555 if (EFI_ERROR (Status
)) {
2561 // Parent statement end tag found, update ParentStatement info.
2563 if (IsStatementOpCode(ScopeOpCode
) && (ParentStatement
!= NULL
) && (ParentStatement
->Operand
== ScopeOpCode
)) {
2564 ParentStatement
= ParentStatement
->ParentStatement
;
2567 switch (ScopeOpCode
) {
2568 case EFI_IFR_FORM_SET_OP
:
2570 // End of FormSet, update FormSet IFR binary length
2571 // to stop parsing substantial OpCodes
2573 FormSet
->IfrBinaryLength
= OpCodeOffset
;
2576 case EFI_IFR_FORM_OP
:
2577 case EFI_IFR_FORM_MAP_OP
:
2582 SuppressForQuestion
= FALSE
;
2585 case EFI_IFR_ONE_OF_OPTION_OP
:
2589 CurrentOption
= NULL
;
2592 case EFI_IFR_NO_SUBMIT_IF_OP
:
2593 case EFI_IFR_INCONSISTENT_IF_OP
:
2594 case EFI_IFR_WARNING_IF_OP
:
2596 // Ignore end of EFI_IFR_NO_SUBMIT_IF and EFI_IFR_INCONSISTENT_IF
2600 case EFI_IFR_SUPPRESS_IF_OP
:
2601 if (SuppressForOption
) {
2602 PopConditionalExpression(ExpressOption
);
2603 } else if (SuppressForQuestion
) {
2604 PopConditionalExpression(ExpressStatement
);
2606 PopConditionalExpression(ExpressForm
);
2610 case EFI_IFR_GRAY_OUT_IF_OP
:
2611 PopConditionalExpression(ExpressStatement
);
2614 case EFI_IFR_DISABLE_IF_OP
:
2615 if (CurrentForm
!= NULL
) {
2616 PopConditionalExpression(ExpressStatement
);
2618 InScopeDisable
= FALSE
;
2619 OpCodeDisabled
= FALSE
;
2622 case EFI_IFR_ONE_OF_OP
:
2623 case EFI_IFR_ORDERED_LIST_OP
:
2624 SuppressForOption
= FALSE
;
2627 case EFI_IFR_DEFAULT_OP
:
2628 InScopeDefault
= FALSE
;
2631 case EFI_IFR_MAP_OP
:
2633 // Get current Map Expression List.
2635 Status
= PopMapExpressionList ((VOID
**) &MapExpressionList
);
2636 if (Status
== EFI_ACCESS_DENIED
) {
2637 MapExpressionList
= NULL
;
2640 // Get current expression.
2642 Status
= PopCurrentExpression ((VOID
**) &CurrentExpression
);
2643 ASSERT_EFI_ERROR (Status
);
2644 ASSERT (MapScopeDepth
> 0);
2649 if (IsExpressionOpCode (ScopeOpCode
)) {
2650 if (InScopeDisable
&& CurrentForm
== NULL
) {
2652 // This is DisableIf expression for Form, it should be a constant expression
2654 ASSERT (CurrentExpression
!= NULL
);
2655 Status
= EvaluateExpression (FormSet
, CurrentForm
, CurrentExpression
);
2656 if (EFI_ERROR (Status
)) {
2660 OpCodeDisabled
= IsTrue (&CurrentExpression
->Result
);
2663 // DisableIf Expression is only used once and not queued, free it
2665 DestroyExpression (CurrentExpression
);
2669 // End of current Expression
2671 CurrentExpression
= NULL
;
2681 if (IsStatementOpCode(Operand
)) {
2682 CurrentStatement
->ParentStatement
= ParentStatement
;
2685 // Scope != 0, other statements or options may nest in this statement.
2686 // Update the ParentStatement info.
2688 ParentStatement
= CurrentStatement
;