]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/SetupBrowserDxe/Ui.h
1) Clean up the INF and add in comment to describe the surface area of modules
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Ui.h
1 /** @file
2 Private structure, MACRO and function definitions for User Interface related functionalities.
3
4 Copyright (c) 2004 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. 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 _UI_H_
16 #define _UI_H_
17
18 #include "Setup.h"
19
20 //
21 // Globals
22 //
23 #define REGULAR_NUMERIC 0
24 #define TIME_NUMERIC 1
25 #define DATE_NUMERIC 2
26
27 #define SUBTITLE_INDENT 2
28
29
30 //
31 // It take 23 characters including the NULL to print a 64 bits number with "[" and "]".
32 // pow(2, 64) = [18446744073709551616]
33 //
34 #define MAX_NUMERIC_INPUT_WIDTH 23
35
36 typedef enum {
37 UiNoOperation,
38 UiDefault,
39 UiSelect,
40 UiUp,
41 UiDown,
42 UiLeft,
43 UiRight,
44 UiReset,
45 UiSave,
46 UiPrevious,
47 UiPageUp,
48 UiPageDown,
49 UiMaxOperation
50 } UI_SCREEN_OPERATION;
51
52 typedef enum {
53 CfInitialization,
54 CfCheckSelection,
55 CfRepaint,
56 CfRefreshHighLight,
57 CfUpdateHelpString,
58 CfPrepareToReadKey,
59 CfReadKey,
60 CfScreenOperation,
61 CfUiPrevious,
62 CfUiSelect,
63 CfUiReset,
64 CfUiLeft,
65 CfUiRight,
66 CfUiUp,
67 CfUiPageUp,
68 CfUiPageDown,
69 CfUiDown,
70 CfUiSave,
71 CfUiDefault,
72 CfUiNoOperation,
73 CfExit,
74 CfMaxControlFlag
75 } UI_CONTROL_FLAG;
76
77 #define UI_ACTION_NONE 0
78 #define UI_ACTION_REFRESH_FORM 1
79 #define UI_ACTION_REFRESH_FORMSET 2
80 #define UI_ACTION_EXIT 3
81
82 typedef struct {
83 EFI_HII_HANDLE Handle;
84
85 //
86 // Target formset/form/Question information
87 //
88 EFI_GUID FormSetGuid;
89 UINT16 FormId;
90 UINT16 QuestionId;
91
92 UINTN TopRow;
93 UINTN BottomRow;
94 UINTN PromptCol;
95 UINTN OptionCol;
96 UINTN CurrentRow;
97
98 //
99 // Ation for Browser to taken:
100 // UI_ACTION_NONE - navigation inside a form
101 // UI_ACTION_REFRESH_FORM - re-evaluate expressions and repaint form
102 // UI_ACTION_REFRESH_FORMSET - re-parse formset IFR binary
103 //
104 UINTN Action;
105
106 //
107 // Current selected fomset/form/Question
108 //
109 FORM_BROWSER_FORMSET *FormSet;
110 FORM_BROWSER_FORM *Form;
111 FORM_BROWSER_STATEMENT *Statement;
112 } UI_MENU_SELECTION;
113
114 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
115 #define UI_MENU_LIST_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'l')
116
117 typedef struct {
118 UINTN Signature;
119 LIST_ENTRY Link;
120
121 EFI_HII_HANDLE Handle;
122 FORM_BROWSER_STATEMENT *ThisTag;
123 UINT16 EntryNumber;
124
125 UINTN Row;
126 UINTN Col;
127 UINTN OptCol;
128 CHAR16 *Description;
129 UINTN Skip; // Number of lines
130
131 //
132 // Display item sequence for date/time
133 // Date: Month/Day/Year
134 // Sequence: 0 1 2
135 //
136 // Time: Hour : Minute : Second
137 // Sequence: 0 1 2
138 //
139 //
140 UINTN Sequence;
141
142 BOOLEAN GrayOut;
143 BOOLEAN ReadOnly;
144 } UI_MENU_OPTION;
145
146 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
147
148 typedef struct {
149 UINTN Signature;
150 LIST_ENTRY MenuLink;
151
152 UINT16 FormId;
153 UINT16 QuestionId;
154 } UI_MENU_LIST;
155
156 typedef struct _MENU_REFRESH_ENTRY {
157 struct _MENU_REFRESH_ENTRY *Next;
158 UI_MENU_OPTION *MenuOption; // Describes the entry needing an update
159 UI_MENU_SELECTION *Selection;
160 UINTN CurrentColumn;
161 UINTN CurrentRow;
162 UINTN CurrentAttribute;
163 } MENU_REFRESH_ENTRY;
164
165 typedef struct {
166 UINT16 ScanCode;
167 UI_SCREEN_OPERATION ScreenOperation;
168 } SCAN_CODE_TO_SCREEN_OPERATION;
169
170 typedef struct {
171 UI_SCREEN_OPERATION ScreenOperation;
172 UI_CONTROL_FLAG ControlFlag;
173 } SCREEN_OPERATION_T0_CONTROL_FLAG;
174
175
176 extern LIST_ENTRY gMenuList;
177 extern MENU_REFRESH_ENTRY *gMenuRefreshHead;
178 extern UI_MENU_SELECTION *gCurrentSelection;
179 extern BOOLEAN mHiiPackageListUpdated;
180
181 //
182 // Global Functions
183 //
184 /**
185 Initialize Menu option list.
186
187 **/
188 VOID
189 UiInitMenu (
190 VOID
191 );
192
193 /**
194 Initialize Menu option list.
195
196 **/
197 VOID
198 UiInitMenuList (
199 VOID
200 );
201
202 /**
203 Remove a Menu in list, and return FormId/QuestionId for previous Menu.
204
205 @param Selection Menu selection.
206
207 **/
208 VOID
209 UiRemoveMenuListEntry (
210 OUT UI_MENU_SELECTION *Selection
211 );
212
213 /**
214 Free Menu option linked list.
215
216 **/
217 VOID
218 UiFreeMenuList (
219 VOID
220 );
221
222 /**
223 Add one menu entry to the linked lst
224
225 @param Selection Menu selection.
226
227 **/
228 VOID
229 UiAddMenuListEntry (
230 IN UI_MENU_SELECTION *Selection
231 );
232
233 /**
234 Free Menu option linked list.
235
236 **/
237 VOID
238 UiFreeMenu (
239 VOID
240 );
241
242 /**
243 Add one menu option by specified description and context.
244
245 @param String String description for this option.
246 @param Handle Hii handle for the package list.
247 @param Statement Statement of this Menu Option.
248 @param NumberOfLines Display lines for this Menu Option.
249 @param MenuItemCount The index for this Option in the Menu.
250
251 **/
252 VOID
253 UiAddMenuOption (
254 IN CHAR16 *String,
255 IN EFI_HII_HANDLE Handle,
256 IN FORM_BROWSER_STATEMENT *Statement,
257 IN UINT16 NumberOfLines,
258 IN UINT16 MenuItemCount
259 );
260
261 /**
262 Display menu and wait for user to select one menu option, then return it.
263 If AutoBoot is enabled, then if user doesn't select any option,
264 after period of time, it will automatically return the first menu option.
265
266 @param Selection Menu selection.
267
268 @return Return the pointer of the menu which selected,
269 @return otherwise return NULL.
270
271 **/
272 EFI_STATUS
273 UiDisplayMenu (
274 IN OUT UI_MENU_SELECTION *Selection
275 );
276
277 /**
278 Free up the resource allocated for all strings required
279 by Setup Browser.
280
281 **/
282 VOID
283 FreeBrowserStrings (
284 VOID
285 );
286
287 /**
288 The worker function that send the displays to the screen. On output,
289 the selection made by user is returned.
290
291 @param Selection On input, Selection tell setup browser the information
292 about the Selection, form and formset to be displayed.
293 On output, Selection return the screen item that is selected
294 by user.
295
296 @retval EFI_SUCCESS The page is displayed successfully.
297 @return Other value if the page failed to be diplayed.
298
299 **/
300 EFI_STATUS
301 SetupBrowser (
302 IN OUT UI_MENU_SELECTION *Selection
303 );
304
305 /**
306 VSPrint worker function that prints a Value as a decimal number in Buffer.
307
308 @param Buffer Location to place ascii decimal number string of Value.
309 @param Flags Flags to use in printing decimal string, see file header for
310 details.
311 @param Value Decimal value to convert to a string in Buffer.
312
313 @return Number of characters printed.
314
315 **/
316 VOID
317 ValueToString (
318 IN CHAR16 *Buffer,
319 IN BOOLEAN Flags,
320 IN INT64 Value
321 );
322
323 /**
324 Set Buffer to Value for Size bytes.
325
326 @param Buffer Memory to set.
327 @param Size Number of bytes to set
328 @param Value Value of the set operation.
329
330 **/
331 VOID
332 SetUnicodeMem (
333 IN VOID *Buffer,
334 IN UINTN Size,
335 IN CHAR16 Value
336 );
337
338 /**
339 Wait for a given event to fire, or for an optional timeout to expire.
340
341 @param Event The event to wait for
342 @param Timeout An optional timeout value in 100 ns units.
343 @param RefreshInterval Menu refresh interval (in seconds).
344
345 @retval EFI_SUCCESS Event fired before Timeout expired.
346 @retval EFI_TIME_OUT Timout expired before Event fired.
347
348 **/
349 EFI_STATUS
350 UiWaitForSingleEvent (
351 IN EFI_EVENT Event,
352 IN UINT64 Timeout, OPTIONAL
353 IN UINT8 RefreshInterval OPTIONAL
354 );
355
356 /**
357 Draw a pop up windows based on the dimension, number of lines and
358 strings specified.
359
360 @param ScreenWidth The width of the pop-up.
361 @param NumberOfLines The number of lines.
362 @param ... A series of text strings that displayed in the pop-up.
363
364 **/
365 VOID
366 CreatePopUp (
367 IN UINTN ScreenWidth,
368 IN UINTN NumberOfLines,
369 ...
370 );
371
372 /**
373 Get string or password input from user.
374
375 @param MenuOption Pointer to the current input menu.
376 @param Prompt The prompt string shown on popup window.
377 @param StringPtr Destination for use input string.
378
379 @retval EFI_SUCCESS If string input is read successfully
380 @retval EFI_DEVICE_ERROR If operation fails
381
382 **/
383 EFI_STATUS
384 ReadString (
385 IN UI_MENU_OPTION *MenuOption,
386 IN CHAR16 *Prompt,
387 OUT CHAR16 *StringPtr
388 );
389
390 /**
391 Get selection for OneOf and OrderedList (Left/Right will be ignored).
392
393 @param Selection Pointer to current selection.
394 @param MenuOption Pointer to the current input menu.
395
396 @retval EFI_SUCCESS If Option input is processed successfully
397 @retval EFI_DEVICE_ERROR If operation fails
398
399 **/
400 EFI_STATUS
401 GetSelectionInputPopUp (
402 IN UI_MENU_SELECTION *Selection,
403 IN UI_MENU_OPTION *MenuOption
404 );
405
406 /**
407 This routine reads a numeric value from the user input.
408
409 @param Selection Pointer to current selection.
410 @param MenuOption Pointer to the current input menu.
411
412 @retval EFI_SUCCESS If numerical input is read successfully
413 @retval EFI_DEVICE_ERROR If operation fails
414
415 **/
416 EFI_STATUS
417 GetNumericInput (
418 IN UI_MENU_SELECTION *Selection,
419 IN UI_MENU_OPTION *MenuOption
420 );
421
422 /**
423 Update status bar on the bottom of menu.
424
425 @param MessageType The type of message to be shown.
426 @param Flags The flags in Question header.
427 @param State Set or clear.
428
429 **/
430 VOID
431 UpdateStatusBar (
432 IN UINTN MessageType,
433 IN UINT8 Flags,
434 IN BOOLEAN State
435 );
436
437 /**
438 Process Question Config.
439
440 @param Selection The UI menu selection.
441 @param Question The Question to be peocessed.
442
443 @retval EFI_SUCCESS Question Config process success.
444 @retval Other Question Config process fail.
445
446 **/
447 EFI_STATUS
448 ProcessQuestionConfig (
449 IN UI_MENU_SELECTION *Selection,
450 IN FORM_BROWSER_STATEMENT *Question
451 );
452
453 /**
454 Print Question Value according to it's storage width and display attributes.
455
456 @param Question The Question to be printed.
457 @param FormattedNumber Buffer for output string.
458 @param BufferSize The FormattedNumber buffer size in bytes.
459
460 @retval EFI_SUCCESS Print success.
461 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
462
463 **/
464 EFI_STATUS
465 PrintFormattedNumber (
466 IN FORM_BROWSER_STATEMENT *Question,
467 IN OUT CHAR16 *FormattedNumber,
468 IN UINTN BufferSize
469 );
470
471 /**
472 Search an Option of a Question by its value.
473
474 @param Question The Question
475 @param OptionValue Value for Option to be searched.
476
477 @retval Pointer Pointer to the found Option.
478 @retval NULL Option not found.
479
480 **/
481 QUESTION_OPTION *
482 ValueToOption (
483 IN FORM_BROWSER_STATEMENT *Question,
484 IN EFI_HII_VALUE *OptionValue
485 );
486
487 /**
488 Process a Question's Option (whether selected or un-selected).
489
490 @param Selection Pointer to UI_MENU_SELECTION.
491 @param MenuOption The MenuOption for this Question.
492 @param Selected TRUE: if Question is selected.
493 @param OptionString Pointer of the Option String to be displayed.
494
495 @retval EFI_SUCCESS Question Option process success.
496 @retval Other Question Option process fail.
497
498 **/
499 EFI_STATUS
500 ProcessOptions (
501 IN UI_MENU_SELECTION *Selection,
502 IN UI_MENU_OPTION *MenuOption,
503 IN BOOLEAN Selected,
504 OUT CHAR16 **OptionString
505 );
506
507 /**
508 Process the help string: Split StringPtr to several lines of strings stored in
509 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
510
511 @param StringPtr The entire help string.
512 @param FormattedString The oupput formatted string.
513 @param RowCount TRUE: if Question is selected.
514
515 **/
516 VOID
517 ProcessHelpString (
518 IN CHAR16 *StringPtr,
519 OUT CHAR16 **FormattedString,
520 IN UINTN RowCount
521 );
522
523 /**
524 Update key's help imformation.
525
526 @param MenuOption The Menu option
527 @param Selected Whether or not a tag be selected
528
529 **/
530 VOID
531 UpdateKeyHelp (
532 IN UI_MENU_OPTION *MenuOption,
533 IN BOOLEAN Selected
534 );
535
536 /**
537 Clear retangle with specified text attribute.
538
539 @param LeftColumn Left column of retangle.
540 @param RightColumn Right column of retangle.
541 @param TopRow Start row of retangle.
542 @param BottomRow End row of retangle.
543 @param TextAttribute The character foreground and background.
544
545 **/
546 VOID
547 ClearLines (
548 UINTN LeftColumn,
549 UINTN RightColumn,
550 UINTN TopRow,
551 UINTN BottomRow,
552 UINTN TextAttribute
553 );
554
555 /**
556 Count the storage space of a Unicode string.
557
558 This function handles the Unicode string with NARROW_CHAR
559 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
560 does not count in the resultant output. If a WIDE_CHAR is
561 hit, then 2 Unicode character will consume an output storage
562 space with size of CHAR16 till a NARROW_CHAR is hit.
563
564 @param String The input string to be counted.
565
566 @return Storage space for the input string.
567
568 **/
569 UINTN
570 GetStringWidth (
571 CHAR16 *String
572 );
573
574 /**
575 Will copy LineWidth amount of a string in the OutputString buffer and return the
576 number of CHAR16 characters that were copied into the OutputString buffer.
577
578 @param InputString String description for this option.
579 @param LineWidth Width of the desired string to extract in CHAR16
580 characters
581 @param Index Where in InputString to start the copy process
582 @param OutputString Buffer to copy the string into
583
584 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
585
586 **/
587 UINT16
588 GetLineByWidth (
589 IN CHAR16 *InputString,
590 IN UINT16 LineWidth,
591 IN OUT UINTN *Index,
592 OUT CHAR16 **OutputString
593 );
594
595 /**
596 Get the supported width for a particular op-code
597
598 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
599 @param Handle The handle in the HII database being used
600
601 @return Returns the number of CHAR16 characters that is support.
602
603 **/
604 UINT16
605 GetWidth (
606 IN FORM_BROWSER_STATEMENT *Statement,
607 IN EFI_HII_HANDLE Handle
608 );
609
610 /**
611 Concatenate a narrow string to another string.
612
613 @param Destination The destination string.
614 @param Source The source string. The string to be concatenated.
615 to the end of Destination.
616
617 **/
618 VOID
619 NewStrCat (
620 CHAR16 *Destination,
621 CHAR16 *Source
622 );
623
624 /**
625 Wait for a key to be pressed by user.
626
627 @param Key The key which is pressed by user.
628
629 @retval EFI_SUCCESS The function always completed successfully.
630
631 **/
632 EFI_STATUS
633 WaitForKeyStroke (
634 OUT EFI_INPUT_KEY *Key
635 );
636
637 /**
638 Reset stack pointer to begin of the stack.
639
640 **/
641 VOID
642 ResetScopeStack (
643 VOID
644 );
645
646 /**
647 Push an Operand onto the Stack
648
649 @param Operand Operand to push.
650
651 @retval EFI_SUCCESS The value was pushed onto the stack.
652 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
653 stack.
654
655 **/
656 EFI_STATUS
657 PushScope (
658 IN UINT8 Operand
659 );
660
661 /**
662 Pop an Operand from the Stack
663
664 @param Operand Operand to pop.
665
666 @retval EFI_SUCCESS The value was pushed onto the stack.
667 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
668 stack.
669
670 **/
671 EFI_STATUS
672 PopScope (
673 OUT UINT8 *Operand
674 );
675
676 /**
677 Get Form given its FormId.
678
679 @param FormSet The formset which contains this form.
680 @param FormId Id of this form.
681
682 @retval Pointer The form.
683 @retval NULL Specified Form is not found in the formset.
684
685 **/
686 FORM_BROWSER_FORM *
687 IdToForm (
688 IN FORM_BROWSER_FORMSET *FormSet,
689 IN UINT16 FormId
690 );
691
692 /**
693 Search a Question in Formset scope using its QuestionId.
694
695 @param FormSet The formset which contains this form.
696 @param Form The form which contains this Question.
697 @param QuestionId Id of this Question.
698
699 @retval Pointer The Question.
700 @retval NULL Specified Question not found in the form.
701
702 **/
703 FORM_BROWSER_STATEMENT *
704 IdToQuestion (
705 IN FORM_BROWSER_FORMSET *FormSet,
706 IN FORM_BROWSER_FORM *Form,
707 IN UINT16 QuestionId
708 );
709
710 /**
711 Zero extend integer/boolean/date/time to UINT64 for comparing.
712
713 @param Value HII Value to be converted.
714
715 **/
716 VOID
717 ExtendValueToU64 (
718 IN EFI_HII_VALUE *Value
719 );
720
721 /**
722 Compare two Hii value.
723
724 @param Value1 Expression value to compare on left-hand.
725 @param Value2 Expression value to compare on right-hand.
726 @param HiiHandle Only required for string compare.
727
728 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
729 @retval 0 Two operators equeal.
730 @return Positive value if Value1 is greater than Value2.
731 @retval Negative value if Value1 is less than Value2.
732
733 **/
734 INTN
735 CompareHiiValue (
736 IN EFI_HII_VALUE *Value1,
737 IN EFI_HII_VALUE *Value2,
738 IN EFI_HII_HANDLE HiiHandle OPTIONAL
739 );
740
741 /**
742 Evaluate the result of a HII expression
743
744 If Expression is NULL, then ASSERT.
745
746 @param FormSet FormSet associated with this expression.
747 @param Form Form associated with this expression.
748 @param Expression Expression to be evaluated.
749
750 @retval EFI_SUCCESS The expression evaluated successfuly
751 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
752 could not be found.
753 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
754 stack.
755 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
756 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
757
758 **/
759 EFI_STATUS
760 EvaluateExpression (
761 IN FORM_BROWSER_FORMSET *FormSet,
762 IN FORM_BROWSER_FORM *Form,
763 IN OUT FORM_EXPRESSION *Expression
764 );
765
766 #endif // _UI_H