]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
Update the copyright notice format
[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 4
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 PrintAt (
637 IN UINTN Column,
638 IN UINTN Row,
639 IN CHAR16 *Fmt,
640 ...
641 );
642
643 /**
644 Prints a unicode string to the default console, at
645 the supplied cursor position, using L"%s" format.
646
647 @param Column The cursor position to print the string at.
648 @param Row The cursor position to print the string at
649 @param String String pointer.
650
651 @return Length of string printed to the console
652
653 **/
654 UINTN
655 PrintStringAt (
656 IN UINTN Column,
657 IN UINTN Row,
658 IN CHAR16 *String
659 );
660
661 /**
662 Prints a chracter to the default console, at
663 the supplied cursor position, using L"%c" format.
664
665 @param Column The cursor position to print the string at.
666 @param Row The cursor position to print the string at.
667 @param Character Character to print.
668
669 @return Length of string printed to the console.
670
671 **/
672 UINTN
673 PrintCharAt (
674 IN UINTN Column,
675 IN UINTN Row,
676 CHAR16 Character
677 );
678
679 /**
680 Parse opcodes in the formset IFR binary.
681
682 @param FormSet Pointer of the FormSet data structure.
683
684 @retval EFI_SUCCESS Opcode parse success.
685 @retval Other Opcode parse fail.
686
687 **/
688 EFI_STATUS
689 ParseOpCodes (
690 IN FORM_BROWSER_FORMSET *FormSet
691 );
692
693 /**
694 Free resources allocated for a FormSet.
695
696 @param FormSet Pointer of the FormSet
697
698 **/
699 VOID
700 DestroyFormSet (
701 IN OUT FORM_BROWSER_FORMSET *FormSet
702 );
703
704 /**
705 This function displays the page frame.
706
707 **/
708 VOID
709 DisplayPageFrame (
710 VOID
711 );
712
713 /**
714 Create a new string in HII Package List.
715
716 @param String The String to be added
717 @param HiiHandle The package list in the HII database to insert the
718 specified string.
719
720 @return The output string.
721
722 **/
723 EFI_STRING_ID
724 NewString (
725 IN CHAR16 *String,
726 IN EFI_HII_HANDLE HiiHandle
727 );
728
729 /**
730 Delete a string from HII Package List.
731
732 @param StringId Id of the string in HII database.
733 @param HiiHandle The HII package list handle.
734
735 @retval EFI_SUCCESS The string was deleted successfully.
736
737 **/
738 EFI_STATUS
739 DeleteString (
740 IN EFI_STRING_ID StringId,
741 IN EFI_HII_HANDLE HiiHandle
742 );
743
744 /**
745 Get the string based on the StringId and HII Package List Handle.
746
747 @param Token The String's ID.
748 @param HiiHandle The package list in the HII database to search for
749 the specified string.
750
751 @return The output string.
752
753 **/
754 CHAR16 *
755 GetToken (
756 IN EFI_STRING_ID Token,
757 IN EFI_HII_HANDLE HiiHandle
758 );
759
760 /**
761 Draw a pop up windows based on the dimension, number of lines and
762 strings specified.
763
764 @param RequestedWidth The width of the pop-up.
765 @param NumberOfLines The number of lines.
766 @param Marker The variable argument list for the list of string to be printed.
767
768 **/
769 VOID
770 CreateSharedPopUp (
771 IN UINTN RequestedWidth,
772 IN UINTN NumberOfLines,
773 IN VA_LIST Marker
774 );
775
776 /**
777 Routine used to abstract a generic dialog interface and return the selected key or string
778
779 @param NumberOfLines The number of lines for the dialog box
780 @param HotKey Defines whether a single character is parsed
781 (TRUE) and returned in KeyValue or a string is
782 returned in StringBuffer. Two special characters
783 are considered when entering a string, a SCAN_ESC
784 and an CHAR_CARRIAGE_RETURN. SCAN_ESC terminates
785 string input and returns
786 @param MaximumStringSize The maximum size in bytes of a typed in string
787 (each character is a CHAR16) and the minimum
788 string returned is two bytes
789 @param StringBuffer The passed in pointer to the buffer which will
790 hold the typed in string if HotKey is FALSE
791 @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
792 @param ... A series of (quantity == NumberOfLines) text
793 strings which will be used to construct the dialog
794 box
795
796 @retval EFI_SUCCESS Displayed dialog and received user interaction
797 @retval EFI_INVALID_PARAMETER One of the parameters was invalid (e.g.
798 (StringBuffer == NULL) && (HotKey == FALSE))
799 @retval EFI_DEVICE_ERROR User typed in an ESC character to exit the routine
800
801 **/
802 EFI_STATUS
803 CreateDialog (
804 IN UINTN NumberOfLines,
805 IN BOOLEAN HotKey,
806 IN UINTN MaximumStringSize,
807 OUT CHAR16 *StringBuffer,
808 OUT EFI_INPUT_KEY *KeyValue,
809 ...
810 );
811
812 /**
813 Get Value for given Name from a NameValue Storage.
814
815 @param Storage The NameValue Storage.
816 @param Name The Name.
817 @param Value The retured Value.
818
819 @retval EFI_SUCCESS Value found for given Name.
820 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
821
822 **/
823 EFI_STATUS
824 GetValueByName (
825 IN FORMSET_STORAGE *Storage,
826 IN CHAR16 *Name,
827 IN OUT CHAR16 **Value
828 );
829
830 /**
831 Set Value of given Name in a NameValue Storage.
832
833 @param Storage The NameValue Storage.
834 @param Name The Name.
835 @param Value The Value to set.
836
837 @retval EFI_SUCCESS Value found for given Name.
838 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
839
840 **/
841 EFI_STATUS
842 SetValueByName (
843 IN FORMSET_STORAGE *Storage,
844 IN CHAR16 *Name,
845 IN CHAR16 *Value
846 );
847
848 /**
849 Get Question's current Value.
850
851 @param FormSet FormSet data structure.
852 @param Form Form data structure.
853 @param Question Question to be initialized.
854 @param Cached TRUE: get from Edit copy FALSE: get from original
855 Storage
856
857 @retval EFI_SUCCESS The function completed successfully.
858
859 **/
860 EFI_STATUS
861 GetQuestionValue (
862 IN FORM_BROWSER_FORMSET *FormSet,
863 IN FORM_BROWSER_FORM *Form,
864 IN OUT FORM_BROWSER_STATEMENT *Question,
865 IN BOOLEAN Cached
866 );
867
868 /**
869 Save Question Value to edit copy(cached) or Storage(uncached).
870
871 @param FormSet FormSet data structure.
872 @param Form Form data structure.
873 @param Question Pointer to the Question.
874 @param Cached TRUE: set to Edit copy FALSE: set to original
875 Storage
876
877 @retval EFI_SUCCESS The function completed successfully.
878
879 **/
880 EFI_STATUS
881 SetQuestionValue (
882 IN FORM_BROWSER_FORMSET *FormSet,
883 IN FORM_BROWSER_FORM *Form,
884 IN OUT FORM_BROWSER_STATEMENT *Question,
885 IN BOOLEAN Cached
886 );
887
888 /**
889 Perform inconsistent check for a Form.
890
891 @param FormSet FormSet data structure.
892 @param Form Form data structure.
893 @param Question The Question to be validated.
894 @param Type Validation type: InConsistent or NoSubmit
895
896 @retval EFI_SUCCESS Form validation pass.
897 @retval other Form validation failed.
898
899 **/
900 EFI_STATUS
901 ValidateQuestion (
902 IN FORM_BROWSER_FORMSET *FormSet,
903 IN FORM_BROWSER_FORM *Form,
904 IN FORM_BROWSER_STATEMENT *Question,
905 IN UINTN Type
906 );
907
908 /**
909 Submit a Form.
910
911 @param FormSet FormSet data structure.
912 @param Form Form data structure.
913
914 @retval EFI_SUCCESS The function completed successfully.
915
916 **/
917 EFI_STATUS
918 SubmitForm (
919 IN FORM_BROWSER_FORMSET *FormSet,
920 IN FORM_BROWSER_FORM *Form
921 );
922
923 /**
924 Reset Question to its default value.
925
926 @param FormSet The form set.
927 @param Form The form.
928 @param Question The question.
929 @param DefaultId The Class of the default.
930
931 @retval EFI_SUCCESS Question is reset to default value.
932
933 **/
934 EFI_STATUS
935 GetQuestionDefault (
936 IN FORM_BROWSER_FORMSET *FormSet,
937 IN FORM_BROWSER_FORM *Form,
938 IN FORM_BROWSER_STATEMENT *Question,
939 IN UINT16 DefaultId
940 );
941
942 /**
943 Get current setting of Questions.
944
945 @param FormSet FormSet data structure.
946
947 @retval EFI_SUCCESS The function completed successfully.
948
949 **/
950 EFI_STATUS
951 InitializeCurrentSetting (
952 IN OUT FORM_BROWSER_FORMSET *FormSet
953 );
954
955 /**
956 Initialize the internal data structure of a FormSet.
957
958 @param Handle PackageList Handle
959 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
960 GUID), take the first FormSet found in package
961 list.
962 @param FormSet FormSet data structure.
963
964 @retval EFI_SUCCESS The function completed successfully.
965 @retval EFI_NOT_FOUND The specified FormSet could not be found.
966
967 **/
968 EFI_STATUS
969 InitializeFormSet (
970 IN EFI_HII_HANDLE Handle,
971 IN OUT EFI_GUID *FormSetGuid,
972 OUT FORM_BROWSER_FORMSET *FormSet
973 );
974
975 /**
976 Reset Questions in a Form to their default value.
977
978 @param FormSet FormSet data structure.
979 @param Form The Form which to be reset.
980 @param DefaultId The Class of the default.
981
982 @retval EFI_SUCCESS The function completed successfully.
983
984 **/
985 EFI_STATUS
986 ExtractFormDefault (
987 IN FORM_BROWSER_FORMSET *FormSet,
988 IN FORM_BROWSER_FORM *Form,
989 IN UINT16 DefaultId
990 );
991
992 /**
993 Initialize Question's Edit copy from Storage.
994
995 @param Selection Selection contains the information about
996 the Selection, form and formset to be displayed.
997 Selection action may be updated in retrieve callback.
998 @param FormSet FormSet data structure.
999 @param Form Form data structure.
1000
1001 @retval EFI_SUCCESS The function completed successfully.
1002
1003 **/
1004 EFI_STATUS
1005 LoadFormConfig (
1006 IN OUT UI_MENU_SELECTION *Selection,
1007 IN FORM_BROWSER_FORMSET *FormSet,
1008 IN FORM_BROWSER_FORM *Form
1009 );
1010
1011 /**
1012 Initialize Question's Edit copy from Storage for the whole Formset.
1013
1014 @param Selection Selection contains the information about
1015 the Selection, form and formset to be displayed.
1016 Selection action may be updated in retrieve callback.
1017 @param FormSet FormSet data structure.
1018
1019 @retval EFI_SUCCESS The function completed successfully.
1020
1021 **/
1022 EFI_STATUS
1023 LoadFormSetConfig (
1024 IN OUT UI_MENU_SELECTION *Selection,
1025 IN FORM_BROWSER_FORMSET *FormSet
1026 );
1027
1028 /**
1029 Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
1030
1031 @param Storage The Storage to be conveted.
1032 @param ConfigResp The returned <ConfigResp>.
1033
1034 @retval EFI_SUCCESS Convert success.
1035 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1036
1037 **/
1038 EFI_STATUS
1039 StorageToConfigResp (
1040 IN FORMSET_STORAGE *Storage,
1041 IN CHAR16 **ConfigResp
1042 );
1043
1044 /**
1045 Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.
1046
1047 @param Storage The Storage to receive the settings.
1048 @param ConfigResp The <ConfigResp> to be converted.
1049
1050 @retval EFI_SUCCESS Convert success.
1051 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1052
1053 **/
1054 EFI_STATUS
1055 ConfigRespToStorage (
1056 IN FORMSET_STORAGE *Storage,
1057 IN CHAR16 *ConfigResp
1058 );
1059
1060 /**
1061 Fill storage's edit copy with settings requested from Configuration Driver.
1062
1063 @param FormSet FormSet data structure.
1064 @param Storage Buffer Storage.
1065
1066 @retval EFI_SUCCESS The function completed successfully.
1067
1068 **/
1069 EFI_STATUS
1070 LoadStorage (
1071 IN FORM_BROWSER_FORMSET *FormSet,
1072 IN FORMSET_STORAGE *Storage
1073 );
1074
1075 /**
1076 Fetch the Ifr binary data of a FormSet.
1077
1078 @param Handle PackageList Handle
1079 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
1080 GUID), take the first FormSet found in package
1081 list.
1082 @param BinaryLength The length of the FormSet IFR binary.
1083 @param BinaryData The buffer designed to receive the FormSet.
1084
1085 @retval EFI_SUCCESS Buffer filled with the requested FormSet.
1086 BufferLength was updated.
1087 @retval EFI_INVALID_PARAMETER The handle is unknown.
1088 @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
1089 be found with the requested FormId.
1090
1091 **/
1092 EFI_STATUS
1093 GetIfrBinaryData (
1094 IN EFI_HII_HANDLE Handle,
1095 IN OUT EFI_GUID *FormSetGuid,
1096 OUT UINTN *BinaryLength,
1097 OUT UINT8 **BinaryData
1098 );
1099
1100 /**
1101 Save globals used by previous call to SendForm(). SendForm() may be called from
1102 HiiConfigAccess.Callback(), this will cause SendForm() be reentried.
1103 So, save globals of previous call to SendForm() and restore them upon exit.
1104
1105 **/
1106 VOID
1107 SaveBrowserContext (
1108 VOID
1109 );
1110
1111 /**
1112 Restore globals used by previous call to SendForm().
1113
1114 **/
1115 VOID
1116 RestoreBrowserContext (
1117 VOID
1118 );
1119
1120 /**
1121 This is the routine which an external caller uses to direct the browser
1122 where to obtain it's information.
1123
1124
1125 @param This The Form Browser protocol instanse.
1126 @param Handles A pointer to an array of Handles. If HandleCount > 1 we
1127 display a list of the formsets for the handles specified.
1128 @param HandleCount The number of Handles specified in Handle.
1129 @param FormSetGuid This field points to the EFI_GUID which must match the Guid
1130 field in the EFI_IFR_FORM_SET op-code for the specified
1131 forms-based package. If FormSetGuid is NULL, then this
1132 function will display the first found forms package.
1133 @param FormId This field specifies which EFI_IFR_FORM to render as the first
1134 displayable page. If this field has a value of 0x0000, then
1135 the forms browser will render the specified forms in their encoded order.
1136 ScreenDimenions - This allows the browser to be called so that it occupies a
1137 portion of the physical screen instead of dynamically determining the screen dimensions.
1138 ActionRequest - Points to the action recommended by the form.
1139 @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
1140 characters.
1141 @param ActionRequest Points to the action recommended by the form.
1142
1143 @retval EFI_SUCCESS The function completed successfully.
1144 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1145 @retval EFI_NOT_FOUND No valid forms could be found to display.
1146
1147 **/
1148 EFI_STATUS
1149 EFIAPI
1150 SendForm (
1151 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1152 IN EFI_HII_HANDLE *Handles,
1153 IN UINTN HandleCount,
1154 IN EFI_GUID *FormSetGuid, OPTIONAL
1155 IN UINT16 FormId, OPTIONAL
1156 IN CONST EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
1157 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OPTIONAL
1158 );
1159
1160 /**
1161 This function is called by a callback handler to retrieve uncommitted state
1162 data from the browser.
1163
1164 @param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL
1165 instance.
1166 @param ResultsDataSize A pointer to the size of the buffer associated
1167 with ResultsData.
1168 @param ResultsData A string returned from an IFR browser or
1169 equivalent. The results string will have no
1170 routing information in them.
1171 @param RetrieveData A BOOLEAN field which allows an agent to retrieve
1172 (if RetrieveData = TRUE) data from the uncommitted
1173 browser state information or set (if RetrieveData
1174 = FALSE) data in the uncommitted browser state
1175 information.
1176 @param VariableGuid An optional field to indicate the target variable
1177 GUID name to use.
1178 @param VariableName An optional field to indicate the target
1179 human-readable variable name.
1180
1181 @retval EFI_SUCCESS The results have been distributed or are awaiting
1182 distribution.
1183 @retval EFI_BUFFER_TOO_SMALL The ResultsDataSize specified was too small to
1184 contain the results data.
1185
1186 **/
1187 EFI_STATUS
1188 EFIAPI
1189 BrowserCallback (
1190 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1191 IN OUT UINTN *ResultsDataSize,
1192 IN OUT EFI_STRING ResultsData,
1193 IN BOOLEAN RetrieveData,
1194 IN CONST EFI_GUID *VariableGuid, OPTIONAL
1195 IN CONST CHAR16 *VariableName OPTIONAL
1196 );
1197
1198 #endif