2 FormDiplay protocol to show Form
4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __FORM_DISPLAY_H__
10 #define __FORM_DISPLAY_H__
12 #include <Library/UefiBootServicesTableLib.h>
13 #include <Library/DebugLib.h>
14 #include <Library/BaseMemoryLib.h>
15 #include <Library/BaseLib.h>
16 #include <Library/HiiLib.h>
17 #include <Library/MemoryAllocationLib.h>
18 #include <Library/PrintLib.h>
19 #include <Library/CustomizedDisplayLib.h>
21 #include <Protocol/FormBrowserEx2.h>
22 #include <Protocol/SimpleTextIn.h>
23 #include <Protocol/DisplayProtocol.h>
24 #include <Protocol/HiiPopup.h>
26 #include <Guid/MdeModuleHii.h>
29 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
31 extern UINT8 DisplayEngineStrings
[];
32 extern EFI_SCREEN_DESCRIPTOR gStatementDimensions
;
33 extern USER_INPUT
*gUserInput
;
34 extern FORM_DISPLAY_ENGINE_FORM
*gFormData
;
35 extern EFI_HII_HANDLE gHiiHandle
;
36 extern UINT16 gDirection
;
37 extern LIST_ENTRY gMenuOption
;
38 extern CHAR16
*gConfirmOptYes
;
39 extern CHAR16
*gConfirmOptNo
;
40 extern CHAR16
*gConfirmOptOk
;
41 extern CHAR16
*gConfirmOptCancel
;
42 extern CHAR16
*gYesOption
;
43 extern CHAR16
*gNoOption
;
44 extern CHAR16
*gOkOption
;
45 extern CHAR16
*gCancelOption
;
46 extern CHAR16
*gErrorPopup
;
47 extern CHAR16
*gWarningPopup
;
48 extern CHAR16
*gInfoPopup
;
51 // Browser Global Strings
53 extern CHAR16
*gSaveFailed
;
54 extern CHAR16
*gPromptForData
;
55 extern CHAR16
*gPromptForPassword
;
56 extern CHAR16
*gPromptForNewPassword
;
57 extern CHAR16
*gConfirmPassword
;
58 extern CHAR16
*gConfirmError
;
59 extern CHAR16
*gPassowordInvalid
;
60 extern CHAR16
*gPressEnter
;
61 extern CHAR16
*gEmptyString
;
62 extern CHAR16
*gMiniString
;
63 extern CHAR16
*gOptionMismatch
;
64 extern CHAR16
*gFormSuppress
;
65 extern CHAR16
*gProtocolNotFound
;
66 extern CHAR16
*gPasswordUnsupported
;
68 extern CHAR16 gPromptBlockWidth
;
69 extern CHAR16 gOptionBlockWidth
;
70 extern CHAR16 gHelpBlockWidth
;
71 extern CHAR16
*mUnknownString
;
72 extern BOOLEAN gMisMatch
;
78 #define LEFT_SKIPPED_COLUMNS 3
79 #define SCROLL_ARROW_HEIGHT 1
80 #define POPUP_PAD_SPACE_COUNT 5
81 #define POPUP_FRAME_WIDTH 2
83 #define UPPER_LOWER_CASE_OFFSET 0x20
86 // Display definitions
88 #define LEFT_ONEOF_DELIMITER L'<'
89 #define RIGHT_ONEOF_DELIMITER L'>'
91 #define LEFT_NUMERIC_DELIMITER L'['
92 #define RIGHT_NUMERIC_DELIMITER L']'
94 #define LEFT_CHECKBOX_DELIMITER L'['
95 #define RIGHT_CHECKBOX_DELIMITER L']'
98 #define CHECK_OFF L' '
100 #define TIME_SEPARATOR L':'
101 #define DATE_SEPARATOR L'/'
103 #define SUBTITLE_INDENT 2
106 // This is the Input Error Message
108 #define INPUT_ERROR 1
111 // This is the NV RAM update required Message
113 #define NV_UPDATE_REQUIRED 2
117 #define ONE_SECOND 10000000
120 // It take 23 characters including the NULL to print a 64 bits number with "[" and "]".
121 // pow(2, 64) = [18446744073709551616]
122 // with extra '-' flat, set the width to 24.
124 #define MAX_NUMERIC_INPUT_WIDTH 24
126 #define EFI_HII_EXPRESSION_INCONSISTENT_IF 0
127 #define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1
128 #define EFI_HII_EXPRESSION_GRAY_OUT_IF 2
129 #define EFI_HII_EXPRESSION_SUPPRESS_IF 3
130 #define EFI_HII_EXPRESSION_DISABLE_IF 4
133 // Character definitions
135 #define CHAR_SPACE 0x0020
137 #define FORM_DISPLAY_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'D', 'D', 'V')
146 EDKII_FORM_DISPLAY_ENGINE_PROTOCOL FromDisplayProt
;
147 EFI_HII_POPUP_PROTOCOL HiiPopup
;
148 } FORM_DISPLAY_DRIVER_PRIVATE_DATA
;
163 } UI_SCREEN_OPERATION
;
197 UI_SCREEN_OPERATION ScreenOperation
;
198 } SCAN_CODE_TO_SCREEN_OPERATION
;
201 UI_SCREEN_OPERATION ScreenOperation
;
202 UI_CONTROL_FLAG ControlFlag
;
203 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
206 EFI_HII_HANDLE HiiHandle
;
210 // Info for the highlight question.
211 // HLT means highlight
213 // If one statement has questionid, save questionid info to find the question.
214 // If one statement not has questionid info, save the opcode info to find the
215 // statement. If more than one statement has same opcode in one form(just like
216 // empty subtitle info may has more than one info one form), also use Index
217 // info to find the statement.
219 EFI_QUESTION_ID HLTQuestionId
;
220 EFI_IFR_OP_HEADER
*HLTOpCode
;
225 // Info for the top of screen question.
226 // TOS means Top Of Screen
228 EFI_QUESTION_ID TOSQuestionId
;
229 EFI_IFR_OP_HEADER
*TOSOpCode
;
233 } DISPLAY_HIGHLIGHT_MENU_INFO
;
239 } WARNING_IF_CONTEXT
;
241 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
247 EFI_HII_HANDLE Handle
;
248 FORM_DISPLAY_ENGINE_STATEMENT
*ThisTag
;
255 UINTN Skip
; // Number of lines
258 // Display item sequence for date/time
259 // Date: Month/Day/Year
262 // Time: Hour : Minute : Second
272 // Whether user could change value of this item
275 BOOLEAN NestInStatement
;
278 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
280 #define USER_SELECTABLE_OPTION_OK_WIDTH StrLen (gOkOption)
281 #define USER_SELECTABLE_OPTION_OK_CAL_WIDTH (StrLen (gOkOption) + StrLen (gCancelOption))
282 #define USER_SELECTABLE_OPTION_YES_NO_WIDTH (StrLen (gYesOption) + StrLen (gNoOption))
283 #define USER_SELECTABLE_OPTION_YES_NO_CAL_WIDTH (StrLen (gYesOption) + StrLen (gNoOption) + StrLen (gCancelOption))
285 #define USER_SELECTABLE_OPTION_SKIP_WIDTH 2
288 // +-------------------------------------------+ // POPUP_BORDER }
289 // | ERROR/WARNING/INFO | // POPUP_STYLE_STRING_HEIGHT } POPUP_HEADER_HEIGHT
290 // |-------------------------------------------| // POPUP_EMPTY_LINE_HEIGHT }
291 // | popup messages |
292 // | | // POPUP_EMPTY_LINE_HEIGHT }
293 // | user selectable options | // POPUP_USER_SELECTABLE_OPTION_HEIGHT } POPUP_FOOTER_HEIGHT
294 // +-------------------------------------------+ // POPUP_BORDER }
296 #define POPUP_BORDER 1
297 #define POPUP_EMPTY_LINE_HEIGHT 1
298 #define POPUP_STYLE_STRING_HEIGHT 1
299 #define POPUP_USER_SELECTABLE_OPTION_HEIGHT 1
301 #define POPUP_HEADER_HEIGHT (POPUP_BORDER + POPUP_STYLE_STRING_HEIGHT + POPUP_EMPTY_LINE_HEIGHT)
302 #define POPUP_FOOTER_HEIGHT (POPUP_EMPTY_LINE_HEIGHT + POPUP_USER_SELECTABLE_OPTION_HEIGHT + POPUP_BORDER)
304 #define USER_SELECTABLE_OPTION_SIGNATURE SIGNATURE_32 ('u', 's', 's', 'o')
309 EFI_HII_POPUP_SELECTION OptionType
;
310 CHAR16
*OptionString
;
312 // Display item sequence for user select options
316 // Ok/Cancel: Ok : Cancel
322 // Yes/No/Cancel: Yes : No: Cancel
330 } USER_SELECTABLE_OPTION
;
332 #define SELECTABLE_OPTION_FROM_LINK(a) CR (a, USER_SELECTABLE_OPTION, Link, USER_SELECTABLE_OPTION_SIGNATURE)
335 Print Question Value according to it's storage width and display attributes.
337 @param Question The Question to be printed.
338 @param FormattedNumber Buffer for output string.
339 @param BufferSize The FormattedNumber buffer size in bytes.
341 @retval EFI_SUCCESS Print success.
342 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
346 PrintFormattedNumber (
347 IN FORM_DISPLAY_ENGINE_STATEMENT
*Question
,
348 IN OUT CHAR16
*FormattedNumber
,
353 Set value of a data element in an Array by its Index.
355 @param Array The data array.
356 @param Type Type of the data in this array.
357 @param Index Zero based index for data in this array.
358 @param Value The value to be set.
370 Return data element in an Array by its Index.
372 @param Array The data array.
373 @param Type Type of the data in this array.
374 @param Index Zero based index for data in this array.
376 @retval Value The data to be returned
387 Search an Option of a Question by its value.
389 @param Question The Question
390 @param OptionValue Value for Option to be searched.
392 @retval Pointer Pointer to the found Option.
393 @retval NULL Option not found.
396 DISPLAY_QUESTION_OPTION
*
398 IN FORM_DISPLAY_ENGINE_STATEMENT
*Question
,
399 IN EFI_HII_VALUE
*OptionValue
403 Compare two Hii value.
405 @param Value1 Expression value to compare on left-hand.
406 @param Value2 Expression value to compare on right-hand.
407 @param Result Return value after compare.
408 retval 0 Two operators equal.
409 return Positive value if Value1 is greater than Value2.
410 retval Negative value if Value1 is less than Value2.
411 @param HiiHandle Only required for string compare.
413 @retval other Could not perform compare on two values.
414 @retval EFI_SUCCESS Compare the value success.
419 IN EFI_HII_VALUE
*Value1
,
420 IN EFI_HII_VALUE
*Value2
,
422 IN EFI_HII_HANDLE HiiHandle OPTIONAL
426 Draw a pop up windows based on the dimension, number of lines and
429 @param RequestedWidth The width of the pop-up.
430 @param NumberOfLines The number of lines.
431 @param ... A series of text strings that displayed in the pop-up.
436 CreateMultiStringPopUp (
437 IN UINTN RequestedWidth
,
438 IN UINTN NumberOfLines
,
443 Will copy LineWidth amount of a string in the OutputString buffer and return the
444 number of CHAR16 characters that were copied into the OutputString buffer.
445 The output string format is:
446 Glyph Info + String info + '\0'.
448 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
450 @param InputString String description for this option.
451 @param LineWidth Width of the desired string to extract in CHAR16
453 @param GlyphWidth The glyph width of the begin of the char in the string.
454 @param Index Where in InputString to start the copy process
455 @param OutputString Buffer to copy the string into
457 @return Returns the number of CHAR16 characters that were copied into the OutputString
458 buffer, include extra glyph info and '\0' info.
463 IN CHAR16
*InputString
,
465 IN OUT UINT16
*GlyphWidth
,
467 OUT CHAR16
**OutputString
471 Get the string based on the StringId and HII Package List Handle.
473 @param Token The String's ID.
474 @param HiiHandle The Hii handle for this string package.
476 @return The output string.
481 IN EFI_STRING_ID Token
,
482 IN EFI_HII_HANDLE HiiHandle
486 Count the storage space of a Unicode string.
488 This function handles the Unicode string with NARROW_CHAR
489 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
490 does not count in the resultant output. If a WIDE_CHAR is
491 hit, then 2 Unicode character will consume an output storage
492 space with size of CHAR16 till a NARROW_CHAR is hit.
494 If String is NULL, then ASSERT ().
496 @param String The input string to be counted.
498 @return Storage space for the input string.
507 This routine reads a numeric value from the user input.
509 @param MenuOption Pointer to the current input menu.
511 @retval EFI_SUCCESS If numerical input is read successfully
512 @retval EFI_DEVICE_ERROR If operation fails
517 IN UI_MENU_OPTION
*MenuOption
521 Get string or password input from user.
523 @param MenuOption Pointer to the current input menu.
524 @param Prompt The prompt string shown on popup window.
525 @param StringPtr Old user input and destination for use input string.
527 @retval EFI_SUCCESS If string input is read successfully
528 @retval EFI_DEVICE_ERROR If operation fails
533 IN UI_MENU_OPTION
*MenuOption
,
535 IN OUT CHAR16
*StringPtr
539 Draw a pop up windows based on the dimension, number of lines and
542 @param RequestedWidth The width of the pop-up.
543 @param NumberOfLines The number of lines.
544 @param Marker The variable argument list for the list of string to be printed.
549 IN UINTN RequestedWidth
,
550 IN UINTN NumberOfLines
,
555 Wait for a key to be pressed by user.
557 @param Key The key which is pressed by user.
559 @retval EFI_SUCCESS The function always completed successfully.
564 OUT EFI_INPUT_KEY
*Key
568 Get selection for OneOf and OrderedList (Left/Right will be ignored).
570 @param MenuOption Pointer to the current input menu.
572 @retval EFI_SUCCESS If Option input is processed successfully
573 @retval EFI_DEVICE_ERROR If operation fails
577 GetSelectionInputPopUp (
578 IN UI_MENU_OPTION
*MenuOption
582 Process the help string: Split StringPtr to several lines of strings stored in
583 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
585 @param StringPtr The entire help string.
586 @param FormattedString The oupput formatted string.
587 @param EachLineWidth The max string length of each line in the formatted string.
588 @param RowCount TRUE: if Question is selected.
593 IN CHAR16
*StringPtr
,
594 OUT CHAR16
**FormattedString
,
595 OUT UINT16
*EachLineWidth
,
600 Process a Question's Option (whether selected or un-selected).
602 @param MenuOption The MenuOption for this Question.
603 @param Selected TRUE: if Question is selected.
604 @param OptionString Pointer of the Option String to be displayed.
605 @param SkipErrorValue Whether need to return when value without option for it.
607 @retval EFI_SUCCESS Question Option process success.
608 @retval Other Question Option process fail.
613 IN UI_MENU_OPTION
*MenuOption
,
615 OUT CHAR16
**OptionString
,
616 IN BOOLEAN SkipErrorValue
620 Set Buffer to Value for Size bytes.
622 @param Buffer Memory to set.
623 @param Size Number of bytes to set
624 @param Value Value of the set operation.
635 Display one form, and return user input.
637 @param FormData Form Data to be shown.
638 @param UserInputData User input data.
640 @retval EFI_SUCCESS Form Data is shown, and user input is got.
645 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
646 OUT USER_INPUT
*UserInputData
650 Clear Screen to the initial state.
654 DriverClearDisplayPage (
659 Exit Display and Clear Screen to the original state.
671 @param Event The Event need to be process
672 @param Context The context of the event.
683 Process for the refresh interval statement.
685 @param Event The Event need to be process
686 @param Context The context of the event.
691 RefreshTimeOutProcess (
697 Record the highlight menu and top of screen menu info.
699 @param Highlight The menu opton which is highlight.
700 @param TopOfScreen The menu opton which is at the top of the form.
701 @param SkipValue The skip line info for the top of screen menu.
705 UpdateHighlightMenuInfo (
706 IN LIST_ENTRY
*Highlight
,
707 IN LIST_ENTRY
*TopOfScreen
,
712 Displays a popup window.
714 @param This A pointer to the EFI_HII_POPUP_PROTOCOL instance.
715 @param PopupStyle Popup style to use.
716 @param PopupType Type of the popup to display.
717 @param HiiHandle HII handle of the string pack containing Message
718 @param Message A message to display in the popup box.
719 @param UserSelection User selection.
721 @retval EFI_SUCCESS The popup box was successfully displayed.
722 @retval EFI_INVALID_PARAMETER HiiHandle and Message do not define a valid HII string.
723 @retval EFI_INVALID_PARAMETER PopupType is not one of the values defined by this specification.
724 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to display the popup box.
730 IN EFI_HII_POPUP_PROTOCOL
*This
,
731 IN EFI_HII_POPUP_STYLE PopupStyle
,
732 IN EFI_HII_POPUP_TYPE PopupType
,
733 IN EFI_HII_HANDLE HiiHandle
,
734 IN EFI_STRING_ID Message
,
735 OUT EFI_HII_POPUP_SELECTION
*UserSelection OPTIONAL