]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[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 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7
8 **/
9
10 #ifndef _SETUP_H_
11 #define _SETUP_H_
12
13
14 #include <PiDxe.h>
15
16 #include <Protocol/SimpleTextOut.h>
17 #include <Protocol/SimpleTextIn.h>
18 #include <Protocol/FormBrowser2.h>
19 #include <Protocol/FormBrowserEx2.h>
20 #include <Protocol/DisplayProtocol.h>
21 #include <Protocol/DevicePath.h>
22 #include <Protocol/UnicodeCollation.h>
23 #include <Protocol/HiiConfigAccess.h>
24 #include <Protocol/HiiConfigRouting.h>
25 #include <Protocol/HiiDatabase.h>
26 #include <Protocol/HiiString.h>
27 #include <Protocol/UserManager.h>
28 #include <Protocol/DevicePathFromText.h>
29 #include <Protocol/RegularExpressionProtocol.h>
30
31 #include <Guid/MdeModuleHii.h>
32 #include <Guid/HiiPlatformSetupFormset.h>
33 #include <Guid/HiiFormMapMethodGuid.h>
34 #include <Guid/ZeroGuid.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 #include <Library/UefiLib.h>
48
49
50 //
51 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
52 //
53
54 #define UI_ACTION_NONE 0
55 #define UI_ACTION_REFRESH_FORM 1
56 #define UI_ACTION_REFRESH_FORMSET 2
57 #define UI_ACTION_EXIT 3
58
59 //
60 //
61 // Time definitions
62 //
63 #define ONE_SECOND 10000000
64
65 // Incremental string lenght of ConfigRequest
66 //
67 #define CONFIG_REQUEST_STRING_INCREMENTAL 1024
68
69 //
70 // Incremental size of stack for expression
71 //
72 #define EXPRESSION_STACK_SIZE_INCREMENT 0x100
73
74 #define EFI_IFR_SPECIFICATION_VERSION (UINT16) (((EFI_SYSTEM_TABLE_REVISION >> 16) << 8) | (((EFI_SYSTEM_TABLE_REVISION & 0xFFFF) / 10) << 4) | ((EFI_SYSTEM_TABLE_REVISION & 0xFFFF) % 10))
75
76
77 #define SETUP_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'B', 'D', 'V')
78 typedef struct {
79 UINT32 Signature;
80
81 EFI_HANDLE Handle;
82
83 //
84 // Produced protocol
85 //
86 EFI_FORM_BROWSER2_PROTOCOL FormBrowser2;
87 EDKII_FORM_BROWSER_EXTENSION_PROTOCOL FormBrowserEx;
88
89 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL FormBrowserEx2;
90
91 } SETUP_DRIVER_PRIVATE_DATA;
92
93 //
94 // IFR relative definition
95 //
96 #define EFI_HII_EXPRESSION_INCONSISTENT_IF 0
97 #define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1
98 #define EFI_HII_EXPRESSION_GRAY_OUT_IF 2
99 #define EFI_HII_EXPRESSION_SUPPRESS_IF 3
100 #define EFI_HII_EXPRESSION_DISABLE_IF 4
101 #define EFI_HII_EXPRESSION_VALUE 5
102 #define EFI_HII_EXPRESSION_RULE 6
103 #define EFI_HII_EXPRESSION_READ 7
104 #define EFI_HII_EXPRESSION_WRITE 8
105 #define EFI_HII_EXPRESSION_WARNING_IF 9
106
107 #define EFI_HII_VARSTORE_BUFFER 0
108 #define EFI_HII_VARSTORE_NAME_VALUE 1
109 #define EFI_HII_VARSTORE_EFI_VARIABLE 2 // EFI Varstore type follow UEFI spec before 2.3.1.
110 #define EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER 3 // EFI varstore type follow UEFI spec 2.3.1 and later.
111
112 #define FORM_INCONSISTENT_VALIDATION 0
113 #define FORM_NO_SUBMIT_VALIDATION 1
114
115 #define NAME_VALUE_NODE_SIGNATURE SIGNATURE_32 ('N', 'V', 'S', 'T')
116
117 typedef struct {
118 UINTN Signature;
119 LIST_ENTRY Link;
120 CHAR16 *Name;
121 CHAR16 *Value;
122 CHAR16 *EditValue;
123 } NAME_VALUE_NODE;
124
125 #define NAME_VALUE_NODE_FROM_LINK(a) CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)
126
127 #define BROWSER_STORAGE_SIGNATURE SIGNATURE_32 ('B', 'S', 'T', 'G')
128
129 typedef struct {
130 UINTN Signature;
131 LIST_ENTRY Link;
132
133 UINT8 Type; // Storage type
134
135 BOOLEAN Initialized; // Whether this varstore is initialized, efi varstore not used.
136
137 EFI_HII_HANDLE HiiHandle; // HiiHandle for this varstore, efi varstore not used.
138 EFI_GUID Guid;
139
140 CHAR16 *Name; // For EFI_IFR_VARSTORE
141 UINT16 Size;
142 UINT8 *Buffer;
143 UINT8 *EditBuffer; // Edit copy for Buffer Storage
144
145 LIST_ENTRY NameValueListHead; // List of NAME_VALUE_NODE
146
147 UINT32 Attributes; // For EFI_IFR_VARSTORE_EFI: EFI Variable attribute
148
149 CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
150 // <RequestElement> includes all fields which is used by current form sets.
151 UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
152 } BROWSER_STORAGE;
153
154 #define BROWSER_STORAGE_FROM_LINK(a) CR (a, BROWSER_STORAGE, Link, BROWSER_STORAGE_SIGNATURE)
155
156 #define FORMSET_STORAGE_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'G')
157
158 typedef struct {
159 UINTN Signature;
160 LIST_ENTRY Link;
161
162 LIST_ENTRY SaveFailLink;
163
164 UINT16 VarStoreId;
165
166 BROWSER_STORAGE *BrowserStorage;
167
168 CHAR16 *ConfigHdr; // <ConfigHdr>
169
170 CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
171 CHAR16 *ConfigAltResp; // Alt config response string for this ConfigRequest.
172 BOOLEAN HasCallAltCfg; // Flag to show whether browser has call ExtractConfig to get Altcfg string.
173 UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
174 UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
175 CHAR16 *RestoreConfigRequest; // When submit formset fail, the element need to be restored
176 CHAR16 *SyncConfigRequest; // When submit formset fail, the element need to be synced
177 } FORMSET_STORAGE;
178
179 #define FORMSET_STORAGE_FROM_LINK(a) CR (a, FORMSET_STORAGE, Link, FORMSET_STORAGE_SIGNATURE)
180 #define FORMSET_STORAGE_FROM_SAVE_FAIL_LINK(a) CR (a, FORMSET_STORAGE, SaveFailLink, FORMSET_STORAGE_SIGNATURE)
181
182 typedef union {
183 EFI_STRING_ID VarName;
184 UINT16 VarOffset;
185 } VAR_STORE_INFO;
186
187 #define EXPRESSION_OPCODE_SIGNATURE SIGNATURE_32 ('E', 'X', 'O', 'P')
188
189 typedef struct {
190 UINTN Signature;
191 LIST_ENTRY Link;
192
193 UINT8 Operand;
194
195 UINT8 Format; // For EFI_IFR_TO_STRING, EFI_IFR_FIND
196 UINT8 Flags; // For EFI_IFR_SPAN
197 UINT8 RuleId; // For EFI_IFR_RULE_REF
198
199 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
200
201 EFI_QUESTION_ID QuestionId; // For EFI_IFR_EQ_ID_ID, EFI_IFR_EQ_ID_VAL_LIST, EFI_IFR_QUESTION_REF1
202 EFI_QUESTION_ID QuestionId2;
203
204 UINT16 ListLength; // For EFI_IFR_EQ_ID_VAL_LIST
205 UINT16 *ValueList;
206
207 EFI_STRING_ID DevicePath; // For EFI_IFR_QUESTION_REF3_2, EFI_IFR_QUESTION_REF3_3
208 EFI_GUID Guid;
209
210 BROWSER_STORAGE *VarStorage; // For EFI_IFR_SET, EFI_IFR_GET
211 VAR_STORE_INFO VarStoreInfo;// For EFI_IFR_SET, EFI_IFR_GET
212 UINT8 ValueType; // For EFI_IFR_SET, EFI_IFR_GET
213 UINT8 ValueWidth; // For EFI_IFR_SET, EFI_IFR_GET
214 CHAR16 *ValueName; // For EFI_IFR_SET, EFI_IFR_GET
215 LIST_ENTRY MapExpressionList; // nested expressions inside of Map opcode.
216 } EXPRESSION_OPCODE;
217
218 #define EXPRESSION_OPCODE_FROM_LINK(a) CR (a, EXPRESSION_OPCODE, Link, EXPRESSION_OPCODE_SIGNATURE)
219
220 #define FORM_EXPRESSION_SIGNATURE SIGNATURE_32 ('F', 'E', 'X', 'P')
221
222 typedef struct {
223 UINTN Signature;
224 LIST_ENTRY Link;
225
226 UINT8 Type; // Type for this expression
227
228 UINT8 RuleId; // For EFI_IFR_RULE only
229 EFI_STRING_ID Error; // For EFI_IFR_NO_SUBMIT_IF, EFI_IFR_INCONSISTENT_IF only
230
231 EFI_HII_VALUE Result; // Expression evaluation result
232
233 UINT8 TimeOut; // For EFI_IFR_WARNING_IF
234 EFI_IFR_OP_HEADER *OpCode; // Save the opcode buffer.
235
236 LIST_ENTRY OpCodeListHead; // OpCodes consist of this expression (EXPRESSION_OPCODE)
237 } FORM_EXPRESSION;
238
239 #define FORM_EXPRESSION_FROM_LINK(a) CR (a, FORM_EXPRESSION, Link, FORM_EXPRESSION_SIGNATURE)
240
241 #define FORM_EXPRESSION_LIST_SIGNATURE SIGNATURE_32 ('F', 'E', 'X', 'R')
242
243 typedef struct {
244 UINTN Signature;
245 UINTN Count;
246 FORM_EXPRESSION *Expression[1]; // Array[Count] of expressions
247 } FORM_EXPRESSION_LIST;
248
249 #define QUESTION_DEFAULT_SIGNATURE SIGNATURE_32 ('Q', 'D', 'F', 'T')
250
251 typedef struct {
252 UINTN Signature;
253 LIST_ENTRY Link;
254
255 UINT16 DefaultId;
256 EFI_HII_VALUE Value; // Default value
257
258 FORM_EXPRESSION *ValueExpression; // Not-NULL indicates default value is provided by EFI_IFR_VALUE
259 } QUESTION_DEFAULT;
260
261 #define QUESTION_DEFAULT_FROM_LINK(a) CR (a, QUESTION_DEFAULT, Link, QUESTION_DEFAULT_SIGNATURE)
262
263 #define QUESTION_OPTION_SIGNATURE SIGNATURE_32 ('Q', 'O', 'P', 'T')
264
265 typedef struct {
266 UINTN Signature;
267 LIST_ENTRY Link;
268
269 EFI_IFR_ONE_OF_OPTION *OpCode; // OneOfOption Data
270
271 EFI_STRING_ID Text;
272 UINT8 Flags;
273 EFI_HII_VALUE Value;
274 EFI_IMAGE_ID ImageId;
275
276 FORM_EXPRESSION_LIST *SuppressExpression; // Non-NULL indicates nested inside of SuppressIf
277 } QUESTION_OPTION;
278
279 #define QUESTION_OPTION_FROM_LINK(a) CR (a, QUESTION_OPTION, Link, QUESTION_OPTION_SIGNATURE)
280
281 typedef enum {
282 ExpressFalse = 0,
283 ExpressGrayOut,
284 ExpressSuppress,
285 ExpressDisable
286 } EXPRESS_RESULT;
287
288 typedef enum {
289 ExpressNone = 0,
290 ExpressForm,
291 ExpressStatement,
292 ExpressOption
293 } EXPRESS_LEVEL;
294
295 typedef struct _FORM_BROWSER_STATEMENT FORM_BROWSER_STATEMENT;
296
297 #define FORM_BROWSER_STATEMENT_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'A')
298
299 struct _FORM_BROWSER_STATEMENT{
300 UINTN Signature;
301 LIST_ENTRY Link;
302
303 UINT8 Operand; // The operand (first byte) of this Statement or Question
304 EFI_IFR_OP_HEADER *OpCode;
305
306 //
307 // Statement Header
308 //
309 EFI_STRING_ID Prompt;
310 EFI_STRING_ID Help;
311 EFI_STRING_ID TextTwo; // For EFI_IFR_TEXT
312
313 //
314 // Fake Question Id, used for statement not has true QuestionId.
315 //
316 EFI_QUESTION_ID FakeQuestionId;
317
318 //
319 // Question Header
320 //
321 EFI_QUESTION_ID QuestionId; // The value of zero is reserved
322 EFI_VARSTORE_ID VarStoreId; // A value of zero indicates no variable storage
323 BROWSER_STORAGE *Storage;
324 VAR_STORE_INFO VarStoreInfo;
325 UINT16 StorageWidth;
326 UINT16 BitStorageWidth;
327 UINT16 BitVarOffset;
328 UINT8 QuestionFlags;
329 BOOLEAN QuestionReferToBitField;// Whether the question is stored in a bit field.
330 CHAR16 *VariableName; // Name/Value or EFI Variable name
331 CHAR16 *BlockName; // Buffer storage block name: "OFFSET=...WIDTH=..."
332
333 EFI_HII_VALUE HiiValue; // Edit copy for checkbox, numberic, oneof
334 UINT8 *BufferValue; // Edit copy for string, password, orderedlist
335 UINT8 ValueType; // Data type for orderedlist value array
336
337 //
338 // OpCode specific members
339 //
340 UINT8 Flags; // for EFI_IFR_CHECKBOX, EFI_IFR_DATE, EFI_IFR_NUMERIC, EFI_IFR_ONE_OF,
341 // EFI_IFR_ORDERED_LIST, EFI_IFR_STRING,EFI_IFR_SUBTITLE,EFI_IFR_TIME, EFI_IFR_BANNER
342 UINT8 MaxContainers; // for EFI_IFR_ORDERED_LIST
343
344 UINT16 BannerLineNumber; // for EFI_IFR_BANNER, 1-based line number
345 EFI_STRING_ID QuestionConfig; // for EFI_IFR_ACTION, if 0 then no configuration string will be processed
346
347 UINT64 Minimum; // for EFI_IFR_ONE_OF/EFI_IFR_NUMERIC, it's Min/Max value
348 UINT64 Maximum; // for EFI_IFR_STRING/EFI_IFR_PASSWORD, it's Min/Max length
349 UINT64 Step;
350
351 EFI_DEFAULT_ID DefaultId; // for EFI_IFR_RESET_BUTTON
352 EFI_GUID RefreshGuid; // for EFI_IFR_REFRESH_ID
353 BOOLEAN Locked; // Whether this statement is locked.
354 BOOLEAN ValueChanged; // Whether this statement's value is changed.
355 //
356 // Get from IFR parsing
357 //
358 FORM_EXPRESSION *ValueExpression; // nested EFI_IFR_VALUE, provide Question value and indicate Question is ReadOnly
359 LIST_ENTRY DefaultListHead; // nested EFI_IFR_DEFAULT list (QUESTION_DEFAULT), provide default values
360 LIST_ENTRY OptionListHead; // nested EFI_IFR_ONE_OF_OPTION list (QUESTION_OPTION)
361
362 EFI_IMAGE_ID ImageId; // nested EFI_IFR_IMAGE
363 UINT8 RefreshInterval; // nested EFI_IFR_REFRESH, refresh interval(in seconds) for Question value, 0 means no refresh
364
365 FORM_BROWSER_STATEMENT *ParentStatement;
366
367 LIST_ENTRY InconsistentListHead;// nested inconsistent expression list (FORM_EXPRESSION)
368 LIST_ENTRY NoSubmitListHead; // nested nosubmit expression list (FORM_EXPRESSION)
369 LIST_ENTRY WarningListHead; // nested warning expression list (FORM_EXPRESSION)
370 FORM_EXPRESSION_LIST *Expression; // nesting inside of GrayOutIf/DisableIf/SuppressIf
371
372 FORM_EXPRESSION *ReadExpression; // nested EFI_IFR_READ, provide this question value by read expression.
373 FORM_EXPRESSION *WriteExpression; // nested EFI_IFR_WRITE, evaluate write expression after this question value is set.
374 };
375
376 #define FORM_BROWSER_STATEMENT_FROM_LINK(a) CR (a, FORM_BROWSER_STATEMENT, Link, FORM_BROWSER_STATEMENT_SIGNATURE)
377
378 #define FORM_BROWSER_CONFIG_REQUEST_SIGNATURE SIGNATURE_32 ('F', 'C', 'R', 'S')
379 typedef struct {
380 UINTN Signature;
381 LIST_ENTRY Link;
382
383 LIST_ENTRY SaveFailLink;
384
385 CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
386 CHAR16 *ConfigAltResp; // Alt config response string for this ConfigRequest.
387 UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
388 UINTN SpareStrLen;
389 CHAR16 *RestoreConfigRequest; // When submit form fail, the element need to be restored
390 CHAR16 *SyncConfigRequest; // When submit form fail, the element need to be synced
391
392 BROWSER_STORAGE *Storage;
393 } FORM_BROWSER_CONFIG_REQUEST;
394 #define FORM_BROWSER_CONFIG_REQUEST_FROM_LINK(a) CR (a, FORM_BROWSER_CONFIG_REQUEST, Link, FORM_BROWSER_CONFIG_REQUEST_SIGNATURE)
395 #define FORM_BROWSER_CONFIG_REQUEST_FROM_SAVE_FAIL_LINK(a) CR (a, FORM_BROWSER_CONFIG_REQUEST, SaveFailLink, FORM_BROWSER_CONFIG_REQUEST_SIGNATURE)
396
397 #define FORM_BROWSER_FORM_SIGNATURE SIGNATURE_32 ('F', 'F', 'R', 'M')
398 #define STANDARD_MAP_FORM_TYPE 0x01
399
400 typedef struct {
401 UINTN Signature;
402 LIST_ENTRY Link;
403
404 UINT16 FormId; // FormId of normal form or formmap form.
405 EFI_STRING_ID FormTitle; // FormTile of normal form, or FormMapMethod title of formmap form.
406 UINT16 FormType; // Specific form type for the different form.
407
408 EFI_IMAGE_ID ImageId;
409
410 BOOLEAN ModalForm; // Whether this is a modal form.
411 BOOLEAN Locked; // Whether this form is locked.
412 EFI_GUID RefreshGuid; // Form refresh event guid.
413
414 LIST_ENTRY FormViewListHead; // List of type FORMID_INFO is Browser View Form History List.
415 LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
416 LIST_ENTRY StatementListHead; // List of Statements and Questions (FORM_BROWSER_STATEMENT)
417 LIST_ENTRY ConfigRequestHead; // List of configreques for all storage.
418 FORM_EXPRESSION_LIST *SuppressExpression; // nesting inside of SuppressIf
419 } FORM_BROWSER_FORM;
420
421 #define FORM_BROWSER_FORM_FROM_LINK(a) CR (a, FORM_BROWSER_FORM, Link, FORM_BROWSER_FORM_SIGNATURE)
422
423 #define FORMSET_DEFAULTSTORE_SIGNATURE SIGNATURE_32 ('F', 'D', 'F', 'S')
424
425 typedef struct {
426 UINTN Signature;
427 LIST_ENTRY Link;
428
429 UINT16 DefaultId;
430 EFI_STRING_ID DefaultName;
431 } FORMSET_DEFAULTSTORE;
432
433 #define FORMSET_DEFAULTSTORE_FROM_LINK(a) CR (a, FORMSET_DEFAULTSTORE, Link, FORMSET_DEFAULTSTORE_SIGNATURE)
434
435 #define FORM_BROWSER_FORMSET_SIGNATURE SIGNATURE_32 ('F', 'B', 'F', 'S')
436
437 typedef struct {
438 UINTN Signature;
439 LIST_ENTRY Link;
440 LIST_ENTRY SaveFailLink;
441
442 EFI_HII_HANDLE HiiHandle; // unique id for formset.
443 EFI_HANDLE DriverHandle;
444 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
445 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
446
447 UINTN IfrBinaryLength;
448 UINT8 *IfrBinaryData;
449
450 BOOLEAN QuestionInited; // Have finished question initilization?
451 EFI_GUID Guid;
452 EFI_STRING_ID FormSetTitle;
453 EFI_STRING_ID Help;
454 UINT8 NumberOfClassGuid;
455 EFI_GUID ClassGuid[3]; // Up to three ClassGuid
456 UINT16 Class; // Tiano extended Class code
457 UINT16 SubClass; // Tiano extended Subclass code
458 EFI_IMAGE_ID ImageId;
459 EFI_IFR_OP_HEADER *OpCode; //mainly for formset op to get ClassGuid
460
461 FORM_BROWSER_STATEMENT *StatementBuffer; // Buffer for all Statements and Questions
462 EXPRESSION_OPCODE *ExpressionBuffer; // Buffer for all Expression OpCode
463 FORM_BROWSER_FORM *SaveFailForm; // The form which failed to save.
464 FORM_BROWSER_STATEMENT *SaveFailStatement; // The Statement which failed to save.
465
466 LIST_ENTRY StatementListOSF; // Statement list out side of the form.
467 LIST_ENTRY StorageListHead; // Storage list (FORMSET_STORAGE)
468 LIST_ENTRY SaveFailStorageListHead; // Storage list for the save fail storage.
469 LIST_ENTRY DefaultStoreListHead; // DefaultStore list (FORMSET_DEFAULTSTORE)
470 LIST_ENTRY FormListHead; // Form list (FORM_BROWSER_FORM)
471 LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
472 } FORM_BROWSER_FORMSET;
473 #define FORM_BROWSER_FORMSET_FROM_LINK(a) CR (a, FORM_BROWSER_FORMSET, Link, FORM_BROWSER_FORMSET_SIGNATURE)
474
475 #define FORM_BROWSER_FORMSET_FROM_SAVE_FAIL_LINK(a) CR (a, FORM_BROWSER_FORMSET, SaveFailLink, FORM_BROWSER_FORMSET_SIGNATURE)
476
477 typedef struct {
478 LIST_ENTRY Link;
479 EFI_EVENT RefreshEvent;
480 } FORM_BROWSER_REFRESH_EVENT_NODE;
481
482 #define FORM_BROWSER_REFRESH_EVENT_FROM_LINK(a) BASE_CR (a, FORM_BROWSER_REFRESH_EVENT_NODE, Link)
483
484
485 typedef struct {
486 EFI_HII_HANDLE Handle;
487
488 //
489 // Target formset/form/Question information
490 //
491 EFI_GUID FormSetGuid;
492 UINT16 FormId;
493 UINT16 QuestionId;
494 UINTN Sequence; // used for time/date only.
495
496 UINTN TopRow;
497 UINTN BottomRow;
498 UINTN PromptCol;
499 UINTN OptionCol;
500 UINTN CurrentRow;
501
502 //
503 // Ation for Browser to taken:
504 // UI_ACTION_NONE - navigation inside a form
505 // UI_ACTION_REFRESH_FORM - re-evaluate expressions and repaint form
506 // UI_ACTION_REFRESH_FORMSET - re-parse formset IFR binary
507 //
508 UINTN Action;
509
510 //
511 // Current selected fomset/form/Question
512 //
513 FORM_BROWSER_FORMSET *FormSet;
514 FORM_BROWSER_FORM *Form;
515 FORM_BROWSER_STATEMENT *Statement;
516
517 //
518 // Whether the Form is editable
519 //
520 BOOLEAN FormEditable;
521
522 FORM_ENTRY_INFO *CurrentMenu;
523 } UI_MENU_SELECTION;
524
525 #define BROWSER_CONTEXT_SIGNATURE SIGNATURE_32 ('B', 'C', 'T', 'X')
526
527 typedef struct {
528 UINTN Signature;
529 LIST_ENTRY Link;
530
531 //
532 // Globals defined in Setup.c
533 //
534 BOOLEAN FlagReconnect;
535 BOOLEAN CallbackReconnect;
536 BOOLEAN ResetRequired;
537 BOOLEAN ExitRequired;
538 EFI_HII_HANDLE HiiHandle;
539 EFI_GUID FormSetGuid;
540 EFI_FORM_ID FormId;
541 UI_MENU_SELECTION *Selection;
542 FORM_BROWSER_FORMSET *SystemLevelFormSet;
543 EFI_QUESTION_ID CurFakeQestId;
544 BOOLEAN HiiPackageListUpdated;
545 BOOLEAN FinishRetrieveCall;
546 LIST_ENTRY FormHistoryList;
547 LIST_ENTRY FormSetList;
548 } BROWSER_CONTEXT;
549
550 #define BROWSER_CONTEXT_FROM_LINK(a) CR (a, BROWSER_CONTEXT, Link, BROWSER_CONTEXT_SIGNATURE)
551
552 //
553 // Scope for get defaut value. It may be GetDefaultForNoStorage, GetDefaultForStorage or GetDefaultForAll.
554 //
555 typedef enum {
556 GetDefaultForNoStorage, // Get default value for question which not has storage.
557 GetDefaultForStorage, // Get default value for question which has storage.
558 GetDefaultForAll, // Get default value for all questions.
559 GetDefaultForMax // Invalid value.
560 } BROWSER_GET_DEFAULT_VALUE;
561
562 //
563 // Get/set question value from/to.
564 //
565 typedef enum {
566 GetSetValueWithEditBuffer = 0, // Get/Set question value from/to editbuffer in the storage.
567 GetSetValueWithBuffer, // Get/Set question value from/to buffer in the storage.
568 GetSetValueWithHiiDriver, // Get/Set question value from/to hii driver.
569 GetSetValueWithBothBuffer, // Compare the editbuffer with buffer for this question, not use the question value.
570 GetSetValueWithMax // Invalid value.
571 } GET_SET_QUESTION_VALUE_WITH;
572
573 extern EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
574 extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting;
575 extern EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mPathFromText;
576 extern EDKII_FORM_DISPLAY_ENGINE_PROTOCOL *mFormDisplay;
577
578 extern BOOLEAN gCallbackReconnect;
579 extern BOOLEAN gFlagReconnect;
580 extern BOOLEAN gResetRequiredFormLevel;
581 extern BOOLEAN gResetRequiredSystemLevel;
582 extern BOOLEAN gExitRequired;
583 extern LIST_ENTRY gBrowserFormSetList;
584 extern LIST_ENTRY gBrowserHotKeyList;
585 extern BROWSER_SETTING_SCOPE gBrowserSettingScope;
586 extern EXIT_HANDLER ExitHandlerFunction;
587 extern EFI_HII_HANDLE mCurrentHiiHandle;
588 extern SETUP_DRIVER_PRIVATE_DATA mPrivateData;
589 //
590 // Browser Global Strings
591 //
592 extern CHAR16 *gEmptyString;
593
594 extern UI_MENU_SELECTION *gCurrentSelection;
595 extern BOOLEAN mHiiPackageListUpdated;
596 extern UINT16 mCurFakeQestId;
597 extern BOOLEAN mFinishRetrieveCall;
598
599 //
600 // Global Procedure Defines
601 //
602 #include "Expression.h"
603
604 /**
605 Initialize the HII String Token to the correct values.
606
607 **/
608 VOID
609 InitializeBrowserStrings (
610 VOID
611 );
612
613 /**
614 Parse opcodes in the formset IFR binary.
615
616 @param FormSet Pointer of the FormSet data structure.
617
618 @retval EFI_SUCCESS Opcode parse success.
619 @retval Other Opcode parse fail.
620
621 **/
622 EFI_STATUS
623 ParseOpCodes (
624 IN FORM_BROWSER_FORMSET *FormSet
625 );
626
627 /**
628 Free resources allocated for a FormSet.
629
630 @param FormSet Pointer of the FormSet
631
632 **/
633 VOID
634 DestroyFormSet (
635 IN OUT FORM_BROWSER_FORMSET *FormSet
636 );
637
638
639 /**
640 Create a new string in HII Package List.
641
642 @param String The String to be added
643 @param HiiHandle The package list in the HII database to insert the
644 specified string.
645
646 @return The output string.
647
648 **/
649 EFI_STRING_ID
650 NewString (
651 IN CHAR16 *String,
652 IN EFI_HII_HANDLE HiiHandle
653 );
654
655 /**
656 Delete a string from HII Package List.
657
658 @param StringId Id of the string in HII database.
659 @param HiiHandle The HII package list handle.
660
661 @retval EFI_SUCCESS The string was deleted successfully.
662
663 **/
664 EFI_STATUS
665 DeleteString (
666 IN EFI_STRING_ID StringId,
667 IN EFI_HII_HANDLE HiiHandle
668 );
669
670 /**
671 Get the string based on the StringId and HII Package List Handle.
672
673 @param Token The String's ID.
674 @param HiiHandle The package list in the HII database to search for
675 the specified string.
676
677 @return The output string.
678
679 **/
680 CHAR16 *
681 GetToken (
682 IN EFI_STRING_ID Token,
683 IN EFI_HII_HANDLE HiiHandle
684 );
685
686 /**
687 Get Value for given Name from a NameValue Storage.
688
689 @param Storage The NameValue Storage.
690 @param Name The Name.
691 @param Value The retured Value.
692 @param GetValueFrom Where to get source value, from EditValue or Value.
693
694 @retval EFI_SUCCESS Value found for given Name.
695 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
696
697 **/
698 EFI_STATUS
699 GetValueByName (
700 IN BROWSER_STORAGE *Storage,
701 IN CHAR16 *Name,
702 IN OUT CHAR16 **Value,
703 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
704 );
705
706 /**
707 Set Value of given Name in a NameValue Storage.
708
709 @param Storage The NameValue Storage.
710 @param Name The Name.
711 @param Value The Value to set.
712 @param SetValueTo Whether update editValue or Value.
713 @param ReturnNode The node use the input name.
714
715 @retval EFI_SUCCESS Value found for given Name.
716 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
717
718 **/
719 EFI_STATUS
720 SetValueByName (
721 IN BROWSER_STORAGE *Storage,
722 IN CHAR16 *Name,
723 IN CHAR16 *Value,
724 IN GET_SET_QUESTION_VALUE_WITH SetValueTo,
725 OUT NAME_VALUE_NODE **ReturnNode
726 );
727
728 /**
729 Validate whether this question's value has changed.
730
731 @param FormSet FormSet data structure.
732 @param Form Form data structure.
733 @param Question Question to be initialized.
734 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
735
736 @retval TRUE Question's value has changed.
737 @retval FALSE Question's value has not changed
738
739 **/
740 BOOLEAN
741 IsQuestionValueChanged (
742 IN FORM_BROWSER_FORMSET *FormSet,
743 IN FORM_BROWSER_FORM *Form,
744 IN OUT FORM_BROWSER_STATEMENT *Question,
745 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
746 );
747
748 /**
749 Validate the FormSet. If the formset is not validate, remove it from the list.
750
751 @param FormSet The input FormSet which need to validate.
752
753 @retval TRUE The handle is validate.
754 @retval FALSE The handle is invalidate.
755
756 **/
757 BOOLEAN
758 ValidateFormSet (
759 FORM_BROWSER_FORMSET *FormSet
760 );
761
762 /**
763 Update the ValueChanged status for questions.
764
765 @param FormSet FormSet data structure.
766 @param Form Form data structure.
767 @param SettingScope Setting Scope for Default action.
768
769 **/
770 VOID
771 UpdateStatementStatus (
772 IN FORM_BROWSER_FORMSET *FormSet,
773 IN FORM_BROWSER_FORM *Form,
774 IN BROWSER_SETTING_SCOPE SettingScope
775 );
776
777 /**
778 Get Question's current Value.
779
780 @param FormSet FormSet data structure.
781 @param Form Form data structure.
782 @param Question Question to be initialized.
783 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
784
785 @retval EFI_SUCCESS The function completed successfully.
786
787 **/
788 EFI_STATUS
789 GetQuestionValue (
790 IN FORM_BROWSER_FORMSET *FormSet,
791 IN FORM_BROWSER_FORM *Form,
792 IN OUT FORM_BROWSER_STATEMENT *Question,
793 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
794 );
795
796 /**
797 Save Question Value to edit copy(cached) or Storage(uncached).
798
799 @param FormSet FormSet data structure.
800 @param Form Form data structure.
801 @param Question Pointer to the Question.
802 @param SetValueTo Update the question value to editbuffer , buffer or hii driver.
803
804 @retval EFI_SUCCESS The function completed successfully.
805
806 **/
807 EFI_STATUS
808 SetQuestionValue (
809 IN FORM_BROWSER_FORMSET *FormSet,
810 IN FORM_BROWSER_FORM *Form,
811 IN OUT FORM_BROWSER_STATEMENT *Question,
812 IN GET_SET_QUESTION_VALUE_WITH SetValueTo
813 );
814
815 /**
816 Perform inconsistent check for a Form.
817
818 @param FormSet FormSet data structure.
819 @param Form Form data structure.
820 @param Question The Question to be validated.
821 @param Type Validation type: InConsistent or NoSubmit
822
823 @retval EFI_SUCCESS Form validation pass.
824 @retval other Form validation failed.
825
826 **/
827 EFI_STATUS
828 ValidateQuestion (
829 IN FORM_BROWSER_FORMSET *FormSet,
830 IN FORM_BROWSER_FORM *Form,
831 IN FORM_BROWSER_STATEMENT *Question,
832 IN UINTN Type
833 );
834
835
836 /**
837 Discard data based on the input setting scope (Form, FormSet or System).
838
839 @param FormSet FormSet data structure.
840 @param Form Form data structure.
841 @param SettingScope Setting Scope for Discard action.
842
843 @retval EFI_SUCCESS The function completed successfully.
844 @retval EFI_UNSUPPORTED Unsupport SettingScope.
845
846 **/
847 EFI_STATUS
848 DiscardForm (
849 IN FORM_BROWSER_FORMSET *FormSet,
850 IN FORM_BROWSER_FORM *Form,
851 IN BROWSER_SETTING_SCOPE SettingScope
852 );
853
854 /**
855 Submit data based on the input Setting level (Form, FormSet or System).
856
857 @param FormSet FormSet data structure.
858 @param Form Form data structure.
859 @param SettingScope Setting Scope for Submit action.
860
861 @retval EFI_SUCCESS The function completed successfully.
862 @retval EFI_UNSUPPORTED Unsupport SettingScope.
863
864 **/
865 EFI_STATUS
866 SubmitForm (
867 IN FORM_BROWSER_FORMSET *FormSet,
868 IN FORM_BROWSER_FORM *Form,
869 IN BROWSER_SETTING_SCOPE SettingScope
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 **/
897 VOID
898 InitializeCurrentSetting (
899 IN OUT FORM_BROWSER_FORMSET *FormSet
900 );
901
902 /**
903 Initialize the internal data structure of a FormSet.
904
905 @param Handle PackageList Handle
906 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
907 GUID), take the first FormSet found in package
908 list.
909 @param FormSet FormSet data structure.
910
911 @retval EFI_SUCCESS The function completed successfully.
912 @retval EFI_NOT_FOUND The specified FormSet could not be found.
913
914 **/
915 EFI_STATUS
916 InitializeFormSet (
917 IN EFI_HII_HANDLE Handle,
918 IN OUT EFI_GUID *FormSetGuid,
919 OUT FORM_BROWSER_FORMSET *FormSet
920 );
921
922 /**
923 Reset Questions to their initial value or default value in a Form, Formset or System.
924
925 GetDefaultValueScope parameter decides which questions will reset
926 to its default value.
927
928 @param FormSet FormSet data structure.
929 @param Form Form data structure.
930 @param DefaultId The Class of the default.
931 @param SettingScope Setting Scope for Default action.
932 @param GetDefaultValueScope Get default value scope.
933 @param Storage Get default value only for this storage.
934 @param RetrieveValueFirst Whether call the retrieve call back to
935 get the initial value before get default
936 value.
937 @param SkipGetAltCfg Whether skip the get altcfg string process.
938
939 @retval EFI_SUCCESS The function completed successfully.
940 @retval EFI_UNSUPPORTED Unsupport SettingScope.
941
942 **/
943 EFI_STATUS
944 ExtractDefault (
945 IN FORM_BROWSER_FORMSET *FormSet,
946 IN FORM_BROWSER_FORM *Form,
947 IN UINT16 DefaultId,
948 IN BROWSER_SETTING_SCOPE SettingScope,
949 IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
950 IN BROWSER_STORAGE *Storage,
951 IN BOOLEAN RetrieveValueFirst,
952 IN BOOLEAN SkipGetAltCfg
953 );
954
955 /**
956 Initialize Question's Edit copy from Storage.
957
958 @param Selection Selection contains the information about
959 the Selection, form and formset to be displayed.
960 Selection action may be updated in retrieve callback.
961 If Selection is NULL, only initialize Question value.
962 @param FormSet FormSet data structure.
963 @param Form Form data structure.
964
965 @retval EFI_SUCCESS The function completed successfully.
966
967 **/
968 EFI_STATUS
969 LoadFormConfig (
970 IN OUT UI_MENU_SELECTION *Selection,
971 IN FORM_BROWSER_FORMSET *FormSet,
972 IN FORM_BROWSER_FORM *Form
973 );
974
975 /**
976 Initialize Question's Edit copy from Storage for the whole Formset.
977
978 @param Selection Selection contains the information about
979 the Selection, form and formset to be displayed.
980 Selection action may be updated in retrieve callback.
981 If Selection is NULL, only initialize Question value.
982 @param FormSet FormSet data structure.
983
984 @retval EFI_SUCCESS The function completed successfully.
985
986 **/
987 EFI_STATUS
988 LoadFormSetConfig (
989 IN OUT UI_MENU_SELECTION *Selection,
990 IN FORM_BROWSER_FORMSET *FormSet
991 );
992
993 /**
994 Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
995
996 @param Storage The Storage to be conveted.
997 @param ConfigResp The returned <ConfigResp>.
998 @param ConfigRequest The ConfigRequest string.
999 @param GetEditBuf Get the data from editbuffer or buffer.
1000
1001 @retval EFI_SUCCESS Convert success.
1002 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1003
1004 **/
1005 EFI_STATUS
1006 StorageToConfigResp (
1007 IN BROWSER_STORAGE *Storage,
1008 IN CHAR16 **ConfigResp,
1009 IN CHAR16 *ConfigRequest,
1010 IN BOOLEAN GetEditBuf
1011 );
1012
1013 /**
1014 Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.
1015
1016 @param Storage The Storage to receive the settings.
1017 @param ConfigResp The <ConfigResp> to be converted.
1018
1019 @retval EFI_SUCCESS Convert success.
1020 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1021
1022 **/
1023 EFI_STATUS
1024 ConfigRespToStorage (
1025 IN BROWSER_STORAGE *Storage,
1026 IN CHAR16 *ConfigResp
1027 );
1028
1029 /**
1030 Fill storage's edit copy with settings requested from Configuration Driver.
1031
1032 @param FormSet FormSet data structure.
1033 @param Storage Buffer Storage.
1034
1035 **/
1036 VOID
1037 LoadStorage (
1038 IN FORM_BROWSER_FORMSET *FormSet,
1039 IN FORMSET_STORAGE *Storage
1040 );
1041
1042 /**
1043 Fetch the Ifr binary data of a FormSet.
1044
1045 @param Handle PackageList Handle
1046 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
1047 GUID), take the first FormSet found in package
1048 list.
1049 @param BinaryLength The length of the FormSet IFR binary.
1050 @param BinaryData The buffer designed to receive the FormSet.
1051
1052 @retval EFI_SUCCESS Buffer filled with the requested FormSet.
1053 BufferLength was updated.
1054 @retval EFI_INVALID_PARAMETER The handle is unknown.
1055 @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
1056 be found with the requested FormId.
1057
1058 **/
1059 EFI_STATUS
1060 GetIfrBinaryData (
1061 IN EFI_HII_HANDLE Handle,
1062 IN OUT EFI_GUID *FormSetGuid,
1063 OUT UINTN *BinaryLength,
1064 OUT UINT8 **BinaryData
1065 );
1066
1067 /**
1068 Save globals used by previous call to SendForm(). SendForm() may be called from
1069 HiiConfigAccess.Callback(), this will cause SendForm() be reentried.
1070 So, save globals of previous call to SendForm() and restore them upon exit.
1071
1072 **/
1073 VOID
1074 SaveBrowserContext (
1075 VOID
1076 );
1077
1078 /**
1079 Restore globals used by previous call to SendForm().
1080
1081 **/
1082 VOID
1083 RestoreBrowserContext (
1084 VOID
1085 );
1086
1087 /**
1088 This is the routine which an external caller uses to direct the browser
1089 where to obtain it's information.
1090
1091
1092 @param This The Form Browser protocol instanse.
1093 @param Handles A pointer to an array of Handles. If HandleCount > 1 we
1094 display a list of the formsets for the handles specified.
1095 @param HandleCount The number of Handles specified in Handle.
1096 @param FormSetGuid This field points to the EFI_GUID which must match the Guid
1097 field in the EFI_IFR_FORM_SET op-code for the specified
1098 forms-based package. If FormSetGuid is NULL, then this
1099 function will display the first found forms package.
1100 @param FormId This field specifies which EFI_IFR_FORM to render as the first
1101 displayable page. If this field has a value of 0x0000, then
1102 the forms browser will render the specified forms in their encoded order.
1103 ScreenDimenions - This allows the browser to be called so that it occupies a
1104 portion of the physical screen instead of dynamically determining the screen dimensions.
1105 ActionRequest - Points to the action recommended by the form.
1106 @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
1107 characters.
1108 @param ActionRequest Points to the action recommended by the form.
1109
1110 @retval EFI_SUCCESS The function completed successfully.
1111 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1112 @retval EFI_NOT_FOUND No valid forms could be found to display.
1113
1114 **/
1115 EFI_STATUS
1116 EFIAPI
1117 SendForm (
1118 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1119 IN EFI_HII_HANDLE *Handles,
1120 IN UINTN HandleCount,
1121 IN EFI_GUID *FormSetGuid, OPTIONAL
1122 IN UINT16 FormId, OPTIONAL
1123 IN CONST EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
1124 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OPTIONAL
1125 );
1126
1127 /**
1128 This function is called by a callback handler to retrieve uncommitted state
1129 data from the browser.
1130
1131 @param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL
1132 instance.
1133 @param ResultsDataSize A pointer to the size of the buffer associated
1134 with ResultsData.
1135 @param ResultsData A string returned from an IFR browser or
1136 equivalent. The results string will have no
1137 routing information in them.
1138 @param RetrieveData A BOOLEAN field which allows an agent to retrieve
1139 (if RetrieveData = TRUE) data from the uncommitted
1140 browser state information or set (if RetrieveData
1141 = FALSE) data in the uncommitted browser state
1142 information.
1143 @param VariableGuid An optional field to indicate the target variable
1144 GUID name to use.
1145 @param VariableName An optional field to indicate the target
1146 human-readable variable name.
1147
1148 @retval EFI_SUCCESS The results have been distributed or are awaiting
1149 distribution.
1150 @retval EFI_BUFFER_TOO_SMALL The ResultsDataSize specified was too small to
1151 contain the results data.
1152
1153 **/
1154 EFI_STATUS
1155 EFIAPI
1156 BrowserCallback (
1157 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1158 IN OUT UINTN *ResultsDataSize,
1159 IN OUT EFI_STRING ResultsData,
1160 IN BOOLEAN RetrieveData,
1161 IN CONST EFI_GUID *VariableGuid, OPTIONAL
1162 IN CONST CHAR16 *VariableName OPTIONAL
1163 );
1164
1165 /**
1166 Find menu which will show next time.
1167
1168 @param Selection On input, Selection tell setup browser the information
1169 about the Selection, form and formset to be displayed.
1170 On output, Selection return the screen item that is selected
1171 by user.
1172 @param SettingLevel Input Settting level, if it is FormLevel, just exit current form.
1173 else, we need to exit current formset.
1174
1175 @retval TRUE Exit current form.
1176 @retval FALSE User press ESC and keep in current form.
1177 **/
1178 BOOLEAN
1179 FindNextMenu (
1180 IN OUT UI_MENU_SELECTION *Selection,
1181 IN BROWSER_SETTING_SCOPE SettingLevel
1182 );
1183
1184 /**
1185 check whether the form need to update the NV.
1186
1187 @param Form Form data structure.
1188
1189 @retval TRUE Need to update the NV.
1190 @retval FALSE No need to update the NV.
1191 **/
1192 BOOLEAN
1193 IsNvUpdateRequiredForForm (
1194 IN FORM_BROWSER_FORM *Form
1195 );
1196
1197 /**
1198 check whether the formset need to update the NV.
1199
1200 @param FormSet FormSet data structure.
1201
1202 @retval TRUE Need to update the NV.
1203 @retval FALSE No need to update the NV.
1204 **/
1205 BOOLEAN
1206 IsNvUpdateRequiredForFormSet (
1207 IN FORM_BROWSER_FORMSET *FormSet
1208 );
1209
1210 /**
1211 Call the call back function for the question and process the return action.
1212
1213 @param Selection On input, Selection tell setup browser the information
1214 about the Selection, form and formset to be displayed.
1215 On output, Selection return the screen item that is selected
1216 by user.
1217 @param FormSet The formset this question belong to.
1218 @param Form The form this question belong to.
1219 @param Question The Question which need to call.
1220 @param Action The action request.
1221 @param SkipSaveOrDiscard Whether skip save or discard action.
1222
1223 @retval EFI_SUCCESS The call back function executes successfully.
1224 @return Other value if the call back function failed to execute.
1225 **/
1226 EFI_STATUS
1227 ProcessCallBackFunction (
1228 IN OUT UI_MENU_SELECTION *Selection,
1229 IN FORM_BROWSER_FORMSET *FormSet,
1230 IN FORM_BROWSER_FORM *Form,
1231 IN FORM_BROWSER_STATEMENT *Question,
1232 IN EFI_BROWSER_ACTION Action,
1233 IN BOOLEAN SkipSaveOrDiscard
1234 );
1235
1236 /**
1237 Call the retrieve type call back function for one question to get the initialize data.
1238
1239 This function only used when in the initialize stage, because in this stage, the
1240 Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.
1241
1242 @param ConfigAccess The config access protocol produced by the hii driver.
1243 @param Statement The Question which need to call.
1244 @param FormSet The formset this question belong to.
1245
1246 @retval EFI_SUCCESS The call back function executes successfully.
1247 @return Other value if the call back function failed to execute.
1248 **/
1249 EFI_STATUS
1250 ProcessRetrieveForQuestion (
1251 IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess,
1252 IN FORM_BROWSER_STATEMENT *Statement,
1253 IN FORM_BROWSER_FORMSET *FormSet
1254 );
1255
1256 /**
1257 Find the matched FormSet context in the backup maintain list based on HiiHandle.
1258
1259 @param Handle The Hii Handle.
1260
1261 @return the found FormSet context. If no found, NULL will return.
1262
1263 **/
1264 FORM_BROWSER_FORMSET *
1265 GetFormSetFromHiiHandle (
1266 EFI_HII_HANDLE Handle
1267 );
1268
1269 /**
1270 Check whether the input HII handle is the FormSet that is being used.
1271
1272 @param Handle The Hii Handle.
1273
1274 @retval TRUE HII handle is being used.
1275 @retval FALSE HII handle is not being used.
1276
1277 **/
1278 BOOLEAN
1279 IsHiiHandleInBrowserContext (
1280 EFI_HII_HANDLE Handle
1281 );
1282
1283 /**
1284 Configure what scope the hot key will impact.
1285 All hot keys have the same scope. The mixed hot keys with the different level are not supported.
1286 If no scope is set, the default scope will be FormSet level.
1287 After all registered hot keys are removed, previous Scope can reset to another level.
1288
1289 @param[in] Scope Scope level to be set.
1290
1291 @retval EFI_SUCCESS Scope is set correctly.
1292 @retval EFI_INVALID_PARAMETER Scope is not the valid value specified in BROWSER_SETTING_SCOPE.
1293 @retval EFI_UNSPPORTED Scope level is different from current one that the registered hot keys have.
1294
1295 **/
1296 EFI_STATUS
1297 EFIAPI
1298 SetScope (
1299 IN BROWSER_SETTING_SCOPE Scope
1300 );
1301
1302 /**
1303 Register the hot key with its browser action, or unregistered the hot key.
1304 Only support hot key that is not printable character (control key, function key, etc.).
1305 If the action value is zero, the hot key will be unregistered if it has been registered.
1306 If the same hot key has been registered, the new action and help string will override the previous ones.
1307
1308 @param[in] KeyData A pointer to a buffer that describes the keystroke
1309 information for the hot key. Its type is EFI_INPUT_KEY to
1310 be supported by all ConsoleIn devices.
1311 @param[in] Action Action value that describes what action will be trigged when the hot key is pressed.
1312 @param[in] DefaultId Specifies the type of defaults to retrieve, which is only for DEFAULT action.
1313 @param[in] HelpString Help string that describes the hot key information.
1314 Its value may be NULL for the unregistered hot key.
1315
1316 @retval EFI_SUCCESS Hot key is registered or unregistered.
1317 @retval EFI_INVALID_PARAMETER KeyData is NULL.
1318 @retval EFI_NOT_FOUND KeyData is not found to be unregistered.
1319 @retval EFI_UNSUPPORTED Key represents a printable character. It is conflicted with Browser.
1320 @retval EFI_ALREADY_STARTED Key already been registered for one hot key.
1321 **/
1322 EFI_STATUS
1323 EFIAPI
1324 RegisterHotKey (
1325 IN EFI_INPUT_KEY *KeyData,
1326 IN UINT32 Action,
1327 IN UINT16 DefaultId,
1328 IN EFI_STRING HelpString OPTIONAL
1329 );
1330
1331 /**
1332 Register Exit handler function.
1333 When more than one handler function is registered, the latter one will override the previous one.
1334 When NULL handler is specified, the previous Exit handler will be unregistered.
1335
1336 @param[in] Handler Pointer to handler function.
1337
1338 **/
1339 VOID
1340 EFIAPI
1341 RegiserExitHandler (
1342 IN EXIT_HANDLER Handler
1343 );
1344
1345 /**
1346
1347 Check whether the browser data has been modified.
1348
1349 @retval TRUE Browser data is changed.
1350 @retval FALSE No browser data is changed.
1351
1352 **/
1353 BOOLEAN
1354 EFIAPI
1355 IsBrowserDataModified (
1356 VOID
1357 );
1358
1359 /**
1360
1361 Execute the action requested by the Action parameter.
1362
1363 @param[in] Action Execute the request action.
1364 @param[in] DefaultId The default Id info when need to load default value.
1365
1366 @retval EFI_SUCCESS Execute the request action succss.
1367 @retval EFI_INVALID_PARAMETER The input action value is invalid.
1368
1369 **/
1370 EFI_STATUS
1371 EFIAPI
1372 ExecuteAction (
1373 IN UINT32 Action,
1374 IN UINT16 DefaultId
1375 );
1376
1377 /**
1378 Create reminder to let user to choose save or discard the changed browser data.
1379 Caller can use it to actively check the changed browser data.
1380
1381 @retval BROWSER_NO_CHANGES No browser data is changed.
1382 @retval BROWSER_SAVE_CHANGES The changed browser data is saved.
1383 @retval BROWSER_DISCARD_CHANGES The changed browser data is discard.
1384 @retval BROWSER_KEEP_CURRENT Browser keep current changes.
1385
1386 **/
1387 UINT32
1388 EFIAPI
1389 SaveReminder (
1390 VOID
1391 );
1392
1393 /**
1394 Check whether the Reset Required for the browser
1395
1396 @retval TRUE Browser required to reset after exit.
1397 @retval FALSE Browser not need to reset after exit.
1398
1399 **/
1400 BOOLEAN
1401 EFIAPI
1402 IsResetRequired (
1403 VOID
1404 );
1405
1406 /**
1407 Find the registered HotKey based on KeyData.
1408
1409 @param[in] KeyData A pointer to a buffer that describes the keystroke
1410 information for the hot key.
1411
1412 @return The registered HotKey context. If no found, NULL will return.
1413 **/
1414 BROWSER_HOT_KEY *
1415 GetHotKeyFromRegisterList (
1416 IN EFI_INPUT_KEY *KeyData
1417 );
1418
1419 /**
1420
1421 Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
1422
1423 @param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.
1424
1425 @retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.
1426
1427 **/
1428 FORM_BROWSER_STATEMENT *
1429 GetBrowserStatement (
1430 IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement
1431 );
1432
1433 /**
1434 Password may be stored as encrypted by Configuration Driver. When change a
1435 password, user will be challenged with old password. To validate user input old
1436 password, we will send the clear text to Configuration Driver via Callback().
1437 Configuration driver is responsible to check the passed in password and return
1438 the validation result. If validation pass, state machine in password Callback()
1439 will transit from BROWSER_STATE_VALIDATE_PASSWORD to BROWSER_STATE_SET_PASSWORD.
1440 After user type in new password twice, Callback() will be invoked to send the
1441 new password to Configuration Driver.
1442
1443 @param Selection Pointer to UI_MENU_SELECTION.
1444 @param MenuOption The MenuOption for this password Question.
1445 @param String The clear text of password.
1446
1447 @retval EFI_NOT_AVAILABLE_YET Callback() request to terminate password input.
1448 @return In state of BROWSER_STATE_VALIDATE_PASSWORD:
1449 @retval EFI_SUCCESS Password correct, Browser will prompt for new
1450 password.
1451 @retval EFI_NOT_READY Password incorrect, Browser will show error
1452 message.
1453 @retval Other Browser will do nothing.
1454 @return In state of BROWSER_STATE_SET_PASSWORD:
1455 @retval EFI_SUCCESS Set password success.
1456 @retval Other Set password failed.
1457
1458 **/
1459 EFI_STATUS
1460 PasswordCallback (
1461 IN UI_MENU_SELECTION *Selection,
1462 IN FORM_BROWSER_STATEMENT *Question,
1463 IN CHAR16 *String
1464 );
1465
1466 /**
1467 Display error message for invalid password.
1468
1469 **/
1470 VOID
1471 PasswordInvalid (
1472 VOID
1473 );
1474
1475 /**
1476 The worker function that send the displays to the screen. On output,
1477 the selection made by user is returned.
1478
1479 @param Selection On input, Selection tell setup browser the information
1480 about the Selection, form and formset to be displayed.
1481 On output, Selection return the screen item that is selected
1482 by user.
1483
1484 @retval EFI_SUCCESS The page is displayed successfully.
1485 @return Other value if the page failed to be diplayed.
1486
1487 **/
1488 EFI_STATUS
1489 SetupBrowser (
1490 IN OUT UI_MENU_SELECTION *Selection
1491 );
1492
1493 /**
1494 Free up the resource allocated for all strings required
1495 by Setup Browser.
1496
1497 **/
1498 VOID
1499 FreeBrowserStrings (
1500 VOID
1501 );
1502
1503 /**
1504 Create a menu with specified formset GUID and form ID, and add it as a child
1505 of the given parent menu.
1506
1507 @param HiiHandle Hii handle related to this formset.
1508 @param FormSetGuid The Formset Guid of menu to be added.
1509 @param FormId The Form ID of menu to be added.
1510 @param QuestionId The question id of this menu to be added.
1511
1512 @return A pointer to the newly added menu or NULL if memory is insufficient.
1513
1514 **/
1515 FORM_ENTRY_INFO *
1516 UiAddMenuList (
1517 IN EFI_HII_HANDLE HiiHandle,
1518 IN EFI_GUID *FormSetGuid,
1519 IN UINT16 FormId,
1520 IN UINT16 QuestionId
1521 );
1522
1523 /**
1524 Search Menu with given FormSetGuid and FormId in all cached menu list.
1525
1526 @param HiiHandle HiiHandle for FormSet.
1527 @param FormSetGuid The Formset GUID of the menu to search.
1528 @param FormId The Form ID of menu to search.
1529
1530 @return A pointer to menu found or NULL if not found.
1531
1532 **/
1533 FORM_ENTRY_INFO *
1534 UiFindMenuList (
1535 IN EFI_HII_HANDLE HiiHandle,
1536 IN EFI_GUID *FormSetGuid,
1537 IN UINT16 FormId
1538 );
1539
1540 /**
1541 Free Menu list linked list.
1542
1543 @param MenuListHead One Menu list point in the menu list.
1544
1545 **/
1546 VOID
1547 UiFreeMenuList (
1548 LIST_ENTRY *MenuListHead
1549 );
1550
1551 /**
1552 Find parent menu for current menu.
1553
1554 @param CurrentMenu Current Menu
1555 @param SettingLevel Whether find parent menu in Form Level or Formset level.
1556 In form level, just find the parent menu;
1557 In formset level, find the parent menu which has different
1558 formset guid value.
1559
1560 @retval The parent menu for current menu.
1561 **/
1562 FORM_ENTRY_INFO *
1563 UiFindParentMenu (
1564 IN FORM_ENTRY_INFO *CurrentMenu,
1565 IN BROWSER_SETTING_SCOPE SettingLevel
1566 );
1567
1568 /**
1569 Validate the HiiHandle.
1570
1571 @param HiiHandle The input HiiHandle which need to validate.
1572
1573 @retval TRUE The handle is validate.
1574 @retval FALSE The handle is invalidate.
1575
1576 **/
1577 BOOLEAN
1578 ValidateHiiHandle (
1579 EFI_HII_HANDLE HiiHandle
1580 );
1581
1582 /**
1583 Copy current Menu list to the new menu list.
1584
1585 @param NewMenuListHead New create Menu list.
1586 @param CurrentMenuListHead Current Menu list.
1587
1588 **/
1589 VOID
1590 UiCopyMenuList (
1591 OUT LIST_ENTRY *NewMenuListHead,
1592 IN LIST_ENTRY *CurrentMenuListHead
1593 );
1594
1595 /**
1596 Search an Option of a Question by its value.
1597
1598 @param Question The Question
1599 @param OptionValue Value for Option to be searched.
1600
1601 @retval Pointer Pointer to the found Option.
1602 @retval NULL Option not found.
1603
1604 **/
1605 QUESTION_OPTION *
1606 ValueToOption (
1607 IN FORM_BROWSER_STATEMENT *Question,
1608 IN EFI_HII_VALUE *OptionValue
1609 );
1610 /**
1611 Return data element in an Array by its Index.
1612
1613 @param Array The data array.
1614 @param Type Type of the data in this array.
1615 @param Index Zero based index for data in this array.
1616
1617 @retval Value The data to be returned
1618
1619 **/
1620 UINT64
1621 GetArrayData (
1622 IN VOID *Array,
1623 IN UINT8 Type,
1624 IN UINTN Index
1625 );
1626
1627 /**
1628 Set value of a data element in an Array by its Index.
1629
1630 @param Array The data array.
1631 @param Type Type of the data in this array.
1632 @param Index Zero based index for data in this array.
1633 @param Value The value to be set.
1634
1635 **/
1636 VOID
1637 SetArrayData (
1638 IN VOID *Array,
1639 IN UINT8 Type,
1640 IN UINTN Index,
1641 IN UINT64 Value
1642 );
1643
1644 /**
1645 Compare two Hii value.
1646
1647 @param Value1 Expression value to compare on left-hand.
1648 @param Value2 Expression value to compare on right-hand.
1649 @param Result Return value after compare.
1650 retval 0 Two operators equal.
1651 return Positive value if Value1 is greater than Value2.
1652 retval Negative value if Value1 is less than Value2.
1653 @param HiiHandle Only required for string compare.
1654
1655 @retval other Could not perform compare on two values.
1656 @retval EFI_SUCCESS Compare the value success.
1657
1658 **/
1659 EFI_STATUS
1660 CompareHiiValue (
1661 IN EFI_HII_VALUE *Value1,
1662 IN EFI_HII_VALUE *Value2,
1663 OUT INTN *Result,
1664 IN EFI_HII_HANDLE HiiHandle OPTIONAL
1665 );
1666
1667 /**
1668 Perform Password check.
1669 Passwork may be encrypted by driver that requires the specific check.
1670
1671 @param Form Form where Password Statement is in.
1672 @param Statement Password statement
1673 @param PasswordString Password string to be checked. It may be NULL.
1674 NULL means to restore password.
1675 "" string can be used to checked whether old password does exist.
1676
1677 @return Status Status of Password check.
1678 **/
1679 EFI_STATUS
1680 EFIAPI
1681 PasswordCheck (
1682 IN FORM_DISPLAY_ENGINE_FORM *Form,
1683 IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,
1684 IN EFI_STRING PasswordString OPTIONAL
1685 );
1686
1687 /**
1688
1689 Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
1690
1691 @param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.
1692
1693 @retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.
1694
1695 **/
1696 FORM_BROWSER_STATEMENT *
1697 GetBrowserStatement (
1698 IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement
1699 );
1700
1701 /**
1702
1703 Initialize the Display form structure data.
1704
1705 **/
1706 VOID
1707 InitializeDisplayFormData (
1708 VOID
1709 );
1710
1711
1712 /**
1713 Base on the current formset info, clean the ConfigRequest string in browser storage.
1714
1715 @param FormSet Pointer of the FormSet
1716
1717 **/
1718 VOID
1719 CleanBrowserStorage (
1720 IN OUT FORM_BROWSER_FORMSET *FormSet
1721 );
1722
1723 /**
1724 Find HII Handle in the HII database associated with given Device Path.
1725
1726 If DevicePath is NULL, then ASSERT.
1727
1728 @param DevicePath Device Path associated with the HII package list
1729 handle.
1730 @param FormsetGuid The formset guid for this formset.
1731
1732 @retval Handle HII package list Handle associated with the Device
1733 Path.
1734 @retval NULL Hii Package list handle is not found.
1735
1736 **/
1737 EFI_HII_HANDLE
1738 DevicePathToHiiHandle (
1739 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
1740 IN EFI_GUID *FormsetGuid
1741 );
1742
1743 /**
1744 Adjust the config request info, remove the request elements which already in AllConfigRequest string.
1745
1746 @param Storage Form set Storage.
1747 @param Request The input request string.
1748 @param RespString Whether the input is ConfigRequest or ConfigResp format.
1749
1750 @retval TRUE Has element not covered by current used elements, need to continue to call ExtractConfig
1751 @retval FALSE All elements covered by current used elements.
1752
1753 **/
1754 BOOLEAN
1755 ConfigRequestAdjust (
1756 IN BROWSER_STORAGE *Storage,
1757 IN CHAR16 *Request,
1758 IN BOOLEAN RespString
1759 );
1760
1761 /**
1762 Perform question check.
1763
1764 If one question has more than one check, process form high priority to low.
1765
1766 @param FormSet FormSet data structure.
1767 @param Form Form data structure.
1768 @param Question The Question to be validated.
1769
1770 @retval EFI_SUCCESS Form validation pass.
1771 @retval other Form validation failed.
1772
1773 **/
1774 EFI_STATUS
1775 ValueChangedValidation (
1776 IN FORM_BROWSER_FORMSET *FormSet,
1777 IN FORM_BROWSER_FORM *Form,
1778 IN FORM_BROWSER_STATEMENT *Question
1779 );
1780
1781 /**
1782 Pop up the error info.
1783
1784 @param BrowserStatus The input browser status.
1785 @param HiiHandle The HiiHandle for this error opcode.
1786 @param OpCode The opcode use to get the erro info and timeout value.
1787 @param ErrorString Error string used by BROWSER_NO_SUBMIT_IF.
1788
1789 **/
1790 UINT32
1791 PopupErrorMessage (
1792 IN UINT32 BrowserStatus,
1793 IN EFI_HII_HANDLE HiiHandle,
1794 IN EFI_IFR_OP_HEADER *OpCode, OPTIONAL
1795 IN CHAR16 *ErrorString
1796 );
1797
1798 /**
1799 Check whether the result is TRUE or FALSE.
1800
1801 For the EFI_HII_VALUE value type is numeric, return TRUE if the
1802 value is not 0.
1803
1804 @param Result Input the result data.
1805
1806 @retval TRUE The result is TRUE.
1807 @retval FALSE The result is FALSE.
1808
1809 **/
1810 BOOLEAN
1811 IsTrue (
1812 IN EFI_HII_VALUE *Result
1813 );
1814
1815 /**
1816 Get Formset_storage base on the input varstoreid info.
1817
1818 @param FormSet Pointer of the current FormSet.
1819 @param VarStoreId Varstore ID info.
1820
1821 @return Pointer to a FORMSET_STORAGE data structure.
1822
1823 **/
1824 FORMSET_STORAGE *
1825 GetFstStgFromVarId (
1826 IN FORM_BROWSER_FORMSET *FormSet,
1827 IN EFI_VARSTORE_ID VarStoreId
1828 );
1829
1830 /**
1831 Get Formset_storage base on the input browser storage.
1832
1833 More than one formsets may share the same browser storage,
1834 this function just get the first formset storage which
1835 share the browser storage.
1836
1837 @param Storage browser storage info.
1838
1839 @return Pointer to a FORMSET_STORAGE data structure.
1840
1841
1842 **/
1843 FORMSET_STORAGE *
1844 GetFstStgFromBrsStg (
1845 IN BROWSER_STORAGE *Storage
1846 );
1847
1848 /**
1849 Reconnect the controller.
1850
1851 @param DriverHandle The controller handle which need to be reconnect.
1852
1853 @retval TRUE do the reconnect behavior success.
1854 @retval FALSE do the reconnect behavior failed.
1855
1856 **/
1857 BOOLEAN
1858 ReconnectController (
1859 IN EFI_HANDLE DriverHandle
1860 );
1861
1862 /**
1863 Converts the unicode character of the string from uppercase to lowercase.
1864 This is a internal function.
1865
1866 @param ConfigString String to be converted
1867
1868 **/
1869 VOID
1870 EFIAPI
1871 HiiToLower (
1872 IN EFI_STRING ConfigString
1873 );
1874
1875 #endif