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
48 } UI_SCREEN_OPERATION
;
74 #define UI_ACTION_NONE 0
75 #define UI_ACTION_REFRESH_FORM 1
76 #define UI_ACTION_REFRESH_FORMSET 2
77 #define UI_ACTION_EXIT 3
79 typedef struct _UI_MENU_LIST UI_MENU_LIST
;
82 EFI_HII_HANDLE Handle
;
85 // Target formset/form/Question information
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
;
167 UI_MENU_LIST
*Parent
;
168 LIST_ENTRY ChildListHead
;
171 #define UI_MENU_LIST_FROM_LINK(a) CR (a, UI_MENU_LIST, Link, UI_MENU_LIST_SIGNATURE)
173 typedef struct _MENU_REFRESH_ENTRY MENU_REFRESH_ENTRY
;
174 struct _MENU_REFRESH_ENTRY
{
175 MENU_REFRESH_ENTRY
*Next
;
176 UI_MENU_OPTION
*MenuOption
; // Describes the entry needing an update
177 UI_MENU_SELECTION
*Selection
;
180 UINTN CurrentAttribute
;
186 UI_SCREEN_OPERATION ScreenOperation
;
187 } SCAN_CODE_TO_SCREEN_OPERATION
;
190 UI_SCREEN_OPERATION ScreenOperation
;
191 UI_CONTROL_FLAG ControlFlag
;
192 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
195 extern LIST_ENTRY gMenuOption
;
196 extern MENU_REFRESH_ENTRY
*gMenuRefreshHead
;
197 extern UI_MENU_SELECTION
*gCurrentSelection
;
198 extern BOOLEAN mHiiPackageListUpdated
;
204 Initialize Menu option list.
213 Initialize Menu option list.
222 Free Menu option linked list.
231 Create a menu with specified formset GUID and form ID, and add it as a child
232 of the given parent menu.
234 @param Parent The parent of menu to be added.
235 @param FormSetGuid The Formset Guid of menu to be added.
236 @param FormId The Form ID of menu to be added.
238 @return A pointer to the newly added menu or NULL if memory is insufficient.
243 IN OUT UI_MENU_LIST
*Parent
,
244 IN EFI_GUID
*FormSetGuid
,
249 Search Menu with given FormId in the parent menu and all its child menus.
251 @param Parent The parent of menu to search.
252 @param FormId The Form ID of menu to search.
254 @return A pointer to menu found or NULL if not found.
258 UiFindChildMenuList (
259 IN UI_MENU_LIST
*Parent
,
264 Search Menu with given FormSetGuid and FormId in all cached menu list.
266 @param FormSetGuid The Formset GUID of the menu to search.
267 @param FormId The Form ID of menu to search.
269 @return A pointer to menu found or NULL if not found.
274 IN EFI_GUID
*FormSetGuid
,
279 Free Menu option linked list.
288 Add one menu option by specified description and context.
290 @param String String description for this option.
291 @param Handle Hii handle for the package list.
292 @param Statement Statement of this Menu Option.
293 @param NumberOfLines Display lines for this Menu Option.
294 @param MenuItemCount The index for this Option in the Menu.
296 @retval Pointer Pointer to the added Menu Option.
302 IN EFI_HII_HANDLE Handle
,
303 IN FORM_BROWSER_STATEMENT
*Statement
,
304 IN UINT16 NumberOfLines
,
305 IN UINT16 MenuItemCount
309 Display menu and wait for user to select one menu option, then return it.
310 If AutoBoot is enabled, then if user doesn't select any option,
311 after period of time, it will automatically return the first menu option.
313 @param Selection Menu selection.
315 @return Return the pointer of the menu which selected,
316 @return otherwise return NULL.
321 IN OUT UI_MENU_SELECTION
*Selection
325 Free up the resource allocated for all strings required
335 The worker function that send the displays to the screen. On output,
336 the selection made by user is returned.
338 @param Selection On input, Selection tell setup browser the information
339 about the Selection, form and formset to be displayed.
340 On output, Selection return the screen item that is selected
343 @retval EFI_SUCCESS The page is displayed successfully.
344 @return Other value if the page failed to be diplayed.
349 IN OUT UI_MENU_SELECTION
*Selection
353 Set Buffer to Value for Size bytes.
355 @param Buffer Memory to set.
356 @param Size Number of bytes to set
357 @param Value Value of the set operation.
368 Wait for a given event to fire, or for an optional timeout to expire.
370 @param Event The event to wait for
371 @param Timeout An optional timeout value in 100 ns units.
372 @param RefreshInterval Menu refresh interval (in seconds).
374 @retval EFI_SUCCESS Event fired before Timeout expired.
375 @retval EFI_TIME_OUT Timout expired before Event fired.
379 UiWaitForSingleEvent (
381 IN UINT64 Timeout
, OPTIONAL
382 IN UINT8 RefreshInterval OPTIONAL
386 Draw a pop up windows based on the dimension, number of lines and
389 @param ScreenWidth The width of the pop-up.
390 @param NumberOfLines The number of lines.
391 @param ... A series of text strings that displayed in the pop-up.
396 CreateMultiStringPopUp (
397 IN UINTN ScreenWidth
,
398 IN UINTN NumberOfLines
,
403 Get string or password input from user.
405 @param MenuOption Pointer to the current input menu.
406 @param Prompt The prompt string shown on popup window.
407 @param StringPtr Destination for use input string.
409 @retval EFI_SUCCESS If string input is read successfully
410 @retval EFI_DEVICE_ERROR If operation fails
415 IN UI_MENU_OPTION
*MenuOption
,
417 OUT CHAR16
*StringPtr
421 Get selection for OneOf and OrderedList (Left/Right will be ignored).
423 @param Selection Pointer to current selection.
424 @param MenuOption Pointer to the current input menu.
426 @retval EFI_SUCCESS If Option input is processed successfully
427 @retval EFI_DEVICE_ERROR If operation fails
431 GetSelectionInputPopUp (
432 IN UI_MENU_SELECTION
*Selection
,
433 IN UI_MENU_OPTION
*MenuOption
437 This routine reads a numeric value from the user input.
439 @param Selection Pointer to current selection.
440 @param MenuOption Pointer to the current input menu.
442 @retval EFI_SUCCESS If numerical input is read successfully
443 @retval EFI_DEVICE_ERROR If operation fails
448 IN UI_MENU_SELECTION
*Selection
,
449 IN UI_MENU_OPTION
*MenuOption
453 Update status bar on the bottom of menu.
455 @param Selection Current selection info.
456 @param MessageType The type of message to be shown.
457 @param Flags The flags in Question header.
458 @param State Set or clear.
463 IN UI_MENU_SELECTION
*Selection
,
464 IN UINTN MessageType
,
470 Process Question Config.
472 @param Selection The UI menu selection.
473 @param Question The Question to be peocessed.
475 @retval EFI_SUCCESS Question Config process success.
476 @retval Other Question Config process fail.
480 ProcessQuestionConfig (
481 IN UI_MENU_SELECTION
*Selection
,
482 IN FORM_BROWSER_STATEMENT
*Question
486 Print Question Value according to it's storage width and display attributes.
488 @param Question The Question to be printed.
489 @param FormattedNumber Buffer for output string.
490 @param BufferSize The FormattedNumber buffer size in bytes.
492 @retval EFI_SUCCESS Print success.
493 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
497 PrintFormattedNumber (
498 IN FORM_BROWSER_STATEMENT
*Question
,
499 IN OUT CHAR16
*FormattedNumber
,
504 Search an Option of a Question by its value.
506 @param Question The Question
507 @param OptionValue Value for Option to be searched.
509 @retval Pointer Pointer to the found Option.
510 @retval NULL Option not found.
515 IN FORM_BROWSER_STATEMENT
*Question
,
516 IN EFI_HII_VALUE
*OptionValue
520 Return data element in an Array by its Index.
522 @param Array The data array.
523 @param Type Type of the data in this array.
524 @param Index Zero based index for data in this array.
526 @retval Value The data to be returned
537 Set value of a data element in an Array by its Index.
539 @param Array The data array.
540 @param Type Type of the data in this array.
541 @param Index Zero based index for data in this array.
542 @param Value The value to be set.
554 Process a Question's Option (whether selected or un-selected).
556 @param Selection Pointer to UI_MENU_SELECTION.
557 @param MenuOption The MenuOption for this Question.
558 @param Selected TRUE: if Question is selected.
559 @param OptionString Pointer of the Option String to be displayed.
561 @retval EFI_SUCCESS Question Option process success.
562 @retval Other Question Option process fail.
567 IN UI_MENU_SELECTION
*Selection
,
568 IN UI_MENU_OPTION
*MenuOption
,
570 OUT CHAR16
**OptionString
574 Process the help string: Split StringPtr to several lines of strings stored in
575 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
577 @param StringPtr The entire help string.
578 @param FormattedString The oupput formatted string.
579 @param RowCount TRUE: if Question is selected.
584 IN CHAR16
*StringPtr
,
585 OUT CHAR16
**FormattedString
,
590 Update key's help imformation.
592 @param Selection Tell setup browser the information about the Selection
593 @param MenuOption The Menu option
594 @param Selected Whether or not a tag be selected
599 IN UI_MENU_SELECTION
*Selection
,
600 IN UI_MENU_OPTION
*MenuOption
,
605 Clear retangle with specified text attribute.
607 @param LeftColumn Left column of retangle.
608 @param RightColumn Right column of retangle.
609 @param TopRow Start row of retangle.
610 @param BottomRow End row of retangle.
611 @param TextAttribute The character foreground and background.
617 IN UINTN RightColumn
,
620 IN UINTN TextAttribute
624 Count the storage space of a Unicode string.
626 This function handles the Unicode string with NARROW_CHAR
627 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
628 does not count in the resultant output. If a WIDE_CHAR is
629 hit, then 2 Unicode character will consume an output storage
630 space with size of CHAR16 till a NARROW_CHAR is hit.
632 If String is NULL, then ASSERT ().
634 @param String The input string to be counted.
636 @return Storage space for the input string.
645 Will copy LineWidth amount of a string in the OutputString buffer and return the
646 number of CHAR16 characters that were copied into the OutputString buffer.
648 @param InputString String description for this option.
649 @param LineWidth Width of the desired string to extract in CHAR16
651 @param Index Where in InputString to start the copy process
652 @param OutputString Buffer to copy the string into
654 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
659 IN CHAR16
*InputString
,
662 OUT CHAR16
**OutputString
666 Get the supported width for a particular op-code
668 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
669 @param Handle The handle in the HII database being used
671 @return Returns the number of CHAR16 characters that is support.
676 IN FORM_BROWSER_STATEMENT
*Statement
,
677 IN EFI_HII_HANDLE Handle
681 Concatenate a narrow string to another string.
683 @param Destination The destination string.
684 @param Source The source string. The string to be concatenated.
685 to the end of Destination.
690 IN OUT CHAR16
*Destination
,
695 Wait for a key to be pressed by user.
697 @param Key The key which is pressed by user.
699 @retval EFI_SUCCESS The function always completed successfully.
704 OUT EFI_INPUT_KEY
*Key
708 Reset stack pointer to begin of the stack.
717 Push an Operand onto the Stack
719 @param Operand Operand to push.
721 @retval EFI_SUCCESS The value was pushed onto the stack.
722 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
732 Pop an Operand from the Stack
734 @param Operand Operand to pop.
736 @retval EFI_SUCCESS The value was pushed onto the stack.
737 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
747 Reset stack pointer to begin of the stack.
751 ResetCurrentExpressionStack (
756 Push current expression onto the Stack
758 @param Pointer Pointer to current expression.
760 @retval EFI_SUCCESS The value was pushed onto the stack.
761 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
765 PushCurrentExpression (
770 Pop current expression from the Stack
772 @param Pointer Pointer to current expression to be pop.
774 @retval EFI_SUCCESS The value was pushed onto the stack.
775 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
779 PopCurrentExpression (
784 Reset stack pointer to begin of the stack.
788 ResetMapExpressionListStack (
793 Push the list of map expression onto the Stack
795 @param Pointer Pointer to the list of map expression to be pushed.
797 @retval EFI_SUCCESS The value was pushed onto the stack.
798 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
802 PushMapExpressionList (
807 Pop the list of map expression from the Stack
809 @param Pointer Pointer to the list of map expression to be pop.
811 @retval EFI_SUCCESS The value was pushed onto the stack.
812 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
816 PopMapExpressionList (
821 Get Form given its FormId.
823 @param FormSet The formset which contains this form.
824 @param FormId Id of this form.
826 @retval Pointer The form.
827 @retval NULL Specified Form is not found in the formset.
832 IN FORM_BROWSER_FORMSET
*FormSet
,
837 Search a Question in Formset scope using its QuestionId.
839 @param FormSet The formset which contains this form.
840 @param Form The form which contains this Question.
841 @param QuestionId Id of this Question.
843 @retval Pointer The Question.
844 @retval NULL Specified Question not found in the form.
847 FORM_BROWSER_STATEMENT
*
849 IN FORM_BROWSER_FORMSET
*FormSet
,
850 IN FORM_BROWSER_FORM
*Form
,
855 Zero extend integer/boolean/date/time to UINT64 for comparing.
857 @param Value HII Value to be converted.
862 IN EFI_HII_VALUE
*Value
866 Compare two Hii value.
868 @param Value1 Expression value to compare on left-hand.
869 @param Value2 Expression value to compare on right-hand.
870 @param HiiHandle Only required for string compare.
872 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
873 @retval 0 Two operators equeal.
874 @return Positive value if Value1 is greater than Value2.
875 @retval Negative value if Value1 is less than Value2.
880 IN EFI_HII_VALUE
*Value1
,
881 IN EFI_HII_VALUE
*Value2
,
882 IN EFI_HII_HANDLE HiiHandle OPTIONAL
886 Evaluate the result of a HII expression
888 If Expression is NULL, then ASSERT.
890 @param FormSet FormSet associated with this expression.
891 @param Form Form associated with this expression.
892 @param Expression Expression to be evaluated.
894 @retval EFI_SUCCESS The expression evaluated successfuly
895 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
897 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
899 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
900 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
905 IN FORM_BROWSER_FORMSET
*FormSet
,
906 IN FORM_BROWSER_FORM
*Form
,
907 IN OUT FORM_EXPRESSION
*Expression