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.
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.
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
;
464 Handle
= Selection
->Handle
;
471 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
473 StringPtr
= GetToken (Selection
->Form
->FormTitle
, Handle
);
475 if (gClassOfVfr
!= FORMSET_CLASS_FRONT_PAGE
) {
476 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| TITLE_BACKGROUND
);
478 (LocalScreen
.RightColumn
+ LocalScreen
.LeftColumn
- GetStringWidth (StringPtr
) / 2) / 2,
479 LocalScreen
.TopRow
+ 1,
485 // Remove Buffer allocated for StringPtr after it has been used.
487 FreePool (StringPtr
);
490 // Evaluate all the Expressions in this Form
492 Status
= EvaluateFormExpressions (Selection
->FormSet
, Selection
->Form
);
493 if (EFI_ERROR (Status
)) {
497 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
498 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
499 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
501 if (Statement
->SuppressExpression
!= NULL
) {
502 Suppress
= Statement
->SuppressExpression
->Result
.Value
.b
;
507 if (Statement
->DisableExpression
!= NULL
) {
508 Suppress
= (BOOLEAN
) (Suppress
|| Statement
->DisableExpression
->Result
.Value
.b
);
512 StringPtr
= GetToken (Statement
->Prompt
, Handle
);
514 Width
= GetWidth (Statement
, Handle
);
518 for (; GetLineByWidth (StringPtr
, Width
, &ArrayEntry
, &OutputString
) != 0x0000;) {
520 // If there is more string to process print on the next row and increment the Skip value
522 if (StrLen (&StringPtr
[ArrayEntry
]) != 0) {
526 FreePool (OutputString
);
530 // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do
533 UiAddMenuOption (StringPtr
, Selection
->Handle
, Statement
, NumberOfLines
, MenuItemCount
);
537 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
540 Status
= UiDisplayMenu (Selection
);
548 Initialize the HII String Token to the correct values.
552 InitializeBrowserStrings (
556 gFunctionOneString
= GetToken (STRING_TOKEN (FUNCTION_ONE_STRING
), gHiiHandle
);
557 gFunctionNineString
= GetToken (STRING_TOKEN (FUNCTION_NINE_STRING
), gHiiHandle
);
558 gFunctionTenString
= GetToken (STRING_TOKEN (FUNCTION_TEN_STRING
), gHiiHandle
);
559 gEnterString
= GetToken (STRING_TOKEN (ENTER_STRING
), gHiiHandle
);
560 gEnterCommitString
= GetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), gHiiHandle
);
561 gEnterEscapeString
= GetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), gHiiHandle
);
562 gEscapeString
= GetToken (STRING_TOKEN (ESCAPE_STRING
), gHiiHandle
);
563 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
564 gMoveHighlight
= GetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), gHiiHandle
);
565 gMakeSelection
= GetToken (STRING_TOKEN (MAKE_SELECTION
), gHiiHandle
);
566 gDecNumericInput
= GetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), gHiiHandle
);
567 gHexNumericInput
= GetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), gHiiHandle
);
568 gToggleCheckBox
= GetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), gHiiHandle
);
569 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
570 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
571 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
572 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
573 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
574 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
575 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
576 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
577 gAreYouSure
= GetToken (STRING_TOKEN (ARE_YOU_SURE
), gHiiHandle
);
578 gYesResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), gHiiHandle
);
579 gNoResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), gHiiHandle
);
580 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
581 gPlusString
= GetToken (STRING_TOKEN (PLUS_STRING
), gHiiHandle
);
582 gMinusString
= GetToken (STRING_TOKEN (MINUS_STRING
), gHiiHandle
);
583 gAdjustNumber
= GetToken (STRING_TOKEN (ADJUST_NUMBER
), gHiiHandle
);
584 gSaveChanges
= GetToken (STRING_TOKEN (SAVE_CHANGES
), gHiiHandle
);
585 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
590 Free up the resource allocated for all strings required
599 FreePool (gFunctionOneString
);
600 FreePool (gFunctionNineString
);
601 FreePool (gFunctionTenString
);
602 FreePool (gEnterString
);
603 FreePool (gEnterCommitString
);
604 FreePool (gEnterEscapeString
);
605 FreePool (gEscapeString
);
606 FreePool (gMoveHighlight
);
607 FreePool (gMakeSelection
);
608 FreePool (gDecNumericInput
);
609 FreePool (gHexNumericInput
);
610 FreePool (gToggleCheckBox
);
611 FreePool (gPromptForData
);
612 FreePool (gPromptForPassword
);
613 FreePool (gPromptForNewPassword
);
614 FreePool (gConfirmPassword
);
615 FreePool (gPassowordInvalid
);
616 FreePool (gConfirmError
);
617 FreePool (gPressEnter
);
618 FreePool (gEmptyString
);
619 FreePool (gAreYouSure
);
620 FreePool (gYesResponse
);
621 FreePool (gNoResponse
);
622 FreePool (gMiniString
);
623 FreePool (gPlusString
);
624 FreePool (gMinusString
);
625 FreePool (gAdjustNumber
);
626 FreePool (gSaveChanges
);
627 FreePool (gOptionMismatch
);
633 Update key's help imformation.
635 @param MenuOption The Menu option
636 @param Selected Whether or not a tag be selected
641 IN UI_MENU_OPTION
*MenuOption
,
647 UINTN LeftColumnOfHelp
;
648 UINTN RightColumnOfHelp
;
650 UINTN BottomRowOfHelp
;
651 UINTN StartColumnOfHelp
;
652 EFI_SCREEN_DESCRIPTOR LocalScreen
;
653 FORM_BROWSER_STATEMENT
*Statement
;
655 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
657 SecCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
658 ThdCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3;
660 StartColumnOfHelp
= LocalScreen
.LeftColumn
+ 2;
661 LeftColumnOfHelp
= LocalScreen
.LeftColumn
+ 1;
662 RightColumnOfHelp
= LocalScreen
.RightColumn
- 2;
663 TopRowOfHelp
= LocalScreen
.BottomRow
- 4;
664 BottomRowOfHelp
= LocalScreen
.BottomRow
- 3;
666 gST
->ConOut
->SetAttribute (gST
->ConOut
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
668 Statement
= MenuOption
->ThisTag
;
669 switch (Statement
->Operand
) {
670 case EFI_IFR_ORDERED_LIST_OP
:
671 case EFI_IFR_ONE_OF_OP
:
672 case EFI_IFR_NUMERIC_OP
:
673 case EFI_IFR_TIME_OP
:
674 case EFI_IFR_DATE_OP
:
675 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
678 if (gClassOfVfr
== FORMSET_CLASS_PLATFORM_SETUP
) {
679 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gFunctionOneString
);
680 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
681 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
682 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
685 if ((Statement
->Operand
== EFI_IFR_DATE_OP
) ||
686 (Statement
->Operand
== EFI_IFR_TIME_OP
)) {
697 PrintStringAt (SecCol
, BottomRowOfHelp
, gAdjustNumber
);
699 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
700 if (Statement
->Operand
== EFI_IFR_NUMERIC_OP
&& Statement
->Step
!= 0) {
701 PrintStringAt (SecCol
, BottomRowOfHelp
, gAdjustNumber
);
703 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
707 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterCommitString
);
710 // If it is a selected numeric with manual input, display different message
712 if ((Statement
->Operand
== EFI_IFR_NUMERIC_OP
) && (Statement
->Step
== 0)) {
716 ((Statement
->Flags
& EFI_IFR_DISPLAY_UINT_HEX
) == EFI_IFR_DISPLAY_UINT_HEX
) ? gHexNumericInput
: gDecNumericInput
718 } else if (Statement
->Operand
!= EFI_IFR_ORDERED_LIST_OP
) {
719 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
722 if (Statement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) {
723 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gPlusString
);
724 PrintStringAt (ThdCol
, TopRowOfHelp
, gMinusString
);
727 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
731 case EFI_IFR_CHECKBOX_OP
:
732 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
734 if (gClassOfVfr
== FORMSET_CLASS_PLATFORM_SETUP
) {
735 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gFunctionOneString
);
736 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
737 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
738 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
741 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
742 PrintStringAt (SecCol
, BottomRowOfHelp
, gToggleCheckBox
);
746 case EFI_IFR_PASSWORD_OP
:
747 case EFI_IFR_STRING_OP
:
748 case EFI_IFR_TEXT_OP
:
749 case EFI_IFR_ACTION_OP
:
750 case EFI_IFR_RESET_BUTTON_OP
:
751 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
754 if (gClassOfVfr
== FORMSET_CLASS_PLATFORM_SETUP
) {
755 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gFunctionOneString
);
756 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
757 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
758 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
761 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
762 if (Statement
->Operand
!= EFI_IFR_TEXT_OP
) {
763 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
766 if (Statement
->Operand
!= EFI_IFR_REF_OP
) {
768 (LocalScreen
.RightColumn
- GetStringWidth (gEnterCommitString
) / 2) / 2,
772 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
783 Functions which are registered to receive notification of
784 database events have this prototype. The actual event is encoded
785 in NotifyType. The following table describes how PackageType,
786 PackageGuid, Handle, and Package are used for each of the
789 @param PackageType Package type of the notification.
791 @param PackageGuid If PackageType is
792 EFI_HII_PACKAGE_TYPE_GUID, then this is
793 the pointer to the GUID from the Guid
794 field of EFI_HII_PACKAGE_GUID_HEADER.
795 Otherwise, it must be NULL.
797 @param Package Points to the package referred to by the
798 notification Handle The handle of the package
799 list which contains the specified package.
801 @param Handle The HII handle.
803 @param NotifyType The type of change concerning the
805 EFI_HII_DATABASE_NOTIFY_TYPE.
811 IN UINT8 PackageType
,
812 IN CONST EFI_GUID
*PackageGuid
,
813 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
814 IN EFI_HII_HANDLE Handle
,
815 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
818 mHiiPackageListUpdated
= TRUE
;
824 The worker function that send the displays to the screen. On output,
825 the selection made by user is returned.
827 @param Selection On input, Selection tell setup browser the information
828 about the Selection, form and formset to be displayed.
829 On output, Selection return the screen item that is selected
832 @retval EFI_SUCCESS The page is displayed successfully.
833 @return Other value if the page failed to be diplayed.
838 IN OUT UI_MENU_SELECTION
*Selection
843 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
844 EFI_HANDLE NotifyHandle
;
845 EFI_HII_VALUE
*HiiValue
;
846 FORM_BROWSER_STATEMENT
*Statement
;
847 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
848 FORM_BROWSER_FORMSET
*FormSet
;
850 gMenuRefreshHead
= NULL
;
851 gResetRequired
= FALSE
;
852 FormSet
= Selection
->FormSet
;
855 // Register notify for Form package update
857 Status
= mHiiDatabase
->RegisterPackageNotify (
859 EFI_HII_PACKAGE_FORMS
,
862 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
865 if (EFI_ERROR (Status
)) {
870 // Initialize current settings of Questions in this FormSet
872 Status
= InitializeCurrentSetting (Selection
->FormSet
);
873 if (EFI_ERROR (Status
)) {
874 Selection
->Action
= UI_ACTION_EXIT
;
880 // Displays the Header and Footer borders
885 // Initialize Selection->Form
887 if (Selection
->FormId
== 0) {
889 // Zero FormId indicates display the first Form in a FormSet
891 Link
= GetFirstNode (&Selection
->FormSet
->FormListHead
);
893 Selection
->Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
894 Selection
->FormId
= Selection
->Form
->FormId
;
896 Selection
->Form
= IdToForm (Selection
->FormSet
, Selection
->FormId
);
899 if (Selection
->Form
== NULL
) {
901 // No Form to display
903 return EFI_NOT_FOUND
;
907 // Load Questions' Value for display
909 Status
= LoadFormSetConfig (Selection
->FormSet
);
910 if (EFI_ERROR (Status
)) {
917 Status
= DisplayForm (Selection
);
918 if (EFI_ERROR (Status
)) {
923 // Check Selected Statement (if press ESC, Selection->Statement will be NULL)
925 Statement
= Selection
->Statement
;
926 if (Statement
!= NULL
) {
927 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_RESET_REQUIRED
) == EFI_IFR_FLAG_RESET_REQUIRED
) {
928 gResetRequired
= TRUE
;
932 // Reset FormPackage update flag
934 mHiiPackageListUpdated
= FALSE
;
936 if (((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) && (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
)) {
937 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
939 HiiValue
= &Statement
->HiiValue
;
940 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
942 // Create String in HII database for Configuration Driver to retrieve
944 HiiValue
->Value
.string
= NewString ((CHAR16
*) Statement
->BufferValue
, Selection
->FormSet
->HiiHandle
);
947 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
948 if (ConfigAccess
== NULL
) {
949 return EFI_UNSUPPORTED
;
951 Status
= ConfigAccess
->Callback (
953 EFI_BROWSER_ACTION_CHANGING
,
954 Statement
->QuestionId
,
960 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
962 // Clean the String in HII Database
964 DeleteString (HiiValue
->Value
.string
, Selection
->FormSet
->HiiHandle
);
967 if (!EFI_ERROR (Status
)) {
968 switch (ActionRequest
) {
969 case EFI_BROWSER_ACTION_REQUEST_RESET
:
970 gResetRequired
= TRUE
;
973 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
974 SubmitForm (Selection
->FormSet
, Selection
->Form
);
977 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
978 Selection
->Action
= UI_ACTION_EXIT
;
979 gNvUpdateRequired
= FALSE
;
989 // Check whether Form Package has been updated during Callback
991 if (mHiiPackageListUpdated
&& (Selection
->Action
== UI_ACTION_REFRESH_FORM
)) {
993 // Force to reparse IFR binary of target Formset
995 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
998 } while (Selection
->Action
== UI_ACTION_REFRESH_FORM
);
1001 // Record the old formset
1003 if (gOldFormSet
!= NULL
) {
1004 DestroyFormSet (gOldFormSet
);
1006 gOldFormSet
= FormSet
;
1010 // Unregister notify for Form package update
1012 Status
= mHiiDatabase
->UnregisterPackageNotify (