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