2 Private structure, MACRO and function definitions for User Interface related functionalities.
4 Copyright (c) 2004 - 2009, Intel Corporation
5 All rights reserved. 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.
23 #define REGULAR_NUMERIC 0
24 #define TIME_NUMERIC 1
25 #define DATE_NUMERIC 2
27 #define SUBTITLE_INDENT 2
31 // It take 23 characters including the NULL to print a 64 bits number with "[" and "]".
32 // pow(2, 64) = [18446744073709551616]
34 #define MAX_NUMERIC_INPUT_WIDTH 23
50 } UI_SCREEN_OPERATION
;
76 #define UI_ACTION_NONE 0
77 #define UI_ACTION_REFRESH_FORM 1
78 #define UI_ACTION_REFRESH_FORMSET 2
79 #define UI_ACTION_EXIT 3
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
;
118 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
119 #define UI_MENU_LIST_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'l')
125 EFI_HII_HANDLE Handle
;
126 FORM_BROWSER_STATEMENT
*ThisTag
;
133 UINTN Skip
; // Number of lines
136 // Display item sequence for date/time
137 // Date: Month/Day/Year
140 // Time: Hour : Minute : Second
150 // Whether user could change value of this item
155 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
157 typedef struct _UI_MENU_LIST UI_MENU_LIST
;
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
{
174 struct _MENU_REFRESH_ENTRY
*Next
;
175 UI_MENU_OPTION
*MenuOption
; // Describes the entry needing an update
176 UI_MENU_SELECTION
*Selection
;
179 UINTN CurrentAttribute
;
180 } MENU_REFRESH_ENTRY
;
184 UI_SCREEN_OPERATION ScreenOperation
;
185 } SCAN_CODE_TO_SCREEN_OPERATION
;
188 UI_SCREEN_OPERATION ScreenOperation
;
189 UI_CONTROL_FLAG ControlFlag
;
190 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
193 extern LIST_ENTRY gMenuOption
;
194 extern MENU_REFRESH_ENTRY
*gMenuRefreshHead
;
195 extern UI_MENU_SELECTION
*gCurrentSelection
;
196 extern BOOLEAN mHiiPackageListUpdated
;
202 Initialize Menu option list.
211 Initialize Menu option list.
220 Free Menu option linked list.
229 Create a menu with specified formset GUID and form ID, and add it as a child
230 of the given parent menu.
232 @param Parent The parent of menu to be added.
233 @param FormSetGuid The Formset Guid of menu to be added.
234 @param FormId The Form ID of menu to be added.
236 @return A pointer to the newly added menu or NULL if memory is insufficient.
241 IN OUT UI_MENU_LIST
*Parent
,
242 IN EFI_GUID
*FormSetGuid
,
247 Search Menu with given FormId in the parent menu and all its child menus.
249 @param Parent The parent of menu to search.
250 @param FormId The Form ID of menu to search.
252 @return A pointer to menu found or NULL if not found.
256 UiFindChildMenuList (
257 IN UI_MENU_LIST
*Parent
,
262 Search Menu with given FormSetGuid and FormId in all cached menu list.
264 @param FormSetGuid The Formset GUID of the menu to search.
265 @param FormId The Form ID of menu to search.
267 @return A pointer to menu found or NULL if not found.
272 IN EFI_GUID
*FormSetGuid
,
277 Free Menu option linked list.
286 Add one menu option by specified description and context.
288 @param String String description for this option.
289 @param Handle Hii handle for the package list.
290 @param Statement Statement of this Menu Option.
291 @param NumberOfLines Display lines for this Menu Option.
292 @param MenuItemCount The index for this Option in the Menu.
294 @retval Pointer Pointer to the added Menu Option.
300 IN EFI_HII_HANDLE Handle
,
301 IN FORM_BROWSER_STATEMENT
*Statement
,
302 IN UINT16 NumberOfLines
,
303 IN UINT16 MenuItemCount
307 Display menu and wait for user to select one menu option, then return it.
308 If AutoBoot is enabled, then if user doesn't select any option,
309 after period of time, it will automatically return the first menu option.
311 @param Selection Menu selection.
313 @return Return the pointer of the menu which selected,
314 @return otherwise return NULL.
319 IN OUT UI_MENU_SELECTION
*Selection
323 Free up the resource allocated for all strings required
333 The worker function that send the displays to the screen. On output,
334 the selection made by user is returned.
336 @param Selection On input, Selection tell setup browser the information
337 about the Selection, form and formset to be displayed.
338 On output, Selection return the screen item that is selected
341 @retval EFI_SUCCESS The page is displayed successfully.
342 @return Other value if the page failed to be diplayed.
347 IN OUT UI_MENU_SELECTION
*Selection
351 Set Buffer to Value for Size bytes.
353 @param Buffer Memory to set.
354 @param Size Number of bytes to set
355 @param Value Value of the set operation.
366 Wait for a given event to fire, or for an optional timeout to expire.
368 @param Event The event to wait for
369 @param Timeout An optional timeout value in 100 ns units.
370 @param RefreshInterval Menu refresh interval (in seconds).
372 @retval EFI_SUCCESS Event fired before Timeout expired.
373 @retval EFI_TIME_OUT Timout expired before Event fired.
377 UiWaitForSingleEvent (
379 IN UINT64 Timeout
, OPTIONAL
380 IN UINT8 RefreshInterval OPTIONAL
384 Draw a pop up windows based on the dimension, number of lines and
387 @param ScreenWidth The width of the pop-up.
388 @param NumberOfLines The number of lines.
389 @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 @param String The input string to be counted.
629 @return Storage space for the input string.
638 Will copy LineWidth amount of a string in the OutputString buffer and return the
639 number of CHAR16 characters that were copied into the OutputString buffer.
641 @param InputString String description for this option.
642 @param LineWidth Width of the desired string to extract in CHAR16
644 @param Index Where in InputString to start the copy process
645 @param OutputString Buffer to copy the string into
647 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
652 IN CHAR16
*InputString
,
655 OUT CHAR16
**OutputString
659 Get the supported width for a particular op-code
661 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
662 @param Handle The handle in the HII database being used
664 @return Returns the number of CHAR16 characters that is support.
669 IN FORM_BROWSER_STATEMENT
*Statement
,
670 IN EFI_HII_HANDLE Handle
674 Concatenate a narrow string to another string.
676 @param Destination The destination string.
677 @param Source The source string. The string to be concatenated.
678 to the end of Destination.
683 IN OUT CHAR16
*Destination
,
688 Wait for a key to be pressed by user.
690 @param Key The key which is pressed by user.
692 @retval EFI_SUCCESS The function always completed successfully.
697 OUT EFI_INPUT_KEY
*Key
701 Reset stack pointer to begin of the stack.
710 Push an Operand onto the Stack
712 @param Operand Operand to push.
714 @retval EFI_SUCCESS The value was pushed onto the stack.
715 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
725 Pop an Operand from the Stack
727 @param Operand Operand to pop.
729 @retval EFI_SUCCESS The value was pushed onto the stack.
730 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
740 Get Form given its FormId.
742 @param FormSet The formset which contains this form.
743 @param FormId Id of this form.
745 @retval Pointer The form.
746 @retval NULL Specified Form is not found in the formset.
751 IN FORM_BROWSER_FORMSET
*FormSet
,
756 Search a Question in Formset scope using its QuestionId.
758 @param FormSet The formset which contains this form.
759 @param Form The form which contains this Question.
760 @param QuestionId Id of this Question.
762 @retval Pointer The Question.
763 @retval NULL Specified Question not found in the form.
766 FORM_BROWSER_STATEMENT
*
768 IN FORM_BROWSER_FORMSET
*FormSet
,
769 IN FORM_BROWSER_FORM
*Form
,
774 Zero extend integer/boolean/date/time to UINT64 for comparing.
776 @param Value HII Value to be converted.
781 IN EFI_HII_VALUE
*Value
785 Compare two Hii value.
787 @param Value1 Expression value to compare on left-hand.
788 @param Value2 Expression value to compare on right-hand.
789 @param HiiHandle Only required for string compare.
791 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
792 @retval 0 Two operators equeal.
793 @return Positive value if Value1 is greater than Value2.
794 @retval Negative value if Value1 is less than Value2.
799 IN EFI_HII_VALUE
*Value1
,
800 IN EFI_HII_VALUE
*Value2
,
801 IN EFI_HII_HANDLE HiiHandle OPTIONAL
805 Evaluate the result of a HII expression
807 If Expression is NULL, then ASSERT.
809 @param FormSet FormSet associated with this expression.
810 @param Form Form associated with this expression.
811 @param Expression Expression to be evaluated.
813 @retval EFI_SUCCESS The expression evaluated successfuly
814 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
816 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
818 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
819 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
824 IN FORM_BROWSER_FORMSET
*FormSet
,
825 IN FORM_BROWSER_FORM
*Form
,
826 IN OUT FORM_EXPRESSION
*Expression