2 Utility functions for UI presentation.
4 Copyright (c) 2004 - 2009, Intel Corporation
5 All rights reserved. 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.
18 BOOLEAN mHiiPackageListUpdated
;
19 UI_MENU_SELECTION
*gCurrentSelection
;
23 Clear retangle with specified text attribute.
25 @param LeftColumn Left column of retangle.
26 @param RightColumn Right column of retangle.
27 @param TopRow Start row of retangle.
28 @param BottomRow End row of retangle.
29 @param TextAttribute The character foreground and background.
38 IN UINTN TextAttribute
45 // For now, allocate an arbitrarily long buffer
47 Buffer
= AllocateZeroPool (0x10000);
48 ASSERT (Buffer
!= NULL
);
51 // Set foreground and background as defined
53 gST
->ConOut
->SetAttribute (gST
->ConOut
, TextAttribute
);
56 // Much faster to buffer the long string instead of print it a character at a time
58 SetUnicodeMem (Buffer
, RightColumn
- LeftColumn
, L
' ');
61 // Clear the desired area with the appropriate foreground/background
63 for (Row
= TopRow
; Row
<= BottomRow
; Row
++) {
64 PrintStringAt (LeftColumn
, Row
, Buffer
);
67 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, LeftColumn
, TopRow
);
74 Concatenate a narrow string to another string.
76 @param Destination The destination string.
77 @param Source The source string. The string to be concatenated.
78 to the end of Destination.
83 IN OUT CHAR16
*Destination
,
89 for (Length
= 0; Destination
[Length
] != 0; Length
++)
93 // We now have the length of the original string
94 // We can safely assume for now that we are concatenating a narrow value to this string.
95 // For instance, the string is "XYZ" and cat'ing ">"
96 // If this assumption changes, we need to make this routine a bit more complex
98 Destination
[Length
] = NARROW_CHAR
;
101 StrCpy (Destination
+ Length
, Source
);
105 Count the storage space of a Unicode string.
107 This function handles the Unicode string with NARROW_CHAR
108 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
109 does not count in the resultant output. If a WIDE_CHAR is
110 hit, then 2 Unicode character will consume an output storage
111 space with size of CHAR16 till a NARROW_CHAR is hit.
113 @param String The input string to be counted.
115 @return Storage space for the input string.
125 UINTN IncrementValue
;
133 // Advance to the null-terminator or to the first width directive
136 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
137 Index
++, Count
= Count
+ IncrementValue
142 // We hit the null-terminator, we now have a count
144 if (String
[Index
] == 0) {
148 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
149 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
151 if (String
[Index
] == NARROW_CHAR
) {
153 // Skip to the next character
159 // Skip to the next character
164 } while (String
[Index
] != 0);
167 // Increment by one to include the null-terminator in the size
171 return Count
* sizeof (CHAR16
);
175 This function displays the page frame.
188 CHAR16
*StrFrontPageBanner
;
190 EFI_SCREEN_DESCRIPTOR LocalScreen
;
194 ZeroMem (&LocalScreen
, sizeof (EFI_SCREEN_DESCRIPTOR
));
195 gST
->ConOut
->QueryMode (gST
->ConOut
, gST
->ConOut
->Mode
->Mode
, &LocalScreen
.RightColumn
, &LocalScreen
.BottomRow
);
196 ClearLines (0, LocalScreen
.RightColumn
, 0, LocalScreen
.BottomRow
, KEYHELP_BACKGROUND
);
198 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
201 // For now, allocate an arbitrarily long buffer
203 Buffer
= AllocateZeroPool (0x10000);
204 ASSERT (Buffer
!= NULL
);
206 Character
= BOXDRAW_HORIZONTAL
;
208 for (Index
= 0; Index
+ 2 < (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
); Index
++) {
209 Buffer
[Index
] = Character
;
212 if (gClassOfVfr
== FORMSET_CLASS_FRONT_PAGE
) {
214 // ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
217 LocalScreen
.LeftColumn
,
218 LocalScreen
.RightColumn
,
220 FRONT_PAGE_HEADER_HEIGHT
- 1 + LocalScreen
.TopRow
,
221 BANNER_TEXT
| BANNER_BACKGROUND
224 // for (Line = 0; Line < BANNER_HEIGHT; Line++) {
226 for (Line
= (UINT8
) LocalScreen
.TopRow
; Line
< BANNER_HEIGHT
+ (UINT8
) LocalScreen
.TopRow
; Line
++) {
228 // for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
230 for (Alignment
= (UINT8
) LocalScreen
.LeftColumn
;
231 Alignment
< BANNER_COLUMNS
+ (UINT8
) LocalScreen
.LeftColumn
;
234 RowIdx
= (UINT8
) (Line
- (UINT8
) LocalScreen
.TopRow
);
235 ColumnIdx
= (UINT8
) (Alignment
- (UINT8
) LocalScreen
.LeftColumn
);
237 ASSERT (RowIdx
< BANNER_HEIGHT
);
238 ASSERT (ColumnIdx
< BANNER_COLUMNS
);
240 if (gBannerData
->Banner
[RowIdx
][ColumnIdx
] != 0x0000) {
241 StrFrontPageBanner
= GetToken (
242 gBannerData
->Banner
[RowIdx
][ColumnIdx
],
249 switch (Alignment
- LocalScreen
.LeftColumn
) {
252 // Handle left column
254 PrintStringAt (LocalScreen
.LeftColumn
, Line
, StrFrontPageBanner
);
259 // Handle center column
262 LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3,
270 // Handle right column
273 LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3,
280 FreePool (StrFrontPageBanner
);
286 LocalScreen
.LeftColumn
,
287 LocalScreen
.RightColumn
,
288 LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
,
289 LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 1,
290 KEYHELP_TEXT
| KEYHELP_BACKGROUND
293 if (gClassOfVfr
!= FORMSET_CLASS_FRONT_PAGE
) {
295 LocalScreen
.LeftColumn
,
296 LocalScreen
.RightColumn
,
298 LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1,
299 TITLE_TEXT
| TITLE_BACKGROUND
302 // Print Top border line
303 // +------------------------------------------------------------------------------+
305 // +------------------------------------------------------------------------------+
307 Character
= BOXDRAW_DOWN_RIGHT
;
309 PrintChar (Character
);
310 PrintString (Buffer
);
312 Character
= BOXDRAW_DOWN_LEFT
;
313 PrintChar (Character
);
315 Character
= BOXDRAW_VERTICAL
;
316 for (Row
= LocalScreen
.TopRow
+ 1; Row
<= LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 2; Row
++) {
317 PrintCharAt (LocalScreen
.LeftColumn
, Row
, Character
);
318 PrintCharAt (LocalScreen
.RightColumn
- 1, Row
, Character
);
321 Character
= BOXDRAW_UP_RIGHT
;
322 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1, Character
);
323 PrintString (Buffer
);
325 Character
= BOXDRAW_UP_LEFT
;
326 PrintChar (Character
);
328 if (gClassOfVfr
== FORMSET_CLASS_PLATFORM_SETUP
) {
330 // Print Bottom border line
331 // +------------------------------------------------------------------------------+
333 // +------------------------------------------------------------------------------+
335 Character
= BOXDRAW_DOWN_RIGHT
;
336 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
, Character
);
338 PrintString (Buffer
);
340 Character
= BOXDRAW_DOWN_LEFT
;
341 PrintChar (Character
);
342 Character
= BOXDRAW_VERTICAL
;
343 for (Row
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
+ 1;
344 Row
<= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 2;
347 PrintCharAt (LocalScreen
.LeftColumn
, Row
, Character
);
348 PrintCharAt (LocalScreen
.RightColumn
- 1, Row
, Character
);
351 Character
= BOXDRAW_UP_RIGHT
;
352 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 1, Character
);
354 PrintString (Buffer
);
356 Character
= BOXDRAW_UP_LEFT
;
357 PrintChar (Character
);
367 Evaluate all expressions in a Form.
369 @param FormSet FormSet this Form belongs to.
370 @param Form The Form.
372 @retval EFI_SUCCESS The expression evaluated successfuly
376 EvaluateFormExpressions (
377 IN FORM_BROWSER_FORMSET
*FormSet
,
378 IN FORM_BROWSER_FORM
*Form
383 FORM_EXPRESSION
*Expression
;
385 Link
= GetFirstNode (&Form
->ExpressionListHead
);
386 while (!IsNull (&Form
->ExpressionListHead
, Link
)) {
387 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
388 Link
= GetNextNode (&Form
->ExpressionListHead
, Link
);
390 if (Expression
->Type
== EFI_HII_EXPRESSION_INCONSISTENT_IF
||
391 Expression
->Type
== EFI_HII_EXPRESSION_NO_SUBMIT_IF
) {
393 // Postpone Form validation to Question editing or Form submiting
398 Status
= EvaluateExpression (FormSet
, Form
, Expression
);
399 if (EFI_ERROR (Status
)) {
408 +------------------------------------------------------------------------------+
410 +------------------------------------------------------------------------------+
428 +------------------------------------------------------------------------------+
429 ?F1=Scroll Help F9=Reset to Defaults F10=Save and Exit ?
430 | ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Discard Changes |
431 +------------------------------------------------------------------------------+
437 Display form and wait for user to select one menu option, then return it.
439 @param Selection On input, Selection tell setup browser the information
440 about the Selection, form and formset to be displayed.
441 On output, Selection return the screen item that is selected
443 @retval EFI_SUCESSS This function always return successfully for now.
448 IN OUT UI_MENU_SELECTION
*Selection
452 UINT16 MenuItemCount
;
453 EFI_HII_HANDLE Handle
;
455 EFI_SCREEN_DESCRIPTOR LocalScreen
;
458 CHAR16
*OutputString
;
460 FORM_BROWSER_STATEMENT
*Statement
;
461 UINT16 NumberOfLines
;
463 UI_MENU_OPTION
*MenuOption
;
465 Handle
= Selection
->Handle
;
472 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
474 StringPtr
= GetToken (Selection
->Form
->FormTitle
, Handle
);
476 if (gClassOfVfr
!= FORMSET_CLASS_FRONT_PAGE
) {
477 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| TITLE_BACKGROUND
);
479 (LocalScreen
.RightColumn
+ LocalScreen
.LeftColumn
- GetStringWidth (StringPtr
) / 2) / 2,
480 LocalScreen
.TopRow
+ 1,
486 // Remove Buffer allocated for StringPtr after it has been used.
488 FreePool (StringPtr
);
491 // Evaluate all the Expressions in this Form
493 Status
= EvaluateFormExpressions (Selection
->FormSet
, Selection
->Form
);
494 if (EFI_ERROR (Status
)) {
498 Selection
->FormEditable
= FALSE
;
499 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
500 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
501 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
503 if (Statement
->SuppressExpression
!= NULL
) {
504 Suppress
= Statement
->SuppressExpression
->Result
.Value
.b
;
509 if (Statement
->DisableExpression
!= NULL
) {
510 Suppress
= (BOOLEAN
) (Suppress
|| Statement
->DisableExpression
->Result
.Value
.b
);
514 StringPtr
= GetToken (Statement
->Prompt
, Handle
);
516 Width
= GetWidth (Statement
, Handle
);
520 for (; GetLineByWidth (StringPtr
, Width
, &ArrayEntry
, &OutputString
) != 0x0000;) {
522 // If there is more string to process print on the next row and increment the Skip value
524 if (StrLen (&StringPtr
[ArrayEntry
]) != 0) {
528 FreePool (OutputString
);
532 // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do
535 MenuOption
= UiAddMenuOption (StringPtr
, Selection
->Handle
, Statement
, NumberOfLines
, MenuItemCount
);
538 if (MenuOption
->IsQuestion
&& !MenuOption
->ReadOnly
) {
540 // At least one item is not readonly, this Form is considered as editable
542 Selection
->FormEditable
= TRUE
;
546 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
549 Status
= UiDisplayMenu (Selection
);
557 Initialize the HII String Token to the correct values.
561 InitializeBrowserStrings (
565 gFunctionNineString
= GetToken (STRING_TOKEN (FUNCTION_NINE_STRING
), gHiiHandle
);
566 gFunctionTenString
= GetToken (STRING_TOKEN (FUNCTION_TEN_STRING
), gHiiHandle
);
567 gEnterString
= GetToken (STRING_TOKEN (ENTER_STRING
), gHiiHandle
);
568 gEnterCommitString
= GetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), gHiiHandle
);
569 gEnterEscapeString
= GetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), gHiiHandle
);
570 gEscapeString
= GetToken (STRING_TOKEN (ESCAPE_STRING
), gHiiHandle
);
571 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
572 gMoveHighlight
= GetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), gHiiHandle
);
573 gMakeSelection
= GetToken (STRING_TOKEN (MAKE_SELECTION
), gHiiHandle
);
574 gDecNumericInput
= GetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), gHiiHandle
);
575 gHexNumericInput
= GetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), gHiiHandle
);
576 gToggleCheckBox
= GetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), gHiiHandle
);
577 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
578 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
579 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
580 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
581 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
582 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
583 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
584 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
585 gAreYouSure
= GetToken (STRING_TOKEN (ARE_YOU_SURE
), gHiiHandle
);
586 gYesResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), gHiiHandle
);
587 gNoResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), gHiiHandle
);
588 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
589 gPlusString
= GetToken (STRING_TOKEN (PLUS_STRING
), gHiiHandle
);
590 gMinusString
= GetToken (STRING_TOKEN (MINUS_STRING
), gHiiHandle
);
591 gAdjustNumber
= GetToken (STRING_TOKEN (ADJUST_NUMBER
), gHiiHandle
);
592 gSaveChanges
= GetToken (STRING_TOKEN (SAVE_CHANGES
), gHiiHandle
);
593 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
594 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
599 Free up the resource allocated for all strings required
608 FreePool (gFunctionNineString
);
609 FreePool (gFunctionTenString
);
610 FreePool (gEnterString
);
611 FreePool (gEnterCommitString
);
612 FreePool (gEnterEscapeString
);
613 FreePool (gEscapeString
);
614 FreePool (gMoveHighlight
);
615 FreePool (gMakeSelection
);
616 FreePool (gDecNumericInput
);
617 FreePool (gHexNumericInput
);
618 FreePool (gToggleCheckBox
);
619 FreePool (gPromptForData
);
620 FreePool (gPromptForPassword
);
621 FreePool (gPromptForNewPassword
);
622 FreePool (gConfirmPassword
);
623 FreePool (gPassowordInvalid
);
624 FreePool (gConfirmError
);
625 FreePool (gPressEnter
);
626 FreePool (gEmptyString
);
627 FreePool (gAreYouSure
);
628 FreePool (gYesResponse
);
629 FreePool (gNoResponse
);
630 FreePool (gMiniString
);
631 FreePool (gPlusString
);
632 FreePool (gMinusString
);
633 FreePool (gAdjustNumber
);
634 FreePool (gSaveChanges
);
635 FreePool (gOptionMismatch
);
636 FreePool (gFormSuppress
);
642 Update key's help imformation.
644 @param Selection Tell setup browser the information about the Selection
645 @param MenuOption The Menu option
646 @param Selected Whether or not a tag be selected
651 IN UI_MENU_SELECTION
*Selection
,
652 IN UI_MENU_OPTION
*MenuOption
,
658 UINTN LeftColumnOfHelp
;
659 UINTN RightColumnOfHelp
;
661 UINTN BottomRowOfHelp
;
662 UINTN StartColumnOfHelp
;
663 EFI_SCREEN_DESCRIPTOR LocalScreen
;
664 FORM_BROWSER_STATEMENT
*Statement
;
666 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
668 SecCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
669 ThdCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3;
671 StartColumnOfHelp
= LocalScreen
.LeftColumn
+ 2;
672 LeftColumnOfHelp
= LocalScreen
.LeftColumn
+ 1;
673 RightColumnOfHelp
= LocalScreen
.RightColumn
- 2;
674 TopRowOfHelp
= LocalScreen
.BottomRow
- 4;
675 BottomRowOfHelp
= LocalScreen
.BottomRow
- 3;
677 gST
->ConOut
->SetAttribute (gST
->ConOut
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
679 Statement
= MenuOption
->ThisTag
;
680 switch (Statement
->Operand
) {
681 case EFI_IFR_ORDERED_LIST_OP
:
682 case EFI_IFR_ONE_OF_OP
:
683 case EFI_IFR_NUMERIC_OP
:
684 case EFI_IFR_TIME_OP
:
685 case EFI_IFR_DATE_OP
:
686 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
689 if (gClassOfVfr
== FORMSET_CLASS_PLATFORM_SETUP
) {
690 if (Selection
->FormEditable
) {
691 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
692 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
694 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
697 if ((Statement
->Operand
== EFI_IFR_DATE_OP
) ||
698 (Statement
->Operand
== EFI_IFR_TIME_OP
)) {
709 PrintStringAt (SecCol
, BottomRowOfHelp
, gAdjustNumber
);
711 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
712 if (Statement
->Operand
== EFI_IFR_NUMERIC_OP
&& Statement
->Step
!= 0) {
713 PrintStringAt (SecCol
, BottomRowOfHelp
, gAdjustNumber
);
715 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
719 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterCommitString
);
722 // If it is a selected numeric with manual input, display different message
724 if ((Statement
->Operand
== EFI_IFR_NUMERIC_OP
) && (Statement
->Step
== 0)) {
728 ((Statement
->Flags
& EFI_IFR_DISPLAY_UINT_HEX
) == EFI_IFR_DISPLAY_UINT_HEX
) ? gHexNumericInput
: gDecNumericInput
730 } else if (Statement
->Operand
!= EFI_IFR_ORDERED_LIST_OP
) {
731 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
734 if (Statement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) {
735 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gPlusString
);
736 PrintStringAt (ThdCol
, TopRowOfHelp
, gMinusString
);
739 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
743 case EFI_IFR_CHECKBOX_OP
:
744 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
746 if (gClassOfVfr
== FORMSET_CLASS_PLATFORM_SETUP
) {
747 if (Selection
->FormEditable
) {
748 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
749 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
751 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
754 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
755 PrintStringAt (SecCol
, BottomRowOfHelp
, gToggleCheckBox
);
759 case EFI_IFR_PASSWORD_OP
:
760 case EFI_IFR_STRING_OP
:
761 case EFI_IFR_TEXT_OP
:
762 case EFI_IFR_ACTION_OP
:
763 case EFI_IFR_RESET_BUTTON_OP
:
764 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
767 if (gClassOfVfr
== FORMSET_CLASS_PLATFORM_SETUP
) {
768 if (Selection
->FormEditable
) {
769 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
770 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
772 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
775 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
776 if (Statement
->Operand
!= EFI_IFR_TEXT_OP
) {
777 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
780 if (Statement
->Operand
!= EFI_IFR_REF_OP
) {
782 (LocalScreen
.RightColumn
- GetStringWidth (gEnterCommitString
) / 2) / 2,
786 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
797 Functions which are registered to receive notification of
798 database events have this prototype. The actual event is encoded
799 in NotifyType. The following table describes how PackageType,
800 PackageGuid, Handle, and Package are used for each of the
803 @param PackageType Package type of the notification.
805 @param PackageGuid If PackageType is
806 EFI_HII_PACKAGE_TYPE_GUID, then this is
807 the pointer to the GUID from the Guid
808 field of EFI_HII_PACKAGE_GUID_HEADER.
809 Otherwise, it must be NULL.
811 @param Package Points to the package referred to by the
812 notification Handle The handle of the package
813 list which contains the specified package.
815 @param Handle The HII handle.
817 @param NotifyType The type of change concerning the
819 EFI_HII_DATABASE_NOTIFY_TYPE.
825 IN UINT8 PackageType
,
826 IN CONST EFI_GUID
*PackageGuid
,
827 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
828 IN EFI_HII_HANDLE Handle
,
829 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
832 mHiiPackageListUpdated
= TRUE
;
838 The worker function that send the displays to the screen. On output,
839 the selection made by user is returned.
841 @param Selection On input, Selection tell setup browser the information
842 about the Selection, form and formset to be displayed.
843 On output, Selection return the screen item that is selected
846 @retval EFI_SUCCESS The page is displayed successfully.
847 @return Other value if the page failed to be diplayed.
852 IN OUT UI_MENU_SELECTION
*Selection
857 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
858 EFI_HANDLE NotifyHandle
;
859 EFI_HII_VALUE
*HiiValue
;
860 FORM_BROWSER_STATEMENT
*Statement
;
861 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
862 FORM_BROWSER_FORMSET
*FormSet
;
865 gMenuRefreshHead
= NULL
;
866 gResetRequired
= FALSE
;
867 FormSet
= Selection
->FormSet
;
870 // Register notify for Form package update
872 Status
= mHiiDatabase
->RegisterPackageNotify (
874 EFI_HII_PACKAGE_FORMS
,
877 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
880 if (EFI_ERROR (Status
)) {
885 // Before display the formset, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN
887 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
888 if ((ConfigAccess
!= NULL
) && (Selection
->Action
!= UI_ACTION_REFRESH_FORMSET
)) {
889 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
890 mHiiPackageListUpdated
= FALSE
;
891 Status
= ConfigAccess
->Callback (
893 EFI_BROWSER_ACTION_FORM_OPEN
,
895 EFI_IFR_TYPE_UNDEFINED
,
900 if (!EFI_ERROR (Status
)) {
901 switch (ActionRequest
) {
902 case EFI_BROWSER_ACTION_REQUEST_RESET
:
903 gResetRequired
= TRUE
;
906 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
908 // Till now there is no uncommitted data, so ignore this request
912 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
913 Selection
->Action
= UI_ACTION_EXIT
;
921 if (mHiiPackageListUpdated
) {
923 // IFR is updated during callback, force to reparse the IFR binary
925 mHiiPackageListUpdated
= FALSE
;
926 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
932 // Initialize current settings of Questions in this FormSet
934 Status
= InitializeCurrentSetting (Selection
->FormSet
);
935 if (EFI_ERROR (Status
)) {
936 Selection
->Action
= UI_ACTION_EXIT
;
942 // Initialize Selection->Form
944 if (Selection
->FormId
== 0) {
946 // Zero FormId indicates display the first Form in a FormSet
948 Link
= GetFirstNode (&Selection
->FormSet
->FormListHead
);
950 Selection
->Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
951 Selection
->FormId
= Selection
->Form
->FormId
;
953 Selection
->Form
= IdToForm (Selection
->FormSet
, Selection
->FormId
);
956 if (Selection
->Form
== NULL
) {
958 // No Form to display
960 return EFI_NOT_FOUND
;
964 // Check Form is suppressed.
966 if (Selection
->Form
->SuppressExpression
!= NULL
) {
967 Status
= EvaluateExpression (Selection
->FormSet
, Selection
->Form
, Selection
->Form
->SuppressExpression
);
968 if (EFI_ERROR (Status
)) {
972 if (Selection
->Form
->SuppressExpression
->Result
.Value
.b
) {
974 // Form is suppressed.
977 CreateDialog (4, TRUE
, 0, NULL
, &Key
, gEmptyString
, gFormSuppress
, gPressEnter
, gEmptyString
);
978 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
980 return EFI_NOT_FOUND
;
985 // Load Questions' Value for display
987 Status
= LoadFormSetConfig (Selection
->FormSet
);
988 if (EFI_ERROR (Status
)) {
993 // Displays the Header and Footer borders
1000 Status
= DisplayForm (Selection
);
1001 if (EFI_ERROR (Status
)) {
1006 // Check Selected Statement (if press ESC, Selection->Statement will be NULL)
1008 Statement
= Selection
->Statement
;
1009 if (Statement
!= NULL
) {
1010 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_RESET_REQUIRED
) == EFI_IFR_FLAG_RESET_REQUIRED
) {
1011 gResetRequired
= TRUE
;
1015 // Reset FormPackage update flag
1017 mHiiPackageListUpdated
= FALSE
;
1019 if (((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) && (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
)) {
1020 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1022 HiiValue
= &Statement
->HiiValue
;
1023 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
1025 // Create String in HII database for Configuration Driver to retrieve
1027 HiiValue
->Value
.string
= NewString ((CHAR16
*) Statement
->BufferValue
, Selection
->FormSet
->HiiHandle
);
1030 if (ConfigAccess
== NULL
) {
1031 return EFI_UNSUPPORTED
;
1033 Status
= ConfigAccess
->Callback (
1035 EFI_BROWSER_ACTION_CHANGING
,
1036 Statement
->QuestionId
,
1042 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
1044 // Clean the String in HII Database
1046 DeleteString (HiiValue
->Value
.string
, Selection
->FormSet
->HiiHandle
);
1049 if (!EFI_ERROR (Status
)) {
1050 switch (ActionRequest
) {
1051 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1052 gResetRequired
= TRUE
;
1055 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1056 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1059 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1060 Selection
->Action
= UI_ACTION_EXIT
;
1061 gNvUpdateRequired
= FALSE
;
1067 } else if (Status
!= EFI_UNSUPPORTED
) {
1069 // Callback return error status other than EFI_UNSUPPORTED
1071 if (Statement
->Operand
== EFI_IFR_REF_OP
) {
1073 // Cross reference will not be taken
1075 Selection
->FormId
= Selection
->Form
->FormId
;
1076 Selection
->QuestionId
= 0;
1082 // Check whether Form Package has been updated during Callback
1084 if (mHiiPackageListUpdated
&& (Selection
->Action
== UI_ACTION_REFRESH_FORM
)) {
1086 // Force to reparse IFR binary of target Formset
1088 mHiiPackageListUpdated
= FALSE
;
1089 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1092 } while (Selection
->Action
== UI_ACTION_REFRESH_FORM
);
1095 // Before exit the formset, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE
1097 if ((ConfigAccess
!= NULL
) && (Selection
->Action
== UI_ACTION_EXIT
)) {
1098 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1099 Status
= ConfigAccess
->Callback (
1101 EFI_BROWSER_ACTION_FORM_CLOSE
,
1103 EFI_IFR_TYPE_UNDEFINED
,
1108 if (!EFI_ERROR (Status
)) {
1109 switch (ActionRequest
) {
1110 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1111 gResetRequired
= TRUE
;
1114 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1115 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1118 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1119 gNvUpdateRequired
= FALSE
;
1129 // Record the old formset
1131 if (gOldFormSet
!= NULL
) {
1132 DestroyFormSet (gOldFormSet
);
1134 gOldFormSet
= FormSet
;
1138 // Unregister notify for Form package update
1140 Status
= mHiiDatabase
->UnregisterPackageNotify (