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
;
185 UI_SCREEN_OPERATION ScreenOperation
;
186 } SCAN_CODE_TO_SCREEN_OPERATION
;
189 UI_SCREEN_OPERATION ScreenOperation
;
190 UI_CONTROL_FLAG ControlFlag
;
191 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
194 extern LIST_ENTRY gMenuOption
;
195 extern MENU_REFRESH_ENTRY
*gMenuRefreshHead
;
196 extern UI_MENU_SELECTION
*gCurrentSelection
;
197 extern BOOLEAN mHiiPackageListUpdated
;
203 Initialize Menu option list.
212 Initialize Menu option list.
221 Free Menu option linked list.
230 Create a menu with specified formset GUID and form ID, and add it as a child
231 of the given parent menu.
233 @param Parent The parent of menu to be added.
234 @param FormSetGuid The Formset Guid of menu to be added.
235 @param FormId The Form ID of menu to be added.
237 @return A pointer to the newly added menu or NULL if memory is insufficient.
242 IN OUT UI_MENU_LIST
*Parent
,
243 IN EFI_GUID
*FormSetGuid
,
248 Search Menu with given FormId in the parent menu and all its child menus.
250 @param Parent The parent of menu to search.
251 @param FormId The Form ID of menu to search.
253 @return A pointer to menu found or NULL if not found.
257 UiFindChildMenuList (
258 IN UI_MENU_LIST
*Parent
,
263 Search Menu with given FormSetGuid and FormId in all cached menu list.
265 @param FormSetGuid The Formset GUID of the menu to search.
266 @param FormId The Form ID of menu to search.
268 @return A pointer to menu found or NULL if not found.
273 IN EFI_GUID
*FormSetGuid
,
278 Free Menu option linked list.
287 Add one menu option by specified description and context.
289 @param String String description for this option.
290 @param Handle Hii handle for the package list.
291 @param Statement Statement of this Menu Option.
292 @param NumberOfLines Display lines for this Menu Option.
293 @param MenuItemCount The index for this Option in the Menu.
295 @retval Pointer Pointer to the added Menu Option.
301 IN EFI_HII_HANDLE Handle
,
302 IN FORM_BROWSER_STATEMENT
*Statement
,
303 IN UINT16 NumberOfLines
,
304 IN UINT16 MenuItemCount
308 Display menu and wait for user to select one menu option, then return it.
309 If AutoBoot is enabled, then if user doesn't select any option,
310 after period of time, it will automatically return the first menu option.
312 @param Selection Menu selection.
314 @return Return the pointer of the menu which selected,
315 @return otherwise return NULL.
320 IN OUT UI_MENU_SELECTION
*Selection
324 Free up the resource allocated for all strings required
334 The worker function that send the displays to the screen. On output,
335 the selection made by user is returned.
337 @param Selection On input, Selection tell setup browser the information
338 about the Selection, form and formset to be displayed.
339 On output, Selection return the screen item that is selected
342 @retval EFI_SUCCESS The page is displayed successfully.
343 @return Other value if the page failed to be diplayed.
348 IN OUT UI_MENU_SELECTION
*Selection
352 Set Buffer to Value for Size bytes.
354 @param Buffer Memory to set.
355 @param Size Number of bytes to set
356 @param Value Value of the set operation.
367 Wait for a given event to fire, or for an optional timeout to expire.
369 @param Event The event to wait for
370 @param Timeout An optional timeout value in 100 ns units.
371 @param RefreshInterval Menu refresh interval (in seconds).
373 @retval EFI_SUCCESS Event fired before Timeout expired.
374 @retval EFI_TIME_OUT Timout expired before Event fired.
378 UiWaitForSingleEvent (
380 IN UINT64 Timeout
, OPTIONAL
381 IN UINT8 RefreshInterval OPTIONAL
385 Draw a pop up windows based on the dimension, number of lines and
388 @param ScreenWidth The width of the pop-up.
389 @param NumberOfLines The number of lines.
390 @param ... A series of text strings that displayed in the pop-up.
395 CreateMultiStringPopUp (
396 IN UINTN ScreenWidth
,
397 IN UINTN NumberOfLines
,
402 Get string or password input from user.
404 @param MenuOption Pointer to the current input menu.
405 @param Prompt The prompt string shown on popup window.
406 @param StringPtr Destination for use input string.
408 @retval EFI_SUCCESS If string input is read successfully
409 @retval EFI_DEVICE_ERROR If operation fails
414 IN UI_MENU_OPTION
*MenuOption
,
416 OUT CHAR16
*StringPtr
420 Get selection for OneOf and OrderedList (Left/Right will be ignored).
422 @param Selection Pointer to current selection.
423 @param MenuOption Pointer to the current input menu.
425 @retval EFI_SUCCESS If Option input is processed successfully
426 @retval EFI_DEVICE_ERROR If operation fails
430 GetSelectionInputPopUp (
431 IN UI_MENU_SELECTION
*Selection
,
432 IN UI_MENU_OPTION
*MenuOption
436 This routine reads a numeric value from the user input.
438 @param Selection Pointer to current selection.
439 @param MenuOption Pointer to the current input menu.
441 @retval EFI_SUCCESS If numerical input is read successfully
442 @retval EFI_DEVICE_ERROR If operation fails
447 IN UI_MENU_SELECTION
*Selection
,
448 IN UI_MENU_OPTION
*MenuOption
452 Update status bar on the bottom of menu.
454 @param Selection Current selection info.
455 @param MessageType The type of message to be shown.
456 @param Flags The flags in Question header.
457 @param State Set or clear.
462 IN UI_MENU_SELECTION
*Selection
,
463 IN UINTN MessageType
,
469 Process Question Config.
471 @param Selection The UI menu selection.
472 @param Question The Question to be peocessed.
474 @retval EFI_SUCCESS Question Config process success.
475 @retval Other Question Config process fail.
479 ProcessQuestionConfig (
480 IN UI_MENU_SELECTION
*Selection
,
481 IN FORM_BROWSER_STATEMENT
*Question
485 Print Question Value according to it's storage width and display attributes.
487 @param Question The Question to be printed.
488 @param FormattedNumber Buffer for output string.
489 @param BufferSize The FormattedNumber buffer size in bytes.
491 @retval EFI_SUCCESS Print success.
492 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
496 PrintFormattedNumber (
497 IN FORM_BROWSER_STATEMENT
*Question
,
498 IN OUT CHAR16
*FormattedNumber
,
503 Search an Option of a Question by its value.
505 @param Question The Question
506 @param OptionValue Value for Option to be searched.
508 @retval Pointer Pointer to the found Option.
509 @retval NULL Option not found.
514 IN FORM_BROWSER_STATEMENT
*Question
,
515 IN EFI_HII_VALUE
*OptionValue
519 Return data element in an Array by its Index.
521 @param Array The data array.
522 @param Type Type of the data in this array.
523 @param Index Zero based index for data in this array.
525 @retval Value The data to be returned
536 Set value of a data element in an Array by its Index.
538 @param Array The data array.
539 @param Type Type of the data in this array.
540 @param Index Zero based index for data in this array.
541 @param Value The value to be set.
553 Process a Question's Option (whether selected or un-selected).
555 @param Selection Pointer to UI_MENU_SELECTION.
556 @param MenuOption The MenuOption for this Question.
557 @param Selected TRUE: if Question is selected.
558 @param OptionString Pointer of the Option String to be displayed.
560 @retval EFI_SUCCESS Question Option process success.
561 @retval Other Question Option process fail.
566 IN UI_MENU_SELECTION
*Selection
,
567 IN UI_MENU_OPTION
*MenuOption
,
569 OUT CHAR16
**OptionString
573 Process the help string: Split StringPtr to several lines of strings stored in
574 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
576 @param StringPtr The entire help string.
577 @param FormattedString The oupput formatted string.
578 @param RowCount TRUE: if Question is selected.
583 IN CHAR16
*StringPtr
,
584 OUT CHAR16
**FormattedString
,
589 Update key's help imformation.
591 @param Selection Tell setup browser the information about the Selection
592 @param MenuOption The Menu option
593 @param Selected Whether or not a tag be selected
598 IN UI_MENU_SELECTION
*Selection
,
599 IN UI_MENU_OPTION
*MenuOption
,
604 Clear retangle with specified text attribute.
606 @param LeftColumn Left column of retangle.
607 @param RightColumn Right column of retangle.
608 @param TopRow Start row of retangle.
609 @param BottomRow End row of retangle.
610 @param TextAttribute The character foreground and background.
616 IN UINTN RightColumn
,
619 IN UINTN TextAttribute
623 Count the storage space of a Unicode string.
625 This function handles the Unicode string with NARROW_CHAR
626 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
627 does not count in the resultant output. If a WIDE_CHAR is
628 hit, then 2 Unicode character will consume an output storage
629 space with size of CHAR16 till a NARROW_CHAR is hit.
631 If String is NULL, then ASSERT ().
633 @param String The input string to be counted.
635 @return Storage space for the input string.
644 Will copy LineWidth amount of a string in the OutputString buffer and return the
645 number of CHAR16 characters that were copied into the OutputString buffer.
647 @param InputString String description for this option.
648 @param LineWidth Width of the desired string to extract in CHAR16
650 @param Index Where in InputString to start the copy process
651 @param OutputString Buffer to copy the string into
653 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
658 IN CHAR16
*InputString
,
661 OUT CHAR16
**OutputString
665 Get the supported width for a particular op-code
667 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
668 @param Handle The handle in the HII database being used
670 @return Returns the number of CHAR16 characters that is support.
675 IN FORM_BROWSER_STATEMENT
*Statement
,
676 IN EFI_HII_HANDLE Handle
680 Concatenate a narrow string to another string.
682 @param Destination The destination string.
683 @param Source The source string. The string to be concatenated.
684 to the end of Destination.
689 IN OUT CHAR16
*Destination
,
694 Wait for a key to be pressed by user.
696 @param Key The key which is pressed by user.
698 @retval EFI_SUCCESS The function always completed successfully.
703 OUT EFI_INPUT_KEY
*Key
707 Reset stack pointer to begin of the stack.
716 Push an Operand onto the Stack
718 @param Operand Operand to push.
720 @retval EFI_SUCCESS The value was pushed onto the stack.
721 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
731 Pop an Operand from the Stack
733 @param Operand Operand to pop.
735 @retval EFI_SUCCESS The value was pushed onto the stack.
736 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
746 Reset stack pointer to begin of the stack.
750 ResetCurrentExpressionStack (
755 Push current expression onto the Stack
757 @param Pointer Pointer to current expression.
759 @retval EFI_SUCCESS The value was pushed onto the stack.
760 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
764 PushCurrentExpression (
769 Pop current expression from the Stack
771 @param Pointer Pointer to current expression to be pop.
773 @retval EFI_SUCCESS The value was pushed onto the stack.
774 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
778 PopCurrentExpression (
783 Reset stack pointer to begin of the stack.
787 ResetMapExpressionListStack (
792 Push the list of map expression onto the Stack
794 @param Pointer Pointer to the list of map expression to be pushed.
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 PushMapExpressionList (
806 Pop the list of map expression from the Stack
808 @param Pointer Pointer to the list of map expression to be pop.
810 @retval EFI_SUCCESS The value was pushed onto the stack.
811 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the stack.
815 PopMapExpressionList (
820 Get Form given its FormId.
822 @param FormSet The formset which contains this form.
823 @param FormId Id of this form.
825 @retval Pointer The form.
826 @retval NULL Specified Form is not found in the formset.
831 IN FORM_BROWSER_FORMSET
*FormSet
,
836 Search a Question in Formset scope using its QuestionId.
838 @param FormSet The formset which contains this form.
839 @param Form The form which contains this Question.
840 @param QuestionId Id of this Question.
842 @retval Pointer The Question.
843 @retval NULL Specified Question not found in the form.
846 FORM_BROWSER_STATEMENT
*
848 IN FORM_BROWSER_FORMSET
*FormSet
,
849 IN FORM_BROWSER_FORM
*Form
,
854 Zero extend integer/boolean/date/time to UINT64 for comparing.
856 @param Value HII Value to be converted.
861 IN EFI_HII_VALUE
*Value
865 Compare two Hii value.
867 @param Value1 Expression value to compare on left-hand.
868 @param Value2 Expression value to compare on right-hand.
869 @param HiiHandle Only required for string compare.
871 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
872 @retval 0 Two operators equeal.
873 @return Positive value if Value1 is greater than Value2.
874 @retval Negative value if Value1 is less than Value2.
879 IN EFI_HII_VALUE
*Value1
,
880 IN EFI_HII_VALUE
*Value2
,
881 IN EFI_HII_HANDLE HiiHandle OPTIONAL
885 Evaluate the result of a HII expression
887 If Expression is NULL, then ASSERT.
889 @param FormSet FormSet associated with this expression.
890 @param Form Form associated with this expression.
891 @param Expression Expression to be evaluated.
893 @retval EFI_SUCCESS The expression evaluated successfuly
894 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
896 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
898 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
899 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
904 IN FORM_BROWSER_FORMSET
*FormSet
,
905 IN FORM_BROWSER_FORM
*Form
,
906 IN OUT FORM_EXPRESSION
*Expression