2 Private structure, MACRO and function definitions for User Interface related functionalities.
4 Copyright (c) 2004 - 2013, 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.
21 #define REGULAR_NUMERIC 0
22 #define TIME_NUMERIC 1
23 #define DATE_NUMERIC 2
25 #define SUBTITLE_INDENT 2
29 // It take 23 characters including the NULL to print a 64 bits number with "[" and "]".
30 // pow(2, 64) = [18446744073709551616]
32 #define MAX_NUMERIC_INPUT_WIDTH 23
47 } UI_SCREEN_OPERATION
;
73 #define UI_ACTION_NONE 0
74 #define UI_ACTION_REFRESH_FORM 1
75 #define UI_ACTION_REFRESH_FORMSET 2
76 #define UI_ACTION_EXIT 3
78 typedef struct _UI_MENU_LIST UI_MENU_LIST
;
81 EFI_HII_HANDLE Handle
;
84 // Target formset/form/Question information
89 UINTN Sequence
; // used for time/date only.
98 // Ation for Browser to taken:
99 // UI_ACTION_NONE - navigation inside a form
100 // UI_ACTION_REFRESH_FORM - re-evaluate expressions and repaint form
101 // UI_ACTION_REFRESH_FORMSET - re-parse formset IFR binary
106 // Current selected fomset/form/Question
108 FORM_BROWSER_FORMSET
*FormSet
;
109 FORM_BROWSER_FORM
*Form
;
110 FORM_BROWSER_STATEMENT
*Statement
;
113 // Whether the Form is editable
115 BOOLEAN FormEditable
;
117 UI_MENU_LIST
*CurrentMenu
;
120 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
121 #define UI_MENU_LIST_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'l')
127 EFI_HII_HANDLE Handle
;
128 FORM_BROWSER_STATEMENT
*ThisTag
;
135 UINTN Skip
; // Number of lines
138 // Display item sequence for date/time
139 // Date: Month/Day/Year
142 // Time: Hour : Minute : Second
152 // Whether user could change value of this item
157 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
159 struct _UI_MENU_LIST
{
163 EFI_HII_HANDLE HiiHandle
;
164 EFI_GUID FormSetGuid
;
167 UINTN Sequence
; // used for time/date only.
169 UI_MENU_LIST
*Parent
;
170 LIST_ENTRY ChildListHead
;
173 #define UI_MENU_LIST_FROM_LINK(a) CR (a, UI_MENU_LIST, Link, UI_MENU_LIST_SIGNATURE)
175 typedef struct _MENU_REFRESH_ENTRY MENU_REFRESH_ENTRY
;
176 struct _MENU_REFRESH_ENTRY
{
177 MENU_REFRESH_ENTRY
*Next
;
178 UI_MENU_OPTION
*MenuOption
; // Describes the entry needing an update
179 UI_MENU_SELECTION
*Selection
;
182 UINTN CurrentAttribute
;
188 UI_SCREEN_OPERATION ScreenOperation
;
189 } SCAN_CODE_TO_SCREEN_OPERATION
;
192 UI_SCREEN_OPERATION ScreenOperation
;
193 UI_CONTROL_FLAG ControlFlag
;
194 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
197 extern LIST_ENTRY gMenuOption
;
198 extern LIST_ENTRY gMenuList
;
199 extern MENU_REFRESH_ENTRY
*gMenuRefreshHead
;
200 extern UI_MENU_SELECTION
*gCurrentSelection
;
201 extern BOOLEAN mHiiPackageListUpdated
;
207 Initialize Menu option list.
216 Initialize Menu option list.
225 Free Menu option linked list.
234 Create a menu with specified formset GUID and form ID, and add it as a child
235 of the given parent menu.
237 @param Parent The parent of menu to be added.
238 @param HiiHandle Hii handle related to this formset.
239 @param FormSetGuid The Formset Guid of menu to be added.
240 @param FormId The Form ID of menu to be added.
242 @return A pointer to the newly added menu or NULL if memory is insufficient.
247 IN OUT UI_MENU_LIST
*Parent
,
248 IN EFI_HII_HANDLE HiiHandle
,
249 IN EFI_GUID
*FormSetGuid
,
254 Search Menu with given FormId, FormSetGuid and Handle in all cached menu list.
256 @param Parent The parent of menu to search.
257 @param Handle Hii handle related to this formset.
258 @param FormSetGuid The Formset GUID of the menu to search.
259 @param FormId The Form ID of menu to search.
261 @return A pointer to menu found or NULL if not found.
265 UiFindChildMenuList (
266 IN UI_MENU_LIST
*Parent
,
267 IN EFI_HII_HANDLE Handle
,
268 IN EFI_GUID
*FormSetGuid
,
273 Search Menu with given Handle, FormSetGuid and FormId in all cached menu list.
275 @param Handle Hii handle related to this formset.
276 @param FormSetGuid The Formset GUID of the menu to search.
277 @param FormId The Form ID of menu to search.
279 @return A pointer to menu found or NULL if not found.
284 IN EFI_HII_HANDLE Handle
,
285 IN EFI_GUID
*FormSetGuid
,
290 Free Menu list linked list.
292 @param MenuListHead One Menu list point in the menu list.
297 LIST_ENTRY
*MenuListHead
301 Free Menu option linked list.
310 Add one menu option by specified description and context.
312 @param String String description for this option.
313 @param Handle Hii handle for the package list.
314 @param Form The form this statement belong to.
315 @param Statement Statement of this Menu Option.
316 @param NumberOfLines Display lines for this Menu Option.
317 @param MenuItemCount The index for this Option in the Menu.
319 @retval Pointer Pointer to the added Menu Option.
325 IN EFI_HII_HANDLE Handle
,
326 IN FORM_BROWSER_FORM
*Form
,
327 IN FORM_BROWSER_STATEMENT
*Statement
,
328 IN UINT16 NumberOfLines
,
329 IN UINT16 MenuItemCount
333 Display menu and wait for user to select one menu option, then return it.
334 If AutoBoot is enabled, then if user doesn't select any option,
335 after period of time, it will automatically return the first menu option.
337 @param Selection Menu selection.
339 @return Return the pointer of the menu which selected,
340 @return otherwise return NULL.
345 IN OUT UI_MENU_SELECTION
*Selection
349 Free up the resource allocated for all strings required
359 Process the goto op code, update the info in the selection structure.
361 @param Statement The statement belong to goto op code.
362 @param Selection The selection info.
363 @param Repaint Whether need to repaint the menu.
364 @param NewLine Whether need to create new line.
366 @retval EFI_SUCCESS The menu process successfully.
367 @return Other value if the process failed.
371 IN OUT FORM_BROWSER_STATEMENT
*Statement
,
372 IN OUT UI_MENU_SELECTION
*Selection
,
373 OUT BOOLEAN
*Repaint
,
379 The worker function that send the displays to the screen. On output,
380 the selection made by user is returned.
382 @param Selection On input, Selection tell setup browser the information
383 about the Selection, form and formset to be displayed.
384 On output, Selection return the screen item that is selected
387 @retval EFI_SUCCESS The page is displayed successfully.
388 @return Other value if the page failed to be diplayed.
393 IN OUT UI_MENU_SELECTION
*Selection
397 Set Buffer to Value for Size bytes.
399 @param Buffer Memory to set.
400 @param Size Number of bytes to set
401 @param Value Value of the set operation.
412 Wait for a given event to fire, or for an optional timeout to expire.
414 @param Event The event to wait for
415 @param Timeout An optional timeout value in 100 ns units.
416 @param RefreshInterval Menu refresh interval (in seconds).
418 @retval EFI_SUCCESS Event fired before Timeout expired.
419 @retval EFI_TIME_OUT Timout expired before Event fired.
423 UiWaitForSingleEvent (
425 IN UINT64 Timeout
, OPTIONAL
426 IN UINT8 RefreshInterval OPTIONAL
430 Draw a pop up windows based on the dimension, number of lines and
433 @param ScreenWidth The width of the pop-up.
434 @param NumberOfLines The number of lines.
435 @param ... A series of text strings that displayed in the pop-up.
440 CreateMultiStringPopUp (
441 IN UINTN ScreenWidth
,
442 IN UINTN NumberOfLines
,
447 Get string or password input from user.
449 @param MenuOption Pointer to the current input menu.
450 @param Prompt The prompt string shown on popup window.
451 @param StringPtr Old user input and destination for use input string.
453 @retval EFI_SUCCESS If string input is read successfully
454 @retval EFI_DEVICE_ERROR If operation fails
459 IN UI_MENU_OPTION
*MenuOption
,
461 IN OUT CHAR16
*StringPtr
465 Get selection for OneOf and OrderedList (Left/Right will be ignored).
467 @param Selection Pointer to current selection.
468 @param MenuOption Pointer to the current input menu.
470 @retval EFI_SUCCESS If Option input is processed successfully
471 @retval EFI_DEVICE_ERROR If operation fails
475 GetSelectionInputPopUp (
476 IN UI_MENU_SELECTION
*Selection
,
477 IN UI_MENU_OPTION
*MenuOption
481 This routine reads a numeric value from the user input.
483 @param Selection Pointer to current selection.
484 @param MenuOption Pointer to the current input menu.
486 @retval EFI_SUCCESS If numerical input is read successfully
487 @retval EFI_DEVICE_ERROR If operation fails
492 IN UI_MENU_SELECTION
*Selection
,
493 IN UI_MENU_OPTION
*MenuOption
497 Update status bar on the bottom of menu.
499 @param Selection Current selection info.
500 @param MessageType The type of message to be shown.
501 @param Flags The flags in Question header.
502 @param State Set or clear.
507 IN UI_MENU_SELECTION
*Selection
,
508 IN UINTN MessageType
,
514 Process Question Config.
516 @param Selection The UI menu selection.
517 @param Question The Question to be peocessed.
519 @retval EFI_SUCCESS Question Config process success.
520 @retval Other Question Config process fail.
524 ProcessQuestionConfig (
525 IN UI_MENU_SELECTION
*Selection
,
526 IN FORM_BROWSER_STATEMENT
*Question
530 Print Question Value according to it's storage width and display attributes.
532 @param Question The Question to be printed.
533 @param FormattedNumber Buffer for output string.
534 @param BufferSize The FormattedNumber buffer size in bytes.
536 @retval EFI_SUCCESS Print success.
537 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
541 PrintFormattedNumber (
542 IN FORM_BROWSER_STATEMENT
*Question
,
543 IN OUT CHAR16
*FormattedNumber
,
548 Search an Option of a Question by its value.
550 @param Question The Question
551 @param OptionValue Value for Option to be searched.
553 @retval Pointer Pointer to the found Option.
554 @retval NULL Option not found.
559 IN FORM_BROWSER_STATEMENT
*Question
,
560 IN EFI_HII_VALUE
*OptionValue
564 Return data element in an Array by its Index.
566 @param Array The data array.
567 @param Type Type of the data in this array.
568 @param Index Zero based index for data in this array.
570 @retval Value The data to be returned
581 Set value of a data element in an Array by its Index.
583 @param Array The data array.
584 @param Type Type of the data in this array.
585 @param Index Zero based index for data in this array.
586 @param Value The value to be set.
598 Check whether this value already in the array, if yes, return the index.
600 @param Array The data array.
601 @param Type Type of the data in this array.
602 @param Value The value to be find.
603 @param Index The index in the array which has same value with Value.
605 @retval TRUE Found the value in the array.
606 @retval FALSE Not found the value.
614 OUT UINTN
*Index OPTIONAL
618 Process a Question's Option (whether selected or un-selected).
620 @param Selection Pointer to UI_MENU_SELECTION.
621 @param MenuOption The MenuOption for this Question.
622 @param Selected TRUE: if Question is selected.
623 @param OptionString Pointer of the Option String to be displayed.
625 @retval EFI_SUCCESS Question Option process success.
626 @retval Other Question Option process fail.
631 IN UI_MENU_SELECTION
*Selection
,
632 IN UI_MENU_OPTION
*MenuOption
,
634 OUT CHAR16
**OptionString
638 Process the help string: Split StringPtr to several lines of strings stored in
639 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
641 @param StringPtr The entire help string.
642 @param FormattedString The oupput formatted string.
643 @param EachLineWidth The string length of each line in the formatted string.
644 @param RowCount TRUE: if Question is selected.
649 IN CHAR16
*StringPtr
,
650 OUT CHAR16
**FormattedString
,
651 OUT UINT16
*EachLineWidth
,
656 Update key's help imformation.
658 @param Selection Tell setup browser the information about the Selection
659 @param MenuOption The Menu option
660 @param Selected Whether or not a tag be selected
665 IN UI_MENU_SELECTION
*Selection
,
666 IN UI_MENU_OPTION
*MenuOption
,
671 Clear retangle with specified text attribute.
673 @param LeftColumn Left column of retangle.
674 @param RightColumn Right column of retangle.
675 @param TopRow Start row of retangle.
676 @param BottomRow End row of retangle.
677 @param TextAttribute The character foreground and background.
683 IN UINTN RightColumn
,
686 IN UINTN TextAttribute
690 Count the storage space of a Unicode string.
692 This function handles the Unicode string with NARROW_CHAR
693 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
694 does not count in the resultant output. If a WIDE_CHAR is
695 hit, then 2 Unicode character will consume an output storage
696 space with size of CHAR16 till a NARROW_CHAR is hit.
698 If String is NULL, then ASSERT ().
700 @param String The input string to be counted.
702 @return Storage space for the input string.
711 Will copy LineWidth amount of a string in the OutputString buffer and return the
712 number of CHAR16 characters that were copied into the OutputString buffer.
713 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
715 @param InputString String description for this option.
716 @param LineWidth Width of the desired string to extract in CHAR16
718 @param GlyphWidth The glyph width of the beging char in the string.
719 @param Index Where in InputString to start the copy process
720 @param OutputString Buffer to copy the string into
722 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
727 IN CHAR16
*InputString
,
729 IN OUT UINT16
*GlyphWidth
,
731 OUT CHAR16
**OutputString
735 Get the supported width for a particular op-code
737 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
738 @param Handle The handle in the HII database being used
740 @return Returns the number of CHAR16 characters that is support.
745 IN FORM_BROWSER_STATEMENT
*Statement
,
746 IN EFI_HII_HANDLE Handle
750 Concatenate a narrow string to another string.
752 @param Destination The destination string.
753 @param Source The source string. The string to be concatenated.
754 to the end of Destination.
759 IN OUT CHAR16
*Destination
,
764 Wait for a key to be pressed by user.
766 @param Key The key which is pressed by user.
768 @retval EFI_SUCCESS The function always completed successfully.
773 OUT EFI_INPUT_KEY
*Key
777 Reset stack pointer to begin of the stack.
786 Push the expression options onto the Stack.
788 @param Pointer Pointer to the current expression.
789 @param Level Which type this expression belong to. Form,
792 @retval EFI_SUCCESS The value was pushed onto the stack.
793 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
797 PushConditionalExpression (
798 IN FORM_EXPRESSION
*Pointer
,
799 IN EXPRESS_LEVEL Level
803 Pop the expression options from the Stack
805 @param Level Which type this expression belong to. Form,
808 @retval EFI_SUCCESS The value was pushed onto the stack.
809 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
813 PopConditionalExpression (
814 IN EXPRESS_LEVEL Level
818 Get the expression Buffer pointer.
820 @param Level Which type this expression belong to. Form,
823 @retval The start pointer of the expression buffer or NULL.
827 GetConditionalExpressionList (
828 IN EXPRESS_LEVEL Level
832 Get the expression list count.
834 @param Level Which type this expression belong to. Form,
837 @retval >=0 The expression count
838 @retval -1 Input parameter error.
842 GetConditionalExpressionCount (
843 IN EXPRESS_LEVEL Level
847 Push an Operand onto the Stack
849 @param Operand Operand to push.
851 @retval EFI_SUCCESS The value was pushed onto the stack.
852 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
862 Pop an Operand from the Stack
864 @param Operand Operand to pop.
866 @retval EFI_SUCCESS The value was pushed onto the stack.
867 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
877 Reset stack pointer to begin of the stack.
881 ResetCurrentExpressionStack (
886 Push current expression onto the Stack
888 @param Pointer Pointer to current expression.
890 @retval EFI_SUCCESS The value was pushed onto the stack.
891 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
895 PushCurrentExpression (
900 Pop current expression from the Stack
902 @param Pointer Pointer to current expression to be pop.
904 @retval EFI_SUCCESS The value was pushed onto the stack.
905 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
909 PopCurrentExpression (
914 Reset stack pointer to begin of the stack.
918 ResetMapExpressionListStack (
923 Push the list of map expression onto the Stack
925 @param Pointer Pointer to the list of map expression to be pushed.
927 @retval EFI_SUCCESS The value was pushed onto the stack.
928 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
932 PushMapExpressionList (
937 Pop the list of map expression from the Stack
939 @param Pointer Pointer to the list of map expression to be pop.
941 @retval EFI_SUCCESS The value was pushed onto the stack.
942 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
946 PopMapExpressionList (
951 Get Form given its FormId.
953 @param FormSet The formset which contains this form.
954 @param FormId Id of this form.
956 @retval Pointer The form.
957 @retval NULL Specified Form is not found in the formset.
962 IN FORM_BROWSER_FORMSET
*FormSet
,
967 Search a Question in Formset scope using its QuestionId.
969 @param FormSet The formset which contains this form.
970 @param Form The form which contains this Question.
971 @param QuestionId Id of this Question.
973 @retval Pointer The Question.
974 @retval NULL Specified Question not found in the form.
977 FORM_BROWSER_STATEMENT
*
979 IN FORM_BROWSER_FORMSET
*FormSet
,
980 IN FORM_BROWSER_FORM
*Form
,
985 Zero extend integer/boolean/date/time to UINT64 for comparing.
987 @param Value HII Value to be converted.
992 IN EFI_HII_VALUE
*Value
996 Compare two Hii value.
998 @param Value1 Expression value to compare on left-hand.
999 @param Value2 Expression value to compare on right-hand.
1000 @param Result Return value after compare.
1001 retval 0 Two operators equal.
1002 return Positive value if Value1 is greater than Value2.
1003 retval Negative value if Value1 is less than Value2.
1004 @param HiiHandle Only required for string compare.
1006 @retval other Could not perform compare on two values.
1007 @retval EFI_SUCCESS Compare the value success.
1012 IN EFI_HII_VALUE
*Value1
,
1013 IN EFI_HII_VALUE
*Value2
,
1015 IN EFI_HII_HANDLE HiiHandle OPTIONAL
1019 Evaluate the result of a HII expression
1021 If Expression is NULL, then ASSERT.
1023 @param FormSet FormSet associated with this expression.
1024 @param Form Form associated with this expression.
1025 @param Expression Expression to be evaluated.
1027 @retval EFI_SUCCESS The expression evaluated successfuly
1028 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
1030 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
1032 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
1033 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
1037 EvaluateExpression (
1038 IN FORM_BROWSER_FORMSET
*FormSet
,
1039 IN FORM_BROWSER_FORM
*Form
,
1040 IN OUT FORM_EXPRESSION
*Expression
1044 Return the result of the expression list. Check the expression list and
1045 return the highest priority express result.
1046 Priority: DisableIf > SuppressIf > GrayOutIf > FALSE
1048 @param ExpList The input expression list.
1049 @param Evaluate Whether need to evaluate the expression first.
1050 @param FormSet FormSet associated with this expression. Only
1051 needed when Evaluate is TRUE
1052 @param Form Form associated with this expression. Only
1053 needed when Evaluate is TRUE
1055 @retval EXPRESS_RESULT Return the higher priority express result.
1056 DisableIf > SuppressIf > GrayOutIf > FALSE
1060 EvaluateExpressionList (
1061 IN FORM_EXPRESSION_LIST
*ExpList
,
1062 IN BOOLEAN Evaluate
,
1063 IN FORM_BROWSER_FORMSET
*FormSet
, OPTIONAL
1064 IN FORM_BROWSER_FORM
*Form OPTIONAL