2 Utility functions for UI presentation.
4 Copyright (c) 2004 - 2011, 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.
196 CHAR16
*StrFrontPageBanner
;
198 EFI_SCREEN_DESCRIPTOR LocalScreen
;
202 ZeroMem (&LocalScreen
, sizeof (EFI_SCREEN_DESCRIPTOR
));
203 gST
->ConOut
->QueryMode (gST
->ConOut
, gST
->ConOut
->Mode
->Mode
, &LocalScreen
.RightColumn
, &LocalScreen
.BottomRow
);
204 ClearLines (0, LocalScreen
.RightColumn
, 0, LocalScreen
.BottomRow
, KEYHELP_BACKGROUND
);
206 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
209 // For now, allocate an arbitrarily long buffer
211 Buffer
= AllocateZeroPool (0x10000);
212 ASSERT (Buffer
!= NULL
);
214 Character
= BOXDRAW_HORIZONTAL
;
216 for (Index
= 0; Index
+ 2 < (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
); Index
++) {
217 Buffer
[Index
] = Character
;
220 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) == FORMSET_CLASS_FRONT_PAGE
) {
222 // ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
225 LocalScreen
.LeftColumn
,
226 LocalScreen
.RightColumn
,
228 FRONT_PAGE_HEADER_HEIGHT
- 1 + LocalScreen
.TopRow
,
229 BANNER_TEXT
| BANNER_BACKGROUND
232 // for (Line = 0; Line < BANNER_HEIGHT; Line++) {
234 for (Line
= (UINT8
) LocalScreen
.TopRow
; Line
< BANNER_HEIGHT
+ (UINT8
) LocalScreen
.TopRow
; Line
++) {
236 // for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
238 for (Alignment
= (UINT8
) LocalScreen
.LeftColumn
;
239 Alignment
< BANNER_COLUMNS
+ (UINT8
) LocalScreen
.LeftColumn
;
242 RowIdx
= (UINT8
) (Line
- (UINT8
) LocalScreen
.TopRow
);
243 ColumnIdx
= (UINT8
) (Alignment
- (UINT8
) LocalScreen
.LeftColumn
);
245 ASSERT (RowIdx
< BANNER_HEIGHT
);
246 ASSERT (ColumnIdx
< BANNER_COLUMNS
);
248 if (gBannerData
->Banner
[RowIdx
][ColumnIdx
] != 0x0000) {
249 StrFrontPageBanner
= GetToken (
250 gBannerData
->Banner
[RowIdx
][ColumnIdx
],
257 switch (Alignment
- LocalScreen
.LeftColumn
) {
260 // Handle left column
262 PrintStringAt (LocalScreen
.LeftColumn
+ BANNER_LEFT_COLUMN_INDENT
, Line
, StrFrontPageBanner
);
267 // Handle center column
270 LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3,
278 // Handle right column
281 LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3,
288 FreePool (StrFrontPageBanner
);
294 LocalScreen
.LeftColumn
,
295 LocalScreen
.RightColumn
,
296 LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
,
297 LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 1,
298 KEYHELP_TEXT
| KEYHELP_BACKGROUND
301 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) != FORMSET_CLASS_FRONT_PAGE
) {
303 LocalScreen
.LeftColumn
,
304 LocalScreen
.RightColumn
,
306 LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1,
307 TITLE_TEXT
| TITLE_BACKGROUND
310 // Print Top border line
311 // +------------------------------------------------------------------------------+
313 // +------------------------------------------------------------------------------+
315 Character
= BOXDRAW_DOWN_RIGHT
;
317 PrintChar (Character
);
318 PrintString (Buffer
);
320 Character
= BOXDRAW_DOWN_LEFT
;
321 PrintChar (Character
);
323 Character
= BOXDRAW_VERTICAL
;
324 for (Row
= LocalScreen
.TopRow
+ 1; Row
<= LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 2; Row
++) {
325 PrintCharAt (LocalScreen
.LeftColumn
, Row
, Character
);
326 PrintCharAt (LocalScreen
.RightColumn
- 1, Row
, Character
);
329 Character
= BOXDRAW_UP_RIGHT
;
330 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1, Character
);
331 PrintString (Buffer
);
333 Character
= BOXDRAW_UP_LEFT
;
334 PrintChar (Character
);
336 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
338 // Print Bottom border line
339 // +------------------------------------------------------------------------------+
341 // +------------------------------------------------------------------------------+
343 Character
= BOXDRAW_DOWN_RIGHT
;
344 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
, Character
);
346 PrintString (Buffer
);
348 Character
= BOXDRAW_DOWN_LEFT
;
349 PrintChar (Character
);
350 Character
= BOXDRAW_VERTICAL
;
351 for (Row
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
+ 1;
352 Row
<= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 2;
355 PrintCharAt (LocalScreen
.LeftColumn
, Row
, Character
);
356 PrintCharAt (LocalScreen
.RightColumn
- 1, Row
, Character
);
359 Character
= BOXDRAW_UP_RIGHT
;
360 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 1, Character
);
362 PrintString (Buffer
);
364 Character
= BOXDRAW_UP_LEFT
;
365 PrintChar (Character
);
375 Evaluate all expressions in a Form.
377 @param FormSet FormSet this Form belongs to.
378 @param Form The Form.
380 @retval EFI_SUCCESS The expression evaluated successfuly
384 EvaluateFormExpressions (
385 IN FORM_BROWSER_FORMSET
*FormSet
,
386 IN FORM_BROWSER_FORM
*Form
391 FORM_EXPRESSION
*Expression
;
393 Link
= GetFirstNode (&Form
->ExpressionListHead
);
394 while (!IsNull (&Form
->ExpressionListHead
, Link
)) {
395 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
396 Link
= GetNextNode (&Form
->ExpressionListHead
, Link
);
398 if (Expression
->Type
== EFI_HII_EXPRESSION_INCONSISTENT_IF
||
399 Expression
->Type
== EFI_HII_EXPRESSION_NO_SUBMIT_IF
||
400 Expression
->Type
== EFI_HII_EXPRESSION_WRITE
||
401 (Expression
->Type
== EFI_HII_EXPRESSION_READ
&& Form
->FormType
!= STANDARD_MAP_FORM_TYPE
)) {
403 // Postpone Form validation to Question editing or Form submitting or Question Write or Question Read for nonstandard form.
408 Status
= EvaluateExpression (FormSet
, Form
, Expression
);
409 if (EFI_ERROR (Status
)) {
418 +------------------------------------------------------------------------------+
420 +------------------------------------------------------------------------------+
438 +------------------------------------------------------------------------------+
439 ?F1=Scroll Help F9=Reset to Defaults F10=Save and Exit ?
440 | ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Discard Changes |
441 +------------------------------------------------------------------------------+
447 Display form and wait for user to select one menu option, then return it.
449 @param Selection On input, Selection tell setup browser the information
450 about the Selection, form and formset to be displayed.
451 On output, Selection return the screen item that is selected
453 @retval EFI_SUCESSS This function always return successfully for now.
458 IN OUT UI_MENU_SELECTION
*Selection
462 UINT16 MenuItemCount
;
463 EFI_HII_HANDLE Handle
;
465 EFI_SCREEN_DESCRIPTOR LocalScreen
;
468 CHAR16
*OutputString
;
470 FORM_BROWSER_STATEMENT
*Statement
;
471 UINT16 NumberOfLines
;
473 UI_MENU_OPTION
*MenuOption
;
475 Handle
= Selection
->Handle
;
482 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
484 StringPtr
= GetToken (Selection
->Form
->FormTitle
, Handle
);
486 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) != FORMSET_CLASS_FRONT_PAGE
) {
487 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| TITLE_BACKGROUND
);
489 (LocalScreen
.RightColumn
+ LocalScreen
.LeftColumn
- GetStringWidth (StringPtr
) / 2) / 2,
490 LocalScreen
.TopRow
+ 1,
496 // Remove Buffer allocated for StringPtr after it has been used.
498 FreePool (StringPtr
);
501 // Evaluate all the Expressions in this Form
503 Status
= EvaluateFormExpressions (Selection
->FormSet
, Selection
->Form
);
504 if (EFI_ERROR (Status
)) {
508 Selection
->FormEditable
= FALSE
;
509 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
510 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
511 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
513 if (Statement
->SuppressExpression
!= NULL
) {
514 Suppress
= Statement
->SuppressExpression
->Result
.Value
.b
;
519 if (Statement
->DisableExpression
!= NULL
) {
520 Suppress
= (BOOLEAN
) (Suppress
|| Statement
->DisableExpression
->Result
.Value
.b
);
524 StringPtr
= GetToken (Statement
->Prompt
, Handle
);
526 Width
= GetWidth (Statement
, Handle
);
530 for (; GetLineByWidth (StringPtr
, Width
, &ArrayEntry
, &OutputString
) != 0x0000;) {
532 // If there is more string to process print on the next row and increment the Skip value
534 if (StrLen (&StringPtr
[ArrayEntry
]) != 0) {
538 FreePool (OutputString
);
542 // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do
545 MenuOption
= UiAddMenuOption (StringPtr
, Selection
->Handle
, Statement
, NumberOfLines
, MenuItemCount
);
548 if (MenuOption
->IsQuestion
&& !MenuOption
->ReadOnly
) {
550 // At least one item is not readonly, this Form is considered as editable
552 Selection
->FormEditable
= TRUE
;
556 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
559 Status
= UiDisplayMenu (Selection
);
567 Initialize the HII String Token to the correct values.
571 InitializeBrowserStrings (
575 gFunctionNineString
= GetToken (STRING_TOKEN (FUNCTION_NINE_STRING
), gHiiHandle
);
576 gFunctionTenString
= GetToken (STRING_TOKEN (FUNCTION_TEN_STRING
), gHiiHandle
);
577 gEnterString
= GetToken (STRING_TOKEN (ENTER_STRING
), gHiiHandle
);
578 gEnterCommitString
= GetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), gHiiHandle
);
579 gEnterEscapeString
= GetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), gHiiHandle
);
580 gEscapeString
= GetToken (STRING_TOKEN (ESCAPE_STRING
), gHiiHandle
);
581 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), 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 (gFunctionNineString
);
619 FreePool (gFunctionTenString
);
620 FreePool (gEnterString
);
621 FreePool (gEnterCommitString
);
622 FreePool (gEnterEscapeString
);
623 FreePool (gEscapeString
);
624 FreePool (gMoveHighlight
);
625 FreePool (gMakeSelection
);
626 FreePool (gDecNumericInput
);
627 FreePool (gHexNumericInput
);
628 FreePool (gToggleCheckBox
);
629 FreePool (gPromptForData
);
630 FreePool (gPromptForPassword
);
631 FreePool (gPromptForNewPassword
);
632 FreePool (gConfirmPassword
);
633 FreePool (gPassowordInvalid
);
634 FreePool (gConfirmError
);
635 FreePool (gPressEnter
);
636 FreePool (gEmptyString
);
637 FreePool (gAreYouSure
);
638 FreePool (gYesResponse
);
639 FreePool (gNoResponse
);
640 FreePool (gMiniString
);
641 FreePool (gPlusString
);
642 FreePool (gMinusString
);
643 FreePool (gAdjustNumber
);
644 FreePool (gSaveChanges
);
645 FreePool (gOptionMismatch
);
646 FreePool (gFormSuppress
);
652 Update key's help imformation.
654 @param Selection Tell setup browser the information about the Selection
655 @param MenuOption The Menu option
656 @param Selected Whether or not a tag be selected
661 IN UI_MENU_SELECTION
*Selection
,
662 IN UI_MENU_OPTION
*MenuOption
,
668 UINTN LeftColumnOfHelp
;
669 UINTN RightColumnOfHelp
;
671 UINTN BottomRowOfHelp
;
672 UINTN StartColumnOfHelp
;
673 EFI_SCREEN_DESCRIPTOR LocalScreen
;
674 FORM_BROWSER_STATEMENT
*Statement
;
676 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
678 SecCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
679 ThdCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3;
681 StartColumnOfHelp
= LocalScreen
.LeftColumn
+ 2;
682 LeftColumnOfHelp
= LocalScreen
.LeftColumn
+ 1;
683 RightColumnOfHelp
= LocalScreen
.RightColumn
- 2;
684 TopRowOfHelp
= LocalScreen
.BottomRow
- 4;
685 BottomRowOfHelp
= LocalScreen
.BottomRow
- 3;
687 gST
->ConOut
->SetAttribute (gST
->ConOut
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
689 Statement
= MenuOption
->ThisTag
;
690 switch (Statement
->Operand
) {
691 case EFI_IFR_ORDERED_LIST_OP
:
692 case EFI_IFR_ONE_OF_OP
:
693 case EFI_IFR_NUMERIC_OP
:
694 case EFI_IFR_TIME_OP
:
695 case EFI_IFR_DATE_OP
:
696 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
699 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
700 if (Selection
->FormEditable
) {
701 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
702 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
704 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
707 if ((Statement
->Operand
== EFI_IFR_DATE_OP
) ||
708 (Statement
->Operand
== EFI_IFR_TIME_OP
)) {
719 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
720 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gAdjustNumber
);
722 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
723 if (Statement
->Operand
== EFI_IFR_NUMERIC_OP
&& Statement
->Step
!= 0) {
724 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gAdjustNumber
);
726 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
729 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterCommitString
);
732 // If it is a selected numeric with manual input, display different message
734 if ((Statement
->Operand
== EFI_IFR_NUMERIC_OP
) ||
735 (Statement
->Operand
== EFI_IFR_DATE_OP
) ||
736 (Statement
->Operand
== EFI_IFR_TIME_OP
)) {
740 ((Statement
->Flags
& EFI_IFR_DISPLAY_UINT_HEX
) == EFI_IFR_DISPLAY_UINT_HEX
) ? gHexNumericInput
: gDecNumericInput
742 } else if (Statement
->Operand
!= EFI_IFR_ORDERED_LIST_OP
) {
743 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
746 if (Statement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) {
747 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gPlusString
);
748 PrintStringAt (ThdCol
, TopRowOfHelp
, gMinusString
);
751 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
755 case EFI_IFR_CHECKBOX_OP
:
756 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
758 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
759 if (Selection
->FormEditable
) {
760 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
761 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
763 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
766 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
767 PrintStringAt (SecCol
, BottomRowOfHelp
, gToggleCheckBox
);
771 case EFI_IFR_PASSWORD_OP
:
772 case EFI_IFR_STRING_OP
:
773 case EFI_IFR_TEXT_OP
:
774 case EFI_IFR_ACTION_OP
:
775 case EFI_IFR_RESET_BUTTON_OP
:
776 case EFI_IFR_SUBTITLE_OP
:
777 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
780 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
781 if (Selection
->FormEditable
) {
782 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
783 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
785 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
788 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
789 if (Statement
->Operand
!= EFI_IFR_TEXT_OP
&& Statement
->Operand
!= EFI_IFR_SUBTITLE_OP
) {
790 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
793 if (Statement
->Operand
!= EFI_IFR_REF_OP
) {
795 (LocalScreen
.RightColumn
- GetStringWidth (gEnterCommitString
) / 2) / 2,
799 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
810 Functions which are registered to receive notification of
811 database events have this prototype. The actual event is encoded
812 in NotifyType. The following table describes how PackageType,
813 PackageGuid, Handle, and Package are used for each of the
816 @param PackageType Package type of the notification.
818 @param PackageGuid If PackageType is
819 EFI_HII_PACKAGE_TYPE_GUID, then this is
820 the pointer to the GUID from the Guid
821 field of EFI_HII_PACKAGE_GUID_HEADER.
822 Otherwise, it must be NULL.
824 @param Package Points to the package referred to by the
825 notification Handle The handle of the package
826 list which contains the specified package.
828 @param Handle The HII handle.
830 @param NotifyType The type of change concerning the
832 EFI_HII_DATABASE_NOTIFY_TYPE.
838 IN UINT8 PackageType
,
839 IN CONST EFI_GUID
*PackageGuid
,
840 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
841 IN EFI_HII_HANDLE Handle
,
842 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
845 mHiiPackageListUpdated
= TRUE
;
851 The worker function that send the displays to the screen. On output,
852 the selection made by user is returned.
854 @param Selection On input, Selection tell setup browser the information
855 about the Selection, form and formset to be displayed.
856 On output, Selection return the screen item that is selected
859 @retval EFI_SUCCESS The page is displayed successfully.
860 @return Other value if the page failed to be diplayed.
865 IN OUT UI_MENU_SELECTION
*Selection
870 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
871 EFI_HANDLE NotifyHandle
;
872 EFI_HII_VALUE
*HiiValue
;
873 EFI_IFR_TYPE_VALUE
*TypeValue
;
874 FORM_BROWSER_STATEMENT
*Statement
;
875 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
876 FORM_BROWSER_FORMSET
*FormSet
;
878 BOOLEAN SubmitFormIsRequired
;
880 gMenuRefreshHead
= NULL
;
881 gResetRequired
= FALSE
;
882 FormSet
= Selection
->FormSet
;
883 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
886 // Register notify for Form package update
888 Status
= mHiiDatabase
->RegisterPackageNotify (
890 EFI_HII_PACKAGE_FORMS
,
893 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
896 if (EFI_ERROR (Status
)) {
901 // Initialize current settings of Questions in this FormSet
903 Status
= InitializeCurrentSetting (Selection
->FormSet
);
904 if (EFI_ERROR (Status
)) {
910 // Initialize Selection->Form
912 if (Selection
->FormId
== 0) {
914 // Zero FormId indicates display the first Form in a FormSet
916 Link
= GetFirstNode (&Selection
->FormSet
->FormListHead
);
918 Selection
->Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
919 Selection
->FormId
= Selection
->Form
->FormId
;
921 Selection
->Form
= IdToForm (Selection
->FormSet
, Selection
->FormId
);
924 if (Selection
->Form
== NULL
) {
926 // No Form to display
928 Status
= EFI_NOT_FOUND
;
933 // Check Form is suppressed.
935 if (Selection
->Form
->SuppressExpression
!= NULL
) {
936 Status
= EvaluateExpression (Selection
->FormSet
, Selection
->Form
, Selection
->Form
->SuppressExpression
);
937 if (EFI_ERROR (Status
) || (Selection
->Form
->SuppressExpression
->Result
.Type
!= EFI_IFR_TYPE_BOOLEAN
)) {
938 Status
= EFI_INVALID_PARAMETER
;
942 if (Selection
->Form
->SuppressExpression
->Result
.Value
.b
) {
944 // Form is suppressed.
947 CreateDialog (4, TRUE
, 0, NULL
, &Key
, gEmptyString
, gFormSuppress
, gPressEnter
, gEmptyString
);
948 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
950 Status
= EFI_NOT_FOUND
;
956 // Reset FormPackage update flag
958 mHiiPackageListUpdated
= FALSE
;
961 // Before display new form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN
962 // for each question with callback flag.
963 // New form may be the first form, or the different form after another form close.
965 if ((ConfigAccess
!= NULL
) &&
966 ((Selection
->Handle
!= mCurrentHiiHandle
) ||
967 (!CompareGuid (&Selection
->FormSetGuid
, &mCurrentFormSetGuid
)) ||
968 (Selection
->FormId
!= mCurrentFormId
))) {
971 // Keep current form information
973 mCurrentHiiHandle
= Selection
->Handle
;
974 CopyGuid (&mCurrentFormSetGuid
, &Selection
->FormSetGuid
);
975 mCurrentFormId
= Selection
->FormId
;
978 // Go through each statement in this form
980 SubmitFormIsRequired
= FALSE
;
981 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
982 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
983 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
984 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
986 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) {
991 // Check whether Statement is disabled.
993 if (Statement
->DisableExpression
!= NULL
) {
994 Status
= EvaluateExpression (Selection
->FormSet
, Selection
->Form
, Statement
->DisableExpression
);
995 if (!EFI_ERROR (Status
) &&
996 (Statement
->DisableExpression
->Result
.Type
== EFI_IFR_TYPE_BOOLEAN
) &&
997 (Statement
->DisableExpression
->Result
.Value
.b
)) {
1002 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1003 Status
= ConfigAccess
->Callback (
1005 EFI_BROWSER_ACTION_FORM_OPEN
,
1006 Statement
->QuestionId
,
1007 EFI_IFR_TYPE_UNDEFINED
,
1012 if (!EFI_ERROR (Status
)) {
1013 switch (ActionRequest
) {
1014 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1015 gResetRequired
= TRUE
;
1018 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1019 SubmitFormIsRequired
= TRUE
;
1022 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1023 Selection
->Action
= UI_ACTION_EXIT
;
1024 gNvUpdateRequired
= FALSE
;
1032 if (SubmitFormIsRequired
) {
1033 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1036 // EXIT requests to close form.
1038 if (Selection
->Action
== UI_ACTION_EXIT
) {
1042 // IFR is updated during callback of open form, force to reparse the IFR binary
1044 if (mHiiPackageListUpdated
) {
1045 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1046 mHiiPackageListUpdated
= FALSE
;
1052 // Load Questions' Value for display
1054 Status
= LoadFormSetConfig (Selection
, Selection
->FormSet
);
1055 if (EFI_ERROR (Status
)) {
1060 // EXIT requests to close form.
1062 if (Selection
->Action
== UI_ACTION_EXIT
) {
1066 // IFR is updated during callback of read value, force to reparse the IFR binary
1068 if (mHiiPackageListUpdated
) {
1069 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1070 mHiiPackageListUpdated
= FALSE
;
1075 // Displays the Header and Footer borders
1077 DisplayPageFrame ();
1082 Status
= DisplayForm (Selection
);
1083 if (EFI_ERROR (Status
)) {
1088 // Check Selected Statement (if press ESC, Selection->Statement will be NULL)
1090 Statement
= Selection
->Statement
;
1091 if (Statement
!= NULL
) {
1092 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_RESET_REQUIRED
) == EFI_IFR_FLAG_RESET_REQUIRED
) {
1093 gResetRequired
= TRUE
;
1097 // Reset FormPackage update flag
1099 mHiiPackageListUpdated
= FALSE
;
1101 if ((ConfigAccess
!= NULL
) &&
1102 ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) &&
1103 (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
)) {
1105 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1107 HiiValue
= &Statement
->HiiValue
;
1108 TypeValue
= &HiiValue
->Value
;
1109 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
1111 // For OrderedList, passing in the value buffer to Callback()
1113 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Statement
->BufferValue
;
1116 Status
= ConfigAccess
->Callback (
1118 EFI_BROWSER_ACTION_CHANGING
,
1119 Statement
->QuestionId
,
1125 if (!EFI_ERROR (Status
)) {
1126 switch (ActionRequest
) {
1127 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1128 gResetRequired
= TRUE
;
1131 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1132 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1135 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1136 Selection
->Action
= UI_ACTION_EXIT
;
1137 gNvUpdateRequired
= FALSE
;
1143 } else if (Status
!= EFI_UNSUPPORTED
) {
1145 // Callback return error status other than EFI_UNSUPPORTED
1147 if (Statement
->Operand
== EFI_IFR_REF_OP
) {
1149 // Cross reference will not be taken
1151 Selection
->FormId
= Selection
->Form
->FormId
;
1152 Selection
->QuestionId
= 0;
1158 // Check whether Form Package has been updated during Callback
1160 if (mHiiPackageListUpdated
&& (Selection
->Action
== UI_ACTION_REFRESH_FORM
)) {
1162 // Force to reparse IFR binary of target Formset
1164 mHiiPackageListUpdated
= FALSE
;
1165 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1170 // Before exit the form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE
1171 // for each question with callback flag.
1173 if ((ConfigAccess
!= NULL
) &&
1174 ((Selection
->Action
== UI_ACTION_EXIT
) ||
1175 (Selection
->Handle
!= mCurrentHiiHandle
) ||
1176 (!CompareGuid (&Selection
->FormSetGuid
, &mCurrentFormSetGuid
)) ||
1177 (Selection
->FormId
!= mCurrentFormId
))) {
1179 // Go through each statement in this form
1181 SubmitFormIsRequired
= FALSE
;
1182 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
1183 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
1184 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
1185 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
1187 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) {
1191 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1192 Status
= ConfigAccess
->Callback (
1194 EFI_BROWSER_ACTION_FORM_CLOSE
,
1195 Statement
->QuestionId
,
1196 EFI_IFR_TYPE_UNDEFINED
,
1201 if (!EFI_ERROR (Status
)) {
1202 switch (ActionRequest
) {
1203 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1204 gResetRequired
= TRUE
;
1207 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1208 SubmitFormIsRequired
= TRUE
;
1211 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1212 Selection
->Action
= UI_ACTION_EXIT
;
1213 gNvUpdateRequired
= FALSE
;
1221 if (SubmitFormIsRequired
) {
1222 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1225 } while (Selection
->Action
== UI_ACTION_REFRESH_FORM
);
1228 // Record the old formset
1230 if (gOldFormSet
!= NULL
) {
1231 DestroyFormSet (gOldFormSet
);
1233 gOldFormSet
= FormSet
;
1237 // Reset current form information to the initial setting when error happens or form exit.
1239 if (EFI_ERROR (Status
) || Selection
->Action
== UI_ACTION_EXIT
) {
1240 mCurrentHiiHandle
= NULL
;
1241 CopyGuid (&mCurrentFormSetGuid
, &gZeroGuid
);
1246 // Unregister notify for Form package update
1248 mHiiDatabase
->UnregisterPackageNotify (