2 Utility functions for UI presentation.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2015 - 2022 Hewlett Packard Enterprise Development LP<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
12 BOOLEAN mHiiPackageListUpdated
;
13 UI_MENU_SELECTION
*gCurrentSelection
;
14 EFI_HII_HANDLE mCurrentHiiHandle
= NULL
;
15 EFI_GUID mCurrentFormSetGuid
= {
16 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 }
18 UINT16 mCurrentFormId
= 0;
19 EFI_EVENT mValueChangedEvent
= NULL
;
20 LIST_ENTRY mRefreshEventList
= INITIALIZE_LIST_HEAD_VARIABLE (mRefreshEventList
);
21 UINT16 mCurFakeQestId
;
22 FORM_DISPLAY_ENGINE_FORM gDisplayFormData
;
23 BOOLEAN mFinishRetrieveCall
= FALSE
;
26 Check whether the ConfigAccess protocol is available.
28 @param FormSet FormSet of which the ConfigAcces protocol need to be checked.
30 @retval EFI_SUCCESS The function executed successfully.
35 IN FORM_BROWSER_FORMSET
*FormSet
40 Status
= gBS
->HandleProtocol (
41 FormSet
->DriverHandle
,
42 &gEfiHiiConfigAccessProtocolGuid
,
43 (VOID
**)&FormSet
->ConfigAccess
45 if (EFI_ERROR (Status
)) {
47 // Configuration Driver don't attach ConfigAccess protocol to its HII package
48 // list, then there will be no configuration action required.
49 // Or the ConfigAccess protocol has been uninstalled.
51 FormSet
->ConfigAccess
= NULL
;
58 Evaluate all expressions in a Form.
60 @param FormSet FormSet this Form belongs to.
63 @retval EFI_SUCCESS The expression evaluated successfuly
67 EvaluateFormExpressions (
68 IN FORM_BROWSER_FORMSET
*FormSet
,
69 IN FORM_BROWSER_FORM
*Form
74 FORM_EXPRESSION
*Expression
;
76 Link
= GetFirstNode (&Form
->ExpressionListHead
);
77 while (!IsNull (&Form
->ExpressionListHead
, Link
)) {
78 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
79 Link
= GetNextNode (&Form
->ExpressionListHead
, Link
);
81 if ((Expression
->Type
== EFI_HII_EXPRESSION_INCONSISTENT_IF
) ||
82 (Expression
->Type
== EFI_HII_EXPRESSION_NO_SUBMIT_IF
) ||
83 (Expression
->Type
== EFI_HII_EXPRESSION_WARNING_IF
) ||
84 (Expression
->Type
== EFI_HII_EXPRESSION_WRITE
) ||
85 ((Expression
->Type
== EFI_HII_EXPRESSION_READ
) && (Form
->FormType
!= STANDARD_MAP_FORM_TYPE
)))
88 // Postpone Form validation to Question editing or Form submitting or Question Write or Question Read for nonstandard form.
93 Status
= EvaluateExpression (FormSet
, Form
, Expression
);
94 if (EFI_ERROR (Status
)) {
103 Base on the opcode buffer info to get the display statement.
105 @param OpCode The input opcode buffer for this statement.
107 @retval Statement The statement use this opcode buffer.
110 FORM_DISPLAY_ENGINE_STATEMENT
*
111 GetDisplayStatement (
112 IN EFI_IFR_OP_HEADER
*OpCode
115 FORM_DISPLAY_ENGINE_STATEMENT
*DisplayStatement
;
118 Link
= GetFirstNode (&gDisplayFormData
.StatementListHead
);
119 while (!IsNull (&gDisplayFormData
.StatementListHead
, Link
)) {
120 DisplayStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
122 if (DisplayStatement
->OpCode
== OpCode
) {
123 return DisplayStatement
;
126 Link
= GetNextNode (&gDisplayFormData
.StatementListHead
, Link
);
133 Free the refresh event list.
142 FORM_BROWSER_REFRESH_EVENT_NODE
*EventNode
;
144 while (!IsListEmpty (&mRefreshEventList
)) {
145 Link
= GetFirstNode (&mRefreshEventList
);
146 EventNode
= FORM_BROWSER_REFRESH_EVENT_FROM_LINK (Link
);
147 RemoveEntryList (&EventNode
->Link
);
149 gBS
->CloseEvent (EventNode
->RefreshEvent
);
151 FreePool (EventNode
);
156 Check whether this statement value is changed. If yes, update the statement value and return TRUE;
159 @param Statement The statement need to check.
164 IN OUT FORM_BROWSER_STATEMENT
*Statement
167 GetQuestionValue (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, GetSetValueWithHiiDriver
);
170 // Reset FormPackage update flag
172 mHiiPackageListUpdated
= FALSE
;
175 // Question value may be changed, need invoke its Callback()
177 ProcessCallBackFunction (gCurrentSelection
, gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, EFI_BROWSER_ACTION_RETRIEVE
, FALSE
);
179 if (mHiiPackageListUpdated
) {
181 // Package list is updated, force to reparse IFR binary of target Formset
183 mHiiPackageListUpdated
= FALSE
;
184 gCurrentSelection
->Action
= UI_ACTION_REFRESH_FORMSET
;
189 Refresh the question which has refresh guid event attribute.
191 @param Event The event which has this function related.
192 @param Context The input context info related to this event or the status code return to the caller.
196 RefreshEventNotifyForStatement (
201 FORM_BROWSER_STATEMENT
*Statement
;
203 Statement
= (FORM_BROWSER_STATEMENT
*)Context
;
204 UpdateStatement (Statement
);
205 gBS
->SignalEvent (mValueChangedEvent
);
209 Refresh the questions within this form.
211 @param Event The event which has this function related.
212 @param Context The input context info related to this event or the status code return to the caller.
216 RefreshEventNotifyForForm (
221 gCurrentSelection
->Action
= UI_ACTION_REFRESH_FORMSET
;
223 gBS
->SignalEvent (mValueChangedEvent
);
227 Create refresh hook event for statement which has refresh event or interval.
229 @param Statement The statement need to check.
233 CreateRefreshEventForStatement (
234 IN FORM_BROWSER_STATEMENT
*Statement
238 EFI_EVENT RefreshEvent
;
239 FORM_BROWSER_REFRESH_EVENT_NODE
*EventNode
;
242 // If question has refresh guid, create the notify function.
244 Status
= gBS
->CreateEventEx (
247 RefreshEventNotifyForStatement
,
249 &Statement
->RefreshGuid
,
252 ASSERT_EFI_ERROR (Status
);
254 EventNode
= AllocateZeroPool (sizeof (FORM_BROWSER_REFRESH_EVENT_NODE
));
255 ASSERT (EventNode
!= NULL
);
256 EventNode
->RefreshEvent
= RefreshEvent
;
257 InsertTailList (&mRefreshEventList
, &EventNode
->Link
);
261 Create refresh hook event for form which has refresh event or interval.
263 @param Form The form need to check.
267 CreateRefreshEventForForm (
268 IN FORM_BROWSER_FORM
*Form
272 EFI_EVENT RefreshEvent
;
273 FORM_BROWSER_REFRESH_EVENT_NODE
*EventNode
;
276 // If question has refresh guid, create the notify function.
278 Status
= gBS
->CreateEventEx (
281 RefreshEventNotifyForForm
,
286 ASSERT_EFI_ERROR (Status
);
288 EventNode
= AllocateZeroPool (sizeof (FORM_BROWSER_REFRESH_EVENT_NODE
));
289 ASSERT (EventNode
!= NULL
);
290 EventNode
->RefreshEvent
= RefreshEvent
;
291 InsertTailList (&mRefreshEventList
, &EventNode
->Link
);
296 Initialize the Display statement structure data.
298 @param DisplayStatement Pointer to the display Statement data strucure.
299 @param Statement The statement need to check.
302 InitializeDisplayStatement (
303 IN OUT FORM_DISPLAY_ENGINE_STATEMENT
*DisplayStatement
,
304 IN FORM_BROWSER_STATEMENT
*Statement
308 QUESTION_OPTION
*Option
;
309 DISPLAY_QUESTION_OPTION
*DisplayOption
;
310 FORM_DISPLAY_ENGINE_STATEMENT
*ParentStatement
;
312 DisplayStatement
->Signature
= FORM_DISPLAY_ENGINE_STATEMENT_SIGNATURE
;
313 DisplayStatement
->Version
= FORM_DISPLAY_ENGINE_STATEMENT_VERSION_1
;
314 DisplayStatement
->OpCode
= Statement
->OpCode
;
315 InitializeListHead (&DisplayStatement
->NestStatementList
);
316 InitializeListHead (&DisplayStatement
->OptionListHead
);
318 if ((EvaluateExpressionList (Statement
->Expression
, FALSE
, NULL
, NULL
) == ExpressGrayOut
) || Statement
->Locked
) {
319 DisplayStatement
->Attribute
|= HII_DISPLAY_GRAYOUT
;
322 if ((Statement
->ValueExpression
!= NULL
) || ((Statement
->QuestionFlags
& EFI_IFR_FLAG_READ_ONLY
) != 0)) {
323 DisplayStatement
->Attribute
|= HII_DISPLAY_READONLY
;
327 // Initilize the option list in statement.
329 Link
= GetFirstNode (&Statement
->OptionListHead
);
330 while (!IsNull (&Statement
->OptionListHead
, Link
)) {
331 Option
= QUESTION_OPTION_FROM_LINK (Link
);
332 Link
= GetNextNode (&Statement
->OptionListHead
, Link
);
333 if ((Option
->SuppressExpression
!= NULL
) &&
334 ((EvaluateExpressionList (Option
->SuppressExpression
, FALSE
, NULL
, NULL
) == ExpressSuppress
)))
339 DisplayOption
= AllocateZeroPool (sizeof (DISPLAY_QUESTION_OPTION
));
340 ASSERT (DisplayOption
!= NULL
);
342 DisplayOption
->ImageId
= Option
->ImageId
;
343 DisplayOption
->Signature
= DISPLAY_QUESTION_OPTION_SIGNATURE
;
344 DisplayOption
->OptionOpCode
= Option
->OpCode
;
345 InsertTailList (&DisplayStatement
->OptionListHead
, &DisplayOption
->Link
);
348 CopyMem (&DisplayStatement
->CurrentValue
, &Statement
->HiiValue
, sizeof (EFI_HII_VALUE
));
351 // Some special op code need an extra buffer to save the data.
352 // Such as string, password, orderedlist...
354 if (Statement
->BufferValue
!= NULL
) {
356 // Ordered list opcode may not initilized, get default value here.
358 if ((Statement
->OpCode
->OpCode
== EFI_IFR_ORDERED_LIST_OP
) && (GetArrayData (Statement
->BufferValue
, Statement
->ValueType
, 0) == 0)) {
359 GetQuestionDefault (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, 0);
362 DisplayStatement
->CurrentValue
.Buffer
= AllocateCopyPool (Statement
->StorageWidth
, Statement
->BufferValue
);
363 DisplayStatement
->CurrentValue
.BufferLen
= Statement
->StorageWidth
;
366 DisplayStatement
->SettingChangedFlag
= Statement
->ValueChanged
;
369 // Get the highlight statement for current form.
371 if (((gCurrentSelection
->QuestionId
!= 0) && (Statement
->QuestionId
== gCurrentSelection
->QuestionId
)) ||
372 ((mCurFakeQestId
!= 0) && (Statement
->FakeQuestionId
== mCurFakeQestId
)))
374 gDisplayFormData
.HighLightedStatement
= DisplayStatement
;
378 // Create the refresh event process function.
380 if (!IsZeroGuid (&Statement
->RefreshGuid
)) {
381 CreateRefreshEventForStatement (Statement
);
385 // For RTC type of date/time, set default refresh interval to be 1 second.
387 if (((Statement
->Operand
== EFI_IFR_DATE_OP
) || (Statement
->Operand
== EFI_IFR_TIME_OP
)) && (Statement
->Storage
== NULL
)) {
388 Statement
->RefreshInterval
= 1;
392 // Create the refresh guid hook event.
393 // If the statement in this form has refresh event or refresh interval, browser will create this event for display engine.
395 if ((!IsZeroGuid (&Statement
->RefreshGuid
)) || (Statement
->RefreshInterval
!= 0)) {
396 gDisplayFormData
.FormRefreshEvent
= mValueChangedEvent
;
400 // Save the password check function for later use.
402 if (Statement
->Operand
== EFI_IFR_PASSWORD_OP
) {
403 DisplayStatement
->PasswordCheck
= PasswordCheck
;
407 // If this statement is nest in the subtitle, insert to the host statement.
408 // else insert to the form it belongs to.
410 if (Statement
->ParentStatement
!= NULL
) {
411 ParentStatement
= GetDisplayStatement (Statement
->ParentStatement
->OpCode
);
412 ASSERT (ParentStatement
!= NULL
);
413 InsertTailList (&ParentStatement
->NestStatementList
, &DisplayStatement
->DisplayLink
);
415 InsertTailList (&gDisplayFormData
.StatementListHead
, &DisplayStatement
->DisplayLink
);
420 Process for the refresh interval statement.
422 @param Event The Event need to be process
423 @param Context The context of the event.
428 RefreshIntervalProcess (
433 FORM_BROWSER_STATEMENT
*Statement
;
436 Link
= GetFirstNode (&gCurrentSelection
->Form
->StatementListHead
);
437 while (!IsNull (&gCurrentSelection
->Form
->StatementListHead
, Link
)) {
438 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
439 Link
= GetNextNode (&gCurrentSelection
->Form
->StatementListHead
, Link
);
441 if (Statement
->RefreshInterval
== 0) {
445 UpdateStatement (Statement
);
448 gBS
->SignalEvent (mValueChangedEvent
);
453 Make a copy of the global hotkey info.
461 BROWSER_HOT_KEY
*HotKey
;
462 BROWSER_HOT_KEY
*CopyKey
;
465 Link
= GetFirstNode (&gBrowserHotKeyList
);
466 while (!IsNull (&gBrowserHotKeyList
, Link
)) {
467 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
469 CopyKey
= AllocateCopyPool (sizeof (BROWSER_HOT_KEY
), HotKey
);
470 ASSERT (CopyKey
!= NULL
);
471 CopyKey
->KeyData
= AllocateCopyPool (sizeof (EFI_INPUT_KEY
), HotKey
->KeyData
);
472 ASSERT (CopyKey
->KeyData
!= NULL
);
473 CopyKey
->HelpString
= AllocateCopyPool (StrSize (HotKey
->HelpString
), HotKey
->HelpString
);
474 ASSERT (CopyKey
->HelpString
!= NULL
);
476 InsertTailList (&gDisplayFormData
.HotKeyListHead
, &CopyKey
->Link
);
478 Link
= GetNextNode (&gBrowserHotKeyList
, Link
);
484 Get the extra question attribute from override question list.
486 @param QuestionId The question id for this request question.
488 @retval The attribute for this question or NULL if not found this
489 question in the list.
493 ProcessQuestionExtraAttr (
494 IN EFI_QUESTION_ID QuestionId
498 QUESTION_ATTRIBUTE_OVERRIDE
*QuestionDesc
;
501 // Return HII_DISPLAY_NONE if input a invalid question id.
503 if (QuestionId
== 0) {
504 return HII_DISPLAY_NONE
;
507 Link
= GetFirstNode (&mPrivateData
.FormBrowserEx2
.OverrideQestListHead
);
508 while (!IsNull (&mPrivateData
.FormBrowserEx2
.OverrideQestListHead
, Link
)) {
509 QuestionDesc
= FORM_QUESTION_ATTRIBUTE_OVERRIDE_FROM_LINK (Link
);
510 Link
= GetNextNode (&mPrivateData
.FormBrowserEx2
.OverrideQestListHead
, Link
);
512 if ((QuestionDesc
->QuestionId
== QuestionId
) &&
513 (QuestionDesc
->FormId
== gCurrentSelection
->FormId
) &&
514 (QuestionDesc
->HiiHandle
== gCurrentSelection
->Handle
) &&
515 CompareGuid (&QuestionDesc
->FormSetGuid
, &gCurrentSelection
->FormSetGuid
))
517 return QuestionDesc
->Attribute
;
521 return HII_DISPLAY_NONE
;
526 Enum all statement in current form, find all the statement can be display and
527 add to the display form.
531 AddStatementToDisplayForm (
537 FORM_BROWSER_STATEMENT
*Statement
;
538 FORM_DISPLAY_ENGINE_STATEMENT
*DisplayStatement
;
539 UINT8 MinRefreshInterval
;
540 EFI_EVENT RefreshIntervalEvent
;
541 FORM_BROWSER_REFRESH_EVENT_NODE
*EventNode
;
542 BOOLEAN FormEditable
;
543 UINT32 ExtraAttribute
;
545 MinRefreshInterval
= 0;
546 FormEditable
= FALSE
;
549 // Process the statement outside the form, these statements are not recognized
552 Link
= GetFirstNode (&gCurrentSelection
->FormSet
->StatementListOSF
);
553 while (!IsNull (&gCurrentSelection
->FormSet
->StatementListOSF
, Link
)) {
554 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
555 Link
= GetNextNode (&gCurrentSelection
->FormSet
->StatementListOSF
, Link
);
557 DisplayStatement
= AllocateZeroPool (sizeof (FORM_DISPLAY_ENGINE_STATEMENT
));
558 ASSERT (DisplayStatement
!= NULL
);
559 DisplayStatement
->Signature
= FORM_DISPLAY_ENGINE_STATEMENT_SIGNATURE
;
560 DisplayStatement
->Version
= FORM_DISPLAY_ENGINE_STATEMENT_VERSION_1
;
561 DisplayStatement
->OpCode
= Statement
->OpCode
;
563 InitializeListHead (&DisplayStatement
->NestStatementList
);
564 InitializeListHead (&DisplayStatement
->OptionListHead
);
566 InsertTailList (&gDisplayFormData
.StatementListOSF
, &DisplayStatement
->DisplayLink
);
570 // treat formset as statement outside the form,get its opcode.
572 DisplayStatement
= AllocateZeroPool (sizeof (FORM_DISPLAY_ENGINE_STATEMENT
));
573 ASSERT (DisplayStatement
!= NULL
);
575 DisplayStatement
->Signature
= FORM_DISPLAY_ENGINE_STATEMENT_SIGNATURE
;
576 DisplayStatement
->Version
= FORM_DISPLAY_ENGINE_STATEMENT_VERSION_1
;
577 DisplayStatement
->OpCode
= gCurrentSelection
->FormSet
->OpCode
;
579 InitializeListHead (&DisplayStatement
->NestStatementList
);
580 InitializeListHead (&DisplayStatement
->OptionListHead
);
582 InsertTailList (&gDisplayFormData
.StatementListOSF
, &DisplayStatement
->DisplayLink
);
585 // Process the statement in this form.
587 Link
= GetFirstNode (&gCurrentSelection
->Form
->StatementListHead
);
588 while (!IsNull (&gCurrentSelection
->Form
->StatementListHead
, Link
)) {
589 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
590 Link
= GetNextNode (&gCurrentSelection
->Form
->StatementListHead
, Link
);
593 // This statement can't be show, skip it.
595 if (EvaluateExpressionList (Statement
->Expression
, FALSE
, NULL
, NULL
) > ExpressGrayOut
) {
600 // Check the extra attribute.
602 ExtraAttribute
= ProcessQuestionExtraAttr (Statement
->QuestionId
);
603 if ((ExtraAttribute
& HII_DISPLAY_SUPPRESS
) != 0) {
607 DisplayStatement
= AllocateZeroPool (sizeof (FORM_DISPLAY_ENGINE_STATEMENT
));
608 ASSERT (DisplayStatement
!= NULL
);
611 // Initialize this statement and add it to the display form.
613 InitializeDisplayStatement (DisplayStatement
, Statement
);
616 // Set the extra attribute.
618 DisplayStatement
->Attribute
|= ExtraAttribute
;
620 if (Statement
->Storage
!= NULL
) {
625 // Get the minimal refresh interval value for later use.
627 if ((Statement
->RefreshInterval
!= 0) &&
628 ((MinRefreshInterval
== 0) || (Statement
->RefreshInterval
< MinRefreshInterval
)))
630 MinRefreshInterval
= Statement
->RefreshInterval
;
635 // Create the periodic timer for refresh interval statement.
637 if (MinRefreshInterval
!= 0) {
638 Status
= gBS
->CreateEvent (EVT_TIMER
| EVT_NOTIFY_SIGNAL
, TPL_CALLBACK
, RefreshIntervalProcess
, NULL
, &RefreshIntervalEvent
);
639 ASSERT_EFI_ERROR (Status
);
640 Status
= gBS
->SetTimer (RefreshIntervalEvent
, TimerPeriodic
, MinRefreshInterval
* ONE_SECOND
);
641 ASSERT_EFI_ERROR (Status
);
643 EventNode
= AllocateZeroPool (sizeof (FORM_BROWSER_REFRESH_EVENT_NODE
));
644 ASSERT (EventNode
!= NULL
);
645 EventNode
->RefreshEvent
= RefreshIntervalEvent
;
646 InsertTailList (&mRefreshEventList
, &EventNode
->Link
);
650 // Create the refresh event process function for Form.
652 if (!IsZeroGuid (&gCurrentSelection
->Form
->RefreshGuid
)) {
653 CreateRefreshEventForForm (gCurrentSelection
->Form
);
654 if (gDisplayFormData
.FormRefreshEvent
== NULL
) {
655 gDisplayFormData
.FormRefreshEvent
= mValueChangedEvent
;
660 // Update hotkey list field.
662 if ((gBrowserSettingScope
== SystemLevel
) || FormEditable
) {
669 Initialize the SettingChangedFlag variable in the display form.
673 UpdateDataChangedFlag (
678 FORM_BROWSER_FORMSET
*LocalFormSet
;
680 gDisplayFormData
.SettingChangedFlag
= FALSE
;
682 if (IsNvUpdateRequiredForForm (gCurrentSelection
->Form
)) {
683 gDisplayFormData
.SettingChangedFlag
= TRUE
;
688 // Base on the system level to check whether need to show the NV flag.
690 switch (gBrowserSettingScope
) {
693 // Check the maintain list to see whether there is any change.
695 Link
= GetFirstNode (&gBrowserFormSetList
);
696 while (!IsNull (&gBrowserFormSetList
, Link
)) {
697 LocalFormSet
= FORM_BROWSER_FORMSET_FROM_LINK (Link
);
698 if (IsNvUpdateRequiredForFormSet (LocalFormSet
)) {
699 gDisplayFormData
.SettingChangedFlag
= TRUE
;
703 Link
= GetNextNode (&gBrowserFormSetList
, Link
);
709 if (IsNvUpdateRequiredForFormSet (gCurrentSelection
->FormSet
)) {
710 gDisplayFormData
.SettingChangedFlag
= TRUE
;
723 Initialize the Display form structure data.
727 InitializeDisplayFormData (
733 gDisplayFormData
.Signature
= FORM_DISPLAY_ENGINE_FORM_SIGNATURE
;
734 gDisplayFormData
.Version
= FORM_DISPLAY_ENGINE_VERSION_1
;
735 gDisplayFormData
.ImageId
= 0;
736 gDisplayFormData
.AnimationId
= 0;
738 InitializeListHead (&gDisplayFormData
.StatementListHead
);
739 InitializeListHead (&gDisplayFormData
.StatementListOSF
);
740 InitializeListHead (&gDisplayFormData
.HotKeyListHead
);
742 Status
= gBS
->CreateEvent (
745 EfiEventEmptyFunction
,
749 ASSERT_EFI_ERROR (Status
);
754 Free the kotkey info saved in form data.
762 BROWSER_HOT_KEY
*HotKey
;
765 while (!IsListEmpty (&gDisplayFormData
.HotKeyListHead
)) {
766 Link
= GetFirstNode (&gDisplayFormData
.HotKeyListHead
);
767 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
769 RemoveEntryList (&HotKey
->Link
);
771 FreePool (HotKey
->KeyData
);
772 FreePool (HotKey
->HelpString
);
779 Update the Display form structure data.
783 UpdateDisplayFormData (
787 gDisplayFormData
.FormTitle
= gCurrentSelection
->Form
->FormTitle
;
788 gDisplayFormData
.FormId
= gCurrentSelection
->FormId
;
789 gDisplayFormData
.HiiHandle
= gCurrentSelection
->Handle
;
790 CopyGuid (&gDisplayFormData
.FormSetGuid
, &gCurrentSelection
->FormSetGuid
);
792 gDisplayFormData
.Attribute
= 0;
793 gDisplayFormData
.Attribute
|= gCurrentSelection
->Form
->ModalForm
? HII_DISPLAY_MODAL
: 0;
794 gDisplayFormData
.Attribute
|= gCurrentSelection
->Form
->Locked
? HII_DISPLAY_LOCK
: 0;
796 gDisplayFormData
.FormRefreshEvent
= NULL
;
797 gDisplayFormData
.HighLightedStatement
= NULL
;
799 UpdateDataChangedFlag ();
801 AddStatementToDisplayForm ();
806 Free the Display Statement structure data.
808 @param StatementList Point to the statement list which need to be free.
813 LIST_ENTRY
*StatementList
817 LIST_ENTRY
*OptionLink
;
818 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
819 DISPLAY_QUESTION_OPTION
*Option
;
822 // Free Statements/Questions
824 while (!IsListEmpty (StatementList
)) {
825 Link
= GetFirstNode (StatementList
);
826 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
831 while (!IsListEmpty (&Statement
->OptionListHead
)) {
832 OptionLink
= GetFirstNode (&Statement
->OptionListHead
);
833 Option
= DISPLAY_QUESTION_OPTION_FROM_LINK (OptionLink
);
834 RemoveEntryList (&Option
->Link
);
839 // Free nest statement List
841 if (!IsListEmpty (&Statement
->NestStatementList
)) {
842 FreeStatementData (&Statement
->NestStatementList
);
845 RemoveEntryList (&Statement
->DisplayLink
);
846 FreePool (Statement
);
852 Free the Display form structure data.
856 FreeDisplayFormData (
860 FreeStatementData (&gDisplayFormData
.StatementListHead
);
861 FreeStatementData (&gDisplayFormData
.StatementListOSF
);
870 Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
872 @param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.
874 @retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.
877 FORM_BROWSER_STATEMENT
*
878 GetBrowserStatement (
879 IN FORM_DISPLAY_ENGINE_STATEMENT
*DisplayStatement
882 FORM_BROWSER_STATEMENT
*Statement
;
885 Link
= GetFirstNode (&gCurrentSelection
->Form
->StatementListHead
);
886 while (!IsNull (&gCurrentSelection
->Form
->StatementListHead
, Link
)) {
887 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
889 if (Statement
->OpCode
== DisplayStatement
->OpCode
) {
893 Link
= GetNextNode (&gCurrentSelection
->Form
->StatementListHead
, Link
);
900 Update the ValueChanged status for questions in this form.
902 @param FormSet FormSet data structure.
903 @param Form Form data structure.
907 UpdateStatementStatusForForm (
908 IN FORM_BROWSER_FORMSET
*FormSet
,
909 IN FORM_BROWSER_FORM
*Form
913 FORM_BROWSER_STATEMENT
*Question
;
915 Link
= GetFirstNode (&Form
->StatementListHead
);
916 while (!IsNull (&Form
->StatementListHead
, Link
)) {
917 Question
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
918 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
921 // For password opcode, not set the the value changed flag.
923 if (Question
->Operand
== EFI_IFR_PASSWORD_OP
) {
927 IsQuestionValueChanged (FormSet
, Form
, Question
, GetSetValueWithBuffer
);
932 Update the ValueChanged status for questions in this formset.
934 @param FormSet FormSet data structure.
938 UpdateStatementStatusForFormSet (
939 IN FORM_BROWSER_FORMSET
*FormSet
943 FORM_BROWSER_FORM
*Form
;
945 Link
= GetFirstNode (&FormSet
->FormListHead
);
946 while (!IsNull (&FormSet
->FormListHead
, Link
)) {
947 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
948 Link
= GetNextNode (&FormSet
->FormListHead
, Link
);
950 UpdateStatementStatusForForm (FormSet
, Form
);
955 Update the ValueChanged status for questions.
957 @param FormSet FormSet data structure.
958 @param Form Form data structure.
959 @param SettingScope Setting Scope for Default action.
963 UpdateStatementStatus (
964 IN FORM_BROWSER_FORMSET
*FormSet
,
965 IN FORM_BROWSER_FORM
*Form
,
966 IN BROWSER_SETTING_SCOPE SettingScope
970 FORM_BROWSER_FORMSET
*LocalFormSet
;
972 switch (SettingScope
) {
974 Link
= GetFirstNode (&gBrowserFormSetList
);
975 while (!IsNull (&gBrowserFormSetList
, Link
)) {
976 LocalFormSet
= FORM_BROWSER_FORMSET_FROM_LINK (Link
);
977 Link
= GetNextNode (&gBrowserFormSetList
, Link
);
978 if (!ValidateFormSet (LocalFormSet
)) {
982 UpdateStatementStatusForFormSet (LocalFormSet
);
988 UpdateStatementStatusForFormSet (FormSet
);
992 UpdateStatementStatusForForm (FormSet
, Form
);
1002 Process the action request in user input.
1004 @param Action The user input action request info.
1005 @param DefaultId The user input default Id info.
1007 @retval EFI_SUCESSS This function always return successfully for now.
1017 // This is caused by use press ESC, and it should not combine with other action type.
1019 if ((Action
& BROWSER_ACTION_FORM_EXIT
) == BROWSER_ACTION_FORM_EXIT
) {
1020 FindNextMenu (gCurrentSelection
, FormLevel
);
1025 // Below is normal hotkey trigged action, these action maybe combine with each other.
1027 if ((Action
& BROWSER_ACTION_DISCARD
) == BROWSER_ACTION_DISCARD
) {
1028 DiscardForm (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, gBrowserSettingScope
);
1031 if ((Action
& BROWSER_ACTION_DEFAULT
) == BROWSER_ACTION_DEFAULT
) {
1032 ExtractDefault (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, DefaultId
, gBrowserSettingScope
, GetDefaultForAll
, NULL
, FALSE
, FALSE
);
1033 UpdateStatementStatus (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, gBrowserSettingScope
);
1036 if ((Action
& BROWSER_ACTION_SUBMIT
) == BROWSER_ACTION_SUBMIT
) {
1037 SubmitForm (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, gBrowserSettingScope
);
1040 if ((Action
& BROWSER_ACTION_RESET
) == BROWSER_ACTION_RESET
) {
1041 gResetRequiredFormLevel
= TRUE
;
1042 gResetRequiredSystemLevel
= TRUE
;
1045 if ((Action
& BROWSER_ACTION_EXIT
) == BROWSER_ACTION_EXIT
) {
1047 // Form Exit without saving, Similar to ESC Key.
1048 // FormSet Exit without saving, Exit SendForm.
1049 // System Exit without saving, CallExitHandler and Exit SendForm.
1051 DiscardForm (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, gBrowserSettingScope
);
1052 if ((gBrowserSettingScope
== FormLevel
) || (gBrowserSettingScope
== FormSetLevel
)) {
1053 FindNextMenu (gCurrentSelection
, gBrowserSettingScope
);
1054 } else if (gBrowserSettingScope
== SystemLevel
) {
1055 if (ExitHandlerFunction
!= NULL
) {
1056 ExitHandlerFunction ();
1059 gCurrentSelection
->Action
= UI_ACTION_EXIT
;
1067 Check whether the formset guid is in this Hii package list.
1069 @param HiiHandle The HiiHandle for this HII package list.
1070 @param FormSetGuid The formset guid for the request formset.
1072 @retval TRUE Find the formset guid.
1073 @retval FALSE Not found the formset guid.
1077 GetFormsetGuidFromHiiHandle (
1078 IN EFI_HII_HANDLE HiiHandle
,
1079 IN EFI_GUID
*FormSetGuid
1082 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
1086 UINT32 PackageListLength
;
1087 EFI_HII_PACKAGE_HEADER PackageHeader
;
1094 HiiPackageList
= NULL
;
1097 Status
= mHiiDatabase
->ExportPackageLists (mHiiDatabase
, HiiHandle
, &BufferSize
, HiiPackageList
);
1098 if (Status
== EFI_BUFFER_TOO_SMALL
) {
1099 HiiPackageList
= AllocatePool (BufferSize
);
1100 ASSERT (HiiPackageList
!= NULL
);
1102 Status
= mHiiDatabase
->ExportPackageLists (mHiiDatabase
, HiiHandle
, &BufferSize
, HiiPackageList
);
1105 if (EFI_ERROR (Status
) || (HiiPackageList
== NULL
)) {
1110 // Get Form package from this HII package List
1112 Offset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
1114 CopyMem (&PackageListLength
, &HiiPackageList
->PackageLength
, sizeof (UINT32
));
1116 while (Offset
< PackageListLength
) {
1117 Package
= ((UINT8
*)HiiPackageList
) + Offset
;
1118 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
1119 Offset
+= PackageHeader
.Length
;
1121 if (PackageHeader
.Type
== EFI_HII_PACKAGE_FORMS
) {
1123 // Search FormSet in this Form Package
1125 Offset2
= sizeof (EFI_HII_PACKAGE_HEADER
);
1126 while (Offset2
< PackageHeader
.Length
) {
1127 OpCodeData
= Package
+ Offset2
;
1129 if (((EFI_IFR_OP_HEADER
*)OpCodeData
)->OpCode
== EFI_IFR_FORM_SET_OP
) {
1130 if (CompareGuid (FormSetGuid
, (EFI_GUID
*)(OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
)))) {
1136 Offset2
+= ((EFI_IFR_OP_HEADER
*)OpCodeData
)->Length
;
1145 FreePool (HiiPackageList
);
1151 Find HII Handle in the HII database associated with given Device Path.
1153 If DevicePath is NULL, then ASSERT.
1155 @param DevicePath Device Path associated with the HII package list
1157 @param FormsetGuid The formset guid for this formset.
1159 @retval Handle HII package list Handle associated with the Device
1161 @retval NULL Hii Package list handle is not found.
1165 DevicePathToHiiHandle (
1166 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1167 IN EFI_GUID
*FormsetGuid
1171 EFI_DEVICE_PATH_PROTOCOL
*TmpDevicePath
;
1174 EFI_HANDLE DriverHandle
;
1175 EFI_HII_HANDLE
*HiiHandles
;
1176 EFI_HII_HANDLE HiiHandle
;
1178 ASSERT (DevicePath
!= NULL
);
1180 TmpDevicePath
= DevicePath
;
1182 // Locate Device Path Protocol handle buffer
1184 Status
= gBS
->LocateDevicePath (
1185 &gEfiDevicePathProtocolGuid
,
1189 if (EFI_ERROR (Status
) || !IsDevicePathEnd (TmpDevicePath
)) {
1194 // Retrieve all HII Handles from HII database
1196 HiiHandles
= HiiGetHiiHandles (NULL
);
1197 if (HiiHandles
== NULL
) {
1202 // Search Hii Handle by Driver Handle
1205 for (Index
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
1206 Status
= mHiiDatabase
->GetPackageListHandle (
1211 if (!EFI_ERROR (Status
) && (Handle
== DriverHandle
)) {
1212 if (GetFormsetGuidFromHiiHandle (HiiHandles
[Index
], FormsetGuid
)) {
1213 HiiHandle
= HiiHandles
[Index
];
1217 if (HiiHandle
!= NULL
) {
1223 FreePool (HiiHandles
);
1228 Find HII Handle in the HII database associated with given form set guid.
1230 If FormSetGuid is NULL, then ASSERT.
1232 @param ComparingGuid FormSet Guid associated with the HII package list
1235 @retval Handle HII package list Handle associated with the Device
1237 @retval NULL Hii Package list handle is not found.
1241 FormSetGuidToHiiHandle (
1242 EFI_GUID
*ComparingGuid
1245 EFI_HII_HANDLE
*HiiHandles
;
1246 EFI_HII_HANDLE HiiHandle
;
1249 ASSERT (ComparingGuid
!= NULL
);
1253 // Get all the Hii handles
1255 HiiHandles
= HiiGetHiiHandles (NULL
);
1256 ASSERT (HiiHandles
!= NULL
);
1259 // Search for formset of each class type
1261 for (Index
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
1262 if (GetFormsetGuidFromHiiHandle (HiiHandles
[Index
], ComparingGuid
)) {
1263 HiiHandle
= HiiHandles
[Index
];
1267 if (HiiHandle
!= NULL
) {
1272 FreePool (HiiHandles
);
1278 check how to process the changed data in current form or form set.
1280 @param Selection On input, Selection tell setup browser the information
1281 about the Selection, form and formset to be displayed.
1282 On output, Selection return the screen item that is selected
1285 @param Scope Data save or discard scope, form or formset.
1287 @retval TRUE Success process the changed data, will return to the parent form.
1288 @retval FALSE Reject to process the changed data, will stay at current form.
1291 ProcessChangedData (
1292 IN OUT UI_MENU_SELECTION
*Selection
,
1293 IN BROWSER_SETTING_SCOPE Scope
1300 switch (mFormDisplay
->ConfirmDataChange ()) {
1301 case BROWSER_ACTION_DISCARD
:
1302 DiscardForm (Selection
->FormSet
, Selection
->Form
, Scope
);
1305 case BROWSER_ACTION_SUBMIT
:
1306 Status
= SubmitForm (Selection
->FormSet
, Selection
->Form
, Scope
);
1307 if (EFI_ERROR (Status
)) {
1313 case BROWSER_ACTION_NONE
:
1319 // if Invalid value return, process same as BROWSER_ACTION_NONE.
1329 Find parent formset menu(the first menu which has different formset) for current menu.
1330 If not find, just return to the first menu.
1332 @param Selection The selection info.
1337 IN OUT UI_MENU_SELECTION
*Selection
1340 FORM_ENTRY_INFO
*CurrentMenu
;
1341 FORM_ENTRY_INFO
*ParentMenu
;
1343 CurrentMenu
= Selection
->CurrentMenu
;
1344 ParentMenu
= UiFindParentMenu (CurrentMenu
, FormSetLevel
);
1346 if (ParentMenu
!= NULL
) {
1347 CopyMem (&Selection
->FormSetGuid
, &ParentMenu
->FormSetGuid
, sizeof (EFI_GUID
));
1348 Selection
->Handle
= ParentMenu
->HiiHandle
;
1349 Selection
->FormId
= ParentMenu
->FormId
;
1350 Selection
->QuestionId
= ParentMenu
->QuestionId
;
1352 Selection
->FormId
= CurrentMenu
->FormId
;
1353 Selection
->QuestionId
= CurrentMenu
->QuestionId
;
1356 Selection
->Statement
= NULL
;
1360 Process the goto op code, update the info in the selection structure.
1362 @param Statement The statement belong to goto op code.
1363 @param Selection The selection info.
1365 @retval EFI_SUCCESS The menu process successfully.
1366 @return Other value if the process failed.
1370 IN OUT FORM_BROWSER_STATEMENT
*Statement
,
1371 IN OUT UI_MENU_SELECTION
*Selection
1375 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
1376 FORM_BROWSER_FORM
*RefForm
;
1378 EFI_HII_HANDLE HiiHandle
;
1380 Status
= EFI_SUCCESS
;
1385 // Prepare the device path check, get the device path info first.
1387 if (Statement
->HiiValue
.Value
.ref
.DevicePath
!= 0) {
1388 StringPtr
= GetToken (Statement
->HiiValue
.Value
.ref
.DevicePath
, Selection
->FormSet
->HiiHandle
);
1392 // Check whether the device path string is a valid string.
1394 if ((Statement
->HiiValue
.Value
.ref
.DevicePath
!= 0) && (StringPtr
!= NULL
) && (StringPtr
[0] != L
'\0')) {
1395 if (Selection
->Form
->ModalForm
) {
1400 // Goto another Hii Package list
1402 if (mPathFromText
!= NULL
) {
1403 DevicePath
= mPathFromText
->ConvertTextToDevicePath (StringPtr
);
1404 if (DevicePath
!= NULL
) {
1405 HiiHandle
= DevicePathToHiiHandle (DevicePath
, &Statement
->HiiValue
.Value
.ref
.FormSetGuid
);
1406 FreePool (DevicePath
);
1409 FreePool (StringPtr
);
1412 // Not found the EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL protocol.
1414 PopupErrorMessage (BROWSER_PROTOCOL_NOT_FOUND
, NULL
, NULL
, NULL
);
1415 FreePool (StringPtr
);
1419 if (HiiHandle
!= Selection
->Handle
) {
1421 // Goto another Formset, check for uncommitted data
1423 if (((gBrowserSettingScope
== FormLevel
) || (gBrowserSettingScope
== FormSetLevel
)) &&
1424 IsNvUpdateRequiredForFormSet (Selection
->FormSet
))
1426 if (!ProcessChangedData (Selection
, FormSetLevel
)) {
1432 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1433 Selection
->Handle
= HiiHandle
;
1434 if (Selection
->Handle
== NULL
) {
1436 // If target Hii Handle not found, exit current formset.
1438 FindParentFormSet (Selection
);
1442 CopyMem (&Selection
->FormSetGuid
, &Statement
->HiiValue
.Value
.ref
.FormSetGuid
, sizeof (EFI_GUID
));
1443 Selection
->FormId
= Statement
->HiiValue
.Value
.ref
.FormId
;
1444 Selection
->QuestionId
= Statement
->HiiValue
.Value
.ref
.QuestionId
;
1445 } else if (!IsZeroGuid (&Statement
->HiiValue
.Value
.ref
.FormSetGuid
)) {
1446 if (Selection
->Form
->ModalForm
) {
1450 if (!CompareGuid (&Statement
->HiiValue
.Value
.ref
.FormSetGuid
, &Selection
->FormSetGuid
)) {
1452 // Goto another Formset, check for uncommitted data
1454 if (((gBrowserSettingScope
== FormLevel
) || (gBrowserSettingScope
== FormSetLevel
)) &&
1455 IsNvUpdateRequiredForFormSet (Selection
->FormSet
))
1457 if (!ProcessChangedData (Selection
, FormSetLevel
)) {
1463 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1464 Selection
->Handle
= FormSetGuidToHiiHandle (&Statement
->HiiValue
.Value
.ref
.FormSetGuid
);
1465 if (Selection
->Handle
== NULL
) {
1467 // If target Hii Handle not found, exit current formset.
1469 FindParentFormSet (Selection
);
1473 CopyMem (&Selection
->FormSetGuid
, &Statement
->HiiValue
.Value
.ref
.FormSetGuid
, sizeof (EFI_GUID
));
1474 Selection
->FormId
= Statement
->HiiValue
.Value
.ref
.FormId
;
1475 Selection
->QuestionId
= Statement
->HiiValue
.Value
.ref
.QuestionId
;
1476 } else if (Statement
->HiiValue
.Value
.ref
.FormId
!= 0) {
1478 // Goto another Form, check for uncommitted data
1480 if (Statement
->HiiValue
.Value
.ref
.FormId
!= Selection
->FormId
) {
1481 if (((gBrowserSettingScope
== FormLevel
) && IsNvUpdateRequiredForForm (Selection
->Form
))) {
1482 if (!ProcessChangedData (Selection
, FormLevel
)) {
1488 RefForm
= IdToForm (Selection
->FormSet
, Statement
->HiiValue
.Value
.ref
.FormId
);
1489 if ((RefForm
!= NULL
) && (RefForm
->SuppressExpression
!= NULL
)) {
1490 if (EvaluateExpressionList (RefForm
->SuppressExpression
, TRUE
, Selection
->FormSet
, RefForm
) != ExpressFalse
) {
1492 // Form is suppressed.
1494 PopupErrorMessage (BROWSER_FORM_SUPPRESS
, NULL
, NULL
, NULL
);
1499 Selection
->FormId
= Statement
->HiiValue
.Value
.ref
.FormId
;
1500 Selection
->QuestionId
= Statement
->HiiValue
.Value
.ref
.QuestionId
;
1501 } else if (Statement
->HiiValue
.Value
.ref
.QuestionId
!= 0) {
1502 Selection
->QuestionId
= Statement
->HiiValue
.Value
.ref
.QuestionId
;
1509 Process Question Config.
1511 @param Selection The UI menu selection.
1512 @param Question The Question to be peocessed.
1514 @retval EFI_SUCCESS Question Config process success.
1515 @retval Other Question Config process fail.
1519 ProcessQuestionConfig (
1520 IN UI_MENU_SELECTION
*Selection
,
1521 IN FORM_BROWSER_STATEMENT
*Question
1528 if (Question
->QuestionConfig
== 0) {
1535 ConfigResp
= GetToken (Question
->QuestionConfig
, Selection
->FormSet
->HiiHandle
);
1536 if (ConfigResp
== NULL
) {
1537 return EFI_NOT_FOUND
;
1538 } else if (ConfigResp
[0] == L
'\0') {
1543 // Send config to Configuration Driver
1545 Status
= mHiiConfigRouting
->RouteConfig (
1556 Process the user input data.
1558 @param UserInput The user input data.
1560 @retval EFI_SUCESSS This function always return successfully for now.
1565 IN USER_INPUT
*UserInput
1569 FORM_BROWSER_STATEMENT
*Statement
;
1571 Status
= EFI_SUCCESS
;
1575 // When Exit from FormDisplay function, one of the below two cases must be true.
1577 ASSERT (UserInput
->Action
!= 0 || UserInput
->SelectedStatement
!= NULL
);
1580 // Remove the last highligh question id, this id will update when show next form.
1582 gCurrentSelection
->QuestionId
= 0;
1583 if (UserInput
->SelectedStatement
!= NULL
) {
1584 Statement
= GetBrowserStatement (UserInput
->SelectedStatement
);
1585 ASSERT (Statement
!= NULL
);
1588 // This question is the current user select one,record it and later
1589 // show it as the highlight question.
1591 gCurrentSelection
->CurrentMenu
->QuestionId
= Statement
->QuestionId
;
1593 // For statement like text, actio, it not has question id.
1594 // So use FakeQuestionId to save the question.
1596 if (gCurrentSelection
->CurrentMenu
->QuestionId
== 0) {
1597 mCurFakeQestId
= Statement
->FakeQuestionId
;
1604 // First process the Action field in USER_INPUT.
1606 if (UserInput
->Action
!= 0) {
1607 Status
= ProcessAction (UserInput
->Action
, UserInput
->DefaultId
);
1608 gCurrentSelection
->Statement
= NULL
;
1610 ASSERT (Statement
!= NULL
);
1611 gCurrentSelection
->Statement
= Statement
;
1612 switch (Statement
->Operand
) {
1613 case EFI_IFR_REF_OP
:
1614 Status
= ProcessGotoOpCode (Statement
, gCurrentSelection
);
1617 case EFI_IFR_ACTION_OP
:
1619 // Process the Config string <ConfigResp>
1621 Status
= ProcessQuestionConfig (gCurrentSelection
, Statement
);
1624 case EFI_IFR_RESET_BUTTON_OP
:
1626 // Reset Question to default value specified by DefaultId
1628 Status
= ExtractDefault (gCurrentSelection
->FormSet
, NULL
, Statement
->DefaultId
, FormSetLevel
, GetDefaultForAll
, NULL
, FALSE
, FALSE
);
1629 UpdateStatementStatus (gCurrentSelection
->FormSet
, NULL
, FormSetLevel
);
1633 switch (Statement
->Operand
) {
1634 case EFI_IFR_STRING_OP
:
1635 DeleteString (Statement
->HiiValue
.Value
.string
, gCurrentSelection
->FormSet
->HiiHandle
);
1636 Statement
->HiiValue
.Value
.string
= UserInput
->InputValue
.Value
.string
;
1637 CopyMem (Statement
->BufferValue
, UserInput
->InputValue
.Buffer
, (UINTN
)UserInput
->InputValue
.BufferLen
);
1638 FreePool (UserInput
->InputValue
.Buffer
);
1641 case EFI_IFR_PASSWORD_OP
:
1642 if (UserInput
->InputValue
.Buffer
== NULL
) {
1644 // User not input new password, just return.
1649 DeleteString (Statement
->HiiValue
.Value
.string
, gCurrentSelection
->FormSet
->HiiHandle
);
1650 Statement
->HiiValue
.Value
.string
= UserInput
->InputValue
.Value
.string
;
1651 CopyMem (Statement
->BufferValue
, UserInput
->InputValue
.Buffer
, (UINTN
)UserInput
->InputValue
.BufferLen
);
1652 ZeroMem (UserInput
->InputValue
.Buffer
, (UINTN
)UserInput
->InputValue
.BufferLen
);
1653 FreePool (UserInput
->InputValue
.Buffer
);
1655 // Two password match, send it to Configuration Driver
1657 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != 0) {
1658 PasswordCheck (NULL
, UserInput
->SelectedStatement
, (CHAR16
*)Statement
->BufferValue
);
1660 // Clean the value after saved it.
1662 ZeroMem (Statement
->BufferValue
, (UINTN
)UserInput
->InputValue
.BufferLen
);
1663 HiiSetString (gCurrentSelection
->FormSet
->HiiHandle
, Statement
->HiiValue
.Value
.string
, (CHAR16
*)Statement
->BufferValue
, NULL
);
1665 SetQuestionValue (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, GetSetValueWithHiiDriver
);
1670 case EFI_IFR_ORDERED_LIST_OP
:
1671 CopyMem (Statement
->BufferValue
, UserInput
->InputValue
.Buffer
, UserInput
->InputValue
.BufferLen
);
1675 CopyMem (&Statement
->HiiValue
, &UserInput
->InputValue
, sizeof (EFI_HII_VALUE
));
1688 Display form and wait for user to select one menu option, then return it.
1690 @retval EFI_SUCESSS This function always return successfully for now.
1699 USER_INPUT UserInput
;
1700 FORM_ENTRY_INFO
*CurrentMenu
;
1702 ZeroMem (&UserInput
, sizeof (USER_INPUT
));
1705 // Update the menu history data.
1707 CurrentMenu
= UiFindMenuList (gCurrentSelection
->Handle
, &gCurrentSelection
->FormSetGuid
, gCurrentSelection
->FormId
);
1708 if (CurrentMenu
== NULL
) {
1710 // Current menu not found, add it to the menu tree
1712 CurrentMenu
= UiAddMenuList (
1713 gCurrentSelection
->Handle
,
1714 &gCurrentSelection
->FormSetGuid
,
1715 gCurrentSelection
->FormId
,
1716 gCurrentSelection
->QuestionId
1718 ASSERT (CurrentMenu
!= NULL
);
1722 // Back up the form view history data for this form.
1724 UiCopyMenuList (&gCurrentSelection
->Form
->FormViewListHead
, &mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
);
1726 gCurrentSelection
->CurrentMenu
= CurrentMenu
;
1728 if (gCurrentSelection
->QuestionId
== 0) {
1730 // Highlight not specified, fetch it from cached menu
1732 gCurrentSelection
->QuestionId
= CurrentMenu
->QuestionId
;
1735 Status
= EvaluateFormExpressions (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
);
1736 if (EFI_ERROR (Status
)) {
1740 UpdateDisplayFormData ();
1742 ASSERT (gDisplayFormData
.BrowserStatus
== BROWSER_SUCCESS
);
1743 Status
= mFormDisplay
->FormDisplay (&gDisplayFormData
, &UserInput
);
1744 if (EFI_ERROR (Status
)) {
1745 FreeDisplayFormData ();
1749 CheckConfigAccess (gCurrentSelection
->FormSet
);
1751 Status
= ProcessUserInput (&UserInput
);
1752 FreeDisplayFormData ();
1757 Functions which are registered to receive notification of
1758 database events have this prototype. The actual event is encoded
1759 in NotifyType. The following table describes how PackageType,
1760 PackageGuid, Handle, and Package are used for each of the
1763 @param PackageType Package type of the notification.
1765 @param PackageGuid If PackageType is
1766 EFI_HII_PACKAGE_TYPE_GUID, then this is
1767 the pointer to the GUID from the Guid
1768 field of EFI_HII_PACKAGE_GUID_HEADER.
1769 Otherwise, it must be NULL.
1771 @param Package Points to the package referred to by the
1772 notification Handle The handle of the package
1773 list which contains the specified package.
1775 @param Handle The HII handle.
1777 @param NotifyType The type of change concerning the
1779 EFI_HII_DATABASE_NOTIFY_TYPE.
1785 IN UINT8 PackageType
,
1786 IN CONST EFI_GUID
*PackageGuid
,
1787 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
1788 IN EFI_HII_HANDLE Handle
,
1789 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
1792 mHiiPackageListUpdated
= TRUE
;
1798 Update the NV flag info for this form set.
1800 @param FormSet FormSet data structure.
1804 IsNvUpdateRequiredForFormSet (
1805 IN FORM_BROWSER_FORMSET
*FormSet
1809 FORM_BROWSER_FORM
*Form
;
1813 // Not finished question initialization, return FALSE.
1815 if (!FormSet
->QuestionInited
) {
1821 Link
= GetFirstNode (&FormSet
->FormListHead
);
1822 while (!IsNull (&FormSet
->FormListHead
, Link
)) {
1823 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
1825 RetVal
= IsNvUpdateRequiredForForm (Form
);
1830 Link
= GetNextNode (&FormSet
->FormListHead
, Link
);
1837 Update the NvUpdateRequired flag for a form.
1839 @param Form Form data structure.
1843 IsNvUpdateRequiredForForm (
1844 IN FORM_BROWSER_FORM
*Form
1848 FORM_BROWSER_STATEMENT
*Statement
;
1850 Link
= GetFirstNode (&Form
->StatementListHead
);
1851 while (!IsNull (&Form
->StatementListHead
, Link
)) {
1852 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
1854 if (Statement
->ValueChanged
) {
1858 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
1865 Find menu which will show next time.
1867 @param Selection On input, Selection tell setup browser the information
1868 about the Selection, form and formset to be displayed.
1869 On output, Selection return the screen item that is selected
1871 @param SettingLevel Input Settting level, if it is FormLevel, just exit current form.
1872 else, we need to exit current formset.
1874 @retval TRUE Exit current form.
1875 @retval FALSE User press ESC and keep in current form.
1879 IN OUT UI_MENU_SELECTION
*Selection
,
1880 IN BROWSER_SETTING_SCOPE SettingLevel
1883 FORM_ENTRY_INFO
*CurrentMenu
;
1884 FORM_ENTRY_INFO
*ParentMenu
;
1885 BROWSER_SETTING_SCOPE Scope
;
1887 CurrentMenu
= Selection
->CurrentMenu
;
1888 Scope
= FormSetLevel
;
1890 ParentMenu
= UiFindParentMenu (CurrentMenu
, SettingLevel
);
1891 while (ParentMenu
!= NULL
&& !ValidateHiiHandle (ParentMenu
->HiiHandle
)) {
1892 ParentMenu
= UiFindParentMenu (ParentMenu
, SettingLevel
);
1895 if (ParentMenu
!= NULL
) {
1896 if (CompareGuid (&CurrentMenu
->FormSetGuid
, &ParentMenu
->FormSetGuid
)) {
1899 Scope
= FormSetLevel
;
1904 // Form Level Check whether the data is changed.
1906 if (((gBrowserSettingScope
== FormLevel
) && IsNvUpdateRequiredForForm (Selection
->Form
)) ||
1907 ((gBrowserSettingScope
== FormSetLevel
) && IsNvUpdateRequiredForFormSet (Selection
->FormSet
) && (Scope
== FormSetLevel
)))
1909 if (!ProcessChangedData (Selection
, gBrowserSettingScope
)) {
1914 if (ParentMenu
!= NULL
) {
1916 // ParentMenu is found. Then, go to it.
1918 if (Scope
== FormLevel
) {
1919 Selection
->Action
= UI_ACTION_REFRESH_FORM
;
1921 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1922 CopyMem (&Selection
->FormSetGuid
, &ParentMenu
->FormSetGuid
, sizeof (EFI_GUID
));
1923 Selection
->Handle
= ParentMenu
->HiiHandle
;
1926 Selection
->Statement
= NULL
;
1928 Selection
->FormId
= ParentMenu
->FormId
;
1929 Selection
->QuestionId
= ParentMenu
->QuestionId
;
1932 // Clear highlight record for this menu
1934 CurrentMenu
->QuestionId
= 0;
1939 // Current in root page, exit the SendForm
1941 Selection
->Action
= UI_ACTION_EXIT
;
1947 Reconnect the controller.
1949 @param DriverHandle The controller handle which need to be reconnect.
1951 @retval TRUE do the reconnect behavior success.
1952 @retval FALSE do the reconnect behavior failed.
1956 ReconnectController (
1957 IN EFI_HANDLE DriverHandle
1962 Status
= gBS
->DisconnectController (DriverHandle
, NULL
, NULL
);
1963 if (!EFI_ERROR (Status
)) {
1964 Status
= gBS
->ConnectController (DriverHandle
, NULL
, NULL
, TRUE
);
1967 return Status
== EFI_SUCCESS
;
1971 Call the call back function for the question and process the return action.
1973 @param Selection On input, Selection tell setup browser the information
1974 about the Selection, form and formset to be displayed.
1975 On output, Selection return the screen item that is selected
1977 @param FormSet The formset this question belong to.
1978 @param Form The form this question belong to.
1979 @param Question The Question which need to call.
1980 @param Action The action request.
1981 @param SkipSaveOrDiscard Whether skip save or discard action.
1983 @retval EFI_SUCCESS The call back function executes successfully.
1984 @return Other value if the call back function failed to execute.
1987 ProcessCallBackFunction (
1988 IN OUT UI_MENU_SELECTION
*Selection
,
1989 IN FORM_BROWSER_FORMSET
*FormSet
,
1990 IN FORM_BROWSER_FORM
*Form
,
1991 IN FORM_BROWSER_STATEMENT
*Question
,
1992 IN EFI_BROWSER_ACTION Action
,
1993 IN BOOLEAN SkipSaveOrDiscard
1997 EFI_STATUS InternalStatus
;
1998 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
1999 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
2000 EFI_HII_VALUE
*HiiValue
;
2001 EFI_IFR_TYPE_VALUE
*TypeValue
;
2002 FORM_BROWSER_STATEMENT
*Statement
;
2003 BOOLEAN SubmitFormIsRequired
;
2004 BOOLEAN DiscardFormIsRequired
;
2007 BROWSER_SETTING_SCOPE SettingLevel
;
2008 EFI_IFR_TYPE_VALUE BackUpValue
;
2009 UINT8
*BackUpBuffer
;
2012 ConfigAccess
= FormSet
->ConfigAccess
;
2013 SubmitFormIsRequired
= FALSE
;
2014 SettingLevel
= FormSetLevel
;
2015 DiscardFormIsRequired
= FALSE
;
2017 Status
= EFI_SUCCESS
;
2018 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
2019 BackUpBuffer
= NULL
;
2021 if (ConfigAccess
== NULL
) {
2025 Link
= GetFirstNode (&Form
->StatementListHead
);
2026 while (!IsNull (&Form
->StatementListHead
, Link
)) {
2027 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
2028 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
2031 // if Question != NULL, only process the question. Else, process all question in this form.
2033 if ((Question
!= NULL
) && (Statement
!= Question
)) {
2037 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) {
2042 // Check whether Statement is disabled.
2044 if (Statement
->Expression
!= NULL
) {
2045 if (EvaluateExpressionList (Statement
->Expression
, TRUE
, FormSet
, Form
) == ExpressDisable
) {
2050 HiiValue
= &Statement
->HiiValue
;
2051 TypeValue
= &HiiValue
->Value
;
2052 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
2054 // For OrderedList, passing in the value buffer to Callback()
2056 TypeValue
= (EFI_IFR_TYPE_VALUE
*)Statement
->BufferValue
;
2060 // If EFI_BROWSER_ACTION_CHANGING type, back up the new question value.
2062 if (Action
== EFI_BROWSER_ACTION_CHANGING
) {
2063 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
2064 BackUpBuffer
= AllocateCopyPool (Statement
->StorageWidth
, Statement
->BufferValue
);
2065 ASSERT (BackUpBuffer
!= NULL
);
2067 CopyMem (&BackUpValue
, &HiiValue
->Value
, sizeof (EFI_IFR_TYPE_VALUE
));
2071 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
2072 Status
= ConfigAccess
->Callback (
2075 Statement
->QuestionId
,
2080 if (!EFI_ERROR (Status
)) {
2082 // Need to sync the value between Statement->HiiValue->Value and Statement->BufferValue
2084 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
2085 NewString
= GetToken (Statement
->HiiValue
.Value
.string
, FormSet
->HiiHandle
);
2086 ASSERT (NewString
!= NULL
);
2088 ASSERT (StrLen (NewString
) * sizeof (CHAR16
) <= Statement
->StorageWidth
);
2089 if (StrLen (NewString
) * sizeof (CHAR16
) <= Statement
->StorageWidth
) {
2090 ZeroMem (Statement
->BufferValue
, Statement
->StorageWidth
);
2091 CopyMem (Statement
->BufferValue
, NewString
, StrSize (NewString
));
2093 CopyMem (Statement
->BufferValue
, NewString
, Statement
->StorageWidth
);
2096 FreePool (NewString
);
2100 // Only for EFI_BROWSER_ACTION_CHANGED need to handle this ActionRequest.
2103 case EFI_BROWSER_ACTION_CHANGED
:
2104 switch (ActionRequest
) {
2105 case EFI_BROWSER_ACTION_REQUEST_RESET
:
2106 DiscardFormIsRequired
= TRUE
;
2107 gResetRequiredFormLevel
= TRUE
;
2108 gResetRequiredSystemLevel
= TRUE
;
2112 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
2113 SubmitFormIsRequired
= TRUE
;
2117 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
2118 DiscardFormIsRequired
= TRUE
;
2122 case EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
:
2123 SubmitFormIsRequired
= TRUE
;
2124 SettingLevel
= FormLevel
;
2128 case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT
:
2129 DiscardFormIsRequired
= TRUE
;
2130 SettingLevel
= FormLevel
;
2134 case EFI_BROWSER_ACTION_REQUEST_FORM_APPLY
:
2135 SubmitFormIsRequired
= TRUE
;
2136 SettingLevel
= FormLevel
;
2139 case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD
:
2140 DiscardFormIsRequired
= TRUE
;
2141 SettingLevel
= FormLevel
;
2144 case EFI_BROWSER_ACTION_REQUEST_RECONNECT
:
2145 gCallbackReconnect
= TRUE
;
2154 case EFI_BROWSER_ACTION_CHANGING
:
2156 // Do the question validation.
2158 Status
= ValueChangedValidation (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
);
2159 if (!EFI_ERROR (Status
)) {
2161 // check whether the question value changed compared with edit buffer before updating edit buffer
2162 // if changed, set the ValueChanged flag to TRUE,in order to trig the CHANGED callback function
2164 IsQuestionValueChanged (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, GetSetValueWithEditBuffer
);
2166 // According the spec, return value from call back of "changing" and
2167 // "retrieve" should update to the question's temp buffer.
2169 SetQuestionValue (FormSet
, Form
, Statement
, GetSetValueWithEditBuffer
);
2174 case EFI_BROWSER_ACTION_RETRIEVE
:
2176 // According the spec, return value from call back of "changing" and
2177 // "retrieve" should update to the question's temp buffer.
2179 SetQuestionValue (FormSet
, Form
, Statement
, GetSetValueWithEditBuffer
);
2187 // If the callback returns EFI_UNSUPPORTED for EFI_BROWSER_ACTION_CHANGING,
2188 // then the browser will use the value passed to Callback() and ignore the
2189 // value returned by Callback().
2191 if ((Action
== EFI_BROWSER_ACTION_CHANGING
) && (Status
== EFI_UNSUPPORTED
)) {
2192 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
2193 CopyMem (Statement
->BufferValue
, BackUpBuffer
, Statement
->StorageWidth
);
2195 CopyMem (&HiiValue
->Value
, &BackUpValue
, sizeof (EFI_IFR_TYPE_VALUE
));
2199 // Do the question validation.
2201 InternalStatus
= ValueChangedValidation (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
);
2202 if (!EFI_ERROR (InternalStatus
)) {
2204 // check whether the question value changed compared with edit buffer before updating edit buffer
2205 // if changed, set the ValueChanged flag to TRUE,in order to trig the CHANGED callback function
2207 IsQuestionValueChanged (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, GetSetValueWithEditBuffer
);
2208 SetQuestionValue (FormSet
, Form
, Statement
, GetSetValueWithEditBuffer
);
2213 // According the spec, return fail from call back of "changing" and
2214 // "retrieve", should restore the question's value.
2216 if ((Action
== EFI_BROWSER_ACTION_CHANGING
) && (Status
!= EFI_UNSUPPORTED
)) {
2217 if (Statement
->Storage
!= NULL
) {
2218 GetQuestionValue (FormSet
, Form
, Statement
, GetSetValueWithEditBuffer
);
2219 } else if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != 0) {
2220 ProcessCallBackFunction (Selection
, FormSet
, Form
, Question
, EFI_BROWSER_ACTION_RETRIEVE
, FALSE
);
2224 if (Action
== EFI_BROWSER_ACTION_RETRIEVE
) {
2225 GetQuestionValue (FormSet
, Form
, Statement
, GetSetValueWithEditBuffer
);
2228 if (Status
== EFI_UNSUPPORTED
) {
2230 // If return EFI_UNSUPPORTED, also consider Hii driver suceess deal with it.
2232 Status
= EFI_SUCCESS
;
2236 if (BackUpBuffer
!= NULL
) {
2237 FreePool (BackUpBuffer
);
2241 // If Question != NULL, means just process one question
2242 // and if code reach here means this question has finished
2243 // processing, so just break.
2245 if (Question
!= NULL
) {
2250 if (gCallbackReconnect
&& (EFI_BROWSER_ACTION_CHANGED
== Action
)) {
2252 // Confirm changes with user first.
2254 if (IsNvUpdateRequiredForFormSet (FormSet
)) {
2255 if (BROWSER_ACTION_DISCARD
== PopupErrorMessage (BROWSER_RECONNECT_SAVE_CHANGES
, NULL
, NULL
, NULL
)) {
2256 gCallbackReconnect
= FALSE
;
2257 DiscardFormIsRequired
= TRUE
;
2259 SubmitFormIsRequired
= TRUE
;
2262 PopupErrorMessage (BROWSER_RECONNECT_REQUIRED
, NULL
, NULL
, NULL
);
2266 // Exit current formset before do the reconnect.
2269 SettingLevel
= FormSetLevel
;
2272 if (SubmitFormIsRequired
&& !SkipSaveOrDiscard
) {
2273 SubmitForm (FormSet
, Form
, SettingLevel
);
2276 if (DiscardFormIsRequired
&& !SkipSaveOrDiscard
) {
2277 DiscardForm (FormSet
, Form
, SettingLevel
);
2281 FindNextMenu (Selection
, SettingLevel
);
2288 Call the retrieve type call back function for one question to get the initialize data.
2290 This function only used when in the initialize stage, because in this stage, the
2291 Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.
2293 @param ConfigAccess The config access protocol produced by the hii driver.
2294 @param Statement The Question which need to call.
2295 @param FormSet The formset this question belong to.
2297 @retval EFI_SUCCESS The call back function executes successfully.
2298 @return Other value if the call back function failed to execute.
2301 ProcessRetrieveForQuestion (
2302 IN EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
,
2303 IN FORM_BROWSER_STATEMENT
*Statement
,
2304 IN FORM_BROWSER_FORMSET
*FormSet
2308 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
2309 EFI_HII_VALUE
*HiiValue
;
2310 EFI_IFR_TYPE_VALUE
*TypeValue
;
2313 Status
= EFI_SUCCESS
;
2314 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
2316 if (((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) || (ConfigAccess
== NULL
)) {
2317 return EFI_UNSUPPORTED
;
2320 HiiValue
= &Statement
->HiiValue
;
2321 TypeValue
= &HiiValue
->Value
;
2322 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
2324 // For OrderedList, passing in the value buffer to Callback()
2326 TypeValue
= (EFI_IFR_TYPE_VALUE
*)Statement
->BufferValue
;
2329 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
2330 Status
= ConfigAccess
->Callback (
2332 EFI_BROWSER_ACTION_RETRIEVE
,
2333 Statement
->QuestionId
,
2338 if (!EFI_ERROR (Status
) && (HiiValue
->Type
== EFI_IFR_TYPE_STRING
)) {
2339 NewString
= GetToken (Statement
->HiiValue
.Value
.string
, FormSet
->HiiHandle
);
2340 ASSERT (NewString
!= NULL
);
2342 ASSERT (StrLen (NewString
) * sizeof (CHAR16
) <= Statement
->StorageWidth
);
2343 if (StrLen (NewString
) * sizeof (CHAR16
) <= Statement
->StorageWidth
) {
2344 ZeroMem (Statement
->BufferValue
, Statement
->StorageWidth
);
2345 CopyMem (Statement
->BufferValue
, NewString
, StrSize (NewString
));
2347 CopyMem (Statement
->BufferValue
, NewString
, Statement
->StorageWidth
);
2350 FreePool (NewString
);
2357 The worker function that send the displays to the screen. On output,
2358 the selection made by user is returned.
2360 @param Selection On input, Selection tell setup browser the information
2361 about the Selection, form and formset to be displayed.
2362 On output, Selection return the screen item that is selected
2365 @retval EFI_SUCCESS The page is displayed successfully.
2366 @return Other value if the page failed to be diplayed.
2371 IN OUT UI_MENU_SELECTION
*Selection
2376 EFI_HANDLE NotifyHandle
;
2377 FORM_BROWSER_STATEMENT
*Statement
;
2378 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
2380 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
2383 // Register notify for Form package update
2385 Status
= mHiiDatabase
->RegisterPackageNotify (
2387 EFI_HII_PACKAGE_FORMS
,
2390 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
2393 if (EFI_ERROR (Status
)) {
2398 // Initialize current settings of Questions in this FormSet
2400 InitializeCurrentSetting (Selection
->FormSet
);
2403 // Initilize Action field.
2405 Selection
->Action
= UI_ACTION_REFRESH_FORM
;
2408 // Clean the mCurFakeQestId value is formset refreshed.
2414 // Reset Status to prevent the next break from returning incorrect error status.
2416 Status
= EFI_SUCCESS
;
2419 // IFR is updated, force to reparse the IFR binary
2420 // This check is shared by EFI_BROWSER_ACTION_FORM_CLOSE and
2421 // EFI_BROWSER_ACTION_RETRIEVE, so code place here.
2423 if (mHiiPackageListUpdated
) {
2424 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
2425 mHiiPackageListUpdated
= FALSE
;
2430 // Initialize Selection->Form
2432 if (Selection
->FormId
== 0) {
2434 // Zero FormId indicates display the first Form in a FormSet
2436 Link
= GetFirstNode (&Selection
->FormSet
->FormListHead
);
2438 Selection
->Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
2439 Selection
->FormId
= Selection
->Form
->FormId
;
2441 Selection
->Form
= IdToForm (Selection
->FormSet
, Selection
->FormId
);
2444 if (Selection
->Form
== NULL
) {
2446 // No Form to display
2448 Status
= EFI_NOT_FOUND
;
2453 // Check Form is suppressed.
2455 if (Selection
->Form
->SuppressExpression
!= NULL
) {
2456 if (EvaluateExpressionList (Selection
->Form
->SuppressExpression
, TRUE
, Selection
->FormSet
, Selection
->Form
) == ExpressSuppress
) {
2458 // Form is suppressed.
2460 PopupErrorMessage (BROWSER_FORM_SUPPRESS
, NULL
, NULL
, NULL
);
2461 Status
= EFI_NOT_FOUND
;
2467 // Before display new form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN
2468 // for each question with callback flag.
2469 // New form may be the first form, or the different form after another form close.
2471 if (((Selection
->Handle
!= mCurrentHiiHandle
) ||
2472 (!CompareGuid (&Selection
->FormSetGuid
, &mCurrentFormSetGuid
)) ||
2473 (Selection
->FormId
!= mCurrentFormId
)))
2476 // Update Retrieve flag.
2478 mFinishRetrieveCall
= FALSE
;
2481 // Keep current form information
2483 mCurrentHiiHandle
= Selection
->Handle
;
2484 CopyGuid (&mCurrentFormSetGuid
, &Selection
->FormSetGuid
);
2485 mCurrentFormId
= Selection
->FormId
;
2487 if (ConfigAccess
!= NULL
) {
2488 Status
= ProcessCallBackFunction (Selection
, Selection
->FormSet
, Selection
->Form
, NULL
, EFI_BROWSER_ACTION_FORM_OPEN
, FALSE
);
2489 if (EFI_ERROR (Status
)) {
2494 // IFR is updated during callback of EFI_BROWSER_ACTION_FORM_OPEN, force to reparse the IFR binary
2496 if (mHiiPackageListUpdated
) {
2497 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
2498 mHiiPackageListUpdated
= FALSE
;
2505 // Load Questions' Value for display
2507 Status
= LoadFormSetConfig (Selection
, Selection
->FormSet
);
2508 if (EFI_ERROR (Status
)) {
2512 if (!mFinishRetrieveCall
) {
2514 // Finish call RETRIEVE callback for this form.
2516 mFinishRetrieveCall
= TRUE
;
2518 if (ConfigAccess
!= NULL
) {
2519 Status
= ProcessCallBackFunction (Selection
, Selection
->FormSet
, Selection
->Form
, NULL
, EFI_BROWSER_ACTION_RETRIEVE
, FALSE
);
2520 if (EFI_ERROR (Status
)) {
2525 // IFR is updated during callback of open form, force to reparse the IFR binary
2527 if (mHiiPackageListUpdated
) {
2528 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
2529 mHiiPackageListUpdated
= FALSE
;
2538 Status
= DisplayForm ();
2539 if (EFI_ERROR (Status
)) {
2544 // Check Selected Statement (if press ESC, Selection->Statement will be NULL)
2546 Statement
= Selection
->Statement
;
2547 if (Statement
!= NULL
) {
2548 if ((ConfigAccess
!= NULL
) &&
2549 ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) &&
2550 (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
))
2552 Status
= ProcessCallBackFunction (Selection
, Selection
->FormSet
, Selection
->Form
, Statement
, EFI_BROWSER_ACTION_CHANGING
, FALSE
);
2553 if (Statement
->Operand
== EFI_IFR_REF_OP
) {
2555 // Process dynamic update ref opcode.
2557 if (!EFI_ERROR (Status
)) {
2558 Status
= ProcessGotoOpCode (Statement
, Selection
);
2562 // Callback return error status or status return from process goto opcode.
2564 if (EFI_ERROR (Status
)) {
2566 // Cross reference will not be taken, restore all essential field
2568 Selection
->Handle
= mCurrentHiiHandle
;
2569 CopyMem (&Selection
->FormSetGuid
, &mCurrentFormSetGuid
, sizeof (EFI_GUID
));
2570 Selection
->FormId
= mCurrentFormId
;
2571 Selection
->QuestionId
= 0;
2572 Selection
->Action
= UI_ACTION_REFRESH_FORM
;
2576 if (!EFI_ERROR (Status
) &&
2577 (Statement
->Operand
!= EFI_IFR_REF_OP
) &&
2578 ((Statement
->Storage
== NULL
) || ((Statement
->Storage
!= NULL
) && Statement
->ValueChanged
)))
2581 // Only question value has been changed, browser will trig CHANGED callback.
2583 ProcessCallBackFunction (Selection
, Selection
->FormSet
, Selection
->Form
, Statement
, EFI_BROWSER_ACTION_CHANGED
, FALSE
);
2585 // check whether the question value changed compared with buffer value
2586 // if doesn't change ,set the ValueChanged flag to FALSE ,in order not to display the "configuration changed "information on the screen
2588 IsQuestionValueChanged (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, GetSetValueWithBuffer
);
2592 // Do the question validation.
2594 Status
= ValueChangedValidation (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
);
2595 if (!EFI_ERROR (Status
) && (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
)) {
2596 SetQuestionValue (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, GetSetValueWithEditBuffer
);
2598 // Verify whether question value has checked, update the ValueChanged flag in Question.
2600 IsQuestionValueChanged (gCurrentSelection
->FormSet
, gCurrentSelection
->Form
, Statement
, GetSetValueWithBuffer
);
2605 // If question has EFI_IFR_FLAG_RESET_REQUIRED/EFI_IFR_FLAG_RECONNECT_REQUIRED flag and without storage
2606 // and process question success till here, trig the gResetFlag/gFlagReconnect.
2608 if ((Status
== EFI_SUCCESS
) &&
2609 (Statement
->Storage
== NULL
))
2611 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_RESET_REQUIRED
) != 0) {
2612 gResetRequiredFormLevel
= TRUE
;
2613 gResetRequiredSystemLevel
= TRUE
;
2616 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_RECONNECT_REQUIRED
) != 0) {
2617 gFlagReconnect
= TRUE
;
2623 // Check whether Exit flag is TRUE.
2625 if (gExitRequired
) {
2626 switch (gBrowserSettingScope
) {
2628 Selection
->Action
= UI_ACTION_EXIT
;
2633 FindNextMenu (Selection
, gBrowserSettingScope
);
2640 gExitRequired
= FALSE
;
2644 // Before exit the form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE
2645 // for each question with callback flag.
2647 if ((ConfigAccess
!= NULL
) &&
2648 ((Selection
->Action
== UI_ACTION_EXIT
) ||
2649 (Selection
->Handle
!= mCurrentHiiHandle
) ||
2650 (!CompareGuid (&Selection
->FormSetGuid
, &mCurrentFormSetGuid
)) ||
2651 (Selection
->FormId
!= mCurrentFormId
)))
2653 Status
= ProcessCallBackFunction (Selection
, Selection
->FormSet
, Selection
->Form
, NULL
, EFI_BROWSER_ACTION_FORM_CLOSE
, FALSE
);
2654 if (EFI_ERROR (Status
)) {
2658 } while (Selection
->Action
== UI_ACTION_REFRESH_FORM
);
2662 // Reset current form information to the initial setting when error happens or form exit.
2664 if (EFI_ERROR (Status
) || (Selection
->Action
== UI_ACTION_EXIT
)) {
2665 mCurrentHiiHandle
= NULL
;
2666 CopyGuid (&mCurrentFormSetGuid
, &gZeroGuid
);
2671 // Unregister notify for Form package update
2673 mHiiDatabase
->UnregisterPackageNotify (