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
90 UINTN Sequence
; // used for time/date only.
99 // Ation for Browser to taken:
100 // UI_ACTION_NONE - navigation inside a form
101 // UI_ACTION_REFRESH_FORM - re-evaluate expressions and repaint form
102 // UI_ACTION_REFRESH_FORMSET - re-parse formset IFR binary
107 // Current selected fomset/form/Question
109 FORM_BROWSER_FORMSET
*FormSet
;
110 FORM_BROWSER_FORM
*Form
;
111 FORM_BROWSER_STATEMENT
*Statement
;
114 // Whether the Form is editable
116 BOOLEAN FormEditable
;
118 UI_MENU_LIST
*CurrentMenu
;
121 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
122 #define UI_MENU_LIST_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'l')
128 EFI_HII_HANDLE Handle
;
129 FORM_BROWSER_STATEMENT
*ThisTag
;
136 UINTN Skip
; // Number of lines
139 // Display item sequence for date/time
140 // Date: Month/Day/Year
143 // Time: Hour : Minute : Second
153 // Whether user could change value of this item
158 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
160 struct _UI_MENU_LIST
{
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 MENU_REFRESH_ENTRY
*gMenuRefreshHead
;
199 extern UI_MENU_SELECTION
*gCurrentSelection
;
200 extern BOOLEAN mHiiPackageListUpdated
;
206 Initialize Menu option list.
215 Initialize Menu option list.
224 Free Menu option linked list.
233 Create a menu with specified formset GUID and form ID, and add it as a child
234 of the given parent menu.
236 @param Parent The parent of menu to be added.
237 @param FormSetGuid The Formset Guid of menu to be added.
238 @param FormId The Form ID of menu to be added.
240 @return A pointer to the newly added menu or NULL if memory is insufficient.
245 IN OUT UI_MENU_LIST
*Parent
,
246 IN EFI_GUID
*FormSetGuid
,
251 Search Menu with given FormId in the parent menu and all its child menus.
253 @param Parent The parent of menu to search.
254 @param FormId The Form ID of menu to search.
256 @return A pointer to menu found or NULL if not found.
260 UiFindChildMenuList (
261 IN UI_MENU_LIST
*Parent
,
266 Search Menu with given FormSetGuid and FormId in all cached menu list.
268 @param FormSetGuid The Formset GUID of the menu to search.
269 @param FormId The Form ID of menu to search.
271 @return A pointer to menu found or NULL if not found.
276 IN EFI_GUID
*FormSetGuid
,
281 Free Menu option linked list.
290 Add one menu option by specified description and context.
292 @param String String description for this option.
293 @param Handle Hii handle for the package list.
294 @param Statement Statement of this Menu Option.
295 @param NumberOfLines Display lines for this Menu Option.
296 @param MenuItemCount The index for this Option in the Menu.
298 @retval Pointer Pointer to the added Menu Option.
304 IN EFI_HII_HANDLE Handle
,
305 IN FORM_BROWSER_STATEMENT
*Statement
,
306 IN UINT16 NumberOfLines
,
307 IN UINT16 MenuItemCount
311 Display menu and wait for user to select one menu option, then return it.
312 If AutoBoot is enabled, then if user doesn't select any option,
313 after period of time, it will automatically return the first menu option.
315 @param Selection Menu selection.
317 @return Return the pointer of the menu which selected,
318 @return otherwise return NULL.
323 IN OUT UI_MENU_SELECTION
*Selection
327 Free up the resource allocated for all strings required
337 Process the goto op code, update the info in the selection structure.
339 @param Statement The statement belong to goto op code.
340 @param Selection The selection info.
341 @param Repaint Whether need to repaint the menu.
342 @param NewLine Whether need to create new line.
344 @retval EFI_SUCCESS The menu process successfully.
345 @return Other value if the process failed.
349 IN OUT FORM_BROWSER_STATEMENT
*Statement
,
350 IN OUT UI_MENU_SELECTION
*Selection
,
351 OUT BOOLEAN
*Repaint
,
357 The worker function that send the displays to the screen. On output,
358 the selection made by user is returned.
360 @param Selection On input, Selection tell setup browser the information
361 about the Selection, form and formset to be displayed.
362 On output, Selection return the screen item that is selected
365 @retval EFI_SUCCESS The page is displayed successfully.
366 @return Other value if the page failed to be diplayed.
371 IN OUT UI_MENU_SELECTION
*Selection
375 Set Buffer to Value for Size bytes.
377 @param Buffer Memory to set.
378 @param Size Number of bytes to set
379 @param Value Value of the set operation.
390 Wait for a given event to fire, or for an optional timeout to expire.
392 @param Event The event to wait for
393 @param Timeout An optional timeout value in 100 ns units.
394 @param RefreshInterval Menu refresh interval (in seconds).
396 @retval EFI_SUCCESS Event fired before Timeout expired.
397 @retval EFI_TIME_OUT Timout expired before Event fired.
401 UiWaitForSingleEvent (
403 IN UINT64 Timeout
, OPTIONAL
404 IN UINT8 RefreshInterval OPTIONAL
408 Draw a pop up windows based on the dimension, number of lines and
411 @param ScreenWidth The width of the pop-up.
412 @param NumberOfLines The number of lines.
413 @param ... A series of text strings that displayed in the pop-up.
418 CreateMultiStringPopUp (
419 IN UINTN ScreenWidth
,
420 IN UINTN NumberOfLines
,
425 Get string or password input from user.
427 @param MenuOption Pointer to the current input menu.
428 @param Prompt The prompt string shown on popup window.
429 @param StringPtr Old user input and destination for use input string.
431 @retval EFI_SUCCESS If string input is read successfully
432 @retval EFI_DEVICE_ERROR If operation fails
437 IN UI_MENU_OPTION
*MenuOption
,
439 IN OUT CHAR16
*StringPtr
443 Get selection for OneOf and OrderedList (Left/Right will be ignored).
445 @param Selection Pointer to current selection.
446 @param MenuOption Pointer to the current input menu.
448 @retval EFI_SUCCESS If Option input is processed successfully
449 @retval EFI_DEVICE_ERROR If operation fails
453 GetSelectionInputPopUp (
454 IN UI_MENU_SELECTION
*Selection
,
455 IN UI_MENU_OPTION
*MenuOption
459 This routine reads a numeric value from the user input.
461 @param Selection Pointer to current selection.
462 @param MenuOption Pointer to the current input menu.
464 @retval EFI_SUCCESS If numerical input is read successfully
465 @retval EFI_DEVICE_ERROR If operation fails
470 IN UI_MENU_SELECTION
*Selection
,
471 IN UI_MENU_OPTION
*MenuOption
475 Update status bar on the bottom of menu.
477 @param Selection Current selection info.
478 @param MessageType The type of message to be shown.
479 @param Flags The flags in Question header.
480 @param State Set or clear.
485 IN UI_MENU_SELECTION
*Selection
,
486 IN UINTN MessageType
,
492 Process Question Config.
494 @param Selection The UI menu selection.
495 @param Question The Question to be peocessed.
497 @retval EFI_SUCCESS Question Config process success.
498 @retval Other Question Config process fail.
502 ProcessQuestionConfig (
503 IN UI_MENU_SELECTION
*Selection
,
504 IN FORM_BROWSER_STATEMENT
*Question
508 Print Question Value according to it's storage width and display attributes.
510 @param Question The Question to be printed.
511 @param FormattedNumber Buffer for output string.
512 @param BufferSize The FormattedNumber buffer size in bytes.
514 @retval EFI_SUCCESS Print success.
515 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
519 PrintFormattedNumber (
520 IN FORM_BROWSER_STATEMENT
*Question
,
521 IN OUT CHAR16
*FormattedNumber
,
526 Search an Option of a Question by its value.
528 @param Question The Question
529 @param OptionValue Value for Option to be searched.
531 @retval Pointer Pointer to the found Option.
532 @retval NULL Option not found.
537 IN FORM_BROWSER_STATEMENT
*Question
,
538 IN EFI_HII_VALUE
*OptionValue
542 Return data element in an Array by its Index.
544 @param Array The data array.
545 @param Type Type of the data in this array.
546 @param Index Zero based index for data in this array.
548 @retval Value The data to be returned
559 Set value of a data element in an Array by its Index.
561 @param Array The data array.
562 @param Type Type of the data in this array.
563 @param Index Zero based index for data in this array.
564 @param Value The value to be set.
576 Process a Question's Option (whether selected or un-selected).
578 @param Selection Pointer to UI_MENU_SELECTION.
579 @param MenuOption The MenuOption for this Question.
580 @param Selected TRUE: if Question is selected.
581 @param OptionString Pointer of the Option String to be displayed.
583 @retval EFI_SUCCESS Question Option process success.
584 @retval Other Question Option process fail.
589 IN UI_MENU_SELECTION
*Selection
,
590 IN UI_MENU_OPTION
*MenuOption
,
592 OUT CHAR16
**OptionString
596 Process the help string: Split StringPtr to several lines of strings stored in
597 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
599 @param StringPtr The entire help string.
600 @param FormattedString The oupput formatted string.
601 @param RowCount TRUE: if Question is selected.
606 IN CHAR16
*StringPtr
,
607 OUT CHAR16
**FormattedString
,
612 Update key's help imformation.
614 @param Selection Tell setup browser the information about the Selection
615 @param MenuOption The Menu option
616 @param Selected Whether or not a tag be selected
621 IN UI_MENU_SELECTION
*Selection
,
622 IN UI_MENU_OPTION
*MenuOption
,
627 Clear retangle with specified text attribute.
629 @param LeftColumn Left column of retangle.
630 @param RightColumn Right column of retangle.
631 @param TopRow Start row of retangle.
632 @param BottomRow End row of retangle.
633 @param TextAttribute The character foreground and background.
639 IN UINTN RightColumn
,
642 IN UINTN TextAttribute
646 Count the storage space of a Unicode string.
648 This function handles the Unicode string with NARROW_CHAR
649 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
650 does not count in the resultant output. If a WIDE_CHAR is
651 hit, then 2 Unicode character will consume an output storage
652 space with size of CHAR16 till a NARROW_CHAR is hit.
654 If String is NULL, then ASSERT ().
656 @param String The input string to be counted.
658 @return Storage space for the input string.
667 Will copy LineWidth amount of a string in the OutputString buffer and return the
668 number of CHAR16 characters that were copied into the OutputString buffer.
670 @param InputString String description for this option.
671 @param LineWidth Width of the desired string to extract in CHAR16
673 @param Index Where in InputString to start the copy process
674 @param OutputString Buffer to copy the string into
676 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
681 IN CHAR16
*InputString
,
684 OUT CHAR16
**OutputString
688 Get the supported width for a particular op-code
690 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
691 @param Handle The handle in the HII database being used
693 @return Returns the number of CHAR16 characters that is support.
698 IN FORM_BROWSER_STATEMENT
*Statement
,
699 IN EFI_HII_HANDLE Handle
703 Concatenate a narrow string to another string.
705 @param Destination The destination string.
706 @param Source The source string. The string to be concatenated.
707 to the end of Destination.
712 IN OUT CHAR16
*Destination
,
717 Wait for a key to be pressed by user.
719 @param Key The key which is pressed by user.
721 @retval EFI_SUCCESS The function always completed successfully.
726 OUT EFI_INPUT_KEY
*Key
730 Reset stack pointer to begin of the stack.
739 Push an Operand onto the Stack
741 @param Operand Operand to push.
743 @retval EFI_SUCCESS The value was pushed onto the stack.
744 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
754 Pop an Operand from the Stack
756 @param Operand Operand to pop.
758 @retval EFI_SUCCESS The value was pushed onto the stack.
759 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
769 Reset stack pointer to begin of the stack.
773 ResetCurrentExpressionStack (
778 Push current expression onto the Stack
780 @param Pointer Pointer to current expression.
782 @retval EFI_SUCCESS The value was pushed onto the stack.
783 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
787 PushCurrentExpression (
792 Pop current expression from the Stack
794 @param Pointer Pointer to current expression to be pop.
796 @retval EFI_SUCCESS The value was pushed onto the stack.
797 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
801 PopCurrentExpression (
806 Reset stack pointer to begin of the stack.
810 ResetMapExpressionListStack (
815 Push the list of map expression onto the Stack
817 @param Pointer Pointer to the list of map expression to be pushed.
819 @retval EFI_SUCCESS The value was pushed onto the stack.
820 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
824 PushMapExpressionList (
829 Pop the list of map expression from the Stack
831 @param Pointer Pointer to the list of map expression to be pop.
833 @retval EFI_SUCCESS The value was pushed onto the stack.
834 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
838 PopMapExpressionList (
843 Get Form given its FormId.
845 @param FormSet The formset which contains this form.
846 @param FormId Id of this form.
848 @retval Pointer The form.
849 @retval NULL Specified Form is not found in the formset.
854 IN FORM_BROWSER_FORMSET
*FormSet
,
859 Search a Question in Formset scope using its QuestionId.
861 @param FormSet The formset which contains this form.
862 @param Form The form which contains this Question.
863 @param QuestionId Id of this Question.
865 @retval Pointer The Question.
866 @retval NULL Specified Question not found in the form.
869 FORM_BROWSER_STATEMENT
*
871 IN FORM_BROWSER_FORMSET
*FormSet
,
872 IN FORM_BROWSER_FORM
*Form
,
877 Zero extend integer/boolean/date/time to UINT64 for comparing.
879 @param Value HII Value to be converted.
884 IN EFI_HII_VALUE
*Value
888 Compare two Hii value.
890 @param Value1 Expression value to compare on left-hand.
891 @param Value2 Expression value to compare on right-hand.
892 @param HiiHandle Only required for string compare.
894 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
895 @retval 0 Two operators equeal.
896 @return Positive value if Value1 is greater than Value2.
897 @retval Negative value if Value1 is less than Value2.
902 IN EFI_HII_VALUE
*Value1
,
903 IN EFI_HII_VALUE
*Value2
,
904 IN EFI_HII_HANDLE HiiHandle OPTIONAL
908 Evaluate the result of a HII expression
910 If Expression is NULL, then ASSERT.
912 @param FormSet FormSet associated with this expression.
913 @param Form Form associated with this expression.
914 @param Expression Expression to be evaluated.
916 @retval EFI_SUCCESS The expression evaluated successfuly
917 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
919 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
921 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
922 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
927 IN FORM_BROWSER_FORMSET
*FormSet
,
928 IN FORM_BROWSER_FORM
*Form
,
929 IN OUT FORM_EXPRESSION
*Expression