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