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