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