]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/SetupBrowserDxe/Ui.h
Clean up to update the reference of the these macros:
[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 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 SIGNATURE_32 ('u', 'i', 'm', 'm')
108 #define UI_MENU_LIST_SIGNATURE 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 extern BOOLEAN mHiiPackageListUpdated;
173
174 //
175 // Global Functions
176 //
177 /**
178 Initialize Menu option list.
179
180 **/
181 VOID
182 UiInitMenu (
183 VOID
184 );
185
186 /**
187 Initialize Menu option list.
188
189 **/
190 VOID
191 UiInitMenuList (
192 VOID
193 );
194
195 /**
196 Remove a Menu in list, and return FormId/QuestionId for previous Menu.
197
198 @param Selection Menu selection.
199
200 **/
201 VOID
202 UiRemoveMenuListEntry (
203 OUT UI_MENU_SELECTION *Selection
204 );
205
206 /**
207 Free Menu option linked list.
208
209 **/
210 VOID
211 UiFreeMenuList (
212 VOID
213 );
214
215 /**
216 Add one menu entry to the linked lst
217
218 @param Selection Menu selection.
219
220 **/
221 VOID
222 UiAddMenuListEntry (
223 IN UI_MENU_SELECTION *Selection
224 );
225
226 /**
227 Free Menu option linked list.
228
229 **/
230 VOID
231 UiFreeMenu (
232 VOID
233 );
234
235 /**
236 Add one menu option by specified description and context.
237
238 @param String String description for this option.
239 @param Handle Hii handle for the package list.
240 @param Statement Statement of this Menu Option.
241 @param NumberOfLines Display lines for this Menu Option.
242 @param MenuItemCount The index for this Option in the Menu.
243
244 **/
245 VOID
246 UiAddMenuOption (
247 IN CHAR16 *String,
248 IN EFI_HII_HANDLE Handle,
249 IN FORM_BROWSER_STATEMENT *Statement,
250 IN UINT16 NumberOfLines,
251 IN UINT16 MenuItemCount
252 );
253
254 /**
255 Display menu and wait for user to select one menu option, then return it.
256 If AutoBoot is enabled, then if user doesn't select any option,
257 after period of time, it will automatically return the first menu option.
258
259 @param Selection Menu selection.
260
261 @return Return the pointer of the menu which selected,
262 @return otherwise return NULL.
263
264 **/
265 EFI_STATUS
266 UiDisplayMenu (
267 IN OUT UI_MENU_SELECTION *Selection
268 );
269
270 /**
271 Free up the resource allocated for all strings required
272 by Setup Browser.
273
274 **/
275 VOID
276 FreeBrowserStrings (
277 VOID
278 );
279
280 /**
281 The worker function that send the displays to the screen. On output,
282 the selection made by user is returned.
283
284 @param Selection On input, Selection tell setup browser the information
285 about the Selection, form and formset to be displayed.
286 On output, Selection return the screen item that is selected
287 by user.
288
289 @retval EFI_SUCCESS The page is displayed successfully.
290 @return Other value if the page failed to be diplayed.
291
292 **/
293 EFI_STATUS
294 SetupBrowser (
295 IN OUT UI_MENU_SELECTION *Selection
296 );
297
298 /**
299 VSPrint worker function that prints a Value as a decimal number in Buffer.
300
301 @param Buffer Location to place ascii decimal number string of Value.
302 @param Flags Flags to use in printing decimal string, see file header for
303 details.
304 @param Value Decimal value to convert to a string in Buffer.
305
306 @return Number of characters printed.
307
308 **/
309 VOID
310 ValueToString (
311 IN CHAR16 *Buffer,
312 IN BOOLEAN Flags,
313 IN INT64 Value
314 );
315
316 /**
317 Set Buffer to Value for Size bytes.
318
319 @param Buffer Memory to set.
320 @param Size Number of bytes to set
321 @param Value Value of the set operation.
322
323 **/
324 VOID
325 SetUnicodeMem (
326 IN VOID *Buffer,
327 IN UINTN Size,
328 IN CHAR16 Value
329 );
330
331 /**
332 Wait for a given event to fire, or for an optional timeout to expire.
333
334 @param Event The event to wait for
335 @param Timeout An optional timeout value in 100 ns units.
336 @param RefreshInterval Menu refresh interval (in seconds).
337
338 @retval EFI_SUCCESS Event fired before Timeout expired.
339 @retval EFI_TIME_OUT Timout expired before Event fired.
340
341 **/
342 EFI_STATUS
343 UiWaitForSingleEvent (
344 IN EFI_EVENT Event,
345 IN UINT64 Timeout, OPTIONAL
346 IN UINT8 RefreshInterval OPTIONAL
347 );
348
349 /**
350 Draw a pop up windows based on the dimension, number of lines and
351 strings specified.
352
353 @param ScreenWidth The width of the pop-up.
354 @param NumberOfLines The number of lines.
355 @param ... A series of text strings that displayed in the pop-up.
356
357 **/
358 VOID
359 CreatePopUp (
360 IN UINTN ScreenWidth,
361 IN UINTN NumberOfLines,
362 ...
363 );
364
365 /**
366 Get string or password input from user.
367
368 @param MenuOption Pointer to the current input menu.
369 @param Prompt The prompt string shown on popup window.
370 @param StringPtr Destination for use input string.
371
372 @retval EFI_SUCCESS If string input is read successfully
373 @retval EFI_DEVICE_ERROR If operation fails
374
375 **/
376 EFI_STATUS
377 ReadString (
378 IN UI_MENU_OPTION *MenuOption,
379 IN CHAR16 *Prompt,
380 OUT CHAR16 *StringPtr
381 );
382
383 /**
384 Get selection for OneOf and OrderedList (Left/Right will be ignored).
385
386 @param Selection Pointer to current selection.
387 @param MenuOption Pointer to the current input menu.
388
389 @retval EFI_SUCCESS If Option input is processed successfully
390 @retval EFI_DEVICE_ERROR If operation fails
391
392 **/
393 EFI_STATUS
394 GetSelectionInputPopUp (
395 IN UI_MENU_SELECTION *Selection,
396 IN UI_MENU_OPTION *MenuOption
397 );
398
399 /**
400 This routine reads a numeric value from the user input.
401
402 @param Selection Pointer to current selection.
403 @param MenuOption Pointer to the current input menu.
404
405 @retval EFI_SUCCESS If numerical input is read successfully
406 @retval EFI_DEVICE_ERROR If operation fails
407
408 **/
409 EFI_STATUS
410 GetNumericInput (
411 IN UI_MENU_SELECTION *Selection,
412 IN UI_MENU_OPTION *MenuOption
413 );
414
415 /**
416 Update status bar on the bottom of menu.
417
418 @param MessageType The type of message to be shown.
419 @param Flags The flags in Question header.
420 @param State Set or clear.
421
422 **/
423 VOID
424 UpdateStatusBar (
425 IN UINTN MessageType,
426 IN UINT8 Flags,
427 IN BOOLEAN State
428 );
429
430 /**
431 Process Question Config.
432
433 @param Selection The UI menu selection.
434 @param Question The Question to be peocessed.
435
436 @retval EFI_SUCCESS Question Config process success.
437 @retval Other Question Config process fail.
438
439 **/
440 EFI_STATUS
441 ProcessQuestionConfig (
442 IN UI_MENU_SELECTION *Selection,
443 IN FORM_BROWSER_STATEMENT *Question
444 );
445
446 /**
447 Print Question Value according to it's storage width and display attributes.
448
449 @param Question The Question to be printed.
450 @param FormattedNumber Buffer for output string.
451 @param BufferSize The FormattedNumber buffer size in bytes.
452
453 @retval EFI_SUCCESS Print success.
454 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
455
456 **/
457 EFI_STATUS
458 PrintFormattedNumber (
459 IN FORM_BROWSER_STATEMENT *Question,
460 IN OUT CHAR16 *FormattedNumber,
461 IN UINTN BufferSize
462 );
463
464 /**
465 Search an Option of a Question by its value.
466
467 @param Question The Question
468 @param OptionValue Value for Option to be searched.
469
470 @retval Pointer Pointer to the found Option.
471 @retval NULL Option not found.
472
473 **/
474 QUESTION_OPTION *
475 ValueToOption (
476 IN FORM_BROWSER_STATEMENT *Question,
477 IN EFI_HII_VALUE *OptionValue
478 );
479
480 /**
481 Process a Question's Option (whether selected or un-selected).
482
483 @param Selection Pointer to UI_MENU_SELECTION.
484 @param MenuOption The MenuOption for this Question.
485 @param Selected TRUE: if Question is selected.
486 @param OptionString Pointer of the Option String to be displayed.
487
488 @retval EFI_SUCCESS Question Option process success.
489 @retval Other Question Option process fail.
490
491 **/
492 EFI_STATUS
493 ProcessOptions (
494 IN UI_MENU_SELECTION *Selection,
495 IN UI_MENU_OPTION *MenuOption,
496 IN BOOLEAN Selected,
497 OUT CHAR16 **OptionString
498 );
499
500 /**
501 Process the help string: Split StringPtr to several lines of strings stored in
502 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
503
504 @param StringPtr The entire help string.
505 @param FormattedString The oupput formatted string.
506 @param RowCount TRUE: if Question is selected.
507
508 **/
509 VOID
510 ProcessHelpString (
511 IN CHAR16 *StringPtr,
512 OUT CHAR16 **FormattedString,
513 IN UINTN RowCount
514 );
515
516 /**
517 Update key's help imformation.
518
519 @param MenuOption The Menu option
520 @param Selected Whether or not a tag be selected
521
522 **/
523 VOID
524 UpdateKeyHelp (
525 IN UI_MENU_OPTION *MenuOption,
526 IN BOOLEAN Selected
527 );
528
529 /**
530 Clear retangle with specified text attribute.
531
532 @param LeftColumn Left column of retangle.
533 @param RightColumn Right column of retangle.
534 @param TopRow Start row of retangle.
535 @param BottomRow End row of retangle.
536 @param TextAttribute The character foreground and background.
537
538 **/
539 VOID
540 ClearLines (
541 UINTN LeftColumn,
542 UINTN RightColumn,
543 UINTN TopRow,
544 UINTN BottomRow,
545 UINTN TextAttribute
546 );
547
548 /**
549 Count the storage space of a Unicode string.
550
551 This function handles the Unicode string with NARROW_CHAR
552 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
553 does not count in the resultant output. If a WIDE_CHAR is
554 hit, then 2 Unicode character will consume an output storage
555 space with size of CHAR16 till a NARROW_CHAR is hit.
556
557 @param String The input string to be counted.
558
559 @return Storage space for the input string.
560
561 **/
562 UINTN
563 GetStringWidth (
564 CHAR16 *String
565 );
566
567 /**
568 Will copy LineWidth amount of a string in the OutputString buffer and return the
569 number of CHAR16 characters that were copied into the OutputString buffer.
570
571 @param InputString String description for this option.
572 @param LineWidth Width of the desired string to extract in CHAR16
573 characters
574 @param Index Where in InputString to start the copy process
575 @param OutputString Buffer to copy the string into
576
577 @return Returns the number of CHAR16 characters that were copied into the OutputString buffer.
578
579 **/
580 UINT16
581 GetLineByWidth (
582 IN CHAR16 *InputString,
583 IN UINT16 LineWidth,
584 IN OUT UINTN *Index,
585 OUT CHAR16 **OutputString
586 );
587
588 /**
589 Get the supported width for a particular op-code
590
591 @param Statement The FORM_BROWSER_STATEMENT structure passed in.
592 @param Handle The handle in the HII database being used
593
594 @return Returns the number of CHAR16 characters that is support.
595
596 **/
597 UINT16
598 GetWidth (
599 IN FORM_BROWSER_STATEMENT *Statement,
600 IN EFI_HII_HANDLE Handle
601 );
602
603 /**
604 Concatenate a narrow string to another string.
605
606 @param Destination The destination string.
607 @param Source The source string. The string to be concatenated.
608 to the end of Destination.
609
610 **/
611 VOID
612 NewStrCat (
613 CHAR16 *Destination,
614 CHAR16 *Source
615 );
616
617 /**
618 Wait for a key to be pressed by user.
619
620 @param Key The key which is pressed by user.
621
622 @retval EFI_SUCCESS The function always completed successfully.
623
624 **/
625 EFI_STATUS
626 WaitForKeyStroke (
627 OUT EFI_INPUT_KEY *Key
628 );
629
630 /**
631 Reset stack pointer to begin of the stack.
632
633 **/
634 VOID
635 ResetScopeStack (
636 VOID
637 );
638
639 /**
640 Push an Operand onto the Stack
641
642 @param Operand Operand to push.
643
644 @retval EFI_SUCCESS The value was pushed onto the stack.
645 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
646 stack.
647
648 **/
649 EFI_STATUS
650 PushScope (
651 IN UINT8 Operand
652 );
653
654 /**
655 Pop an Operand from the Stack
656
657 @param Operand Operand to pop.
658
659 @retval EFI_SUCCESS The value was pushed onto the stack.
660 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
661 stack.
662
663 **/
664 EFI_STATUS
665 PopScope (
666 OUT UINT8 *Operand
667 );
668
669 /**
670 Get Form given its FormId.
671
672 @param FormSet The formset which contains this form.
673 @param FormId Id of this form.
674
675 @retval Pointer The form.
676 @retval NULL Specified Form is not found in the formset.
677
678 **/
679 FORM_BROWSER_FORM *
680 IdToForm (
681 IN FORM_BROWSER_FORMSET *FormSet,
682 IN UINT16 FormId
683 );
684
685 /**
686 Search a Question in Formset scope using its QuestionId.
687
688 @param FormSet The formset which contains this form.
689 @param Form The form which contains this Question.
690 @param QuestionId Id of this Question.
691
692 @retval Pointer The Question.
693 @retval NULL Specified Question not found in the form.
694
695 **/
696 FORM_BROWSER_STATEMENT *
697 IdToQuestion (
698 IN FORM_BROWSER_FORMSET *FormSet,
699 IN FORM_BROWSER_FORM *Form,
700 IN UINT16 QuestionId
701 );
702
703 /**
704 Zero extend integer/boolean/date/time to UINT64 for comparing.
705
706 @param Value HII Value to be converted.
707
708 **/
709 VOID
710 ExtendValueToU64 (
711 IN EFI_HII_VALUE *Value
712 );
713
714 /**
715 Compare two Hii value.
716
717 @param Value1 Expression value to compare on left-hand.
718 @param Value2 Expression value to compare on right-hand.
719 @param HiiHandle Only required for string compare.
720
721 @retval EFI_INVALID_PARAMETER Could not perform comparation on two values.
722 @retval 0 Two operators equeal.
723 @return Positive value if Value1 is greater than Value2.
724 @retval Negative value if Value1 is less than Value2.
725
726 **/
727 INTN
728 CompareHiiValue (
729 IN EFI_HII_VALUE *Value1,
730 IN EFI_HII_VALUE *Value2,
731 IN EFI_HII_HANDLE HiiHandle OPTIONAL
732 );
733
734 /**
735 Evaluate the result of a HII expression
736
737 @param FormSet FormSet associated with this expression.
738 @param Form Form associated with this expression.
739 @param Expression Expression to be evaluated.
740
741 @retval EFI_SUCCESS The expression evaluated successfuly
742 @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
743 could not be found.
744 @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
745 stack.
746 @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
747 @retval EFI_INVALID_PARAMETER Syntax error with the Expression
748
749 **/
750 EFI_STATUS
751 EvaluateExpression (
752 IN FORM_BROWSER_FORMSET *FormSet,
753 IN FORM_BROWSER_FORM *Form,
754 IN OUT FORM_EXPRESSION *Expression
755 );
756
757 #endif // _UI_H