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