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