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