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