2 Private structure, MACRO and function definitions for User Interface related functionalities.
4 Copyright (c) 2004 - 2011, 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_GUID FormSetGuid
;
166 UINTN Sequence
; // used for time/date only.
168 UI_MENU_LIST
*Parent
;
169 LIST_ENTRY ChildListHead
;
172 #define UI_MENU_LIST_FROM_LINK(a) CR (a, UI_MENU_LIST, Link, UI_MENU_LIST_SIGNATURE)
174 typedef struct _MENU_REFRESH_ENTRY MENU_REFRESH_ENTRY
;
175 struct _MENU_REFRESH_ENTRY
{
176 MENU_REFRESH_ENTRY
*Next
;
177 UI_MENU_OPTION
*MenuOption
; // Describes the entry needing an update
178 UI_MENU_SELECTION
*Selection
;
181 UINTN CurrentAttribute
;
187 UI_SCREEN_OPERATION ScreenOperation
;
188 } SCAN_CODE_TO_SCREEN_OPERATION
;
191 UI_SCREEN_OPERATION ScreenOperation
;
192 UI_CONTROL_FLAG ControlFlag
;
193 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
196 extern LIST_ENTRY gMenuOption
;
197 extern MENU_REFRESH_ENTRY
*gMenuRefreshHead
;
198 extern UI_MENU_SELECTION
*gCurrentSelection
;
199 extern BOOLEAN mHiiPackageListUpdated
;
205 Initialize Menu option list.
214 Initialize Menu option list.
223 Free Menu option linked list.
232 Create a menu with specified formset GUID and form ID, and add it as a child
233 of the given parent menu.
235 @param Parent The parent of menu to be added.
236 @param FormSetGuid The Formset Guid of menu to be added.
237 @param FormId The Form ID of menu to be added.
239 @return A pointer to the newly added menu or NULL if memory is insufficient.
244 IN OUT UI_MENU_LIST
*Parent
,
245 IN EFI_GUID
*FormSetGuid
,
250 Search Menu with given FormId in the parent menu and all its child menus.
252 @param Parent The parent of menu to search.
253 @param FormId The Form ID of menu to search.
255 @return A pointer to menu found or NULL if not found.
259 UiFindChildMenuList (
260 IN UI_MENU_LIST
*Parent
,
265 Search Menu with given FormSetGuid and FormId in all cached menu list.
267 @param FormSetGuid The Formset GUID of the menu to search.
268 @param FormId The Form ID of menu to search.
270 @return A pointer to menu found or NULL if not found.
275 IN EFI_GUID
*FormSetGuid
,
280 Free Menu option linked list.
289 Add one menu option by specified description and context.
291 @param String String description for this option.
292 @param Handle Hii handle for the package list.
293 @param Statement Statement of this Menu Option.
294 @param NumberOfLines Display lines for this Menu Option.
295 @param MenuItemCount The index for this Option in the Menu.
297 @retval Pointer Pointer to the added Menu Option.
303 IN EFI_HII_HANDLE Handle
,
304 IN FORM_BROWSER_STATEMENT
*Statement
,
305 IN UINT16 NumberOfLines
,
306 IN UINT16 MenuItemCount
310 Display menu and wait for user to select one menu option, then return it.
311 If AutoBoot is enabled, then if user doesn't select any option,
312 after period of time, it will automatically return the first menu option.
314 @param Selection Menu selection.
316 @return Return the pointer of the menu which selected,
317 @return otherwise return NULL.
322 IN OUT UI_MENU_SELECTION
*Selection
326 Free up the resource allocated for all strings required
336 Process the goto op code, update the info in the selection structure.
338 @param Statement The statement belong to goto op code.
339 @param Selection The selection info.
340 @param Repaint Whether need to repaint the menu.
341 @param NewLine Whether need to create new line.
343 @retval EFI_SUCCESS The menu process successfully.
344 @return Other value if the process failed.
348 IN OUT FORM_BROWSER_STATEMENT
*Statement
,
349 IN OUT UI_MENU_SELECTION
*Selection
,
350 OUT BOOLEAN
*Repaint
,
356 The worker function that send the displays to the screen. On output,
357 the selection made by user is returned.
359 @param Selection On input, Selection tell setup browser the information
360 about the Selection, form and formset to be displayed.
361 On output, Selection return the screen item that is selected
364 @retval EFI_SUCCESS The page is displayed successfully.
365 @return Other value if the page failed to be diplayed.
370 IN OUT UI_MENU_SELECTION
*Selection
374 Set Buffer to Value for Size bytes.
376 @param Buffer Memory to set.
377 @param Size Number of bytes to set
378 @param Value Value of the set operation.
389 Wait for a given event to fire, or for an optional timeout to expire.
391 @param Event The event to wait for
392 @param Timeout An optional timeout value in 100 ns units.
393 @param RefreshInterval Menu refresh interval (in seconds).
395 @retval EFI_SUCCESS Event fired before Timeout expired.
396 @retval EFI_TIME_OUT Timout expired before Event fired.
400 UiWaitForSingleEvent (
402 IN UINT64 Timeout
, OPTIONAL
403 IN UINT8 RefreshInterval OPTIONAL
407 Draw a pop up windows based on the dimension, number of lines and
410 @param ScreenWidth The width of the pop-up.
411 @param NumberOfLines The number of lines.
412 @param ... A series of text strings that displayed in the pop-up.
417 CreateMultiStringPopUp (
418 IN UINTN ScreenWidth
,
419 IN UINTN NumberOfLines
,
424 Get string or password input from user.
426 @param MenuOption Pointer to the current input menu.
427 @param Prompt The prompt string shown on popup window.
428 @param StringPtr Old user input and destination for use input string.
430 @retval EFI_SUCCESS If string input is read successfully
431 @retval EFI_DEVICE_ERROR If operation fails
436 IN UI_MENU_OPTION
*MenuOption
,
438 IN OUT CHAR16
*StringPtr
442 Get selection for OneOf and OrderedList (Left/Right will be ignored).
444 @param Selection Pointer to current selection.
445 @param MenuOption Pointer to the current input menu.
447 @retval EFI_SUCCESS If Option input is processed successfully
448 @retval EFI_DEVICE_ERROR If operation fails
452 GetSelectionInputPopUp (
453 IN UI_MENU_SELECTION
*Selection
,
454 IN UI_MENU_OPTION
*MenuOption
458 This routine reads a numeric value from the user input.
460 @param Selection Pointer to current selection.
461 @param MenuOption Pointer to the current input menu.
463 @retval EFI_SUCCESS If numerical input is read successfully
464 @retval EFI_DEVICE_ERROR If operation fails
469 IN UI_MENU_SELECTION
*Selection
,
470 IN UI_MENU_OPTION
*MenuOption
474 Update status bar on the bottom of menu.
476 @param Selection Current selection info.
477 @param MessageType The type of message to be shown.
478 @param Flags The flags in Question header.
479 @param State Set or clear.
484 IN UI_MENU_SELECTION
*Selection
,
485 IN UINTN MessageType
,
491 Process Question Config.
493 @param Selection The UI menu selection.
494 @param Question The Question to be peocessed.
496 @retval EFI_SUCCESS Question Config process success.
497 @retval Other Question Config process fail.
501 ProcessQuestionConfig (
502 IN UI_MENU_SELECTION
*Selection
,
503 IN FORM_BROWSER_STATEMENT
*Question
507 Print Question Value according to it's storage width and display attributes.
509 @param Question The Question to be printed.
510 @param FormattedNumber Buffer for output string.
511 @param BufferSize The FormattedNumber buffer size in bytes.
513 @retval EFI_SUCCESS Print success.
514 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
518 PrintFormattedNumber (
519 IN FORM_BROWSER_STATEMENT
*Question
,
520 IN OUT CHAR16
*FormattedNumber
,
525 Search an Option of a Question by its value.
527 @param Question The Question
528 @param OptionValue Value for Option to be searched.
530 @retval Pointer Pointer to the found Option.
531 @retval NULL Option not found.
536 IN FORM_BROWSER_STATEMENT
*Question
,
537 IN EFI_HII_VALUE
*OptionValue
541 Return data element in an Array by its Index.
543 @param Array The data array.
544 @param Type Type of the data in this array.
545 @param Index Zero based index for data in this array.
547 @retval Value The data to be returned
558 Set value of a data element in an Array by its Index.
560 @param Array The data array.
561 @param Type Type of the data in this array.
562 @param Index Zero based index for data in this array.
563 @param Value The value to be set.
575 Process a Question's Option (whether selected or un-selected).
577 @param Selection Pointer to UI_MENU_SELECTION.
578 @param MenuOption The MenuOption for this Question.
579 @param Selected TRUE: if Question is selected.
580 @param OptionString Pointer of the Option String to be displayed.
582 @retval EFI_SUCCESS Question Option process success.
583 @retval Other Question Option process fail.
588 IN UI_MENU_SELECTION
*Selection
,
589 IN UI_MENU_OPTION
*MenuOption
,
591 OUT CHAR16
**OptionString
595 Process the help string: Split StringPtr to several lines of strings stored in
596 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
598 @param StringPtr The entire help string.
599 @param FormattedString The oupput formatted string.
600 @param RowCount TRUE: if Question is selected.
605 IN CHAR16
*StringPtr
,
606 OUT CHAR16
**FormattedString
,
611 Update key's help imformation.
613 @param Selection Tell setup browser the information about the Selection
614 @param MenuOption The Menu option
615 @param Selected Whether or not a tag be selected
620 IN UI_MENU_SELECTION
*Selection
,
621 IN UI_MENU_OPTION
*MenuOption
,
626 Clear retangle with specified text attribute.
628 @param LeftColumn Left column of retangle.
629 @param RightColumn Right column of retangle.
630 @param TopRow Start row of retangle.
631 @param BottomRow End row of retangle.
632 @param TextAttribute The character foreground and background.
638 IN UINTN RightColumn
,
641 IN UINTN TextAttribute
645 Count the storage space of a Unicode string.
647 This function handles the Unicode string with NARROW_CHAR
648 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
649 does not count in the resultant output. If a WIDE_CHAR is
650 hit, then 2 Unicode character will consume an output storage
651 space with size of CHAR16 till a NARROW_CHAR is hit.
653 If String is NULL, then ASSERT ().
655 @param String The input string to be counted.
657 @return Storage space for the input string.
666 Will copy LineWidth amount of a string in the OutputString buffer and return the
667 number of CHAR16 characters that were copied into the OutputString buffer.
669 @param InputString String description for this option.
670 @param LineWidth Width of the desired string to extract in CHAR16
672 @param Index Where in InputString to start the copy process
673 @param OutputString Buffer to copy the string into
675 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
680 IN CHAR16
*InputString
,
683 OUT CHAR16
**OutputString
687 Get the supported width for a particular op-code
689 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
690 @param Handle The handle in the HII database being used
692 @return Returns the number of CHAR16 characters that is support.
697 IN FORM_BROWSER_STATEMENT
*Statement
,
698 IN EFI_HII_HANDLE Handle
702 Concatenate a narrow string to another string.
704 @param Destination The destination string.
705 @param Source The source string. The string to be concatenated.
706 to the end of Destination.
711 IN OUT CHAR16
*Destination
,
716 Wait for a key to be pressed by user.
718 @param Key The key which is pressed by user.
720 @retval EFI_SUCCESS The function always completed successfully.
725 OUT EFI_INPUT_KEY
*Key
729 Reset stack pointer to begin of the stack.
738 Push an Operand onto the Stack
740 @param Operand Operand to push.
742 @retval EFI_SUCCESS The value was pushed onto the stack.
743 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
753 Pop an Operand from the Stack
755 @param Operand Operand to pop.
757 @retval EFI_SUCCESS The value was pushed onto the stack.
758 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
768 Reset stack pointer to begin of the stack.
772 ResetCurrentExpressionStack (
777 Push current expression onto the Stack
779 @param Pointer Pointer to current expression.
781 @retval EFI_SUCCESS The value was pushed onto the stack.
782 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
786 PushCurrentExpression (
791 Pop current expression from the Stack
793 @param Pointer Pointer to current expression to be pop.
795 @retval EFI_SUCCESS The value was pushed onto the stack.
796 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
800 PopCurrentExpression (
805 Reset stack pointer to begin of the stack.
809 ResetMapExpressionListStack (
814 Push the list of map expression onto the Stack
816 @param Pointer Pointer to the list of map expression to be pushed.
818 @retval EFI_SUCCESS The value was pushed onto the stack.
819 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
823 PushMapExpressionList (
828 Pop the list of map expression from the Stack
830 @param Pointer Pointer to the list of map expression to be pop.
832 @retval EFI_SUCCESS The value was pushed onto the stack.
833 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
837 PopMapExpressionList (
842 Get Form given its FormId.
844 @param FormSet The formset which contains this form.
845 @param FormId Id of this form.
847 @retval Pointer The form.
848 @retval NULL Specified Form is not found in the formset.
853 IN FORM_BROWSER_FORMSET
*FormSet
,
858 Search a Question in Formset scope using its QuestionId.
860 @param FormSet The formset which contains this form.
861 @param Form The form which contains this Question.
862 @param QuestionId Id of this Question.
864 @retval Pointer The Question.
865 @retval NULL Specified Question not found in the form.
868 FORM_BROWSER_STATEMENT
*
870 IN FORM_BROWSER_FORMSET
*FormSet
,
871 IN FORM_BROWSER_FORM
*Form
,
876 Zero extend integer/boolean/date/time to UINT64 for comparing.
878 @param Value HII Value to be converted.
883 IN EFI_HII_VALUE
*Value
887 Compare two Hii value.
889 @param Value1 Expression value to compare on left-hand.
890 @param Value2 Expression value to compare on right-hand.
891 @param HiiHandle Only required for string compare.
893 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
894 @retval 0 Two operators equeal.
895 @return Positive value if Value1 is greater than Value2.
896 @retval Negative value if Value1 is less than Value2.
901 IN EFI_HII_VALUE
*Value1
,
902 IN EFI_HII_VALUE
*Value2
,
903 IN EFI_HII_HANDLE HiiHandle OPTIONAL
907 Evaluate the result of a HII expression
909 If Expression is NULL, then ASSERT.
911 @param FormSet FormSet associated with this expression.
912 @param Form Form associated with this expression.
913 @param Expression Expression to be evaluated.
915 @retval EFI_SUCCESS The expression evaluated successfuly
916 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
918 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
920 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
921 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
926 IN FORM_BROWSER_FORMSET
*FormSet
,
927 IN FORM_BROWSER_FORM
*Form
,
928 IN OUT FORM_EXPRESSION
*Expression