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_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 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 HiiHandle Hii handle related to this formset.
238 @param FormSetGuid The Formset Guid of menu to be added.
239 @param FormId The Form ID of menu to be added.
241 @return A pointer to the newly added menu or NULL if memory is insufficient.
246 IN OUT UI_MENU_LIST
*Parent
,
247 IN EFI_HII_HANDLE HiiHandle
,
248 IN EFI_GUID
*FormSetGuid
,
253 Search Menu with given FormId in the parent menu and all its child menus.
255 @param Parent The parent of menu to search.
256 @param FormSetGuid The Formset GUID of the menu to search.
257 @param FormId The Form ID of menu to search.
259 @return A pointer to menu found or NULL if not found.
263 UiFindChildMenuList (
264 IN UI_MENU_LIST
*Parent
,
265 IN EFI_GUID
*FormSetGuid
,
270 Search Menu with given FormSetGuid and FormId in all cached menu list.
272 @param FormSetGuid The Formset GUID of the menu to search.
273 @param FormId The Form ID of menu to search.
275 @return A pointer to menu found or NULL if not found.
280 IN EFI_GUID
*FormSetGuid
,
285 Free Menu option linked list.
294 Add one menu option by specified description and context.
296 @param String String description for this option.
297 @param Handle Hii handle for the package list.
298 @param Statement Statement of this Menu Option.
299 @param NumberOfLines Display lines for this Menu Option.
300 @param MenuItemCount The index for this Option in the Menu.
302 @retval Pointer Pointer to the added Menu Option.
308 IN EFI_HII_HANDLE Handle
,
309 IN FORM_BROWSER_STATEMENT
*Statement
,
310 IN UINT16 NumberOfLines
,
311 IN UINT16 MenuItemCount
315 Display menu and wait for user to select one menu option, then return it.
316 If AutoBoot is enabled, then if user doesn't select any option,
317 after period of time, it will automatically return the first menu option.
319 @param Selection Menu selection.
321 @return Return the pointer of the menu which selected,
322 @return otherwise return NULL.
327 IN OUT UI_MENU_SELECTION
*Selection
331 Free up the resource allocated for all strings required
341 Process the goto op code, update the info in the selection structure.
343 @param Statement The statement belong to goto op code.
344 @param Selection The selection info.
345 @param Repaint Whether need to repaint the menu.
346 @param NewLine Whether need to create new line.
348 @retval EFI_SUCCESS The menu process successfully.
349 @return Other value if the process failed.
353 IN OUT FORM_BROWSER_STATEMENT
*Statement
,
354 IN OUT UI_MENU_SELECTION
*Selection
,
355 OUT BOOLEAN
*Repaint
,
361 The worker function that send the displays to the screen. On output,
362 the selection made by user is returned.
364 @param Selection On input, Selection tell setup browser the information
365 about the Selection, form and formset to be displayed.
366 On output, Selection return the screen item that is selected
369 @retval EFI_SUCCESS The page is displayed successfully.
370 @return Other value if the page failed to be diplayed.
375 IN OUT UI_MENU_SELECTION
*Selection
379 Set Buffer to Value for Size bytes.
381 @param Buffer Memory to set.
382 @param Size Number of bytes to set
383 @param Value Value of the set operation.
394 Wait for a given event to fire, or for an optional timeout to expire.
396 @param Event The event to wait for
397 @param Timeout An optional timeout value in 100 ns units.
398 @param RefreshInterval Menu refresh interval (in seconds).
400 @retval EFI_SUCCESS Event fired before Timeout expired.
401 @retval EFI_TIME_OUT Timout expired before Event fired.
405 UiWaitForSingleEvent (
407 IN UINT64 Timeout
, OPTIONAL
408 IN UINT8 RefreshInterval OPTIONAL
412 Draw a pop up windows based on the dimension, number of lines and
415 @param ScreenWidth The width of the pop-up.
416 @param NumberOfLines The number of lines.
417 @param ... A series of text strings that displayed in the pop-up.
422 CreateMultiStringPopUp (
423 IN UINTN ScreenWidth
,
424 IN UINTN NumberOfLines
,
429 Get string or password input from user.
431 @param MenuOption Pointer to the current input menu.
432 @param Prompt The prompt string shown on popup window.
433 @param StringPtr Old user input and destination for use input string.
435 @retval EFI_SUCCESS If string input is read successfully
436 @retval EFI_DEVICE_ERROR If operation fails
441 IN UI_MENU_OPTION
*MenuOption
,
443 IN OUT CHAR16
*StringPtr
447 Get selection for OneOf and OrderedList (Left/Right will be ignored).
449 @param Selection Pointer to current selection.
450 @param MenuOption Pointer to the current input menu.
452 @retval EFI_SUCCESS If Option input is processed successfully
453 @retval EFI_DEVICE_ERROR If operation fails
457 GetSelectionInputPopUp (
458 IN UI_MENU_SELECTION
*Selection
,
459 IN UI_MENU_OPTION
*MenuOption
463 This routine reads a numeric value from the user input.
465 @param Selection Pointer to current selection.
466 @param MenuOption Pointer to the current input menu.
468 @retval EFI_SUCCESS If numerical input is read successfully
469 @retval EFI_DEVICE_ERROR If operation fails
474 IN UI_MENU_SELECTION
*Selection
,
475 IN UI_MENU_OPTION
*MenuOption
479 Update status bar on the bottom of menu.
481 @param Selection Current selection info.
482 @param MessageType The type of message to be shown.
483 @param Flags The flags in Question header.
484 @param State Set or clear.
489 IN UI_MENU_SELECTION
*Selection
,
490 IN UINTN MessageType
,
496 Process Question Config.
498 @param Selection The UI menu selection.
499 @param Question The Question to be peocessed.
501 @retval EFI_SUCCESS Question Config process success.
502 @retval Other Question Config process fail.
506 ProcessQuestionConfig (
507 IN UI_MENU_SELECTION
*Selection
,
508 IN FORM_BROWSER_STATEMENT
*Question
512 Print Question Value according to it's storage width and display attributes.
514 @param Question The Question to be printed.
515 @param FormattedNumber Buffer for output string.
516 @param BufferSize The FormattedNumber buffer size in bytes.
518 @retval EFI_SUCCESS Print success.
519 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
523 PrintFormattedNumber (
524 IN FORM_BROWSER_STATEMENT
*Question
,
525 IN OUT CHAR16
*FormattedNumber
,
530 Search an Option of a Question by its value.
532 @param Question The Question
533 @param OptionValue Value for Option to be searched.
535 @retval Pointer Pointer to the found Option.
536 @retval NULL Option not found.
541 IN FORM_BROWSER_STATEMENT
*Question
,
542 IN EFI_HII_VALUE
*OptionValue
546 Return data element in an Array by its Index.
548 @param Array The data array.
549 @param Type Type of the data in this array.
550 @param Index Zero based index for data in this array.
552 @retval Value The data to be returned
563 Set value of a data element in an Array by its Index.
565 @param Array The data array.
566 @param Type Type of the data in this array.
567 @param Index Zero based index for data in this array.
568 @param Value The value to be set.
580 Process a Question's Option (whether selected or un-selected).
582 @param Selection Pointer to UI_MENU_SELECTION.
583 @param MenuOption The MenuOption for this Question.
584 @param Selected TRUE: if Question is selected.
585 @param OptionString Pointer of the Option String to be displayed.
587 @retval EFI_SUCCESS Question Option process success.
588 @retval Other Question Option process fail.
593 IN UI_MENU_SELECTION
*Selection
,
594 IN UI_MENU_OPTION
*MenuOption
,
596 OUT CHAR16
**OptionString
600 Process the help string: Split StringPtr to several lines of strings stored in
601 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
603 @param StringPtr The entire help string.
604 @param FormattedString The oupput formatted string.
605 @param RowCount TRUE: if Question is selected.
610 IN CHAR16
*StringPtr
,
611 OUT CHAR16
**FormattedString
,
616 Update key's help imformation.
618 @param Selection Tell setup browser the information about the Selection
619 @param MenuOption The Menu option
620 @param Selected Whether or not a tag be selected
625 IN UI_MENU_SELECTION
*Selection
,
626 IN UI_MENU_OPTION
*MenuOption
,
631 Clear retangle with specified text attribute.
633 @param LeftColumn Left column of retangle.
634 @param RightColumn Right column of retangle.
635 @param TopRow Start row of retangle.
636 @param BottomRow End row of retangle.
637 @param TextAttribute The character foreground and background.
643 IN UINTN RightColumn
,
646 IN UINTN TextAttribute
650 Count the storage space of a Unicode string.
652 This function handles the Unicode string with NARROW_CHAR
653 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
654 does not count in the resultant output. If a WIDE_CHAR is
655 hit, then 2 Unicode character will consume an output storage
656 space with size of CHAR16 till a NARROW_CHAR is hit.
658 If String is NULL, then ASSERT ().
660 @param String The input string to be counted.
662 @return Storage space for the input string.
671 Will copy LineWidth amount of a string in the OutputString buffer and return the
672 number of CHAR16 characters that were copied into the OutputString buffer.
674 @param InputString String description for this option.
675 @param LineWidth Width of the desired string to extract in CHAR16
677 @param Index Where in InputString to start the copy process
678 @param OutputString Buffer to copy the string into
680 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
685 IN CHAR16
*InputString
,
688 OUT CHAR16
**OutputString
692 Get the supported width for a particular op-code
694 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
695 @param Handle The handle in the HII database being used
697 @return Returns the number of CHAR16 characters that is support.
702 IN FORM_BROWSER_STATEMENT
*Statement
,
703 IN EFI_HII_HANDLE Handle
707 Concatenate a narrow string to another string.
709 @param Destination The destination string.
710 @param Source The source string. The string to be concatenated.
711 to the end of Destination.
716 IN OUT CHAR16
*Destination
,
721 Wait for a key to be pressed by user.
723 @param Key The key which is pressed by user.
725 @retval EFI_SUCCESS The function always completed successfully.
730 OUT EFI_INPUT_KEY
*Key
734 Reset stack pointer to begin of the stack.
743 Push an Operand onto the Stack
745 @param Operand Operand to push.
747 @retval EFI_SUCCESS The value was pushed onto the stack.
748 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
758 Pop an Operand from the Stack
760 @param Operand Operand to pop.
762 @retval EFI_SUCCESS The value was pushed onto the stack.
763 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
773 Reset stack pointer to begin of the stack.
777 ResetCurrentExpressionStack (
782 Push current expression onto the Stack
784 @param Pointer Pointer to current expression.
786 @retval EFI_SUCCESS The value was pushed onto the stack.
787 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
791 PushCurrentExpression (
796 Pop current expression from the Stack
798 @param Pointer Pointer to current expression to be pop.
800 @retval EFI_SUCCESS The value was pushed onto the stack.
801 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
805 PopCurrentExpression (
810 Reset stack pointer to begin of the stack.
814 ResetMapExpressionListStack (
819 Push the list of map expression onto the Stack
821 @param Pointer Pointer to the list of map expression to be pushed.
823 @retval EFI_SUCCESS The value was pushed onto the stack.
824 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
828 PushMapExpressionList (
833 Pop the list of map expression from the Stack
835 @param Pointer Pointer to the list of map expression to be pop.
837 @retval EFI_SUCCESS The value was pushed onto the stack.
838 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
842 PopMapExpressionList (
847 Get Form given its FormId.
849 @param FormSet The formset which contains this form.
850 @param FormId Id of this form.
852 @retval Pointer The form.
853 @retval NULL Specified Form is not found in the formset.
858 IN FORM_BROWSER_FORMSET
*FormSet
,
863 Search a Question in Formset scope using its QuestionId.
865 @param FormSet The formset which contains this form.
866 @param Form The form which contains this Question.
867 @param QuestionId Id of this Question.
869 @retval Pointer The Question.
870 @retval NULL Specified Question not found in the form.
873 FORM_BROWSER_STATEMENT
*
875 IN FORM_BROWSER_FORMSET
*FormSet
,
876 IN FORM_BROWSER_FORM
*Form
,
881 Zero extend integer/boolean/date/time to UINT64 for comparing.
883 @param Value HII Value to be converted.
888 IN EFI_HII_VALUE
*Value
892 Compare two Hii value.
894 @param Value1 Expression value to compare on left-hand.
895 @param Value2 Expression value to compare on right-hand.
896 @param HiiHandle Only required for string compare.
898 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
899 @retval 0 Two operators equeal.
900 @return Positive value if Value1 is greater than Value2.
901 @retval Negative value if Value1 is less than Value2.
906 IN EFI_HII_VALUE
*Value1
,
907 IN EFI_HII_VALUE
*Value2
,
908 IN EFI_HII_HANDLE HiiHandle OPTIONAL
912 Evaluate the result of a HII expression
914 If Expression is NULL, then ASSERT.
916 @param FormSet FormSet associated with this expression.
917 @param Form Form associated with this expression.
918 @param Expression Expression to be evaluated.
920 @retval EFI_SUCCESS The expression evaluated successfuly
921 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
923 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
925 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
926 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
931 IN FORM_BROWSER_FORMSET
*FormSet
,
932 IN FORM_BROWSER_FORM
*Form
,
933 IN OUT FORM_EXPRESSION
*Expression