2 Private structure, MACRO and function definitions for User Interface related functionalities.
4 Copyright (c) 2004 - 2008, 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
;
77 #define UI_ACTION_NONE 0
78 #define UI_ACTION_REFRESH_FORM 1
79 #define UI_ACTION_REFRESH_FORMSET 2
80 #define UI_ACTION_EXIT 3
83 EFI_HII_HANDLE Handle
;
86 // Target formset/form/Question information
99 // Ation for Browser to taken:
100 // UI_ACTION_NONE - navigation inside a form
101 // UI_ACTION_REFRESH_FORM - re-evaluate expressions and repaint form
102 // UI_ACTION_REFRESH_FORMSET - re-parse formset IFR binary
107 // Current selected fomset/form/Question
109 FORM_BROWSER_FORMSET
*FormSet
;
110 FORM_BROWSER_FORM
*Form
;
111 FORM_BROWSER_STATEMENT
*Statement
;
114 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
115 #define UI_MENU_LIST_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'l')
121 EFI_HII_HANDLE Handle
;
122 FORM_BROWSER_STATEMENT
*ThisTag
;
129 UINTN Skip
; // Number of lines
132 // Display item sequence for date/time
133 // Date: Month/Day/Year
136 // Time: Hour : Minute : Second
146 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
156 typedef struct _MENU_REFRESH_ENTRY
{
157 struct _MENU_REFRESH_ENTRY
*Next
;
158 UI_MENU_OPTION
*MenuOption
; // Describes the entry needing an update
159 UI_MENU_SELECTION
*Selection
;
162 UINTN CurrentAttribute
;
163 } MENU_REFRESH_ENTRY
;
167 UI_SCREEN_OPERATION ScreenOperation
;
168 } SCAN_CODE_TO_SCREEN_OPERATION
;
171 UI_SCREEN_OPERATION ScreenOperation
;
172 UI_CONTROL_FLAG ControlFlag
;
173 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
176 extern LIST_ENTRY gMenuList
;
177 extern MENU_REFRESH_ENTRY
*gMenuRefreshHead
;
178 extern UI_MENU_SELECTION
*gCurrentSelection
;
179 extern BOOLEAN mHiiPackageListUpdated
;
185 Initialize Menu option list.
194 Initialize Menu option list.
203 Remove a Menu in list, and return FormId/QuestionId for previous Menu.
205 @param Selection Menu selection.
209 UiRemoveMenuListEntry (
210 OUT UI_MENU_SELECTION
*Selection
214 Free Menu option linked list.
223 Add one menu entry to the linked lst
225 @param Selection Menu selection.
230 IN UI_MENU_SELECTION
*Selection
234 Free Menu option linked list.
243 Add one menu option by specified description and context.
245 @param String String description for this option.
246 @param Handle Hii handle for the package list.
247 @param Statement Statement of this Menu Option.
248 @param NumberOfLines Display lines for this Menu Option.
249 @param MenuItemCount The index for this Option in the Menu.
255 IN EFI_HII_HANDLE Handle
,
256 IN FORM_BROWSER_STATEMENT
*Statement
,
257 IN UINT16 NumberOfLines
,
258 IN UINT16 MenuItemCount
262 Display menu and wait for user to select one menu option, then return it.
263 If AutoBoot is enabled, then if user doesn't select any option,
264 after period of time, it will automatically return the first menu option.
266 @param Selection Menu selection.
268 @return Return the pointer of the menu which selected,
269 @return otherwise return NULL.
274 IN OUT UI_MENU_SELECTION
*Selection
278 Free up the resource allocated for all strings required
288 The worker function that send the displays to the screen. On output,
289 the selection made by user is returned.
291 @param Selection On input, Selection tell setup browser the information
292 about the Selection, form and formset to be displayed.
293 On output, Selection return the screen item that is selected
296 @retval EFI_SUCCESS The page is displayed successfully.
297 @return Other value if the page failed to be diplayed.
302 IN OUT UI_MENU_SELECTION
*Selection
306 VSPrint worker function that prints a Value as a decimal number in Buffer.
308 @param Buffer Location to place ascii decimal number string of Value.
309 @param Flags Flags to use in printing decimal string, see file header for
311 @param Value Decimal value to convert to a string in Buffer.
313 @return Number of characters printed.
324 Set Buffer to Value for Size bytes.
326 @param Buffer Memory to set.
327 @param Size Number of bytes to set
328 @param Value Value of the set operation.
339 Wait for a given event to fire, or for an optional timeout to expire.
341 @param Event The event to wait for
342 @param Timeout An optional timeout value in 100 ns units.
343 @param RefreshInterval Menu refresh interval (in seconds).
345 @retval EFI_SUCCESS Event fired before Timeout expired.
346 @retval EFI_TIME_OUT Timout expired before Event fired.
350 UiWaitForSingleEvent (
352 IN UINT64 Timeout
, OPTIONAL
353 IN UINT8 RefreshInterval OPTIONAL
357 Draw a pop up windows based on the dimension, number of lines and
360 @param ScreenWidth The width of the pop-up.
361 @param NumberOfLines The number of lines.
362 @param ... A series of text strings that displayed in the pop-up.
367 IN UINTN ScreenWidth
,
368 IN UINTN NumberOfLines
,
373 Get string or password input from user.
375 @param MenuOption Pointer to the current input menu.
376 @param Prompt The prompt string shown on popup window.
377 @param StringPtr Destination for use input string.
379 @retval EFI_SUCCESS If string input is read successfully
380 @retval EFI_DEVICE_ERROR If operation fails
385 IN UI_MENU_OPTION
*MenuOption
,
387 OUT CHAR16
*StringPtr
391 Get selection for OneOf and OrderedList (Left/Right will be ignored).
393 @param Selection Pointer to current selection.
394 @param MenuOption Pointer to the current input menu.
396 @retval EFI_SUCCESS If Option input is processed successfully
397 @retval EFI_DEVICE_ERROR If operation fails
401 GetSelectionInputPopUp (
402 IN UI_MENU_SELECTION
*Selection
,
403 IN UI_MENU_OPTION
*MenuOption
407 This routine reads a numeric value from the user input.
409 @param Selection Pointer to current selection.
410 @param MenuOption Pointer to the current input menu.
412 @retval EFI_SUCCESS If numerical input is read successfully
413 @retval EFI_DEVICE_ERROR If operation fails
418 IN UI_MENU_SELECTION
*Selection
,
419 IN UI_MENU_OPTION
*MenuOption
423 Update status bar on the bottom of menu.
425 @param MessageType The type of message to be shown.
426 @param Flags The flags in Question header.
427 @param State Set or clear.
432 IN UINTN MessageType
,
438 Process Question Config.
440 @param Selection The UI menu selection.
441 @param Question The Question to be peocessed.
443 @retval EFI_SUCCESS Question Config process success.
444 @retval Other Question Config process fail.
448 ProcessQuestionConfig (
449 IN UI_MENU_SELECTION
*Selection
,
450 IN FORM_BROWSER_STATEMENT
*Question
454 Print Question Value according to it's storage width and display attributes.
456 @param Question The Question to be printed.
457 @param FormattedNumber Buffer for output string.
458 @param BufferSize The FormattedNumber buffer size in bytes.
460 @retval EFI_SUCCESS Print success.
461 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
465 PrintFormattedNumber (
466 IN FORM_BROWSER_STATEMENT
*Question
,
467 IN OUT CHAR16
*FormattedNumber
,
472 Search an Option of a Question by its value.
474 @param Question The Question
475 @param OptionValue Value for Option to be searched.
477 @retval Pointer Pointer to the found Option.
478 @retval NULL Option not found.
483 IN FORM_BROWSER_STATEMENT
*Question
,
484 IN EFI_HII_VALUE
*OptionValue
488 Process a Question's Option (whether selected or un-selected).
490 @param Selection Pointer to UI_MENU_SELECTION.
491 @param MenuOption The MenuOption for this Question.
492 @param Selected TRUE: if Question is selected.
493 @param OptionString Pointer of the Option String to be displayed.
495 @retval EFI_SUCCESS Question Option process success.
496 @retval Other Question Option process fail.
501 IN UI_MENU_SELECTION
*Selection
,
502 IN UI_MENU_OPTION
*MenuOption
,
504 OUT CHAR16
**OptionString
508 Process the help string: Split StringPtr to several lines of strings stored in
509 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
511 @param StringPtr The entire help string.
512 @param FormattedString The oupput formatted string.
513 @param RowCount TRUE: if Question is selected.
518 IN CHAR16
*StringPtr
,
519 OUT CHAR16
**FormattedString
,
524 Update key's help imformation.
526 @param MenuOption The Menu option
527 @param Selected Whether or not a tag be selected
532 IN UI_MENU_OPTION
*MenuOption
,
537 Clear retangle with specified text attribute.
539 @param LeftColumn Left column of retangle.
540 @param RightColumn Right column of retangle.
541 @param TopRow Start row of retangle.
542 @param BottomRow End row of retangle.
543 @param TextAttribute The character foreground and background.
556 Count the storage space of a Unicode string.
558 This function handles the Unicode string with NARROW_CHAR
559 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
560 does not count in the resultant output. If a WIDE_CHAR is
561 hit, then 2 Unicode character will consume an output storage
562 space with size of CHAR16 till a NARROW_CHAR is hit.
564 @param String The input string to be counted.
566 @return Storage space for the input string.
575 Will copy LineWidth amount of a string in the OutputString buffer and return the
576 number of CHAR16 characters that were copied into the OutputString buffer.
578 @param InputString String description for this option.
579 @param LineWidth Width of the desired string to extract in CHAR16
581 @param Index Where in InputString to start the copy process
582 @param OutputString Buffer to copy the string into
584 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
589 IN CHAR16
*InputString
,
592 OUT CHAR16
**OutputString
596 Get the supported width for a particular op-code
598 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
599 @param Handle The handle in the HII database being used
601 @return Returns the number of CHAR16 characters that is support.
606 IN FORM_BROWSER_STATEMENT
*Statement
,
607 IN EFI_HII_HANDLE Handle
611 Concatenate a narrow string to another string.
613 @param Destination The destination string.
614 @param Source The source string. The string to be concatenated.
615 to the end of Destination.
625 Wait for a key to be pressed by user.
627 @param Key The key which is pressed by user.
629 @retval EFI_SUCCESS The function always completed successfully.
634 OUT EFI_INPUT_KEY
*Key
638 Reset stack pointer to begin of the stack.
647 Push an Operand onto the Stack
649 @param Operand Operand to push.
651 @retval EFI_SUCCESS The value was pushed onto the stack.
652 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
662 Pop an Operand from the Stack
664 @param Operand Operand to pop.
666 @retval EFI_SUCCESS The value was pushed onto the stack.
667 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
677 Get Form given its FormId.
679 @param FormSet The formset which contains this form.
680 @param FormId Id of this form.
682 @retval Pointer The form.
683 @retval NULL Specified Form is not found in the formset.
688 IN FORM_BROWSER_FORMSET
*FormSet
,
693 Search a Question in Formset scope using its QuestionId.
695 @param FormSet The formset which contains this form.
696 @param Form The form which contains this Question.
697 @param QuestionId Id of this Question.
699 @retval Pointer The Question.
700 @retval NULL Specified Question not found in the form.
703 FORM_BROWSER_STATEMENT
*
705 IN FORM_BROWSER_FORMSET
*FormSet
,
706 IN FORM_BROWSER_FORM
*Form
,
711 Zero extend integer/boolean/date/time to UINT64 for comparing.
713 @param Value HII Value to be converted.
718 IN EFI_HII_VALUE
*Value
722 Compare two Hii value.
724 @param Value1 Expression value to compare on left-hand.
725 @param Value2 Expression value to compare on right-hand.
726 @param HiiHandle Only required for string compare.
728 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
729 @retval 0 Two operators equeal.
730 @return Positive value if Value1 is greater than Value2.
731 @retval Negative value if Value1 is less than Value2.
736 IN EFI_HII_VALUE
*Value1
,
737 IN EFI_HII_VALUE
*Value2
,
738 IN EFI_HII_HANDLE HiiHandle OPTIONAL
742 Evaluate the result of a HII expression
744 If Expression is NULL, then ASSERT.
746 @param FormSet FormSet associated with this expression.
747 @param Form Form associated with this expression.
748 @param Expression Expression to be evaluated.
750 @retval EFI_SUCCESS The expression evaluated successfuly
751 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
753 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
755 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
756 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
761 IN FORM_BROWSER_FORMSET
*FormSet
,
762 IN FORM_BROWSER_FORM
*Form
,
763 IN OUT FORM_EXPRESSION
*Expression