2 Implementation for handling user input from the User Interfaces.
4 Copyright (c) 2004 - 2012, 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 Get maximum and minimum info from this opcode.
20 @param OpCode Pointer to the current input opcode.
21 @param Minimum The minimum size info for this opcode.
22 @param Maximum The maximum size info for this opcode.
27 IN EFI_IFR_OP_HEADER
*OpCode
,
32 EFI_IFR_STRING
*StringOp
;
33 EFI_IFR_PASSWORD
*PasswordOp
;
34 if (OpCode
->OpCode
== EFI_IFR_STRING_OP
) {
35 StringOp
= (EFI_IFR_STRING
*) OpCode
;
36 *Minimum
= StringOp
->MinSize
;
37 *Maximum
= StringOp
->MaxSize
;
38 } else if (OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) {
39 PasswordOp
= (EFI_IFR_PASSWORD
*) OpCode
;
40 *Minimum
= PasswordOp
->MinSize
;
41 *Maximum
= PasswordOp
->MaxSize
;
49 Get string or password input from user.
51 @param MenuOption Pointer to the current input menu.
52 @param Prompt The prompt string shown on popup window.
53 @param StringPtr Old user input and destination for use input string.
55 @retval EFI_SUCCESS If string input is read successfully
56 @retval EFI_DEVICE_ERROR If operation fails
61 IN UI_MENU_OPTION
*MenuOption
,
63 IN OUT CHAR16
*StringPtr
73 CHAR16
*BufferedString
;
79 UINTN DimensionsWidth
;
80 UINTN DimensionsHeight
;
82 BOOLEAN CursorVisible
;
85 FORM_DISPLAY_ENGINE_STATEMENT
*Question
;
88 DimensionsWidth
= gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
;
89 DimensionsHeight
= gStatementDimensions
.BottomRow
- gStatementDimensions
.TopRow
;
91 NullCharacter
= CHAR_NULL
;
92 ScreenSize
= GetStringWidth (Prompt
) / sizeof (CHAR16
);
96 Question
= MenuOption
->ThisTag
;
97 GetFieldFromOp(Question
->OpCode
, &Minimum
, &Maximum
);
99 if (Question
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) {
105 TempString
= AllocateZeroPool ((Maximum
+ 1)* sizeof (CHAR16
));
108 if (ScreenSize
< (Maximum
+ 1)) {
109 ScreenSize
= Maximum
+ 1;
112 if ((ScreenSize
+ 2) > DimensionsWidth
) {
113 ScreenSize
= DimensionsWidth
- 2;
116 BufferedString
= AllocateZeroPool (ScreenSize
* 2);
117 ASSERT (BufferedString
);
119 Start
= (DimensionsWidth
- ScreenSize
- 2) / 2 + gStatementDimensions
.LeftColumn
+ 1;
120 Top
= ((DimensionsHeight
- 6) / 2) + gStatementDimensions
.TopRow
- 1;
123 // Display prompt for string
125 // CreateDialog (NULL, "", Prompt, Space, "", NULL);
126 CreateMultiStringPopUp (ScreenSize
, 4, &NullCharacter
, Prompt
, Space
, &NullCharacter
);
127 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_BLACK
, EFI_LIGHTGRAY
));
129 CursorVisible
= gST
->ConOut
->Mode
->CursorVisible
;
130 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
132 CurrentCursor
= GetStringWidth (StringPtr
) / 2 - 1;
133 if (CurrentCursor
!= 0) {
135 // Show the string which has beed saved before.
137 SetUnicodeMem (BufferedString
, ScreenSize
- 1, L
' ');
138 PrintStringAt (Start
+ 1, Top
+ 3, BufferedString
);
140 if ((GetStringWidth (StringPtr
) / 2) > (DimensionsWidth
- 2)) {
141 Index
= (GetStringWidth (StringPtr
) / 2) - DimensionsWidth
+ 2;
147 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, Start
+ 1, Top
+ 3);
150 for (Count
= 0; Index
+ 1 < GetStringWidth (StringPtr
) / 2; Index
++, Count
++) {
151 BufferedString
[Count
] = StringPtr
[Index
];
154 PrintCharAt ((UINTN
)-1, (UINTN
)-1, L
'*');
159 PrintStringAt (Start
+ 1, Top
+ 3, BufferedString
);
162 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
163 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, Start
+ GetStringWidth (StringPtr
) / 2, Top
+ 3);
167 Status
= WaitForKeyStroke (&Key
);
168 ASSERT_EFI_ERROR (Status
);
170 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_BLACK
, EFI_LIGHTGRAY
));
171 switch (Key
.UnicodeChar
) {
173 switch (Key
.ScanCode
) {
175 if (CurrentCursor
> 0) {
181 if (CurrentCursor
< (GetStringWidth (StringPtr
) / 2 - 1)) {
187 FreePool (TempString
);
188 FreePool (BufferedString
);
189 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
190 gST
->ConOut
->EnableCursor (gST
->ConOut
, CursorVisible
);
191 return EFI_DEVICE_ERROR
;
194 for (Index
= CurrentCursor
; StringPtr
[Index
] != CHAR_NULL
; Index
++) {
195 StringPtr
[Index
] = StringPtr
[Index
+ 1];
196 PrintCharAt (Start
+ Index
+ 1, Top
+ 3, IsPassword
&& StringPtr
[Index
] != CHAR_NULL
? L
'*' : StringPtr
[Index
]);
206 case CHAR_CARRIAGE_RETURN
:
207 if (GetStringWidth (StringPtr
) >= ((Minimum
+ 1) * sizeof (CHAR16
))) {
209 FreePool (TempString
);
210 FreePool (BufferedString
);
211 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
212 gST
->ConOut
->EnableCursor (gST
->ConOut
, CursorVisible
);
216 // Simply create a popup to tell the user that they had typed in too few characters.
217 // To save code space, we can then treat this as an error and return back to the menu.
220 CreateDialog (&Key
, &NullCharacter
, gMiniString
, gPressEnter
, &NullCharacter
, NULL
);
221 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
223 FreePool (TempString
);
224 FreePool (BufferedString
);
225 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
226 gST
->ConOut
->EnableCursor (gST
->ConOut
, CursorVisible
);
227 return EFI_DEVICE_ERROR
;
233 if (StringPtr
[0] != CHAR_NULL
&& CurrentCursor
!= 0) {
234 for (Index
= 0; Index
< CurrentCursor
- 1; Index
++) {
235 TempString
[Index
] = StringPtr
[Index
];
237 Count
= GetStringWidth (StringPtr
) / 2 - 1;
238 if (Count
>= CurrentCursor
) {
239 for (Index
= CurrentCursor
- 1, Index2
= CurrentCursor
; Index2
< Count
; Index
++, Index2
++) {
240 TempString
[Index
] = StringPtr
[Index2
];
242 TempString
[Index
] = CHAR_NULL
;
245 // Effectively truncate string by 1 character
247 StrCpy (StringPtr
, TempString
);
253 // If it is the beginning of the string, don't worry about checking maximum limits
255 if ((StringPtr
[0] == CHAR_NULL
) && (Key
.UnicodeChar
!= CHAR_BACKSPACE
)) {
256 StrnCpy (StringPtr
, &Key
.UnicodeChar
, 1);
258 } else if ((GetStringWidth (StringPtr
) < ((Maximum
+ 1) * sizeof (CHAR16
))) && (Key
.UnicodeChar
!= CHAR_BACKSPACE
)) {
259 KeyPad
[0] = Key
.UnicodeChar
;
260 KeyPad
[1] = CHAR_NULL
;
261 Count
= GetStringWidth (StringPtr
) / 2 - 1;
262 if (CurrentCursor
< Count
) {
263 for (Index
= 0; Index
< CurrentCursor
; Index
++) {
264 TempString
[Index
] = StringPtr
[Index
];
266 TempString
[Index
] = CHAR_NULL
;
267 StrCat (TempString
, KeyPad
);
268 StrCat (TempString
, StringPtr
+ CurrentCursor
);
269 StrCpy (StringPtr
, TempString
);
271 StrCat (StringPtr
, KeyPad
);
277 // If the width of the input string is now larger than the screen, we nee to
278 // adjust the index to start printing portions of the string
280 SetUnicodeMem (BufferedString
, ScreenSize
- 1, L
' ');
281 PrintStringAt (Start
+ 1, Top
+ 3, BufferedString
);
283 if ((GetStringWidth (StringPtr
) / 2) > (DimensionsWidth
- 2)) {
284 Index
= (GetStringWidth (StringPtr
) / 2) - DimensionsWidth
+ 2;
290 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, Start
+ 1, Top
+ 3);
293 for (Count
= 0; Index
+ 1 < GetStringWidth (StringPtr
) / 2; Index
++, Count
++) {
294 BufferedString
[Count
] = StringPtr
[Index
];
297 PrintCharAt ((UINTN
)-1, (UINTN
)-1, L
'*');
302 PrintStringAt (Start
+ 1, Top
+ 3, BufferedString
);
307 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
308 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, Start
+ CurrentCursor
+ 1, Top
+ 3);
314 Adjust the value to the correct one. Rules follow the sample:
315 like: Year change: 2012.02.29 -> 2013.02.29 -> 2013.02.01
316 Month change: 2013.03.29 -> 2013.02.29 -> 2013.02.28
318 @param QuestionValue Pointer to current question.
319 @param Sequence The sequence of the field in the question.
322 AdjustQuestionValue (
323 IN EFI_HII_VALUE
*QuestionValue
,
332 Month
= QuestionValue
->Value
.date
.Month
;
333 Year
= QuestionValue
->Value
.date
.Year
;
338 if ((Year
% 4) == 0 && ((Year
% 100) != 0 || (Year
% 400) == 0)) {
356 // Change the month area.
359 if (QuestionValue
->Value
.date
.Day
> Maximum
) {
360 QuestionValue
->Value
.date
.Day
= Maximum
;
365 // Change the Year area.
368 if (QuestionValue
->Value
.date
.Day
> Maximum
) {
369 QuestionValue
->Value
.date
.Day
= Minimum
;
375 Get field info from numeric opcode.
377 @param OpCode Pointer to the current input opcode.
378 @param IntInput Whether question shows with EFI_IFR_DISPLAY_INT_DEC type.
379 @param QuestionValue Input question value, with EFI_HII_VALUE type.
380 @param Value Return question value, always return UINT64 type.
381 @param Minimum The minimum size info for this opcode.
382 @param Maximum The maximum size info for this opcode.
383 @param Step The step size info for this opcode.
384 @param StorageWidth The storage width info for this opcode.
389 IN EFI_IFR_OP_HEADER
*OpCode
,
391 IN EFI_HII_VALUE
*QuestionValue
,
396 OUT UINT16
*StorageWidth
399 EFI_IFR_NUMERIC
*NumericOp
;
401 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
403 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
404 case EFI_IFR_NUMERIC_SIZE_1
:
406 *Minimum
= (INT64
) (INT8
) NumericOp
->data
.u8
.MinValue
;
407 *Maximum
= (INT64
) (INT8
) NumericOp
->data
.u8
.MaxValue
;
408 *Value
= (INT64
) (INT8
) QuestionValue
->Value
.u8
;
410 *Minimum
= NumericOp
->data
.u8
.MinValue
;
411 *Maximum
= NumericOp
->data
.u8
.MaxValue
;
412 *Value
= QuestionValue
->Value
.u8
;
414 *Step
= NumericOp
->data
.u8
.Step
;
415 *StorageWidth
= (UINT16
) sizeof (UINT8
);
418 case EFI_IFR_NUMERIC_SIZE_2
:
420 *Minimum
= (INT64
) (INT16
) NumericOp
->data
.u16
.MinValue
;
421 *Maximum
= (INT64
) (INT16
) NumericOp
->data
.u16
.MaxValue
;
422 *Value
= (INT64
) (INT16
) QuestionValue
->Value
.u16
;
424 *Minimum
= NumericOp
->data
.u16
.MinValue
;
425 *Maximum
= NumericOp
->data
.u16
.MaxValue
;
426 *Value
= QuestionValue
->Value
.u16
;
428 *Step
= NumericOp
->data
.u16
.Step
;
429 *StorageWidth
= (UINT16
) sizeof (UINT16
);
432 case EFI_IFR_NUMERIC_SIZE_4
:
434 *Minimum
= (INT64
) (INT32
) NumericOp
->data
.u32
.MinValue
;
435 *Maximum
= (INT64
) (INT32
) NumericOp
->data
.u32
.MaxValue
;
436 *Value
= (INT64
) (INT32
) QuestionValue
->Value
.u32
;
438 *Minimum
= NumericOp
->data
.u32
.MinValue
;
439 *Maximum
= NumericOp
->data
.u32
.MaxValue
;
440 *Value
= QuestionValue
->Value
.u32
;
442 *Step
= NumericOp
->data
.u32
.Step
;
443 *StorageWidth
= (UINT16
) sizeof (UINT32
);
446 case EFI_IFR_NUMERIC_SIZE_8
:
448 *Minimum
= (INT64
) NumericOp
->data
.u64
.MinValue
;
449 *Maximum
= (INT64
) NumericOp
->data
.u64
.MaxValue
;
450 *Value
= (INT64
) QuestionValue
->Value
.u64
;
452 *Minimum
= NumericOp
->data
.u64
.MinValue
;
453 *Maximum
= NumericOp
->data
.u64
.MaxValue
;
454 *Value
= QuestionValue
->Value
.u64
;
456 *Step
= NumericOp
->data
.u64
.Step
;
457 *StorageWidth
= (UINT16
) sizeof (UINT64
);
465 *Maximum
= (UINT64
) -1;
470 This routine reads a numeric value from the user input.
472 @param MenuOption Pointer to the current input menu.
474 @retval EFI_SUCCESS If numerical input is read successfully
475 @retval EFI_DEVICE_ERROR If operation fails
480 IN UI_MENU_OPTION
*MenuOption
485 CHAR16 InputText
[MAX_NUMERIC_INPUT_WIDTH
];
486 CHAR16 FormattedNumber
[MAX_NUMERIC_INPUT_WIDTH
- 1];
487 UINT64 PreviousNumber
[MAX_NUMERIC_INPUT_WIDTH
- 3];
494 BOOLEAN ValidateFail
;
504 EFI_HII_VALUE
*QuestionValue
;
505 FORM_DISPLAY_ENGINE_STATEMENT
*Question
;
506 EFI_IFR_NUMERIC
*NumericOp
;
509 Column
= MenuOption
->OptCol
;
510 Row
= MenuOption
->Row
;
511 PreviousNumber
[0] = 0;
522 ValidateFail
= FALSE
;
524 Question
= MenuOption
->ThisTag
;
525 QuestionValue
= &Question
->CurrentValue
;
528 // Only two case, user can enter to this function: Enter and +/- case.
529 // In Enter case, gDirection = 0; in +/- case, gDirection = SCAN_LEFT/SCAN_WRIGHT
531 ManualInput
= (BOOLEAN
)(gDirection
== 0 ? TRUE
: FALSE
);
533 if ((Question
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (Question
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
540 // Prepare Value to be edit
544 if (Question
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
548 switch (MenuOption
->Sequence
) {
552 EditValue
= QuestionValue
->Value
.date
.Month
;
556 switch (QuestionValue
->Value
.date
.Month
) {
558 if ((QuestionValue
->Value
.date
.Year
% 4) == 0 &&
559 ((QuestionValue
->Value
.date
.Year
% 100) != 0 ||
560 (QuestionValue
->Value
.date
.Year
% 400) == 0)) {
578 EditValue
= QuestionValue
->Value
.date
.Day
;
584 EditValue
= QuestionValue
->Value
.date
.Year
;
590 } else if (Question
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
594 switch (MenuOption
->Sequence
) {
598 EditValue
= QuestionValue
->Value
.time
.Hour
;
604 EditValue
= QuestionValue
->Value
.time
.Minute
;
610 EditValue
= QuestionValue
->Value
.time
.Second
;
617 ASSERT (Question
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
);
618 NumericOp
= (EFI_IFR_NUMERIC
*) Question
->OpCode
;
619 GetValueFromNum(Question
->OpCode
, (NumericOp
->Flags
& EFI_IFR_DISPLAY
) == 0, QuestionValue
, &EditValue
, &Minimum
, &Maximum
, &Step
, &StorageWidth
);
620 EraseLen
= gOptionBlockWidth
;
623 if ((Question
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) && (NumericOp
!= NULL
)) {
624 if ((NumericOp
->Flags
& EFI_IFR_DISPLAY
) == EFI_IFR_DISPLAY_UINT_HEX
){
626 } else if ((NumericOp
->Flags
& EFI_IFR_DISPLAY
) == 0){
628 // Display with EFI_IFR_DISPLAY_INT_DEC type. Support negative number.
635 // Enter from "Enter" input, clear the old word showing.
638 if (Question
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) {
640 InputWidth
= StorageWidth
* 2;
642 switch (StorageWidth
) {
666 // Support an extra '-' for negative number.
672 InputText
[0] = LEFT_NUMERIC_DELIMITER
;
673 SetUnicodeMem (InputText
+ 1, InputWidth
, L
' ');
674 ASSERT (InputWidth
+ 2 < MAX_NUMERIC_INPUT_WIDTH
);
675 InputText
[InputWidth
+ 1] = RIGHT_NUMERIC_DELIMITER
;
676 InputText
[InputWidth
+ 2] = L
'\0';
678 PrintStringAt (Column
, Row
, InputText
);
682 if (Question
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
683 if (MenuOption
->Sequence
== 2) {
689 if (MenuOption
->Sequence
== 0) {
690 InputText
[0] = LEFT_NUMERIC_DELIMITER
;
691 SetUnicodeMem (InputText
+ 1, InputWidth
, L
' ');
693 SetUnicodeMem (InputText
, InputWidth
, L
' ');
696 if (MenuOption
->Sequence
== 2) {
697 InputText
[InputWidth
+ 1] = RIGHT_NUMERIC_DELIMITER
;
699 InputText
[InputWidth
+ 1] = DATE_SEPARATOR
;
701 InputText
[InputWidth
+ 2] = L
'\0';
703 PrintStringAt (Column
, Row
, InputText
);
704 if (MenuOption
->Sequence
== 0) {
709 if (Question
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
712 if (MenuOption
->Sequence
== 0) {
713 InputText
[0] = LEFT_NUMERIC_DELIMITER
;
714 SetUnicodeMem (InputText
+ 1, InputWidth
, L
' ');
716 SetUnicodeMem (InputText
, InputWidth
, L
' ');
719 if (MenuOption
->Sequence
== 2) {
720 InputText
[InputWidth
+ 1] = RIGHT_NUMERIC_DELIMITER
;
722 InputText
[InputWidth
+ 1] = TIME_SEPARATOR
;
724 InputText
[InputWidth
+ 2] = L
'\0';
726 PrintStringAt (Column
, Row
, InputText
);
727 if (MenuOption
->Sequence
== 0) {
734 // First time we enter this handler, we need to check to see if
735 // we were passed an increment or decrement directive
738 Key
.UnicodeChar
= CHAR_NULL
;
739 if (gDirection
!= 0) {
740 Key
.ScanCode
= gDirection
;
745 WaitForKeyStroke (&Key
);
748 switch (Key
.UnicodeChar
) {
752 if (ManualInput
&& IntInput
) {
754 // In Manual input mode, check whether input the negative flag.
756 if (Key
.UnicodeChar
== '-') {
761 PrintCharAt (Column
++, Row
, Key
.UnicodeChar
);
764 if (Key
.UnicodeChar
== '+') {
765 Key
.ScanCode
= SCAN_RIGHT
;
767 Key
.ScanCode
= SCAN_LEFT
;
769 Key
.UnicodeChar
= CHAR_NULL
;
775 switch (Key
.ScanCode
) {
778 if (DateOrTime
&& !ManualInput
) {
780 // By setting this value, we will return back to the caller.
781 // We need to do this since an auto-refresh will destroy the adjustment
782 // based on what the real-time-clock is showing. So we always commit
783 // upon changing the value.
785 gDirection
= SCAN_DOWN
;
788 if ((Step
!= 0) && !ManualInput
) {
789 if (Key
.ScanCode
== SCAN_LEFT
) {
791 if ((INT64
) EditValue
>= (INT64
) Minimum
+ (INT64
) Step
) {
792 EditValue
= EditValue
- Step
;
793 } else if ((INT64
) EditValue
> (INT64
) Minimum
){
799 if (EditValue
>= Minimum
+ Step
) {
800 EditValue
= EditValue
- Step
;
801 } else if (EditValue
> Minimum
){
807 } else if (Key
.ScanCode
== SCAN_RIGHT
) {
809 if ((INT64
) EditValue
+ (INT64
) Step
<= (INT64
) Maximum
) {
810 EditValue
= EditValue
+ Step
;
811 } else if ((INT64
) EditValue
< (INT64
) Maximum
) {
817 if (EditValue
+ Step
<= Maximum
) {
818 EditValue
= EditValue
+ Step
;
819 } else if (EditValue
< Maximum
) {
827 ZeroMem (FormattedNumber
, 21 * sizeof (CHAR16
));
828 if (Question
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
829 if (MenuOption
->Sequence
== 2) {
833 UnicodeSPrint (FormattedNumber
, 21 * sizeof (CHAR16
), L
"%04d", (UINT16
) EditValue
);
838 UnicodeSPrint (FormattedNumber
, 21 * sizeof (CHAR16
), L
"%02d", (UINT8
) EditValue
);
841 if (MenuOption
->Sequence
== 0) {
842 ASSERT (EraseLen
>= 2);
843 FormattedNumber
[EraseLen
- 2] = DATE_SEPARATOR
;
844 } else if (MenuOption
->Sequence
== 1) {
845 ASSERT (EraseLen
>= 1);
846 FormattedNumber
[EraseLen
- 1] = DATE_SEPARATOR
;
848 } else if (Question
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
849 UnicodeSPrint (FormattedNumber
, 21 * sizeof (CHAR16
), L
"%02d", (UINT8
) EditValue
);
851 if (MenuOption
->Sequence
== 0) {
852 ASSERT (EraseLen
>= 2);
853 FormattedNumber
[EraseLen
- 2] = TIME_SEPARATOR
;
854 } else if (MenuOption
->Sequence
== 1) {
855 ASSERT (EraseLen
>= 1);
856 FormattedNumber
[EraseLen
- 1] = TIME_SEPARATOR
;
859 QuestionValue
->Value
.u64
= EditValue
;
860 PrintFormattedNumber (Question
, FormattedNumber
, 21 * sizeof (CHAR16
));
863 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
864 for (Loop
= 0; Loop
< EraseLen
; Loop
++) {
865 PrintStringAt (MenuOption
->OptCol
+ Loop
, MenuOption
->Row
, L
" ");
867 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
869 if (MenuOption
->Sequence
== 0) {
870 PrintCharAt (MenuOption
->OptCol
, Row
, LEFT_NUMERIC_DELIMITER
);
871 Column
= MenuOption
->OptCol
+ 1;
874 PrintStringAt (Column
, Row
, FormattedNumber
);
876 if (!DateOrTime
|| MenuOption
->Sequence
== 2) {
877 PrintCharAt ((UINTN
)-1, (UINTN
)-1, RIGHT_NUMERIC_DELIMITER
);
881 goto EnterCarriageReturn
;
886 goto EnterCarriageReturn
;
889 return EFI_DEVICE_ERROR
;
899 case CHAR_CARRIAGE_RETURN
:
901 // Validate input value with Minimum value.
903 ValidateFail
= FALSE
;
906 // After user input Enter, need to check whether the input value.
907 // If input a negative value, should compare with maximum value.
908 // else compare with the minimum value.
911 ValidateFail
= (INT64
) EditValue
> (INT64
) Maximum
? TRUE
: FALSE
;
913 ValidateFail
= (INT64
) EditValue
< (INT64
) Minimum
? TRUE
: FALSE
;
917 UpdateStatusBar (INPUT_ERROR
, TRUE
);
920 } else if (EditValue
< Minimum
) {
921 UpdateStatusBar (INPUT_ERROR
, TRUE
);
925 UpdateStatusBar (INPUT_ERROR
, FALSE
);
926 CopyMem (&gUserInput
->InputValue
, &Question
->CurrentValue
, sizeof (EFI_HII_VALUE
));
927 QuestionValue
= &gUserInput
->InputValue
;
929 // Store Edit value back to Question
931 if (Question
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
932 switch (MenuOption
->Sequence
) {
934 QuestionValue
->Value
.date
.Month
= (UINT8
) EditValue
;
938 QuestionValue
->Value
.date
.Day
= (UINT8
) EditValue
;
942 QuestionValue
->Value
.date
.Year
= (UINT16
) EditValue
;
948 } else if (Question
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
949 switch (MenuOption
->Sequence
) {
951 QuestionValue
->Value
.time
.Hour
= (UINT8
) EditValue
;
955 QuestionValue
->Value
.time
.Minute
= (UINT8
) EditValue
;
959 QuestionValue
->Value
.time
.Second
= (UINT8
) EditValue
;
969 QuestionValue
->Value
.u64
= EditValue
;
973 // Adjust the value to the correct one.
974 // Sample like: 2012.02.29 -> 2013.02.29 -> 2013.02.01
975 // 2013.03.29 -> 2013.02.29 -> 2013.02.28
977 if (Question
->OpCode
->OpCode
== EFI_IFR_DATE_OP
&&
978 (MenuOption
->Sequence
== 0 || MenuOption
->Sequence
== 2)) {
979 AdjustQuestionValue (QuestionValue
, (UINT8
)MenuOption
->Sequence
);
991 PrintStringAt (Column
, Row
, L
" ");
996 // Remove a character
998 EditValue
= PreviousNumber
[Count
- 1];
999 UpdateStatusBar (INPUT_ERROR
, FALSE
);
1002 PrintStringAt (Column
, Row
, L
" ");
1009 if ((Key
.UnicodeChar
>= L
'0') && (Key
.UnicodeChar
<= L
'9')) {
1010 Digital
= (UINT8
) (Key
.UnicodeChar
- L
'0');
1011 } else if ((Key
.UnicodeChar
>= L
'A') && (Key
.UnicodeChar
<= L
'F')) {
1012 Digital
= (UINT8
) (Key
.UnicodeChar
- L
'A' + 0x0A);
1013 } else if ((Key
.UnicodeChar
>= L
'a') && (Key
.UnicodeChar
<= L
'f')) {
1014 Digital
= (UINT8
) (Key
.UnicodeChar
- L
'a' + 0x0A);
1016 UpdateStatusBar (INPUT_ERROR
, TRUE
);
1020 if (Key
.UnicodeChar
> L
'9' || Key
.UnicodeChar
< L
'0') {
1021 UpdateStatusBar (INPUT_ERROR
, TRUE
);
1027 // If Count exceed input width, there is no way more is valid
1029 if (Count
>= InputWidth
) {
1033 // Someone typed something valid!
1037 EditValue
= LShiftU64 (EditValue
, 4) + Digital
;
1038 } else if (IntInput
&& Negative
) {
1040 // Save the negative number.
1042 EditValue
= ~(MultU64x32 (~(EditValue
- 1), 10) + (Key
.UnicodeChar
- L
'0')) + 1;
1044 EditValue
= MultU64x32 (EditValue
, 10) + (Key
.UnicodeChar
- L
'0');
1048 EditValue
= Digital
;
1049 } else if (IntInput
&& Negative
) {
1051 // Save the negative number.
1053 EditValue
= ~(Key
.UnicodeChar
- L
'0') + 1;
1055 EditValue
= Key
.UnicodeChar
- L
'0';
1060 ValidateFail
= FALSE
;
1062 // When user input a new value, should check the current value.
1063 // If user input a negative value, should compare it with minimum
1064 // value, else compare it with maximum value.
1067 ValidateFail
= (INT64
) EditValue
< (INT64
) Minimum
? TRUE
: FALSE
;
1069 ValidateFail
= (INT64
) EditValue
> (INT64
) Maximum
? TRUE
: FALSE
;
1073 UpdateStatusBar (INPUT_ERROR
, TRUE
);
1074 ASSERT (Count
< sizeof (PreviousNumber
) / sizeof (PreviousNumber
[0]));
1075 EditValue
= PreviousNumber
[Count
];
1079 if (EditValue
> Maximum
) {
1080 UpdateStatusBar (INPUT_ERROR
, TRUE
);
1081 ASSERT (Count
< sizeof (PreviousNumber
) / sizeof (PreviousNumber
[0]));
1082 EditValue
= PreviousNumber
[Count
];
1087 UpdateStatusBar (INPUT_ERROR
, FALSE
);
1090 ASSERT (Count
< (sizeof (PreviousNumber
) / sizeof (PreviousNumber
[0])));
1091 PreviousNumber
[Count
] = EditValue
;
1093 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
1094 PrintCharAt (Column
, Row
, Key
.UnicodeChar
);
1103 Adjust option order base on the question value.
1105 @param Question Pointer to current question.
1106 @param PopUpMenuLines The line number of the pop up menu.
1108 @retval EFI_SUCCESS If Option input is processed successfully
1109 @retval EFI_DEVICE_ERROR If operation fails
1114 IN FORM_DISPLAY_ENGINE_STATEMENT
*Question
,
1115 OUT UINTN
*PopUpMenuLines
1119 EFI_IFR_ORDERED_LIST
*OrderList
;
1123 DISPLAY_QUESTION_OPTION
*OneOfOption
;
1124 EFI_HII_VALUE
*HiiValueArray
;
1126 Link
= GetFirstNode (&Question
->OptionListHead
);
1127 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1128 ValueArray
= Question
->CurrentValue
.Buffer
;
1129 ValueType
= OneOfOption
->OptionOpCode
->Type
;
1130 OrderList
= (EFI_IFR_ORDERED_LIST
*) Question
->OpCode
;
1132 for (Index
= 0; Index
< OrderList
->MaxContainers
; Index
++) {
1133 if (GetArrayData (ValueArray
, ValueType
, Index
) == 0) {
1138 *PopUpMenuLines
= Index
;
1141 // Prepare HiiValue array
1143 HiiValueArray
= AllocateZeroPool (*PopUpMenuLines
* sizeof (EFI_HII_VALUE
));
1144 ASSERT (HiiValueArray
!= NULL
);
1146 for (Index
= 0; Index
< *PopUpMenuLines
; Index
++) {
1147 HiiValueArray
[Index
].Type
= ValueType
;
1148 HiiValueArray
[Index
].Value
.u64
= GetArrayData (ValueArray
, ValueType
, Index
);
1151 for (Index
= 0; Index
< *PopUpMenuLines
; Index
++) {
1152 OneOfOption
= ValueToOption (Question
, &HiiValueArray
[*PopUpMenuLines
- Index
- 1]);
1153 if (OneOfOption
== NULL
) {
1154 return EFI_NOT_FOUND
;
1157 RemoveEntryList (&OneOfOption
->Link
);
1162 InsertHeadList (&Question
->OptionListHead
, &OneOfOption
->Link
);
1165 FreePool (HiiValueArray
);
1171 Base on the type to compare the value.
1173 @param Value1 The first value need to compare.
1174 @param Value2 The second value need to compare.
1175 @param Type The value type for above two values.
1177 @retval TRUE The two value are same.
1178 @retval FALSE The two value are different.
1183 IN EFI_IFR_TYPE_VALUE
*Value1
,
1184 IN EFI_IFR_TYPE_VALUE
*Value2
,
1189 case EFI_IFR_TYPE_BOOLEAN
:
1190 case EFI_IFR_TYPE_NUM_SIZE_8
:
1191 return (BOOLEAN
) (Value1
->u8
== Value2
->u8
);
1193 case EFI_IFR_TYPE_NUM_SIZE_16
:
1194 return (BOOLEAN
) (Value1
->u16
== Value2
->u16
);
1196 case EFI_IFR_TYPE_NUM_SIZE_32
:
1197 return (BOOLEAN
) (Value1
->u32
== Value2
->u32
);
1199 case EFI_IFR_TYPE_NUM_SIZE_64
:
1200 return (BOOLEAN
) (Value1
->u64
== Value2
->u64
);
1209 Base on the type to set the value.
1211 @param Dest The dest value.
1212 @param Source The source value.
1213 @param Type The value type for above two values.
1218 OUT EFI_IFR_TYPE_VALUE
*Dest
,
1219 IN EFI_IFR_TYPE_VALUE
*Source
,
1224 case EFI_IFR_TYPE_BOOLEAN
:
1225 Dest
->b
= Source
->b
;
1228 case EFI_IFR_TYPE_NUM_SIZE_8
:
1229 Dest
->u8
= Source
->u8
;
1232 case EFI_IFR_TYPE_NUM_SIZE_16
:
1233 Dest
->u16
= Source
->u16
;
1236 case EFI_IFR_TYPE_NUM_SIZE_32
:
1237 Dest
->u32
= Source
->u32
;
1240 case EFI_IFR_TYPE_NUM_SIZE_64
:
1241 Dest
->u64
= Source
->u64
;
1251 Get selection for OneOf and OrderedList (Left/Right will be ignored).
1253 @param MenuOption Pointer to the current input menu.
1255 @retval EFI_SUCCESS If Option input is processed successfully
1256 @retval EFI_DEVICE_ERROR If operation fails
1260 GetSelectionInputPopUp (
1261 IN UI_MENU_OPTION
*MenuOption
1267 CHAR16
*TempStringPtr
;
1269 UINTN TopOptionIndex
;
1270 UINTN HighlightOptionIndex
;
1275 UINTN PopUpMenuLines
;
1276 UINTN MenuLinesInView
;
1279 INT32 SavedAttribute
;
1280 BOOLEAN ShowDownArrow
;
1281 BOOLEAN ShowUpArrow
;
1282 UINTN DimensionsWidth
;
1284 BOOLEAN OrderedList
;
1288 EFI_HII_VALUE HiiValue
;
1289 DISPLAY_QUESTION_OPTION
*OneOfOption
;
1290 DISPLAY_QUESTION_OPTION
*CurrentOption
;
1291 FORM_DISPLAY_ENGINE_STATEMENT
*Question
;
1293 EFI_IFR_ORDERED_LIST
*OrderList
;
1295 DimensionsWidth
= gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
;
1299 CurrentOption
= NULL
;
1300 ShowDownArrow
= FALSE
;
1301 ShowUpArrow
= FALSE
;
1303 StringPtr
= AllocateZeroPool ((gOptionBlockWidth
+ 1) * 2);
1306 ZeroMem (&HiiValue
, sizeof (EFI_HII_VALUE
));
1308 Question
= MenuOption
->ThisTag
;
1309 if (Question
->OpCode
->OpCode
== EFI_IFR_ORDERED_LIST_OP
) {
1310 Link
= GetFirstNode (&Question
->OptionListHead
);
1311 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1312 ValueArray
= Question
->CurrentValue
.Buffer
;
1313 ValueType
= OneOfOption
->OptionOpCode
->Type
;
1315 OrderList
= (EFI_IFR_ORDERED_LIST
*) Question
->OpCode
;
1317 OrderedList
= FALSE
;
1322 // Calculate Option count
1326 AdjustOptionOrder(Question
, &PopUpMenuLines
);
1328 Link
= GetFirstNode (&Question
->OptionListHead
);
1329 while (!IsNull (&Question
->OptionListHead
, Link
)) {
1330 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1332 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
1337 // Get the number of one of options present and its size
1340 HighlightOptionIndex
= 0;
1341 Link
= GetFirstNode (&Question
->OptionListHead
);
1342 for (Index
= 0; Index
< PopUpMenuLines
; Index
++) {
1343 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1345 StringPtr
= GetToken (OneOfOption
->OptionOpCode
->Option
, gFormData
->HiiHandle
);
1346 if (StrLen (StringPtr
) > PopUpWidth
) {
1347 PopUpWidth
= StrLen (StringPtr
);
1349 FreePool (StringPtr
);
1350 HiiValue
.Type
= OneOfOption
->OptionOpCode
->Type
;
1351 SetValuesByType (&HiiValue
.Value
, &OneOfOption
->OptionOpCode
->Value
, HiiValue
.Type
);
1352 if (!OrderedList
&& (CompareHiiValue (&Question
->CurrentValue
, &HiiValue
, &Result
, NULL
) == EFI_SUCCESS
) && (Result
== 0)) {
1354 // Find current selected Option for OneOf
1356 HighlightOptionIndex
= Index
;
1359 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
1363 // Perform popup menu initialization.
1365 PopUpWidth
= PopUpWidth
+ POPUP_PAD_SPACE_COUNT
;
1367 SavedAttribute
= gST
->ConOut
->Mode
->Attribute
;
1368 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetPopupColor ());
1370 if ((PopUpWidth
+ POPUP_FRAME_WIDTH
) > DimensionsWidth
) {
1371 PopUpWidth
= DimensionsWidth
- POPUP_FRAME_WIDTH
;
1374 Start
= (DimensionsWidth
- PopUpWidth
- POPUP_FRAME_WIDTH
) / 2 + gStatementDimensions
.LeftColumn
;
1375 End
= Start
+ PopUpWidth
+ POPUP_FRAME_WIDTH
;
1376 Top
= gStatementDimensions
.TopRow
;
1377 Bottom
= gStatementDimensions
.BottomRow
- 1;
1379 MenuLinesInView
= Bottom
- Top
- 1;
1380 if (MenuLinesInView
>= PopUpMenuLines
) {
1381 Top
= Top
+ (MenuLinesInView
- PopUpMenuLines
) / 2;
1382 Bottom
= Top
+ PopUpMenuLines
+ 1;
1384 ShowDownArrow
= TRUE
;
1387 if (HighlightOptionIndex
> (MenuLinesInView
- 1)) {
1388 TopOptionIndex
= HighlightOptionIndex
- MenuLinesInView
+ 1;
1395 // Clear that portion of the screen
1397 ClearLines (Start
, End
, Top
, Bottom
, GetPopupColor ());
1400 // Draw "One of" pop-up menu
1402 Character
= BOXDRAW_DOWN_RIGHT
;
1403 PrintCharAt (Start
, Top
, Character
);
1404 for (Index
= Start
; Index
+ 2 < End
; Index
++) {
1405 if ((ShowUpArrow
) && ((Index
+ 1) == (Start
+ End
) / 2)) {
1406 Character
= GEOMETRICSHAPE_UP_TRIANGLE
;
1408 Character
= BOXDRAW_HORIZONTAL
;
1411 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
1414 Character
= BOXDRAW_DOWN_LEFT
;
1415 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
1416 Character
= BOXDRAW_VERTICAL
;
1417 for (Index
= Top
+ 1; Index
< Bottom
; Index
++) {
1418 PrintCharAt (Start
, Index
, Character
);
1419 PrintCharAt (End
- 1, Index
, Character
);
1423 // Move to top Option
1425 Link
= GetFirstNode (&Question
->OptionListHead
);
1426 for (Index
= 0; Index
< TopOptionIndex
; Index
++) {
1427 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
1431 // Display the One of options
1434 for (Index
= TopOptionIndex
; (Index
< PopUpMenuLines
) && (Index2
< Bottom
); Index
++) {
1435 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1436 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
1438 StringPtr
= GetToken (OneOfOption
->OptionOpCode
->Option
, gFormData
->HiiHandle
);
1439 ASSERT (StringPtr
!= NULL
);
1441 // If the string occupies multiple lines, truncate it to fit in one line,
1442 // and append a "..." for indication.
1444 if (StrLen (StringPtr
) > (PopUpWidth
- 1)) {
1445 TempStringPtr
= AllocateZeroPool (sizeof (CHAR16
) * (PopUpWidth
- 1));
1446 ASSERT ( TempStringPtr
!= NULL
);
1447 CopyMem (TempStringPtr
, StringPtr
, (sizeof (CHAR16
) * (PopUpWidth
- 5)));
1448 FreePool (StringPtr
);
1449 StringPtr
= TempStringPtr
;
1450 StrCat (StringPtr
, L
"...");
1453 if (Index
== HighlightOptionIndex
) {
1455 // Highlight the selected one
1457 CurrentOption
= OneOfOption
;
1459 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetPickListColor ());
1460 PrintStringAt (Start
+ 2, Index2
, StringPtr
);
1461 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetPopupColor ());
1463 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetPopupColor ());
1464 PrintStringAt (Start
+ 2, Index2
, StringPtr
);
1468 FreePool (StringPtr
);
1471 Character
= BOXDRAW_UP_RIGHT
;
1472 PrintCharAt (Start
, Bottom
, Character
);
1473 for (Index
= Start
; Index
+ 2 < End
; Index
++) {
1474 if ((ShowDownArrow
) && ((Index
+ 1) == (Start
+ End
) / 2)) {
1475 Character
= GEOMETRICSHAPE_DOWN_TRIANGLE
;
1477 Character
= BOXDRAW_HORIZONTAL
;
1480 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
1483 Character
= BOXDRAW_UP_LEFT
;
1484 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
1487 // Get User selection
1489 Key
.UnicodeChar
= CHAR_NULL
;
1490 if ((gDirection
== SCAN_UP
) || (gDirection
== SCAN_DOWN
)) {
1491 Key
.ScanCode
= gDirection
;
1496 WaitForKeyStroke (&Key
);
1499 switch (Key
.UnicodeChar
) {
1502 if ((TopOptionIndex
> 0) && (TopOptionIndex
== HighlightOptionIndex
)) {
1504 // Highlight reaches the top of the popup window, scroll one menu item.
1507 ShowDownArrow
= TRUE
;
1510 if (TopOptionIndex
== 0) {
1511 ShowUpArrow
= FALSE
;
1514 if (HighlightOptionIndex
> 0) {
1515 HighlightOptionIndex
--;
1517 ASSERT (CurrentOption
!= NULL
);
1518 SwapListEntries (CurrentOption
->Link
.BackLink
, &CurrentOption
->Link
);
1525 // If an ordered list op-code, we will allow for a popup of +/- keys
1526 // to create an ordered list of items
1529 if (((TopOptionIndex
+ MenuLinesInView
) < PopUpMenuLines
) &&
1530 (HighlightOptionIndex
== (TopOptionIndex
+ MenuLinesInView
- 1))) {
1532 // Highlight reaches the bottom of the popup window, scroll one menu item.
1538 if ((TopOptionIndex
+ MenuLinesInView
) == PopUpMenuLines
) {
1539 ShowDownArrow
= FALSE
;
1542 if (HighlightOptionIndex
< (PopUpMenuLines
- 1)) {
1543 HighlightOptionIndex
++;
1545 ASSERT (CurrentOption
!= NULL
);
1546 SwapListEntries (&CurrentOption
->Link
, CurrentOption
->Link
.ForwardLink
);
1552 switch (Key
.ScanCode
) {
1555 if (Key
.ScanCode
== SCAN_UP
) {
1556 if ((TopOptionIndex
> 0) && (TopOptionIndex
== HighlightOptionIndex
)) {
1558 // Highlight reaches the top of the popup window, scroll one menu item.
1561 ShowDownArrow
= TRUE
;
1564 if (TopOptionIndex
== 0) {
1565 ShowUpArrow
= FALSE
;
1568 if (HighlightOptionIndex
> 0) {
1569 HighlightOptionIndex
--;
1572 if (((TopOptionIndex
+ MenuLinesInView
) < PopUpMenuLines
) &&
1573 (HighlightOptionIndex
== (TopOptionIndex
+ MenuLinesInView
- 1))) {
1575 // Highlight reaches the bottom of the popup window, scroll one menu item.
1581 if ((TopOptionIndex
+ MenuLinesInView
) == PopUpMenuLines
) {
1582 ShowDownArrow
= FALSE
;
1585 if (HighlightOptionIndex
< (PopUpMenuLines
- 1)) {
1586 HighlightOptionIndex
++;
1592 gST
->ConOut
->SetAttribute (gST
->ConOut
, SavedAttribute
);
1595 // Restore link list order for orderedlist
1598 HiiValue
.Type
= ValueType
;
1599 HiiValue
.Value
.u64
= 0;
1600 for (Index
= 0; Index
< OrderList
->MaxContainers
; Index
++) {
1601 HiiValue
.Value
.u64
= GetArrayData (ValueArray
, ValueType
, Index
);
1602 if (HiiValue
.Value
.u64
== 0) {
1606 OneOfOption
= ValueToOption (Question
, &HiiValue
);
1607 if (OneOfOption
== NULL
) {
1608 return EFI_NOT_FOUND
;
1611 RemoveEntryList (&OneOfOption
->Link
);
1612 InsertTailList (&Question
->OptionListHead
, &OneOfOption
->Link
);
1616 return EFI_DEVICE_ERROR
;
1624 case CHAR_CARRIAGE_RETURN
:
1626 // return the current selection
1629 ReturnValue
= AllocateZeroPool (Question
->CurrentValue
.BufferLen
);
1630 ASSERT (ReturnValue
!= NULL
);
1632 Link
= GetFirstNode (&Question
->OptionListHead
);
1633 while (!IsNull (&Question
->OptionListHead
, Link
)) {
1634 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1635 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
1637 SetArrayData (ReturnValue
, ValueType
, Index
, OneOfOption
->OptionOpCode
->Value
.u64
);
1640 if (Index
> OrderList
->MaxContainers
) {
1644 if (CompareMem (ReturnValue
, ValueArray
, Question
->CurrentValue
.BufferLen
) == 0) {
1645 FreePool (ReturnValue
);
1646 return EFI_DEVICE_ERROR
;
1648 gUserInput
->InputValue
.Buffer
= ReturnValue
;
1649 gUserInput
->InputValue
.BufferLen
= Question
->CurrentValue
.BufferLen
;
1652 ASSERT (CurrentOption
!= NULL
);
1653 gUserInput
->InputValue
.Type
= CurrentOption
->OptionOpCode
->Type
;
1654 if (IsValuesEqual (&Question
->CurrentValue
.Value
, &CurrentOption
->OptionOpCode
->Value
, gUserInput
->InputValue
.Type
)) {
1655 return EFI_DEVICE_ERROR
;
1657 SetValuesByType (&gUserInput
->InputValue
.Value
, &CurrentOption
->OptionOpCode
->Value
, gUserInput
->InputValue
.Type
);
1661 gST
->ConOut
->SetAttribute (gST
->ConOut
, SavedAttribute
);