2 Private structure, MACRO and function definitions for User Interface related functionalities.
4 Copyright (c) 2004 - 2010, 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
80 EFI_HII_HANDLE Handle
;
83 // Target formset/form/Question information
96 // Ation for Browser to taken:
97 // UI_ACTION_NONE - navigation inside a form
98 // UI_ACTION_REFRESH_FORM - re-evaluate expressions and repaint form
99 // UI_ACTION_REFRESH_FORMSET - re-parse formset IFR binary
104 // Current selected fomset/form/Question
106 FORM_BROWSER_FORMSET
*FormSet
;
107 FORM_BROWSER_FORM
*Form
;
108 FORM_BROWSER_STATEMENT
*Statement
;
111 // Whether the Form is editable
113 BOOLEAN FormEditable
;
116 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
117 #define UI_MENU_LIST_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'l')
123 EFI_HII_HANDLE Handle
;
124 FORM_BROWSER_STATEMENT
*ThisTag
;
131 UINTN Skip
; // Number of lines
134 // Display item sequence for date/time
135 // Date: Month/Day/Year
138 // Time: Hour : Minute : Second
148 // Whether user could change value of this item
153 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
155 typedef struct _UI_MENU_LIST UI_MENU_LIST
;
157 struct _UI_MENU_LIST
{
161 EFI_GUID FormSetGuid
;
165 UI_MENU_LIST
*Parent
;
166 LIST_ENTRY ChildListHead
;
169 #define UI_MENU_LIST_FROM_LINK(a) CR (a, UI_MENU_LIST, Link, UI_MENU_LIST_SIGNATURE)
171 typedef struct _MENU_REFRESH_ENTRY MENU_REFRESH_ENTRY
;
172 struct _MENU_REFRESH_ENTRY
{
173 MENU_REFRESH_ENTRY
*Next
;
174 UI_MENU_OPTION
*MenuOption
; // Describes the entry needing an update
175 UI_MENU_SELECTION
*Selection
;
178 UINTN CurrentAttribute
;
183 UI_SCREEN_OPERATION ScreenOperation
;
184 } SCAN_CODE_TO_SCREEN_OPERATION
;
187 UI_SCREEN_OPERATION ScreenOperation
;
188 UI_CONTROL_FLAG ControlFlag
;
189 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
192 extern LIST_ENTRY gMenuOption
;
193 extern MENU_REFRESH_ENTRY
*gMenuRefreshHead
;
194 extern UI_MENU_SELECTION
*gCurrentSelection
;
195 extern BOOLEAN mHiiPackageListUpdated
;
201 Initialize Menu option list.
210 Initialize Menu option list.
219 Free Menu option linked list.
228 Create a menu with specified formset GUID and form ID, and add it as a child
229 of the given parent menu.
231 @param Parent The parent of menu to be added.
232 @param FormSetGuid The Formset Guid of menu to be added.
233 @param FormId The Form ID of menu to be added.
235 @return A pointer to the newly added menu or NULL if memory is insufficient.
240 IN OUT UI_MENU_LIST
*Parent
,
241 IN EFI_GUID
*FormSetGuid
,
246 Search Menu with given FormId in the parent menu and all its child menus.
248 @param Parent The parent of menu to search.
249 @param FormId The Form ID of menu to search.
251 @return A pointer to menu found or NULL if not found.
255 UiFindChildMenuList (
256 IN UI_MENU_LIST
*Parent
,
261 Search Menu with given FormSetGuid and FormId in all cached menu list.
263 @param FormSetGuid The Formset GUID of the menu to search.
264 @param FormId The Form ID of menu to search.
266 @return A pointer to menu found or NULL if not found.
271 IN EFI_GUID
*FormSetGuid
,
276 Free Menu option linked list.
285 Add one menu option by specified description and context.
287 @param String String description for this option.
288 @param Handle Hii handle for the package list.
289 @param Statement Statement of this Menu Option.
290 @param NumberOfLines Display lines for this Menu Option.
291 @param MenuItemCount The index for this Option in the Menu.
293 @retval Pointer Pointer to the added Menu Option.
299 IN EFI_HII_HANDLE Handle
,
300 IN FORM_BROWSER_STATEMENT
*Statement
,
301 IN UINT16 NumberOfLines
,
302 IN UINT16 MenuItemCount
306 Display menu and wait for user to select one menu option, then return it.
307 If AutoBoot is enabled, then if user doesn't select any option,
308 after period of time, it will automatically return the first menu option.
310 @param Selection Menu selection.
312 @return Return the pointer of the menu which selected,
313 @return otherwise return NULL.
318 IN OUT UI_MENU_SELECTION
*Selection
322 Free up the resource allocated for all strings required
332 The worker function that send the displays to the screen. On output,
333 the selection made by user is returned.
335 @param Selection On input, Selection tell setup browser the information
336 about the Selection, form and formset to be displayed.
337 On output, Selection return the screen item that is selected
340 @retval EFI_SUCCESS The page is displayed successfully.
341 @return Other value if the page failed to be diplayed.
346 IN OUT UI_MENU_SELECTION
*Selection
350 Set Buffer to Value for Size bytes.
352 @param Buffer Memory to set.
353 @param Size Number of bytes to set
354 @param Value Value of the set operation.
365 Wait for a given event to fire, or for an optional timeout to expire.
367 @param Event The event to wait for
368 @param Timeout An optional timeout value in 100 ns units.
369 @param RefreshInterval Menu refresh interval (in seconds).
371 @retval EFI_SUCCESS Event fired before Timeout expired.
372 @retval EFI_TIME_OUT Timout expired before Event fired.
376 UiWaitForSingleEvent (
378 IN UINT64 Timeout
, OPTIONAL
379 IN UINT8 RefreshInterval OPTIONAL
383 Draw a pop up windows based on the dimension, number of lines and
386 @param ScreenWidth The width of the pop-up.
387 @param NumberOfLines The number of lines.
388 @param ... A series of text strings that displayed in the pop-up.
393 CreateMultiStringPopUp (
394 IN UINTN ScreenWidth
,
395 IN UINTN NumberOfLines
,
400 Get string or password input from user.
402 @param MenuOption Pointer to the current input menu.
403 @param Prompt The prompt string shown on popup window.
404 @param StringPtr Destination for use input string.
406 @retval EFI_SUCCESS If string input is read successfully
407 @retval EFI_DEVICE_ERROR If operation fails
412 IN UI_MENU_OPTION
*MenuOption
,
414 OUT CHAR16
*StringPtr
418 Get selection for OneOf and OrderedList (Left/Right will be ignored).
420 @param Selection Pointer to current selection.
421 @param MenuOption Pointer to the current input menu.
423 @retval EFI_SUCCESS If Option input is processed successfully
424 @retval EFI_DEVICE_ERROR If operation fails
428 GetSelectionInputPopUp (
429 IN UI_MENU_SELECTION
*Selection
,
430 IN UI_MENU_OPTION
*MenuOption
434 This routine reads a numeric value from the user input.
436 @param Selection Pointer to current selection.
437 @param MenuOption Pointer to the current input menu.
439 @retval EFI_SUCCESS If numerical input is read successfully
440 @retval EFI_DEVICE_ERROR If operation fails
445 IN UI_MENU_SELECTION
*Selection
,
446 IN UI_MENU_OPTION
*MenuOption
450 Update status bar on the bottom of menu.
452 @param MessageType The type of message to be shown.
453 @param Flags The flags in Question header.
454 @param State Set or clear.
459 IN UINTN MessageType
,
465 Process Question Config.
467 @param Selection The UI menu selection.
468 @param Question The Question to be peocessed.
470 @retval EFI_SUCCESS Question Config process success.
471 @retval Other Question Config process fail.
475 ProcessQuestionConfig (
476 IN UI_MENU_SELECTION
*Selection
,
477 IN FORM_BROWSER_STATEMENT
*Question
481 Print Question Value according to it's storage width and display attributes.
483 @param Question The Question to be printed.
484 @param FormattedNumber Buffer for output string.
485 @param BufferSize The FormattedNumber buffer size in bytes.
487 @retval EFI_SUCCESS Print success.
488 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
492 PrintFormattedNumber (
493 IN FORM_BROWSER_STATEMENT
*Question
,
494 IN OUT CHAR16
*FormattedNumber
,
499 Search an Option of a Question by its value.
501 @param Question The Question
502 @param OptionValue Value for Option to be searched.
504 @retval Pointer Pointer to the found Option.
505 @retval NULL Option not found.
510 IN FORM_BROWSER_STATEMENT
*Question
,
511 IN EFI_HII_VALUE
*OptionValue
515 Return data element in an Array by its Index.
517 @param Array The data array.
518 @param Type Type of the data in this array.
519 @param Index Zero based index for data in this array.
521 @retval Value The data to be returned
532 Set value of a data element in an Array by its Index.
534 @param Array The data array.
535 @param Type Type of the data in this array.
536 @param Index Zero based index for data in this array.
537 @param Value The value to be set.
549 Process a Question's Option (whether selected or un-selected).
551 @param Selection Pointer to UI_MENU_SELECTION.
552 @param MenuOption The MenuOption for this Question.
553 @param Selected TRUE: if Question is selected.
554 @param OptionString Pointer of the Option String to be displayed.
556 @retval EFI_SUCCESS Question Option process success.
557 @retval Other Question Option process fail.
562 IN UI_MENU_SELECTION
*Selection
,
563 IN UI_MENU_OPTION
*MenuOption
,
565 OUT CHAR16
**OptionString
569 Process the help string: Split StringPtr to several lines of strings stored in
570 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
572 @param StringPtr The entire help string.
573 @param FormattedString The oupput formatted string.
574 @param RowCount TRUE: if Question is selected.
579 IN CHAR16
*StringPtr
,
580 OUT CHAR16
**FormattedString
,
585 Update key's help imformation.
587 @param Selection Tell setup browser the information about the Selection
588 @param MenuOption The Menu option
589 @param Selected Whether or not a tag be selected
594 IN UI_MENU_SELECTION
*Selection
,
595 IN UI_MENU_OPTION
*MenuOption
,
600 Clear retangle with specified text attribute.
602 @param LeftColumn Left column of retangle.
603 @param RightColumn Right column of retangle.
604 @param TopRow Start row of retangle.
605 @param BottomRow End row of retangle.
606 @param TextAttribute The character foreground and background.
612 IN UINTN RightColumn
,
615 IN UINTN TextAttribute
619 Count the storage space of a Unicode string.
621 This function handles the Unicode string with NARROW_CHAR
622 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
623 does not count in the resultant output. If a WIDE_CHAR is
624 hit, then 2 Unicode character will consume an output storage
625 space with size of CHAR16 till a NARROW_CHAR is hit.
627 If String is NULL, then ASSERT ().
629 @param String The input string to be counted.
631 @return Storage space for the input string.
640 Will copy LineWidth amount of a string in the OutputString buffer and return the
641 number of CHAR16 characters that were copied into the OutputString buffer.
643 @param InputString String description for this option.
644 @param LineWidth Width of the desired string to extract in CHAR16
646 @param Index Where in InputString to start the copy process
647 @param OutputString Buffer to copy the string into
649 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
654 IN CHAR16
*InputString
,
657 OUT CHAR16
**OutputString
661 Get the supported width for a particular op-code
663 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
664 @param Handle The handle in the HII database being used
666 @return Returns the number of CHAR16 characters that is support.
671 IN FORM_BROWSER_STATEMENT
*Statement
,
672 IN EFI_HII_HANDLE Handle
676 Concatenate a narrow string to another string.
678 @param Destination The destination string.
679 @param Source The source string. The string to be concatenated.
680 to the end of Destination.
685 IN OUT CHAR16
*Destination
,
690 Wait for a key to be pressed by user.
692 @param Key The key which is pressed by user.
694 @retval EFI_SUCCESS The function always completed successfully.
699 OUT EFI_INPUT_KEY
*Key
703 Reset stack pointer to begin of the stack.
712 Push an Operand onto the Stack
714 @param Operand Operand to push.
716 @retval EFI_SUCCESS The value was pushed onto the stack.
717 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
727 Pop an Operand from the Stack
729 @param Operand Operand to pop.
731 @retval EFI_SUCCESS The value was pushed onto the stack.
732 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
742 Reset stack pointer to begin of the stack.
746 ResetCurrentExpressionStack (
751 Push current expression onto the Stack
753 @param Pointer Pointer to current expression.
755 @retval EFI_SUCCESS The value was pushed onto the stack.
756 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
760 PushCurrentExpression (
765 Pop current expression from the Stack
767 @param Pointer Pointer to current expression to be pop.
769 @retval EFI_SUCCESS The value was pushed onto the stack.
770 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
774 PopCurrentExpression (
779 Reset stack pointer to begin of the stack.
783 ResetMapExpressionListStack (
788 Push the list of map expression onto the Stack
790 @param Pointer Pointer to the list of map expression to be pushed.
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 PushMapExpressionList (
802 Pop the list of map expression from the Stack
804 @param Pointer Pointer to the list of map expression to be pop.
806 @retval EFI_SUCCESS The value was pushed onto the stack.
807 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
811 PopMapExpressionList (
816 Get Form given its FormId.
818 @param FormSet The formset which contains this form.
819 @param FormId Id of this form.
821 @retval Pointer The form.
822 @retval NULL Specified Form is not found in the formset.
827 IN FORM_BROWSER_FORMSET
*FormSet
,
832 Search a Question in Formset scope using its QuestionId.
834 @param FormSet The formset which contains this form.
835 @param Form The form which contains this Question.
836 @param QuestionId Id of this Question.
838 @retval Pointer The Question.
839 @retval NULL Specified Question not found in the form.
842 FORM_BROWSER_STATEMENT
*
844 IN FORM_BROWSER_FORMSET
*FormSet
,
845 IN FORM_BROWSER_FORM
*Form
,
850 Zero extend integer/boolean/date/time to UINT64 for comparing.
852 @param Value HII Value to be converted.
857 IN EFI_HII_VALUE
*Value
861 Compare two Hii value.
863 @param Value1 Expression value to compare on left-hand.
864 @param Value2 Expression value to compare on right-hand.
865 @param HiiHandle Only required for string compare.
867 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
868 @retval 0 Two operators equeal.
869 @return Positive value if Value1 is greater than Value2.
870 @retval Negative value if Value1 is less than Value2.
875 IN EFI_HII_VALUE
*Value1
,
876 IN EFI_HII_VALUE
*Value2
,
877 IN EFI_HII_HANDLE HiiHandle OPTIONAL
881 Evaluate the result of a HII expression
883 If Expression is NULL, then ASSERT.
885 @param FormSet FormSet associated with this expression.
886 @param Form Form associated with this expression.
887 @param Expression Expression to be evaluated.
889 @retval EFI_SUCCESS The expression evaluated successfuly
890 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
892 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
894 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
895 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
900 IN FORM_BROWSER_FORMSET
*FormSet
,
901 IN FORM_BROWSER_FORM
*Form
,
902 IN OUT FORM_EXPRESSION
*Expression