2 Utility functions for UI presentation.
4 Copyright (c) 2004 - 2010, 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
;
22 Clear retangle with specified text attribute.
24 @param LeftColumn Left column of retangle.
25 @param RightColumn Right column of retangle.
26 @param TopRow Start row of retangle.
27 @param BottomRow End row of retangle.
28 @param TextAttribute The character foreground and background.
37 IN UINTN TextAttribute
44 // For now, allocate an arbitrarily long buffer
46 Buffer
= AllocateZeroPool (0x10000);
47 ASSERT (Buffer
!= NULL
);
50 // Set foreground and background as defined
52 gST
->ConOut
->SetAttribute (gST
->ConOut
, TextAttribute
);
55 // Much faster to buffer the long string instead of print it a character at a time
57 SetUnicodeMem (Buffer
, RightColumn
- LeftColumn
, L
' ');
60 // Clear the desired area with the appropriate foreground/background
62 for (Row
= TopRow
; Row
<= BottomRow
; Row
++) {
63 PrintStringAt (LeftColumn
, Row
, Buffer
);
66 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, LeftColumn
, TopRow
);
73 Concatenate a narrow string to another string.
75 @param Destination The destination string.
76 @param Source The source string. The string to be concatenated.
77 to the end of Destination.
82 IN OUT CHAR16
*Destination
,
88 for (Length
= 0; Destination
[Length
] != 0; Length
++)
92 // We now have the length of the original string
93 // We can safely assume for now that we are concatenating a narrow value to this string.
94 // For instance, the string is "XYZ" and cat'ing ">"
95 // If this assumption changes, we need to make this routine a bit more complex
97 Destination
[Length
] = NARROW_CHAR
;
100 StrCpy (Destination
+ Length
, Source
);
104 Count the storage space of a Unicode string.
106 This function handles the Unicode string with NARROW_CHAR
107 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
108 does not count in the resultant output. If a WIDE_CHAR is
109 hit, then 2 Unicode character will consume an output storage
110 space with size of CHAR16 till a NARROW_CHAR is hit.
112 If String is NULL, then ASSERT ().
114 @param String The input string to be counted.
116 @return Storage space for the input string.
126 UINTN IncrementValue
;
128 ASSERT (String
!= NULL
);
129 if (String
== NULL
) {
139 // Advance to the null-terminator or to the first width directive
142 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
143 Index
++, Count
= Count
+ IncrementValue
148 // We hit the null-terminator, we now have a count
150 if (String
[Index
] == 0) {
154 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
155 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
157 if (String
[Index
] == NARROW_CHAR
) {
159 // Skip to the next character
165 // Skip to the next character
170 } while (String
[Index
] != 0);
173 // Increment by one to include the null-terminator in the size
177 return Count
* sizeof (CHAR16
);
181 This function displays the page frame.
194 CHAR16
*StrFrontPageBanner
;
196 EFI_SCREEN_DESCRIPTOR LocalScreen
;
200 ZeroMem (&LocalScreen
, sizeof (EFI_SCREEN_DESCRIPTOR
));
201 gST
->ConOut
->QueryMode (gST
->ConOut
, gST
->ConOut
->Mode
->Mode
, &LocalScreen
.RightColumn
, &LocalScreen
.BottomRow
);
202 ClearLines (0, LocalScreen
.RightColumn
, 0, LocalScreen
.BottomRow
, KEYHELP_BACKGROUND
);
204 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
207 // For now, allocate an arbitrarily long buffer
209 Buffer
= AllocateZeroPool (0x10000);
210 ASSERT (Buffer
!= NULL
);
212 Character
= BOXDRAW_HORIZONTAL
;
214 for (Index
= 0; Index
+ 2 < (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
); Index
++) {
215 Buffer
[Index
] = Character
;
218 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) == FORMSET_CLASS_FRONT_PAGE
) {
220 // ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
223 LocalScreen
.LeftColumn
,
224 LocalScreen
.RightColumn
,
226 FRONT_PAGE_HEADER_HEIGHT
- 1 + LocalScreen
.TopRow
,
227 BANNER_TEXT
| BANNER_BACKGROUND
230 // for (Line = 0; Line < BANNER_HEIGHT; Line++) {
232 for (Line
= (UINT8
) LocalScreen
.TopRow
; Line
< BANNER_HEIGHT
+ (UINT8
) LocalScreen
.TopRow
; Line
++) {
234 // for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
236 for (Alignment
= (UINT8
) LocalScreen
.LeftColumn
;
237 Alignment
< BANNER_COLUMNS
+ (UINT8
) LocalScreen
.LeftColumn
;
240 RowIdx
= (UINT8
) (Line
- (UINT8
) LocalScreen
.TopRow
);
241 ColumnIdx
= (UINT8
) (Alignment
- (UINT8
) LocalScreen
.LeftColumn
);
243 ASSERT (RowIdx
< BANNER_HEIGHT
);
244 ASSERT (ColumnIdx
< BANNER_COLUMNS
);
246 if (gBannerData
->Banner
[RowIdx
][ColumnIdx
] != 0x0000) {
247 StrFrontPageBanner
= GetToken (
248 gBannerData
->Banner
[RowIdx
][ColumnIdx
],
255 switch (Alignment
- LocalScreen
.LeftColumn
) {
258 // Handle left column
260 PrintStringAt (LocalScreen
.LeftColumn
, Line
, StrFrontPageBanner
);
265 // Handle center column
268 LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3,
276 // Handle right column
279 LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3,
286 FreePool (StrFrontPageBanner
);
292 LocalScreen
.LeftColumn
,
293 LocalScreen
.RightColumn
,
294 LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
,
295 LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 1,
296 KEYHELP_TEXT
| KEYHELP_BACKGROUND
299 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) != FORMSET_CLASS_FRONT_PAGE
) {
301 LocalScreen
.LeftColumn
,
302 LocalScreen
.RightColumn
,
304 LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1,
305 TITLE_TEXT
| TITLE_BACKGROUND
308 // Print Top border line
309 // +------------------------------------------------------------------------------+
311 // +------------------------------------------------------------------------------+
313 Character
= BOXDRAW_DOWN_RIGHT
;
315 PrintChar (Character
);
316 PrintString (Buffer
);
318 Character
= BOXDRAW_DOWN_LEFT
;
319 PrintChar (Character
);
321 Character
= BOXDRAW_VERTICAL
;
322 for (Row
= LocalScreen
.TopRow
+ 1; Row
<= LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 2; Row
++) {
323 PrintCharAt (LocalScreen
.LeftColumn
, Row
, Character
);
324 PrintCharAt (LocalScreen
.RightColumn
- 1, Row
, Character
);
327 Character
= BOXDRAW_UP_RIGHT
;
328 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1, Character
);
329 PrintString (Buffer
);
331 Character
= BOXDRAW_UP_LEFT
;
332 PrintChar (Character
);
334 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
336 // Print Bottom border line
337 // +------------------------------------------------------------------------------+
339 // +------------------------------------------------------------------------------+
341 Character
= BOXDRAW_DOWN_RIGHT
;
342 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
, Character
);
344 PrintString (Buffer
);
346 Character
= BOXDRAW_DOWN_LEFT
;
347 PrintChar (Character
);
348 Character
= BOXDRAW_VERTICAL
;
349 for (Row
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
+ 1;
350 Row
<= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 2;
353 PrintCharAt (LocalScreen
.LeftColumn
, Row
, Character
);
354 PrintCharAt (LocalScreen
.RightColumn
- 1, Row
, Character
);
357 Character
= BOXDRAW_UP_RIGHT
;
358 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 1, Character
);
360 PrintString (Buffer
);
362 Character
= BOXDRAW_UP_LEFT
;
363 PrintChar (Character
);
373 Evaluate all expressions in a Form.
375 @param FormSet FormSet this Form belongs to.
376 @param Form The Form.
378 @retval EFI_SUCCESS The expression evaluated successfuly
382 EvaluateFormExpressions (
383 IN FORM_BROWSER_FORMSET
*FormSet
,
384 IN FORM_BROWSER_FORM
*Form
389 FORM_EXPRESSION
*Expression
;
391 Link
= GetFirstNode (&Form
->ExpressionListHead
);
392 while (!IsNull (&Form
->ExpressionListHead
, Link
)) {
393 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
394 Link
= GetNextNode (&Form
->ExpressionListHead
, Link
);
396 if (Expression
->Type
== EFI_HII_EXPRESSION_INCONSISTENT_IF
||
397 Expression
->Type
== EFI_HII_EXPRESSION_NO_SUBMIT_IF
||
398 Expression
->Type
== EFI_HII_EXPRESSION_WRITE
||
399 (Expression
->Type
== EFI_HII_EXPRESSION_READ
&& Form
->FormType
!= STANDARD_MAP_FORM_TYPE
)) {
401 // Postpone Form validation to Question editing or Form submitting or Question Write or Question Read for nonstandard form.
406 Status
= EvaluateExpression (FormSet
, Form
, Expression
);
407 if (EFI_ERROR (Status
)) {
416 +------------------------------------------------------------------------------+
418 +------------------------------------------------------------------------------+
436 +------------------------------------------------------------------------------+
437 ?F1=Scroll Help F9=Reset to Defaults F10=Save and Exit ?
438 | ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Discard Changes |
439 +------------------------------------------------------------------------------+
445 Display form and wait for user to select one menu option, then return it.
447 @param Selection On input, Selection tell setup browser the information
448 about the Selection, form and formset to be displayed.
449 On output, Selection return the screen item that is selected
451 @retval EFI_SUCESSS This function always return successfully for now.
456 IN OUT UI_MENU_SELECTION
*Selection
460 UINT16 MenuItemCount
;
461 EFI_HII_HANDLE Handle
;
463 EFI_SCREEN_DESCRIPTOR LocalScreen
;
466 CHAR16
*OutputString
;
468 FORM_BROWSER_STATEMENT
*Statement
;
469 UINT16 NumberOfLines
;
471 UI_MENU_OPTION
*MenuOption
;
473 Handle
= Selection
->Handle
;
480 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
482 StringPtr
= GetToken (Selection
->Form
->FormTitle
, Handle
);
484 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) != FORMSET_CLASS_FRONT_PAGE
) {
485 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| TITLE_BACKGROUND
);
487 (LocalScreen
.RightColumn
+ LocalScreen
.LeftColumn
- GetStringWidth (StringPtr
) / 2) / 2,
488 LocalScreen
.TopRow
+ 1,
494 // Remove Buffer allocated for StringPtr after it has been used.
496 FreePool (StringPtr
);
499 // Evaluate all the Expressions in this Form
501 Status
= EvaluateFormExpressions (Selection
->FormSet
, Selection
->Form
);
502 if (EFI_ERROR (Status
)) {
506 Selection
->FormEditable
= FALSE
;
507 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
508 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
509 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
511 if (Statement
->SuppressExpression
!= NULL
) {
512 Suppress
= Statement
->SuppressExpression
->Result
.Value
.b
;
517 if (Statement
->DisableExpression
!= NULL
) {
518 Suppress
= (BOOLEAN
) (Suppress
|| Statement
->DisableExpression
->Result
.Value
.b
);
522 StringPtr
= GetToken (Statement
->Prompt
, Handle
);
524 Width
= GetWidth (Statement
, Handle
);
528 for (; GetLineByWidth (StringPtr
, Width
, &ArrayEntry
, &OutputString
) != 0x0000;) {
530 // If there is more string to process print on the next row and increment the Skip value
532 if (StrLen (&StringPtr
[ArrayEntry
]) != 0) {
536 FreePool (OutputString
);
540 // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do
543 MenuOption
= UiAddMenuOption (StringPtr
, Selection
->Handle
, Statement
, NumberOfLines
, MenuItemCount
);
546 if (MenuOption
->IsQuestion
&& !MenuOption
->ReadOnly
) {
548 // At least one item is not readonly, this Form is considered as editable
550 Selection
->FormEditable
= TRUE
;
554 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
557 Status
= UiDisplayMenu (Selection
);
565 Initialize the HII String Token to the correct values.
569 InitializeBrowserStrings (
573 gFunctionNineString
= GetToken (STRING_TOKEN (FUNCTION_NINE_STRING
), gHiiHandle
);
574 gFunctionTenString
= GetToken (STRING_TOKEN (FUNCTION_TEN_STRING
), gHiiHandle
);
575 gEnterString
= GetToken (STRING_TOKEN (ENTER_STRING
), gHiiHandle
);
576 gEnterCommitString
= GetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), gHiiHandle
);
577 gEnterEscapeString
= GetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), gHiiHandle
);
578 gEscapeString
= GetToken (STRING_TOKEN (ESCAPE_STRING
), gHiiHandle
);
579 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
580 gMoveHighlight
= GetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), gHiiHandle
);
581 gMakeSelection
= GetToken (STRING_TOKEN (MAKE_SELECTION
), gHiiHandle
);
582 gDecNumericInput
= GetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), gHiiHandle
);
583 gHexNumericInput
= GetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), gHiiHandle
);
584 gToggleCheckBox
= GetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), gHiiHandle
);
585 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
586 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
587 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
588 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
589 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
590 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
591 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
592 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
593 gAreYouSure
= GetToken (STRING_TOKEN (ARE_YOU_SURE
), gHiiHandle
);
594 gYesResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), gHiiHandle
);
595 gNoResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), gHiiHandle
);
596 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
597 gPlusString
= GetToken (STRING_TOKEN (PLUS_STRING
), gHiiHandle
);
598 gMinusString
= GetToken (STRING_TOKEN (MINUS_STRING
), gHiiHandle
);
599 gAdjustNumber
= GetToken (STRING_TOKEN (ADJUST_NUMBER
), gHiiHandle
);
600 gSaveChanges
= GetToken (STRING_TOKEN (SAVE_CHANGES
), gHiiHandle
);
601 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
602 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
607 Free up the resource allocated for all strings required
616 FreePool (gFunctionNineString
);
617 FreePool (gFunctionTenString
);
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
);
650 Update key's help imformation.
652 @param Selection Tell setup browser the information about the Selection
653 @param MenuOption The Menu option
654 @param Selected Whether or not a tag be selected
659 IN UI_MENU_SELECTION
*Selection
,
660 IN UI_MENU_OPTION
*MenuOption
,
666 UINTN LeftColumnOfHelp
;
667 UINTN RightColumnOfHelp
;
669 UINTN BottomRowOfHelp
;
670 UINTN StartColumnOfHelp
;
671 EFI_SCREEN_DESCRIPTOR LocalScreen
;
672 FORM_BROWSER_STATEMENT
*Statement
;
674 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
676 SecCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
677 ThdCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3;
679 StartColumnOfHelp
= LocalScreen
.LeftColumn
+ 2;
680 LeftColumnOfHelp
= LocalScreen
.LeftColumn
+ 1;
681 RightColumnOfHelp
= LocalScreen
.RightColumn
- 2;
682 TopRowOfHelp
= LocalScreen
.BottomRow
- 4;
683 BottomRowOfHelp
= LocalScreen
.BottomRow
- 3;
685 gST
->ConOut
->SetAttribute (gST
->ConOut
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
687 Statement
= MenuOption
->ThisTag
;
688 switch (Statement
->Operand
) {
689 case EFI_IFR_ORDERED_LIST_OP
:
690 case EFI_IFR_ONE_OF_OP
:
691 case EFI_IFR_NUMERIC_OP
:
692 case EFI_IFR_TIME_OP
:
693 case EFI_IFR_DATE_OP
:
694 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
697 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
698 if (Selection
->FormEditable
) {
699 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
700 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
702 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
705 if ((Statement
->Operand
== EFI_IFR_DATE_OP
) ||
706 (Statement
->Operand
== EFI_IFR_TIME_OP
)) {
717 PrintStringAt (SecCol
, BottomRowOfHelp
, gAdjustNumber
);
719 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
720 if (Statement
->Operand
== EFI_IFR_NUMERIC_OP
&& Statement
->Step
!= 0) {
721 PrintStringAt (SecCol
, BottomRowOfHelp
, gAdjustNumber
);
723 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
727 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterCommitString
);
730 // If it is a selected numeric with manual input, display different message
732 if ((Statement
->Operand
== EFI_IFR_NUMERIC_OP
) && (Statement
->Step
== 0)) {
736 ((Statement
->Flags
& EFI_IFR_DISPLAY_UINT_HEX
) == EFI_IFR_DISPLAY_UINT_HEX
) ? gHexNumericInput
: gDecNumericInput
738 } else if (Statement
->Operand
!= EFI_IFR_ORDERED_LIST_OP
) {
739 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
742 if (Statement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) {
743 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gPlusString
);
744 PrintStringAt (ThdCol
, TopRowOfHelp
, gMinusString
);
747 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
751 case EFI_IFR_CHECKBOX_OP
:
752 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
754 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
755 if (Selection
->FormEditable
) {
756 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
757 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
759 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
762 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
763 PrintStringAt (SecCol
, BottomRowOfHelp
, gToggleCheckBox
);
767 case EFI_IFR_PASSWORD_OP
:
768 case EFI_IFR_STRING_OP
:
769 case EFI_IFR_TEXT_OP
:
770 case EFI_IFR_ACTION_OP
:
771 case EFI_IFR_RESET_BUTTON_OP
:
772 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
775 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
776 if (Selection
->FormEditable
) {
777 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
778 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
780 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
783 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
784 if (Statement
->Operand
!= EFI_IFR_TEXT_OP
) {
785 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
788 if (Statement
->Operand
!= EFI_IFR_REF_OP
) {
790 (LocalScreen
.RightColumn
- GetStringWidth (gEnterCommitString
) / 2) / 2,
794 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
805 Functions which are registered to receive notification of
806 database events have this prototype. The actual event is encoded
807 in NotifyType. The following table describes how PackageType,
808 PackageGuid, Handle, and Package are used for each of the
811 @param PackageType Package type of the notification.
813 @param PackageGuid If PackageType is
814 EFI_HII_PACKAGE_TYPE_GUID, then this is
815 the pointer to the GUID from the Guid
816 field of EFI_HII_PACKAGE_GUID_HEADER.
817 Otherwise, it must be NULL.
819 @param Package Points to the package referred to by the
820 notification Handle The handle of the package
821 list which contains the specified package.
823 @param Handle The HII handle.
825 @param NotifyType The type of change concerning the
827 EFI_HII_DATABASE_NOTIFY_TYPE.
833 IN UINT8 PackageType
,
834 IN CONST EFI_GUID
*PackageGuid
,
835 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
836 IN EFI_HII_HANDLE Handle
,
837 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
840 mHiiPackageListUpdated
= TRUE
;
845 BOOLEAN mFormCloseCallBack
= FALSE
;
848 The worker function that send the displays to the screen. On output,
849 the selection made by user is returned.
851 @param Selection On input, Selection tell setup browser the information
852 about the Selection, form and formset to be displayed.
853 On output, Selection return the screen item that is selected
856 @retval EFI_SUCCESS The page is displayed successfully.
857 @return Other value if the page failed to be diplayed.
862 IN OUT UI_MENU_SELECTION
*Selection
867 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
868 EFI_HANDLE NotifyHandle
;
869 EFI_HII_VALUE
*HiiValue
;
870 EFI_IFR_TYPE_VALUE
*TypeValue
;
871 FORM_BROWSER_STATEMENT
*Statement
;
872 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
873 FORM_BROWSER_FORMSET
*FormSet
;
875 BOOLEAN FormOpenCallBack
;
876 BOOLEAN SubmitFormIsRequired
;
877 EFI_GUID CurrentFormSetGuid
;
878 EFI_HII_HANDLE CurrentHiiHandle
;
879 UINT16 CurrentFormId
;
881 gMenuRefreshHead
= NULL
;
882 gResetRequired
= FALSE
;
883 FormSet
= Selection
->FormSet
;
884 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
887 // Register notify for Form package update
889 Status
= mHiiDatabase
->RegisterPackageNotify (
891 EFI_HII_PACKAGE_FORMS
,
894 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
897 if (EFI_ERROR (Status
)) {
902 // Initialize current settings of Questions in this FormSet
904 Status
= InitializeCurrentSetting (Selection
->FormSet
);
905 if (EFI_ERROR (Status
)) {
906 Selection
->Action
= UI_ACTION_EXIT
;
912 // Initialize Selection->Form
914 FormOpenCallBack
= FALSE
;
915 if (Selection
->FormId
== 0) {
917 // First Form will open.
919 FormOpenCallBack
= TRUE
;
922 // Zero FormId indicates display the first Form in a FormSet
924 Link
= GetFirstNode (&Selection
->FormSet
->FormListHead
);
926 Selection
->Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
927 Selection
->FormId
= Selection
->Form
->FormId
;
929 if (Selection
->Form
== NULL
) {
931 // First Form will open.
933 FormOpenCallBack
= TRUE
;
935 Selection
->Form
= IdToForm (Selection
->FormSet
, Selection
->FormId
);
938 if (Selection
->Form
== NULL
) {
940 // No Form to display
942 return EFI_NOT_FOUND
;
946 // Check Form is suppressed.
948 if (Selection
->Form
->SuppressExpression
!= NULL
) {
949 Status
= EvaluateExpression (Selection
->FormSet
, Selection
->Form
, Selection
->Form
->SuppressExpression
);
950 if (EFI_ERROR (Status
)) {
954 if (Selection
->Form
->SuppressExpression
->Result
.Value
.b
) {
956 // Form is suppressed.
959 CreateDialog (4, TRUE
, 0, NULL
, &Key
, gEmptyString
, gFormSuppress
, gPressEnter
, gEmptyString
);
960 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
962 return EFI_NOT_FOUND
;
967 // Keep current form information
969 CurrentHiiHandle
= Selection
->Handle
;
970 CopyGuid (&CurrentFormSetGuid
, &Selection
->FormSetGuid
);
971 CurrentFormId
= Selection
->FormId
;
974 // Reset FormPackage update flag
976 mHiiPackageListUpdated
= FALSE
;
979 // Before display new form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN
980 // for each question with callback flag.
981 // New form may be the first form, or the different form after another form close.
983 if ((FormOpenCallBack
|| mFormCloseCallBack
) && (ConfigAccess
!= NULL
)) {
984 mFormCloseCallBack
= FALSE
;
986 // Go through each statement in this form
988 SubmitFormIsRequired
= FALSE
;
989 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
990 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
991 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
992 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
994 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) {
999 // Check whether Statement is disabled.
1001 if (Statement
->DisableExpression
!= NULL
) {
1002 Status
= EvaluateExpression (Selection
->FormSet
, Selection
->Form
, Statement
->DisableExpression
);
1003 if (!EFI_ERROR (Status
) &&
1004 (Statement
->DisableExpression
->Result
.Type
== EFI_IFR_TYPE_BOOLEAN
) &&
1005 (Statement
->DisableExpression
->Result
.Value
.b
)) {
1010 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1011 Status
= ConfigAccess
->Callback (
1013 EFI_BROWSER_ACTION_FORM_OPEN
,
1014 Statement
->QuestionId
,
1015 EFI_IFR_TYPE_UNDEFINED
,
1020 if (!EFI_ERROR (Status
)) {
1021 switch (ActionRequest
) {
1022 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1023 gResetRequired
= TRUE
;
1026 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1027 SubmitFormIsRequired
= TRUE
;
1030 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1031 Selection
->Action
= UI_ACTION_EXIT
;
1032 gNvUpdateRequired
= FALSE
;
1040 if (SubmitFormIsRequired
) {
1041 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1044 // EXIT requests to close form.
1046 if (Selection
->Action
== UI_ACTION_EXIT
) {
1050 // IFR is updated during callback of open form, force to reparse the IFR binary
1052 if (mHiiPackageListUpdated
) {
1053 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1054 mHiiPackageListUpdated
= FALSE
;
1060 // Load Questions' Value for display
1062 Status
= LoadFormSetConfig (Selection
, Selection
->FormSet
);
1063 if (EFI_ERROR (Status
)) {
1068 // EXIT requests to close form.
1070 if (Selection
->Action
== UI_ACTION_EXIT
) {
1074 // IFR is updated during callback of read value, force to reparse the IFR binary
1076 if (mHiiPackageListUpdated
) {
1077 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1078 mHiiPackageListUpdated
= FALSE
;
1083 // Displays the Header and Footer borders
1085 DisplayPageFrame ();
1090 Status
= DisplayForm (Selection
);
1091 if (EFI_ERROR (Status
)) {
1096 // Check Selected Statement (if press ESC, Selection->Statement will be NULL)
1098 Statement
= Selection
->Statement
;
1099 if (Statement
!= NULL
) {
1100 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_RESET_REQUIRED
) == EFI_IFR_FLAG_RESET_REQUIRED
) {
1101 gResetRequired
= TRUE
;
1105 // Reset FormPackage update flag
1107 mHiiPackageListUpdated
= FALSE
;
1109 if (((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) && (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
)) {
1110 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1112 if (ConfigAccess
== NULL
) {
1113 return EFI_UNSUPPORTED
;
1116 HiiValue
= &Statement
->HiiValue
;
1117 TypeValue
= &HiiValue
->Value
;
1118 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
1120 // Create String in HII database for Configuration Driver to retrieve
1122 HiiValue
->Value
.string
= NewString ((CHAR16
*) Statement
->BufferValue
, Selection
->FormSet
->HiiHandle
);
1123 } else if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
1125 // For OrderedList, passing in the value buffer to Callback()
1127 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Statement
->BufferValue
;
1130 Status
= ConfigAccess
->Callback (
1132 EFI_BROWSER_ACTION_CHANGING
,
1133 Statement
->QuestionId
,
1139 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
1141 // Clean the String in HII Database
1143 DeleteString (HiiValue
->Value
.string
, Selection
->FormSet
->HiiHandle
);
1146 if (!EFI_ERROR (Status
)) {
1147 switch (ActionRequest
) {
1148 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1149 gResetRequired
= TRUE
;
1152 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1153 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1156 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1157 Selection
->Action
= UI_ACTION_EXIT
;
1158 gNvUpdateRequired
= FALSE
;
1164 } else if (Status
!= EFI_UNSUPPORTED
) {
1166 // Callback return error status other than EFI_UNSUPPORTED
1168 if (Statement
->Operand
== EFI_IFR_REF_OP
) {
1170 // Cross reference will not be taken
1172 Selection
->FormId
= Selection
->Form
->FormId
;
1173 Selection
->QuestionId
= 0;
1179 // Check whether Form Package has been updated during Callback
1181 if (mHiiPackageListUpdated
&& (Selection
->Action
== UI_ACTION_REFRESH_FORM
)) {
1183 // Force to reparse IFR binary of target Formset
1185 mHiiPackageListUpdated
= FALSE
;
1186 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1191 // Before exit the form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE
1192 // for each question with callback flag.
1194 mFormCloseCallBack
= FALSE
;
1195 if ((ConfigAccess
!= NULL
) &&
1196 ((Selection
->Action
== UI_ACTION_EXIT
) ||
1197 (Selection
->Handle
!= CurrentHiiHandle
) ||
1198 (!CompareGuid (&CurrentFormSetGuid
, &Selection
->FormSetGuid
)) ||
1199 (Selection
->FormId
!= CurrentFormId
))) {
1201 // Go through each statement in this form
1203 mFormCloseCallBack
= TRUE
;
1204 SubmitFormIsRequired
= FALSE
;
1205 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
1206 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
1207 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
1208 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
1210 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) {
1214 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1215 Status
= ConfigAccess
->Callback (
1217 EFI_BROWSER_ACTION_FORM_CLOSE
,
1218 Statement
->QuestionId
,
1219 EFI_IFR_TYPE_UNDEFINED
,
1224 if (!EFI_ERROR (Status
)) {
1225 switch (ActionRequest
) {
1226 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1227 gResetRequired
= TRUE
;
1230 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1231 SubmitFormIsRequired
= TRUE
;
1234 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1235 Selection
->Action
= UI_ACTION_EXIT
;
1236 gNvUpdateRequired
= FALSE
;
1244 if (SubmitFormIsRequired
) {
1245 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1248 } while (Selection
->Action
== UI_ACTION_REFRESH_FORM
);
1251 // Record the old formset
1253 if (gOldFormSet
!= NULL
) {
1254 DestroyFormSet (gOldFormSet
);
1256 gOldFormSet
= FormSet
;
1260 // Unregister notify for Form package update
1262 Status
= mHiiDatabase
->UnregisterPackageNotify (