2 Utility functions for UI presentation.
4 Copyright (c) 2004 - 2013, 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 BOOLEAN mHiiPackageListUpdated
;
18 UI_MENU_SELECTION
*gCurrentSelection
;
19 EFI_HII_HANDLE mCurrentHiiHandle
= NULL
;
20 EFI_GUID mCurrentFormSetGuid
= {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
21 UINT16 mCurrentFormId
= 0;
22 EFI_EVENT mValueChangedEvent
= NULL
;
23 LIST_ENTRY mRefreshEventList
= INITIALIZE_LIST_HEAD_VARIABLE (mRefreshEventList
);
24 UINT32 gBrowserStatus
= BROWSER_SUCCESS
;
26 UINT16 mCurFakeQestId
;
27 FORM_DISPLAY_ENGINE_FORM gDisplayFormData
;
30 Evaluate all expressions in a Form.
32 @param FormSet FormSet this Form belongs to.
35 @retval EFI_SUCCESS The expression evaluated successfuly
39 EvaluateFormExpressions (
40 IN FORM_BROWSER_FORMSET
*FormSet
,
41 IN FORM_BROWSER_FORM
*Form
46 FORM_EXPRESSION
*Expression
;
48 Link
= GetFirstNode (&Form
->ExpressionListHead
);
49 while (!IsNull (&Form
->ExpressionListHead
, Link
)) {
50 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
51 Link
= GetNextNode (&Form
->ExpressionListHead
, Link
);
53 if (Expression
->Type
== EFI_HII_EXPRESSION_INCONSISTENT_IF
||
54 Expression
->Type
== EFI_HII_EXPRESSION_NO_SUBMIT_IF
||
55 Expression
->Type
== EFI_HII_EXPRESSION_WARNING_IF
||
56 Expression
->Type
== EFI_HII_EXPRESSION_WRITE
||
57 (Expression
->Type
== EFI_HII_EXPRESSION_READ
&& Form
->FormType
!= STANDARD_MAP_FORM_TYPE
)) {
59 // Postpone Form validation to Question editing or Form submitting or Question Write or Question Read for nonstandard form.
64 Status
= EvaluateExpression (FormSet
, Form
, Expression
);
65 if (EFI_ERROR (Status
)) {
74 Add empty function for event process function.
76 @param Event The Event need to be process
77 @param Context The context of the event.
82 SetupBrowserEmptyFunction (
90 Base on the opcode buffer info to get the display statement.
92 @param OpCode The input opcode buffer for this statement.
94 @retval Statement The statement use this opcode buffer.
97 FORM_DISPLAY_ENGINE_STATEMENT
*
99 IN EFI_IFR_OP_HEADER
*OpCode
102 FORM_DISPLAY_ENGINE_STATEMENT
*DisplayStatement
;
105 Link
= GetFirstNode (&gDisplayFormData
.StatementListHead
);
106 while (!IsNull (&gDisplayFormData
.StatementListHead
, Link
)) {
107 DisplayStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
109 if (DisplayStatement
->OpCode
== OpCode
) {
110 return DisplayStatement
;
112 Link
= GetNextNode (&gDisplayFormData
.StatementListHead
, Link
);
119 Free the refresh event list.
128 FORM_BROWSER_REFRESH_EVENT_NODE
*EventNode
;
130 while (!IsListEmpty (&mRefreshEventList
)) {
131 Link
= GetFirstNode (&mRefreshEventList
);
132 EventNode
= FORM_BROWSER_REFRESH_EVENT_FROM_LINK (Link
);
133 RemoveEntryList (&EventNode
->Link
);
135 gBS
->CloseEvent (EventNode
->RefreshEvent
);
137 FreePool (EventNode
);
142 Check whether this statement value is changed. If yes, update the statement value and return TRUE;
145 @param Statement The statement need to check.
150 IN OUT FORM_BROWSER_STATEMENT
*Statement
153 GetQuestionValue (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, GetSetValueWithHiiDriver
);
156 // Reset FormPackage update flag
158 mHiiPackageListUpdated
= FALSE
;
161 // Question value may be changed, need invoke its Callback()
163 ProcessCallBackFunction (gCurrentSelection
, gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, EFI_BROWSER_ACTION_RETRIEVE
, FALSE
);
165 if (mHiiPackageListUpdated
) {
167 // Package list is updated, force to reparse IFR binary of target Formset
169 mHiiPackageListUpdated
= FALSE
;
170 gCurrentSelection
->Action
= UI_ACTION_REFRESH_FORMSET
;
175 Refresh the question which has refresh guid event attribute.
177 @param Event The event which has this function related.
178 @param Context The input context info related to this event or the status code return to the caller.
187 FORM_BROWSER_STATEMENT
*Statement
;
189 Statement
= (FORM_BROWSER_STATEMENT
*)Context
;
190 UpdateStatement(Statement
);
191 gBS
->SignalEvent (mValueChangedEvent
);
196 Create refresh hook event for statement which has refresh event or interval.
198 @param Statement The statement need to check.
203 IN FORM_BROWSER_STATEMENT
*Statement
207 EFI_EVENT RefreshEvent
;
208 FORM_BROWSER_REFRESH_EVENT_NODE
*EventNode
;
211 // If question has refresh guid, create the notify function.
213 Status
= gBS
->CreateEventEx (
218 &Statement
->RefreshGuid
,
220 ASSERT_EFI_ERROR (Status
);
222 EventNode
= AllocateZeroPool (sizeof (FORM_BROWSER_REFRESH_EVENT_NODE
));
223 ASSERT (EventNode
!= NULL
);
224 EventNode
->RefreshEvent
= RefreshEvent
;
225 InsertTailList(&mRefreshEventList
, &EventNode
->Link
);
229 Perform value check for a question.
231 @param Question The question need to do check.
232 @param Type Condition type need to check.
233 @param ErrorInfo Return info about the error.
235 @retval The check result.
239 IN FORM_BROWSER_STATEMENT
*Question
,
241 OUT STATEMENT_ERROR_INFO
*ErrorInfo
246 FORM_EXPRESSION
*Expression
;
247 LIST_ENTRY
*ListHead
;
250 RetVal
= STATEMENT_VALID
;
254 case EFI_HII_EXPRESSION_INCONSISTENT_IF
:
255 ListHead
= &Question
->InconsistentListHead
;
258 case EFI_HII_EXPRESSION_WARNING_IF
:
259 ListHead
= &Question
->WarningListHead
;
267 ASSERT (ListHead
!= NULL
);
268 Link
= GetFirstNode (ListHead
);
269 while (!IsNull (ListHead
, Link
)) {
270 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
271 Link
= GetNextNode (ListHead
, Link
);
274 // Evaluate the expression
276 Status
= EvaluateExpression (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Expression
);
277 if (EFI_ERROR (Status
)) {
281 if ((Expression
->Result
.Type
== EFI_IFR_TYPE_BOOLEAN
) && Expression
->Result
.Value
.b
) {
282 ErrorInfo
->StringId
= Expression
->Error
;
284 case EFI_HII_EXPRESSION_INCONSISTENT_IF
:
285 ErrorInfo
->TimeOut
= 0;
286 RetVal
= INCOSISTENT_IF_TRUE
;
289 case EFI_HII_EXPRESSION_WARNING_IF
:
290 ErrorInfo
->TimeOut
= Expression
->TimeOut
;
291 RetVal
= WARNING_IF_TRUE
;
306 Perform value check for a question.
308 @param Form Form where Statement is in.
309 @param Statement Value will check for it.
310 @param InputValue New value will be checked.
311 @param ErrorInfo Return the error info for this check.
313 @retval TRUE Input Value is valid.
314 @retval FALSE Input Value is invalid.
319 IN FORM_DISPLAY_ENGINE_FORM
*Form
,
320 IN FORM_DISPLAY_ENGINE_STATEMENT
*Statement
,
321 IN EFI_HII_VALUE
*InputValue
,
322 OUT STATEMENT_ERROR_INFO
*ErrorInfo
325 FORM_BROWSER_STATEMENT
*Question
;
326 EFI_HII_VALUE BackUpValue
;
331 RetVal
= STATEMENT_VALID
;
333 ASSERT (Form
!= NULL
&& Statement
!= NULL
&& InputValue
!= NULL
&& ErrorInfo
!= NULL
);
335 Question
= GetBrowserStatement(Statement
);
336 ASSERT (Question
!= NULL
);
339 // Back up the quesion value.
341 switch (Question
->Operand
) {
342 case EFI_IFR_ORDERED_LIST_OP
:
343 BackUpBuffer
= AllocateCopyPool (Question
->StorageWidth
, Question
->BufferValue
);
344 ASSERT (BackUpBuffer
!= NULL
);
345 CopyMem (Question
->BufferValue
, InputValue
->Buffer
, Question
->StorageWidth
);
349 CopyMem (&BackUpValue
, &Question
->HiiValue
, sizeof (EFI_HII_VALUE
));
350 CopyMem (&Question
->HiiValue
, InputValue
, sizeof (EFI_HII_VALUE
));
355 // Do the inconsistentif check.
357 if (!IsListEmpty (&Question
->InconsistentListHead
)) {
358 RetVal
= ConditionCheck(Question
, EFI_HII_EXPRESSION_INCONSISTENT_IF
, ErrorInfo
);
362 // Do the warningif check.
364 if (RetVal
== STATEMENT_VALID
&& !IsListEmpty (&Question
->WarningListHead
)) {
365 RetVal
= ConditionCheck(Question
, EFI_HII_EXPRESSION_WARNING_IF
, ErrorInfo
);
369 // Restore the quesion value.
371 switch (Question
->Operand
) {
372 case EFI_IFR_ORDERED_LIST_OP
:
373 CopyMem (Question
->BufferValue
, BackUpBuffer
, Question
->StorageWidth
);
377 CopyMem (&Question
->HiiValue
, &BackUpValue
, sizeof (EFI_HII_VALUE
));
386 Initialize the Display statement structure data.
388 @param DisplayStatement Pointer to the display Statement data strucure.
389 @param Statement The statement need to check.
392 InitializeDisplayStatement (
393 IN OUT FORM_DISPLAY_ENGINE_STATEMENT
*DisplayStatement
,
394 IN FORM_BROWSER_STATEMENT
*Statement
398 QUESTION_OPTION
*Option
;
399 DISPLAY_QUESTION_OPTION
*DisplayOption
;
400 FORM_DISPLAY_ENGINE_STATEMENT
*ParentStatement
;
402 DisplayStatement
->Signature
= FORM_DISPLAY_ENGINE_STATEMENT_SIGNATURE
;
403 DisplayStatement
->Version
= FORM_DISPLAY_ENGINE_STATEMENT_VERSION_1
;
404 DisplayStatement
->OpCode
= Statement
->OpCode
;
405 InitializeListHead (&DisplayStatement
->NestStatementList
);
406 InitializeListHead (&DisplayStatement
->OptionListHead
);
408 if ((EvaluateExpressionList(Statement
->Expression
, FALSE
, NULL
, NULL
) == ExpressGrayOut
) || Statement
->Locked
) {
409 DisplayStatement
->Attribute
|= HII_DISPLAY_GRAYOUT
;
411 if ((Statement
->ValueExpression
!= NULL
) || ((Statement
->QuestionFlags
& EFI_IFR_FLAG_READ_ONLY
) != 0)) {
412 DisplayStatement
->Attribute
|= HII_DISPLAY_READONLY
;
416 // Initilize the option list in statement.
418 Link
= GetFirstNode (&Statement
->OptionListHead
);
419 while (!IsNull (&Statement
->OptionListHead
, Link
)) {
420 Option
= QUESTION_OPTION_FROM_LINK (Link
);
421 Link
= GetNextNode (&Statement
->OptionListHead
, Link
);
422 if ((Option
->SuppressExpression
!= NULL
) &&
423 ((EvaluateExpressionList(Option
->SuppressExpression
, FALSE
, NULL
, NULL
) == ExpressSuppress
))) {
427 DisplayOption
= AllocateZeroPool (sizeof (DISPLAY_QUESTION_OPTION
));
428 ASSERT (DisplayOption
!= NULL
);
430 DisplayOption
->ImageId
= Option
->ImageId
;
431 DisplayOption
->Signature
= DISPLAY_QUESTION_OPTION_SIGNATURE
;
432 DisplayOption
->OptionOpCode
= Option
->OpCode
;
433 InsertTailList(&DisplayStatement
->OptionListHead
, &DisplayOption
->Link
);
436 CopyMem (&DisplayStatement
->CurrentValue
, &Statement
->HiiValue
, sizeof (EFI_HII_VALUE
));
439 // Some special op code need an extra buffer to save the data.
440 // Such as string, password, orderedlist...
442 if (Statement
->BufferValue
!= NULL
) {
444 // Ordered list opcode may not initilized, get default value here.
446 if (Statement
->OpCode
->OpCode
== EFI_IFR_ORDERED_LIST_OP
&& GetArrayData (Statement
->BufferValue
, Statement
->ValueType
, 0) == 0) {
447 GetQuestionDefault (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, 0);
450 DisplayStatement
->CurrentValue
.Buffer
= AllocateCopyPool(Statement
->StorageWidth
,Statement
->BufferValue
);
451 DisplayStatement
->CurrentValue
.BufferLen
= Statement
->StorageWidth
;
454 DisplayStatement
->SettingChangedFlag
= Statement
->ValueChanged
;
457 // Get the highlight statement for current form.
459 if (((gCurrentSelection
->QuestionId
!= 0) && (Statement
->QuestionId
== gCurrentSelection
->QuestionId
)) ||
460 ((mCurFakeQestId
!= 0) && (Statement
->FakeQuestionId
== mCurFakeQestId
))) {
461 gDisplayFormData
.HighLightedStatement
= DisplayStatement
;
465 // Create the refresh event process function.
467 if (!CompareGuid (&Statement
->RefreshGuid
, &gZeroGuid
)) {
468 CreateRefreshEvent (Statement
);
472 // For RTC type of date/time, set default refresh interval to be 1 second.
474 if ((Statement
->Operand
== EFI_IFR_DATE_OP
|| Statement
->Operand
== EFI_IFR_TIME_OP
) && Statement
->Storage
== NULL
) {
475 Statement
->RefreshInterval
= 1;
479 // Create the refresh guid hook event.
480 // If the statement in this form has refresh event or refresh interval, browser will create this event for display engine.
482 if ((!CompareGuid (&Statement
->RefreshGuid
, &gZeroGuid
)) || (Statement
->RefreshInterval
!= 0)) {
483 gDisplayFormData
.FormRefreshEvent
= mValueChangedEvent
;
487 // Save the password check function for later use.
489 if (Statement
->Operand
== EFI_IFR_PASSWORD_OP
) {
490 DisplayStatement
->PasswordCheck
= PasswordCheck
;
494 // Save the validate check question for later use.
496 if (!IsListEmpty (&Statement
->InconsistentListHead
) || !IsListEmpty (&Statement
->WarningListHead
)) {
497 DisplayStatement
->ValidateQuestion
= QuestionCheck
;
501 // If this statement is nest in the subtitle, insert to the host statement.
502 // else insert to the form it belongs to.
504 if (Statement
->ParentStatement
!= NULL
) {
505 ParentStatement
= GetDisplayStatement(Statement
->ParentStatement
->OpCode
);
506 ASSERT (ParentStatement
!= NULL
);
507 InsertTailList(&ParentStatement
->NestStatementList
, &DisplayStatement
->DisplayLink
);
509 InsertTailList(&gDisplayFormData
.StatementListHead
, &DisplayStatement
->DisplayLink
);
514 Process for the refresh interval statement.
516 @param Event The Event need to be process
517 @param Context The context of the event.
522 RefreshIntervalProcess (
527 FORM_BROWSER_STATEMENT
*Statement
;
530 Link
= GetFirstNode (&gCurrentSelection
->Form
->StatementListHead
);
531 while (!IsNull (&gCurrentSelection
->Form
->StatementListHead
, Link
)) {
532 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
533 Link
= GetNextNode (&gCurrentSelection
->Form
->StatementListHead
, Link
);
535 if (Statement
->RefreshInterval
== 0) {
539 UpdateStatement(Statement
);
542 gBS
->SignalEvent (mValueChangedEvent
);
547 Make a copy of the global hotkey info.
555 BROWSER_HOT_KEY
*HotKey
;
556 BROWSER_HOT_KEY
*CopyKey
;
559 Link
= GetFirstNode (&gBrowserHotKeyList
);
560 while (!IsNull (&gBrowserHotKeyList
, Link
)) {
561 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
563 CopyKey
= AllocateCopyPool(sizeof (BROWSER_HOT_KEY
), HotKey
);
564 CopyKey
->KeyData
= AllocateCopyPool(sizeof (EFI_INPUT_KEY
), HotKey
->KeyData
);
565 CopyKey
->HelpString
= AllocateCopyPool(StrSize (HotKey
->HelpString
), HotKey
->HelpString
);
567 InsertTailList(&gDisplayFormData
.HotKeyListHead
, &CopyKey
->Link
);
569 Link
= GetNextNode (&gBrowserHotKeyList
, Link
);
575 Get the extra question attribute from override question list.
577 @param QuestionId The question id for this request question.
579 @retval The attribute for this question or NULL if not found this
580 question in the list.
584 ProcessQuestionExtraAttr (
585 IN EFI_QUESTION_ID QuestionId
589 QUESTION_ATTRIBUTE_OVERRIDE
*QuestionDesc
;
592 // Return HII_DISPLAY_NONE if input a invalid question id.
594 if (QuestionId
== 0) {
595 return HII_DISPLAY_NONE
;
598 Link
= GetFirstNode (&mPrivateData
.FormBrowserEx2
.OverrideQestListHead
);
599 while (!IsNull (&mPrivateData
.FormBrowserEx2
.OverrideQestListHead
, Link
)) {
600 QuestionDesc
= FORM_QUESTION_ATTRIBUTE_OVERRIDE_FROM_LINK (Link
);
601 Link
= GetNextNode (&mPrivateData
.FormBrowserEx2
.OverrideQestListHead
, Link
);
603 if ((QuestionDesc
->QuestionId
== QuestionId
) &&
604 (QuestionDesc
->FormId
== gCurrentSelection
->FormId
) &&
605 (QuestionDesc
->HiiHandle
== gCurrentSelection
->Handle
) &&
606 CompareGuid (&QuestionDesc
->FormSetGuid
, &gCurrentSelection
->FormSetGuid
)) {
607 return QuestionDesc
->Attribute
;
611 return HII_DISPLAY_NONE
;
616 Enum all statement in current form, find all the statement can be display and
617 add to the display form.
621 AddStatementToDisplayForm (
627 FORM_BROWSER_STATEMENT
*Statement
;
628 FORM_DISPLAY_ENGINE_STATEMENT
*DisplayStatement
;
629 UINT8 MinRefreshInterval
;
630 EFI_EVENT RefreshIntervalEvent
;
631 FORM_BROWSER_REFRESH_EVENT_NODE
*EventNode
;
632 BOOLEAN FormEditable
;
633 UINT32 ExtraAttribute
;
635 MinRefreshInterval
= 0;
636 FormEditable
= FALSE
;
639 // Process the statement outside the form, these statements are not recognized
642 Link
= GetFirstNode (&gCurrentSelection
->FormSet
->StatementListOSF
);
643 while (!IsNull (&gCurrentSelection
->FormSet
->StatementListOSF
, Link
)) {
644 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
645 Link
= GetNextNode (&gCurrentSelection
->FormSet
->StatementListOSF
, Link
);
647 DisplayStatement
= AllocateZeroPool (sizeof (FORM_DISPLAY_ENGINE_STATEMENT
));
648 ASSERT (DisplayStatement
!= NULL
);
649 DisplayStatement
->Signature
= FORM_DISPLAY_ENGINE_STATEMENT_SIGNATURE
;
650 DisplayStatement
->Version
= FORM_DISPLAY_ENGINE_STATEMENT_VERSION_1
;
651 DisplayStatement
->OpCode
= Statement
->OpCode
;
653 InitializeListHead (&DisplayStatement
->NestStatementList
);
654 InitializeListHead (&DisplayStatement
->OptionListHead
);
656 InsertTailList(&gDisplayFormData
.StatementListOSF
, &DisplayStatement
->DisplayLink
);
660 // Process the statement in this form.
662 Link
= GetFirstNode (&gCurrentSelection
->Form
->StatementListHead
);
663 while (!IsNull (&gCurrentSelection
->Form
->StatementListHead
, Link
)) {
664 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
665 Link
= GetNextNode (&gCurrentSelection
->Form
->StatementListHead
, Link
);
668 // This statement can't be show, skip it.
670 if (EvaluateExpressionList(Statement
->Expression
, FALSE
, NULL
, NULL
) > ExpressGrayOut
) {
675 // Check the extra attribute.
677 ExtraAttribute
= ProcessQuestionExtraAttr (Statement
->QuestionId
);
678 if ((ExtraAttribute
& HII_DISPLAY_SUPPRESS
) != 0) {
682 DisplayStatement
= AllocateZeroPool (sizeof (FORM_DISPLAY_ENGINE_STATEMENT
));
683 ASSERT (DisplayStatement
!= NULL
);
686 // Initialize this statement and add it to the display form.
688 InitializeDisplayStatement(DisplayStatement
, Statement
);
691 // Set the extra attribute.
693 DisplayStatement
->Attribute
|= ExtraAttribute
;
695 if (Statement
->Storage
!= NULL
) {
700 // Get the minimal refresh interval value for later use.
702 if ((Statement
->RefreshInterval
!= 0) &&
703 (MinRefreshInterval
== 0 || Statement
->RefreshInterval
< MinRefreshInterval
)) {
704 MinRefreshInterval
= Statement
->RefreshInterval
;
709 // Create the periodic timer for refresh interval statement.
711 if (MinRefreshInterval
!= 0) {
712 Status
= gBS
->CreateEvent (EVT_TIMER
| EVT_NOTIFY_SIGNAL
, TPL_CALLBACK
, RefreshIntervalProcess
, NULL
, &RefreshIntervalEvent
);
713 ASSERT_EFI_ERROR (Status
);
714 Status
= gBS
->SetTimer (RefreshIntervalEvent
, TimerPeriodic
, MinRefreshInterval
* ONE_SECOND
);
715 ASSERT_EFI_ERROR (Status
);
717 EventNode
= AllocateZeroPool (sizeof (FORM_BROWSER_REFRESH_EVENT_NODE
));
718 ASSERT (EventNode
!= NULL
);
719 EventNode
->RefreshEvent
= RefreshIntervalEvent
;
720 InsertTailList(&mRefreshEventList
, &EventNode
->Link
);
724 // Update hotkey list field.
726 if (gBrowserSettingScope
== SystemLevel
|| FormEditable
) {
733 Initialize the SettingChangedFlag variable in the display form.
737 UpdateDataChangedFlag (
742 FORM_BROWSER_FORMSET
*LocalFormSet
;
744 gDisplayFormData
.SettingChangedFlag
= FALSE
;
746 if (IsNvUpdateRequiredForForm (gCurrentSelection
->Form
)) {
747 gDisplayFormData
.SettingChangedFlag
= TRUE
;
752 // Base on the system level to check whether need to show the NV flag.
754 switch (gBrowserSettingScope
) {
757 // Check the maintain list to see whether there is any change.
759 Link
= GetFirstNode (&gBrowserFormSetList
);
760 while (!IsNull (&gBrowserFormSetList
, Link
)) {
761 LocalFormSet
= FORM_BROWSER_FORMSET_FROM_LINK (Link
);
762 if (IsNvUpdateRequiredForFormSet(LocalFormSet
)) {
763 gDisplayFormData
.SettingChangedFlag
= TRUE
;
766 Link
= GetNextNode (&gBrowserFormSetList
, Link
);
771 if (IsNvUpdateRequiredForFormSet(gCurrentSelection
->FormSet
)) {
772 gDisplayFormData
.SettingChangedFlag
= TRUE
;
784 Initialize the Display form structure data.
788 InitializeDisplayFormData (
794 gDisplayFormData
.Signature
= FORM_DISPLAY_ENGINE_FORM_SIGNATURE
;
795 gDisplayFormData
.Version
= FORM_DISPLAY_ENGINE_VERSION_1
;
796 gDisplayFormData
.ImageId
= 0;
797 gDisplayFormData
.AnimationId
= 0;
799 InitializeListHead (&gDisplayFormData
.StatementListHead
);
800 InitializeListHead (&gDisplayFormData
.StatementListOSF
);
801 InitializeListHead (&gDisplayFormData
.HotKeyListHead
);
803 Status
= gBS
->CreateEvent (
806 SetupBrowserEmptyFunction
,
810 ASSERT_EFI_ERROR (Status
);
815 Free the kotkey info saved in form data.
823 BROWSER_HOT_KEY
*HotKey
;
826 while (!IsListEmpty (&gDisplayFormData
.HotKeyListHead
)) {
827 Link
= GetFirstNode (&gDisplayFormData
.HotKeyListHead
);
828 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
830 RemoveEntryList (&HotKey
->Link
);
832 FreePool (HotKey
->KeyData
);
833 FreePool (HotKey
->HelpString
);
840 Update the Display form structure data.
844 UpdateDisplayFormData (
848 gDisplayFormData
.FormTitle
= gCurrentSelection
->Form
->FormTitle
;
849 gDisplayFormData
.FormId
= gCurrentSelection
->FormId
;
850 gDisplayFormData
.HiiHandle
= gCurrentSelection
->Handle
;
851 CopyGuid (&gDisplayFormData
.FormSetGuid
, &gCurrentSelection
->FormSetGuid
);
853 gDisplayFormData
.Attribute
= 0;
854 gDisplayFormData
.Attribute
|= gCurrentSelection
->Form
->ModalForm
? HII_DISPLAY_MODAL
: 0;
855 gDisplayFormData
.Attribute
|= gCurrentSelection
->Form
->Locked
? HII_DISPLAY_LOCK
: 0;
857 gDisplayFormData
.FormRefreshEvent
= NULL
;
858 gDisplayFormData
.HighLightedStatement
= NULL
;
860 gDisplayFormData
.BrowserStatus
= gBrowserStatus
;
861 gDisplayFormData
.ErrorString
= gErrorInfo
;
863 gBrowserStatus
= BROWSER_SUCCESS
;
866 UpdateDataChangedFlag ();
868 AddStatementToDisplayForm ();
873 Free the Display Statement structure data.
875 @param StatementList Point to the statement list which need to be free.
880 LIST_ENTRY
*StatementList
884 LIST_ENTRY
*OptionLink
;
885 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
886 DISPLAY_QUESTION_OPTION
*Option
;
889 // Free Statements/Questions
891 while (!IsListEmpty (StatementList
)) {
892 Link
= GetFirstNode (StatementList
);
893 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
898 while (!IsListEmpty (&Statement
->OptionListHead
)) {
899 OptionLink
= GetFirstNode (&Statement
->OptionListHead
);
900 Option
= DISPLAY_QUESTION_OPTION_FROM_LINK (OptionLink
);
901 RemoveEntryList (&Option
->Link
);
906 // Free nest statement List
908 if (!IsListEmpty (&Statement
->NestStatementList
)) {
909 FreeStatementData(&Statement
->NestStatementList
);
912 RemoveEntryList (&Statement
->DisplayLink
);
913 FreePool (Statement
);
919 Free the Display form structure data.
923 FreeDisplayFormData (
927 FreeStatementData (&gDisplayFormData
.StatementListHead
);
928 FreeStatementData (&gDisplayFormData
.StatementListOSF
);
937 Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
939 @param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.
941 @retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.
944 FORM_BROWSER_STATEMENT
*
945 GetBrowserStatement (
946 IN FORM_DISPLAY_ENGINE_STATEMENT
*DisplayStatement
949 FORM_BROWSER_STATEMENT
*Statement
;
952 Link
= GetFirstNode (&gCurrentSelection
->Form
->StatementListHead
);
953 while (!IsNull (&gCurrentSelection
->Form
->StatementListHead
, Link
)) {
954 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
956 if (Statement
->OpCode
== DisplayStatement
->OpCode
) {
960 Link
= GetNextNode (&gCurrentSelection
->Form
->StatementListHead
, Link
);
968 Process the action request in user input.
970 @param Action The user input action request info.
971 @param DefaultId The user input default Id info.
973 @retval EFI_SUCESSS This function always return successfully for now.
985 // This is caused by use press ESC, and it should not combine with other action type.
987 if ((Action
& BROWSER_ACTION_FORM_EXIT
) == BROWSER_ACTION_FORM_EXIT
) {
988 FindNextMenu (gCurrentSelection
, FormLevel
);
993 // Below is normal hotkey trigged action, these action maybe combine with each other.
995 if ((Action
& BROWSER_ACTION_DISCARD
) == BROWSER_ACTION_DISCARD
) {
996 DiscardForm (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, gBrowserSettingScope
);
999 if ((Action
& BROWSER_ACTION_DEFAULT
) == BROWSER_ACTION_DEFAULT
) {
1000 ExtractDefault (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, DefaultId
, gBrowserSettingScope
, GetDefaultForAll
, NULL
, FALSE
);
1003 if ((Action
& BROWSER_ACTION_SUBMIT
) == BROWSER_ACTION_SUBMIT
) {
1004 Status
= SubmitForm (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, gBrowserSettingScope
);
1005 if (EFI_ERROR (Status
)) {
1006 gBrowserStatus
= BROWSER_SUBMIT_FAIL
;
1010 if ((Action
& BROWSER_ACTION_RESET
) == BROWSER_ACTION_RESET
) {
1011 gResetRequired
= TRUE
;
1014 if ((Action
& BROWSER_ACTION_EXIT
) == BROWSER_ACTION_EXIT
) {
1016 // Form Exit without saving, Similar to ESC Key.
1017 // FormSet Exit without saving, Exit SendForm.
1018 // System Exit without saving, CallExitHandler and Exit SendForm.
1020 DiscardForm (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, gBrowserSettingScope
);
1021 if (gBrowserSettingScope
== FormLevel
|| gBrowserSettingScope
== FormSetLevel
) {
1022 FindNextMenu (gCurrentSelection
, gBrowserSettingScope
);
1023 } else if (gBrowserSettingScope
== SystemLevel
) {
1024 if (ExitHandlerFunction
!= NULL
) {
1025 ExitHandlerFunction ();
1027 gCurrentSelection
->Action
= UI_ACTION_EXIT
;
1035 Check whether the formset guid is in this Hii package list.
1037 @param HiiHandle The HiiHandle for this HII package list.
1038 @param FormSetGuid The formset guid for the request formset.
1040 @retval TRUE Find the formset guid.
1041 @retval FALSE Not found the formset guid.
1045 GetFormsetGuidFromHiiHandle (
1046 IN EFI_HII_HANDLE HiiHandle
,
1047 IN EFI_GUID
*FormSetGuid
1050 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
1054 UINT32 PackageListLength
;
1055 EFI_HII_PACKAGE_HEADER PackageHeader
;
1062 HiiPackageList
= NULL
;
1065 Status
= mHiiDatabase
->ExportPackageLists (mHiiDatabase
, HiiHandle
, &BufferSize
, HiiPackageList
);
1066 if (Status
== EFI_BUFFER_TOO_SMALL
) {
1067 HiiPackageList
= AllocatePool (BufferSize
);
1068 ASSERT (HiiPackageList
!= NULL
);
1070 Status
= mHiiDatabase
->ExportPackageLists (mHiiDatabase
, HiiHandle
, &BufferSize
, HiiPackageList
);
1072 if (EFI_ERROR (Status
) || HiiPackageList
== NULL
) {
1077 // Get Form package from this HII package List
1079 Offset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
1081 CopyMem (&PackageListLength
, &HiiPackageList
->PackageLength
, sizeof (UINT32
));
1083 while (Offset
< PackageListLength
) {
1084 Package
= ((UINT8
*) HiiPackageList
) + Offset
;
1085 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
1086 Offset
+= PackageHeader
.Length
;
1088 if (PackageHeader
.Type
== EFI_HII_PACKAGE_FORMS
) {
1090 // Search FormSet in this Form Package
1092 Offset2
= sizeof (EFI_HII_PACKAGE_HEADER
);
1093 while (Offset2
< PackageHeader
.Length
) {
1094 OpCodeData
= Package
+ Offset2
;
1096 if (((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
== EFI_IFR_FORM_SET_OP
) {
1097 if (CompareGuid (FormSetGuid
, (EFI_GUID
*)(OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
)))){
1103 Offset2
+= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
1111 FreePool (HiiPackageList
);
1117 Find HII Handle in the HII database associated with given Device Path.
1119 If DevicePath is NULL, then ASSERT.
1121 @param DevicePath Device Path associated with the HII package list
1123 @param FormsetGuid The formset guid for this formset.
1125 @retval Handle HII package list Handle associated with the Device
1127 @retval NULL Hii Package list handle is not found.
1131 DevicePathToHiiHandle (
1132 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1133 IN EFI_GUID
*FormsetGuid
1137 EFI_DEVICE_PATH_PROTOCOL
*TmpDevicePath
;
1140 EFI_HANDLE DriverHandle
;
1141 EFI_HII_HANDLE
*HiiHandles
;
1142 EFI_HII_HANDLE HiiHandle
;
1144 ASSERT (DevicePath
!= NULL
);
1146 TmpDevicePath
= DevicePath
;
1148 // Locate Device Path Protocol handle buffer
1150 Status
= gBS
->LocateDevicePath (
1151 &gEfiDevicePathProtocolGuid
,
1155 if (EFI_ERROR (Status
) || !IsDevicePathEnd (TmpDevicePath
)) {
1160 // Retrieve all HII Handles from HII database
1162 HiiHandles
= HiiGetHiiHandles (NULL
);
1163 if (HiiHandles
== NULL
) {
1168 // Search Hii Handle by Driver Handle
1171 for (Index
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
1172 Status
= mHiiDatabase
->GetPackageListHandle (
1177 if (!EFI_ERROR (Status
) && (Handle
== DriverHandle
)) {
1178 if (GetFormsetGuidFromHiiHandle(HiiHandles
[Index
], FormsetGuid
)) {
1179 HiiHandle
= HiiHandles
[Index
];
1183 if (HiiHandle
!= NULL
) {
1189 FreePool (HiiHandles
);
1194 Find HII Handle in the HII database associated with given form set guid.
1196 If FormSetGuid is NULL, then ASSERT.
1198 @param ComparingGuid FormSet Guid associated with the HII package list
1201 @retval Handle HII package list Handle associated with the Device
1203 @retval NULL Hii Package list handle is not found.
1207 FormSetGuidToHiiHandle (
1208 EFI_GUID
*ComparingGuid
1211 EFI_HII_HANDLE
*HiiHandles
;
1212 EFI_HII_HANDLE HiiHandle
;
1215 ASSERT (ComparingGuid
!= NULL
);
1219 // Get all the Hii handles
1221 HiiHandles
= HiiGetHiiHandles (NULL
);
1222 ASSERT (HiiHandles
!= NULL
);
1225 // Search for formset of each class type
1227 for (Index
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
1228 if (GetFormsetGuidFromHiiHandle(HiiHandles
[Index
], ComparingGuid
)) {
1229 HiiHandle
= HiiHandles
[Index
];
1233 if (HiiHandle
!= NULL
) {
1238 FreePool (HiiHandles
);
1244 check how to process the changed data in current form or form set.
1246 @param Selection On input, Selection tell setup browser the information
1247 about the Selection, form and formset to be displayed.
1248 On output, Selection return the screen item that is selected
1251 @param Scope Data save or discard scope, form or formset.
1253 @retval TRUE Success process the changed data, will return to the parent form.
1254 @retval FALSE Reject to process the changed data, will stay at current form.
1257 ProcessChangedData (
1258 IN OUT UI_MENU_SELECTION
*Selection
,
1259 IN BROWSER_SETTING_SCOPE Scope
1265 switch (mFormDisplay
->ConfirmDataChange()) {
1266 case BROWSER_ACTION_DISCARD
:
1267 DiscardForm (Selection
->FormSet
, Selection
->Form
, Scope
);
1270 case BROWSER_ACTION_SUBMIT
:
1271 SubmitForm (Selection
->FormSet
, Selection
->Form
, Scope
);
1274 case BROWSER_ACTION_NONE
:
1280 // if Invalid value return, process same as BROWSER_ACTION_NONE.
1290 Find parent formset menu(the first menu which has different formset) for current menu.
1291 If not find, just return to the first menu.
1293 @param Selection The selection info.
1298 IN OUT UI_MENU_SELECTION
*Selection
1301 FORM_ENTRY_INFO
*CurrentMenu
;
1302 FORM_ENTRY_INFO
*ParentMenu
;
1304 CurrentMenu
= Selection
->CurrentMenu
;
1305 ParentMenu
= UiFindParentMenu(CurrentMenu
);
1308 // Find a menu which has different formset guid with current.
1310 while (ParentMenu
!= NULL
&& CompareGuid (&CurrentMenu
->FormSetGuid
, &ParentMenu
->FormSetGuid
)) {
1311 CurrentMenu
= ParentMenu
;
1312 ParentMenu
= UiFindParentMenu(CurrentMenu
);
1315 if (ParentMenu
!= NULL
) {
1316 CopyMem (&Selection
->FormSetGuid
, &ParentMenu
->FormSetGuid
, sizeof (EFI_GUID
));
1317 Selection
->Handle
= ParentMenu
->HiiHandle
;
1318 Selection
->FormId
= ParentMenu
->FormId
;
1319 Selection
->QuestionId
= ParentMenu
->QuestionId
;
1321 Selection
->FormId
= CurrentMenu
->FormId
;
1322 Selection
->QuestionId
= CurrentMenu
->QuestionId
;
1325 Selection
->Statement
= NULL
;
1329 Process the goto op code, update the info in the selection structure.
1331 @param Statement The statement belong to goto op code.
1332 @param Selection The selection info.
1334 @retval EFI_SUCCESS The menu process successfully.
1335 @return Other value if the process failed.
1339 IN OUT FORM_BROWSER_STATEMENT
*Statement
,
1340 IN OUT UI_MENU_SELECTION
*Selection
1344 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
1345 FORM_BROWSER_FORM
*RefForm
;
1347 EFI_HII_HANDLE HiiHandle
;
1349 Status
= EFI_SUCCESS
;
1354 // Prepare the device path check, get the device path info first.
1356 if (Statement
->HiiValue
.Value
.ref
.DevicePath
!= 0) {
1357 StringPtr
= GetToken (Statement
->HiiValue
.Value
.ref
.DevicePath
, Selection
->FormSet
->HiiHandle
);
1361 // Check whether the device path string is a valid string.
1363 if (Statement
->HiiValue
.Value
.ref
.DevicePath
!= 0 && StringPtr
!= NULL
&& StringPtr
[0] != L
'\0') {
1364 if (Selection
->Form
->ModalForm
) {
1369 // Goto another Hii Package list
1371 if (mPathFromText
!= NULL
) {
1372 DevicePath
= mPathFromText
->ConvertTextToDevicePath(StringPtr
);
1373 if (DevicePath
!= NULL
) {
1374 HiiHandle
= DevicePathToHiiHandle (DevicePath
, &Statement
->HiiValue
.Value
.ref
.FormSetGuid
);
1375 FreePool (DevicePath
);
1377 FreePool (StringPtr
);
1380 // Not found the EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL protocol.
1382 gBrowserStatus
= BROWSER_PROTOCOL_NOT_FOUND
;
1383 FreePool (StringPtr
);
1387 if (HiiHandle
!= Selection
->Handle
) {
1389 // Goto another Formset, check for uncommitted data
1391 if ((gBrowserSettingScope
== FormLevel
|| gBrowserSettingScope
== FormSetLevel
) &&
1392 IsNvUpdateRequiredForFormSet(Selection
->FormSet
)) {
1393 if (!ProcessChangedData(Selection
, FormSetLevel
)) {
1399 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1400 Selection
->Handle
= HiiHandle
;
1401 if (Selection
->Handle
== NULL
) {
1403 // If target Hii Handle not found, exit current formset.
1405 FindParentFormSet(Selection
);
1409 CopyMem (&Selection
->FormSetGuid
,&Statement
->HiiValue
.Value
.ref
.FormSetGuid
, sizeof (EFI_GUID
));
1410 Selection
->FormId
= Statement
->HiiValue
.Value
.ref
.FormId
;
1411 Selection
->QuestionId
= Statement
->HiiValue
.Value
.ref
.QuestionId
;
1412 } else if (!CompareGuid (&Statement
->HiiValue
.Value
.ref
.FormSetGuid
, &gZeroGuid
)) {
1413 if (Selection
->Form
->ModalForm
) {
1416 if (!CompareGuid (&Statement
->HiiValue
.Value
.ref
.FormSetGuid
, &Selection
->FormSetGuid
)) {
1418 // Goto another Formset, check for uncommitted data
1420 if ((gBrowserSettingScope
== FormLevel
|| gBrowserSettingScope
== FormSetLevel
) &&
1421 IsNvUpdateRequiredForFormSet(Selection
->FormSet
)) {
1422 if (!ProcessChangedData(Selection
, FormSetLevel
)) {
1428 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1429 Selection
->Handle
= FormSetGuidToHiiHandle(&Statement
->HiiValue
.Value
.ref
.FormSetGuid
);
1430 if (Selection
->Handle
== NULL
) {
1432 // If target Hii Handle not found, exit current formset.
1434 FindParentFormSet(Selection
);
1438 CopyMem (&Selection
->FormSetGuid
, &Statement
->HiiValue
.Value
.ref
.FormSetGuid
, sizeof (EFI_GUID
));
1439 Selection
->FormId
= Statement
->HiiValue
.Value
.ref
.FormId
;
1440 Selection
->QuestionId
= Statement
->HiiValue
.Value
.ref
.QuestionId
;
1441 } else if (Statement
->HiiValue
.Value
.ref
.FormId
!= 0) {
1443 // Goto another Form, check for uncommitted data
1445 if (Statement
->HiiValue
.Value
.ref
.FormId
!= Selection
->FormId
) {
1446 if ((gBrowserSettingScope
== FormLevel
&& IsNvUpdateRequiredForForm(Selection
->Form
))) {
1447 if (!ProcessChangedData (Selection
, FormLevel
)) {
1453 RefForm
= IdToForm (Selection
->FormSet
, Statement
->HiiValue
.Value
.ref
.FormId
);
1454 if ((RefForm
!= NULL
) && (RefForm
->SuppressExpression
!= NULL
)) {
1455 if (EvaluateExpressionList(RefForm
->SuppressExpression
, TRUE
, Selection
->FormSet
, RefForm
) != ExpressFalse
) {
1457 // Form is suppressed.
1459 gBrowserStatus
= BROWSER_FORM_SUPPRESS
;
1464 Selection
->FormId
= Statement
->HiiValue
.Value
.ref
.FormId
;
1465 Selection
->QuestionId
= Statement
->HiiValue
.Value
.ref
.QuestionId
;
1466 } else if (Statement
->HiiValue
.Value
.ref
.QuestionId
!= 0) {
1467 Selection
->QuestionId
= Statement
->HiiValue
.Value
.ref
.QuestionId
;
1475 Process Question Config.
1477 @param Selection The UI menu selection.
1478 @param Question The Question to be peocessed.
1480 @retval EFI_SUCCESS Question Config process success.
1481 @retval Other Question Config process fail.
1485 ProcessQuestionConfig (
1486 IN UI_MENU_SELECTION
*Selection
,
1487 IN FORM_BROWSER_STATEMENT
*Question
1494 if (Question
->QuestionConfig
== 0) {
1501 ConfigResp
= GetToken (Question
->QuestionConfig
, Selection
->FormSet
->HiiHandle
);
1502 if (ConfigResp
== NULL
) {
1503 return EFI_NOT_FOUND
;
1507 // Send config to Configuration Driver
1509 Status
= mHiiConfigRouting
->RouteConfig (
1520 Process the user input data.
1522 @param UserInput The user input data.
1523 @param ChangeHighlight Whether need to change the highlight statement.
1525 @retval EFI_SUCESSS This function always return successfully for now.
1530 IN USER_INPUT
*UserInput
,
1531 IN BOOLEAN ChangeHighlight
1535 FORM_BROWSER_STATEMENT
*Statement
;
1537 Status
= EFI_SUCCESS
;
1540 // When Exit from FormDisplay function, one of the below two cases must be true.
1542 ASSERT (UserInput
->Action
!= 0 || UserInput
->SelectedStatement
!= NULL
);
1545 // Remove the last highligh question id, this id will update when show next form.
1547 gCurrentSelection
->QuestionId
= 0;
1550 // First process the Action field in USER_INPUT.
1552 if (UserInput
->Action
!= 0) {
1553 Status
= ProcessAction (UserInput
->Action
, UserInput
->DefaultId
);
1554 if (EFI_ERROR (Status
)) {
1559 // Clear the highlight info.
1561 gCurrentSelection
->Statement
= NULL
;
1563 if (UserInput
->SelectedStatement
!= NULL
) {
1564 Statement
= GetBrowserStatement(UserInput
->SelectedStatement
);
1565 ASSERT (Statement
!= NULL
);
1567 // Save the current highlight menu in the menu history data.
1568 // which will be used when later browse back to this form.
1570 gCurrentSelection
->CurrentMenu
->QuestionId
= Statement
->QuestionId
;
1572 // For statement like text, actio, it not has question id.
1573 // So use FakeQuestionId to save the question.
1575 if (gCurrentSelection
->CurrentMenu
->QuestionId
== 0) {
1576 mCurFakeQestId
= Statement
->FakeQuestionId
;
1582 Statement
= GetBrowserStatement(UserInput
->SelectedStatement
);
1583 ASSERT (Statement
!= NULL
);
1585 gCurrentSelection
->Statement
= Statement
;
1587 if (ChangeHighlight
) {
1589 // This question is the current user select one,record it and later
1590 // show it as the highlight question.
1592 gCurrentSelection
->CurrentMenu
->QuestionId
= Statement
->QuestionId
;
1594 // For statement like text, actio, it not has question id.
1595 // So use FakeQuestionId to save the question.
1597 if (gCurrentSelection
->CurrentMenu
->QuestionId
== 0) {
1598 mCurFakeQestId
= Statement
->FakeQuestionId
;
1604 switch (Statement
->Operand
) {
1605 case EFI_IFR_REF_OP
:
1606 Status
= ProcessGotoOpCode(Statement
, gCurrentSelection
);
1609 case EFI_IFR_ACTION_OP
:
1611 // Process the Config string <ConfigResp>
1613 Status
= ProcessQuestionConfig (gCurrentSelection
, Statement
);
1616 case EFI_IFR_RESET_BUTTON_OP
:
1618 // Reset Question to default value specified by DefaultId
1620 Status
= ExtractDefault (gCurrentSelection
->FormSet
, NULL
, Statement
->DefaultId
, FormSetLevel
, GetDefaultForAll
, NULL
, FALSE
);
1624 switch (Statement
->Operand
) {
1625 case EFI_IFR_STRING_OP
:
1626 DeleteString(Statement
->HiiValue
.Value
.string
, gCurrentSelection
->FormSet
->HiiHandle
);
1627 Statement
->HiiValue
.Value
.string
= UserInput
->InputValue
.Value
.string
;
1628 CopyMem (Statement
->BufferValue
, UserInput
->InputValue
.Buffer
, (UINTN
) UserInput
->InputValue
.BufferLen
);
1629 FreePool (UserInput
->InputValue
.Buffer
);
1632 case EFI_IFR_PASSWORD_OP
:
1633 if (UserInput
->InputValue
.Buffer
== NULL
) {
1635 // User not input new password, just return.
1640 DeleteString(Statement
->HiiValue
.Value
.string
, gCurrentSelection
->FormSet
->HiiHandle
);
1641 Statement
->HiiValue
.Value
.string
= UserInput
->InputValue
.Value
.string
;
1642 CopyMem (Statement
->BufferValue
, UserInput
->InputValue
.Buffer
, (UINTN
) UserInput
->InputValue
.BufferLen
);
1643 FreePool (UserInput
->InputValue
.Buffer
);
1645 // Two password match, send it to Configuration Driver
1647 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != 0) {
1648 PasswordCheck (NULL
, UserInput
->SelectedStatement
, (CHAR16
*) Statement
->BufferValue
);
1650 // Clean the value after saved it.
1652 ZeroMem (Statement
->BufferValue
, (UINTN
) UserInput
->InputValue
.BufferLen
);
1653 HiiSetString (gCurrentSelection
->FormSet
->HiiHandle
, Statement
->HiiValue
.Value
.string
, (CHAR16
*)Statement
->BufferValue
, NULL
);
1655 SetQuestionValue (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, GetSetValueWithHiiDriver
);
1659 case EFI_IFR_ORDERED_LIST_OP
:
1660 CopyMem (Statement
->BufferValue
, UserInput
->InputValue
.Buffer
, UserInput
->InputValue
.BufferLen
);
1664 CopyMem (&Statement
->HiiValue
, &UserInput
->InputValue
, sizeof (EFI_HII_VALUE
));
1676 Display form and wait for user to select one menu option, then return it.
1678 @retval EFI_SUCESSS This function always return successfully for now.
1687 USER_INPUT UserInput
;
1688 FORM_ENTRY_INFO
*CurrentMenu
;
1689 BOOLEAN ChangeHighlight
;
1691 ZeroMem (&UserInput
, sizeof (USER_INPUT
));
1694 // Update the menu history data.
1696 CurrentMenu
= UiFindMenuList (gCurrentSelection
->Handle
, &gCurrentSelection
->FormSetGuid
, gCurrentSelection
->FormId
);
1697 if (CurrentMenu
== NULL
) {
1699 // Current menu not found, add it to the menu tree
1701 CurrentMenu
= UiAddMenuList (gCurrentSelection
->Handle
, &gCurrentSelection
->FormSetGuid
,
1702 gCurrentSelection
->FormId
, gCurrentSelection
->QuestionId
);
1703 ASSERT (CurrentMenu
!= NULL
);
1705 gCurrentSelection
->CurrentMenu
= CurrentMenu
;
1708 // Find currrent highlight statement.
1710 if (gCurrentSelection
->QuestionId
== 0) {
1712 // Highlight not specified, fetch it from cached menu
1714 gCurrentSelection
->QuestionId
= CurrentMenu
->QuestionId
;
1718 // Evaluate all the Expressions in this Form
1720 Status
= EvaluateFormExpressions (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
);
1721 if (EFI_ERROR (Status
)) {
1725 UpdateDisplayFormData ();
1728 // Three possible status maybe return.
1730 // EFI_INVALID_PARAMETER: The input dimension info is not valid.
1731 // EFI_NOT_FOUND: The input value for oneof/orderedlist opcode is not valid
1732 // and an valid value has return.
1733 // EFI_SUCCESS: Success shows form and get user input in UserInput paramenter.
1735 Status
= mFormDisplay
->FormDisplay (&gDisplayFormData
, &UserInput
);
1736 if (EFI_ERROR (Status
) && Status
!= EFI_NOT_FOUND
) {
1737 FreeDisplayFormData();
1742 // If status is EFI_SUCCESS, means user has change the highlight menu and new user input return.
1743 // in this case, browser need to change the highlight menu.
1744 // If status is EFI_NOT_FOUND, means the input DisplayFormData has error for oneof/orderedlist
1745 // opcode and new valid value has return, browser core need to adjust
1746 // value for this opcode and shows this form again.
1748 ChangeHighlight
= (Status
== EFI_SUCCESS
? TRUE
:FALSE
);
1750 Status
= ProcessUserInput (&UserInput
, ChangeHighlight
);
1752 FreeDisplayFormData();
1758 Functions which are registered to receive notification of
1759 database events have this prototype. The actual event is encoded
1760 in NotifyType. The following table describes how PackageType,
1761 PackageGuid, Handle, and Package are used for each of the
1764 @param PackageType Package type of the notification.
1766 @param PackageGuid If PackageType is
1767 EFI_HII_PACKAGE_TYPE_GUID, then this is
1768 the pointer to the GUID from the Guid
1769 field of EFI_HII_PACKAGE_GUID_HEADER.
1770 Otherwise, it must be NULL.
1772 @param Package Points to the package referred to by the
1773 notification Handle The handle of the package
1774 list which contains the specified package.
1776 @param Handle The HII handle.
1778 @param NotifyType The type of change concerning the
1780 EFI_HII_DATABASE_NOTIFY_TYPE.
1786 IN UINT8 PackageType
,
1787 IN CONST EFI_GUID
*PackageGuid
,
1788 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
1789 IN EFI_HII_HANDLE Handle
,
1790 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
1793 mHiiPackageListUpdated
= TRUE
;
1799 Update the NV flag info for this form set.
1801 @param FormSet FormSet data structure.
1805 IsNvUpdateRequiredForFormSet (
1806 IN FORM_BROWSER_FORMSET
*FormSet
1810 FORM_BROWSER_FORM
*Form
;
1814 // Not finished question initialization, return FALSE.
1816 if (!FormSet
->QuestionInited
) {
1822 Link
= GetFirstNode (&FormSet
->FormListHead
);
1823 while (!IsNull (&FormSet
->FormListHead
, Link
)) {
1824 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
1826 RetVal
= IsNvUpdateRequiredForForm(Form
);
1831 Link
= GetNextNode (&FormSet
->FormListHead
, Link
);
1838 Update the NvUpdateRequired flag for a form.
1840 @param Form Form data structure.
1844 IsNvUpdateRequiredForForm (
1845 IN FORM_BROWSER_FORM
*Form
1849 FORM_BROWSER_STATEMENT
*Statement
;
1851 Link
= GetFirstNode (&Form
->StatementListHead
);
1852 while (!IsNull (&Form
->StatementListHead
, Link
)) {
1853 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
1855 if (Statement
->ValueChanged
) {
1859 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
1866 Check whether the storage data for current form set is changed.
1868 @param FormSet FormSet data structure.
1870 @retval TRUE Data is changed.
1871 @retval FALSE Data is not changed.
1874 IsStorageDataChangedForFormSet (
1875 IN FORM_BROWSER_FORMSET
*FormSet
1879 FORMSET_STORAGE
*Storage
;
1880 BROWSER_STORAGE
*BrowserStorage
;
1881 CHAR16
*ConfigRespNew
;
1882 CHAR16
*ConfigRespOld
;
1886 ConfigRespNew
= NULL
;
1887 ConfigRespOld
= NULL
;
1890 // Request current settings from Configuration Driver
1892 Link
= GetFirstNode (&FormSet
->StorageListHead
);
1893 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
1894 Storage
= FORMSET_STORAGE_FROM_LINK (Link
);
1895 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
1897 BrowserStorage
= Storage
->BrowserStorage
;
1899 if (BrowserStorage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
1903 if (Storage
->ElementCount
== 0) {
1907 StorageToConfigResp (BrowserStorage
, &ConfigRespNew
, Storage
->ConfigRequest
, TRUE
);
1908 StorageToConfigResp (BrowserStorage
, &ConfigRespOld
, Storage
->ConfigRequest
, FALSE
);
1909 ASSERT (ConfigRespNew
!= NULL
&& ConfigRespOld
!= NULL
);
1911 if (StrCmp (ConfigRespNew
, ConfigRespOld
) != 0) {
1915 FreePool (ConfigRespNew
);
1916 ConfigRespNew
= NULL
;
1918 FreePool (ConfigRespOld
);
1919 ConfigRespOld
= NULL
;
1930 Find menu which will show next time.
1932 @param Selection On input, Selection tell setup browser the information
1933 about the Selection, form and formset to be displayed.
1934 On output, Selection return the screen item that is selected
1936 @param SettingLevel Input Settting level, if it is FormLevel, just exit current form.
1937 else, we need to exit current formset.
1939 @retval TRUE Exit current form.
1940 @retval FALSE User press ESC and keep in current form.
1944 IN OUT UI_MENU_SELECTION
*Selection
,
1945 IN BROWSER_SETTING_SCOPE SettingLevel
1948 FORM_ENTRY_INFO
*CurrentMenu
;
1949 FORM_ENTRY_INFO
*ParentMenu
;
1950 BROWSER_SETTING_SCOPE Scope
;
1952 CurrentMenu
= Selection
->CurrentMenu
;
1954 Scope
= FormSetLevel
;
1956 if (CurrentMenu
!= NULL
&& (ParentMenu
= UiFindParentMenu(CurrentMenu
)) != NULL
) {
1958 // we have a parent, so go to the parent menu
1960 if (CompareGuid (&CurrentMenu
->FormSetGuid
, &ParentMenu
->FormSetGuid
)) {
1961 if (SettingLevel
== FormSetLevel
) {
1963 // Find a menu which has different formset guid with current.
1965 while (CompareGuid (&CurrentMenu
->FormSetGuid
, &ParentMenu
->FormSetGuid
)) {
1966 CurrentMenu
= ParentMenu
;
1967 if ((ParentMenu
= UiFindParentMenu(CurrentMenu
)) == NULL
) {
1972 if (ParentMenu
!= NULL
) {
1973 Scope
= FormSetLevel
;
1979 Scope
= FormSetLevel
;
1984 // Form Level Check whether the data is changed.
1986 if ((gBrowserSettingScope
== FormLevel
&& IsNvUpdateRequiredForForm (Selection
->Form
)) ||
1987 (gBrowserSettingScope
== FormSetLevel
&& IsNvUpdateRequiredForFormSet(Selection
->FormSet
) && Scope
== FormSetLevel
)) {
1988 if (!ProcessChangedData(Selection
, Scope
)) {
1993 if (ParentMenu
!= NULL
) {
1995 // ParentMenu is found. Then, go to it.
1997 if (Scope
== FormLevel
) {
1998 Selection
->Action
= UI_ACTION_REFRESH_FORM
;
2000 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
2001 CopyMem (&Selection
->FormSetGuid
, &ParentMenu
->FormSetGuid
, sizeof (EFI_GUID
));
2002 Selection
->Handle
= ParentMenu
->HiiHandle
;
2005 Selection
->Statement
= NULL
;
2007 Selection
->FormId
= ParentMenu
->FormId
;
2008 Selection
->QuestionId
= ParentMenu
->QuestionId
;
2011 // Clear highlight record for this menu
2013 CurrentMenu
->QuestionId
= 0;
2018 // Current in root page, exit the SendForm
2020 Selection
->Action
= UI_ACTION_EXIT
;
2026 Call the call back function for the question and process the return action.
2028 @param Selection On input, Selection tell setup browser the information
2029 about the Selection, form and formset to be displayed.
2030 On output, Selection return the screen item that is selected
2032 @param FormSet The formset this question belong to.
2033 @param Form The form this question belong to.
2034 @param Question The Question which need to call.
2035 @param Action The action request.
2036 @param SkipSaveOrDiscard Whether skip save or discard action.
2038 @retval EFI_SUCCESS The call back function excutes successfully.
2039 @return Other value if the call back function failed to excute.
2042 ProcessCallBackFunction (
2043 IN OUT UI_MENU_SELECTION
*Selection
,
2044 IN FORM_BROWSER_FORMSET
*FormSet
,
2045 IN FORM_BROWSER_FORM
*Form
,
2046 IN FORM_BROWSER_STATEMENT
*Question
,
2047 IN EFI_BROWSER_ACTION Action
,
2048 IN BOOLEAN SkipSaveOrDiscard
2052 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
2053 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
2054 EFI_HII_VALUE
*HiiValue
;
2055 EFI_IFR_TYPE_VALUE
*TypeValue
;
2056 FORM_BROWSER_STATEMENT
*Statement
;
2057 BOOLEAN SubmitFormIsRequired
;
2058 BOOLEAN DiscardFormIsRequired
;
2061 BROWSER_SETTING_SCOPE SettingLevel
;
2062 EFI_IFR_TYPE_VALUE BackUpValue
;
2063 UINT8
*BackUpBuffer
;
2065 ConfigAccess
= FormSet
->ConfigAccess
;
2066 SubmitFormIsRequired
= FALSE
;
2067 SettingLevel
= FormSetLevel
;
2068 DiscardFormIsRequired
= FALSE
;
2070 Status
= EFI_SUCCESS
;
2071 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
2072 BackUpBuffer
= NULL
;
2074 if (ConfigAccess
== NULL
) {
2078 Link
= GetFirstNode (&Form
->StatementListHead
);
2079 while (!IsNull (&Form
->StatementListHead
, Link
)) {
2080 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
2081 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
2084 // if Question != NULL, only process the question. Else, process all question in this form.
2086 if ((Question
!= NULL
) && (Statement
!= Question
)) {
2090 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) {
2095 // Check whether Statement is disabled.
2097 if (Statement
->Expression
!= NULL
) {
2098 if (EvaluateExpressionList(Statement
->Expression
, TRUE
, FormSet
, Form
) == ExpressDisable
) {
2103 HiiValue
= &Statement
->HiiValue
;
2104 TypeValue
= &HiiValue
->Value
;
2105 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
2107 // For OrderedList, passing in the value buffer to Callback()
2109 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Statement
->BufferValue
;
2113 // If EFI_BROWSER_ACTION_CHANGING type, back up the new question value.
2115 if (Action
== EFI_BROWSER_ACTION_CHANGING
) {
2116 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
2117 BackUpBuffer
= AllocateCopyPool(Statement
->StorageWidth
+ sizeof(CHAR16
), Statement
->BufferValue
);
2119 CopyMem (&BackUpValue
, &HiiValue
->Value
, sizeof (EFI_IFR_TYPE_VALUE
));
2123 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
2124 Status
= ConfigAccess
->Callback (
2127 Statement
->QuestionId
,
2132 if (!EFI_ERROR (Status
)) {
2134 // Only for EFI_BROWSER_ACTION_CHANGED need to handle this ActionRequest.
2136 if (Action
== EFI_BROWSER_ACTION_CHANGED
) {
2137 switch (ActionRequest
) {
2138 case EFI_BROWSER_ACTION_REQUEST_RESET
:
2139 DiscardFormIsRequired
= TRUE
;
2140 gResetRequired
= TRUE
;
2144 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
2145 SubmitFormIsRequired
= TRUE
;
2149 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
2150 DiscardFormIsRequired
= TRUE
;
2154 case EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
:
2155 SubmitFormIsRequired
= TRUE
;
2156 SettingLevel
= FormLevel
;
2160 case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT
:
2161 DiscardFormIsRequired
= TRUE
;
2162 SettingLevel
= FormLevel
;
2166 case EFI_BROWSER_ACTION_REQUEST_FORM_APPLY
:
2167 SubmitFormIsRequired
= TRUE
;
2168 SettingLevel
= FormLevel
;
2171 case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD
:
2172 DiscardFormIsRequired
= TRUE
;
2173 SettingLevel
= FormLevel
;
2182 // According the spec, return value from call back of "changing" and
2183 // "retrieve" should update to the question's temp buffer.
2185 if (Action
== EFI_BROWSER_ACTION_CHANGING
|| Action
== EFI_BROWSER_ACTION_RETRIEVE
) {
2186 SetQuestionValue(FormSet
, Form
, Statement
, GetSetValueWithEditBuffer
);
2190 // If the callback returns EFI_UNSUPPORTED for EFI_BROWSER_ACTION_CHANGING,
2191 // then the browser will use the value passed to Callback() and ignore the
2192 // value returned by Callback().
2194 if (Action
== EFI_BROWSER_ACTION_CHANGING
&& Status
== EFI_UNSUPPORTED
) {
2195 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
2196 CopyMem (Statement
->BufferValue
, BackUpBuffer
, Statement
->StorageWidth
+ sizeof(CHAR16
));
2198 CopyMem (&HiiValue
->Value
, &BackUpValue
, sizeof (EFI_IFR_TYPE_VALUE
));
2201 SetQuestionValue(FormSet
, Form
, Statement
, GetSetValueWithEditBuffer
);
2205 // According the spec, return fail from call back of "changing" and
2206 // "retrieve", should restore the question's value.
2208 if ((Action
== EFI_BROWSER_ACTION_CHANGING
&& Status
!= EFI_UNSUPPORTED
) ||
2209 Action
== EFI_BROWSER_ACTION_RETRIEVE
) {
2210 GetQuestionValue(FormSet
, Form
, Statement
, GetSetValueWithEditBuffer
);
2213 if (Status
== EFI_UNSUPPORTED
) {
2215 // If return EFI_UNSUPPORTED, also consider Hii driver suceess deal with it.
2217 Status
= EFI_SUCCESS
;
2221 if (BackUpBuffer
!= NULL
) {
2222 FreePool (BackUpBuffer
);
2226 if (SubmitFormIsRequired
&& !SkipSaveOrDiscard
) {
2227 SubmitForm (FormSet
, Form
, SettingLevel
);
2230 if (DiscardFormIsRequired
&& !SkipSaveOrDiscard
) {
2231 DiscardForm (FormSet
, Form
, SettingLevel
);
2235 FindNextMenu (Selection
, SettingLevel
);
2242 Call the retrieve type call back function for one question to get the initialize data.
2244 This function only used when in the initialize stage, because in this stage, the
2245 Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.
2247 @param ConfigAccess The config access protocol produced by the hii driver.
2248 @param Statement The Question which need to call.
2250 @retval EFI_SUCCESS The call back function excutes successfully.
2251 @return Other value if the call back function failed to excute.
2254 ProcessRetrieveForQuestion (
2255 IN EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
,
2256 IN FORM_BROWSER_STATEMENT
*Statement
2260 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
2261 EFI_HII_VALUE
*HiiValue
;
2262 EFI_IFR_TYPE_VALUE
*TypeValue
;
2264 Status
= EFI_SUCCESS
;
2265 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
2267 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) {
2268 return EFI_UNSUPPORTED
;
2271 HiiValue
= &Statement
->HiiValue
;
2272 TypeValue
= &HiiValue
->Value
;
2273 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
2275 // For OrderedList, passing in the value buffer to Callback()
2277 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Statement
->BufferValue
;
2280 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
2281 Status
= ConfigAccess
->Callback (
2283 EFI_BROWSER_ACTION_RETRIEVE
,
2284 Statement
->QuestionId
,
2293 The worker function that send the displays to the screen. On output,
2294 the selection made by user is returned.
2296 @param Selection On input, Selection tell setup browser the information
2297 about the Selection, form and formset to be displayed.
2298 On output, Selection return the screen item that is selected
2301 @retval EFI_SUCCESS The page is displayed successfully.
2302 @return Other value if the page failed to be diplayed.
2307 IN OUT UI_MENU_SELECTION
*Selection
2312 EFI_HANDLE NotifyHandle
;
2313 FORM_BROWSER_STATEMENT
*Statement
;
2314 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
2316 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
2319 // Register notify for Form package update
2321 Status
= mHiiDatabase
->RegisterPackageNotify (
2323 EFI_HII_PACKAGE_FORMS
,
2326 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
2329 if (EFI_ERROR (Status
)) {
2333 if ((Selection
->Handle
!= mCurrentHiiHandle
) ||
2334 (!CompareGuid (&Selection
->FormSetGuid
, &mCurrentFormSetGuid
))) {
2335 gFinishRetrieveCall
= FALSE
;
2339 // Initialize current settings of Questions in this FormSet
2341 InitializeCurrentSetting (Selection
->FormSet
);
2344 // Initilize Action field.
2346 Selection
->Action
= UI_ACTION_REFRESH_FORM
;
2349 // Clean the mCurFakeQestId value is formset refreshed.
2355 // IFR is updated, force to reparse the IFR binary
2357 if (mHiiPackageListUpdated
) {
2358 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
2359 mHiiPackageListUpdated
= FALSE
;
2364 // Initialize Selection->Form
2366 if (Selection
->FormId
== 0) {
2368 // Zero FormId indicates display the first Form in a FormSet
2370 Link
= GetFirstNode (&Selection
->FormSet
->FormListHead
);
2372 Selection
->Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
2373 Selection
->FormId
= Selection
->Form
->FormId
;
2375 Selection
->Form
= IdToForm (Selection
->FormSet
, Selection
->FormId
);
2378 if (Selection
->Form
== NULL
) {
2380 // No Form to display
2382 Status
= EFI_NOT_FOUND
;
2387 // Check Form is suppressed.
2389 if (Selection
->Form
->SuppressExpression
!= NULL
) {
2390 if (EvaluateExpressionList(Selection
->Form
->SuppressExpression
, TRUE
, Selection
->FormSet
, Selection
->Form
) == ExpressSuppress
) {
2392 // Form is suppressed.
2394 gBrowserStatus
= BROWSER_FORM_SUPPRESS
;
2395 Status
= EFI_NOT_FOUND
;
2401 // Before display new form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN
2402 // for each question with callback flag.
2403 // New form may be the first form, or the different form after another form close.
2405 if ((ConfigAccess
!= NULL
) &&
2406 ((Selection
->Handle
!= mCurrentHiiHandle
) ||
2407 (!CompareGuid (&Selection
->FormSetGuid
, &mCurrentFormSetGuid
)) ||
2408 (Selection
->FormId
!= mCurrentFormId
))) {
2410 // Keep current form information
2412 mCurrentHiiHandle
= Selection
->Handle
;
2413 CopyGuid (&mCurrentFormSetGuid
, &Selection
->FormSetGuid
);
2414 mCurrentFormId
= Selection
->FormId
;
2416 Status
= ProcessCallBackFunction (Selection
, gCurrentSelection
->FormSet
, Selection
->Form
, NULL
, EFI_BROWSER_ACTION_FORM_OPEN
, FALSE
);
2417 if (EFI_ERROR (Status
)) {
2422 // IFR is updated during callback of open form, force to reparse the IFR binary
2424 if (mHiiPackageListUpdated
) {
2425 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
2426 mHiiPackageListUpdated
= FALSE
;
2432 // Load Questions' Value for display
2434 Status
= LoadFormSetConfig (Selection
, Selection
->FormSet
);
2435 if (EFI_ERROR (Status
)) {
2440 // Finish call RETRIEVE callback for this formset.
2442 gFinishRetrieveCall
= TRUE
;
2445 // IFR is updated during callback of read value, force to reparse the IFR binary
2447 if (mHiiPackageListUpdated
) {
2448 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
2449 mHiiPackageListUpdated
= FALSE
;
2456 Status
= DisplayForm ();
2457 if (EFI_ERROR (Status
)) {
2462 // Check Selected Statement (if press ESC, Selection->Statement will be NULL)
2464 Statement
= Selection
->Statement
;
2465 if (Statement
!= NULL
) {
2466 if ((ConfigAccess
!= NULL
) &&
2467 ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) &&
2468 (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
)) {
2469 Status
= ProcessCallBackFunction(Selection
, Selection
->FormSet
, Selection
->Form
, Statement
, EFI_BROWSER_ACTION_CHANGING
, FALSE
);
2470 if (Statement
->Operand
== EFI_IFR_REF_OP
) {
2472 // Process dynamic update ref opcode.
2474 if (!EFI_ERROR (Status
)) {
2475 Status
= ProcessGotoOpCode(Statement
, Selection
);
2479 // Callback return error status or status return from process goto opcode.
2481 if (EFI_ERROR (Status
)) {
2483 // Cross reference will not be taken
2485 Selection
->FormId
= Selection
->Form
->FormId
;
2486 Selection
->QuestionId
= 0;
2490 if (!EFI_ERROR (Status
) && Statement
->Operand
!= EFI_IFR_REF_OP
) {
2491 ProcessCallBackFunction(Selection
, Selection
->FormSet
, Selection
->Form
, Statement
, EFI_BROWSER_ACTION_CHANGED
, FALSE
);
2493 } else if (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
) {
2494 SetQuestionValue (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, GetSetValueWithEditBuffer
);
2499 // Check whether Exit flag is TRUE.
2501 if (gExitRequired
) {
2502 switch (gBrowserSettingScope
) {
2504 Selection
->Action
= UI_ACTION_EXIT
;
2509 FindNextMenu (Selection
, gBrowserSettingScope
);
2516 gExitRequired
= FALSE
;
2520 // Before exit the form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE
2521 // for each question with callback flag.
2523 if ((ConfigAccess
!= NULL
) &&
2524 ((Selection
->Action
== UI_ACTION_EXIT
) ||
2525 (Selection
->Handle
!= mCurrentHiiHandle
) ||
2526 (!CompareGuid (&Selection
->FormSetGuid
, &mCurrentFormSetGuid
)) ||
2527 (Selection
->FormId
!= mCurrentFormId
))) {
2529 Status
= ProcessCallBackFunction (Selection
, Selection
->FormSet
, Selection
->Form
, NULL
, EFI_BROWSER_ACTION_FORM_CLOSE
, FALSE
);
2530 if (EFI_ERROR (Status
)) {
2534 } while (Selection
->Action
== UI_ACTION_REFRESH_FORM
);
2538 // Reset current form information to the initial setting when error happens or form exit.
2540 if (EFI_ERROR (Status
) || Selection
->Action
== UI_ACTION_EXIT
) {
2541 mCurrentHiiHandle
= NULL
;
2542 CopyGuid (&mCurrentFormSetGuid
, &gZeroGuid
);
2547 // Unregister notify for Form package update
2549 mHiiDatabase
->UnregisterPackageNotify (