2 Implementation for handling user input from the User Interfaces.
4 Copyright (c) 2004 - 2015, 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
;
89 DimensionsWidth
= gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
;
90 DimensionsHeight
= gStatementDimensions
.BottomRow
- gStatementDimensions
.TopRow
;
92 NullCharacter
= CHAR_NULL
;
93 ScreenSize
= GetStringWidth (Prompt
) / sizeof (CHAR16
);
97 Question
= MenuOption
->ThisTag
;
98 GetFieldFromOp(Question
->OpCode
, &Minimum
, &Maximum
);
100 if (Question
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) {
106 MaxLen
= Maximum
+ 1;
107 TempString
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
110 if (ScreenSize
< (Maximum
+ 1)) {
111 ScreenSize
= Maximum
+ 1;
114 if ((ScreenSize
+ 2) > DimensionsWidth
) {
115 ScreenSize
= DimensionsWidth
- 2;
118 BufferedString
= AllocateZeroPool (ScreenSize
* 2);
119 ASSERT (BufferedString
);
121 Start
= (DimensionsWidth
- ScreenSize
- 2) / 2 + gStatementDimensions
.LeftColumn
+ 1;
122 Top
= ((DimensionsHeight
- 6) / 2) + gStatementDimensions
.TopRow
- 1;
125 // Display prompt for string
127 // CreateDialog (NULL, "", Prompt, Space, "", NULL);
128 CreateMultiStringPopUp (ScreenSize
, 4, &NullCharacter
, Prompt
, Space
, &NullCharacter
);
129 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_BLACK
, EFI_LIGHTGRAY
));
131 CursorVisible
= gST
->ConOut
->Mode
->CursorVisible
;
132 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
134 CurrentCursor
= GetStringWidth (StringPtr
) / 2 - 1;
135 if (CurrentCursor
!= 0) {
137 // Show the string which has beed saved before.
139 SetUnicodeMem (BufferedString
, ScreenSize
- 1, L
' ');
140 PrintStringAt (Start
+ 1, Top
+ 3, BufferedString
);
142 if ((GetStringWidth (StringPtr
) / 2) > (DimensionsWidth
- 2)) {
143 Index
= (GetStringWidth (StringPtr
) / 2) - DimensionsWidth
+ 2;
149 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, Start
+ 1, Top
+ 3);
152 for (Count
= 0; Index
+ 1 < GetStringWidth (StringPtr
) / 2; Index
++, Count
++) {
153 BufferedString
[Count
] = StringPtr
[Index
];
156 PrintCharAt ((UINTN
)-1, (UINTN
)-1, L
'*');
161 PrintStringAt (Start
+ 1, Top
+ 3, BufferedString
);
164 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
165 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, Start
+ GetStringWidth (StringPtr
) / 2, Top
+ 3);
169 Status
= WaitForKeyStroke (&Key
);
170 ASSERT_EFI_ERROR (Status
);
172 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_BLACK
, EFI_LIGHTGRAY
));
173 switch (Key
.UnicodeChar
) {
175 switch (Key
.ScanCode
) {
177 if (CurrentCursor
> 0) {
183 if (CurrentCursor
< (GetStringWidth (StringPtr
) / 2 - 1)) {
189 FreePool (TempString
);
190 FreePool (BufferedString
);
191 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
192 gST
->ConOut
->EnableCursor (gST
->ConOut
, CursorVisible
);
193 return EFI_DEVICE_ERROR
;
196 for (Index
= CurrentCursor
; StringPtr
[Index
] != CHAR_NULL
; Index
++) {
197 StringPtr
[Index
] = StringPtr
[Index
+ 1];
198 PrintCharAt (Start
+ Index
+ 1, Top
+ 3, IsPassword
&& StringPtr
[Index
] != CHAR_NULL
? L
'*' : StringPtr
[Index
]);
208 case CHAR_CARRIAGE_RETURN
:
209 if (GetStringWidth (StringPtr
) >= ((Minimum
+ 1) * sizeof (CHAR16
))) {
211 FreePool (TempString
);
212 FreePool (BufferedString
);
213 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
214 gST
->ConOut
->EnableCursor (gST
->ConOut
, CursorVisible
);
218 // Simply create a popup to tell the user that they had typed in too few characters.
219 // To save code space, we can then treat this as an error and return back to the menu.
222 CreateDialog (&Key
, &NullCharacter
, gMiniString
, gPressEnter
, &NullCharacter
, NULL
);
223 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
225 FreePool (TempString
);
226 FreePool (BufferedString
);
227 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
228 gST
->ConOut
->EnableCursor (gST
->ConOut
, CursorVisible
);
229 return EFI_DEVICE_ERROR
;
234 if (StringPtr
[0] != CHAR_NULL
&& CurrentCursor
!= 0) {
235 for (Index
= 0; Index
< CurrentCursor
- 1; Index
++) {
236 TempString
[Index
] = StringPtr
[Index
];
238 Count
= GetStringWidth (StringPtr
) / 2 - 1;
239 if (Count
>= CurrentCursor
) {
240 for (Index
= CurrentCursor
- 1, Index2
= CurrentCursor
; Index2
< Count
; Index
++, Index2
++) {
241 TempString
[Index
] = StringPtr
[Index2
];
243 TempString
[Index
] = CHAR_NULL
;
246 // Effectively truncate string by 1 character
248 StrCpyS (StringPtr
, MaxLen
, TempString
);
254 // If it is the beginning of the string, don't worry about checking maximum limits
256 if ((StringPtr
[0] == CHAR_NULL
) && (Key
.UnicodeChar
!= CHAR_BACKSPACE
)) {
257 StrnCpyS (StringPtr
, MaxLen
, &Key
.UnicodeChar
, 1);
259 } else if ((GetStringWidth (StringPtr
) < ((Maximum
+ 1) * sizeof (CHAR16
))) && (Key
.UnicodeChar
!= CHAR_BACKSPACE
)) {
260 KeyPad
[0] = Key
.UnicodeChar
;
261 KeyPad
[1] = CHAR_NULL
;
262 Count
= GetStringWidth (StringPtr
) / 2 - 1;
263 if (CurrentCursor
< Count
) {
264 for (Index
= 0; Index
< CurrentCursor
; Index
++) {
265 TempString
[Index
] = StringPtr
[Index
];
267 TempString
[Index
] = CHAR_NULL
;
268 StrCatS (TempString
, MaxLen
, KeyPad
);
269 StrCatS (TempString
, MaxLen
, StringPtr
+ CurrentCursor
);
270 StrCpyS (StringPtr
, MaxLen
, TempString
);
272 StrCatS (StringPtr
, MaxLen
, KeyPad
);
278 // If the width of the input string is now larger than the screen, we nee to
279 // adjust the index to start printing portions of the string
281 SetUnicodeMem (BufferedString
, ScreenSize
- 1, L
' ');
282 PrintStringAt (Start
+ 1, Top
+ 3, BufferedString
);
284 if ((GetStringWidth (StringPtr
) / 2) > (DimensionsWidth
- 2)) {
285 Index
= (GetStringWidth (StringPtr
) / 2) - DimensionsWidth
+ 2;
291 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, Start
+ 1, Top
+ 3);
294 for (Count
= 0; Index
+ 1 < GetStringWidth (StringPtr
) / 2; Index
++, Count
++) {
295 BufferedString
[Count
] = StringPtr
[Index
];
298 PrintCharAt ((UINTN
)-1, (UINTN
)-1, L
'*');
303 PrintStringAt (Start
+ 1, Top
+ 3, BufferedString
);
308 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
309 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, Start
+ CurrentCursor
+ 1, Top
+ 3);
315 Adjust the value to the correct one. Rules follow the sample:
316 like: Year change: 2012.02.29 -> 2013.02.29 -> 2013.02.01
317 Month change: 2013.03.29 -> 2013.02.29 -> 2013.02.28
319 @param QuestionValue Pointer to current question.
320 @param Sequence The sequence of the field in the question.
323 AdjustQuestionValue (
324 IN EFI_HII_VALUE
*QuestionValue
,
333 Month
= QuestionValue
->Value
.date
.Month
;
334 Year
= QuestionValue
->Value
.date
.Year
;
339 if ((Year
% 4) == 0 && ((Year
% 100) != 0 || (Year
% 400) == 0)) {
357 // Change the month area.
360 if (QuestionValue
->Value
.date
.Day
> Maximum
) {
361 QuestionValue
->Value
.date
.Day
= Maximum
;
366 // Change the Year area.
369 if (QuestionValue
->Value
.date
.Day
> Maximum
) {
370 QuestionValue
->Value
.date
.Day
= Minimum
;
376 Get field info from numeric opcode.
378 @param OpCode Pointer to the current input opcode.
379 @param IntInput Whether question shows with EFI_IFR_DISPLAY_INT_DEC type.
380 @param QuestionValue Input question value, with EFI_HII_VALUE type.
381 @param Value Return question value, always return UINT64 type.
382 @param Minimum The minimum size info for this opcode.
383 @param Maximum The maximum size info for this opcode.
384 @param Step The step size info for this opcode.
385 @param StorageWidth The storage width info for this opcode.
390 IN EFI_IFR_OP_HEADER
*OpCode
,
392 IN EFI_HII_VALUE
*QuestionValue
,
397 OUT UINT16
*StorageWidth
400 EFI_IFR_NUMERIC
*NumericOp
;
402 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
404 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
405 case EFI_IFR_NUMERIC_SIZE_1
:
407 *Minimum
= (INT64
) (INT8
) NumericOp
->data
.u8
.MinValue
;
408 *Maximum
= (INT64
) (INT8
) NumericOp
->data
.u8
.MaxValue
;
409 *Value
= (INT64
) (INT8
) QuestionValue
->Value
.u8
;
411 *Minimum
= NumericOp
->data
.u8
.MinValue
;
412 *Maximum
= NumericOp
->data
.u8
.MaxValue
;
413 *Value
= QuestionValue
->Value
.u8
;
415 *Step
= NumericOp
->data
.u8
.Step
;
416 *StorageWidth
= (UINT16
) sizeof (UINT8
);
419 case EFI_IFR_NUMERIC_SIZE_2
:
421 *Minimum
= (INT64
) (INT16
) NumericOp
->data
.u16
.MinValue
;
422 *Maximum
= (INT64
) (INT16
) NumericOp
->data
.u16
.MaxValue
;
423 *Value
= (INT64
) (INT16
) QuestionValue
->Value
.u16
;
425 *Minimum
= NumericOp
->data
.u16
.MinValue
;
426 *Maximum
= NumericOp
->data
.u16
.MaxValue
;
427 *Value
= QuestionValue
->Value
.u16
;
429 *Step
= NumericOp
->data
.u16
.Step
;
430 *StorageWidth
= (UINT16
) sizeof (UINT16
);
433 case EFI_IFR_NUMERIC_SIZE_4
:
435 *Minimum
= (INT64
) (INT32
) NumericOp
->data
.u32
.MinValue
;
436 *Maximum
= (INT64
) (INT32
) NumericOp
->data
.u32
.MaxValue
;
437 *Value
= (INT64
) (INT32
) QuestionValue
->Value
.u32
;
439 *Minimum
= NumericOp
->data
.u32
.MinValue
;
440 *Maximum
= NumericOp
->data
.u32
.MaxValue
;
441 *Value
= QuestionValue
->Value
.u32
;
443 *Step
= NumericOp
->data
.u32
.Step
;
444 *StorageWidth
= (UINT16
) sizeof (UINT32
);
447 case EFI_IFR_NUMERIC_SIZE_8
:
449 *Minimum
= (INT64
) NumericOp
->data
.u64
.MinValue
;
450 *Maximum
= (INT64
) NumericOp
->data
.u64
.MaxValue
;
451 *Value
= (INT64
) QuestionValue
->Value
.u64
;
453 *Minimum
= NumericOp
->data
.u64
.MinValue
;
454 *Maximum
= NumericOp
->data
.u64
.MaxValue
;
455 *Value
= QuestionValue
->Value
.u64
;
457 *Step
= NumericOp
->data
.u64
.Step
;
458 *StorageWidth
= (UINT16
) sizeof (UINT64
);
466 *Maximum
= (UINT64
) -1;
471 This routine reads a numeric value from the user input.
473 @param MenuOption Pointer to the current input menu.
475 @retval EFI_SUCCESS If numerical input is read successfully
476 @retval EFI_DEVICE_ERROR If operation fails
481 IN UI_MENU_OPTION
*MenuOption
486 CHAR16 InputText
[MAX_NUMERIC_INPUT_WIDTH
];
487 CHAR16 FormattedNumber
[MAX_NUMERIC_INPUT_WIDTH
- 1];
488 UINT64 PreviousNumber
[MAX_NUMERIC_INPUT_WIDTH
- 3];
495 BOOLEAN ValidateFail
;
505 EFI_HII_VALUE
*QuestionValue
;
506 FORM_DISPLAY_ENGINE_STATEMENT
*Question
;
507 EFI_IFR_NUMERIC
*NumericOp
;
510 Column
= MenuOption
->OptCol
;
511 Row
= MenuOption
->Row
;
512 PreviousNumber
[0] = 0;
523 ValidateFail
= FALSE
;
525 Question
= MenuOption
->ThisTag
;
526 QuestionValue
= &Question
->CurrentValue
;
529 // Only two case, user can enter to this function: Enter and +/- case.
530 // In Enter case, gDirection = 0; in +/- case, gDirection = SCAN_LEFT/SCAN_WRIGHT
532 ManualInput
= (BOOLEAN
)(gDirection
== 0 ? TRUE
: FALSE
);
534 if ((Question
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (Question
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
541 // Prepare Value to be edit
545 if (Question
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
549 switch (MenuOption
->Sequence
) {
553 EditValue
= QuestionValue
->Value
.date
.Month
;
557 switch (QuestionValue
->Value
.date
.Month
) {
559 if ((QuestionValue
->Value
.date
.Year
% 4) == 0 &&
560 ((QuestionValue
->Value
.date
.Year
% 100) != 0 ||
561 (QuestionValue
->Value
.date
.Year
% 400) == 0)) {
579 EditValue
= QuestionValue
->Value
.date
.Day
;
585 EditValue
= QuestionValue
->Value
.date
.Year
;
591 } else if (Question
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
595 switch (MenuOption
->Sequence
) {
599 EditValue
= QuestionValue
->Value
.time
.Hour
;
605 EditValue
= QuestionValue
->Value
.time
.Minute
;
611 EditValue
= QuestionValue
->Value
.time
.Second
;
618 ASSERT (Question
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
);
619 NumericOp
= (EFI_IFR_NUMERIC
*) Question
->OpCode
;
620 GetValueFromNum(Question
->OpCode
, (NumericOp
->Flags
& EFI_IFR_DISPLAY
) == 0, QuestionValue
, &EditValue
, &Minimum
, &Maximum
, &Step
, &StorageWidth
);
621 EraseLen
= gOptionBlockWidth
;
624 if ((Question
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) && (NumericOp
!= NULL
)) {
625 if ((NumericOp
->Flags
& EFI_IFR_DISPLAY
) == EFI_IFR_DISPLAY_UINT_HEX
){
627 } else if ((NumericOp
->Flags
& EFI_IFR_DISPLAY
) == 0){
629 // Display with EFI_IFR_DISPLAY_INT_DEC type. Support negative number.
636 // Enter from "Enter" input, clear the old word showing.
639 if (Question
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) {
641 InputWidth
= StorageWidth
* 2;
643 switch (StorageWidth
) {
667 // Support an extra '-' for negative number.
673 InputText
[0] = LEFT_NUMERIC_DELIMITER
;
674 SetUnicodeMem (InputText
+ 1, InputWidth
, L
' ');
675 ASSERT (InputWidth
+ 2 < MAX_NUMERIC_INPUT_WIDTH
);
676 InputText
[InputWidth
+ 1] = RIGHT_NUMERIC_DELIMITER
;
677 InputText
[InputWidth
+ 2] = L
'\0';
679 PrintStringAt (Column
, Row
, InputText
);
683 if (Question
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
684 if (MenuOption
->Sequence
== 2) {
690 if (MenuOption
->Sequence
== 0) {
691 InputText
[0] = LEFT_NUMERIC_DELIMITER
;
692 SetUnicodeMem (InputText
+ 1, InputWidth
, L
' ');
694 SetUnicodeMem (InputText
, InputWidth
, L
' ');
697 if (MenuOption
->Sequence
== 2) {
698 InputText
[InputWidth
+ 1] = RIGHT_NUMERIC_DELIMITER
;
700 InputText
[InputWidth
+ 1] = DATE_SEPARATOR
;
702 InputText
[InputWidth
+ 2] = L
'\0';
704 PrintStringAt (Column
, Row
, InputText
);
705 if (MenuOption
->Sequence
== 0) {
710 if (Question
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
713 if (MenuOption
->Sequence
== 0) {
714 InputText
[0] = LEFT_NUMERIC_DELIMITER
;
715 SetUnicodeMem (InputText
+ 1, InputWidth
, L
' ');
717 SetUnicodeMem (InputText
, InputWidth
, L
' ');
720 if (MenuOption
->Sequence
== 2) {
721 InputText
[InputWidth
+ 1] = RIGHT_NUMERIC_DELIMITER
;
723 InputText
[InputWidth
+ 1] = TIME_SEPARATOR
;
725 InputText
[InputWidth
+ 2] = L
'\0';
727 PrintStringAt (Column
, Row
, InputText
);
728 if (MenuOption
->Sequence
== 0) {
735 // First time we enter this handler, we need to check to see if
736 // we were passed an increment or decrement directive
739 Key
.UnicodeChar
= CHAR_NULL
;
740 if (gDirection
!= 0) {
741 Key
.ScanCode
= gDirection
;
746 WaitForKeyStroke (&Key
);
749 switch (Key
.UnicodeChar
) {
753 if (ManualInput
&& IntInput
) {
755 // In Manual input mode, check whether input the negative flag.
757 if (Key
.UnicodeChar
== '-') {
762 PrintCharAt (Column
++, Row
, Key
.UnicodeChar
);
765 if (Key
.UnicodeChar
== '+') {
766 Key
.ScanCode
= SCAN_RIGHT
;
768 Key
.ScanCode
= SCAN_LEFT
;
770 Key
.UnicodeChar
= CHAR_NULL
;
776 switch (Key
.ScanCode
) {
779 if (DateOrTime
&& !ManualInput
) {
781 // By setting this value, we will return back to the caller.
782 // We need to do this since an auto-refresh will destroy the adjustment
783 // based on what the real-time-clock is showing. So we always commit
784 // upon changing the value.
786 gDirection
= SCAN_DOWN
;
789 if ((Step
!= 0) && !ManualInput
) {
790 if (Key
.ScanCode
== SCAN_LEFT
) {
792 if ((INT64
) EditValue
>= (INT64
) Minimum
+ (INT64
) Step
) {
793 EditValue
= EditValue
- Step
;
794 } else if ((INT64
) EditValue
> (INT64
) Minimum
){
800 if (EditValue
>= Minimum
+ Step
) {
801 EditValue
= EditValue
- Step
;
802 } else if (EditValue
> Minimum
){
808 } else if (Key
.ScanCode
== SCAN_RIGHT
) {
810 if ((INT64
) EditValue
+ (INT64
) Step
<= (INT64
) Maximum
) {
811 EditValue
= EditValue
+ Step
;
812 } else if ((INT64
) EditValue
< (INT64
) Maximum
) {
818 if (EditValue
+ Step
<= Maximum
) {
819 EditValue
= EditValue
+ Step
;
820 } else if (EditValue
< Maximum
) {
828 ZeroMem (FormattedNumber
, 21 * sizeof (CHAR16
));
829 if (Question
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
830 if (MenuOption
->Sequence
== 2) {
834 UnicodeSPrint (FormattedNumber
, 21 * sizeof (CHAR16
), L
"%04d", (UINT16
) EditValue
);
839 UnicodeSPrint (FormattedNumber
, 21 * sizeof (CHAR16
), L
"%02d", (UINT8
) EditValue
);
842 if (MenuOption
->Sequence
== 0) {
843 ASSERT (EraseLen
>= 2);
844 FormattedNumber
[EraseLen
- 2] = DATE_SEPARATOR
;
845 } else if (MenuOption
->Sequence
== 1) {
846 ASSERT (EraseLen
>= 1);
847 FormattedNumber
[EraseLen
- 1] = DATE_SEPARATOR
;
849 } else if (Question
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
850 UnicodeSPrint (FormattedNumber
, 21 * sizeof (CHAR16
), L
"%02d", (UINT8
) EditValue
);
852 if (MenuOption
->Sequence
== 0) {
853 ASSERT (EraseLen
>= 2);
854 FormattedNumber
[EraseLen
- 2] = TIME_SEPARATOR
;
855 } else if (MenuOption
->Sequence
== 1) {
856 ASSERT (EraseLen
>= 1);
857 FormattedNumber
[EraseLen
- 1] = TIME_SEPARATOR
;
860 QuestionValue
->Value
.u64
= EditValue
;
861 PrintFormattedNumber (Question
, FormattedNumber
, 21 * sizeof (CHAR16
));
864 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
865 for (Loop
= 0; Loop
< EraseLen
; Loop
++) {
866 PrintStringAt (MenuOption
->OptCol
+ Loop
, MenuOption
->Row
, L
" ");
868 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
870 if (MenuOption
->Sequence
== 0) {
871 PrintCharAt (MenuOption
->OptCol
, Row
, LEFT_NUMERIC_DELIMITER
);
872 Column
= MenuOption
->OptCol
+ 1;
875 PrintStringAt (Column
, Row
, FormattedNumber
);
877 if (!DateOrTime
|| MenuOption
->Sequence
== 2) {
878 PrintCharAt ((UINTN
)-1, (UINTN
)-1, RIGHT_NUMERIC_DELIMITER
);
882 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
);
990 PrintStringAt (Column
, Row
, L
" ");
995 // Remove a character
997 EditValue
= PreviousNumber
[Count
- 1];
998 UpdateStatusBar (INPUT_ERROR
, FALSE
);
1001 PrintStringAt (Column
, Row
, L
" ");
1008 if ((Key
.UnicodeChar
>= L
'0') && (Key
.UnicodeChar
<= L
'9')) {
1009 Digital
= (UINT8
) (Key
.UnicodeChar
- L
'0');
1010 } else if ((Key
.UnicodeChar
>= L
'A') && (Key
.UnicodeChar
<= L
'F')) {
1011 Digital
= (UINT8
) (Key
.UnicodeChar
- L
'A' + 0x0A);
1012 } else if ((Key
.UnicodeChar
>= L
'a') && (Key
.UnicodeChar
<= L
'f')) {
1013 Digital
= (UINT8
) (Key
.UnicodeChar
- L
'a' + 0x0A);
1015 UpdateStatusBar (INPUT_ERROR
, TRUE
);
1019 if (Key
.UnicodeChar
> L
'9' || Key
.UnicodeChar
< L
'0') {
1020 UpdateStatusBar (INPUT_ERROR
, TRUE
);
1026 // If Count exceed input width, there is no way more is valid
1028 if (Count
>= InputWidth
) {
1032 // Someone typed something valid!
1036 EditValue
= LShiftU64 (EditValue
, 4) + Digital
;
1037 } else if (IntInput
&& Negative
) {
1039 // Save the negative number.
1041 EditValue
= ~(MultU64x32 (~(EditValue
- 1), 10) + (Key
.UnicodeChar
- L
'0')) + 1;
1043 EditValue
= MultU64x32 (EditValue
, 10) + (Key
.UnicodeChar
- L
'0');
1047 EditValue
= Digital
;
1048 } else if (IntInput
&& Negative
) {
1050 // Save the negative number.
1052 EditValue
= ~(Key
.UnicodeChar
- L
'0') + 1;
1054 EditValue
= Key
.UnicodeChar
- L
'0';
1059 ValidateFail
= FALSE
;
1061 // When user input a new value, should check the current value.
1062 // If user input a negative value, should compare it with minimum
1063 // value, else compare it with maximum value.
1066 ValidateFail
= (INT64
) EditValue
< (INT64
) Minimum
? TRUE
: FALSE
;
1068 ValidateFail
= (INT64
) EditValue
> (INT64
) Maximum
? TRUE
: FALSE
;
1072 UpdateStatusBar (INPUT_ERROR
, TRUE
);
1073 ASSERT (Count
< sizeof (PreviousNumber
) / sizeof (PreviousNumber
[0]));
1074 EditValue
= PreviousNumber
[Count
];
1078 if (EditValue
> Maximum
) {
1079 UpdateStatusBar (INPUT_ERROR
, TRUE
);
1080 ASSERT (Count
< sizeof (PreviousNumber
) / sizeof (PreviousNumber
[0]));
1081 EditValue
= PreviousNumber
[Count
];
1086 UpdateStatusBar (INPUT_ERROR
, FALSE
);
1089 ASSERT (Count
< (sizeof (PreviousNumber
) / sizeof (PreviousNumber
[0])));
1090 PreviousNumber
[Count
] = EditValue
;
1092 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
1093 PrintCharAt (Column
, Row
, Key
.UnicodeChar
);
1102 Adjust option order base on the question value.
1104 @param Question Pointer to current question.
1105 @param PopUpMenuLines The line number of the pop up menu.
1107 @retval EFI_SUCCESS If Option input is processed successfully
1108 @retval EFI_DEVICE_ERROR If operation fails
1113 IN FORM_DISPLAY_ENGINE_STATEMENT
*Question
,
1114 OUT UINTN
*PopUpMenuLines
1118 EFI_IFR_ORDERED_LIST
*OrderList
;
1122 DISPLAY_QUESTION_OPTION
*OneOfOption
;
1123 EFI_HII_VALUE
*HiiValueArray
;
1125 Link
= GetFirstNode (&Question
->OptionListHead
);
1126 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1127 ValueArray
= Question
->CurrentValue
.Buffer
;
1128 ValueType
= OneOfOption
->OptionOpCode
->Type
;
1129 OrderList
= (EFI_IFR_ORDERED_LIST
*) Question
->OpCode
;
1131 for (Index
= 0; Index
< OrderList
->MaxContainers
; Index
++) {
1132 if (GetArrayData (ValueArray
, ValueType
, Index
) == 0) {
1137 *PopUpMenuLines
= Index
;
1140 // Prepare HiiValue array
1142 HiiValueArray
= AllocateZeroPool (*PopUpMenuLines
* sizeof (EFI_HII_VALUE
));
1143 ASSERT (HiiValueArray
!= NULL
);
1145 for (Index
= 0; Index
< *PopUpMenuLines
; Index
++) {
1146 HiiValueArray
[Index
].Type
= ValueType
;
1147 HiiValueArray
[Index
].Value
.u64
= GetArrayData (ValueArray
, ValueType
, Index
);
1150 for (Index
= 0; Index
< *PopUpMenuLines
; Index
++) {
1151 OneOfOption
= ValueToOption (Question
, &HiiValueArray
[*PopUpMenuLines
- Index
- 1]);
1152 if (OneOfOption
== NULL
) {
1153 return EFI_NOT_FOUND
;
1156 RemoveEntryList (&OneOfOption
->Link
);
1161 InsertHeadList (&Question
->OptionListHead
, &OneOfOption
->Link
);
1164 FreePool (HiiValueArray
);
1170 Base on the type to compare the value.
1172 @param Value1 The first value need to compare.
1173 @param Value2 The second value need to compare.
1174 @param Type The value type for above two values.
1176 @retval TRUE The two value are same.
1177 @retval FALSE The two value are different.
1182 IN EFI_IFR_TYPE_VALUE
*Value1
,
1183 IN EFI_IFR_TYPE_VALUE
*Value2
,
1188 case EFI_IFR_TYPE_BOOLEAN
:
1189 case EFI_IFR_TYPE_NUM_SIZE_8
:
1190 return (BOOLEAN
) (Value1
->u8
== Value2
->u8
);
1192 case EFI_IFR_TYPE_NUM_SIZE_16
:
1193 return (BOOLEAN
) (Value1
->u16
== Value2
->u16
);
1195 case EFI_IFR_TYPE_NUM_SIZE_32
:
1196 return (BOOLEAN
) (Value1
->u32
== Value2
->u32
);
1198 case EFI_IFR_TYPE_NUM_SIZE_64
:
1199 return (BOOLEAN
) (Value1
->u64
== Value2
->u64
);
1208 Base on the type to set the value.
1210 @param Dest The dest value.
1211 @param Source The source value.
1212 @param Type The value type for above two values.
1217 OUT EFI_IFR_TYPE_VALUE
*Dest
,
1218 IN EFI_IFR_TYPE_VALUE
*Source
,
1223 case EFI_IFR_TYPE_BOOLEAN
:
1224 Dest
->b
= Source
->b
;
1227 case EFI_IFR_TYPE_NUM_SIZE_8
:
1228 Dest
->u8
= Source
->u8
;
1231 case EFI_IFR_TYPE_NUM_SIZE_16
:
1232 Dest
->u16
= Source
->u16
;
1235 case EFI_IFR_TYPE_NUM_SIZE_32
:
1236 Dest
->u32
= Source
->u32
;
1239 case EFI_IFR_TYPE_NUM_SIZE_64
:
1240 Dest
->u64
= Source
->u64
;
1250 Get selection for OneOf and OrderedList (Left/Right will be ignored).
1252 @param MenuOption Pointer to the current input menu.
1254 @retval EFI_SUCCESS If Option input is processed successfully
1255 @retval EFI_DEVICE_ERROR If operation fails
1259 GetSelectionInputPopUp (
1260 IN UI_MENU_OPTION
*MenuOption
1266 CHAR16
*TempStringPtr
;
1268 UINTN TopOptionIndex
;
1269 UINTN HighlightOptionIndex
;
1274 UINTN PopUpMenuLines
;
1275 UINTN MenuLinesInView
;
1278 INT32 SavedAttribute
;
1279 BOOLEAN ShowDownArrow
;
1280 BOOLEAN ShowUpArrow
;
1281 UINTN DimensionsWidth
;
1283 BOOLEAN OrderedList
;
1287 EFI_HII_VALUE HiiValue
;
1288 DISPLAY_QUESTION_OPTION
*OneOfOption
;
1289 DISPLAY_QUESTION_OPTION
*CurrentOption
;
1290 FORM_DISPLAY_ENGINE_STATEMENT
*Question
;
1292 EFI_IFR_ORDERED_LIST
*OrderList
;
1294 DimensionsWidth
= gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
;
1298 CurrentOption
= NULL
;
1299 ShowDownArrow
= FALSE
;
1300 ShowUpArrow
= FALSE
;
1302 StringPtr
= AllocateZeroPool ((gOptionBlockWidth
+ 1) * 2);
1305 ZeroMem (&HiiValue
, sizeof (EFI_HII_VALUE
));
1307 Question
= MenuOption
->ThisTag
;
1308 if (Question
->OpCode
->OpCode
== EFI_IFR_ORDERED_LIST_OP
) {
1309 Link
= GetFirstNode (&Question
->OptionListHead
);
1310 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1311 ValueArray
= Question
->CurrentValue
.Buffer
;
1312 ValueType
= OneOfOption
->OptionOpCode
->Type
;
1314 OrderList
= (EFI_IFR_ORDERED_LIST
*) Question
->OpCode
;
1316 OrderedList
= FALSE
;
1321 // Calculate Option count
1325 AdjustOptionOrder(Question
, &PopUpMenuLines
);
1327 Link
= GetFirstNode (&Question
->OptionListHead
);
1328 while (!IsNull (&Question
->OptionListHead
, Link
)) {
1329 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1331 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
1336 // Get the number of one of options present and its size
1339 HighlightOptionIndex
= 0;
1340 Link
= GetFirstNode (&Question
->OptionListHead
);
1341 for (Index
= 0; Index
< PopUpMenuLines
; Index
++) {
1342 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1344 StringPtr
= GetToken (OneOfOption
->OptionOpCode
->Option
, gFormData
->HiiHandle
);
1345 if (StrLen (StringPtr
) > PopUpWidth
) {
1346 PopUpWidth
= StrLen (StringPtr
);
1348 FreePool (StringPtr
);
1349 HiiValue
.Type
= OneOfOption
->OptionOpCode
->Type
;
1350 SetValuesByType (&HiiValue
.Value
, &OneOfOption
->OptionOpCode
->Value
, HiiValue
.Type
);
1351 if (!OrderedList
&& (CompareHiiValue (&Question
->CurrentValue
, &HiiValue
, &Result
, NULL
) == EFI_SUCCESS
) && (Result
== 0)) {
1353 // Find current selected Option for OneOf
1355 HighlightOptionIndex
= Index
;
1358 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
1362 // Perform popup menu initialization.
1364 PopUpWidth
= PopUpWidth
+ POPUP_PAD_SPACE_COUNT
;
1366 SavedAttribute
= gST
->ConOut
->Mode
->Attribute
;
1367 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetPopupColor ());
1369 if ((PopUpWidth
+ POPUP_FRAME_WIDTH
) > DimensionsWidth
) {
1370 PopUpWidth
= DimensionsWidth
- POPUP_FRAME_WIDTH
;
1373 Start
= (DimensionsWidth
- PopUpWidth
- POPUP_FRAME_WIDTH
) / 2 + gStatementDimensions
.LeftColumn
;
1374 End
= Start
+ PopUpWidth
+ POPUP_FRAME_WIDTH
;
1375 Top
= gStatementDimensions
.TopRow
;
1376 Bottom
= gStatementDimensions
.BottomRow
- 1;
1378 MenuLinesInView
= Bottom
- Top
- 1;
1379 if (MenuLinesInView
>= PopUpMenuLines
) {
1380 Top
= Top
+ (MenuLinesInView
- PopUpMenuLines
) / 2;
1381 Bottom
= Top
+ PopUpMenuLines
+ 1;
1383 ShowDownArrow
= TRUE
;
1386 if (HighlightOptionIndex
> (MenuLinesInView
- 1)) {
1387 TopOptionIndex
= HighlightOptionIndex
- MenuLinesInView
+ 1;
1394 // Clear that portion of the screen
1396 ClearLines (Start
, End
, Top
, Bottom
, GetPopupColor ());
1399 // Draw "One of" pop-up menu
1401 Character
= BOXDRAW_DOWN_RIGHT
;
1402 PrintCharAt (Start
, Top
, Character
);
1403 for (Index
= Start
; Index
+ 2 < End
; Index
++) {
1404 if ((ShowUpArrow
) && ((Index
+ 1) == (Start
+ End
) / 2)) {
1405 Character
= GEOMETRICSHAPE_UP_TRIANGLE
;
1407 Character
= BOXDRAW_HORIZONTAL
;
1410 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
1413 Character
= BOXDRAW_DOWN_LEFT
;
1414 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
1415 Character
= BOXDRAW_VERTICAL
;
1416 for (Index
= Top
+ 1; Index
< Bottom
; Index
++) {
1417 PrintCharAt (Start
, Index
, Character
);
1418 PrintCharAt (End
- 1, Index
, Character
);
1422 // Move to top Option
1424 Link
= GetFirstNode (&Question
->OptionListHead
);
1425 for (Index
= 0; Index
< TopOptionIndex
; Index
++) {
1426 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
1430 // Display the One of options
1433 for (Index
= TopOptionIndex
; (Index
< PopUpMenuLines
) && (Index2
< Bottom
); Index
++) {
1434 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1435 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
1437 StringPtr
= GetToken (OneOfOption
->OptionOpCode
->Option
, gFormData
->HiiHandle
);
1438 ASSERT (StringPtr
!= NULL
);
1440 // If the string occupies multiple lines, truncate it to fit in one line,
1441 // and append a "..." for indication.
1443 if (StrLen (StringPtr
) > (PopUpWidth
- 1)) {
1444 TempStringPtr
= AllocateZeroPool (sizeof (CHAR16
) * (PopUpWidth
- 1));
1445 ASSERT ( TempStringPtr
!= NULL
);
1446 CopyMem (TempStringPtr
, StringPtr
, (sizeof (CHAR16
) * (PopUpWidth
- 5)));
1447 FreePool (StringPtr
);
1448 StringPtr
= TempStringPtr
;
1449 StrCatS (StringPtr
, PopUpWidth
- 1, L
"...");
1452 if (Index
== HighlightOptionIndex
) {
1454 // Highlight the selected one
1456 CurrentOption
= OneOfOption
;
1458 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetPickListColor ());
1459 PrintStringAt (Start
+ 2, Index2
, StringPtr
);
1460 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetPopupColor ());
1462 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetPopupColor ());
1463 PrintStringAt (Start
+ 2, Index2
, StringPtr
);
1467 FreePool (StringPtr
);
1470 Character
= BOXDRAW_UP_RIGHT
;
1471 PrintCharAt (Start
, Bottom
, Character
);
1472 for (Index
= Start
; Index
+ 2 < End
; Index
++) {
1473 if ((ShowDownArrow
) && ((Index
+ 1) == (Start
+ End
) / 2)) {
1474 Character
= GEOMETRICSHAPE_DOWN_TRIANGLE
;
1476 Character
= BOXDRAW_HORIZONTAL
;
1479 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
1482 Character
= BOXDRAW_UP_LEFT
;
1483 PrintCharAt ((UINTN
)-1, (UINTN
)-1, Character
);
1486 // Get User selection
1488 Key
.UnicodeChar
= CHAR_NULL
;
1489 if ((gDirection
== SCAN_UP
) || (gDirection
== SCAN_DOWN
)) {
1490 Key
.ScanCode
= gDirection
;
1495 WaitForKeyStroke (&Key
);
1498 switch (Key
.UnicodeChar
) {
1501 if ((TopOptionIndex
> 0) && (TopOptionIndex
== HighlightOptionIndex
)) {
1503 // Highlight reaches the top of the popup window, scroll one menu item.
1506 ShowDownArrow
= TRUE
;
1509 if (TopOptionIndex
== 0) {
1510 ShowUpArrow
= FALSE
;
1513 if (HighlightOptionIndex
> 0) {
1514 HighlightOptionIndex
--;
1516 ASSERT (CurrentOption
!= NULL
);
1517 SwapListEntries (CurrentOption
->Link
.BackLink
, &CurrentOption
->Link
);
1524 // If an ordered list op-code, we will allow for a popup of +/- keys
1525 // to create an ordered list of items
1528 if (((TopOptionIndex
+ MenuLinesInView
) < PopUpMenuLines
) &&
1529 (HighlightOptionIndex
== (TopOptionIndex
+ MenuLinesInView
- 1))) {
1531 // Highlight reaches the bottom of the popup window, scroll one menu item.
1537 if ((TopOptionIndex
+ MenuLinesInView
) == PopUpMenuLines
) {
1538 ShowDownArrow
= FALSE
;
1541 if (HighlightOptionIndex
< (PopUpMenuLines
- 1)) {
1542 HighlightOptionIndex
++;
1544 ASSERT (CurrentOption
!= NULL
);
1545 SwapListEntries (&CurrentOption
->Link
, CurrentOption
->Link
.ForwardLink
);
1551 switch (Key
.ScanCode
) {
1554 if (Key
.ScanCode
== SCAN_UP
) {
1555 if ((TopOptionIndex
> 0) && (TopOptionIndex
== HighlightOptionIndex
)) {
1557 // Highlight reaches the top of the popup window, scroll one menu item.
1560 ShowDownArrow
= TRUE
;
1563 if (TopOptionIndex
== 0) {
1564 ShowUpArrow
= FALSE
;
1567 if (HighlightOptionIndex
> 0) {
1568 HighlightOptionIndex
--;
1571 if (((TopOptionIndex
+ MenuLinesInView
) < PopUpMenuLines
) &&
1572 (HighlightOptionIndex
== (TopOptionIndex
+ MenuLinesInView
- 1))) {
1574 // Highlight reaches the bottom of the popup window, scroll one menu item.
1580 if ((TopOptionIndex
+ MenuLinesInView
) == PopUpMenuLines
) {
1581 ShowDownArrow
= FALSE
;
1584 if (HighlightOptionIndex
< (PopUpMenuLines
- 1)) {
1585 HighlightOptionIndex
++;
1591 gST
->ConOut
->SetAttribute (gST
->ConOut
, SavedAttribute
);
1594 // Restore link list order for orderedlist
1597 HiiValue
.Type
= ValueType
;
1598 HiiValue
.Value
.u64
= 0;
1599 for (Index
= 0; Index
< OrderList
->MaxContainers
; Index
++) {
1600 HiiValue
.Value
.u64
= GetArrayData (ValueArray
, ValueType
, Index
);
1601 if (HiiValue
.Value
.u64
== 0) {
1605 OneOfOption
= ValueToOption (Question
, &HiiValue
);
1606 if (OneOfOption
== NULL
) {
1607 return EFI_NOT_FOUND
;
1610 RemoveEntryList (&OneOfOption
->Link
);
1611 InsertTailList (&Question
->OptionListHead
, &OneOfOption
->Link
);
1615 return EFI_DEVICE_ERROR
;
1623 case CHAR_CARRIAGE_RETURN
:
1625 // return the current selection
1628 ReturnValue
= AllocateZeroPool (Question
->CurrentValue
.BufferLen
);
1629 ASSERT (ReturnValue
!= NULL
);
1631 Link
= GetFirstNode (&Question
->OptionListHead
);
1632 while (!IsNull (&Question
->OptionListHead
, Link
)) {
1633 OneOfOption
= DISPLAY_QUESTION_OPTION_FROM_LINK (Link
);
1634 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
1636 SetArrayData (ReturnValue
, ValueType
, Index
, OneOfOption
->OptionOpCode
->Value
.u64
);
1639 if (Index
> OrderList
->MaxContainers
) {
1643 if (CompareMem (ReturnValue
, ValueArray
, Question
->CurrentValue
.BufferLen
) == 0) {
1644 FreePool (ReturnValue
);
1645 return EFI_DEVICE_ERROR
;
1647 gUserInput
->InputValue
.Buffer
= ReturnValue
;
1648 gUserInput
->InputValue
.BufferLen
= Question
->CurrentValue
.BufferLen
;
1651 ASSERT (CurrentOption
!= NULL
);
1652 gUserInput
->InputValue
.Type
= CurrentOption
->OptionOpCode
->Type
;
1653 if (IsValuesEqual (&Question
->CurrentValue
.Value
, &CurrentOption
->OptionOpCode
->Value
, gUserInput
->InputValue
.Type
)) {
1654 return EFI_DEVICE_ERROR
;
1656 SetValuesByType (&gUserInput
->InputValue
.Value
, &CurrentOption
->OptionOpCode
->Value
, gUserInput
->InputValue
.Type
);
1660 gST
->ConOut
->SetAttribute (gST
->ConOut
, SavedAttribute
);