2 Entry and initialization module for the browser.
4 Copyright (c) 2007 - 2014, 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.
15 #include "FormDisplay.h"
18 // Search table for UiDisplayMenu()
20 SCAN_CODE_TO_SCREEN_OPERATION gScanCodeToOperation
[] = {
51 UINTN mScanCodeNumber
= sizeof (gScanCodeToOperation
) / sizeof (gScanCodeToOperation
[0]);
53 SCREEN_OPERATION_T0_CONTROL_FLAG gScreenOperationToControlFlag
[] = {
96 EFI_GUID gDisplayEngineGuid
= {
97 0xE38C1029, 0xE38F, 0x45b9, {0x8F, 0x0D, 0xE2, 0xE6, 0x0B, 0xC9, 0xB2, 0x62}
100 FORM_ENTRY_INFO gFormEntryInfo
;
102 EFI_SCREEN_DESCRIPTOR gStatementDimensions
;
103 BOOLEAN mStatementLayoutIsChanged
= TRUE
;
104 USER_INPUT
*gUserInput
;
105 FORM_DISPLAY_ENGINE_FORM
*gFormData
;
106 EFI_HII_HANDLE gHiiHandle
;
108 LIST_ENTRY gMenuOption
;
109 DISPLAY_HIGHLIGHT_MENU_INFO gHighligthMenuInfo
= {0};
110 BOOLEAN mIsFirstForm
= TRUE
;
111 FORM_ENTRY_INFO gOldFormEntry
= {0};
114 // Browser Global Strings
116 CHAR16
*gFormNotFound
;
118 CHAR16
*gBrwoserError
;
120 CHAR16
*gPromptForData
;
121 CHAR16
*gPromptForPassword
;
122 CHAR16
*gPromptForNewPassword
;
123 CHAR16
*gConfirmPassword
;
124 CHAR16
*gConfirmError
;
125 CHAR16
*gPassowordInvalid
;
127 CHAR16
*gEmptyString
;
129 CHAR16
*gOptionMismatch
;
130 CHAR16
*gFormSuppress
;
131 CHAR16
*gProtocolNotFound
;
133 CHAR16 gModalSkipColumn
;
134 CHAR16 gPromptBlockWidth
;
135 CHAR16 gOptionBlockWidth
;
136 CHAR16 gHelpBlockWidth
;
137 CHAR16
*mUnknownString
;
139 FORM_DISPLAY_DRIVER_PRIVATE_DATA mPrivateData
= {
140 FORM_DISPLAY_DRIVER_SIGNATURE
,
144 DriverClearDisplayPage
,
151 Get the string based on the StringId and HII Package List Handle.
153 @param Token The String's ID.
154 @param HiiHandle The package list in the HII database to search for
155 the specified string.
157 @return The output string.
162 IN EFI_STRING_ID Token
,
163 IN EFI_HII_HANDLE HiiHandle
168 String
= HiiGetString (HiiHandle
, Token
, NULL
);
169 if (String
== NULL
) {
170 String
= AllocateCopyPool (StrSize (mUnknownString
), mUnknownString
);
171 ASSERT (String
!= NULL
);
174 return (CHAR16
*) String
;
179 Initialize the HII String Token to the correct values.
183 InitializeDisplayStrings (
187 mUnknownString
= GetToken (STRING_TOKEN (UNKNOWN_STRING
), gHiiHandle
);
188 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
189 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
190 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
191 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
192 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
193 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
194 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
195 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
196 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
197 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
198 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
199 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
200 gProtocolNotFound
= GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND
), gHiiHandle
);
201 gFormNotFound
= GetToken (STRING_TOKEN (STATUS_BROWSER_FORM_NOT_FOUND
), gHiiHandle
);
202 gNoSubmitIf
= GetToken (STRING_TOKEN (STATUS_BROWSER_NO_SUBMIT_IF
), gHiiHandle
);
203 gBrwoserError
= GetToken (STRING_TOKEN (STATUS_BROWSER_ERROR
), gHiiHandle
);
207 Free up the resource allocated for all strings required
216 FreePool (mUnknownString
);
217 FreePool (gEmptyString
);
218 FreePool (gSaveFailed
);
219 FreePool (gPromptForData
);
220 FreePool (gPromptForPassword
);
221 FreePool (gPromptForNewPassword
);
222 FreePool (gConfirmPassword
);
223 FreePool (gConfirmError
);
224 FreePool (gPassowordInvalid
);
225 FreePool (gPressEnter
);
226 FreePool (gMiniString
);
227 FreePool (gOptionMismatch
);
228 FreePool (gFormSuppress
);
229 FreePool (gProtocolNotFound
);
230 FreePool (gBrwoserError
);
231 FreePool (gNoSubmitIf
);
232 FreePool (gFormNotFound
);
236 Get prompt string id from the opcode data buffer.
238 @param OpCode The input opcode buffer.
240 @return The prompt string id.
245 IN EFI_IFR_OP_HEADER
*OpCode
248 EFI_IFR_STATEMENT_HEADER
*Header
;
250 if (OpCode
->Length
<= sizeof (EFI_IFR_OP_HEADER
)) {
254 Header
= (EFI_IFR_STATEMENT_HEADER
*) (OpCode
+ 1);
256 return Header
->Prompt
;
260 Get the supported width for a particular op-code
262 @param MenuOption The menu option.
263 @param AdjustWidth The width which is saved for the space.
265 @return Returns the number of CHAR16 characters that is support.
270 IN UI_MENU_OPTION
*MenuOption
,
271 OUT UINT16
*AdjustWidth
276 EFI_IFR_TEXT
*TestOp
;
278 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
280 Statement
= MenuOption
->ThisTag
;
283 // For modal form, clean the entire row.
285 if ((gFormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
286 if (AdjustWidth
!= NULL
) {
287 *AdjustWidth
= LEFT_SKIPPED_COLUMNS
;
289 return (UINT16
)(gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * (gModalSkipColumn
+ LEFT_SKIPPED_COLUMNS
));
295 // See if the second text parameter is really NULL
297 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
298 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
299 if (TestOp
->TextTwo
!= 0) {
300 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
301 Size
= StrLen (String
);
306 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
307 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
308 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
309 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
310 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
312 // Allow a wide display if text op-code and no secondary text op-code
314 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
318 // Return the space width.
320 if (AdjustWidth
!= NULL
) {
324 // Keep consistent with current behavior.
326 ReturnWidth
= (UINT16
) (gPromptBlockWidth
+ gOptionBlockWidth
- 2);
328 if (AdjustWidth
!= NULL
) {
332 ReturnWidth
= (UINT16
) (gPromptBlockWidth
- 1);
336 // For nest in statement, should the subtitle indent.
338 if (MenuOption
->NestInStatement
) {
339 ReturnWidth
-= SUBTITLE_INDENT
;
346 Will copy LineWidth amount of a string in the OutputString buffer and return the
347 number of CHAR16 characters that were copied into the OutputString buffer.
348 The output string format is:
349 Glyph Info + String info + '\0'.
351 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
353 @param InputString String description for this option.
354 @param LineWidth Width of the desired string to extract in CHAR16
356 @param GlyphWidth The glyph width of the begin of the char in the string.
357 @param Index Where in InputString to start the copy process
358 @param OutputString Buffer to copy the string into
360 @return Returns the number of CHAR16 characters that were copied into the OutputString
361 buffer, include extra glyph info and '\0' info.
366 IN CHAR16
*InputString
,
368 IN OUT UINT16
*GlyphWidth
,
370 OUT CHAR16
**OutputString
375 UINT16 OriginalGlyphWidth
;
377 UINT16 LastSpaceOffset
;
378 UINT16 LastGlyphWidth
;
380 if (InputString
== NULL
|| Index
== NULL
|| OutputString
== NULL
) {
384 if (LineWidth
== 0 || *GlyphWidth
== 0) {
389 // Save original glyph width.
391 OriginalGlyphWidth
= *GlyphWidth
;
392 LastGlyphWidth
= OriginalGlyphWidth
;
397 // NARROW_CHAR can not be printed in screen, so if a line only contain the two CHARs: 'NARROW_CHAR + CHAR_CARRIAGE_RETURN' , it is a empty line in Screen.
398 // To avoid displaying this empty line in screen, just skip the two CHARs here.
400 if ((InputString
[*Index
] == NARROW_CHAR
) && (InputString
[*Index
+ 1] == CHAR_CARRIAGE_RETURN
)) {
405 // Fast-forward the string and see if there is a carriage-return in the string
407 for (StrOffset
= 0, GlyphOffset
= 0; GlyphOffset
<= LineWidth
; StrOffset
++) {
408 switch (InputString
[*Index
+ StrOffset
]) {
417 case CHAR_CARRIAGE_RETURN
:
424 GlyphOffset
= GlyphOffset
+ *GlyphWidth
;
427 // Record the last space info in this line. Will be used in rewind.
429 if ((InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) && (GlyphOffset
<= LineWidth
)) {
430 LastSpaceOffset
= StrOffset
;
431 LastGlyphWidth
= *GlyphWidth
;
442 // Rewind the string from the maximum size until we see a space to break the line
444 if (GlyphOffset
> LineWidth
) {
446 // Rewind the string to last space char in this line.
448 if (LastSpaceOffset
!= 0) {
449 StrOffset
= LastSpaceOffset
;
450 *GlyphWidth
= LastGlyphWidth
;
453 // Roll back to last char in the line width.
460 // The CHAR_NULL has process last time, this time just return 0 to stand for the end.
462 if (StrOffset
== 0 && (InputString
[*Index
+ StrOffset
] == CHAR_NULL
)) {
467 // Need extra glyph info and '\0' info, so +2.
469 *OutputString
= AllocateZeroPool (((UINTN
) (StrOffset
+ 2) * sizeof(CHAR16
)));
470 if (*OutputString
== NULL
) {
475 // Save the glyph info at the begin of the string, will used by Print function.
477 if (OriginalGlyphWidth
== 1) {
478 *(*OutputString
) = NARROW_CHAR
;
480 *(*OutputString
) = WIDE_CHAR
;
483 CopyMem ((*OutputString
) + 1, &InputString
[*Index
], StrOffset
* sizeof(CHAR16
));
485 if (InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) {
487 // Skip the space info at the begin of next line.
489 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
490 } else if (InputString
[*Index
+ StrOffset
] == CHAR_LINEFEED
) {
492 // Skip the /n or /n/r info.
494 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_CARRIAGE_RETURN
) {
495 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
497 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
499 } else if (InputString
[*Index
+ StrOffset
] == CHAR_CARRIAGE_RETURN
) {
501 // Skip the /r or /r/n info.
503 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_LINEFEED
) {
504 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
506 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
509 *Index
= (UINT16
) (*Index
+ StrOffset
);
513 // Include extra glyph info and '\0' info, so +2.
515 return StrOffset
+ 2;
519 Add one menu option by specified description and context.
521 @param Statement Statement of this Menu Option.
522 @param MenuItemCount The index for this Option in the Menu.
523 @param NestIn Whether this statement is nest in another statement.
528 IN FORM_DISPLAY_ENGINE_STATEMENT
*Statement
,
529 IN UINT16
*MenuItemCount
,
533 UI_MENU_OPTION
*MenuOption
;
537 UINT16 NumberOfLines
;
541 CHAR16
*OutputString
;
542 EFI_STRING_ID PromptId
;
550 PromptId
= GetPrompt (Statement
->OpCode
);
551 ASSERT (PromptId
!= 0);
553 String
= GetToken (PromptId
, gFormData
->HiiHandle
);
554 ASSERT (String
!= NULL
);
556 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
560 for (Index
= 0; Index
< Count
; Index
++) {
561 MenuOption
= AllocateZeroPool (sizeof (UI_MENU_OPTION
));
564 MenuOption
->Signature
= UI_MENU_OPTION_SIGNATURE
;
565 MenuOption
->Description
= String
;
566 MenuOption
->Handle
= gFormData
->HiiHandle
;
567 MenuOption
->ThisTag
= Statement
;
568 MenuOption
->NestInStatement
= NestIn
;
569 MenuOption
->EntryNumber
= *MenuItemCount
;
571 MenuOption
->Sequence
= Index
;
573 if ((Statement
->Attribute
& HII_DISPLAY_GRAYOUT
) != 0) {
574 MenuOption
->GrayOut
= TRUE
;
576 MenuOption
->GrayOut
= FALSE
;
579 if ((Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
580 MenuOption
->GrayOut
= TRUE
;
584 // If the form or the question has the lock attribute, deal same as grayout.
586 if ((gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
587 MenuOption
->GrayOut
= TRUE
;
590 switch (Statement
->OpCode
->OpCode
) {
591 case EFI_IFR_ORDERED_LIST_OP
:
592 case EFI_IFR_ONE_OF_OP
:
593 case EFI_IFR_NUMERIC_OP
:
594 case EFI_IFR_TIME_OP
:
595 case EFI_IFR_DATE_OP
:
596 case EFI_IFR_CHECKBOX_OP
:
597 case EFI_IFR_PASSWORD_OP
:
598 case EFI_IFR_STRING_OP
:
600 // User could change the value of these items
602 MenuOption
->IsQuestion
= TRUE
;
604 case EFI_IFR_TEXT_OP
:
605 if (FeaturePcdGet (PcdBrowserGrayOutTextStatement
)) {
607 // Initializing GrayOut option as TRUE for Text setup options
608 // so that those options will be Gray in colour and un selectable.
610 MenuOption
->GrayOut
= TRUE
;
614 MenuOption
->IsQuestion
= FALSE
;
618 if ((Statement
->Attribute
& HII_DISPLAY_READONLY
) != 0) {
619 MenuOption
->ReadOnly
= TRUE
;
620 if (FeaturePcdGet (PcdBrowerGrayOutReadOnlyMenu
)) {
621 MenuOption
->GrayOut
= TRUE
;
626 (Statement
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
627 (Statement
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
628 Width
= GetWidth (MenuOption
, NULL
);
629 for (; GetLineByWidth (String
, Width
, &GlyphWidth
,&ArrayEntry
, &OutputString
) != 0x0000;) {
631 // If there is more string to process print on the next row and increment the Skip value
633 if (StrLen (&String
[ArrayEntry
]) != 0) {
636 FreePool (OutputString
);
640 // Add three MenuOptions for Date/Time
641 // Data format : [01/02/2004] [11:22:33]
642 // Line number : 0 0 1 0 0 1
649 // Override LineNumber for the MenuOption in Date/Time sequence
651 MenuOption
->Skip
= 1;
653 MenuOption
->Skip
= NumberOfLines
;
656 InsertTailList (&gMenuOption
, &MenuOption
->Link
);
663 Create the menu list base on the form data info.
667 ConvertStatementToMenu (
671 UINT16 MenuItemCount
;
673 LIST_ENTRY
*NestLink
;
674 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
675 FORM_DISPLAY_ENGINE_STATEMENT
*NestStatement
;
678 InitializeListHead (&gMenuOption
);
680 Link
= GetFirstNode (&gFormData
->StatementListHead
);
681 while (!IsNull (&gFormData
->StatementListHead
, Link
)) {
682 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
683 Link
= GetNextNode (&gFormData
->StatementListHead
, Link
);
686 // Skip the opcode not recognized by Display core.
688 if (Statement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
692 UiAddMenuOption (Statement
, &MenuItemCount
, FALSE
);
695 // Check the statement nest in this host statement.
697 NestLink
= GetFirstNode (&Statement
->NestStatementList
);
698 while (!IsNull (&Statement
->NestStatementList
, NestLink
)) {
699 NestStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink
);
700 NestLink
= GetNextNode (&Statement
->NestStatementList
, NestLink
);
703 // Skip the opcode not recognized by Display core.
705 if (NestStatement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
709 UiAddMenuOption (NestStatement
, &MenuItemCount
, TRUE
);
715 Count the storage space of a Unicode string.
717 This function handles the Unicode string with NARROW_CHAR
718 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
719 does not count in the resultant output. If a WIDE_CHAR is
720 hit, then 2 Unicode character will consume an output storage
721 space with size of CHAR16 till a NARROW_CHAR is hit.
723 If String is NULL, then ASSERT ().
725 @param String The input string to be counted.
727 @return Storage space for the input string.
737 UINTN IncrementValue
;
739 ASSERT (String
!= NULL
);
740 if (String
== NULL
) {
750 // Advance to the null-terminator or to the first width directive
753 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
754 Index
++, Count
= Count
+ IncrementValue
759 // We hit the null-terminator, we now have a count
761 if (String
[Index
] == 0) {
765 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
766 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
768 if (String
[Index
] == NARROW_CHAR
) {
770 // Skip to the next character
776 // Skip to the next character
781 } while (String
[Index
] != 0);
784 // Increment by one to include the null-terminator in the size
788 return Count
* sizeof (CHAR16
);
792 Base on the input option string to update the skip value for a menu option.
794 @param MenuOption The MenuOption to be checked.
795 @param OptionString The input option string.
799 UpdateSkipInfoForMenu (
800 IN UI_MENU_OPTION
*MenuOption
,
801 IN CHAR16
*OptionString
807 CHAR16
*OutputString
;
810 Width
= (UINT16
) gOptionBlockWidth
;
814 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
815 if (StrLen (&OptionString
[Index
]) != 0) {
819 FreePool (OutputString
);
822 if ((Row
> MenuOption
->Skip
) &&
823 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
824 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
825 MenuOption
->Skip
= Row
;
830 Update display lines for a Menu Option.
832 @param MenuOption The MenuOption to be checked.
836 UpdateOptionSkipLines (
837 IN UI_MENU_OPTION
*MenuOption
840 CHAR16
*OptionString
;
844 ProcessOptions (MenuOption
, FALSE
, &OptionString
, TRUE
);
845 if (OptionString
!= NULL
) {
846 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
848 FreePool (OptionString
);
851 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
852 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
854 if (OptionString
!= NULL
) {
855 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
857 FreePool (OptionString
);
863 Check whether this Menu Option could be print.
865 Check Prompt string, option string or text two string not NULL.
867 This is an internal function.
869 @param MenuOption The MenuOption to be checked.
871 @retval TRUE This Menu Option is printable.
872 @retval FALSE This Menu Option could not be printable.
877 UI_MENU_OPTION
*MenuOption
881 EFI_STRING OptionString
;
885 if (MenuOption
->Description
[0] != '\0') {
889 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
890 if (EFI_ERROR (Status
)) {
893 if (OptionString
!= NULL
&& OptionString
[0] != '\0') {
894 FreePool (OptionString
);
898 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
899 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
900 ASSERT (OptionString
!= NULL
);
901 if (OptionString
[0] != '\0'){
902 FreePool (OptionString
);
911 Check whether this Menu Option could be highlighted.
913 This is an internal function.
915 @param MenuOption The MenuOption to be checked.
917 @retval TRUE This Menu Option is selectable.
918 @retval FALSE This Menu Option could not be selected.
923 UI_MENU_OPTION
*MenuOption
926 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
927 MenuOption
->GrayOut
|| MenuOption
->ReadOnly
|| !PrintableMenu (MenuOption
)) {
935 Move to next selectable statement.
937 This is an internal function.
939 @param GoUp The navigation direction. TRUE: up, FALSE: down.
940 @param CurrentPosition Current position.
941 @param GapToTop Gap position to top or bottom.
942 @param FindInForm Whether find menu in current form or beyond.
944 @return The row distance from current MenuOption to next selectable MenuOption.
946 @retval -1 Reach the begin of the menu, still can't find the selectable menu.
947 @retval Value Find the selectable menu, maybe the truly selectable, maybe the
948 first menu showing beyond current form or last menu showing in
950 The value is the line number between the new selected menu and the
951 current select menu, not include the new selected menu.
955 MoveToNextStatement (
957 IN OUT LIST_ENTRY
**CurrentPosition
,
959 IN BOOLEAN FindInForm
964 UI_MENU_OPTION
*NextMenuOption
;
965 UI_MENU_OPTION
*PreMenuOption
;
968 Pos
= *CurrentPosition
;
970 if (Pos
== &gMenuOption
) {
974 PreMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
977 NextMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
979 // NextMenuOption->Row == 0 means this menu has not calculate
980 // the NextMenuOption->Skip value yet, just calculate here.
982 if (NextMenuOption
->Row
== 0) {
983 UpdateOptionSkipLines (NextMenuOption
);
986 if (IsSelectable (NextMenuOption
)) {
991 // In this case, still can't find the selectable menu,
992 // return the first one beyond the showing form.
994 if ((UINTN
) Distance
+ NextMenuOption
->Skip
> GapToTop
) {
996 NextMenuOption
= PreMenuOption
;
1001 Distance
+= NextMenuOption
->Skip
;
1004 // Arrive at begin of the menu list.
1006 if ((GoUp
? Pos
->BackLink
: Pos
->ForwardLink
) == &gMenuOption
) {
1011 Pos
= (GoUp
? Pos
->BackLink
: Pos
->ForwardLink
);
1012 PreMenuOption
= NextMenuOption
;
1015 *CurrentPosition
= &NextMenuOption
->Link
;
1021 Process option string for date/time opcode.
1023 @param MenuOption Menu option point to date/time.
1024 @param OptionString Option string input for process.
1025 @param AddOptCol Whether need to update MenuOption->OptCol.
1029 ProcessStringForDateTime (
1030 UI_MENU_OPTION
*MenuOption
,
1031 CHAR16
*OptionString
,
1037 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1041 ASSERT (MenuOption
!= NULL
&& OptionString
!= NULL
);
1043 Statement
= MenuOption
->ThisTag
;
1046 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1047 Date
= (EFI_IFR_DATE
*) Statement
->OpCode
;
1048 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1049 Time
= (EFI_IFR_TIME
*) Statement
->OpCode
;
1053 // If leading spaces on OptionString - remove the spaces
1055 for (Index
= 0; OptionString
[Index
] == L
' '; Index
++) {
1057 // Base on the blockspace to get the option column info.
1060 MenuOption
->OptCol
++;
1064 for (Count
= 0; OptionString
[Index
] != CHAR_NULL
; Index
++) {
1065 OptionString
[Count
] = OptionString
[Index
];
1068 OptionString
[Count
] = CHAR_NULL
;
1071 // Enable to suppress field in the opcode base on the flag.
1073 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1075 // OptionString format is: <**: **: ****>
1079 if ((Date
->Flags
& EFI_QF_DATE_MONTH_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1081 // At this point, only "<**:" in the optionstring.
1082 // Clean the day's ** field, after clean, the format is "< :"
1084 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1085 } else if ((Date
->Flags
& EFI_QF_DATE_DAY_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1087 // At this point, only "**:" in the optionstring.
1088 // Clean the month's "**" field, after clean, the format is " :"
1090 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1091 } else if ((Date
->Flags
& EFI_QF_DATE_YEAR_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1093 // At this point, only "****>" in the optionstring.
1094 // Clean the year's "****" field, after clean, the format is " >"
1096 SetUnicodeMem (&OptionString
[0], 4, L
' ');
1098 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1100 // OptionString format is: <**: **: **>
1101 // |hour|minute|second|
1104 if ((Time
->Flags
& QF_TIME_HOUR_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1106 // At this point, only "<**:" in the optionstring.
1107 // Clean the hour's ** field, after clean, the format is "< :"
1109 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1110 } else if ((Time
->Flags
& QF_TIME_MINUTE_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1112 // At this point, only "**:" in the optionstring.
1113 // Clean the minute's "**" field, after clean, the format is " :"
1115 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1116 } else if ((Time
->Flags
& QF_TIME_SECOND_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1118 // At this point, only "**>" in the optionstring.
1119 // Clean the second's "**" field, after clean, the format is " >"
1121 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1128 Adjust Data and Time position accordingly.
1129 Data format : [01/02/2004] [11:22:33]
1130 Line number : 0 0 1 0 0 1
1132 This is an internal function.
1134 @param DirectionUp the up or down direction. False is down. True is
1136 @param CurrentPosition Current position. On return: Point to the last
1137 Option (Year or Second) if up; Point to the first
1138 Option (Month or Hour) if down.
1140 @return Return line number to pad. It is possible that we stand on a zero-advance
1141 @return data or time opcode, so pad one line when we judge if we are going to scroll outside.
1145 AdjustDateAndTimePosition (
1146 IN BOOLEAN DirectionUp
,
1147 IN OUT LIST_ENTRY
**CurrentPosition
1151 LIST_ENTRY
*NewPosition
;
1152 UI_MENU_OPTION
*MenuOption
;
1153 UINTN PadLineNumber
;
1156 NewPosition
= *CurrentPosition
;
1157 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1159 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) ||
1160 (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
1162 // Calculate the distance from current position to the last Date/Time MenuOption
1165 while (MenuOption
->Skip
== 0) {
1167 NewPosition
= NewPosition
->ForwardLink
;
1168 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1172 NewPosition
= *CurrentPosition
;
1175 // Since the behavior of hitting the up arrow on a Date/Time MenuOption is intended
1176 // to be one that back to the previous set of MenuOptions, we need to advance to the first
1177 // Date/Time MenuOption and leave the remaining logic in CfUiUp intact so the appropriate
1178 // checking can be done.
1180 while (Count
++ < 2) {
1181 NewPosition
= NewPosition
->BackLink
;
1185 // Since the behavior of hitting the down arrow on a Date/Time MenuOption is intended
1186 // to be one that progresses to the next set of MenuOptions, we need to advance to the last
1187 // Date/Time MenuOption and leave the remaining logic in CfUiDown intact so the appropriate
1188 // checking can be done.
1190 while (Count
-- > 0) {
1191 NewPosition
= NewPosition
->ForwardLink
;
1195 *CurrentPosition
= NewPosition
;
1198 return PadLineNumber
;
1202 Get step info from numeric opcode.
1204 @param[in] OpCode The input numeric op code.
1206 @return step info for this opcode.
1210 IN EFI_IFR_OP_HEADER
*OpCode
1213 EFI_IFR_NUMERIC
*NumericOp
;
1216 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
1218 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1219 case EFI_IFR_NUMERIC_SIZE_1
:
1220 Step
= NumericOp
->data
.u8
.Step
;
1223 case EFI_IFR_NUMERIC_SIZE_2
:
1224 Step
= NumericOp
->data
.u16
.Step
;
1227 case EFI_IFR_NUMERIC_SIZE_4
:
1228 Step
= NumericOp
->data
.u32
.Step
;
1231 case EFI_IFR_NUMERIC_SIZE_8
:
1232 Step
= NumericOp
->data
.u64
.Step
;
1244 Find the registered HotKey based on KeyData.
1246 @param[in] KeyData A pointer to a buffer that describes the keystroke
1247 information for the hot key.
1249 @return The registered HotKey context. If no found, NULL will return.
1252 GetHotKeyFromRegisterList (
1253 IN EFI_INPUT_KEY
*KeyData
1257 BROWSER_HOT_KEY
*HotKey
;
1259 Link
= GetFirstNode (&gFormData
->HotKeyListHead
);
1260 while (!IsNull (&gFormData
->HotKeyListHead
, Link
)) {
1261 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
1263 if (HotKey
->KeyData
->ScanCode
== KeyData
->ScanCode
) {
1267 Link
= GetNextNode (&gFormData
->HotKeyListHead
, Link
);
1275 Determine if the menu is the last menu that can be selected.
1277 This is an internal function.
1279 @param Direction The scroll direction. False is down. True is up.
1280 @param CurrentPos The current focus.
1282 @return FALSE -- the menu isn't the last menu that can be selected.
1283 @return TRUE -- the menu is the last menu that can be selected.
1288 IN BOOLEAN Direction
,
1289 IN LIST_ENTRY
*CurrentPos
1294 Temp
= Direction
? CurrentPos
->BackLink
: CurrentPos
->ForwardLink
;
1296 if (Temp
== &gMenuOption
) {
1304 Wait for a given event to fire, or for an optional timeout to expire.
1306 @param Event The event to wait for
1308 @retval UI_EVENT_TYPE The type of the event which is trigged.
1320 EFI_EVENT TimerEvent
;
1321 EFI_EVENT WaitList
[3];
1322 UI_EVENT_TYPE EventType
;
1325 Timeout
= FormExitTimeout(gFormData
);
1328 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
1331 // Set the timer event
1340 WaitList
[0] = Event
;
1342 if (gFormData
->FormRefreshEvent
!= NULL
) {
1343 WaitList
[EventNum
] = gFormData
->FormRefreshEvent
;
1348 WaitList
[EventNum
] = TimerEvent
;
1352 Status
= gBS
->WaitForEvent (EventNum
, WaitList
, &Index
);
1353 ASSERT_EFI_ERROR (Status
);
1357 EventType
= UIEventKey
;
1361 if (gFormData
->FormRefreshEvent
!= NULL
) {
1362 EventType
= UIEventDriver
;
1364 ASSERT (Timeout
!= 0 && EventNum
== 2);
1365 EventType
= UIEventTimeOut
;
1370 ASSERT (Index
== 2 && EventNum
== 3);
1371 EventType
= UIEventTimeOut
;
1376 gBS
->CloseEvent (TimerEvent
);
1383 Get question id info from the input opcode header.
1385 @param OpCode The input opcode header pointer.
1387 @retval The question id for this opcode.
1392 IN EFI_IFR_OP_HEADER
*OpCode
1395 EFI_IFR_QUESTION_HEADER
*QuestionHeader
;
1397 if (OpCode
->Length
< sizeof (EFI_IFR_OP_HEADER
) + sizeof (EFI_IFR_QUESTION_HEADER
)) {
1401 QuestionHeader
= (EFI_IFR_QUESTION_HEADER
*)((UINT8
*) OpCode
+ sizeof(EFI_IFR_OP_HEADER
));
1403 return QuestionHeader
->QuestionId
;
1408 Find the top of screen menu base on the current menu.
1410 @param CurPos Current input menu.
1411 @param Rows Totol screen rows.
1412 @param SkipValue SkipValue for this new form.
1414 @retval TopOfScreen Top of screen menu for the new form.
1418 FindTopOfScreenMenu (
1419 IN LIST_ENTRY
*CurPos
,
1421 OUT UINTN
*SkipValue
1425 LIST_ENTRY
*TopOfScreen
;
1426 UI_MENU_OPTION
*PreviousMenuOption
;
1429 PreviousMenuOption
= NULL
;
1431 while (Link
->BackLink
!= &gMenuOption
) {
1432 Link
= Link
->BackLink
;
1433 PreviousMenuOption
= MENU_OPTION_FROM_LINK (Link
);
1434 if (PreviousMenuOption
->Row
== 0) {
1435 UpdateOptionSkipLines (PreviousMenuOption
);
1437 if (Rows
<= PreviousMenuOption
->Skip
) {
1440 Rows
= Rows
- PreviousMenuOption
->Skip
;
1443 if (Link
->BackLink
== &gMenuOption
) {
1444 TopOfScreen
= gMenuOption
.ForwardLink
;
1445 if (PreviousMenuOption
!= NULL
&& Rows
< PreviousMenuOption
->Skip
) {
1446 *SkipValue
= PreviousMenuOption
->Skip
- Rows
;
1452 *SkipValue
= PreviousMenuOption
->Skip
- Rows
;
1459 Find the first menu which will be show at the top.
1461 @param FormData The data info for this form.
1462 @param TopOfScreen The link_entry pointer to top menu.
1463 @param HighlightMenu The menu which will be highlight.
1464 @param SkipValue The skip value for the top menu.
1469 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
1470 OUT LIST_ENTRY
**TopOfScreen
,
1471 OUT LIST_ENTRY
**HighlightMenu
,
1472 OUT UINTN
*SkipValue
1478 UI_MENU_OPTION
*SavedMenuOption
;
1481 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
1482 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
;
1485 // If not has input highlight statement, just return the first one in this form.
1487 if (FormData
->HighLightedStatement
== NULL
) {
1488 *TopOfScreen
= gMenuOption
.ForwardLink
;
1489 *HighlightMenu
= gMenuOption
.ForwardLink
;
1490 if (!IsListEmpty (&gMenuOption
)) {
1491 MoveToNextStatement (FALSE
, HighlightMenu
, BottomRow
- TopRow
, TRUE
);
1498 // Now base on the input highlight menu to find the top menu in this page.
1499 // Will base on the highlight menu show at the bottom to find the top menu.
1501 NewPos
= gMenuOption
.ForwardLink
;
1502 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1504 while ((SavedMenuOption
->ThisTag
!= FormData
->HighLightedStatement
) ||
1505 (SavedMenuOption
->Sequence
!= gSequence
)) {
1506 NewPos
= NewPos
->ForwardLink
;
1507 if (NewPos
== &gMenuOption
) {
1509 // Not Found it, break
1513 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1515 ASSERT (SavedMenuOption
->ThisTag
== FormData
->HighLightedStatement
);
1517 *HighlightMenu
= NewPos
;
1519 AdjustDateAndTimePosition(FALSE
, &NewPos
);
1520 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1521 UpdateOptionSkipLines (SavedMenuOption
);
1524 // If highlight opcode is date/time, keep the highlight row info not change.
1526 if ((SavedMenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| SavedMenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) &&
1527 (gHighligthMenuInfo
.QuestionId
!= 0) &&
1528 (gHighligthMenuInfo
.QuestionId
== GetQuestionIdInfo(SavedMenuOption
->ThisTag
->OpCode
))) {
1530 // Still show the highlight menu before exit from display engine.
1532 BottomRow
= gHighligthMenuInfo
.DisplayRow
+ SavedMenuOption
->Skip
;
1535 if (SavedMenuOption
->Skip
>= BottomRow
- TopRow
) {
1537 *TopOfScreen
= NewPos
;
1539 *TopOfScreen
= FindTopOfScreenMenu(NewPos
, BottomRow
- TopRow
- SavedMenuOption
->Skip
, &TmpValue
);
1541 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1543 *SkipValue
= TmpValue
;
1547 Update highlight menu info.
1549 @param MenuOption The menu opton which is highlight.
1553 UpdateHighlightMenuInfo (
1554 IN UI_MENU_OPTION
*MenuOption
1557 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1560 // This is the current selected statement
1562 Statement
= MenuOption
->ThisTag
;
1565 // Get the highlight statement.
1567 gUserInput
->SelectedStatement
= Statement
;
1568 gSequence
= (UINT16
) MenuOption
->Sequence
;
1571 // Record highlight row info for date/time opcode.
1573 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1574 gHighligthMenuInfo
.QuestionId
= GetQuestionIdInfo(Statement
->OpCode
);
1575 gHighligthMenuInfo
.DisplayRow
= (UINT16
) MenuOption
->Row
;
1577 gHighligthMenuInfo
.QuestionId
= 0;
1578 gHighligthMenuInfo
.DisplayRow
= 0;
1581 RefreshKeyHelp(gFormData
, Statement
, FALSE
);
1585 Update attribut for this menu.
1587 @param MenuOption The menu opton which this attribut used to.
1588 @param Highlight Whether this menu will be highlight.
1592 SetDisplayAttribute (
1593 IN UI_MENU_OPTION
*MenuOption
,
1594 IN BOOLEAN Highlight
1597 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1599 Statement
= MenuOption
->ThisTag
;
1602 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
1606 if (MenuOption
->GrayOut
) {
1607 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetGrayedTextColor ());
1609 if (Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) {
1610 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetSubTitleTextColor ());
1612 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
1618 Print string for this menu option.
1620 @param MenuOption The menu opton which this attribut used to.
1621 @param Col The column that this string will be print at.
1622 @param Row The row that this string will be print at.
1623 @param String The string which need to print.
1624 @param Width The width need to print, if string is less than the
1625 width, the block space will be used.
1626 @param Highlight Whether this menu will be highlight.
1631 IN UI_MENU_OPTION
*MenuOption
,
1636 IN BOOLEAN Highlight
1642 // Print string with normal color.
1645 PrintStringAtWithWidth (Col
, Row
, String
, Width
);
1650 // Print the highlight menu string.
1651 // First print the highlight string.
1653 SetDisplayAttribute(MenuOption
, TRUE
);
1654 Length
= PrintStringAt (Col
, Row
, String
);
1657 // Second, clean the empty after the string.
1659 SetDisplayAttribute(MenuOption
, FALSE
);
1660 PrintStringAtWithWidth (Col
+ Length
, Row
, L
"", Width
- Length
);
1664 Check whether this menu can has option string.
1666 @param MenuOption The menu opton which this attribut used to.
1668 @retval TRUE This menu option can have option string.
1669 @retval FALSE This menu option can't have option string.
1674 IN UI_MENU_OPTION
*MenuOption
1677 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1680 EFI_IFR_TEXT
*TestOp
;
1683 Statement
= MenuOption
->ThisTag
;
1686 // See if the second text parameter is really NULL
1688 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
1689 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
1690 if (TestOp
->TextTwo
!= 0) {
1691 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
1692 Size
= StrLen (String
);
1697 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
1698 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
1699 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
1700 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
1701 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
1703 // Allow a wide display if text op-code and no secondary text op-code
1705 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
1716 Print string for this menu option.
1718 @param MenuOption The menu opton which this attribut used to.
1719 @param SkipWidth The skip width between the left to the start of the prompt.
1720 @param BeginCol The begin column for one menu.
1721 @param SkipLine The skip line for this menu.
1722 @param BottomRow The bottom row for this form.
1723 @param Highlight Whether this menu will be highlight.
1724 @param UpdateCol Whether need to update the column info for Date/Time.
1726 @retval EFI_SUCESSS Process the user selection success.
1731 IN UI_MENU_OPTION
*MenuOption
,
1736 IN BOOLEAN Highlight
,
1737 IN BOOLEAN UpdateCol
1740 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1745 CHAR16
*OptionString
;
1746 CHAR16
*OutputString
;
1754 UINTN PromptLineNum
;
1755 UINTN OptionLineNum
;
1759 Statement
= MenuOption
->ThisTag
;
1769 // Set default color.
1771 SetDisplayAttribute (MenuOption
, FALSE
);
1774 // 1. Paint the option string.
1776 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
1777 if (EFI_ERROR (Status
)) {
1781 if (OptionString
!= NULL
) {
1782 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1784 // Adjust option string for date/time opcode.
1786 ProcessStringForDateTime(MenuOption
, OptionString
, UpdateCol
);
1789 Width
= (UINT16
) gOptionBlockWidth
- 1;
1790 Row
= MenuOption
->Row
;
1794 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1795 if (((Temp2
== 0)) && (Row
<= BottomRow
)) {
1796 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1798 // For date/time question, it has three menu options for this qustion.
1799 // The first/second menu options with the skip value is 0. the last one
1800 // with skip value is 1.
1802 if (MenuOption
->Skip
!= 0) {
1804 // For date/ time, print the last past (year for date and second for time)
1805 // - 7 means skip [##/##/ for date and [##:##: for time.
1807 DisplayMenuString (MenuOption
,MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1 - 7, Highlight
);
1810 // For date/ time, print the first and second past (year for date and second for time)
1811 // The OutputString has a NARROW_CHAR or WIDE_CHAR at the begin of the string,
1812 // so need to - 1 to remove it, otherwise, it will clean 1 extr char follow it.
1813 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, StrLen (OutputString
) - 1, Highlight
);
1816 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
1822 // If there is more string to process print on the next row and increment the Skip value
1824 if (StrLen (&OptionString
[Index
]) != 0) {
1828 // Since the Number of lines for this menu entry may or may not be reflected accurately
1829 // since the prompt might be 1 lines and option might be many, and vice versa, we need to do
1830 // some testing to ensure we are keeping this in-sync.
1832 // If the difference in rows is greater than or equal to the skip value, increase the skip value
1834 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
1840 FreePool (OutputString
);
1848 FreePool (OptionString
);
1852 // 2. Paint the description.
1854 PromptWidth
= GetWidth (MenuOption
, &AdjustValue
);
1855 Row
= MenuOption
->Row
;
1859 if (MenuOption
->Description
== NULL
|| MenuOption
->Description
[0] == '\0') {
1860 PrintStringAtWithWidth (BeginCol
, Row
, L
"", PromptWidth
+ AdjustValue
+ SkipWidth
);
1863 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, PromptWidth
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1864 if ((Temp
== 0) && (Row
<= BottomRow
)) {
1866 // 1.Clean the start LEFT_SKIPPED_COLUMNS
1868 PrintStringAtWithWidth (BeginCol
, Row
, L
"", SkipWidth
);
1870 if (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
&& MenuOption
->Col
>= 2) {
1872 // Print Arrow for Goto button.
1875 MenuOption
->Col
- 2,
1877 GEOMETRICSHAPE_RIGHT_TRIANGLE
1880 DisplayMenuString (MenuOption
, MenuOption
->Col
, Row
, OutputString
, PromptWidth
+ AdjustValue
, Highlight
);
1884 // If there is more string to process print on the next row and increment the Skip value
1886 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
1892 FreePool (OutputString
);
1903 // 3. If this is a text op with secondary text information
1905 if ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
!= 0)) {
1906 StringPtr
= GetToken (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
1908 Width
= (UINT16
) gOptionBlockWidth
- 1;
1909 Row
= MenuOption
->Row
;
1913 for (Index
= 0; GetLineByWidth (StringPtr
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1914 if ((Temp3
== 0) && (Row
<= BottomRow
)) {
1915 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
1919 // If there is more string to process print on the next row and increment the Skip value
1921 if (StrLen (&StringPtr
[Index
]) != 0) {
1925 // If the rows for text two is greater than or equal to the skip value, increase the skip value
1927 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
1933 FreePool (OutputString
);
1939 FreePool (StringPtr
);
1943 // 4.Line number for Option string and prompt string are not equal.
1944 // Clean the column whose line number is less.
1946 if (HasOptionString(MenuOption
) && (OptionLineNum
!= PromptLineNum
)) {
1947 Col
= OptionLineNum
< PromptLineNum
? MenuOption
->OptCol
: BeginCol
;
1948 Row
= (OptionLineNum
< PromptLineNum
? OptionLineNum
: PromptLineNum
) + MenuOption
->Row
;
1949 Width
= (UINT16
) (OptionLineNum
< PromptLineNum
? gOptionBlockWidth
: PromptWidth
+ AdjustValue
+ SkipWidth
);
1950 MaxRow
= (OptionLineNum
< PromptLineNum
? PromptLineNum
: OptionLineNum
) + MenuOption
->Row
- 1;
1952 while (Row
<= MaxRow
) {
1953 DisplayMenuString (MenuOption
, Col
, Row
++, L
"", Width
, FALSE
);
1961 Display menu and wait for user to select one menu option, then return it.
1962 If AutoBoot is enabled, then if user doesn't select any option,
1963 after period of time, it will automatically return the first menu option.
1965 @param FormData The current form data info.
1967 @retval EFI_SUCESSS Process the user selection success.
1968 @retval EFI_NOT_FOUND Process option string for orderedlist/Oneof fail.
1973 IN FORM_DISPLAY_ENGINE_FORM
*FormData
1978 UINTN DistanceValue
;
1988 CHAR16
*OptionString
;
1989 CHAR16
*OutputString
;
1991 CHAR16
*HelpHeaderString
;
1992 CHAR16
*HelpBottomString
;
2001 LIST_ENTRY
*TopOfScreen
;
2002 LIST_ENTRY
*SavedListEntry
;
2003 UI_MENU_OPTION
*MenuOption
;
2004 UI_MENU_OPTION
*NextMenuOption
;
2005 UI_MENU_OPTION
*SavedMenuOption
;
2006 UI_MENU_OPTION
*PreviousMenuOption
;
2007 UI_CONTROL_FLAG ControlFlag
;
2008 UI_SCREEN_OPERATION ScreenOperation
;
2010 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2011 BROWSER_HOT_KEY
*HotKey
;
2012 UINTN HelpPageIndex
;
2013 UINTN HelpPageCount
;
2016 UINTN HelpHeaderLine
;
2017 UINTN HelpBottomLine
;
2018 BOOLEAN MultiHelpPage
;
2019 UINT16 EachLineWidth
;
2020 UINT16 HeaderLineWidth
;
2021 UINT16 BottomLineWidth
;
2022 EFI_STRING_ID HelpInfo
;
2023 UI_EVENT_TYPE EventType
;
2024 FORM_DISPLAY_ENGINE_STATEMENT
*InitialHighlight
;
2025 BOOLEAN SkipHighLight
;
2027 EventType
= UIEventNone
;
2028 Status
= EFI_SUCCESS
;
2030 HelpHeaderString
= NULL
;
2031 HelpBottomString
= NULL
;
2032 OptionString
= NULL
;
2033 ScreenOperation
= UiNoOperation
;
2042 MultiHelpPage
= FALSE
;
2044 HeaderLineWidth
= 0;
2045 BottomLineWidth
= 0;
2046 OutputString
= NULL
;
2050 SkipHighLight
= FALSE
;
2052 NextMenuOption
= NULL
;
2053 PreviousMenuOption
= NULL
;
2054 SavedMenuOption
= NULL
;
2058 gModalSkipColumn
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 6;
2059 InitialHighlight
= gFormData
->HighLightedStatement
;
2061 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
2065 // |<-.->|<-.........->|<- .........->|<-...........->|
2066 // Skip Prompt Option Help
2068 Width
= (CHAR16
) ((gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 3);
2069 gOptionBlockWidth
= Width
+ 1;
2070 gHelpBlockWidth
= (CHAR16
) (Width
- LEFT_SKIPPED_COLUMNS
);
2071 gPromptBlockWidth
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * Width
- 1);
2073 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
2074 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
- 1;
2077 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2078 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gModalSkipColumn
;
2080 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
;
2083 FindTopMenu(FormData
, &TopOfScreen
, &NewPos
, &SkipValue
);
2085 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
2087 ControlFlag
= CfInitialization
;
2089 switch (ControlFlag
) {
2090 case CfInitialization
:
2091 if ((gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
) ||
2092 (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))) {
2094 // Clear Statement range if different formset is painted.
2097 gStatementDimensions
.LeftColumn
,
2098 gStatementDimensions
.RightColumn
,
2099 TopRow
- SCROLL_ARROW_HEIGHT
,
2100 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2101 GetFieldTextColor ()
2105 ControlFlag
= CfRepaint
;
2109 ControlFlag
= CfRefreshHighLight
;
2119 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2122 // 1. Check whether need to print the arrow up.
2124 if (!ValueIsScroll (TRUE
, TopOfScreen
)) {
2128 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2129 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2131 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2134 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2136 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2137 TopRow
- SCROLL_ARROW_HEIGHT
,
2140 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2144 // 2.Paint the menu.
2146 for (Link
= TopOfScreen
; Link
!= &gMenuOption
; Link
= Link
->ForwardLink
) {
2147 MenuOption
= MENU_OPTION_FROM_LINK (Link
);
2148 MenuOption
->Row
= Row
;
2149 MenuOption
->Col
= Col
;
2150 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2151 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
+ gModalSkipColumn
;
2153 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
;
2156 if (MenuOption
->NestInStatement
) {
2157 MenuOption
->Col
+= SUBTITLE_INDENT
;
2161 // Save the highlight menu, will be used in CfRefreshHighLight case.
2163 if (Link
== NewPos
) {
2164 SavedMenuOption
= MenuOption
;
2165 SkipHighLight
= TRUE
;
2168 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2169 Status
= DisplayOneMenu (MenuOption
,
2170 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2171 gStatementDimensions
.LeftColumn
+ gModalSkipColumn
,
2172 Link
== TopOfScreen
? SkipValue
: 0,
2174 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2178 Status
= DisplayOneMenu (MenuOption
,
2179 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2180 gStatementDimensions
.LeftColumn
,
2181 Link
== TopOfScreen
? SkipValue
: 0,
2183 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2188 if (EFI_ERROR (Status
)) {
2192 // 3. Update the row info which will be used by next menu.
2194 if (Link
== TopOfScreen
) {
2195 Row
+= MenuOption
->Skip
- SkipValue
;
2197 Row
+= MenuOption
->Skip
;
2200 if (Row
> BottomRow
) {
2201 if (!ValueIsScroll (FALSE
, Link
)) {
2205 Row
= BottomRow
+ 1;
2211 // 3. Menus in this form may not cover all form, clean the remain field.
2213 while (Row
<= BottomRow
) {
2214 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2215 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2217 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gHelpBlockWidth
- gStatementDimensions
.LeftColumn
);
2222 // 4. Print the down arrow row.
2224 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2225 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * + gModalSkipColumn
);
2227 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2230 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2232 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2233 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2236 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2243 case CfRefreshHighLight
:
2246 // MenuOption: Last menu option that need to remove hilight
2247 // MenuOption is set to NULL in Repaint
2248 // NewPos: Current menu option that need to hilight
2250 ControlFlag
= CfUpdateHelpString
;
2252 if (SkipHighLight
) {
2253 MenuOption
= SavedMenuOption
;
2254 SkipHighLight
= FALSE
;
2255 UpdateHighlightMenuInfo (MenuOption
);
2259 if (IsListEmpty (&gMenuOption
)) {
2261 // No menu option, just update the hotkey filed.
2263 RefreshKeyHelp(gFormData
, NULL
, FALSE
);
2267 if (MenuOption
!= NULL
&& TopOfScreen
== &MenuOption
->Link
) {
2272 if (NewPos
== TopOfScreen
) {
2278 if (NewPos
!= NULL
&& (MenuOption
== NULL
|| NewPos
!= &MenuOption
->Link
)) {
2279 if (MenuOption
!= NULL
) {
2281 // Remove the old highlight menu.
2283 Status
= DisplayOneMenu (MenuOption
,
2284 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2285 gStatementDimensions
.LeftColumn
,
2294 // This is the current selected statement
2296 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2297 Statement
= MenuOption
->ThisTag
;
2299 UpdateHighlightMenuInfo (MenuOption
);
2301 if (!IsSelectable (MenuOption
)) {
2305 Status
= DisplayOneMenu (MenuOption
,
2306 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2307 gStatementDimensions
.LeftColumn
,
2316 case CfUpdateHelpString
:
2317 ControlFlag
= CfPrepareToReadKey
;
2318 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2323 // NewLine means only update highlight menu (remove old highlight and highlith
2324 // the new one), not need to full repain the form.
2326 if (Repaint
|| NewLine
) {
2327 if (IsListEmpty (&gMenuOption
)) {
2329 // Don't print anything if no mwnu option.
2331 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2334 // Don't print anything if it is a NULL help token
2336 ASSERT(MenuOption
!= NULL
);
2337 HelpInfo
= ((EFI_IFR_STATEMENT_HEADER
*) ((CHAR8
*)MenuOption
->ThisTag
->OpCode
+ sizeof (EFI_IFR_OP_HEADER
)))->Help
;
2338 if (HelpInfo
== 0 || !IsSelectable (MenuOption
)) {
2339 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2341 StringPtr
= GetToken (HelpInfo
, gFormData
->HiiHandle
);
2345 RowCount
= BottomRow
- TopRow
+ 1;
2348 // 1.Calculate how many line the help string need to print.
2350 if (HelpString
!= NULL
) {
2351 FreePool (HelpString
);
2354 HelpLine
= ProcessHelpString (StringPtr
, &HelpString
, &EachLineWidth
, RowCount
);
2355 FreePool (StringPtr
);
2357 if (HelpLine
> RowCount
) {
2358 MultiHelpPage
= TRUE
;
2359 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_UP
), gHiiHandle
);
2360 if (HelpHeaderString
!= NULL
) {
2361 FreePool (HelpHeaderString
);
2362 HelpHeaderString
= NULL
;
2364 HelpHeaderLine
= ProcessHelpString (StringPtr
, &HelpHeaderString
, &HeaderLineWidth
, 0);
2365 FreePool (StringPtr
);
2366 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_DOWN
), gHiiHandle
);
2367 if (HelpBottomString
!= NULL
) {
2368 FreePool (HelpBottomString
);
2369 HelpBottomString
= NULL
;
2371 HelpBottomLine
= ProcessHelpString (StringPtr
, &HelpBottomString
, &BottomLineWidth
, 0);
2372 FreePool (StringPtr
);
2374 // Calculate the help page count.
2376 if (HelpLine
> 2 * RowCount
- 2) {
2377 HelpPageCount
= (HelpLine
- RowCount
+ 1) / (RowCount
- 2) + 1;
2378 if ((HelpLine
- RowCount
+ 1) % (RowCount
- 2) > 1) {
2385 MultiHelpPage
= FALSE
;
2390 // Check whether need to show the 'More(U/u)' at the begin.
2391 // Base on current direct info, here shows aligned to the right side of the column.
2392 // If the direction is multi line and aligned to right side may have problem, so
2393 // add ASSERT code here.
2395 if (HelpPageIndex
> 0) {
2396 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2397 for (Index
= 0; Index
< HelpHeaderLine
; Index
++) {
2398 ASSERT (HelpHeaderLine
== 1);
2399 ASSERT (GetStringWidth (HelpHeaderString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2400 PrintStringAtWithWidth (
2401 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2407 gStatementDimensions
.RightColumn
- GetStringWidth (HelpHeaderString
) / 2 - 1,
2409 &HelpHeaderString
[Index
* HeaderLineWidth
]
2414 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHelpTextColor ());
2416 // Print the help string info.
2418 if (!MultiHelpPage
) {
2419 for (Index
= 0; Index
< HelpLine
; Index
++) {
2420 PrintStringAtWithWidth (
2421 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2423 &HelpString
[Index
* EachLineWidth
],
2427 for (; Index
< RowCount
; Index
++) {
2428 PrintStringAtWithWidth (
2429 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2435 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2437 if (HelpPageIndex
== 0) {
2438 for (Index
= 0; Index
< RowCount
- HelpBottomLine
; Index
++) {
2439 PrintStringAtWithWidth (
2440 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2442 &HelpString
[Index
* EachLineWidth
],
2447 for (Index
= 0; (Index
< RowCount
- HelpBottomLine
- HelpHeaderLine
) &&
2448 (Index
+ HelpPageIndex
* (RowCount
- 2) + 1 < HelpLine
); Index
++) {
2449 PrintStringAtWithWidth (
2450 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2451 Index
+ TopRow
+ HelpHeaderLine
,
2452 &HelpString
[(Index
+ HelpPageIndex
* (RowCount
- 2) + 1)* EachLineWidth
],
2456 if (HelpPageIndex
== HelpPageCount
- 1) {
2457 for (; Index
< RowCount
- HelpHeaderLine
; Index
++) {
2458 PrintStringAtWithWidth (
2459 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2460 Index
+ TopRow
+ HelpHeaderLine
,
2465 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2471 // Check whether need to print the 'More(D/d)' at the bottom.
2472 // Base on current direct info, here shows aligned to the right side of the column.
2473 // If the direction is multi line and aligned to right side may have problem, so
2474 // add ASSERT code here.
2476 if (HelpPageIndex
< HelpPageCount
- 1 && MultiHelpPage
) {
2477 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2478 for (Index
= 0; Index
< HelpBottomLine
; Index
++) {
2479 ASSERT (HelpBottomLine
== 1);
2480 ASSERT (GetStringWidth (HelpBottomString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2481 PrintStringAtWithWidth (
2482 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2483 BottomRow
+ Index
- HelpBottomLine
+ 1,
2488 gStatementDimensions
.RightColumn
- GetStringWidth (HelpBottomString
) / 2 - 1,
2489 BottomRow
+ Index
- HelpBottomLine
+ 1,
2490 &HelpBottomString
[Index
* BottomLineWidth
]
2495 // Reset this flag every time we finish using it.
2501 case CfPrepareToReadKey
:
2502 ControlFlag
= CfReadKey
;
2503 ScreenOperation
= UiNoOperation
;
2507 ControlFlag
= CfScreenOperation
;
2510 // Wait for user's selection
2513 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2514 if (!EFI_ERROR (Status
)) {
2515 EventType
= UIEventKey
;
2520 // If we encounter error, continue to read another key in.
2522 if (Status
!= EFI_NOT_READY
) {
2526 EventType
= UiWaitForEvent(gST
->ConIn
->WaitForKey
);
2527 if (EventType
== UIEventKey
) {
2528 gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2533 if (EventType
== UIEventDriver
) {
2534 gUserInput
->Action
= BROWSER_ACTION_NONE
;
2535 ControlFlag
= CfExit
;
2539 if (EventType
== UIEventTimeOut
) {
2540 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2541 ControlFlag
= CfExit
;
2545 switch (Key
.UnicodeChar
) {
2546 case CHAR_CARRIAGE_RETURN
:
2547 if(MenuOption
== NULL
|| MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2548 ControlFlag
= CfReadKey
;
2552 ScreenOperation
= UiSelect
;
2557 // We will push the adjustment of these numeric values directly to the input handler
2558 // NOTE: we won't handle manual input numeric
2563 // If the screen has no menu items, and the user didn't select UiReset
2564 // ignore the selection and go back to reading keys.
2566 ASSERT(MenuOption
!= NULL
);
2567 if(IsListEmpty (&gMenuOption
) || MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2568 ControlFlag
= CfReadKey
;
2572 Statement
= MenuOption
->ThisTag
;
2573 if ((Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
)
2574 || (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
2575 || ((Statement
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) && (GetFieldFromNum(Statement
->OpCode
) != 0))
2577 if (Key
.UnicodeChar
== '+') {
2578 gDirection
= SCAN_RIGHT
;
2580 gDirection
= SCAN_LEFT
;
2583 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2584 if (OptionString
!= NULL
) {
2585 FreePool (OptionString
);
2587 if (EFI_ERROR (Status
)) {
2589 // Repaint to clear possible error prompt pop-up
2594 ControlFlag
= CfExit
;
2600 ScreenOperation
= UiUp
;
2605 ScreenOperation
= UiDown
;
2609 if(IsListEmpty (&gMenuOption
)) {
2610 ControlFlag
= CfReadKey
;
2614 ASSERT(MenuOption
!= NULL
);
2615 if (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_CHECKBOX_OP
&& !MenuOption
->GrayOut
&& !MenuOption
->ReadOnly
) {
2616 ScreenOperation
= UiSelect
;
2622 if (!MultiHelpPage
) {
2623 ControlFlag
= CfReadKey
;
2626 ControlFlag
= CfUpdateHelpString
;
2627 HelpPageIndex
= HelpPageIndex
< HelpPageCount
- 1 ? HelpPageIndex
+ 1 : HelpPageCount
- 1;
2632 if (!MultiHelpPage
) {
2633 ControlFlag
= CfReadKey
;
2636 ControlFlag
= CfUpdateHelpString
;
2637 HelpPageIndex
= HelpPageIndex
> 0 ? HelpPageIndex
- 1 : 0;
2641 for (Index
= 0; Index
< mScanCodeNumber
; Index
++) {
2642 if (Key
.ScanCode
== gScanCodeToOperation
[Index
].ScanCode
) {
2643 ScreenOperation
= gScanCodeToOperation
[Index
].ScreenOperation
;
2648 if (((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) && (Key
.ScanCode
== SCAN_ESC
|| Index
== mScanCodeNumber
)) {
2650 // ModalForm has no ESC key and Hot Key.
2652 ControlFlag
= CfReadKey
;
2653 } else if (Index
== mScanCodeNumber
) {
2655 // Check whether Key matches the registered hot key.
2658 HotKey
= GetHotKeyFromRegisterList (&Key
);
2659 if (HotKey
!= NULL
) {
2660 ScreenOperation
= UiHotKey
;
2667 case CfScreenOperation
:
2668 if ((ScreenOperation
!= UiReset
) && (ScreenOperation
!= UiHotKey
)) {
2670 // If the screen has no menu items, and the user didn't select UiReset or UiHotKey
2671 // ignore the selection and go back to reading keys.
2673 if (IsListEmpty (&gMenuOption
)) {
2674 ControlFlag
= CfReadKey
;
2680 Index
< sizeof (gScreenOperationToControlFlag
) / sizeof (gScreenOperationToControlFlag
[0]);
2683 if (ScreenOperation
== gScreenOperationToControlFlag
[Index
].ScreenOperation
) {
2684 ControlFlag
= gScreenOperationToControlFlag
[Index
].ControlFlag
;
2691 ControlFlag
= CfRepaint
;
2693 ASSERT(MenuOption
!= NULL
);
2694 Statement
= MenuOption
->ThisTag
;
2695 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
2699 switch (Statement
->OpCode
->OpCode
) {
2700 case EFI_IFR_REF_OP
:
2701 case EFI_IFR_ACTION_OP
:
2702 case EFI_IFR_RESET_BUTTON_OP
:
2703 ControlFlag
= CfExit
;
2708 // Editable Questions: oneof, ordered list, checkbox, numeric, string, password
2710 RefreshKeyHelp (gFormData
, Statement
, TRUE
);
2711 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2713 if (OptionString
!= NULL
) {
2714 FreePool (OptionString
);
2717 if (EFI_ERROR (Status
)) {
2720 RefreshKeyHelp (gFormData
, Statement
, FALSE
);
2723 ControlFlag
= CfExit
;
2731 // We come here when someone press ESC
2732 // If the policy is not exit front page when user press ESC, process here.
2734 if (!FormExitPolicy()) {
2737 ControlFlag
= CfRepaint
;
2742 // When user press ESC, it will try to show another menu, should clean the gSequence info.
2744 if (gSequence
!= 0) {
2748 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2749 ControlFlag
= CfExit
;
2753 ControlFlag
= CfRepaint
;
2755 ASSERT (HotKey
!= NULL
);
2756 gUserInput
->Action
= HotKey
->Action
;
2757 ControlFlag
= CfExit
;
2761 ControlFlag
= CfRepaint
;
2762 ASSERT(MenuOption
!= NULL
);
2763 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
2764 if (MenuOption
->Sequence
!= 0) {
2766 // In the middle or tail of the Date/Time op-code set, go left.
2768 ASSERT(NewPos
!= NULL
);
2769 NewPos
= NewPos
->BackLink
;
2775 ControlFlag
= CfRepaint
;
2776 ASSERT(MenuOption
!= NULL
);
2777 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
2778 if (MenuOption
->Sequence
!= 2) {
2780 // In the middle or tail of the Date/Time op-code set, go left.
2782 ASSERT(NewPos
!= NULL
);
2783 NewPos
= NewPos
->ForwardLink
;
2789 ControlFlag
= CfRepaint
;
2792 SavedListEntry
= NewPos
;
2793 ASSERT(NewPos
!= NULL
);
2795 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2796 ASSERT (MenuOption
!= NULL
);
2799 // Adjust Date/Time position before we advance forward.
2801 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2803 NewPos
= NewPos
->BackLink
;
2805 // Find next selectable menu or the first menu beyond current form.
2807 Difference
= MoveToNextStatement (TRUE
, &NewPos
, MenuOption
->Row
- TopRow
, FALSE
);
2808 if (Difference
< 0) {
2810 // We hit the begining MenuOption that can be focused
2811 // so we simply scroll to the top.
2814 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
2815 TopOfScreen
= gMenuOption
.ForwardLink
;
2816 NewPos
= SavedListEntry
;
2820 // Scroll up to the last page when we have arrived at top page.
2822 TopOfScreen
= FindTopOfScreenMenu (gMenuOption
.BackLink
, BottomRow
- TopRow
, &SkipValue
);
2823 NewPos
= gMenuOption
.BackLink
;
2824 MoveToNextStatement (TRUE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
2827 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2829 if (MenuOption
->Row
< TopRow
+ Difference
+ NextMenuOption
->Skip
) {
2831 // Previous focus MenuOption is above the TopOfScreen, so we need to scroll
2833 TopOfScreen
= NewPos
;
2839 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
2841 // BottomRow - TopRow + 1 means the total rows current forms supported.
2842 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
2843 // and new top menu. New top menu will all shows in next form, but last highlight menu
2844 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
2845 // last highlight menu.
2847 if (!IsSelectable(NextMenuOption
) && IsSelectable(MenuOption
) &&
2848 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
2849 NewPos
= SavedListEntry
;
2853 UpdateStatusBar (INPUT_ERROR
, FALSE
);
2856 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
2858 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
2859 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2864 // SkipValue means lines is skipped when show the top menu option.
2866 ControlFlag
= CfRepaint
;
2872 // First minus the menu of the top screen, it's value is SkipValue.
2874 if (SkipValue
>= BottomRow
- TopRow
+ 1) {
2876 // SkipValue > (BottomRow - TopRow + 1) means current menu has more than one
2877 // form of options to be show, so just update the SkipValue to show the next
2878 // parts of options.
2880 SkipValue
-= BottomRow
- TopRow
+ 1;
2881 NewPos
= TopOfScreen
;
2884 Index
= (BottomRow
+ 1) - SkipValue
- TopRow
;
2887 TopOfScreen
= FindTopOfScreenMenu(TopOfScreen
, Index
, &SkipValue
);
2888 NewPos
= TopOfScreen
;
2889 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, FALSE
);
2891 UpdateStatusBar (INPUT_ERROR
, FALSE
);
2894 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
2895 // Don't do this when we are already in the first page.
2897 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
2898 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2903 // SkipValue means lines is skipped when show the top menu option.
2905 ControlFlag
= CfRepaint
;
2910 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
2911 Index
= TopRow
+ NextMenuOption
->Skip
- SkipValue
;
2913 // Count to the menu option which will show at the top of the next form.
2915 while ((Index
<= BottomRow
+ 1) && (Link
->ForwardLink
!= &gMenuOption
)) {
2916 Link
= Link
->ForwardLink
;
2917 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
2918 Index
= Index
+ NextMenuOption
->Skip
;
2921 if ((Link
->ForwardLink
== &gMenuOption
) && (Index
<= BottomRow
+ 1)) {
2923 // Highlight on the last menu which can be highlight.
2926 MoveToNextStatement (TRUE
, &Link
, Index
- TopRow
, TRUE
);
2929 // Calculate the skip line for top of screen menu.
2931 if (Link
== TopOfScreen
) {
2933 // The top of screen menu option occupies the entire form.
2935 SkipValue
+= BottomRow
- TopRow
+ 1;
2937 SkipValue
= NextMenuOption
->Skip
- (Index
- (BottomRow
+ 1));
2942 // Move to the Next selectable menu.
2944 MoveToNextStatement (FALSE
, &Link
, BottomRow
- TopRow
, TRUE
);
2948 // Save the menu as the next highlight menu.
2952 UpdateStatusBar (INPUT_ERROR
, FALSE
);
2955 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
2956 // Don't do this when we are already in the last page.
2958 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
2959 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2964 // SkipValue means lines is skipped when show the top menu option.
2965 // NewPos points to the menu which is highlighted now.
2967 ControlFlag
= CfRepaint
;
2970 if (NewPos
== TopOfScreen
) {
2976 SavedListEntry
= NewPos
;
2978 // Since the behavior of hitting the down arrow on a Date/Time op-code is intended
2979 // to be one that progresses to the next set of op-codes, we need to advance to the last
2980 // Date/Time op-code and leave the remaining logic in UiDown intact so the appropriate
2981 // checking can be done. The only other logic we need to introduce is that if a Date/Time
2982 // op-code is the last entry in the menu, we need to rewind back to the first op-code of
2983 // the Date/Time op-code.
2985 AdjustDateAndTimePosition (FALSE
, &NewPos
);
2987 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2988 NewPos
= NewPos
->ForwardLink
;
2990 // Find the next selectable menu.
2992 if (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
> BottomRow
+ 1) {
2993 if (gMenuOption
.ForwardLink
== NewPos
|| &gMenuOption
== NewPos
) {
2999 Difference
= MoveToNextStatement (FALSE
, &NewPos
, BottomRow
+ 1 - (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
), FALSE
);
3001 if (Difference
< 0) {
3003 // Scroll to the first page.
3005 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3006 TopOfScreen
= gMenuOption
.ForwardLink
;
3010 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3012 NewPos
= gMenuOption
.ForwardLink
;
3013 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
3017 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3019 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3020 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3025 // Get next selected menu info.
3027 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3028 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3029 if (NextMenuOption
->Row
== 0) {
3030 UpdateOptionSkipLines (NextMenuOption
);
3034 // Calculate new highlight menu end row.
3036 Temp
= (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
) + Difference
+ NextMenuOption
->Skip
- 1;
3037 if (Temp
> BottomRow
) {
3039 // Get the top screen menu info.
3041 AdjustDateAndTimePosition (FALSE
, &TopOfScreen
);
3042 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3045 // Current Top screen menu occupy (SavedMenuOption->Skip - SkipValue) rows.
3046 // Full shows the new selected menu need to skip (Temp - BottomRow - 1) rows.
3048 if ((Temp
- BottomRow
) >= (SavedMenuOption
->Skip
- SkipValue
)) {
3050 // Skip the top op-code
3052 TopOfScreen
= TopOfScreen
->ForwardLink
;
3053 DistanceValue
= (Temp
- BottomRow
) - (SavedMenuOption
->Skip
- SkipValue
);
3055 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3058 // If we have a remainder, skip that many more op-codes until we drain the remainder
3059 // Special case is the selected highlight menu has more than one form of menus.
3061 while (DistanceValue
>= SavedMenuOption
->Skip
&& TopOfScreen
!= NewPos
) {
3063 // Since the Difference is greater than or equal to this op-code's skip value, skip it
3065 DistanceValue
= DistanceValue
- (INTN
) SavedMenuOption
->Skip
;
3066 TopOfScreen
= TopOfScreen
->ForwardLink
;
3067 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3070 // Since we will act on this op-code in the next routine, and increment the
3071 // SkipValue, set the skips to one less than what is required.
3073 if (TopOfScreen
!= NewPos
) {
3074 SkipValue
= DistanceValue
;
3080 // Since we will act on this op-code in the next routine, and increment the
3081 // SkipValue, set the skips to one less than what is required.
3083 SkipValue
+= Temp
- BottomRow
;
3086 } else if (!IsSelectable (NextMenuOption
)) {
3088 // Continue to go down until scroll to next page or the selectable option is found.
3090 ScreenOperation
= UiDown
;
3091 ControlFlag
= CfScreenOperation
;
3095 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3098 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
3100 // BottomRow - TopRow + 1 means the total rows current forms supported.
3101 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
3102 // and new top menu. New top menu will all shows in next form, but last highlight menu
3103 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
3104 // last highlight menu.
3106 if (!IsSelectable (NextMenuOption
) && IsSelectable (MenuOption
) &&
3107 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
3108 NewPos
= SavedListEntry
;
3111 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3114 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3116 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3117 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3120 case CfUiNoOperation
:
3121 ControlFlag
= CfRepaint
;
3125 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
3126 if (HelpString
!= NULL
) {
3127 FreePool (HelpString
);
3129 if (HelpHeaderString
!= NULL
) {
3130 FreePool (HelpHeaderString
);
3132 if (HelpBottomString
!= NULL
) {
3133 FreePool (HelpBottomString
);
3145 Base on the browser status info to show an pop up message.
3149 BrowserStatusProcess (
3156 if (gFormData
->BrowserStatus
== BROWSER_SUCCESS
) {
3160 if (gFormData
->ErrorString
!= NULL
) {
3161 ErrorInfo
= gFormData
->ErrorString
;
3163 switch (gFormData
->BrowserStatus
) {
3164 case BROWSER_SUBMIT_FAIL
:
3165 ErrorInfo
= gSaveFailed
;
3168 case BROWSER_NO_SUBMIT_IF
:
3169 ErrorInfo
= gNoSubmitIf
;
3172 case BROWSER_FORM_NOT_FOUND
:
3173 ErrorInfo
= gFormNotFound
;
3176 case BROWSER_FORM_SUPPRESS
:
3177 ErrorInfo
= gFormSuppress
;
3180 case BROWSER_PROTOCOL_NOT_FOUND
:
3181 ErrorInfo
= gProtocolNotFound
;
3185 ErrorInfo
= gBrwoserError
;
3191 // Error occur, prompt error message.
3194 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, gPressEnter
, gEmptyString
, NULL
);
3195 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
3199 Display one form, and return user input.
3201 @param FormData Form Data to be shown.
3202 @param UserInputData User input data.
3204 @retval EFI_SUCCESS 1.Form Data is shown, and user input is got.
3205 2.Error info has show and return.
3206 @retval EFI_INVALID_PARAMETER The input screen dimension is not valid
3207 @retval EFI_NOT_FOUND New form data has some error.
3212 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
3213 OUT USER_INPUT
*UserInputData
3218 ASSERT (FormData
!= NULL
);
3219 if (FormData
== NULL
) {
3220 return EFI_INVALID_PARAMETER
;
3223 gUserInput
= UserInputData
;
3224 gFormData
= FormData
;
3227 // Process the status info first.
3229 BrowserStatusProcess();
3230 if (UserInputData
== NULL
) {
3232 // UserInputData == NULL, means only need to print the error info, return here.
3237 ConvertStatementToMenu();
3239 Status
= DisplayPageFrame (FormData
, &gStatementDimensions
);
3240 if (EFI_ERROR (Status
)) {
3245 // Check whether layout is changed.
3248 || (gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
)
3249 || (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))
3250 || (gOldFormEntry
.FormId
!= FormData
->FormId
)) {
3251 mStatementLayoutIsChanged
= TRUE
;
3253 mStatementLayoutIsChanged
= FALSE
;
3256 Status
= UiDisplayMenu(FormData
);
3259 // Backup last form info.
3261 mIsFirstForm
= FALSE
;
3262 gOldFormEntry
.HiiHandle
= FormData
->HiiHandle
;
3263 CopyGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
);
3264 gOldFormEntry
.FormId
= FormData
->FormId
;
3270 Clear Screen to the initial state.
3274 DriverClearDisplayPage (
3278 ClearDisplayPage ();
3279 mIsFirstForm
= TRUE
;
3283 Set Buffer to Value for Size bytes.
3285 @param Buffer Memory to set.
3286 @param Size Number of bytes to set
3287 @param Value Value of the set operation.
3300 while ((Size
--) != 0) {
3306 Initialize Setup Browser driver.
3308 @param ImageHandle The image handle.
3309 @param SystemTable The system table.
3311 @retval EFI_SUCCESS The Setup Browser module is initialized correctly..
3312 @return Other value if failed to initialize the Setup Browser module.
3317 InitializeDisplayEngine (
3318 IN EFI_HANDLE ImageHandle
,
3319 IN EFI_SYSTEM_TABLE
*SystemTable
3323 EFI_INPUT_KEY HotKey
;
3324 EFI_STRING NewString
;
3325 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL
*FormBrowserEx2
;
3328 // Publish our HII data
3330 gHiiHandle
= HiiAddPackages (
3331 &gDisplayEngineGuid
,
3333 DisplayEngineStrings
,
3336 ASSERT (gHiiHandle
!= NULL
);
3339 // Install Form Display protocol
3341 Status
= gBS
->InstallProtocolInterface (
3342 &mPrivateData
.Handle
,
3343 &gEdkiiFormDisplayEngineProtocolGuid
,
3344 EFI_NATIVE_INTERFACE
,
3345 &mPrivateData
.FromDisplayProt
3347 ASSERT_EFI_ERROR (Status
);
3349 InitializeDisplayStrings();
3351 ZeroMem (&gHighligthMenuInfo
, sizeof (gHighligthMenuInfo
));
3352 ZeroMem (&gOldFormEntry
, sizeof (gOldFormEntry
));
3355 // Use BrowserEx2 protocol to register HotKey.
3357 Status
= gBS
->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid
, NULL
, (VOID
**) &FormBrowserEx2
);
3358 if (!EFI_ERROR (Status
)) {
3360 // Register the default HotKey F9 and F10 again.
3362 HotKey
.UnicodeChar
= CHAR_NULL
;
3363 HotKey
.ScanCode
= SCAN_F10
;
3364 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_TEN_STRING
), NULL
);
3365 ASSERT (NewString
!= NULL
);
3366 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_SUBMIT
, 0, NewString
);
3368 HotKey
.ScanCode
= SCAN_F9
;
3369 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_NINE_STRING
), NULL
);
3370 ASSERT (NewString
!= NULL
);
3371 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_DEFAULT
, EFI_HII_DEFAULT_CLASS_STANDARD
, NewString
);
3378 This is the default unload handle for display core drivers.
3380 @param[in] ImageHandle The drivers' driver image.
3382 @retval EFI_SUCCESS The image is unloaded.
3383 @retval Others Failed to unload the image.
3388 UnloadDisplayEngine (
3389 IN EFI_HANDLE ImageHandle
3392 HiiRemovePackages(gHiiHandle
);
3394 FreeDisplayStrings ();