]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
cf0dd00cc5af10787ec8975e2a2246abd938b772
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Setup.h
1 /** @file
2 Private MACRO, structure and function definitions for Setup Browser module.
3
4 Copyright (c) 2007 - 2010, 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
16 #ifndef _SETUP_H_
17 #define _SETUP_H_
18
19
20 #include <PiDxe.h>
21
22 #include <Protocol/SimpleTextOut.h>
23 #include <Protocol/SimpleTextIn.h>
24 #include <Protocol/FormBrowser2.h>
25 #include <Protocol/DevicePath.h>
26 #include <Protocol/UnicodeCollation.h>
27 #include <Protocol/HiiConfigAccess.h>
28 #include <Protocol/HiiConfigRouting.h>
29 #include <Protocol/HiiDatabase.h>
30 #include <Protocol/HiiString.h>
31 #include <Protocol/UserManager.h>
32
33 #include <Guid/MdeModuleHii.h>
34 #include <Guid/HiiPlatformSetupFormset.h>
35
36 #include <Library/PrintLib.h>
37 #include <Library/DebugLib.h>
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/UefiRuntimeServicesTableLib.h>
40 #include <Library/UefiDriverEntryPoint.h>
41 #include <Library/UefiBootServicesTableLib.h>
42 #include <Library/BaseLib.h>
43 #include <Library/MemoryAllocationLib.h>
44 #include <Library/HiiLib.h>
45 #include <Library/PcdLib.h>
46 #include <Library/DevicePathLib.h>
47
48 #include "Colors.h"
49
50 //
51 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
52 //
53
54 extern UINT8 SetupBrowserStrings[];
55
56 //
57 // Screen definitions
58 //
59 #define BANNER_HEIGHT 6
60 #define BANNER_COLUMNS 3
61
62 #define FRONT_PAGE_HEADER_HEIGHT 6
63 #define NONE_FRONT_PAGE_HEADER_HEIGHT 3
64 #define LEFT_SKIPPED_COLUMNS 4
65 #define FOOTER_HEIGHT 4
66 #define STATUS_BAR_HEIGHT 1
67 #define SCROLL_ARROW_HEIGHT 1
68 #define POPUP_PAD_SPACE_COUNT 5
69 #define POPUP_FRAME_WIDTH 2
70
71 //
72 // Definition for function key setting
73 //
74 #define NONE_FUNCTION_KEY_SETTING 0
75 #define DEFAULT_FUNCTION_KEY_SETTING (FUNCTION_NINE | FUNCTION_TEN)
76
77 #define FUNCTION_NINE (1 << 2)
78 #define FUNCTION_TEN (1 << 3)
79
80 typedef struct {
81 EFI_GUID FormSetGuid;
82 UINTN KeySetting;
83 } FUNCTIION_KEY_SETTING;
84
85 //
86 // Character definitions
87 //
88 #define CHAR_SPACE 0x0020
89 #define UPPER_LOWER_CASE_OFFSET 0x20
90
91 //
92 // Time definitions
93 //
94 #define ONE_SECOND 10000000
95
96 //
97 // Display definitions
98 //
99 #define LEFT_HYPER_DELIMITER L'<'
100 #define RIGHT_HYPER_DELIMITER L'>'
101
102 #define LEFT_ONEOF_DELIMITER L'<'
103 #define RIGHT_ONEOF_DELIMITER L'>'
104
105 #define LEFT_NUMERIC_DELIMITER L'['
106 #define RIGHT_NUMERIC_DELIMITER L']'
107
108 #define LEFT_CHECKBOX_DELIMITER L'['
109 #define RIGHT_CHECKBOX_DELIMITER L']'
110
111 #define CHECK_ON L'X'
112 #define CHECK_OFF L' '
113
114 #define TIME_SEPARATOR L':'
115 #define DATE_SEPARATOR L'/'
116
117 #define YES_ANSWER L'Y'
118 #define NO_ANSWER L'N'
119
120 //
121 // This is the Input Error Message
122 //
123 #define INPUT_ERROR 1
124
125 //
126 // This is the NV RAM update required Message
127 //
128 #define NV_UPDATE_REQUIRED 2
129
130 //
131 // Refresh the Status Bar with flags
132 //
133 #define REFRESH_STATUS_BAR 0xff
134
135 //
136 // Incremental string lenght of ConfigRequest
137 //
138 #define CONFIG_REQUEST_STRING_INCREMENTAL 1024
139
140 //
141 // HII value compare result
142 //
143 #define HII_VALUE_UNDEFINED 0
144 #define HII_VALUE_EQUAL 1
145 #define HII_VALUE_LESS_THAN 2
146 #define HII_VALUE_GREATER_THAN 3
147
148 //
149 // Incremental size of stack for expression
150 //
151 #define EXPRESSION_STACK_SIZE_INCREMENT 0x100
152
153
154 #define EFI_SPECIFICATION_ERRATA_VERSION 0
155
156 #define EFI_IFR_SPECIFICATION_VERSION \
157 ((((EFI_SPECIFICATION_VERSION) >> 8) & 0xff00) | \
158 (((EFI_SPECIFICATION_VERSION) & 0xf) << 4) | \
159 ((EFI_SPECIFICATION_ERRATA_VERSION) & 0xf))
160
161 #define SETUP_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'B', 'D', 'V')
162 typedef struct {
163 UINT32 Signature;
164
165 EFI_HANDLE Handle;
166
167 //
168 // Produced protocol
169 //
170 EFI_FORM_BROWSER2_PROTOCOL FormBrowser2;
171
172 } SETUP_DRIVER_PRIVATE_DATA;
173
174 typedef struct {
175 EFI_STRING_ID Banner[BANNER_HEIGHT][BANNER_COLUMNS];
176 } BANNER_DATA;
177
178 //
179 // IFR relative definition
180 //
181 #define EFI_HII_EXPRESSION_INCONSISTENT_IF 0
182 #define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1
183 #define EFI_HII_EXPRESSION_GRAY_OUT_IF 2
184 #define EFI_HII_EXPRESSION_SUPPRESS_IF 3
185 #define EFI_HII_EXPRESSION_DISABLE_IF 4
186 #define EFI_HII_EXPRESSION_VALUE 5
187 #define EFI_HII_EXPRESSION_RULE 6
188
189 #define EFI_HII_VARSTORE_BUFFER 0
190 #define EFI_HII_VARSTORE_NAME_VALUE 1
191 #define EFI_HII_VARSTORE_EFI_VARIABLE 2
192
193 #define FORM_INCONSISTENT_VALIDATION 0
194 #define FORM_NO_SUBMIT_VALIDATION 1
195
196 #define FORMSET_CLASS_PLATFORM_SETUP 0x0001
197 #define FORMSET_CLASS_FRONT_PAGE 0x0002
198
199 typedef struct {
200 UINT8 Type;
201 EFI_IFR_TYPE_VALUE Value;
202 } EFI_HII_VALUE;
203
204 #define NAME_VALUE_NODE_SIGNATURE SIGNATURE_32 ('N', 'V', 'S', 'T')
205
206 typedef struct {
207 UINTN Signature;
208 LIST_ENTRY Link;
209 CHAR16 *Name;
210 CHAR16 *Value;
211 CHAR16 *EditValue;
212 } NAME_VALUE_NODE;
213
214 #define NAME_VALUE_NODE_FROM_LINK(a) CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)
215
216 #define FORMSET_STORAGE_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'G')
217
218 typedef struct {
219 UINTN Signature;
220 LIST_ENTRY Link;
221
222 UINT8 Type; // Storage type
223
224 UINT16 VarStoreId;
225 EFI_GUID Guid;
226
227 CHAR16 *Name; // For EFI_IFR_VARSTORE
228 UINT16 Size;
229 UINT8 *Buffer;
230 UINT8 *EditBuffer; // Edit copy for Buffer Storage
231
232 LIST_ENTRY NameValueListHead; // List of NAME_VALUE_NODE
233
234 UINT32 Attributes; // For EFI_IFR_VARSTORE_EFI: EFI Variable attribute
235
236 CHAR16 *ConfigHdr; // <ConfigHdr>
237 CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
238 UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
239 UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
240 } FORMSET_STORAGE;
241
242 #define FORMSET_STORAGE_FROM_LINK(a) CR (a, FORMSET_STORAGE, Link, FORMSET_STORAGE_SIGNATURE)
243
244 #define EXPRESSION_OPCODE_SIGNATURE SIGNATURE_32 ('E', 'X', 'O', 'P')
245
246 typedef struct {
247 UINTN Signature;
248 LIST_ENTRY Link;
249
250 UINT8 Operand;
251
252 UINT8 Format; // For EFI_IFR_TO_STRING, EFI_IFR_FIND
253 UINT8 Flags; // For EFI_IFR_SPAN
254 UINT8 RuleId; // For EFI_IFR_RULE_REF
255
256 EFI_HII_VALUE Value; // For EFI_IFR_EQ_ID_VAL, EFI_IFR_UINT64, EFI_IFR_UINT32, EFI_IFR_UINT16, EFI_IFR_UINT8, EFI_IFR_STRING_REF1
257
258 EFI_QUESTION_ID QuestionId; // For EFI_IFR_EQ_ID_ID, EFI_IFR_EQ_ID_VAL_LIST, EFI_IFR_QUESTION_REF1
259 EFI_QUESTION_ID QuestionId2;
260
261 UINT16 ListLength; // For EFI_IFR_EQ_ID_VAL_LIST
262 UINT16 *ValueList;
263
264 EFI_STRING_ID DevicePath; // For EFI_IFR_QUESTION_REF3_2, EFI_IFR_QUESTION_REF3_3
265 EFI_GUID Guid;
266 } EXPRESSION_OPCODE;
267
268 #define EXPRESSION_OPCODE_FROM_LINK(a) CR (a, EXPRESSION_OPCODE, Link, EXPRESSION_OPCODE_SIGNATURE)
269
270 #define FORM_EXPRESSION_SIGNATURE SIGNATURE_32 ('F', 'E', 'X', 'P')
271
272 typedef struct {
273 UINTN Signature;
274 LIST_ENTRY Link;
275
276 UINT8 Type; // Type for this expression
277
278 UINT8 RuleId; // For EFI_IFR_RULE only
279 EFI_STRING_ID Error; // For EFI_IFR_NO_SUBMIT_IF, EFI_IFR_INCONSISTENT_IF only
280
281 EFI_HII_VALUE Result; // Expression evaluation result
282
283 LIST_ENTRY OpCodeListHead; // OpCodes consist of this expression (EXPRESSION_OPCODE)
284 } FORM_EXPRESSION;
285
286 #define FORM_EXPRESSION_FROM_LINK(a) CR (a, FORM_EXPRESSION, Link, FORM_EXPRESSION_SIGNATURE)
287
288 #define QUESTION_DEFAULT_SIGNATURE SIGNATURE_32 ('Q', 'D', 'F', 'T')
289
290 typedef struct {
291 UINTN Signature;
292 LIST_ENTRY Link;
293
294 UINT16 DefaultId;
295 EFI_HII_VALUE Value; // Default value
296
297 FORM_EXPRESSION *ValueExpression; // Not-NULL indicates default value is provided by EFI_IFR_VALUE
298 } QUESTION_DEFAULT;
299
300 #define QUESTION_DEFAULT_FROM_LINK(a) CR (a, QUESTION_DEFAULT, Link, QUESTION_DEFAULT_SIGNATURE)
301
302 #define QUESTION_OPTION_SIGNATURE SIGNATURE_32 ('Q', 'O', 'P', 'T')
303
304 typedef struct {
305 UINTN Signature;
306 LIST_ENTRY Link;
307
308 EFI_STRING_ID Text;
309 UINT8 Flags;
310 EFI_HII_VALUE Value;
311 EFI_IMAGE_ID ImageId;
312
313 FORM_EXPRESSION *SuppressExpression; // Non-NULL indicates nested inside of SuppressIf
314 } QUESTION_OPTION;
315
316 #define QUESTION_OPTION_FROM_LINK(a) CR (a, QUESTION_OPTION, Link, QUESTION_OPTION_SIGNATURE)
317
318 #define FORM_BROWSER_STATEMENT_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'A')
319 typedef struct {
320 UINTN Signature;
321 LIST_ENTRY Link;
322
323 UINT8 Operand; // The operand (first byte) of this Statement or Question
324
325 //
326 // Statement Header
327 //
328 EFI_STRING_ID Prompt;
329 EFI_STRING_ID Help;
330 EFI_STRING_ID TextTwo; // For EFI_IFR_TEXT
331
332 //
333 // Question Header
334 //
335 EFI_QUESTION_ID QuestionId; // The value of zero is reserved
336 EFI_VARSTORE_ID VarStoreId; // A value of zero indicates no variable storage
337 FORMSET_STORAGE *Storage;
338 union {
339 EFI_STRING_ID VarName;
340 UINT16 VarOffset;
341 } VarStoreInfo;
342 UINT16 StorageWidth;
343 UINT8 QuestionFlags;
344 CHAR16 *VariableName; // Name/Value or EFI Variable name
345 CHAR16 *BlockName; // Buffer storage block name: "OFFSET=...WIDTH=..."
346
347 EFI_HII_VALUE HiiValue; // Edit copy for checkbox, numberic, oneof
348 UINT8 *BufferValue; // Edit copy for string, password, orderedlist
349 UINT8 ValueType; // Data type for orderedlist value array
350
351 //
352 // OpCode specific members
353 //
354 UINT8 Flags; // for EFI_IFR_CHECKBOX, EFI_IFR_DATE, EFI_IFR_NUMERIC, EFI_IFR_ONE_OF,
355 // EFI_IFR_ORDERED_LIST, EFI_IFR_STRING,EFI_IFR_SUBTITLE,EFI_IFR_TIME, EFI_IFR_BANNER
356 UINT8 MaxContainers; // for EFI_IFR_ORDERED_LIST
357
358 UINT16 BannerLineNumber; // for EFI_IFR_BANNER, 1-based line number
359 EFI_STRING_ID QuestionConfig; // for EFI_IFR_ACTION, if 0 then no configuration string will be processed
360
361 UINT64 Minimum; // for EFI_IFR_ONE_OF/EFI_IFR_NUMERIC, it's Min/Max value
362 UINT64 Maximum; // for EFI_IFR_STRING/EFI_IFR_PASSWORD, it's Min/Max length
363 UINT64 Step;
364
365 EFI_DEFAULT_ID DefaultId; // for EFI_IFR_RESET_BUTTON
366 EFI_FORM_ID RefFormId; // for EFI_IFR_REF
367 EFI_QUESTION_ID RefQuestionId; // for EFI_IFR_REF2
368 EFI_GUID RefFormSetId; // for EFI_IFR_REF3
369 EFI_STRING_ID RefDevicePath; // for EFI_IFR_REF4
370
371 //
372 // Get from IFR parsing
373 //
374 FORM_EXPRESSION *ValueExpression; // nested EFI_IFR_VALUE, provide Question value and indicate Question is ReadOnly
375 LIST_ENTRY DefaultListHead; // nested EFI_IFR_DEFAULT list (QUESTION_DEFAULT), provide default values
376 LIST_ENTRY OptionListHead; // nested EFI_IFR_ONE_OF_OPTION list (QUESTION_OPTION)
377
378 EFI_IMAGE_ID ImageId; // nested EFI_IFR_IMAGE
379 UINT8 RefreshInterval; // nested EFI_IFR_REFRESH, refresh interval(in seconds) for Question value, 0 means no refresh
380 BOOLEAN InSubtitle; // nesting inside of EFI_IFR_SUBTITLE
381
382 LIST_ENTRY InconsistentListHead;// nested inconsistent expression list (FORM_EXPRESSION)
383 LIST_ENTRY NoSubmitListHead; // nested nosubmit expression list (FORM_EXPRESSION)
384 FORM_EXPRESSION *GrayOutExpression; // nesting inside of GrayOutIf
385 FORM_EXPRESSION *SuppressExpression; // nesting inside of SuppressIf
386 FORM_EXPRESSION *DisableExpression; // nesting inside of DisableIf
387
388 } FORM_BROWSER_STATEMENT;
389
390 #define FORM_BROWSER_STATEMENT_FROM_LINK(a) CR (a, FORM_BROWSER_STATEMENT, Link, FORM_BROWSER_STATEMENT_SIGNATURE)
391
392 #define FORM_BROWSER_FORM_SIGNATURE SIGNATURE_32 ('F', 'F', 'R', 'M')
393
394 typedef struct {
395 UINTN Signature;
396 LIST_ENTRY Link;
397
398 UINT16 FormId;
399 EFI_STRING_ID FormTitle;
400
401 EFI_IMAGE_ID ImageId;
402
403 LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
404 LIST_ENTRY StatementListHead; // List of Statements and Questions (FORM_BROWSER_STATEMENT)
405 FORM_EXPRESSION *SuppressExpression; // nesting inside of SuppressIf
406 } FORM_BROWSER_FORM;
407
408 #define FORM_BROWSER_FORM_FROM_LINK(a) CR (a, FORM_BROWSER_FORM, Link, FORM_BROWSER_FORM_SIGNATURE)
409
410 #define FORMSET_DEFAULTSTORE_SIGNATURE SIGNATURE_32 ('F', 'D', 'F', 'S')
411
412 typedef struct {
413 UINTN Signature;
414 LIST_ENTRY Link;
415
416 UINT16 DefaultId;
417 EFI_STRING_ID DefaultName;
418 } FORMSET_DEFAULTSTORE;
419
420 #define FORMSET_DEFAULTSTORE_FROM_LINK(a) CR (a, FORMSET_DEFAULTSTORE, Link, FORMSET_DEFAULTSTORE_SIGNATURE)
421
422 typedef struct {
423 EFI_HII_HANDLE HiiHandle;
424 EFI_HANDLE DriverHandle;
425 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
426 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
427
428 UINTN IfrBinaryLength;
429 UINT8 *IfrBinaryData;
430
431 EFI_GUID Guid;
432 EFI_STRING_ID FormSetTitle;
433 EFI_STRING_ID Help;
434 UINT8 NumberOfClassGuid;
435 EFI_GUID ClassGuid[3]; // Up to three ClassGuid
436 UINT16 Class; // Tiano extended Class code
437 UINT16 SubClass; // Tiano extended Subclass code
438 EFI_IMAGE_ID ImageId;
439
440 FORM_BROWSER_STATEMENT *StatementBuffer; // Buffer for all Statements and Questions
441 EXPRESSION_OPCODE *ExpressionBuffer; // Buffer for all Expression OpCode
442
443 LIST_ENTRY StorageListHead; // Storage list (FORMSET_STORAGE)
444 LIST_ENTRY DefaultStoreListHead; // DefaultStore list (FORMSET_DEFAULTSTORE)
445 LIST_ENTRY FormListHead; // Form list (FORM_BROWSER_FORM)
446 LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
447 } FORM_BROWSER_FORMSET;
448
449 #define BROWSER_CONTEXT_SIGNATURE SIGNATURE_32 ('B', 'C', 'T', 'X')
450
451 typedef struct {
452 UINTN Signature;
453 LIST_ENTRY Link;
454
455 //
456 // Globals defined in Setup.c
457 //
458 BANNER_DATA *BannerData;
459 UINTN ClassOfVfr;
460 UINTN FunctionKeySetting;
461 BOOLEAN ResetRequired;
462 BOOLEAN NvUpdateRequired;
463 UINT16 Direction;
464 EFI_SCREEN_DESCRIPTOR ScreenDimensions;
465 CHAR16 *FunctionNineString;
466 CHAR16 *FunctionTenString;
467 CHAR16 *EnterString;
468 CHAR16 *EnterCommitString;
469 CHAR16 *EnterEscapeString;
470 CHAR16 *EscapeString;
471 CHAR16 *SaveFailed;
472 CHAR16 *MoveHighlight;
473 CHAR16 *MakeSelection;
474 CHAR16 *DecNumericInput;
475 CHAR16 *HexNumericInput;
476 CHAR16 *ToggleCheckBox;
477 CHAR16 *PromptForData;
478 CHAR16 *PromptForPassword;
479 CHAR16 *PromptForNewPassword;
480 CHAR16 *ConfirmPassword;
481 CHAR16 *ConfirmError;
482 CHAR16 *PassowordInvalid;
483 CHAR16 *PressEnter;
484 CHAR16 *EmptyString;
485 CHAR16 *AreYouSure;
486 CHAR16 *YesResponse;
487 CHAR16 *NoResponse;
488 CHAR16 *MiniString;
489 CHAR16 *PlusString;
490 CHAR16 *MinusString;
491 CHAR16 *AdjustNumber;
492 CHAR16 *SaveChanges;
493 CHAR16 *OptionMismatch;
494 CHAR16 *FormSuppress;
495 CHAR16 PromptBlockWidth;
496 CHAR16 OptionBlockWidth;
497 CHAR16 HelpBlockWidth;
498 FORM_BROWSER_FORMSET *OldFormSet;
499
500 //
501 // Globals defined in Ui.c
502 //
503 LIST_ENTRY MenuOption;
504 VOID *MenuRefreshHead;
505 } BROWSER_CONTEXT;
506
507 #define BROWSER_CONTEXT_FROM_LINK(a) CR (a, BROWSER_CONTEXT, Link, BROWSER_CONTEXT_SIGNATURE)
508
509 extern EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
510 extern EFI_HII_STRING_PROTOCOL *mHiiString;
511 extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting;
512
513 extern BANNER_DATA *gBannerData;
514 extern EFI_HII_HANDLE gFrontPageHandle;
515 extern UINTN gClassOfVfr;
516 extern UINTN gFunctionKeySetting;
517 extern BOOLEAN gResetRequired;
518 extern BOOLEAN gNvUpdateRequired;
519 extern EFI_HII_HANDLE gHiiHandle;
520 extern UINT16 gDirection;
521 extern EFI_SCREEN_DESCRIPTOR gScreenDimensions;
522
523 extern FORM_BROWSER_FORMSET *gOldFormSet;
524
525 //
526 // Browser Global Strings
527 //
528 extern CHAR16 *gFunctionNineString;
529 extern CHAR16 *gFunctionTenString;
530 extern CHAR16 *gEnterString;
531 extern CHAR16 *gEnterCommitString;
532 extern CHAR16 *gEnterEscapeString;
533 extern CHAR16 *gEscapeString;
534 extern CHAR16 *gSaveFailed;
535 extern CHAR16 *gMoveHighlight;
536 extern CHAR16 *gMakeSelection;
537 extern CHAR16 *gDecNumericInput;
538 extern CHAR16 *gHexNumericInput;
539 extern CHAR16 *gToggleCheckBox;
540 extern CHAR16 *gPromptForData;
541 extern CHAR16 *gPromptForPassword;
542 extern CHAR16 *gPromptForNewPassword;
543 extern CHAR16 *gConfirmPassword;
544 extern CHAR16 *gConfirmError;
545 extern CHAR16 *gPassowordInvalid;
546 extern CHAR16 *gPressEnter;
547 extern CHAR16 *gEmptyString;
548 extern CHAR16 *gAreYouSure;
549 extern CHAR16 *gYesResponse;
550 extern CHAR16 *gNoResponse;
551 extern CHAR16 *gMiniString;
552 extern CHAR16 *gPlusString;
553 extern CHAR16 *gMinusString;
554 extern CHAR16 *gAdjustNumber;
555 extern CHAR16 *gSaveChanges;
556 extern CHAR16 *gOptionMismatch;
557 extern CHAR16 *gFormSuppress;
558
559 extern CHAR16 gPromptBlockWidth;
560 extern CHAR16 gOptionBlockWidth;
561 extern CHAR16 gHelpBlockWidth;
562
563 extern EFI_GUID gZeroGuid;
564 extern EFI_GUID gTianoHiiIfrGuid;
565
566 #include "Ui.h"
567 //
568 // Global Procedure Defines
569 //
570
571 /**
572 Initialize the HII String Token to the correct values.
573
574 **/
575 VOID
576 InitializeBrowserStrings (
577 VOID
578 );
579
580 /**
581 Prints a unicode string to the default console,
582 using L"%s" format.
583
584 @param String String pointer.
585
586 @return Length of string printed to the console
587
588 **/
589 UINTN
590 PrintString (
591 IN CHAR16 *String
592 );
593
594 /**
595 Prints a chracter to the default console,
596 using L"%c" format.
597
598 @param Character Character to print.
599
600 @return Length of string printed to the console.
601
602 **/
603 UINTN
604 PrintChar (
605 CHAR16 Character
606 );
607
608 /**
609 Prints a formatted unicode string to the default console, at
610 the supplied cursor position.
611
612 @param Column The cursor position to print the string at.
613 @param Row The cursor position to print the string at
614 @param Fmt Format string
615 @param ... Variable argument list for formating string.
616
617 @return Length of string printed to the console
618
619 **/
620 UINTN
621 PrintAt (
622 IN UINTN Column,
623 IN UINTN Row,
624 IN CHAR16 *Fmt,
625 ...
626 );
627
628 /**
629 Prints a unicode string to the default console, at
630 the supplied cursor position, using L"%s" format.
631
632 @param Column The cursor position to print the string at.
633 @param Row The cursor position to print the string at
634 @param String String pointer.
635
636 @return Length of string printed to the console
637
638 **/
639 UINTN
640 PrintStringAt (
641 IN UINTN Column,
642 IN UINTN Row,
643 IN CHAR16 *String
644 );
645
646 /**
647 Prints a chracter to the default console, at
648 the supplied cursor position, using L"%c" format.
649
650 @param Column The cursor position to print the string at.
651 @param Row The cursor position to print the string at.
652 @param Character Character to print.
653
654 @return Length of string printed to the console.
655
656 **/
657 UINTN
658 PrintCharAt (
659 IN UINTN Column,
660 IN UINTN Row,
661 CHAR16 Character
662 );
663
664 /**
665 Parse opcodes in the formset IFR binary.
666
667 @param FormSet Pointer of the FormSet data structure.
668
669 @retval EFI_SUCCESS Opcode parse success.
670 @retval Other Opcode parse fail.
671
672 **/
673 EFI_STATUS
674 ParseOpCodes (
675 IN FORM_BROWSER_FORMSET *FormSet
676 );
677
678 /**
679 Free resources allocated for a FormSet.
680
681 @param FormSet Pointer of the FormSet
682
683 **/
684 VOID
685 DestroyFormSet (
686 IN OUT FORM_BROWSER_FORMSET *FormSet
687 );
688
689 /**
690 This function displays the page frame.
691
692 **/
693 VOID
694 DisplayPageFrame (
695 VOID
696 );
697
698 /**
699 Create a new string in HII Package List.
700
701 @param String The String to be added
702 @param HiiHandle The package list in the HII database to insert the
703 specified string.
704
705 @return The output string.
706
707 **/
708 EFI_STRING_ID
709 NewString (
710 IN CHAR16 *String,
711 IN EFI_HII_HANDLE HiiHandle
712 );
713
714 /**
715 Delete a string from HII Package List.
716
717 @param StringId Id of the string in HII database.
718 @param HiiHandle The HII package list handle.
719
720 @retval EFI_SUCCESS The string was deleted successfully.
721
722 **/
723 EFI_STATUS
724 DeleteString (
725 IN EFI_STRING_ID StringId,
726 IN EFI_HII_HANDLE HiiHandle
727 );
728
729 /**
730 Get the string based on the StringId and HII Package List Handle.
731
732 @param Token The String's ID.
733 @param HiiHandle The package list in the HII database to search for
734 the specified string.
735
736 @return The output string.
737
738 **/
739 CHAR16 *
740 GetToken (
741 IN EFI_STRING_ID Token,
742 IN EFI_HII_HANDLE HiiHandle
743 );
744
745 /**
746 Draw a pop up windows based on the dimension, number of lines and
747 strings specified.
748
749 @param RequestedWidth The width of the pop-up.
750 @param NumberOfLines The number of lines.
751 @param Marker The variable argument list for the list of string to be printed.
752
753 **/
754 VOID
755 CreateSharedPopUp (
756 IN UINTN RequestedWidth,
757 IN UINTN NumberOfLines,
758 IN VA_LIST Marker
759 );
760
761 /**
762 Routine used to abstract a generic dialog interface and return the selected key or string
763
764 @param NumberOfLines The number of lines for the dialog box
765 @param HotKey Defines whether a single character is parsed
766 (TRUE) and returned in KeyValue or a string is
767 returned in StringBuffer. Two special characters
768 are considered when entering a string, a SCAN_ESC
769 and an CHAR_CARRIAGE_RETURN. SCAN_ESC terminates
770 string input and returns
771 @param MaximumStringSize The maximum size in bytes of a typed in string
772 (each character is a CHAR16) and the minimum
773 string returned is two bytes
774 @param StringBuffer The passed in pointer to the buffer which will
775 hold the typed in string if HotKey is FALSE
776 @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
777 @param ... A series of (quantity == NumberOfLines) text
778 strings which will be used to construct the dialog
779 box
780
781 @retval EFI_SUCCESS Displayed dialog and received user interaction
782 @retval EFI_INVALID_PARAMETER One of the parameters was invalid (e.g.
783 (StringBuffer == NULL) && (HotKey == FALSE))
784 @retval EFI_DEVICE_ERROR User typed in an ESC character to exit the routine
785
786 **/
787 EFI_STATUS
788 CreateDialog (
789 IN UINTN NumberOfLines,
790 IN BOOLEAN HotKey,
791 IN UINTN MaximumStringSize,
792 OUT CHAR16 *StringBuffer,
793 OUT EFI_INPUT_KEY *KeyValue,
794 ...
795 );
796
797 /**
798 Get Question's current Value.
799
800 @param FormSet FormSet data structure.
801 @param Form Form data structure.
802 @param Question Question to be initialized.
803 @param Cached TRUE: get from Edit copy FALSE: get from original
804 Storage
805
806 @retval EFI_SUCCESS The function completed successfully.
807
808 **/
809 EFI_STATUS
810 GetQuestionValue (
811 IN FORM_BROWSER_FORMSET *FormSet,
812 IN FORM_BROWSER_FORM *Form,
813 IN OUT FORM_BROWSER_STATEMENT *Question,
814 IN BOOLEAN Cached
815 );
816
817 /**
818 Save Question Value to edit copy(cached) or Storage(uncached).
819
820 @param FormSet FormSet data structure.
821 @param Form Form data structure.
822 @param Question Pointer to the Question.
823 @param Cached TRUE: set to Edit copy FALSE: set to original
824 Storage
825
826 @retval EFI_SUCCESS The function completed successfully.
827
828 **/
829 EFI_STATUS
830 SetQuestionValue (
831 IN FORM_BROWSER_FORMSET *FormSet,
832 IN FORM_BROWSER_FORM *Form,
833 IN OUT FORM_BROWSER_STATEMENT *Question,
834 IN BOOLEAN Cached
835 );
836
837 /**
838 Perform inconsistent check for a Form.
839
840 @param FormSet FormSet data structure.
841 @param Form Form data structure.
842 @param Question The Question to be validated.
843 @param Type Validation type: InConsistent or NoSubmit
844
845 @retval EFI_SUCCESS Form validation pass.
846 @retval other Form validation failed.
847
848 **/
849 EFI_STATUS
850 ValidateQuestion (
851 IN FORM_BROWSER_FORMSET *FormSet,
852 IN FORM_BROWSER_FORM *Form,
853 IN FORM_BROWSER_STATEMENT *Question,
854 IN UINTN Type
855 );
856
857 /**
858 Submit a Form.
859
860 @param FormSet FormSet data structure.
861 @param Form Form data structure.
862
863 @retval EFI_SUCCESS The function completed successfully.
864
865 **/
866 EFI_STATUS
867 SubmitForm (
868 IN FORM_BROWSER_FORMSET *FormSet,
869 IN FORM_BROWSER_FORM *Form
870 );
871
872 /**
873 Reset Question to its default value.
874
875 @param FormSet The form set.
876 @param Form The form.
877 @param Question The question.
878 @param DefaultId The Class of the default.
879
880 @retval EFI_SUCCESS Question is reset to default value.
881
882 **/
883 EFI_STATUS
884 GetQuestionDefault (
885 IN FORM_BROWSER_FORMSET *FormSet,
886 IN FORM_BROWSER_FORM *Form,
887 IN FORM_BROWSER_STATEMENT *Question,
888 IN UINT16 DefaultId
889 );
890
891 /**
892 Get current setting of Questions.
893
894 @param FormSet FormSet data structure.
895
896 @retval EFI_SUCCESS The function completed successfully.
897
898 **/
899 EFI_STATUS
900 InitializeCurrentSetting (
901 IN OUT FORM_BROWSER_FORMSET *FormSet
902 );
903
904 /**
905 Initialize the internal data structure of a FormSet.
906
907 @param Handle PackageList Handle
908 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
909 GUID), take the first FormSet found in package
910 list.
911 @param FormSet FormSet data structure.
912
913 @retval EFI_SUCCESS The function completed successfully.
914 @retval EFI_NOT_FOUND The specified FormSet could not be found.
915
916 **/
917 EFI_STATUS
918 InitializeFormSet (
919 IN EFI_HII_HANDLE Handle,
920 IN OUT EFI_GUID *FormSetGuid,
921 OUT FORM_BROWSER_FORMSET *FormSet
922 );
923
924 /**
925 Reset Questions in a Form to their default value.
926
927 @param FormSet FormSet data structure.
928 @param Form The Form which to be reset.
929 @param DefaultId The Class of the default.
930
931 @retval EFI_SUCCESS The function completed successfully.
932
933 **/
934 EFI_STATUS
935 ExtractFormDefault (
936 IN FORM_BROWSER_FORMSET *FormSet,
937 IN FORM_BROWSER_FORM *Form,
938 IN UINT16 DefaultId
939 );
940
941 /**
942 Initialize Question's Edit copy from Storage.
943
944 @param Selection Selection contains the information about
945 the Selection, form and formset to be displayed.
946 Selection action may be updated in retrieve callback.
947 @param FormSet FormSet data structure.
948 @param Form Form data structure.
949
950 @retval EFI_SUCCESS The function completed successfully.
951
952 **/
953 EFI_STATUS
954 LoadFormConfig (
955 IN OUT UI_MENU_SELECTION *Selection,
956 IN FORM_BROWSER_FORMSET *FormSet,
957 IN FORM_BROWSER_FORM *Form
958 );
959
960 /**
961 Initialize Question's Edit copy from Storage for the whole Formset.
962
963 @param Selection Selection contains the information about
964 the Selection, form and formset to be displayed.
965 Selection action may be updated in retrieve callback.
966 @param FormSet FormSet data structure.
967
968 @retval EFI_SUCCESS The function completed successfully.
969
970 **/
971 EFI_STATUS
972 LoadFormSetConfig (
973 IN OUT UI_MENU_SELECTION *Selection,
974 IN FORM_BROWSER_FORMSET *FormSet
975 );
976
977 /**
978 Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
979
980 @param Storage The Storage to be conveted.
981 @param ConfigResp The returned <ConfigResp>.
982
983 @retval EFI_SUCCESS Convert success.
984 @retval EFI_INVALID_PARAMETER Incorrect storage type.
985
986 **/
987 EFI_STATUS
988 StorageToConfigResp (
989 IN FORMSET_STORAGE *Storage,
990 IN CHAR16 **ConfigResp
991 );
992
993 /**
994 Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.
995
996 @param Storage The Storage to receive the settings.
997 @param ConfigResp The <ConfigResp> to be converted.
998
999 @retval EFI_SUCCESS Convert success.
1000 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1001
1002 **/
1003 EFI_STATUS
1004 ConfigRespToStorage (
1005 IN FORMSET_STORAGE *Storage,
1006 IN CHAR16 *ConfigResp
1007 );
1008
1009 /**
1010 Fill storage's edit copy with settings requested from Configuration Driver.
1011
1012 @param FormSet FormSet data structure.
1013 @param Storage Buffer Storage.
1014
1015 @retval EFI_SUCCESS The function completed successfully.
1016
1017 **/
1018 EFI_STATUS
1019 LoadStorage (
1020 IN FORM_BROWSER_FORMSET *FormSet,
1021 IN FORMSET_STORAGE *Storage
1022 );
1023
1024 /**
1025 Fetch the Ifr binary data of a FormSet.
1026
1027 @param Handle PackageList Handle
1028 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
1029 GUID), take the first FormSet found in package
1030 list.
1031 @param BinaryLength The length of the FormSet IFR binary.
1032 @param BinaryData The buffer designed to receive the FormSet.
1033
1034 @retval EFI_SUCCESS Buffer filled with the requested FormSet.
1035 BufferLength was updated.
1036 @retval EFI_INVALID_PARAMETER The handle is unknown.
1037 @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
1038 be found with the requested FormId.
1039
1040 **/
1041 EFI_STATUS
1042 GetIfrBinaryData (
1043 IN EFI_HII_HANDLE Handle,
1044 IN OUT EFI_GUID *FormSetGuid,
1045 OUT UINTN *BinaryLength,
1046 OUT UINT8 **BinaryData
1047 );
1048
1049 /**
1050 Save globals used by previous call to SendForm(). SendForm() may be called from
1051 HiiConfigAccess.Callback(), this will cause SendForm() be reentried.
1052 So, save globals of previous call to SendForm() and restore them upon exit.
1053
1054 **/
1055 VOID
1056 SaveBrowserContext (
1057 VOID
1058 );
1059
1060 /**
1061 Restore globals used by previous call to SendForm().
1062
1063 **/
1064 VOID
1065 RestoreBrowserContext (
1066 VOID
1067 );
1068
1069 /**
1070 This is the routine which an external caller uses to direct the browser
1071 where to obtain it's information.
1072
1073
1074 @param This The Form Browser protocol instanse.
1075 @param Handles A pointer to an array of Handles. If HandleCount > 1 we
1076 display a list of the formsets for the handles specified.
1077 @param HandleCount The number of Handles specified in Handle.
1078 @param FormSetGuid This field points to the EFI_GUID which must match the Guid
1079 field in the EFI_IFR_FORM_SET op-code for the specified
1080 forms-based package. If FormSetGuid is NULL, then this
1081 function will display the first found forms package.
1082 @param FormId This field specifies which EFI_IFR_FORM to render as the first
1083 displayable page. If this field has a value of 0x0000, then
1084 the forms browser will render the specified forms in their encoded order.
1085 ScreenDimenions - This allows the browser to be called so that it occupies a
1086 portion of the physical screen instead of dynamically determining the screen dimensions.
1087 ActionRequest - Points to the action recommended by the form.
1088 @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
1089 characters.
1090 @param ActionRequest Points to the action recommended by the form.
1091
1092 @retval EFI_SUCCESS The function completed successfully.
1093 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1094 @retval EFI_NOT_FOUND No valid forms could be found to display.
1095
1096 **/
1097 EFI_STATUS
1098 EFIAPI
1099 SendForm (
1100 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1101 IN EFI_HII_HANDLE *Handles,
1102 IN UINTN HandleCount,
1103 IN EFI_GUID *FormSetGuid, OPTIONAL
1104 IN UINT16 FormId, OPTIONAL
1105 IN CONST EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
1106 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OPTIONAL
1107 );
1108
1109 /**
1110 This function is called by a callback handler to retrieve uncommitted state
1111 data from the browser.
1112
1113 @param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL
1114 instance.
1115 @param ResultsDataSize A pointer to the size of the buffer associated
1116 with ResultsData.
1117 @param ResultsData A string returned from an IFR browser or
1118 equivalent. The results string will have no
1119 routing information in them.
1120 @param RetrieveData A BOOLEAN field which allows an agent to retrieve
1121 (if RetrieveData = TRUE) data from the uncommitted
1122 browser state information or set (if RetrieveData
1123 = FALSE) data in the uncommitted browser state
1124 information.
1125 @param VariableGuid An optional field to indicate the target variable
1126 GUID name to use.
1127 @param VariableName An optional field to indicate the target
1128 human-readable variable name.
1129
1130 @retval EFI_SUCCESS The results have been distributed or are awaiting
1131 distribution.
1132 @retval EFI_BUFFER_TOO_SMALL The ResultsDataSize specified was too small to
1133 contain the results data.
1134
1135 **/
1136 EFI_STATUS
1137 EFIAPI
1138 BrowserCallback (
1139 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1140 IN OUT UINTN *ResultsDataSize,
1141 IN OUT EFI_STRING ResultsData,
1142 IN BOOLEAN RetrieveData,
1143 IN CONST EFI_GUID *VariableGuid, OPTIONAL
1144 IN CONST CHAR16 *VariableName OPTIONAL
1145 );
1146
1147 #endif