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