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