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
) {
392 // Postpone Form validation to Question editing or Form submiting
397 Status
= EvaluateExpression (FormSet
, Form
, Expression
);
398 if (EFI_ERROR (Status
)) {
407 +------------------------------------------------------------------------------+
409 +------------------------------------------------------------------------------+
427 +------------------------------------------------------------------------------+
428 ?F1=Scroll Help F9=Reset to Defaults F10=Save and Exit ?
429 | ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Discard Changes |
430 +------------------------------------------------------------------------------+
436 Display form and wait for user to select one menu option, then return it.
438 @param Selection On input, Selection tell setup browser the information
439 about the Selection, form and formset to be displayed.
440 On output, Selection return the screen item that is selected
442 @retval EFI_SUCESSS This function always return successfully for now.
447 IN OUT UI_MENU_SELECTION
*Selection
451 UINT16 MenuItemCount
;
452 EFI_HII_HANDLE Handle
;
454 EFI_SCREEN_DESCRIPTOR LocalScreen
;
457 CHAR16
*OutputString
;
459 FORM_BROWSER_STATEMENT
*Statement
;
460 UINT16 NumberOfLines
;
462 UI_MENU_OPTION
*MenuOption
;
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
) != 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 Selection
->FormEditable
= FALSE
;
498 Link
= GetFirstNode (&Selection
->Form
->StatementListHead
);
499 while (!IsNull (&Selection
->Form
->StatementListHead
, Link
)) {
500 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
502 if (Statement
->SuppressExpression
!= NULL
) {
503 Suppress
= Statement
->SuppressExpression
->Result
.Value
.b
;
508 if (Statement
->DisableExpression
!= NULL
) {
509 Suppress
= (BOOLEAN
) (Suppress
|| Statement
->DisableExpression
->Result
.Value
.b
);
513 StringPtr
= GetToken (Statement
->Prompt
, Handle
);
515 Width
= GetWidth (Statement
, Handle
);
519 for (; GetLineByWidth (StringPtr
, Width
, &ArrayEntry
, &OutputString
) != 0x0000;) {
521 // If there is more string to process print on the next row and increment the Skip value
523 if (StrLen (&StringPtr
[ArrayEntry
]) != 0) {
527 FreePool (OutputString
);
531 // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do
534 MenuOption
= UiAddMenuOption (StringPtr
, Selection
->Handle
, Statement
, NumberOfLines
, MenuItemCount
);
537 if (MenuOption
->IsQuestion
&& !MenuOption
->ReadOnly
) {
539 // At least one item is not readonly, this Form is considered as editable
541 Selection
->FormEditable
= TRUE
;
545 Link
= GetNextNode (&Selection
->Form
->StatementListHead
, Link
);
548 Status
= UiDisplayMenu (Selection
);
556 Initialize the HII String Token to the correct values.
560 InitializeBrowserStrings (
564 gFunctionNineString
= GetToken (STRING_TOKEN (FUNCTION_NINE_STRING
), gHiiHandle
);
565 gFunctionTenString
= GetToken (STRING_TOKEN (FUNCTION_TEN_STRING
), gHiiHandle
);
566 gEnterString
= GetToken (STRING_TOKEN (ENTER_STRING
), gHiiHandle
);
567 gEnterCommitString
= GetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), gHiiHandle
);
568 gEnterEscapeString
= GetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), gHiiHandle
);
569 gEscapeString
= GetToken (STRING_TOKEN (ESCAPE_STRING
), gHiiHandle
);
570 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
571 gMoveHighlight
= GetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), gHiiHandle
);
572 gMakeSelection
= GetToken (STRING_TOKEN (MAKE_SELECTION
), gHiiHandle
);
573 gDecNumericInput
= GetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), gHiiHandle
);
574 gHexNumericInput
= GetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), gHiiHandle
);
575 gToggleCheckBox
= GetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), gHiiHandle
);
576 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
577 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
578 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
579 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
580 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
581 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
582 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
583 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
584 gAreYouSure
= GetToken (STRING_TOKEN (ARE_YOU_SURE
), gHiiHandle
);
585 gYesResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), gHiiHandle
);
586 gNoResponse
= GetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), gHiiHandle
);
587 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
588 gPlusString
= GetToken (STRING_TOKEN (PLUS_STRING
), gHiiHandle
);
589 gMinusString
= GetToken (STRING_TOKEN (MINUS_STRING
), gHiiHandle
);
590 gAdjustNumber
= GetToken (STRING_TOKEN (ADJUST_NUMBER
), gHiiHandle
);
591 gSaveChanges
= GetToken (STRING_TOKEN (SAVE_CHANGES
), gHiiHandle
);
592 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
593 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
598 Free up the resource allocated for all strings required
607 FreePool (gFunctionNineString
);
608 FreePool (gFunctionTenString
);
609 FreePool (gEnterString
);
610 FreePool (gEnterCommitString
);
611 FreePool (gEnterEscapeString
);
612 FreePool (gEscapeString
);
613 FreePool (gMoveHighlight
);
614 FreePool (gMakeSelection
);
615 FreePool (gDecNumericInput
);
616 FreePool (gHexNumericInput
);
617 FreePool (gToggleCheckBox
);
618 FreePool (gPromptForData
);
619 FreePool (gPromptForPassword
);
620 FreePool (gPromptForNewPassword
);
621 FreePool (gConfirmPassword
);
622 FreePool (gPassowordInvalid
);
623 FreePool (gConfirmError
);
624 FreePool (gPressEnter
);
625 FreePool (gEmptyString
);
626 FreePool (gAreYouSure
);
627 FreePool (gYesResponse
);
628 FreePool (gNoResponse
);
629 FreePool (gMiniString
);
630 FreePool (gPlusString
);
631 FreePool (gMinusString
);
632 FreePool (gAdjustNumber
);
633 FreePool (gSaveChanges
);
634 FreePool (gOptionMismatch
);
635 FreePool (gFormSuppress
);
641 Update key's help imformation.
643 @param Selection Tell setup browser the information about the Selection
644 @param MenuOption The Menu option
645 @param Selected Whether or not a tag be selected
650 IN UI_MENU_SELECTION
*Selection
,
651 IN UI_MENU_OPTION
*MenuOption
,
657 UINTN LeftColumnOfHelp
;
658 UINTN RightColumnOfHelp
;
660 UINTN BottomRowOfHelp
;
661 UINTN StartColumnOfHelp
;
662 EFI_SCREEN_DESCRIPTOR LocalScreen
;
663 FORM_BROWSER_STATEMENT
*Statement
;
665 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
667 SecCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
668 ThdCol
= LocalScreen
.LeftColumn
+ (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) * 2 / 3;
670 StartColumnOfHelp
= LocalScreen
.LeftColumn
+ 2;
671 LeftColumnOfHelp
= LocalScreen
.LeftColumn
+ 1;
672 RightColumnOfHelp
= LocalScreen
.RightColumn
- 2;
673 TopRowOfHelp
= LocalScreen
.BottomRow
- 4;
674 BottomRowOfHelp
= LocalScreen
.BottomRow
- 3;
676 gST
->ConOut
->SetAttribute (gST
->ConOut
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
678 Statement
= MenuOption
->ThisTag
;
679 switch (Statement
->Operand
) {
680 case EFI_IFR_ORDERED_LIST_OP
:
681 case EFI_IFR_ONE_OF_OP
:
682 case EFI_IFR_NUMERIC_OP
:
683 case EFI_IFR_TIME_OP
:
684 case EFI_IFR_DATE_OP
:
685 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
688 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
689 if (Selection
->FormEditable
) {
690 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
691 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
693 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
696 if ((Statement
->Operand
== EFI_IFR_DATE_OP
) ||
697 (Statement
->Operand
== EFI_IFR_TIME_OP
)) {
708 PrintStringAt (SecCol
, BottomRowOfHelp
, gAdjustNumber
);
710 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
711 if (Statement
->Operand
== EFI_IFR_NUMERIC_OP
&& Statement
->Step
!= 0) {
712 PrintStringAt (SecCol
, BottomRowOfHelp
, gAdjustNumber
);
714 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
718 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterCommitString
);
721 // If it is a selected numeric with manual input, display different message
723 if ((Statement
->Operand
== EFI_IFR_NUMERIC_OP
) && (Statement
->Step
== 0)) {
727 ((Statement
->Flags
& EFI_IFR_DISPLAY_UINT_HEX
) == EFI_IFR_DISPLAY_UINT_HEX
) ? gHexNumericInput
: gDecNumericInput
729 } else if (Statement
->Operand
!= EFI_IFR_ORDERED_LIST_OP
) {
730 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
733 if (Statement
->Operand
== EFI_IFR_ORDERED_LIST_OP
) {
734 PrintStringAt (StartColumnOfHelp
, TopRowOfHelp
, gPlusString
);
735 PrintStringAt (ThdCol
, TopRowOfHelp
, gMinusString
);
738 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
742 case EFI_IFR_CHECKBOX_OP
:
743 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
745 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
746 if (Selection
->FormEditable
) {
747 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
748 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
750 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
753 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
754 PrintStringAt (SecCol
, BottomRowOfHelp
, gToggleCheckBox
);
758 case EFI_IFR_PASSWORD_OP
:
759 case EFI_IFR_STRING_OP
:
760 case EFI_IFR_TEXT_OP
:
761 case EFI_IFR_ACTION_OP
:
762 case EFI_IFR_RESET_BUTTON_OP
:
763 ClearLines (LeftColumnOfHelp
, RightColumnOfHelp
, TopRowOfHelp
, BottomRowOfHelp
, KEYHELP_TEXT
| KEYHELP_BACKGROUND
);
766 if ((gClassOfVfr
& FORMSET_CLASS_PLATFORM_SETUP
) == FORMSET_CLASS_PLATFORM_SETUP
) {
767 if (Selection
->FormEditable
) {
768 PrintStringAt (SecCol
, TopRowOfHelp
, gFunctionNineString
);
769 PrintStringAt (ThdCol
, TopRowOfHelp
, gFunctionTenString
);
771 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEscapeString
);
774 PrintAt (StartColumnOfHelp
, BottomRowOfHelp
, L
"%c%c%s", ARROW_UP
, ARROW_DOWN
, gMoveHighlight
);
775 if (Statement
->Operand
!= EFI_IFR_TEXT_OP
) {
776 PrintStringAt (SecCol
, BottomRowOfHelp
, gEnterString
);
779 if (Statement
->Operand
!= EFI_IFR_REF_OP
) {
781 (LocalScreen
.RightColumn
- GetStringWidth (gEnterCommitString
) / 2) / 2,
785 PrintStringAt (ThdCol
, BottomRowOfHelp
, gEnterEscapeString
);
796 Functions which are registered to receive notification of
797 database events have this prototype. The actual event is encoded
798 in NotifyType. The following table describes how PackageType,
799 PackageGuid, Handle, and Package are used for each of the
802 @param PackageType Package type of the notification.
804 @param PackageGuid If PackageType is
805 EFI_HII_PACKAGE_TYPE_GUID, then this is
806 the pointer to the GUID from the Guid
807 field of EFI_HII_PACKAGE_GUID_HEADER.
808 Otherwise, it must be NULL.
810 @param Package Points to the package referred to by the
811 notification Handle The handle of the package
812 list which contains the specified package.
814 @param Handle The HII handle.
816 @param NotifyType The type of change concerning the
818 EFI_HII_DATABASE_NOTIFY_TYPE.
824 IN UINT8 PackageType
,
825 IN CONST EFI_GUID
*PackageGuid
,
826 IN CONST EFI_HII_PACKAGE_HEADER
*Package
,
827 IN EFI_HII_HANDLE Handle
,
828 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
831 mHiiPackageListUpdated
= TRUE
;
837 The worker function that send the displays to the screen. On output,
838 the selection made by user is returned.
840 @param Selection On input, Selection tell setup browser the information
841 about the Selection, form and formset to be displayed.
842 On output, Selection return the screen item that is selected
845 @retval EFI_SUCCESS The page is displayed successfully.
846 @return Other value if the page failed to be diplayed.
851 IN OUT UI_MENU_SELECTION
*Selection
856 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
857 EFI_HANDLE NotifyHandle
;
858 EFI_HII_VALUE
*HiiValue
;
859 EFI_IFR_TYPE_VALUE
*TypeValue
;
860 FORM_BROWSER_STATEMENT
*Statement
;
861 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
862 FORM_BROWSER_FORMSET
*FormSet
;
865 gMenuRefreshHead
= NULL
;
866 gResetRequired
= FALSE
;
867 FormSet
= Selection
->FormSet
;
870 // Register notify for Form package update
872 Status
= mHiiDatabase
->RegisterPackageNotify (
874 EFI_HII_PACKAGE_FORMS
,
877 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK
,
880 if (EFI_ERROR (Status
)) {
885 // Before display the formset, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN
887 ConfigAccess
= Selection
->FormSet
->ConfigAccess
;
888 if ((ConfigAccess
!= NULL
) && (Selection
->Action
!= UI_ACTION_REFRESH_FORMSET
)) {
889 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
890 mHiiPackageListUpdated
= FALSE
;
891 Status
= ConfigAccess
->Callback (
893 EFI_BROWSER_ACTION_FORM_OPEN
,
895 EFI_IFR_TYPE_UNDEFINED
,
900 if (!EFI_ERROR (Status
)) {
901 switch (ActionRequest
) {
902 case EFI_BROWSER_ACTION_REQUEST_RESET
:
903 gResetRequired
= TRUE
;
906 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
908 // Till now there is no uncommitted data, so ignore this request
912 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
913 Selection
->Action
= UI_ACTION_EXIT
;
921 if (mHiiPackageListUpdated
) {
923 // IFR is updated during callback, force to reparse the IFR binary
925 mHiiPackageListUpdated
= FALSE
;
926 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
932 // Initialize current settings of Questions in this FormSet
934 Status
= InitializeCurrentSetting (Selection
->FormSet
);
935 if (EFI_ERROR (Status
)) {
936 Selection
->Action
= UI_ACTION_EXIT
;
942 // Initialize Selection->Form
944 if (Selection
->FormId
== 0) {
946 // Zero FormId indicates display the first Form in a FormSet
948 Link
= GetFirstNode (&Selection
->FormSet
->FormListHead
);
950 Selection
->Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
951 Selection
->FormId
= Selection
->Form
->FormId
;
953 Selection
->Form
= IdToForm (Selection
->FormSet
, Selection
->FormId
);
956 if (Selection
->Form
== NULL
) {
958 // No Form to display
960 return EFI_NOT_FOUND
;
964 // Check Form is suppressed.
966 if (Selection
->Form
->SuppressExpression
!= NULL
) {
967 Status
= EvaluateExpression (Selection
->FormSet
, Selection
->Form
, Selection
->Form
->SuppressExpression
);
968 if (EFI_ERROR (Status
)) {
972 if (Selection
->Form
->SuppressExpression
->Result
.Value
.b
) {
974 // Form is suppressed.
977 CreateDialog (4, TRUE
, 0, NULL
, &Key
, gEmptyString
, gFormSuppress
, gPressEnter
, gEmptyString
);
978 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
980 return EFI_NOT_FOUND
;
985 // Reset FormPackage update flag
987 mHiiPackageListUpdated
= FALSE
;
990 // Load Questions' Value for display
992 Status
= LoadFormSetConfig (Selection
, Selection
->FormSet
);
993 if (EFI_ERROR (Status
)) {
998 // IFR is updated during callback of read value, force to reparse the IFR binary
1000 if (mHiiPackageListUpdated
) {
1001 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1002 mHiiPackageListUpdated
= FALSE
;
1007 // Displays the Header and Footer borders
1009 DisplayPageFrame ();
1014 Status
= DisplayForm (Selection
);
1015 if (EFI_ERROR (Status
)) {
1020 // Check Selected Statement (if press ESC, Selection->Statement will be NULL)
1022 Statement
= Selection
->Statement
;
1023 if (Statement
!= NULL
) {
1024 if ((Statement
->QuestionFlags
& EFI_IFR_FLAG_RESET_REQUIRED
) == EFI_IFR_FLAG_RESET_REQUIRED
) {
1025 gResetRequired
= TRUE
;
1029 // Reset FormPackage update flag
1031 mHiiPackageListUpdated
= FALSE
;
1033 if (((Statement
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) && (Statement
->Operand
!= EFI_IFR_PASSWORD_OP
)) {
1034 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1036 if (ConfigAccess
== NULL
) {
1037 return EFI_UNSUPPORTED
;
1040 HiiValue
= &Statement
->HiiValue
;
1041 TypeValue
= &HiiValue
->Value
;
1042 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
1044 // Create String in HII database for Configuration Driver to retrieve
1046 HiiValue
->Value
.string
= NewString ((CHAR16
*) Statement
->BufferValue
, Selection
->FormSet
->HiiHandle
);
1047 } else if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
1049 // For OrderedList, passing in the value buffer to Callback()
1051 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Statement
->BufferValue
;
1054 Status
= ConfigAccess
->Callback (
1056 EFI_BROWSER_ACTION_CHANGING
,
1057 Statement
->QuestionId
,
1063 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
1065 // Clean the String in HII Database
1067 DeleteString (HiiValue
->Value
.string
, Selection
->FormSet
->HiiHandle
);
1070 if (!EFI_ERROR (Status
)) {
1071 switch (ActionRequest
) {
1072 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1073 gResetRequired
= TRUE
;
1076 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1077 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1080 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1081 Selection
->Action
= UI_ACTION_EXIT
;
1082 gNvUpdateRequired
= FALSE
;
1088 } else if (Status
!= EFI_UNSUPPORTED
) {
1090 // Callback return error status other than EFI_UNSUPPORTED
1092 if (Statement
->Operand
== EFI_IFR_REF_OP
) {
1094 // Cross reference will not be taken
1096 Selection
->FormId
= Selection
->Form
->FormId
;
1097 Selection
->QuestionId
= 0;
1103 // Check whether Form Package has been updated during Callback
1105 if (mHiiPackageListUpdated
&& (Selection
->Action
== UI_ACTION_REFRESH_FORM
)) {
1107 // Force to reparse IFR binary of target Formset
1109 mHiiPackageListUpdated
= FALSE
;
1110 Selection
->Action
= UI_ACTION_REFRESH_FORMSET
;
1113 } while (Selection
->Action
== UI_ACTION_REFRESH_FORM
);
1116 // Before exit the formset, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE
1118 if ((ConfigAccess
!= NULL
) && (Selection
->Action
== UI_ACTION_EXIT
)) {
1119 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1120 Status
= ConfigAccess
->Callback (
1122 EFI_BROWSER_ACTION_FORM_CLOSE
,
1124 EFI_IFR_TYPE_UNDEFINED
,
1129 if (!EFI_ERROR (Status
)) {
1130 switch (ActionRequest
) {
1131 case EFI_BROWSER_ACTION_REQUEST_RESET
:
1132 gResetRequired
= TRUE
;
1135 case EFI_BROWSER_ACTION_REQUEST_SUBMIT
:
1136 SubmitForm (Selection
->FormSet
, Selection
->Form
);
1139 case EFI_BROWSER_ACTION_REQUEST_EXIT
:
1140 gNvUpdateRequired
= FALSE
;
1150 // Record the old formset
1152 if (gOldFormSet
!= NULL
) {
1153 DestroyFormSet (gOldFormSet
);
1155 gOldFormSet
= FormSet
;
1159 // Unregister notify for Form package update
1161 Status
= mHiiDatabase
->UnregisterPackageNotify (