2 Utility functions for UI presentation.
4 Copyright (c) 2004 - 2010, 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.
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 @param String The input string to be counted.
114 @return Storage space for the input string.
124 UINTN IncrementValue
;
132 // Advance to the null-terminator or to the first width directive
135 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
136 Index
++, Count
= Count
+ IncrementValue
141 // We hit the null-terminator, we now have a count
143 if (String
[Index
] == 0) {
147 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
148 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
150 if (String
[Index
] == NARROW_CHAR
) {
152 // Skip to the next character
158 // Skip to the next character
163 } while (String
[Index
] != 0);
166 // Increment by one to include the null-terminator in the size
170 return Count
* sizeof (CHAR16
);
174 This function displays the page frame.
187 CHAR16
*StrFrontPageBanner
;
189 EFI_SCREEN_DESCRIPTOR LocalScreen
;
193 ZeroMem (&LocalScreen
, sizeof (EFI_SCREEN_DESCRIPTOR
));
194 gST
->ConOut
->QueryMode (gST
->ConOut
, gST
->ConOut
->Mode
->Mode
, &LocalScreen
.RightColumn
, &LocalScreen
.BottomRow
);
195 ClearLines (0, LocalScreen
.RightColumn
, 0, LocalScreen
.BottomRow
, KEYHELP_BACKGROUND
);
197 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
200 // For now, allocate an arbitrarily long buffer
202 Buffer
= AllocateZeroPool (0x10000);
203 ASSERT (Buffer
!= NULL
);
205 Character
= BOXDRAW_HORIZONTAL
;
207 for (Index
= 0; Index
+ 2 < (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
); Index
++) {
208 Buffer
[Index
] = Character
;
211 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) == FORMSET_CLASS_FRONT_PAGE
) {
213 // ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
216 LocalScreen
.LeftColumn
,
217 LocalScreen
.RightColumn
,
219 FRONT_PAGE_HEADER_HEIGHT
- 1 + LocalScreen
.TopRow
,
220 BANNER_TEXT
| BANNER_BACKGROUND
223 // for (Line = 0; Line < BANNER_HEIGHT; Line++) {
225 for (Line
= (UINT8
) LocalScreen
.TopRow
; Line
< BANNER_HEIGHT
+ (UINT8
) LocalScreen
.TopRow
; Line
++) {
227 // for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
229 for (Alignment
= (UINT8
) LocalScreen
.LeftColumn
;
230 Alignment
< BANNER_COLUMNS
+ (UINT8
) LocalScreen
.LeftColumn
;
233 RowIdx
= (UINT8
) (Line
- (UINT8
) LocalScreen
.TopRow
);
234 ColumnIdx
= (UINT8
) (Alignment
- (UINT8
) LocalScreen
.LeftColumn
);
236 ASSERT (RowIdx
< BANNER_HEIGHT
);
237 ASSERT (ColumnIdx
< BANNER_COLUMNS
);
239 if (gBannerData
->Banner
[RowIdx
][ColumnIdx
] != 0x0000) {
240 StrFrontPageBanner
= GetToken (
241 gBannerData
->Banner
[RowIdx
][ColumnIdx
],
248 switch (Alignment
- LocalScreen
.LeftColumn
) {
251 // Handle left column
253 PrintStringAt (LocalScreen
.LeftColumn
, Line
, StrFrontPageBanner
);
258 // Handle center column
261 LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3,
269 // Handle right column
272 LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3,
279 FreePool (StrFrontPageBanner
);
285 LocalScreen
.LeftColumn
,
286 LocalScreen
.RightColumn
,
287 LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
,
288 LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 1,
289 KEYHELP_TEXT
| KEYHELP_BACKGROUND
292 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) != FORMSET_CLASS_FRONT_PAGE
) {
294 LocalScreen
.LeftColumn
,
295 LocalScreen
.RightColumn
,
297 LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1,
298 TITLE_TEXT
| TITLE_BACKGROUND
301 // Print Top border line
302 // +------------------------------------------------------------------------------+
304 // +------------------------------------------------------------------------------+
306 Character
= BOXDRAW_DOWN_RIGHT
;
308 PrintChar (Character
);
309 PrintString (Buffer
);
311 Character
= BOXDRAW_DOWN_LEFT
;
312 PrintChar (Character
);
314 Character
= BOXDRAW_VERTICAL
;
315 for (Row
= LocalScreen
.TopRow
+ 1; Row
<= LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 2; Row
++) {
316 PrintCharAt (LocalScreen
.LeftColumn
, Row
, Character
);
317 PrintCharAt (LocalScreen
.RightColumn
- 1, Row
, Character
);
320 Character
= BOXDRAW_UP_RIGHT
;
321 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1, Character
);
322 PrintString (Buffer
);
324 Character
= BOXDRAW_UP_LEFT
;
325 PrintChar (Character
);
327 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
329 // Print Bottom border line
330 // +------------------------------------------------------------------------------+
332 // +------------------------------------------------------------------------------+
334 Character
= BOXDRAW_DOWN_RIGHT
;
335 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
, Character
);
337 PrintString (Buffer
);
339 Character
= BOXDRAW_DOWN_LEFT
;
340 PrintChar (Character
);
341 Character
= BOXDRAW_VERTICAL
;
342 for (Row
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- FOOTER_HEIGHT
+ 1;
343 Row
<= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 2;
346 PrintCharAt (LocalScreen
.LeftColumn
, Row
, Character
);
347 PrintCharAt (LocalScreen
.RightColumn
- 1, Row
, Character
);
350 Character
= BOXDRAW_UP_RIGHT
;
351 PrintCharAt (LocalScreen
.LeftColumn
, LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 1, Character
);
353 PrintString (Buffer
);
355 Character
= BOXDRAW_UP_LEFT
;
356 PrintChar (Character
);
366 Evaluate all expressions in a Form.
368 @param FormSet FormSet this Form belongs to.
369 @param Form The Form.
371 @retval EFI_SUCCESS The expression evaluated successfuly
375 EvaluateFormExpressions (
376 IN FORM_BROWSER_FORMSET
*FormSet
,
377 IN FORM_BROWSER_FORM
*Form
382 FORM_EXPRESSION
*Expression
;
384 Link
= GetFirstNode (&Form
->ExpressionListHead
);
385 while (!IsNull (&Form
->ExpressionListHead
, Link
)) {
386 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
387 Link
= GetNextNode (&Form
->ExpressionListHead
, Link
);
389 if (Expression
->Type
== EFI_HII_EXPRESSION_INCONSISTENT_IF
||
390 Expression
->Type
== EFI_HII_EXPRESSION_NO_SUBMIT_IF
||
391 Expression
->Type
== EFI_HII_EXPRESSION_WRITE
||
392 (Expression
->Type
== EFI_HII_EXPRESSION_READ
&& Form
->FormType
!= STANDARD_MAP_FORM_TYPE
)) {
394 // Postpone Form validation to Question editing or Form submitting or Question Write or Question Read for nonstandard form.
399 Status
= EvaluateExpression (FormSet
, Form
, Expression
);
400 if (EFI_ERROR (Status
)) {
409 +------------------------------------------------------------------------------+
411 +------------------------------------------------------------------------------+
429 +------------------------------------------------------------------------------+
430 ?F1=Scroll Help F9=Reset to Defaults F10=Save and Exit ?
431 | ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Discard Changes |
432 +------------------------------------------------------------------------------+
438 Display form and wait for user to select one menu option, then return it.
440 @param Selection On input, Selection tell setup browser the information
441 about the Selection, form and formset to be displayed.
442 On output, Selection return the screen item that is selected
444 @retval EFI_SUCESSS This function always return successfully for now.
449 IN OUT UI_MENU_SELECTION
*Selection
453 UINT16 MenuItemCount
;
454 EFI_HII_HANDLE Handle
;
456 EFI_SCREEN_DESCRIPTOR LocalScreen
;
459 CHAR16
*OutputString
;
461 FORM_BROWSER_STATEMENT
*Statement
;
462 UINT16 NumberOfLines
;
464 UI_MENU_OPTION
*MenuOption
;
466 Handle
= Selection
->Handle
;
473 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
475 StringPtr
= GetToken (Selection
->Form
->FormTitle
, Handle
);
477 if ((gClassOfVfr
& FORMSET_CLASS_FRONT_PAGE
) != FORMSET_CLASS_FRONT_PAGE
) {
478 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| TITLE_BACKGROUND
);
480 (LocalScreen
.RightColumn
+ LocalScreen
.LeftColumn
- GetStringWidth (StringPtr
) / 2) / 2,
481 LocalScreen
.TopRow
+ 1,
487 // Remove Buffer allocated for StringPtr after it has been used.
489 FreePool (StringPtr
);
492 // Evaluate all the Expressions in this Form
494 Status
= EvaluateFormExpressions (Selection
->FormSet
, Selection
->Form
);
495 if (EFI_ERROR (Status
)) {
499 Selection
->FormEditable
= FALSE
;
500 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
501 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
502 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
504 if (Statement
->SuppressExpression
!= NULL
) {
505 Suppress
= Statement
->SuppressExpression
->Result
.Value
.b
;
510 if (Statement
->DisableExpression
!= NULL
) {
511 Suppress
= (BOOLEAN
) (Suppress
|| Statement
->DisableExpression
->Result
.Value
.b
);
515 StringPtr
= GetToken (Statement
->Prompt
, Handle
);
517 Width
= GetWidth (Statement
, Handle
);
521 for (; GetLineByWidth (StringPtr
, Width
, &ArrayEntry
, &OutputString
) != 0x0000;) {
523 // If there is more string to process print on the next row and increment the Skip value
525 if (StrLen (&StringPtr
[ArrayEntry
]) != 0) {
529 FreePool (OutputString
);
533 // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do
536 MenuOption
= UiAddMenuOption (StringPtr
, Selection
->Handle
, Statement
, NumberOfLines
, MenuItemCount
);
539 if (MenuOption
->IsQuestion
&& !MenuOption
->ReadOnly
) {
541 // At least one item is not readonly, this Form is considered as editable
543 Selection
->FormEditable
= TRUE
;
547 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
550 Status
= UiDisplayMenu (Selection
);
558 Initialize the HII String Token to the correct values.
562 InitializeBrowserStrings (
566 gFunctionNineString
= GetToken (STRING_TOKEN (FUNCTION_NINE_STRING
), gHiiHandle
);
567 gFunctionTenString
= GetToken (STRING_TOKEN (FUNCTION_TEN_STRING
), gHiiHandle
);
568 gEnterString
= GetToken (STRING_TOKEN (ENTER_STRING
), gHiiHandle
);
569 gEnterCommitString
= GetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), gHiiHandle
);
570 gEnterEscapeString
= GetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), gHiiHandle
);
571 gEscapeString
= GetToken (STRING_TOKEN (ESCAPE_STRING
), gHiiHandle
);
572 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
573 gMoveHighlight
= GetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), gHiiHandle
);
574 gMakeSelection
= GetToken (STRING_TOKEN (MAKE_SELECTION
), gHiiHandle
);
575 gDecNumericInput
= GetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), gHiiHandle
);
576 gHexNumericInput
= GetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), gHiiHandle
);
577 gToggleCheckBox
= GetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), gHiiHandle
);
578 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
579 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
580 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
581 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
582 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
583 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
584 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
585 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
586 gAreYouSure
= GetToken (STRING_TOKEN (ARE_YOU_SURE
), gHiiHandle
);
587 gYesResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), gHiiHandle
);
588 gNoResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), gHiiHandle
);
589 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
590 gPlusString
= GetToken (STRING_TOKEN (PLUS_STRING
), gHiiHandle
);
591 gMinusString
= GetToken (STRING_TOKEN (MINUS_STRING
), gHiiHandle
);
592 gAdjustNumber
= GetToken (STRING_TOKEN (ADJUST_NUMBER
), gHiiHandle
);
593 gSaveChanges
= GetToken (STRING_TOKEN (SAVE_CHANGES
), gHiiHandle
);
594 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
595 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
600 Free up the resource allocated for all strings required
609 FreePool (gFunctionNineString
);
610 FreePool (gFunctionTenString
);
611 FreePool (gEnterString
);
612 FreePool (gEnterCommitString
);
613 FreePool (gEnterEscapeString
);
614 FreePool (gEscapeString
);
615 FreePool (gMoveHighlight
);
616 FreePool (gMakeSelection
);
617 FreePool (gDecNumericInput
);
618 FreePool (gHexNumericInput
);
619 FreePool (gToggleCheckBox
);
620 FreePool (gPromptForData
);
621 FreePool (gPromptForPassword
);
622 FreePool (gPromptForNewPassword
);
623 FreePool (gConfirmPassword
);
624 FreePool (gPassowordInvalid
);
625 FreePool (gConfirmError
);
626 FreePool (gPressEnter
);
627 FreePool (gEmptyString
);
628 FreePool (gAreYouSure
);
629 FreePool (gYesResponse
);
630 FreePool (gNoResponse
);
631 FreePool (gMiniString
);
632 FreePool (gPlusString
);
633 FreePool (gMinusString
);
634 FreePool (gAdjustNumber
);
635 FreePool (gSaveChanges
);
636 FreePool (gOptionMismatch
);
637 FreePool (gFormSuppress
);
643 Update key's help imformation.
645 @param Selection Tell setup browser the information about the Selection
646 @param MenuOption The Menu option
647 @param Selected Whether or not a tag be selected
652 IN UI_MENU_SELECTION
*Selection
,
653 IN UI_MENU_OPTION
*MenuOption
,
659 UINTN LeftColumnOfHelp
;
660 UINTN RightColumnOfHelp
;
662 UINTN BottomRowOfHelp
;
663 UINTN StartColumnOfHelp
;
664 EFI_SCREEN_DESCRIPTOR LocalScreen
;
665 FORM_BROWSER_STATEMENT
*Statement
;
667 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
669 SecCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
670 ThdCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3;
672 StartColumnOfHelp
= LocalScreen
.LeftColumn
+ 2;
673 LeftColumnOfHelp
= LocalScreen
.LeftColumn
+ 1;
674 RightColumnOfHelp
= LocalScreen
.RightColumn
- 2;
675 TopRowOfHelp
= LocalScreen
.BottomRow
- 4;
676 BottomRowOfHelp
= LocalScreen
.BottomRow
- 3;
678 gST
->ConOut
->SetAttribute (gST
->ConOut
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
680 Statement
= MenuOption
->ThisTag
;
681 switch (Statement
->Operand
) {
682 case EFI_IFR_ORDERED_LIST_OP
:
683 case EFI_IFR_ONE_OF_OP
:
684 case EFI_IFR_NUMERIC_OP
:
685 case EFI_IFR_TIME_OP
:
686 case EFI_IFR_DATE_OP
:
687 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
690 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
691 if (Selection
->FormEditable
) {
692 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
693 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
695 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
698 if ((Statement
->Operand
== EFI_IFR_DATE_OP
) ||
699 (Statement
->Operand
== EFI_IFR_TIME_OP
)) {
710 PrintStringAt (SecCol
, BottomRowOfHelp
, gAdjustNumber
);
712 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
713 if (Statement
->Operand
== EFI_IFR_NUMERIC_OP
&& Statement
->Step
!= 0) {
714 PrintStringAt (SecCol
, BottomRowOfHelp
, gAdjustNumber
);
716 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
720 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterCommitString
);
723 // If it is a selected numeric with manual input, display different message
725 if ((Statement
->Operand
== EFI_IFR_NUMERIC_OP
) && (Statement
->Step
== 0)) {
729 ((Statement
->Flags
& EFI_IFR_DISPLAY_UINT_HEX
) == EFI_IFR_DISPLAY_UINT_HEX
) ? gHexNumericInput
: gDecNumericInput
731 } else if (Statement
->Operand
!= EFI_IFR_ORDERED_LIST_OP
) {
732 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
735 if (Statement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) {
736 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gPlusString
);
737 PrintStringAt (ThdCol
, TopRowOfHelp
, gMinusString
);
740 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
744 case EFI_IFR_CHECKBOX_OP
:
745 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
747 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
748 if (Selection
->FormEditable
) {
749 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
750 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
752 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
755 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
756 PrintStringAt (SecCol
, BottomRowOfHelp
, gToggleCheckBox
);
760 case EFI_IFR_PASSWORD_OP
:
761 case EFI_IFR_STRING_OP
:
762 case EFI_IFR_TEXT_OP
:
763 case EFI_IFR_ACTION_OP
:
764 case EFI_IFR_RESET_BUTTON_OP
:
765 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
768 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
769 if (Selection
->FormEditable
) {
770 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
771 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
773 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
776 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
777 if (Statement
->Operand
!= EFI_IFR_TEXT_OP
) {
778 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
781 if (Statement
->Operand
!= EFI_IFR_REF_OP
) {
783 (LocalScreen
.RightColumn
- GetStringWidth (gEnterCommitString
) / 2) / 2,
787 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
798 Functions which are registered to receive notification of
799 database events have this prototype. The actual event is encoded
800 in NotifyType. The following table describes how PackageType,
801 PackageGuid, Handle, and Package are used for each of the
804 @param PackageType Package type of the notification.
806 @param PackageGuid If PackageType is
807 EFI_HII_PACKAGE_TYPE_GUID, then this is
808 the pointer to the GUID from the Guid
809 field of EFI_HII_PACKAGE_GUID_HEADER.
810 Otherwise, it must be NULL.
812 @param Package Points to the package referred to by the
813 notification Handle The handle of the package
814 list which contains the specified package.
816 @param Handle The HII handle.
818 @param NotifyType The type of change concerning the
820 EFI_HII_DATABASE_NOTIFY_TYPE.
826 IN UINT8 PackageType
,
827 IN CONST EFI_GUID
*PackageGuid
,
828 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
829 IN EFI_HII_HANDLE Handle
,
830 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
833 mHiiPackageListUpdated
= TRUE
;
839 The worker function that send the displays to the screen. On output,
840 the selection made by user is returned.
842 @param Selection On input, Selection tell setup browser the information
843 about the Selection, form and formset to be displayed.
844 On output, Selection return the screen item that is selected
847 @retval EFI_SUCCESS The page is displayed successfully.
848 @return Other value if the page failed to be diplayed.
853 IN OUT UI_MENU_SELECTION
*Selection
858 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
859 EFI_HANDLE NotifyHandle
;
860 EFI_HII_VALUE
*HiiValue
;
861 EFI_IFR_TYPE_VALUE
*TypeValue
;
862 FORM_BROWSER_STATEMENT
*Statement
;
863 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
864 FORM_BROWSER_FORMSET
*FormSet
;
867 gMenuRefreshHead
= NULL
;
868 gResetRequired
= FALSE
;
869 FormSet
= Selection
->FormSet
;
872 // Register notify for Form package update
874 Status
= mHiiDatabase
->RegisterPackageNotify (
876 EFI_HII_PACKAGE_FORMS
,
879 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
882 if (EFI_ERROR (Status
)) {
887 // Before display the formset, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN
889 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
890 if ((ConfigAccess
!= NULL
) && (Selection
->Action
!= UI_ACTION_REFRESH_FORMSET
)) {
891 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
892 mHiiPackageListUpdated
= FALSE
;
893 Status
= ConfigAccess
->Callback (
895 EFI_BROWSER_ACTION_FORM_OPEN
,
897 EFI_IFR_TYPE_UNDEFINED
,
902 if (!EFI_ERROR (Status
)) {
903 switch (ActionRequest
) {
904 case EFI_BROWSER_ACTION_REQUEST_RESET
:
905 gResetRequired
= TRUE
;
908 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
910 // Till now there is no uncommitted data, so ignore this request
914 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
915 Selection
->Action
= UI_ACTION_EXIT
;
923 if (mHiiPackageListUpdated
) {
925 // IFR is updated during callback, force to reparse the IFR binary
927 mHiiPackageListUpdated
= FALSE
;
928 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
934 // Initialize current settings of Questions in this FormSet
936 Status
= InitializeCurrentSetting (Selection
->FormSet
);
937 if (EFI_ERROR (Status
)) {
938 Selection
->Action
= UI_ACTION_EXIT
;
944 // Initialize Selection->Form
946 if (Selection
->FormId
== 0) {
948 // Zero FormId indicates display the first Form in a FormSet
950 Link
= GetFirstNode (&Selection
->FormSet
->FormListHead
);
952 Selection
->Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
953 Selection
->FormId
= Selection
->Form
->FormId
;
955 Selection
->Form
= IdToForm (Selection
->FormSet
, Selection
->FormId
);
958 if (Selection
->Form
== NULL
) {
960 // No Form to display
962 return EFI_NOT_FOUND
;
966 // Check Form is suppressed.
968 if (Selection
->Form
->SuppressExpression
!= NULL
) {
969 Status
= EvaluateExpression (Selection
->FormSet
, Selection
->Form
, Selection
->Form
->SuppressExpression
);
970 if (EFI_ERROR (Status
)) {
974 if (Selection
->Form
->SuppressExpression
->Result
.Value
.b
) {
976 // Form is suppressed.
979 CreateDialog (4, TRUE
, 0, NULL
, &Key
, gEmptyString
, gFormSuppress
, gPressEnter
, gEmptyString
);
980 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
982 return EFI_NOT_FOUND
;
987 // Reset FormPackage update flag
989 mHiiPackageListUpdated
= FALSE
;
992 // Load Questions' Value for display
994 Status
= LoadFormSetConfig (Selection
, Selection
->FormSet
);
995 if (EFI_ERROR (Status
)) {
1000 // IFR is updated during callback of read value, force to reparse the IFR binary
1002 if (mHiiPackageListUpdated
) {
1003 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1004 mHiiPackageListUpdated
= FALSE
;
1009 // Displays the Header and Footer borders
1011 DisplayPageFrame ();
1016 Status
= DisplayForm (Selection
);
1017 if (EFI_ERROR (Status
)) {
1022 // Check Selected Statement (if press ESC, Selection->Statement will be NULL)
1024 Statement
= Selection
->Statement
;
1025 if (Statement
!= NULL
) {
1026 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_RESET_REQUIRED
) == EFI_IFR_FLAG_RESET_REQUIRED
) {
1027 gResetRequired
= TRUE
;
1031 // Reset FormPackage update flag
1033 mHiiPackageListUpdated
= FALSE
;
1035 if (((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) && (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
)) {
1036 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1038 if (ConfigAccess
== NULL
) {
1039 return EFI_UNSUPPORTED
;
1042 HiiValue
= &Statement
->HiiValue
;
1043 TypeValue
= &HiiValue
->Value
;
1044 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
1046 // Create String in HII database for Configuration Driver to retrieve
1048 HiiValue
->Value
.string
= NewString ((CHAR16
*) Statement
->BufferValue
, Selection
->FormSet
->HiiHandle
);
1049 } else if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
1051 // For OrderedList, passing in the value buffer to Callback()
1053 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Statement
->BufferValue
;
1056 Status
= ConfigAccess
->Callback (
1058 EFI_BROWSER_ACTION_CHANGING
,
1059 Statement
->QuestionId
,
1065 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
1067 // Clean the String in HII Database
1069 DeleteString (HiiValue
->Value
.string
, Selection
->FormSet
->HiiHandle
);
1072 if (!EFI_ERROR (Status
)) {
1073 switch (ActionRequest
) {
1074 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1075 gResetRequired
= TRUE
;
1078 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1079 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1082 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1083 Selection
->Action
= UI_ACTION_EXIT
;
1084 gNvUpdateRequired
= FALSE
;
1090 } else if (Status
!= EFI_UNSUPPORTED
) {
1092 // Callback return error status other than EFI_UNSUPPORTED
1094 if (Statement
->Operand
== EFI_IFR_REF_OP
) {
1096 // Cross reference will not be taken
1098 Selection
->FormId
= Selection
->Form
->FormId
;
1099 Selection
->QuestionId
= 0;
1105 // Check whether Form Package has been updated during Callback
1107 if (mHiiPackageListUpdated
&& (Selection
->Action
== UI_ACTION_REFRESH_FORM
)) {
1109 // Force to reparse IFR binary of target Formset
1111 mHiiPackageListUpdated
= FALSE
;
1112 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1115 } while (Selection
->Action
== UI_ACTION_REFRESH_FORM
);
1118 // Before exit the formset, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE
1120 if ((ConfigAccess
!= NULL
) && (Selection
->Action
== UI_ACTION_EXIT
)) {
1121 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1122 Status
= ConfigAccess
->Callback (
1124 EFI_BROWSER_ACTION_FORM_CLOSE
,
1126 EFI_IFR_TYPE_UNDEFINED
,
1131 if (!EFI_ERROR (Status
)) {
1132 switch (ActionRequest
) {
1133 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1134 gResetRequired
= TRUE
;
1137 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1138 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1141 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1142 gNvUpdateRequired
= FALSE
;
1152 // Record the old formset
1154 if (gOldFormSet
!= NULL
) {
1155 DestroyFormSet (gOldFormSet
);
1157 gOldFormSet
= FormSet
;
1161 // Unregister notify for Form package update
1163 Status
= mHiiDatabase
->UnregisterPackageNotify (