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