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 Process the goto op code, update the info in the selection structure.
337 @param Statement The statement belong to goto op code.
338 @param Selection The selection info.
339 @param Repaint Whether need to repaint the menu.
340 @param NewLine Whether need to create new line.
342 @retval EFI_SUCCESS The menu process successfully.
343 @return Other value if the process failed.
347 IN OUT FORM_BROWSER_STATEMENT
*Statement
,
348 IN OUT UI_MENU_SELECTION
*Selection
,
349 OUT BOOLEAN
*Repaint
,
355 The worker function that send the displays to the screen. On output,
356 the selection made by user is returned.
358 @param Selection On input, Selection tell setup browser the information
359 about the Selection, form and formset to be displayed.
360 On output, Selection return the screen item that is selected
363 @retval EFI_SUCCESS The page is displayed successfully.
364 @return Other value if the page failed to be diplayed.
369 IN OUT UI_MENU_SELECTION
*Selection
373 Set Buffer to Value for Size bytes.
375 @param Buffer Memory to set.
376 @param Size Number of bytes to set
377 @param Value Value of the set operation.
388 Wait for a given event to fire, or for an optional timeout to expire.
390 @param Event The event to wait for
391 @param Timeout An optional timeout value in 100 ns units.
392 @param RefreshInterval Menu refresh interval (in seconds).
394 @retval EFI_SUCCESS Event fired before Timeout expired.
395 @retval EFI_TIME_OUT Timout expired before Event fired.
399 UiWaitForSingleEvent (
401 IN UINT64 Timeout
, OPTIONAL
402 IN UINT8 RefreshInterval OPTIONAL
406 Draw a pop up windows based on the dimension, number of lines and
409 @param ScreenWidth The width of the pop-up.
410 @param NumberOfLines The number of lines.
411 @param ... A series of text strings that displayed in the pop-up.
416 CreateMultiStringPopUp (
417 IN UINTN ScreenWidth
,
418 IN UINTN NumberOfLines
,
423 Get string or password input from user.
425 @param MenuOption Pointer to the current input menu.
426 @param Prompt The prompt string shown on popup window.
427 @param StringPtr Destination for use input string.
429 @retval EFI_SUCCESS If string input is read successfully
430 @retval EFI_DEVICE_ERROR If operation fails
435 IN UI_MENU_OPTION
*MenuOption
,
437 OUT CHAR16
*StringPtr
441 Get selection for OneOf and OrderedList (Left/Right will be ignored).
443 @param Selection Pointer to current selection.
444 @param MenuOption Pointer to the current input menu.
446 @retval EFI_SUCCESS If Option input is processed successfully
447 @retval EFI_DEVICE_ERROR If operation fails
451 GetSelectionInputPopUp (
452 IN UI_MENU_SELECTION
*Selection
,
453 IN UI_MENU_OPTION
*MenuOption
457 This routine reads a numeric value from the user input.
459 @param Selection Pointer to current selection.
460 @param MenuOption Pointer to the current input menu.
462 @retval EFI_SUCCESS If numerical input is read successfully
463 @retval EFI_DEVICE_ERROR If operation fails
468 IN UI_MENU_SELECTION
*Selection
,
469 IN UI_MENU_OPTION
*MenuOption
473 Update status bar on the bottom of menu.
475 @param Selection Current selection info.
476 @param MessageType The type of message to be shown.
477 @param Flags The flags in Question header.
478 @param State Set or clear.
483 IN UI_MENU_SELECTION
*Selection
,
484 IN UINTN MessageType
,
490 Process Question Config.
492 @param Selection The UI menu selection.
493 @param Question The Question to be peocessed.
495 @retval EFI_SUCCESS Question Config process success.
496 @retval Other Question Config process fail.
500 ProcessQuestionConfig (
501 IN UI_MENU_SELECTION
*Selection
,
502 IN FORM_BROWSER_STATEMENT
*Question
506 Print Question Value according to it's storage width and display attributes.
508 @param Question The Question to be printed.
509 @param FormattedNumber Buffer for output string.
510 @param BufferSize The FormattedNumber buffer size in bytes.
512 @retval EFI_SUCCESS Print success.
513 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
517 PrintFormattedNumber (
518 IN FORM_BROWSER_STATEMENT
*Question
,
519 IN OUT CHAR16
*FormattedNumber
,
524 Search an Option of a Question by its value.
526 @param Question The Question
527 @param OptionValue Value for Option to be searched.
529 @retval Pointer Pointer to the found Option.
530 @retval NULL Option not found.
535 IN FORM_BROWSER_STATEMENT
*Question
,
536 IN EFI_HII_VALUE
*OptionValue
540 Return data element in an Array by its Index.
542 @param Array The data array.
543 @param Type Type of the data in this array.
544 @param Index Zero based index for data in this array.
546 @retval Value The data to be returned
557 Set value of a data element in an Array by its Index.
559 @param Array The data array.
560 @param Type Type of the data in this array.
561 @param Index Zero based index for data in this array.
562 @param Value The value to be set.
574 Process a Question's Option (whether selected or un-selected).
576 @param Selection Pointer to UI_MENU_SELECTION.
577 @param MenuOption The MenuOption for this Question.
578 @param Selected TRUE: if Question is selected.
579 @param OptionString Pointer of the Option String to be displayed.
581 @retval EFI_SUCCESS Question Option process success.
582 @retval Other Question Option process fail.
587 IN UI_MENU_SELECTION
*Selection
,
588 IN UI_MENU_OPTION
*MenuOption
,
590 OUT CHAR16
**OptionString
594 Process the help string: Split StringPtr to several lines of strings stored in
595 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
597 @param StringPtr The entire help string.
598 @param FormattedString The oupput formatted string.
599 @param RowCount TRUE: if Question is selected.
604 IN CHAR16
*StringPtr
,
605 OUT CHAR16
**FormattedString
,
610 Update key's help imformation.
612 @param Selection Tell setup browser the information about the Selection
613 @param MenuOption The Menu option
614 @param Selected Whether or not a tag be selected
619 IN UI_MENU_SELECTION
*Selection
,
620 IN UI_MENU_OPTION
*MenuOption
,
625 Clear retangle with specified text attribute.
627 @param LeftColumn Left column of retangle.
628 @param RightColumn Right column of retangle.
629 @param TopRow Start row of retangle.
630 @param BottomRow End row of retangle.
631 @param TextAttribute The character foreground and background.
637 IN UINTN RightColumn
,
640 IN UINTN TextAttribute
644 Count the storage space of a Unicode string.
646 This function handles the Unicode string with NARROW_CHAR
647 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
648 does not count in the resultant output. If a WIDE_CHAR is
649 hit, then 2 Unicode character will consume an output storage
650 space with size of CHAR16 till a NARROW_CHAR is hit.
652 If String is NULL, then ASSERT ().
654 @param String The input string to be counted.
656 @return Storage space for the input string.
665 Will copy LineWidth amount of a string in the OutputString buffer and return the
666 number of CHAR16 characters that were copied into the OutputString buffer.
668 @param InputString String description for this option.
669 @param LineWidth Width of the desired string to extract in CHAR16
671 @param Index Where in InputString to start the copy process
672 @param OutputString Buffer to copy the string into
674 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
679 IN CHAR16
*InputString
,
682 OUT CHAR16
**OutputString
686 Get the supported width for a particular op-code
688 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
689 @param Handle The handle in the HII database being used
691 @return Returns the number of CHAR16 characters that is support.
696 IN FORM_BROWSER_STATEMENT
*Statement
,
697 IN EFI_HII_HANDLE Handle
701 Concatenate a narrow string to another string.
703 @param Destination The destination string.
704 @param Source The source string. The string to be concatenated.
705 to the end of Destination.
710 IN OUT CHAR16
*Destination
,
715 Wait for a key to be pressed by user.
717 @param Key The key which is pressed by user.
719 @retval EFI_SUCCESS The function always completed successfully.
724 OUT EFI_INPUT_KEY
*Key
728 Reset stack pointer to begin of the stack.
737 Push an Operand onto the Stack
739 @param Operand Operand to push.
741 @retval EFI_SUCCESS The value was pushed onto the stack.
742 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
752 Pop an Operand from the Stack
754 @param Operand Operand to pop.
756 @retval EFI_SUCCESS The value was pushed onto the stack.
757 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
767 Reset stack pointer to begin of the stack.
771 ResetCurrentExpressionStack (
776 Push current expression onto the Stack
778 @param Pointer Pointer to current expression.
780 @retval EFI_SUCCESS The value was pushed onto the stack.
781 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
785 PushCurrentExpression (
790 Pop current expression from the Stack
792 @param Pointer Pointer to current expression to be pop.
794 @retval EFI_SUCCESS The value was pushed onto the stack.
795 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
799 PopCurrentExpression (
804 Reset stack pointer to begin of the stack.
808 ResetMapExpressionListStack (
813 Push the list of map expression onto the Stack
815 @param Pointer Pointer to the list of map expression to be pushed.
817 @retval EFI_SUCCESS The value was pushed onto the stack.
818 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
822 PushMapExpressionList (
827 Pop the list of map expression from the Stack
829 @param Pointer Pointer to the list of map expression to be pop.
831 @retval EFI_SUCCESS The value was pushed onto the stack.
832 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
836 PopMapExpressionList (
841 Get Form given its FormId.
843 @param FormSet The formset which contains this form.
844 @param FormId Id of this form.
846 @retval Pointer The form.
847 @retval NULL Specified Form is not found in the formset.
852 IN FORM_BROWSER_FORMSET
*FormSet
,
857 Search a Question in Formset scope using its QuestionId.
859 @param FormSet The formset which contains this form.
860 @param Form The form which contains this Question.
861 @param QuestionId Id of this Question.
863 @retval Pointer The Question.
864 @retval NULL Specified Question not found in the form.
867 FORM_BROWSER_STATEMENT
*
869 IN FORM_BROWSER_FORMSET
*FormSet
,
870 IN FORM_BROWSER_FORM
*Form
,
875 Zero extend integer/boolean/date/time to UINT64 for comparing.
877 @param Value HII Value to be converted.
882 IN EFI_HII_VALUE
*Value
886 Compare two Hii value.
888 @param Value1 Expression value to compare on left-hand.
889 @param Value2 Expression value to compare on right-hand.
890 @param HiiHandle Only required for string compare.
892 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
893 @retval 0 Two operators equeal.
894 @return Positive value if Value1 is greater than Value2.
895 @retval Negative value if Value1 is less than Value2.
900 IN EFI_HII_VALUE
*Value1
,
901 IN EFI_HII_VALUE
*Value2
,
902 IN EFI_HII_HANDLE HiiHandle OPTIONAL
906 Evaluate the result of a HII expression
908 If Expression is NULL, then ASSERT.
910 @param FormSet FormSet associated with this expression.
911 @param Form Form associated with this expression.
912 @param Expression Expression to be evaluated.
914 @retval EFI_SUCCESS The expression evaluated successfuly
915 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
917 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
919 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
920 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
925 IN FORM_BROWSER_FORMSET
*FormSet
,
926 IN FORM_BROWSER_FORM
*Form
,
927 IN OUT FORM_EXPRESSION
*Expression