]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h
Update question validation logic, move the check pointer from after user input to...
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / FormDisplay.h
1 /** @file
2 FormDiplay protocol to show Form
3
4 Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
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.
12
13 **/
14
15 #ifndef __FORM_DISPLAY_H__
16 #define __FORM_DISPLAY_H__
17
18
19 #include <Library/UefiBootServicesTableLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/BaseMemoryLib.h>
22 #include <Library/BaseLib.h>
23 #include <Library/HiiLib.h>
24 #include <Library/MemoryAllocationLib.h>
25 #include <Library/PrintLib.h>
26 #include <Library/CustomizedDisplayLib.h>
27
28 #include <Protocol/FormBrowserEx2.h>
29 #include <Protocol/SimpleTextIn.h>
30 #include <Protocol/DisplayProtocol.h>
31
32 #include <Guid/MdeModuleHii.h>
33
34 //
35 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
36 //
37 extern UINT8 DisplayEngineStrings[];
38 extern EFI_SCREEN_DESCRIPTOR gStatementDimensions;
39 extern USER_INPUT *gUserInput;
40 extern FORM_DISPLAY_ENGINE_FORM *gFormData;
41 extern EFI_HII_HANDLE gHiiHandle;
42 extern UINT16 gDirection;
43 extern LIST_ENTRY gMenuOption;
44
45 //
46 // Browser Global Strings
47 //
48 extern CHAR16 *gSaveFailed;
49 extern CHAR16 *gPromptForData;
50 extern CHAR16 *gPromptForPassword;
51 extern CHAR16 *gPromptForNewPassword;
52 extern CHAR16 *gConfirmPassword;
53 extern CHAR16 *gConfirmError;
54 extern CHAR16 *gPassowordInvalid;
55 extern CHAR16 *gPressEnter;
56 extern CHAR16 *gEmptyString;
57 extern CHAR16 *gMiniString;
58 extern CHAR16 *gOptionMismatch;
59 extern CHAR16 *gFormSuppress;
60 extern CHAR16 *gProtocolNotFound;
61
62 extern CHAR16 gPromptBlockWidth;
63 extern CHAR16 gOptionBlockWidth;
64 extern CHAR16 gHelpBlockWidth;
65 extern CHAR16 *mUnknownString;
66
67 //
68 // Screen definitions
69 //
70
71 #define LEFT_SKIPPED_COLUMNS 3
72 #define SCROLL_ARROW_HEIGHT 1
73 #define POPUP_PAD_SPACE_COUNT 5
74 #define POPUP_FRAME_WIDTH 2
75
76 //
77 // Display definitions
78 //
79 #define LEFT_ONEOF_DELIMITER L'<'
80 #define RIGHT_ONEOF_DELIMITER L'>'
81
82 #define LEFT_NUMERIC_DELIMITER L'['
83 #define RIGHT_NUMERIC_DELIMITER L']'
84
85 #define LEFT_CHECKBOX_DELIMITER L'['
86 #define RIGHT_CHECKBOX_DELIMITER L']'
87
88 #define CHECK_ON L'X'
89 #define CHECK_OFF L' '
90
91 #define TIME_SEPARATOR L':'
92 #define DATE_SEPARATOR L'/'
93
94 #define SUBTITLE_INDENT 2
95
96 //
97 // This is the Input Error Message
98 //
99 #define INPUT_ERROR 1
100
101 //
102 // This is the NV RAM update required Message
103 //
104 #define NV_UPDATE_REQUIRED 2
105 //
106 // Time definitions
107 //
108 #define ONE_SECOND 10000000
109
110 //
111 // It take 23 characters including the NULL to print a 64 bits number with "[" and "]".
112 // pow(2, 64) = [18446744073709551616]
113 //
114 #define MAX_NUMERIC_INPUT_WIDTH 23
115
116 #define EFI_HII_EXPRESSION_INCONSISTENT_IF 0
117 #define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1
118 #define EFI_HII_EXPRESSION_GRAY_OUT_IF 2
119 #define EFI_HII_EXPRESSION_SUPPRESS_IF 3
120 #define EFI_HII_EXPRESSION_DISABLE_IF 4
121
122 //
123 // Character definitions
124 //
125 #define CHAR_SPACE 0x0020
126
127 #define FORM_DISPLAY_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'D', 'D', 'V')
128 typedef struct {
129 UINT32 Signature;
130
131 EFI_HANDLE Handle;
132
133 //
134 // Produced protocol
135 //
136 EDKII_FORM_DISPLAY_ENGINE_PROTOCOL FromDisplayProt;
137 } FORM_DISPLAY_DRIVER_PRIVATE_DATA;
138
139
140 typedef enum {
141 UiNoOperation,
142 UiSelect,
143 UiUp,
144 UiDown,
145 UiLeft,
146 UiRight,
147 UiReset,
148 UiPrevious,
149 UiPageUp,
150 UiPageDown,
151 UiHotKey,
152 UiMaxOperation
153 } UI_SCREEN_OPERATION;
154
155 typedef enum {
156 CfInitialization,
157 CfCheckSelection,
158 CfRepaint,
159 CfRefreshHighLight,
160 CfUpdateHelpString,
161 CfPrepareToReadKey,
162 CfReadKey,
163 CfScreenOperation,
164 CfUiSelect,
165 CfUiReset,
166 CfUiLeft,
167 CfUiRight,
168 CfUiUp,
169 CfUiPageUp,
170 CfUiPageDown,
171 CfUiDown,
172 CfUiDefault,
173 CfUiNoOperation,
174 CfExit,
175 CfUiHotKey,
176 CfMaxControlFlag
177 } UI_CONTROL_FLAG;
178
179 typedef enum {
180 UIEventNone,
181 UIEventKey,
182 UIEventTimeOut,
183 UIEventDriver
184 } UI_EVENT_TYPE;
185
186 typedef struct {
187 UINT16 ScanCode;
188 UI_SCREEN_OPERATION ScreenOperation;
189 } SCAN_CODE_TO_SCREEN_OPERATION;
190
191 typedef struct {
192 UI_SCREEN_OPERATION ScreenOperation;
193 UI_CONTROL_FLAG ControlFlag;
194 } SCREEN_OPERATION_T0_CONTROL_FLAG;
195
196 typedef struct {
197 EFI_HII_HANDLE HiiHandle;
198 EFI_QUESTION_ID QuestionId;
199 EFI_IFR_OP_HEADER *OpCode;
200 UINT16 DisplayRow;
201 UINT16 SkipValue;
202 } DISPLAY_HIGHLIGHT_MENU_INFO;
203
204 typedef struct {
205 EFI_EVENT SyncEvent;
206 UINT8 *TimeOut;
207 CHAR16 *ErrorInfo;
208 } WARNING_IF_CONTEXT;
209
210 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
211
212 typedef struct {
213 UINTN Signature;
214 LIST_ENTRY Link;
215
216 EFI_HII_HANDLE Handle;
217 FORM_DISPLAY_ENGINE_STATEMENT *ThisTag;
218 UINT16 EntryNumber;
219
220 UINTN Row;
221 UINTN Col;
222 UINTN OptCol;
223 CHAR16 *Description;
224 UINTN Skip; // Number of lines
225
226 //
227 // Display item sequence for date/time
228 // Date: Month/Day/Year
229 // Sequence: 0 1 2
230 //
231 // Time: Hour : Minute : Second
232 // Sequence: 0 1 2
233 //
234 //
235 UINTN Sequence;
236
237 BOOLEAN GrayOut;
238 BOOLEAN ReadOnly;
239
240 //
241 // Whether user could change value of this item
242 //
243 BOOLEAN IsQuestion;
244 BOOLEAN NestInStatement;
245 } UI_MENU_OPTION;
246
247 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
248
249 /**
250 Print Question Value according to it's storage width and display attributes.
251
252 @param Question The Question to be printed.
253 @param FormattedNumber Buffer for output string.
254 @param BufferSize The FormattedNumber buffer size in bytes.
255
256 @retval EFI_SUCCESS Print success.
257 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
258
259 **/
260 EFI_STATUS
261 PrintFormattedNumber (
262 IN FORM_DISPLAY_ENGINE_STATEMENT *Question,
263 IN OUT CHAR16 *FormattedNumber,
264 IN UINTN BufferSize
265 );
266
267 /**
268 Set value of a data element in an Array by its Index.
269
270 @param Array The data array.
271 @param Type Type of the data in this array.
272 @param Index Zero based index for data in this array.
273 @param Value The value to be set.
274
275 **/
276 VOID
277 SetArrayData (
278 IN VOID *Array,
279 IN UINT8 Type,
280 IN UINTN Index,
281 IN UINT64 Value
282 );
283
284 /**
285 Return data element in an Array by its Index.
286
287 @param Array The data array.
288 @param Type Type of the data in this array.
289 @param Index Zero based index for data in this array.
290
291 @retval Value The data to be returned
292
293 **/
294 UINT64
295 GetArrayData (
296 IN VOID *Array,
297 IN UINT8 Type,
298 IN UINTN Index
299 );
300
301 /**
302 Search an Option of a Question by its value.
303
304 @param Question The Question
305 @param OptionValue Value for Option to be searched.
306
307 @retval Pointer Pointer to the found Option.
308 @retval NULL Option not found.
309
310 **/
311 DISPLAY_QUESTION_OPTION *
312 ValueToOption (
313 IN FORM_DISPLAY_ENGINE_STATEMENT *Question,
314 IN EFI_HII_VALUE *OptionValue
315 );
316
317 /**
318 Compare two Hii value.
319
320 @param Value1 Expression value to compare on left-hand.
321 @param Value2 Expression value to compare on right-hand.
322 @param Result Return value after compare.
323 retval 0 Two operators equal.
324 return Positive value if Value1 is greater than Value2.
325 retval Negative value if Value1 is less than Value2.
326 @param HiiHandle Only required for string compare.
327
328 @retval other Could not perform compare on two values.
329 @retval EFI_SUCCESS Compare the value success.
330
331 **/
332 EFI_STATUS
333 CompareHiiValue (
334 IN EFI_HII_VALUE *Value1,
335 IN EFI_HII_VALUE *Value2,
336 OUT INTN *Result,
337 IN EFI_HII_HANDLE HiiHandle OPTIONAL
338 );
339
340 /**
341 Draw a pop up windows based on the dimension, number of lines and
342 strings specified.
343
344 @param RequestedWidth The width of the pop-up.
345 @param NumberOfLines The number of lines.
346 @param ... A series of text strings that displayed in the pop-up.
347
348 **/
349 VOID
350 EFIAPI
351 CreateMultiStringPopUp (
352 IN UINTN RequestedWidth,
353 IN UINTN NumberOfLines,
354 ...
355 );
356
357 /**
358 Will copy LineWidth amount of a string in the OutputString buffer and return the
359 number of CHAR16 characters that were copied into the OutputString buffer.
360 The output string format is:
361 Glyph Info + String info + '\0'.
362
363 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
364
365 @param InputString String description for this option.
366 @param LineWidth Width of the desired string to extract in CHAR16
367 characters
368 @param GlyphWidth The glyph width of the begin of the char in the string.
369 @param Index Where in InputString to start the copy process
370 @param OutputString Buffer to copy the string into
371
372 @return Returns the number of CHAR16 characters that were copied into the OutputString
373 buffer, include extra glyph info and '\0' info.
374
375 **/
376 UINT16
377 GetLineByWidth (
378 IN CHAR16 *InputString,
379 IN UINT16 LineWidth,
380 IN OUT UINT16 *GlyphWidth,
381 IN OUT UINTN *Index,
382 OUT CHAR16 **OutputString
383 );
384
385
386 /**
387 Get the string based on the StringId and HII Package List Handle.
388
389 @param Token The String's ID.
390 @param HiiHandle The Hii handle for this string package.
391
392 @return The output string.
393
394 **/
395 CHAR16 *
396 GetToken (
397 IN EFI_STRING_ID Token,
398 IN EFI_HII_HANDLE HiiHandle
399 );
400
401 /**
402 Count the storage space of a Unicode string.
403
404 This function handles the Unicode string with NARROW_CHAR
405 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
406 does not count in the resultant output. If a WIDE_CHAR is
407 hit, then 2 Unicode character will consume an output storage
408 space with size of CHAR16 till a NARROW_CHAR is hit.
409
410 If String is NULL, then ASSERT ().
411
412 @param String The input string to be counted.
413
414 @return Storage space for the input string.
415
416 **/
417 UINTN
418 GetStringWidth (
419 IN CHAR16 *String
420 );
421
422 /**
423 This routine reads a numeric value from the user input.
424
425 @param MenuOption Pointer to the current input menu.
426
427 @retval EFI_SUCCESS If numerical input is read successfully
428 @retval EFI_DEVICE_ERROR If operation fails
429
430 **/
431 EFI_STATUS
432 GetNumericInput (
433 IN UI_MENU_OPTION *MenuOption
434 );
435
436 /**
437 Get string or password input from user.
438
439 @param MenuOption Pointer to the current input menu.
440 @param Prompt The prompt string shown on popup window.
441 @param StringPtr Old user input and destination for use input string.
442
443 @retval EFI_SUCCESS If string input is read successfully
444 @retval EFI_DEVICE_ERROR If operation fails
445
446 **/
447 EFI_STATUS
448 ReadString (
449 IN UI_MENU_OPTION *MenuOption,
450 IN CHAR16 *Prompt,
451 IN OUT CHAR16 *StringPtr
452 );
453
454 /**
455 Draw a pop up windows based on the dimension, number of lines and
456 strings specified.
457
458 @param RequestedWidth The width of the pop-up.
459 @param NumberOfLines The number of lines.
460 @param Marker The variable argument list for the list of string to be printed.
461
462 **/
463 VOID
464 CreateSharedPopUp (
465 IN UINTN RequestedWidth,
466 IN UINTN NumberOfLines,
467 IN VA_LIST Marker
468 );
469
470 /**
471 Wait for a key to be pressed by user.
472
473 @param Key The key which is pressed by user.
474
475 @retval EFI_SUCCESS The function always completed successfully.
476
477 **/
478 EFI_STATUS
479 WaitForKeyStroke (
480 OUT EFI_INPUT_KEY *Key
481 );
482
483 /**
484 Get selection for OneOf and OrderedList (Left/Right will be ignored).
485
486 @param MenuOption Pointer to the current input menu.
487
488 @retval EFI_SUCCESS If Option input is processed successfully
489 @retval EFI_DEVICE_ERROR If operation fails
490
491 **/
492 EFI_STATUS
493 GetSelectionInputPopUp (
494 IN UI_MENU_OPTION *MenuOption
495 );
496
497 /**
498 Process the help string: Split StringPtr to several lines of strings stored in
499 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
500
501 @param StringPtr The entire help string.
502 @param FormattedString The oupput formatted string.
503 @param EachLineWidth The max string length of each line in the formatted string.
504 @param RowCount TRUE: if Question is selected.
505
506 **/
507 UINTN
508 ProcessHelpString (
509 IN CHAR16 *StringPtr,
510 OUT CHAR16 **FormattedString,
511 OUT UINT16 *EachLineWidth,
512 IN UINTN RowCount
513 );
514
515 /**
516 Process a Question's Option (whether selected or un-selected).
517
518 @param MenuOption The MenuOption for this Question.
519 @param Selected TRUE: if Question is selected.
520 @param OptionString Pointer of the Option String to be displayed.
521 @param SkipErrorValue Whether need to return when value without option for it.
522
523 @retval EFI_SUCCESS Question Option process success.
524 @retval Other Question Option process fail.
525
526 **/
527 EFI_STATUS
528 ProcessOptions (
529 IN UI_MENU_OPTION *MenuOption,
530 IN BOOLEAN Selected,
531 OUT CHAR16 **OptionString,
532 IN BOOLEAN SkipErrorValue
533 );
534
535 /**
536 Set Buffer to Value for Size bytes.
537
538 @param Buffer Memory to set.
539 @param Size Number of bytes to set
540 @param Value Value of the set operation.
541
542 **/
543 VOID
544 SetUnicodeMem (
545 IN VOID *Buffer,
546 IN UINTN Size,
547 IN CHAR16 Value
548 );
549
550 /**
551 Display one form, and return user input.
552
553 @param FormData Form Data to be shown.
554 @param UserInputData User input data.
555
556 @retval EFI_SUCCESS Form Data is shown, and user input is got.
557 **/
558 EFI_STATUS
559 EFIAPI
560 FormDisplay (
561 IN FORM_DISPLAY_ENGINE_FORM *FormData,
562 OUT USER_INPUT *UserInputData
563 );
564
565 /**
566 Clear Screen to the initial state.
567 **/
568 VOID
569 EFIAPI
570 DriverClearDisplayPage (
571 VOID
572 );
573
574 /**
575 Exit Display and Clear Screen to the original state.
576
577 **/
578 VOID
579 EFIAPI
580 ExitDisplay (
581 VOID
582 );
583
584 /**
585 Process nothing.
586
587 @param Event The Event need to be process
588 @param Context The context of the event.
589
590 **/
591 VOID
592 EFIAPI
593 EmptyEventProcess (
594 IN EFI_EVENT Event,
595 IN VOID *Context
596 );
597
598 /**
599 Process for the refresh interval statement.
600
601 @param Event The Event need to be process
602 @param Context The context of the event.
603
604 **/
605 VOID
606 EFIAPI
607 RefreshTimeOutProcess (
608 IN EFI_EVENT Event,
609 IN VOID *Context
610 );
611
612 #endif