]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / FormDisplay.h
1 /** @file
2 FormDiplay protocol to show Form
3
4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef __FORM_DISPLAY_H__
10 #define __FORM_DISPLAY_H__
11
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>
20
21 #include <Protocol/FormBrowserEx2.h>
22 #include <Protocol/SimpleTextIn.h>
23 #include <Protocol/DisplayProtocol.h>
24 #include <Protocol/HiiPopup.h>
25
26 #include <Guid/MdeModuleHii.h>
27
28 //
29 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
30 //
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;
49
50 //
51 // Browser Global Strings
52 //
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;
67
68 extern CHAR16 gPromptBlockWidth;
69 extern CHAR16 gOptionBlockWidth;
70 extern CHAR16 gHelpBlockWidth;
71 extern CHAR16 *mUnknownString;
72 extern BOOLEAN gMisMatch;
73
74 //
75 // Screen definitions
76 //
77
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
82
83 #define UPPER_LOWER_CASE_OFFSET 0x20
84
85 //
86 // Display definitions
87 //
88 #define LEFT_ONEOF_DELIMITER L'<'
89 #define RIGHT_ONEOF_DELIMITER L'>'
90
91 #define LEFT_NUMERIC_DELIMITER L'['
92 #define RIGHT_NUMERIC_DELIMITER L']'
93
94 #define LEFT_CHECKBOX_DELIMITER L'['
95 #define RIGHT_CHECKBOX_DELIMITER L']'
96
97 #define CHECK_ON L'X'
98 #define CHECK_OFF L' '
99
100 #define TIME_SEPARATOR L':'
101 #define DATE_SEPARATOR L'/'
102
103 #define SUBTITLE_INDENT 2
104
105 //
106 // This is the Input Error Message
107 //
108 #define INPUT_ERROR 1
109
110 //
111 // This is the NV RAM update required Message
112 //
113 #define NV_UPDATE_REQUIRED 2
114 //
115 // Time definitions
116 //
117 #define ONE_SECOND 10000000
118
119 //
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.
123 //
124 #define MAX_NUMERIC_INPUT_WIDTH 24
125
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
131
132 //
133 // Character definitions
134 //
135 #define CHAR_SPACE 0x0020
136
137 #define FORM_DISPLAY_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'D', 'D', 'V')
138 typedef struct {
139 UINT32 Signature;
140
141 EFI_HANDLE Handle;
142
143 //
144 // Produced protocol
145 //
146 EDKII_FORM_DISPLAY_ENGINE_PROTOCOL FromDisplayProt;
147 EFI_HII_POPUP_PROTOCOL HiiPopup;
148 } FORM_DISPLAY_DRIVER_PRIVATE_DATA;
149
150 typedef enum {
151 UiNoOperation,
152 UiSelect,
153 UiUp,
154 UiDown,
155 UiLeft,
156 UiRight,
157 UiReset,
158 UiPrevious,
159 UiPageUp,
160 UiPageDown,
161 UiHotKey,
162 UiMaxOperation
163 } UI_SCREEN_OPERATION;
164
165 typedef enum {
166 CfInitialization,
167 CfCheckSelection,
168 CfRepaint,
169 CfRefreshHighLight,
170 CfUpdateHelpString,
171 CfPrepareToReadKey,
172 CfReadKey,
173 CfScreenOperation,
174 CfUiSelect,
175 CfUiReset,
176 CfUiLeft,
177 CfUiRight,
178 CfUiUp,
179 CfUiPageUp,
180 CfUiPageDown,
181 CfUiDown,
182 CfUiNoOperation,
183 CfExit,
184 CfUiHotKey,
185 CfMaxControlFlag
186 } UI_CONTROL_FLAG;
187
188 typedef enum {
189 UIEventNone,
190 UIEventKey,
191 UIEventTimeOut,
192 UIEventDriver
193 } UI_EVENT_TYPE;
194
195 typedef struct {
196 UINT16 ScanCode;
197 UI_SCREEN_OPERATION ScreenOperation;
198 } SCAN_CODE_TO_SCREEN_OPERATION;
199
200 typedef struct {
201 UI_SCREEN_OPERATION ScreenOperation;
202 UI_CONTROL_FLAG ControlFlag;
203 } SCREEN_OPERATION_T0_CONTROL_FLAG;
204
205 typedef struct {
206 EFI_HII_HANDLE HiiHandle;
207 UINT16 FormId;
208
209 //
210 // Info for the highlight question.
211 // HLT means highlight
212 //
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.
218 //
219 EFI_QUESTION_ID HLTQuestionId;
220 EFI_IFR_OP_HEADER *HLTOpCode;
221 UINTN HLTIndex;
222 UINTN HLTSequence;
223
224 //
225 // Info for the top of screen question.
226 // TOS means Top Of Screen
227 //
228 EFI_QUESTION_ID TOSQuestionId;
229 EFI_IFR_OP_HEADER *TOSOpCode;
230 UINTN TOSIndex;
231
232 UINT16 SkipValue;
233 } DISPLAY_HIGHLIGHT_MENU_INFO;
234
235 typedef struct {
236 EFI_EVENT SyncEvent;
237 UINT8 *TimeOut;
238 CHAR16 *ErrorInfo;
239 } WARNING_IF_CONTEXT;
240
241 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
242
243 typedef struct {
244 UINTN Signature;
245 LIST_ENTRY Link;
246
247 EFI_HII_HANDLE Handle;
248 FORM_DISPLAY_ENGINE_STATEMENT *ThisTag;
249 UINT16 EntryNumber;
250
251 UINTN Row;
252 UINTN Col;
253 UINTN OptCol;
254 CHAR16 *Description;
255 UINTN Skip; // Number of lines
256
257 //
258 // Display item sequence for date/time
259 // Date: Month/Day/Year
260 // Sequence: 0 1 2
261 //
262 // Time: Hour : Minute : Second
263 // Sequence: 0 1 2
264 //
265 //
266 UINTN Sequence;
267
268 BOOLEAN GrayOut;
269 BOOLEAN ReadOnly;
270
271 //
272 // Whether user could change value of this item
273 //
274 BOOLEAN IsQuestion;
275 BOOLEAN NestInStatement;
276 } UI_MENU_OPTION;
277
278 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
279
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))
284
285 #define USER_SELECTABLE_OPTION_SKIP_WIDTH 2
286
287 //
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 }
295 //
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
300
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)
303
304 #define USER_SELECTABLE_OPTION_SIGNATURE SIGNATURE_32 ('u', 's', 's', 'o')
305
306 typedef struct {
307 UINTN Signature;
308 LIST_ENTRY Link;
309 EFI_HII_POPUP_SELECTION OptionType;
310 CHAR16 *OptionString;
311 //
312 // Display item sequence for user select options
313 // Ok: Ok
314 // Sequence: 0
315 //
316 // Ok/Cancel: Ok : Cancel
317 // Sequence: 0 1
318 //
319 // Yes/No: Yes : No
320 // Sequence: 0 1
321 //
322 // Yes/No/Cancel: Yes : No: Cancel
323 // Sequence: 0 1 2
324 //
325 UINTN Sequence;
326 UINTN OptionRow;
327 UINTN OptionCol;
328 UINTN MaxSequence;
329 UINTN MinSequence;
330 } USER_SELECTABLE_OPTION;
331
332 #define SELECTABLE_OPTION_FROM_LINK(a) CR (a, USER_SELECTABLE_OPTION, Link, USER_SELECTABLE_OPTION_SIGNATURE)
333
334 /**
335 Print Question Value according to it's storage width and display attributes.
336
337 @param Question The Question to be printed.
338 @param FormattedNumber Buffer for output string.
339 @param BufferSize The FormattedNumber buffer size in bytes.
340
341 @retval EFI_SUCCESS Print success.
342 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
343
344 **/
345 EFI_STATUS
346 PrintFormattedNumber (
347 IN FORM_DISPLAY_ENGINE_STATEMENT *Question,
348 IN OUT CHAR16 *FormattedNumber,
349 IN UINTN BufferSize
350 );
351
352 /**
353 Set value of a data element in an Array by its Index.
354
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.
359
360 **/
361 VOID
362 SetArrayData (
363 IN VOID *Array,
364 IN UINT8 Type,
365 IN UINTN Index,
366 IN UINT64 Value
367 );
368
369 /**
370 Return data element in an Array by its Index.
371
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.
375
376 @retval Value The data to be returned
377
378 **/
379 UINT64
380 GetArrayData (
381 IN VOID *Array,
382 IN UINT8 Type,
383 IN UINTN Index
384 );
385
386 /**
387 Search an Option of a Question by its value.
388
389 @param Question The Question
390 @param OptionValue Value for Option to be searched.
391
392 @retval Pointer Pointer to the found Option.
393 @retval NULL Option not found.
394
395 **/
396 DISPLAY_QUESTION_OPTION *
397 ValueToOption (
398 IN FORM_DISPLAY_ENGINE_STATEMENT *Question,
399 IN EFI_HII_VALUE *OptionValue
400 );
401
402 /**
403 Compare two Hii value.
404
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.
412
413 @retval other Could not perform compare on two values.
414 @retval EFI_SUCCESS Compare the value success.
415
416 **/
417 EFI_STATUS
418 CompareHiiValue (
419 IN EFI_HII_VALUE *Value1,
420 IN EFI_HII_VALUE *Value2,
421 OUT INTN *Result,
422 IN EFI_HII_HANDLE HiiHandle OPTIONAL
423 );
424
425 /**
426 Draw a pop up windows based on the dimension, number of lines and
427 strings specified.
428
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.
432
433 **/
434 VOID
435 EFIAPI
436 CreateMultiStringPopUp (
437 IN UINTN RequestedWidth,
438 IN UINTN NumberOfLines,
439 ...
440 );
441
442 /**
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'.
447
448 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
449
450 @param InputString String description for this option.
451 @param LineWidth Width of the desired string to extract in CHAR16
452 characters
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
456
457 @return Returns the number of CHAR16 characters that were copied into the OutputString
458 buffer, include extra glyph info and '\0' info.
459
460 **/
461 UINT16
462 GetLineByWidth (
463 IN CHAR16 *InputString,
464 IN UINT16 LineWidth,
465 IN OUT UINT16 *GlyphWidth,
466 IN OUT UINTN *Index,
467 OUT CHAR16 **OutputString
468 );
469
470 /**
471 Get the string based on the StringId and HII Package List Handle.
472
473 @param Token The String's ID.
474 @param HiiHandle The Hii handle for this string package.
475
476 @return The output string.
477
478 **/
479 CHAR16 *
480 GetToken (
481 IN EFI_STRING_ID Token,
482 IN EFI_HII_HANDLE HiiHandle
483 );
484
485 /**
486 Count the storage space of a Unicode string.
487
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.
493
494 If String is NULL, then ASSERT ().
495
496 @param String The input string to be counted.
497
498 @return Storage space for the input string.
499
500 **/
501 UINTN
502 GetStringWidth (
503 IN CHAR16 *String
504 );
505
506 /**
507 This routine reads a numeric value from the user input.
508
509 @param MenuOption Pointer to the current input menu.
510
511 @retval EFI_SUCCESS If numerical input is read successfully
512 @retval EFI_DEVICE_ERROR If operation fails
513
514 **/
515 EFI_STATUS
516 GetNumericInput (
517 IN UI_MENU_OPTION *MenuOption
518 );
519
520 /**
521 Get string or password input from user.
522
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.
526
527 @retval EFI_SUCCESS If string input is read successfully
528 @retval EFI_DEVICE_ERROR If operation fails
529
530 **/
531 EFI_STATUS
532 ReadString (
533 IN UI_MENU_OPTION *MenuOption,
534 IN CHAR16 *Prompt,
535 IN OUT CHAR16 *StringPtr
536 );
537
538 /**
539 Draw a pop up windows based on the dimension, number of lines and
540 strings specified.
541
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.
545
546 **/
547 VOID
548 CreateSharedPopUp (
549 IN UINTN RequestedWidth,
550 IN UINTN NumberOfLines,
551 IN VA_LIST Marker
552 );
553
554 /**
555 Wait for a key to be pressed by user.
556
557 @param Key The key which is pressed by user.
558
559 @retval EFI_SUCCESS The function always completed successfully.
560
561 **/
562 EFI_STATUS
563 WaitForKeyStroke (
564 OUT EFI_INPUT_KEY *Key
565 );
566
567 /**
568 Get selection for OneOf and OrderedList (Left/Right will be ignored).
569
570 @param MenuOption Pointer to the current input menu.
571
572 @retval EFI_SUCCESS If Option input is processed successfully
573 @retval EFI_DEVICE_ERROR If operation fails
574
575 **/
576 EFI_STATUS
577 GetSelectionInputPopUp (
578 IN UI_MENU_OPTION *MenuOption
579 );
580
581 /**
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.
584
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.
589
590 **/
591 UINTN
592 ProcessHelpString (
593 IN CHAR16 *StringPtr,
594 OUT CHAR16 **FormattedString,
595 OUT UINT16 *EachLineWidth,
596 IN UINTN RowCount
597 );
598
599 /**
600 Process a Question's Option (whether selected or un-selected).
601
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.
606
607 @retval EFI_SUCCESS Question Option process success.
608 @retval Other Question Option process fail.
609
610 **/
611 EFI_STATUS
612 ProcessOptions (
613 IN UI_MENU_OPTION *MenuOption,
614 IN BOOLEAN Selected,
615 OUT CHAR16 **OptionString,
616 IN BOOLEAN SkipErrorValue
617 );
618
619 /**
620 Set Buffer to Value for Size bytes.
621
622 @param Buffer Memory to set.
623 @param Size Number of bytes to set
624 @param Value Value of the set operation.
625
626 **/
627 VOID
628 SetUnicodeMem (
629 IN VOID *Buffer,
630 IN UINTN Size,
631 IN CHAR16 Value
632 );
633
634 /**
635 Display one form, and return user input.
636
637 @param FormData Form Data to be shown.
638 @param UserInputData User input data.
639
640 @retval EFI_SUCCESS Form Data is shown, and user input is got.
641 **/
642 EFI_STATUS
643 EFIAPI
644 FormDisplay (
645 IN FORM_DISPLAY_ENGINE_FORM *FormData,
646 OUT USER_INPUT *UserInputData
647 );
648
649 /**
650 Clear Screen to the initial state.
651 **/
652 VOID
653 EFIAPI
654 DriverClearDisplayPage (
655 VOID
656 );
657
658 /**
659 Exit Display and Clear Screen to the original state.
660
661 **/
662 VOID
663 EFIAPI
664 ExitDisplay (
665 VOID
666 );
667
668 /**
669 Process nothing.
670
671 @param Event The Event need to be process
672 @param Context The context of the event.
673
674 **/
675 VOID
676 EFIAPI
677 EmptyEventProcess (
678 IN EFI_EVENT Event,
679 IN VOID *Context
680 );
681
682 /**
683 Process for the refresh interval statement.
684
685 @param Event The Event need to be process
686 @param Context The context of the event.
687
688 **/
689 VOID
690 EFIAPI
691 RefreshTimeOutProcess (
692 IN EFI_EVENT Event,
693 IN VOID *Context
694 );
695
696 /**
697 Record the highlight menu and top of screen menu info.
698
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.
702
703 **/
704 VOID
705 UpdateHighlightMenuInfo (
706 IN LIST_ENTRY *Highlight,
707 IN LIST_ENTRY *TopOfScreen,
708 IN UINTN SkipValue
709 );
710
711 /**
712 Displays a popup window.
713
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.
720
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.
725
726 **/
727 EFI_STATUS
728 EFIAPI
729 CreatePopup (
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
736 );
737
738 #endif