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
;
846 The worker function that send the displays to the screen. On output,
847 the selection made by user is returned.
849 @param Selection On input, Selection tell setup browser the information
850 about the Selection, form and formset to be displayed.
851 On output, Selection return the screen item that is selected
854 @retval EFI_SUCCESS The page is displayed successfully.
855 @return Other value if the page failed to be diplayed.
860 IN OUT UI_MENU_SELECTION
*Selection
865 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
866 EFI_HANDLE NotifyHandle
;
867 EFI_HII_VALUE
*HiiValue
;
868 EFI_IFR_TYPE_VALUE
*TypeValue
;
869 FORM_BROWSER_STATEMENT
*Statement
;
870 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
871 FORM_BROWSER_FORMSET
*FormSet
;
874 gMenuRefreshHead
= NULL
;
875 gResetRequired
= FALSE
;
876 FormSet
= Selection
->FormSet
;
879 // Register notify for Form package update
881 Status
= mHiiDatabase
->RegisterPackageNotify (
883 EFI_HII_PACKAGE_FORMS
,
886 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
889 if (EFI_ERROR (Status
)) {
894 // Before display the formset, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN
896 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
897 if ((ConfigAccess
!= NULL
) && (Selection
->Action
!= UI_ACTION_REFRESH_FORMSET
)) {
898 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
899 mHiiPackageListUpdated
= FALSE
;
900 Status
= ConfigAccess
->Callback (
902 EFI_BROWSER_ACTION_FORM_OPEN
,
904 EFI_IFR_TYPE_UNDEFINED
,
909 if (!EFI_ERROR (Status
)) {
910 switch (ActionRequest
) {
911 case EFI_BROWSER_ACTION_REQUEST_RESET
:
912 gResetRequired
= TRUE
;
915 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
917 // Till now there is no uncommitted data, so ignore this request
921 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
922 Selection
->Action
= UI_ACTION_EXIT
;
930 if (mHiiPackageListUpdated
) {
932 // IFR is updated during callback, force to reparse the IFR binary
934 mHiiPackageListUpdated
= FALSE
;
935 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
941 // Initialize current settings of Questions in this FormSet
943 Status
= InitializeCurrentSetting (Selection
->FormSet
);
944 if (EFI_ERROR (Status
)) {
945 Selection
->Action
= UI_ACTION_EXIT
;
951 // Initialize Selection->Form
953 if (Selection
->FormId
== 0) {
955 // Zero FormId indicates display the first Form in a FormSet
957 Link
= GetFirstNode (&Selection
->FormSet
->FormListHead
);
959 Selection
->Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
960 Selection
->FormId
= Selection
->Form
->FormId
;
962 Selection
->Form
= IdToForm (Selection
->FormSet
, Selection
->FormId
);
965 if (Selection
->Form
== NULL
) {
967 // No Form to display
969 return EFI_NOT_FOUND
;
973 // Check Form is suppressed.
975 if (Selection
->Form
->SuppressExpression
!= NULL
) {
976 Status
= EvaluateExpression (Selection
->FormSet
, Selection
->Form
, Selection
->Form
->SuppressExpression
);
977 if (EFI_ERROR (Status
)) {
981 if (Selection
->Form
->SuppressExpression
->Result
.Value
.b
) {
983 // Form is suppressed.
986 CreateDialog (4, TRUE
, 0, NULL
, &Key
, gEmptyString
, gFormSuppress
, gPressEnter
, gEmptyString
);
987 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
989 return EFI_NOT_FOUND
;
994 // Reset FormPackage update flag
996 mHiiPackageListUpdated
= FALSE
;
999 // Load Questions' Value for display
1001 Status
= LoadFormSetConfig (Selection
, Selection
->FormSet
);
1002 if (EFI_ERROR (Status
)) {
1007 // IFR is updated during callback of read value, force to reparse the IFR binary
1009 if (mHiiPackageListUpdated
) {
1010 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1011 mHiiPackageListUpdated
= FALSE
;
1016 // Displays the Header and Footer borders
1018 DisplayPageFrame ();
1023 Status
= DisplayForm (Selection
);
1024 if (EFI_ERROR (Status
)) {
1029 // Check Selected Statement (if press ESC, Selection->Statement will be NULL)
1031 Statement
= Selection
->Statement
;
1032 if (Statement
!= NULL
) {
1033 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_RESET_REQUIRED
) == EFI_IFR_FLAG_RESET_REQUIRED
) {
1034 gResetRequired
= TRUE
;
1038 // Reset FormPackage update flag
1040 mHiiPackageListUpdated
= FALSE
;
1042 if (((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) && (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
)) {
1043 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1045 if (ConfigAccess
== NULL
) {
1046 return EFI_UNSUPPORTED
;
1049 HiiValue
= &Statement
->HiiValue
;
1050 TypeValue
= &HiiValue
->Value
;
1051 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
1053 // Create String in HII database for Configuration Driver to retrieve
1055 HiiValue
->Value
.string
= NewString ((CHAR16
*) Statement
->BufferValue
, Selection
->FormSet
->HiiHandle
);
1056 } else if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
1058 // For OrderedList, passing in the value buffer to Callback()
1060 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Statement
->BufferValue
;
1063 Status
= ConfigAccess
->Callback (
1065 EFI_BROWSER_ACTION_CHANGING
,
1066 Statement
->QuestionId
,
1072 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
1074 // Clean the String in HII Database
1076 DeleteString (HiiValue
->Value
.string
, Selection
->FormSet
->HiiHandle
);
1079 if (!EFI_ERROR (Status
)) {
1080 switch (ActionRequest
) {
1081 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1082 gResetRequired
= TRUE
;
1085 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1086 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1089 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1090 Selection
->Action
= UI_ACTION_EXIT
;
1091 gNvUpdateRequired
= FALSE
;
1097 } else if (Status
!= EFI_UNSUPPORTED
) {
1099 // Callback return error status other than EFI_UNSUPPORTED
1101 if (Statement
->Operand
== EFI_IFR_REF_OP
) {
1103 // Cross reference will not be taken
1105 Selection
->FormId
= Selection
->Form
->FormId
;
1106 Selection
->QuestionId
= 0;
1112 // Check whether Form Package has been updated during Callback
1114 if (mHiiPackageListUpdated
&& (Selection
->Action
== UI_ACTION_REFRESH_FORM
)) {
1116 // Force to reparse IFR binary of target Formset
1118 mHiiPackageListUpdated
= FALSE
;
1119 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1122 } while (Selection
->Action
== UI_ACTION_REFRESH_FORM
);
1125 // Before exit the formset, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE
1127 if ((ConfigAccess
!= NULL
) && (Selection
->Action
== UI_ACTION_EXIT
)) {
1128 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1129 Status
= ConfigAccess
->Callback (
1131 EFI_BROWSER_ACTION_FORM_CLOSE
,
1133 EFI_IFR_TYPE_UNDEFINED
,
1138 if (!EFI_ERROR (Status
)) {
1139 switch (ActionRequest
) {
1140 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1141 gResetRequired
= TRUE
;
1144 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1145 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1148 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1149 gNvUpdateRequired
= FALSE
;
1159 // Record the old formset
1161 if (gOldFormSet
!= NULL
) {
1162 DestroyFormSet (gOldFormSet
);
1164 gOldFormSet
= FormSet
;
1168 // Unregister notify for Form package update
1170 Status
= mHiiDatabase
->UnregisterPackageNotify (