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 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
114 #define UI_MENU_LIST_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'l')
120 EFI_HII_HANDLE Handle
;
121 FORM_BROWSER_STATEMENT
*ThisTag
;
128 UINTN Skip
; // Number of lines
131 // Display item sequence for date/time
132 // Date: Month/Day/Year
135 // Time: Hour : Minute : Second
145 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
147 typedef struct _UI_MENU_LIST UI_MENU_LIST
;
149 struct _UI_MENU_LIST
{
153 EFI_GUID FormSetGuid
;
157 UI_MENU_LIST
*Parent
;
158 LIST_ENTRY ChildListHead
;
161 #define UI_MENU_LIST_FROM_LINK(a) CR (a, UI_MENU_LIST, Link, UI_MENU_LIST_SIGNATURE)
163 typedef struct _MENU_REFRESH_ENTRY
{
164 struct _MENU_REFRESH_ENTRY
*Next
;
165 UI_MENU_OPTION
*MenuOption
; // Describes the entry needing an update
166 UI_MENU_SELECTION
*Selection
;
169 UINTN CurrentAttribute
;
170 } MENU_REFRESH_ENTRY
;
174 UI_SCREEN_OPERATION ScreenOperation
;
175 } SCAN_CODE_TO_SCREEN_OPERATION
;
178 UI_SCREEN_OPERATION ScreenOperation
;
179 UI_CONTROL_FLAG ControlFlag
;
180 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
183 extern MENU_REFRESH_ENTRY
*gMenuRefreshHead
;
184 extern UI_MENU_SELECTION
*gCurrentSelection
;
185 extern BOOLEAN mHiiPackageListUpdated
;
191 Initialize Menu option list.
200 Initialize Menu option list.
209 Free Menu option linked list.
218 Create a menu with specified formset GUID and form ID, and add it as a child
219 of the given parent menu.
221 @param Parent The parent of menu to be added.
222 @param FormSetGuid The Formset Guid of menu to be added.
223 @param FormId The Form ID of menu to be added.
225 @return A pointer to the newly added menu or NULL if memory is insufficient.
230 IN OUT UI_MENU_LIST
*Parent
,
231 IN EFI_GUID
*FormSetGuid
,
236 Search Menu with given FormId in the parent menu and all its child menus.
238 @param Parent The parent of menu to search.
239 @param FormId The Form ID of menu to search.
241 @return A pointer to menu found or NULL if not found.
245 UiFindChildMenuList (
246 IN UI_MENU_LIST
*Parent
,
251 Search Menu with given FormSetGuid and FormId in all cached menu list.
253 @param FormSetGuid The Formset GUID of the 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.
261 IN EFI_GUID
*FormSetGuid
,
266 Free Menu option linked list.
275 Add one menu option by specified description and context.
277 @param String String description for this option.
278 @param Handle Hii handle for the package list.
279 @param Statement Statement of this Menu Option.
280 @param NumberOfLines Display lines for this Menu Option.
281 @param MenuItemCount The index for this Option in the Menu.
287 IN EFI_HII_HANDLE Handle
,
288 IN FORM_BROWSER_STATEMENT
*Statement
,
289 IN UINT16 NumberOfLines
,
290 IN UINT16 MenuItemCount
294 Display menu and wait for user to select one menu option, then return it.
295 If AutoBoot is enabled, then if user doesn't select any option,
296 after period of time, it will automatically return the first menu option.
298 @param Selection Menu selection.
300 @return Return the pointer of the menu which selected,
301 @return otherwise return NULL.
306 IN OUT UI_MENU_SELECTION
*Selection
310 Free up the resource allocated for all strings required
320 The worker function that send the displays to the screen. On output,
321 the selection made by user is returned.
323 @param Selection On input, Selection tell setup browser the information
324 about the Selection, form and formset to be displayed.
325 On output, Selection return the screen item that is selected
328 @retval EFI_SUCCESS The page is displayed successfully.
329 @return Other value if the page failed to be diplayed.
334 IN OUT UI_MENU_SELECTION
*Selection
338 VSPrint worker function that prints a Value as a decimal number in Buffer.
340 @param Buffer Location to place ascii decimal number string of Value.
341 @param Flags Flags to use in printing decimal string, see file header for
343 @param Value Decimal value to convert to a string in Buffer.
345 @return Number of characters printed.
356 Set Buffer to Value for Size bytes.
358 @param Buffer Memory to set.
359 @param Size Number of bytes to set
360 @param Value Value of the set operation.
371 Wait for a given event to fire, or for an optional timeout to expire.
373 @param Event The event to wait for
374 @param Timeout An optional timeout value in 100 ns units.
375 @param RefreshInterval Menu refresh interval (in seconds).
377 @retval EFI_SUCCESS Event fired before Timeout expired.
378 @retval EFI_TIME_OUT Timout expired before Event fired.
382 UiWaitForSingleEvent (
384 IN UINT64 Timeout
, OPTIONAL
385 IN UINT8 RefreshInterval OPTIONAL
389 Draw a pop up windows based on the dimension, number of lines and
392 @param ScreenWidth The width of the pop-up.
393 @param NumberOfLines The number of lines.
394 @param ... A series of text strings that displayed in the pop-up.
398 CreateMultiStringPopUp (
399 IN UINTN ScreenWidth
,
400 IN UINTN NumberOfLines
,
405 Get string or password input from user.
407 @param MenuOption Pointer to the current input menu.
408 @param Prompt The prompt string shown on popup window.
409 @param StringPtr Destination for use input string.
411 @retval EFI_SUCCESS If string input is read successfully
412 @retval EFI_DEVICE_ERROR If operation fails
417 IN UI_MENU_OPTION
*MenuOption
,
419 OUT CHAR16
*StringPtr
423 Get selection for OneOf and OrderedList (Left/Right will be ignored).
425 @param Selection Pointer to current selection.
426 @param MenuOption Pointer to the current input menu.
428 @retval EFI_SUCCESS If Option input is processed successfully
429 @retval EFI_DEVICE_ERROR If operation fails
433 GetSelectionInputPopUp (
434 IN UI_MENU_SELECTION
*Selection
,
435 IN UI_MENU_OPTION
*MenuOption
439 This routine reads a numeric value from the user input.
441 @param Selection Pointer to current selection.
442 @param MenuOption Pointer to the current input menu.
444 @retval EFI_SUCCESS If numerical input is read successfully
445 @retval EFI_DEVICE_ERROR If operation fails
450 IN UI_MENU_SELECTION
*Selection
,
451 IN UI_MENU_OPTION
*MenuOption
455 Update status bar on the bottom of menu.
457 @param MessageType The type of message to be shown.
458 @param Flags The flags in Question header.
459 @param State Set or clear.
464 IN UINTN MessageType
,
470 Process Question Config.
472 @param Selection The UI menu selection.
473 @param Question The Question to be peocessed.
475 @retval EFI_SUCCESS Question Config process success.
476 @retval Other Question Config process fail.
480 ProcessQuestionConfig (
481 IN UI_MENU_SELECTION
*Selection
,
482 IN FORM_BROWSER_STATEMENT
*Question
486 Print Question Value according to it's storage width and display attributes.
488 @param Question The Question to be printed.
489 @param FormattedNumber Buffer for output string.
490 @param BufferSize The FormattedNumber buffer size in bytes.
492 @retval EFI_SUCCESS Print success.
493 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
497 PrintFormattedNumber (
498 IN FORM_BROWSER_STATEMENT
*Question
,
499 IN OUT CHAR16
*FormattedNumber
,
504 Search an Option of a Question by its value.
506 @param Question The Question
507 @param OptionValue Value for Option to be searched.
509 @retval Pointer Pointer to the found Option.
510 @retval NULL Option not found.
515 IN FORM_BROWSER_STATEMENT
*Question
,
516 IN EFI_HII_VALUE
*OptionValue
520 Process a Question's Option (whether selected or un-selected).
522 @param Selection Pointer to UI_MENU_SELECTION.
523 @param MenuOption The MenuOption for this Question.
524 @param Selected TRUE: if Question is selected.
525 @param OptionString Pointer of the Option String to be displayed.
527 @retval EFI_SUCCESS Question Option process success.
528 @retval Other Question Option process fail.
533 IN UI_MENU_SELECTION
*Selection
,
534 IN UI_MENU_OPTION
*MenuOption
,
536 OUT CHAR16
**OptionString
540 Process the help string: Split StringPtr to several lines of strings stored in
541 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
543 @param StringPtr The entire help string.
544 @param FormattedString The oupput formatted string.
545 @param RowCount TRUE: if Question is selected.
550 IN CHAR16
*StringPtr
,
551 OUT CHAR16
**FormattedString
,
556 Update key's help imformation.
558 @param MenuOption The Menu option
559 @param Selected Whether or not a tag be selected
564 IN UI_MENU_OPTION
*MenuOption
,
569 Clear retangle with specified text attribute.
571 @param LeftColumn Left column of retangle.
572 @param RightColumn Right column of retangle.
573 @param TopRow Start row of retangle.
574 @param BottomRow End row of retangle.
575 @param TextAttribute The character foreground and background.
588 Count the storage space of a Unicode string.
590 This function handles the Unicode string with NARROW_CHAR
591 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
592 does not count in the resultant output. If a WIDE_CHAR is
593 hit, then 2 Unicode character will consume an output storage
594 space with size of CHAR16 till a NARROW_CHAR is hit.
596 @param String The input string to be counted.
598 @return Storage space for the input string.
607 Will copy LineWidth amount of a string in the OutputString buffer and return the
608 number of CHAR16 characters that were copied into the OutputString buffer.
610 @param InputString String description for this option.
611 @param LineWidth Width of the desired string to extract in CHAR16
613 @param Index Where in InputString to start the copy process
614 @param OutputString Buffer to copy the string into
616 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
621 IN CHAR16
*InputString
,
624 OUT CHAR16
**OutputString
628 Get the supported width for a particular op-code
630 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
631 @param Handle The handle in the HII database being used
633 @return Returns the number of CHAR16 characters that is support.
638 IN FORM_BROWSER_STATEMENT
*Statement
,
639 IN EFI_HII_HANDLE Handle
643 Concatenate a narrow string to another string.
645 @param Destination The destination string.
646 @param Source The source string. The string to be concatenated.
647 to the end of Destination.
657 Wait for a key to be pressed by user.
659 @param Key The key which is pressed by user.
661 @retval EFI_SUCCESS The function always completed successfully.
666 OUT EFI_INPUT_KEY
*Key
670 Reset stack pointer to begin of the stack.
679 Push an Operand onto the Stack
681 @param Operand Operand to push.
683 @retval EFI_SUCCESS The value was pushed onto the stack.
684 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
694 Pop an Operand from the Stack
696 @param Operand Operand to pop.
698 @retval EFI_SUCCESS The value was pushed onto the stack.
699 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
709 Get Form given its FormId.
711 @param FormSet The formset which contains this form.
712 @param FormId Id of this form.
714 @retval Pointer The form.
715 @retval NULL Specified Form is not found in the formset.
720 IN FORM_BROWSER_FORMSET
*FormSet
,
725 Search a Question in Formset scope using its QuestionId.
727 @param FormSet The formset which contains this form.
728 @param Form The form which contains this Question.
729 @param QuestionId Id of this Question.
731 @retval Pointer The Question.
732 @retval NULL Specified Question not found in the form.
735 FORM_BROWSER_STATEMENT
*
737 IN FORM_BROWSER_FORMSET
*FormSet
,
738 IN FORM_BROWSER_FORM
*Form
,
743 Zero extend integer/boolean/date/time to UINT64 for comparing.
745 @param Value HII Value to be converted.
750 IN EFI_HII_VALUE
*Value
754 Compare two Hii value.
756 @param Value1 Expression value to compare on left-hand.
757 @param Value2 Expression value to compare on right-hand.
758 @param HiiHandle Only required for string compare.
760 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
761 @retval 0 Two operators equeal.
762 @return Positive value if Value1 is greater than Value2.
763 @retval Negative value if Value1 is less than Value2.
768 IN EFI_HII_VALUE
*Value1
,
769 IN EFI_HII_VALUE
*Value2
,
770 IN EFI_HII_HANDLE HiiHandle OPTIONAL
774 Evaluate the result of a HII expression
776 If Expression is NULL, then ASSERT.
778 @param FormSet FormSet associated with this expression.
779 @param Form Form associated with this expression.
780 @param Expression Expression to be evaluated.
782 @retval EFI_SUCCESS The expression evaluated successfuly
783 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
785 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
787 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
788 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
793 IN FORM_BROWSER_FORMSET
*FormSet
,
794 IN FORM_BROWSER_FORM
*Form
,
795 IN OUT FORM_EXPRESSION
*Expression