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