2 Utility functions for UI presentation.
4 Copyright (c) 2004 - 2012, 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;
24 Clear retangle with specified text attribute.
26 @param LeftColumn Left column of retangle.
27 @param RightColumn Right column of retangle.
28 @param TopRow Start row of retangle.
29 @param BottomRow End row of retangle.
30 @param TextAttribute The character foreground and background.
39 IN UINTN TextAttribute
46 // For now, allocate an arbitrarily long buffer
48 Buffer
= AllocateZeroPool (0x10000);
49 ASSERT (Buffer
!= NULL
);
52 // Set foreground and background as defined
54 gST
->ConOut
->SetAttribute (gST
->ConOut
, TextAttribute
);
57 // Much faster to buffer the long string instead of print it a character at a time
59 SetUnicodeMem (Buffer
, RightColumn
- LeftColumn
, L
' ');
62 // Clear the desired area with the appropriate foreground/background
64 for (Row
= TopRow
; Row
<= BottomRow
; Row
++) {
65 PrintStringAt (LeftColumn
, Row
, Buffer
);
68 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, LeftColumn
, TopRow
);
75 Concatenate a narrow string to another string.
77 @param Destination The destination string.
78 @param Source The source string. The string to be concatenated.
79 to the end of Destination.
84 IN OUT CHAR16
*Destination
,
90 for (Length
= 0; Destination
[Length
] != 0; Length
++)
94 // We now have the length of the original string
95 // We can safely assume for now that we are concatenating a narrow value to this string.
96 // For instance, the string is "XYZ" and cat'ing ">"
97 // If this assumption changes, we need to make this routine a bit more complex
99 Destination
[Length
] = NARROW_CHAR
;
102 StrCpy (Destination
+ Length
, Source
);
106 Count the storage space of a Unicode string.
108 This function handles the Unicode string with NARROW_CHAR
109 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
110 does not count in the resultant output. If a WIDE_CHAR is
111 hit, then 2 Unicode character will consume an output storage
112 space with size of CHAR16 till a NARROW_CHAR is hit.
114 If String is NULL, then ASSERT ().
116 @param String The input string to be counted.
118 @return Storage space for the input string.
128 UINTN IncrementValue
;
130 ASSERT (String
!= NULL
);
131 if (String
== NULL
) {
141 // Advance to the null-terminator or to the first width directive
144 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
145 Index
++, Count
= Count
+ IncrementValue
150 // We hit the null-terminator, we now have a count
152 if (String
[Index
] == 0) {
156 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
157 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
159 if (String
[Index
] == NARROW_CHAR
) {
161 // Skip to the next character
167 // Skip to the next character
172 } while (String
[Index
] != 0);
175 // Increment by one to include the null-terminator in the size
179 return Count
* sizeof (CHAR16
);
183 This function displays the page frame.
185 @param Selection Selection contains the information about
186 the Selection, form and formset to be displayed.
187 Selection action may be updated in retrieve callback.
191 IN UI_MENU_SELECTION
*Selection
199 CHAR16
*StrFrontPageBanner
;
201 EFI_SCREEN_DESCRIPTOR LocalScreen
;
205 ZeroMem (&LocalScreen
, sizeof (EFI_SCREEN_DESCRIPTOR
));
206 gST
->ConOut
->QueryMode (gST
->ConOut
, gST
->ConOut
->Mode
->Mode
, &LocalScreen
.RightColumn
, &LocalScreen
.BottomRow
);
207 ClearLines (0, LocalScreen
.RightColumn
, 0, LocalScreen
.BottomRow
, KEYHELP_BACKGROUND
);
209 if (Selection
->Form
->ModalForm
) {
213 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
216 // For now, allocate an arbitrarily long buffer
218 Buffer
= AllocateZeroPool (0x10000);
219 ASSERT (Buffer
!= NULL
);
221 Character
= BOXDRAW_HORIZONTAL
;
223 for (Index
= 0; Index
+ 2 < (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
); Index
++) {
224 Buffer
[Index
] = Character
;
227 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) == FORMSET_CLASS_FRONT_PAGE
) {
229 // ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
232 LocalScreen
.LeftColumn
,
233 LocalScreen
.RightColumn
,
235 FRONT_PAGE_HEADER_HEIGHT
- 1 + LocalScreen
.TopRow
,
236 BANNER_TEXT
| BANNER_BACKGROUND
239 // for (Line = 0; Line < BANNER_HEIGHT; Line++) {
241 for (Line
= (UINT8
) LocalScreen
.TopRow
; Line
< BANNER_HEIGHT
+ (UINT8
) LocalScreen
.TopRow
; Line
++) {
243 // for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
245 for (Alignment
= (UINT8
) LocalScreen
.LeftColumn
;
246 Alignment
< BANNER_COLUMNS
+ (UINT8
) LocalScreen
.LeftColumn
;
249 RowIdx
= (UINT8
) (Line
- (UINT8
) LocalScreen
.TopRow
);
250 ColumnIdx
= (UINT8
) (Alignment
- (UINT8
) LocalScreen
.LeftColumn
);
252 ASSERT (RowIdx
< BANNER_HEIGHT
);
253 ASSERT (ColumnIdx
< BANNER_COLUMNS
);
255 if (gBannerData
->Banner
[RowIdx
][ColumnIdx
] != 0x0000) {
256 StrFrontPageBanner
= GetToken (
257 gBannerData
->Banner
[RowIdx
][ColumnIdx
],
264 switch (Alignment
- LocalScreen
.LeftColumn
) {
267 // Handle left column
269 PrintStringAt (LocalScreen
.LeftColumn
+ BANNER_LEFT_COLUMN_INDENT
, Line
, StrFrontPageBanner
);
274 // Handle center column
277 LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3,
285 // Handle right column
288 LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3,
295 FreePool (StrFrontPageBanner
);
301 LocalScreen
.LeftColumn
,
302 LocalScreen
.RightColumn
,
303 LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
,
304 LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 1,
305 KEYHELP_TEXT
| KEYHELP_BACKGROUND
308 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) != FORMSET_CLASS_FRONT_PAGE
) {
310 LocalScreen
.LeftColumn
,
311 LocalScreen
.RightColumn
,
313 LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1,
314 TITLE_TEXT
| TITLE_BACKGROUND
317 // Print Top border line
318 // +------------------------------------------------------------------------------+
320 // +------------------------------------------------------------------------------+
322 Character
= BOXDRAW_DOWN_RIGHT
;
324 PrintChar (Character
);
325 PrintString (Buffer
);
327 Character
= BOXDRAW_DOWN_LEFT
;
328 PrintChar (Character
);
330 Character
= BOXDRAW_VERTICAL
;
331 for (Row
= LocalScreen
.TopRow
+ 1; Row
<= LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 2; Row
++) {
332 PrintCharAt (LocalScreen
.LeftColumn
, Row
, Character
);
333 PrintCharAt (LocalScreen
.RightColumn
- 1, Row
, Character
);
336 Character
= BOXDRAW_UP_RIGHT
;
337 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1, Character
);
338 PrintString (Buffer
);
340 Character
= BOXDRAW_UP_LEFT
;
341 PrintChar (Character
);
343 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
345 // Print Bottom border line
346 // +------------------------------------------------------------------------------+
348 // +------------------------------------------------------------------------------+
350 Character
= BOXDRAW_DOWN_RIGHT
;
351 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
, Character
);
353 PrintString (Buffer
);
355 Character
= BOXDRAW_DOWN_LEFT
;
356 PrintChar (Character
);
357 Character
= BOXDRAW_VERTICAL
;
358 for (Row
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
+ 1;
359 Row
<= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 2;
362 PrintCharAt (LocalScreen
.LeftColumn
, Row
, Character
);
363 PrintCharAt (LocalScreen
.RightColumn
- 1, Row
, Character
);
366 Character
= BOXDRAW_UP_RIGHT
;
367 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 1, Character
);
369 PrintString (Buffer
);
371 Character
= BOXDRAW_UP_LEFT
;
372 PrintChar (Character
);
382 Evaluate all expressions in a Form.
384 @param FormSet FormSet this Form belongs to.
385 @param Form The Form.
387 @retval EFI_SUCCESS The expression evaluated successfuly
391 EvaluateFormExpressions (
392 IN FORM_BROWSER_FORMSET
*FormSet
,
393 IN FORM_BROWSER_FORM
*Form
398 FORM_EXPRESSION
*Expression
;
400 Link
= GetFirstNode (&Form
->ExpressionListHead
);
401 while (!IsNull (&Form
->ExpressionListHead
, Link
)) {
402 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
403 Link
= GetNextNode (&Form
->ExpressionListHead
, Link
);
405 if (Expression
->Type
== EFI_HII_EXPRESSION_INCONSISTENT_IF
||
406 Expression
->Type
== EFI_HII_EXPRESSION_NO_SUBMIT_IF
||
407 Expression
->Type
== EFI_HII_EXPRESSION_WRITE
||
408 (Expression
->Type
== EFI_HII_EXPRESSION_READ
&& Form
->FormType
!= STANDARD_MAP_FORM_TYPE
)) {
410 // Postpone Form validation to Question editing or Form submitting or Question Write or Question Read for nonstandard form.
415 Status
= EvaluateExpression (FormSet
, Form
, Expression
);
416 if (EFI_ERROR (Status
)) {
425 +------------------------------------------------------------------------------+
427 +------------------------------------------------------------------------------+
445 +------------------------------------------------------------------------------+
446 ?F1=Scroll Help F9=Reset to Defaults F10=Save and Exit ?
447 | ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Discard Changes |
448 +------------------------------------------------------------------------------+
454 Display form and wait for user to select one menu option, then return it.
456 @param Selection On input, Selection tell setup browser the information
457 about the Selection, form and formset to be displayed.
458 On output, Selection return the screen item that is selected
460 @retval EFI_SUCESSS This function always return successfully for now.
465 IN OUT UI_MENU_SELECTION
*Selection
469 UINT16 MenuItemCount
;
470 EFI_HII_HANDLE Handle
;
471 EFI_SCREEN_DESCRIPTOR LocalScreen
;
474 CHAR16
*OutputString
;
476 FORM_BROWSER_STATEMENT
*Statement
;
477 UINT16 NumberOfLines
;
479 UI_MENU_OPTION
*MenuOption
;
482 Handle
= Selection
->Handle
;
489 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
491 StringPtr
= GetToken (Selection
->Form
->FormTitle
, Handle
);
493 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) != FORMSET_CLASS_FRONT_PAGE
) {
494 if (Selection
->Form
->ModalForm
) {
495 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| EFI_BACKGROUND_BLACK
);
497 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| TITLE_BACKGROUND
);
500 (LocalScreen
.RightColumn
+ LocalScreen
.LeftColumn
- GetStringWidth (StringPtr
) / 2) / 2,
501 LocalScreen
.TopRow
+ 1,
507 // Remove Buffer allocated for StringPtr after it has been used.
509 FreePool (StringPtr
);
512 // Evaluate all the Expressions in this Form
514 Status
= EvaluateFormExpressions (Selection
->FormSet
, Selection
->Form
);
515 if (EFI_ERROR (Status
)) {
519 Selection
->FormEditable
= FALSE
;
520 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
521 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
522 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
524 if (EvaluateExpressionList(Statement
->Expression
, FALSE
, NULL
, NULL
) <= ExpressGrayOut
) {
525 StringPtr
= GetToken (Statement
->Prompt
, Handle
);
526 ASSERT (StringPtr
!= NULL
);
528 Width
= GetWidth (Statement
, Handle
);
533 for (; GetLineByWidth (StringPtr
, Width
, &GlyphWidth
,&ArrayEntry
, &OutputString
) != 0x0000;) {
535 // If there is more string to process print on the next row and increment the Skip value
537 if (StrLen (&StringPtr
[ArrayEntry
]) != 0) {
541 FreePool (OutputString
);
545 // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do
548 MenuOption
= UiAddMenuOption (StringPtr
, Selection
->Handle
, Selection
->Form
, Statement
, NumberOfLines
, MenuItemCount
);
551 if (MenuOption
->IsQuestion
&& !MenuOption
->ReadOnly
) {
553 // At least one item is not readonly, this Form is considered as editable
555 Selection
->FormEditable
= TRUE
;
559 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
562 Status
= UiDisplayMenu (Selection
);
570 Initialize the HII String Token to the correct values.
574 InitializeBrowserStrings (
578 gEnterString
= GetToken (STRING_TOKEN (ENTER_STRING
), gHiiHandle
);
579 gEnterCommitString
= GetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), gHiiHandle
);
580 gEnterEscapeString
= GetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), gHiiHandle
);
581 gEscapeString
= GetToken (STRING_TOKEN (ESCAPE_STRING
), gHiiHandle
);
582 gMoveHighlight
= GetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), gHiiHandle
);
583 gMakeSelection
= GetToken (STRING_TOKEN (MAKE_SELECTION
), gHiiHandle
);
584 gDecNumericInput
= GetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), gHiiHandle
);
585 gHexNumericInput
= GetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), gHiiHandle
);
586 gToggleCheckBox
= GetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), gHiiHandle
);
587 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
588 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
589 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
590 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
591 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
592 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
593 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
594 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
595 gAreYouSure
= GetToken (STRING_TOKEN (ARE_YOU_SURE
), gHiiHandle
);
596 gYesResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), gHiiHandle
);
597 gNoResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), gHiiHandle
);
598 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
599 gPlusString
= GetToken (STRING_TOKEN (PLUS_STRING
), gHiiHandle
);
600 gMinusString
= GetToken (STRING_TOKEN (MINUS_STRING
), gHiiHandle
);
601 gAdjustNumber
= GetToken (STRING_TOKEN (ADJUST_NUMBER
), gHiiHandle
);
602 gSaveChanges
= GetToken (STRING_TOKEN (SAVE_CHANGES
), gHiiHandle
);
603 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
604 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
609 Free up the resource allocated for all strings required
618 FreePool (gEnterString
);
619 FreePool (gEnterCommitString
);
620 FreePool (gEnterEscapeString
);
621 FreePool (gEscapeString
);
622 FreePool (gMoveHighlight
);
623 FreePool (gMakeSelection
);
624 FreePool (gDecNumericInput
);
625 FreePool (gHexNumericInput
);
626 FreePool (gToggleCheckBox
);
627 FreePool (gPromptForData
);
628 FreePool (gPromptForPassword
);
629 FreePool (gPromptForNewPassword
);
630 FreePool (gConfirmPassword
);
631 FreePool (gPassowordInvalid
);
632 FreePool (gConfirmError
);
633 FreePool (gPressEnter
);
634 FreePool (gEmptyString
);
635 FreePool (gAreYouSure
);
636 FreePool (gYesResponse
);
637 FreePool (gNoResponse
);
638 FreePool (gMiniString
);
639 FreePool (gPlusString
);
640 FreePool (gMinusString
);
641 FreePool (gAdjustNumber
);
642 FreePool (gSaveChanges
);
643 FreePool (gOptionMismatch
);
644 FreePool (gFormSuppress
);
649 Show all registered HotKey help strings on bottom Rows.
653 PrintHotKeyHelpString (
659 UINTN BottomRowOfHotKeyHelp
;
662 EFI_SCREEN_DESCRIPTOR LocalScreen
;
664 BROWSER_HOT_KEY
*HotKey
;
666 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
667 ColumnWidth
= (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
668 BottomRowOfHotKeyHelp
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 3;
671 // Calculate total number of Register HotKeys.
674 Link
= GetFirstNode (&gBrowserHotKeyList
);
675 while (!IsNull (&gBrowserHotKeyList
, Link
)) {
676 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
678 // Help string can't exceed ColumnWidth. One Row will show three Help information.
680 if (StrLen (HotKey
->HelpString
) > ColumnWidth
) {
681 HotKey
->HelpString
[ColumnWidth
] = L
'\0';
684 // Calculate help information Column and Row.
686 if ((Index
% 3) != 2) {
687 CurrentCol
= LocalScreen
.LeftColumn
+ (2 - Index
% 3) * ColumnWidth
;
689 CurrentCol
= LocalScreen
.LeftColumn
+ 2;
691 CurrentRow
= BottomRowOfHotKeyHelp
- Index
/ 3;
693 // Print HotKey help string on bottom Row.
695 PrintStringAt (CurrentCol
, CurrentRow
, HotKey
->HelpString
);
700 Link
= GetNextNode (&gBrowserHotKeyList
, Link
);
708 Update key's help imformation.
710 @param Selection Tell setup browser the information about the Selection
711 @param MenuOption The Menu option
712 @param Selected Whether or not a tag be selected
717 IN UI_MENU_SELECTION
*Selection
,
718 IN UI_MENU_OPTION
*MenuOption
,
724 UINTN LeftColumnOfHelp
;
725 UINTN RightColumnOfHelp
;
727 UINTN BottomRowOfHelp
;
728 UINTN StartColumnOfHelp
;
729 EFI_SCREEN_DESCRIPTOR LocalScreen
;
730 FORM_BROWSER_STATEMENT
*Statement
;
732 gST
->ConOut
->SetAttribute (gST
->ConOut
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
734 if (Selection
->Form
->ModalForm
) {
738 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
740 SecCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
741 ThdCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3 * 2;
743 StartColumnOfHelp
= LocalScreen
.LeftColumn
+ 2;
744 LeftColumnOfHelp
= LocalScreen
.LeftColumn
+ 1;
745 RightColumnOfHelp
= LocalScreen
.RightColumn
- 2;
746 TopRowOfHelp
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
+ 1;
747 BottomRowOfHelp
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 2;
749 Statement
= MenuOption
->ThisTag
;
750 switch (Statement
->Operand
) {
751 case EFI_IFR_ORDERED_LIST_OP
:
752 case EFI_IFR_ONE_OF_OP
:
753 case EFI_IFR_NUMERIC_OP
:
754 case EFI_IFR_TIME_OP
:
755 case EFI_IFR_DATE_OP
:
756 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
760 // On system setting, HotKey will show on every form.
762 if (gBrowserSettingScope
== SystemLevel
||
763 (Selection
->FormEditable
&& gFunctionKeySetting
!= NONE_FUNCTION_KEY_SETTING
)) {
764 PrintHotKeyHelpString ();
767 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
768 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
771 if ((Statement
->Operand
== EFI_IFR_DATE_OP
) ||
772 (Statement
->Operand
== EFI_IFR_TIME_OP
)) {
783 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
784 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gAdjustNumber
);
786 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
787 if (Statement
->Operand
== EFI_IFR_NUMERIC_OP
&& Statement
->Step
!= 0) {
788 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gAdjustNumber
);
790 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
793 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterCommitString
);
796 // If it is a selected numeric with manual input, display different message
798 if ((Statement
->Operand
== EFI_IFR_NUMERIC_OP
) ||
799 (Statement
->Operand
== EFI_IFR_DATE_OP
) ||
800 (Statement
->Operand
== EFI_IFR_TIME_OP
)) {
804 ((Statement
->Flags
& EFI_IFR_DISPLAY_UINT_HEX
) == EFI_IFR_DISPLAY_UINT_HEX
) ? gHexNumericInput
: gDecNumericInput
806 } else if (Statement
->Operand
!= EFI_IFR_ORDERED_LIST_OP
) {
807 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
810 if (Statement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) {
811 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gPlusString
);
812 PrintStringAt (ThdCol
, TopRowOfHelp
, gMinusString
);
815 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
819 case EFI_IFR_CHECKBOX_OP
:
820 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
823 // On system setting, HotKey will show on every form.
825 if (gBrowserSettingScope
== SystemLevel
||
826 (Selection
->FormEditable
&& gFunctionKeySetting
!= NONE_FUNCTION_KEY_SETTING
)) {
827 PrintHotKeyHelpString ();
829 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
830 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
833 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
834 PrintStringAt (SecCol
, BottomRowOfHelp
, gToggleCheckBox
);
838 case EFI_IFR_PASSWORD_OP
:
839 case EFI_IFR_STRING_OP
:
840 case EFI_IFR_TEXT_OP
:
841 case EFI_IFR_ACTION_OP
:
842 case EFI_IFR_RESET_BUTTON_OP
:
843 case EFI_IFR_SUBTITLE_OP
:
844 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
848 // On system setting, HotKey will show on every form.
850 if (gBrowserSettingScope
== SystemLevel
||
851 (Selection
->FormEditable
&& gFunctionKeySetting
!= NONE_FUNCTION_KEY_SETTING
)) {
852 PrintHotKeyHelpString ();
854 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
855 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
858 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
859 if (Statement
->Operand
!= EFI_IFR_TEXT_OP
&& Statement
->Operand
!= EFI_IFR_SUBTITLE_OP
) {
860 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
863 if (Statement
->Operand
!= EFI_IFR_REF_OP
) {
865 (LocalScreen
.RightColumn
- GetStringWidth (gEnterCommitString
) / 2) / 2,
869 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
880 Functions which are registered to receive notification of
881 database events have this prototype. The actual event is encoded
882 in NotifyType. The following table describes how PackageType,
883 PackageGuid, Handle, and Package are used for each of the
886 @param PackageType Package type of the notification.
888 @param PackageGuid If PackageType is
889 EFI_HII_PACKAGE_TYPE_GUID, then this is
890 the pointer to the GUID from the Guid
891 field of EFI_HII_PACKAGE_GUID_HEADER.
892 Otherwise, it must be NULL.
894 @param Package Points to the package referred to by the
895 notification Handle The handle of the package
896 list which contains the specified package.
898 @param Handle The HII handle.
900 @param NotifyType The type of change concerning the
902 EFI_HII_DATABASE_NOTIFY_TYPE.
908 IN UINT8 PackageType
,
909 IN CONST EFI_GUID
*PackageGuid
,
910 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
911 IN EFI_HII_HANDLE Handle
,
912 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
915 mHiiPackageListUpdated
= TRUE
;
921 check whether the formset need to update the NV.
923 @param FormSet FormSet data structure.
925 @retval TRUE Need to update the NV.
926 @retval FALSE No need to update the NV.
930 IN FORM_BROWSER_FORMSET
*FormSet
934 FORM_BROWSER_FORM
*Form
;
936 Link
= GetFirstNode (&FormSet
->FormListHead
);
937 while (!IsNull (&FormSet
->FormListHead
, Link
)) {
938 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
940 if (Form
->NvUpdateRequired
) {
944 Link
= GetNextNode (&FormSet
->FormListHead
, Link
);
951 check whether the formset need to update the NV.
953 @param FormSet FormSet data structure.
954 @param SetValue Whether set new value or clear old value.
959 IN FORM_BROWSER_FORMSET
*FormSet
,
964 FORM_BROWSER_FORM
*Form
;
966 Link
= GetFirstNode (&FormSet
->FormListHead
);
967 while (!IsNull (&FormSet
->FormListHead
, Link
)) {
968 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
970 Form
->NvUpdateRequired
= SetValue
;
972 Link
= GetNextNode (&FormSet
->FormListHead
, Link
);
976 Find menu which will show next time.
978 @param Selection On input, Selection tell setup browser the information
979 about the Selection, form and formset to be displayed.
980 On output, Selection return the screen item that is selected
982 @param Repaint Whether need to repaint the menu.
983 @param NewLine Whether need to show at new line.
985 @retval TRUE Need return.
986 @retval FALSE No need to return.
990 IN OUT UI_MENU_SELECTION
*Selection
,
995 UI_MENU_LIST
*CurrentMenu
;
999 BROWSER_SETTING_SCOPE Scope
;
1001 CurrentMenu
= Selection
->CurrentMenu
;
1003 if (CurrentMenu
!= NULL
&& CurrentMenu
->Parent
!= NULL
) {
1005 // we have a parent, so go to the parent menu
1007 if (CompareGuid (&CurrentMenu
->FormSetGuid
, &CurrentMenu
->Parent
->FormSetGuid
)) {
1009 // The parent menu and current menu are in the same formset
1011 Selection
->Action
= UI_ACTION_REFRESH_FORM
;
1014 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1015 CopyMem (&Selection
->FormSetGuid
, &CurrentMenu
->Parent
->FormSetGuid
, sizeof (EFI_GUID
));
1016 Selection
->Handle
= CurrentMenu
->Parent
->HiiHandle
;
1017 Scope
= FormSetLevel
;
1021 // Form Level Check whether the data is changed.
1023 if ((gBrowserSettingScope
== FormLevel
&& Selection
->Form
->NvUpdateRequired
) ||
1024 (gBrowserSettingScope
== FormSetLevel
&& IsNvUpdateRequired(Selection
->FormSet
) && Scope
== FormSetLevel
)) {
1025 gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
1027 YesResponse
= gYesResponse
[0];
1028 NoResponse
= gNoResponse
[0];
1031 // If NV flag is up, prompt user
1034 CreateDialog (4, TRUE
, 0, NULL
, &Key
, gEmptyString
, gSaveChanges
, gAreYouSure
, gEmptyString
);
1037 (Key
.ScanCode
!= SCAN_ESC
) &&
1038 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (NoResponse
| UPPER_LOWER_CASE_OFFSET
)) &&
1039 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (YesResponse
| UPPER_LOWER_CASE_OFFSET
))
1042 if (Key
.ScanCode
== SCAN_ESC
) {
1044 // User hits the ESC key, Ingore.
1046 if (Repaint
!= NULL
) {
1049 if (NewLine
!= NULL
) {
1053 Selection
->Action
= UI_ACTION_NONE
;
1057 if ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) == (YesResponse
| UPPER_LOWER_CASE_OFFSET
)) {
1059 // If the user hits the YesResponse key
1061 SubmitForm (Selection
->FormSet
, Selection
->Form
, Scope
);
1064 // If the user hits the NoResponse key
1066 DiscardForm (Selection
->FormSet
, Selection
->Form
, Scope
);
1070 Selection
->Statement
= NULL
;
1072 Selection
->FormId
= CurrentMenu
->Parent
->FormId
;
1073 Selection
->QuestionId
= CurrentMenu
->Parent
->QuestionId
;
1076 // Clear highlight record for this menu
1078 CurrentMenu
->QuestionId
= 0;
1082 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) == FORMSET_CLASS_FRONT_PAGE
) {
1084 // We never exit FrontPage, so skip the ESC
1086 Selection
->Action
= UI_ACTION_NONE
;
1091 // We are going to leave current FormSet, so check uncommited data in this FormSet
1093 if (gBrowserSettingScope
!= SystemLevel
&& IsNvUpdateRequired(Selection
->FormSet
)) {
1094 gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
1096 YesResponse
= gYesResponse
[0];
1097 NoResponse
= gNoResponse
[0];
1100 // If NV flag is up, prompt user
1103 CreateDialog (4, TRUE
, 0, NULL
, &Key
, gEmptyString
, gSaveChanges
, gAreYouSure
, gEmptyString
);
1106 (Key
.ScanCode
!= SCAN_ESC
) &&
1107 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (NoResponse
| UPPER_LOWER_CASE_OFFSET
)) &&
1108 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (YesResponse
| UPPER_LOWER_CASE_OFFSET
))
1111 if (Key
.ScanCode
== SCAN_ESC
) {
1113 // User hits the ESC key
1115 if (Repaint
!= NULL
) {
1119 if (NewLine
!= NULL
) {
1123 Selection
->Action
= UI_ACTION_NONE
;
1127 if ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) == (YesResponse
| UPPER_LOWER_CASE_OFFSET
)) {
1129 // If the user hits the YesResponse key
1131 SubmitForm (Selection
->FormSet
, Selection
->Form
, FormSetLevel
);
1134 // If the user hits the NoResponse key
1136 DiscardForm (Selection
->FormSet
, Selection
->Form
, FormSetLevel
);
1140 Selection
->Statement
= NULL
;
1141 if (CurrentMenu
!= NULL
) {
1142 CurrentMenu
->QuestionId
= 0;
1145 Selection
->Action
= UI_ACTION_EXIT
;
1150 Call the call back function for the question and process the return action.
1152 @param Selection On input, Selection tell setup browser the information
1153 about the Selection, form and formset to be displayed.
1154 On output, Selection return the screen item that is selected
1156 @param Question The Question which need to call.
1157 @param Action The action request.
1158 @param SkipSaveOrDiscard Whether skip save or discard action.
1160 @retval EFI_SUCCESS The call back function excutes successfully.
1161 @return Other value if the call back function failed to excute.
1164 ProcessCallBackFunction (
1165 IN OUT UI_MENU_SELECTION
*Selection
,
1166 IN FORM_BROWSER_STATEMENT
*Question
,
1167 IN EFI_BROWSER_ACTION Action
,
1168 IN BOOLEAN SkipSaveOrDiscard
1172 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
1173 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
1174 EFI_HII_VALUE
*HiiValue
;
1175 EFI_IFR_TYPE_VALUE
*TypeValue
;
1176 FORM_BROWSER_STATEMENT
*Statement
;
1177 BOOLEAN SubmitFormIsRequired
;
1178 BOOLEAN DiscardFormIsRequired
;
1181 BROWSER_SETTING_SCOPE SettingLevel
;
1183 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
1184 SubmitFormIsRequired
= FALSE
;
1185 SettingLevel
= FormSetLevel
;
1186 DiscardFormIsRequired
= FALSE
;
1188 Status
= EFI_SUCCESS
;
1189 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1191 if (ConfigAccess
== NULL
) {
1195 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
1196 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
1197 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
1198 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
1201 // if Question != NULL, only process the question. Else, process all question in this form.
1203 if ((Question
!= NULL
) && (Statement
!= Question
)) {
1207 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) {
1212 // Check whether Statement is disabled.
1214 if (Statement
->Expression
!= NULL
) {
1215 if (EvaluateExpressionList(Statement
->Expression
, TRUE
, Selection
->FormSet
, Selection
->Form
) == ExpressDisable
) {
1220 HiiValue
= &Statement
->HiiValue
;
1221 TypeValue
= &HiiValue
->Value
;
1222 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
1224 // For OrderedList, passing in the value buffer to Callback()
1226 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Statement
->BufferValue
;
1229 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1230 Status
= ConfigAccess
->Callback (
1233 Statement
->QuestionId
,
1238 if (!EFI_ERROR (Status
)) {
1240 // Only for EFI_BROWSER_ACTION_CHANGED need to handle this ActionRequest.
1242 if (Action
== EFI_BROWSER_ACTION_CHANGED
) {
1243 switch (ActionRequest
) {
1244 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1245 gResetRequired
= TRUE
;
1246 Selection
->Action
= UI_ACTION_EXIT
;
1249 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1250 SubmitFormIsRequired
= TRUE
;
1251 Selection
->Action
= UI_ACTION_EXIT
;
1254 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1255 Selection
->Action
= UI_ACTION_EXIT
;
1258 case EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
:
1259 SubmitFormIsRequired
= TRUE
;
1260 SettingLevel
= FormLevel
;
1264 case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT
:
1265 DiscardFormIsRequired
= TRUE
;
1266 SettingLevel
= FormLevel
;
1270 case EFI_BROWSER_ACTION_REQUEST_FORM_APPLY
:
1271 SubmitFormIsRequired
= TRUE
;
1272 SettingLevel
= FormLevel
;
1275 case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD
:
1276 DiscardFormIsRequired
= TRUE
;
1277 SettingLevel
= FormLevel
;
1286 // According the spec, return value from call back of "changing" and
1287 // "retrieve" should update to the question's temp buffer.
1289 if (Action
== EFI_BROWSER_ACTION_CHANGING
|| Action
== EFI_BROWSER_ACTION_RETRIEVE
) {
1290 SetQuestionValue(Selection
->FormSet
, Selection
->Form
, Statement
, GetSetValueWithEditBuffer
);
1294 // According the spec, return fail from call back of "changing" and
1295 // "retrieve", should restore the question's value.
1297 if (Action
== EFI_BROWSER_ACTION_CHANGING
|| Action
== EFI_BROWSER_ACTION_RETRIEVE
) {
1298 GetQuestionValue(Selection
->FormSet
, Selection
->Form
, Statement
, GetSetValueWithEditBuffer
);
1301 if (Status
== EFI_UNSUPPORTED
) {
1303 // If return EFI_UNSUPPORTED, also consider Hii driver suceess deal with it.
1305 Status
= EFI_SUCCESS
;
1310 if (SubmitFormIsRequired
&& !SkipSaveOrDiscard
) {
1311 SubmitForm (Selection
->FormSet
, Selection
->Form
, SettingLevel
);
1314 if (DiscardFormIsRequired
&& !SkipSaveOrDiscard
) {
1315 DiscardForm (Selection
->FormSet
, Selection
->Form
, SettingLevel
);
1319 FindNextMenu (Selection
, NULL
, NULL
);
1326 The worker function that send the displays to the screen. On output,
1327 the selection made by user is returned.
1329 @param Selection On input, Selection tell setup browser the information
1330 about the Selection, form and formset to be displayed.
1331 On output, Selection return the screen item that is selected
1334 @retval EFI_SUCCESS The page is displayed successfully.
1335 @return Other value if the page failed to be diplayed.
1340 IN OUT UI_MENU_SELECTION
*Selection
1345 EFI_HANDLE NotifyHandle
;
1346 FORM_BROWSER_STATEMENT
*Statement
;
1347 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
1350 gMenuRefreshHead
= NULL
;
1351 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
1354 // Register notify for Form package update
1356 Status
= mHiiDatabase
->RegisterPackageNotify (
1358 EFI_HII_PACKAGE_FORMS
,
1361 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
1364 if (EFI_ERROR (Status
)) {
1369 // Initialize current settings of Questions in this FormSet
1371 Status
= InitializeCurrentSetting (Selection
->FormSet
);
1372 if (EFI_ERROR (Status
)) {
1377 // Update gOldFormSet on maintain back up FormSet list.
1378 // And, make gOldFormSet point to current FormSet.
1380 if (gOldFormSet
!= NULL
) {
1381 RemoveEntryList (&gOldFormSet
->Link
);
1382 DestroyFormSet (gOldFormSet
);
1384 gOldFormSet
= Selection
->FormSet
;
1385 InsertTailList (&gBrowserFormSetList
, &gOldFormSet
->Link
);
1389 // Initialize Selection->Form
1391 if (Selection
->FormId
== 0) {
1393 // Zero FormId indicates display the first Form in a FormSet
1395 Link
= GetFirstNode (&Selection
->FormSet
->FormListHead
);
1397 Selection
->Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
1398 Selection
->FormId
= Selection
->Form
->FormId
;
1400 Selection
->Form
= IdToForm (Selection
->FormSet
, Selection
->FormId
);
1403 if (Selection
->Form
== NULL
) {
1405 // No Form to display
1407 Status
= EFI_NOT_FOUND
;
1412 // Check Form is suppressed.
1414 if (Selection
->Form
->SuppressExpression
!= NULL
) {
1415 if (EvaluateExpressionList(Selection
->Form
->SuppressExpression
, TRUE
, Selection
->FormSet
, Selection
->Form
) == ExpressSuppress
) {
1417 // Form is suppressed.
1420 CreateDialog (4, TRUE
, 0, NULL
, &Key
, gEmptyString
, gFormSuppress
, gPressEnter
, gEmptyString
);
1421 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
1423 Status
= EFI_NOT_FOUND
;
1429 // Reset FormPackage update flag
1431 mHiiPackageListUpdated
= FALSE
;
1434 // Before display new form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN
1435 // for each question with callback flag.
1436 // New form may be the first form, or the different form after another form close.
1438 if ((ConfigAccess
!= NULL
) &&
1439 ((Selection
->Handle
!= mCurrentHiiHandle
) ||
1440 (!CompareGuid (&Selection
->FormSetGuid
, &mCurrentFormSetGuid
)) ||
1441 (Selection
->FormId
!= mCurrentFormId
))) {
1444 // Keep current form information
1446 mCurrentHiiHandle
= Selection
->Handle
;
1447 CopyGuid (&mCurrentFormSetGuid
, &Selection
->FormSetGuid
);
1448 mCurrentFormId
= Selection
->FormId
;
1450 Status
= ProcessCallBackFunction (Selection
, NULL
, EFI_BROWSER_ACTION_FORM_OPEN
, FALSE
);
1451 if (EFI_ERROR (Status
)) {
1456 // EXIT requests to close form.
1458 if (Selection
->Action
== UI_ACTION_EXIT
) {
1462 // IFR is updated during callback of open form, force to reparse the IFR binary
1464 if (mHiiPackageListUpdated
) {
1465 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1466 mHiiPackageListUpdated
= FALSE
;
1472 // Load Questions' Value for display
1474 Status
= LoadFormSetConfig (Selection
, Selection
->FormSet
);
1475 if (EFI_ERROR (Status
)) {
1480 // EXIT requests to close form.
1482 if (Selection
->Action
== UI_ACTION_EXIT
) {
1486 // IFR is updated during callback of read value, force to reparse the IFR binary
1488 if (mHiiPackageListUpdated
) {
1489 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1490 mHiiPackageListUpdated
= FALSE
;
1495 // Displays the Header and Footer borders
1497 DisplayPageFrame (Selection
);
1502 Status
= DisplayForm (Selection
);
1503 if (EFI_ERROR (Status
)) {
1508 // Check Selected Statement (if press ESC, Selection->Statement will be NULL)
1510 Statement
= Selection
->Statement
;
1511 if (Statement
!= NULL
) {
1512 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_RESET_REQUIRED
) == EFI_IFR_FLAG_RESET_REQUIRED
) {
1513 gResetRequired
= TRUE
;
1517 // Reset FormPackage update flag
1519 mHiiPackageListUpdated
= FALSE
;
1521 if ((ConfigAccess
!= NULL
) &&
1522 ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) &&
1523 (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
)) {
1524 Status
= ProcessCallBackFunction(Selection
, Statement
, EFI_BROWSER_ACTION_CHANGING
, FALSE
);
1525 if (Statement
->Operand
== EFI_IFR_REF_OP
&& Selection
->Action
!= UI_ACTION_EXIT
) {
1527 // Process dynamic update ref opcode.
1529 if (!EFI_ERROR (Status
)) {
1530 Status
= ProcessGotoOpCode(Statement
, Selection
, NULL
, NULL
);
1534 // Callback return error status or status return from process goto opcode.
1536 if (EFI_ERROR (Status
)) {
1538 // Cross reference will not be taken
1540 Selection
->FormId
= Selection
->Form
->FormId
;
1541 Selection
->QuestionId
= 0;
1545 if (!EFI_ERROR (Status
) && Statement
->Operand
!= EFI_IFR_REF_OP
) {
1546 ProcessCallBackFunction(Selection
, Statement
, EFI_BROWSER_ACTION_CHANGED
, FALSE
);
1551 // Check whether Form Package has been updated during Callback
1553 if (mHiiPackageListUpdated
&& (Selection
->Action
== UI_ACTION_REFRESH_FORM
)) {
1555 // Force to reparse IFR binary of target Formset
1557 mHiiPackageListUpdated
= FALSE
;
1558 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1563 // Before exit the form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE
1564 // for each question with callback flag.
1566 if ((ConfigAccess
!= NULL
) &&
1567 ((Selection
->Action
== UI_ACTION_EXIT
) ||
1568 (Selection
->Handle
!= mCurrentHiiHandle
) ||
1569 (!CompareGuid (&Selection
->FormSetGuid
, &mCurrentFormSetGuid
)) ||
1570 (Selection
->FormId
!= mCurrentFormId
))) {
1572 Status
= ProcessCallBackFunction (Selection
, NULL
, EFI_BROWSER_ACTION_FORM_CLOSE
, FALSE
);
1573 if (EFI_ERROR (Status
)) {
1577 } while (Selection
->Action
== UI_ACTION_REFRESH_FORM
);
1581 // Reset current form information to the initial setting when error happens or form exit.
1583 if (EFI_ERROR (Status
) || Selection
->Action
== UI_ACTION_EXIT
) {
1584 mCurrentHiiHandle
= NULL
;
1585 CopyGuid (&mCurrentFormSetGuid
, &gZeroGuid
);
1590 // Unregister notify for Form package update
1592 mHiiDatabase
->UnregisterPackageNotify (