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