]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
MdeModulePkg: Add match2 opcode support in SetupBrowserDxe and sample code in DriverS...
[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
458 FORM_BROWSER_STATEMENT *StatementBuffer; // Buffer for all Statements and Questions
459 EXPRESSION_OPCODE *ExpressionBuffer; // Buffer for all Expression OpCode
460 FORM_BROWSER_FORM *SaveFailForm; // The form which failed to save.
461 FORM_BROWSER_STATEMENT *SaveFailStatement; // The Statement which failed to save.
462
463 LIST_ENTRY StatementListOSF; // Statement list out side of the form.
464 LIST_ENTRY StorageListHead; // Storage list (FORMSET_STORAGE)
465 LIST_ENTRY SaveFailStorageListHead; // Storage list for the save fail storage.
466 LIST_ENTRY DefaultStoreListHead; // DefaultStore list (FORMSET_DEFAULTSTORE)
467 LIST_ENTRY FormListHead; // Form list (FORM_BROWSER_FORM)
468 LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
469 } FORM_BROWSER_FORMSET;
470 #define FORM_BROWSER_FORMSET_FROM_LINK(a) CR (a, FORM_BROWSER_FORMSET, Link, FORM_BROWSER_FORMSET_SIGNATURE)
471
472 #define FORM_BROWSER_FORMSET_FROM_SAVE_FAIL_LINK(a) CR (a, FORM_BROWSER_FORMSET, SaveFailLink, FORM_BROWSER_FORMSET_SIGNATURE)
473
474 typedef struct {
475 LIST_ENTRY Link;
476 EFI_EVENT RefreshEvent;
477 } FORM_BROWSER_REFRESH_EVENT_NODE;
478
479 #define FORM_BROWSER_REFRESH_EVENT_FROM_LINK(a) BASE_CR (a, FORM_BROWSER_REFRESH_EVENT_NODE, Link)
480
481
482 typedef struct {
483 EFI_HII_HANDLE Handle;
484
485 //
486 // Target formset/form/Question information
487 //
488 EFI_GUID FormSetGuid;
489 UINT16 FormId;
490 UINT16 QuestionId;
491 UINTN Sequence; // used for time/date only.
492
493 UINTN TopRow;
494 UINTN BottomRow;
495 UINTN PromptCol;
496 UINTN OptionCol;
497 UINTN CurrentRow;
498
499 //
500 // Ation for Browser to taken:
501 // UI_ACTION_NONE - navigation inside a form
502 // UI_ACTION_REFRESH_FORM - re-evaluate expressions and repaint form
503 // UI_ACTION_REFRESH_FORMSET - re-parse formset IFR binary
504 //
505 UINTN Action;
506
507 //
508 // Current selected fomset/form/Question
509 //
510 FORM_BROWSER_FORMSET *FormSet;
511 FORM_BROWSER_FORM *Form;
512 FORM_BROWSER_STATEMENT *Statement;
513
514 //
515 // Whether the Form is editable
516 //
517 BOOLEAN FormEditable;
518
519 FORM_ENTRY_INFO *CurrentMenu;
520 } UI_MENU_SELECTION;
521
522 #define BROWSER_CONTEXT_SIGNATURE SIGNATURE_32 ('B', 'C', 'T', 'X')
523
524 typedef struct {
525 UINTN Signature;
526 LIST_ENTRY Link;
527
528 //
529 // Globals defined in Setup.c
530 //
531 BOOLEAN ResetRequired;
532 BOOLEAN ExitRequired;
533 EFI_HII_HANDLE HiiHandle;
534 EFI_GUID FormSetGuid;
535 EFI_FORM_ID FormId;
536 UI_MENU_SELECTION *Selection;
537
538 LIST_ENTRY FormHistoryList;
539 } BROWSER_CONTEXT;
540
541 #define BROWSER_CONTEXT_FROM_LINK(a) CR (a, BROWSER_CONTEXT, Link, BROWSER_CONTEXT_SIGNATURE)
542
543 //
544 // Scope for get defaut value. It may be GetDefaultForNoStorage, GetDefaultForStorage or GetDefaultForAll.
545 //
546 typedef enum {
547 GetDefaultForNoStorage, // Get default value for question which not has storage.
548 GetDefaultForStorage, // Get default value for question which has storage.
549 GetDefaultForAll, // Get default value for all questions.
550 GetDefaultForMax // Invalid value.
551 } BROWSER_GET_DEFAULT_VALUE;
552
553 //
554 // Get/set question value from/to.
555 //
556 typedef enum {
557 GetSetValueWithEditBuffer = 0, // Get/Set question value from/to editbuffer in the storage.
558 GetSetValueWithBuffer, // Get/Set question value from/to buffer in the storage.
559 GetSetValueWithHiiDriver, // Get/Set question value from/to hii driver.
560 GetSetValueWithBothBuffer, // Compare the editbuffer with buffer for this question, not use the question value.
561 GetSetValueWithMax // Invalid value.
562 } GET_SET_QUESTION_VALUE_WITH;
563
564 extern EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
565 extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting;
566 extern EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mPathFromText;
567 extern EDKII_FORM_DISPLAY_ENGINE_PROTOCOL *mFormDisplay;
568
569 extern BOOLEAN gResetRequired;
570 extern BOOLEAN gExitRequired;
571 extern LIST_ENTRY gBrowserFormSetList;
572 extern LIST_ENTRY gBrowserHotKeyList;
573 extern BROWSER_SETTING_SCOPE gBrowserSettingScope;
574 extern EXIT_HANDLER ExitHandlerFunction;
575 extern EFI_HII_HANDLE mCurrentHiiHandle;
576 extern SETUP_DRIVER_PRIVATE_DATA mPrivateData;
577 //
578 // Browser Global Strings
579 //
580 extern CHAR16 *gEmptyString;
581
582 extern EFI_GUID gZeroGuid;
583
584 extern UI_MENU_SELECTION *gCurrentSelection;
585
586 //
587 // Global Procedure Defines
588 //
589 #include "Expression.h"
590
591 /**
592 Initialize the HII String Token to the correct values.
593
594 **/
595 VOID
596 InitializeBrowserStrings (
597 VOID
598 );
599
600 /**
601 Parse opcodes in the formset IFR binary.
602
603 @param FormSet Pointer of the FormSet data structure.
604
605 @retval EFI_SUCCESS Opcode parse success.
606 @retval Other Opcode parse fail.
607
608 **/
609 EFI_STATUS
610 ParseOpCodes (
611 IN FORM_BROWSER_FORMSET *FormSet
612 );
613
614 /**
615 Free resources allocated for a FormSet.
616
617 @param FormSet Pointer of the FormSet
618
619 **/
620 VOID
621 DestroyFormSet (
622 IN OUT FORM_BROWSER_FORMSET *FormSet
623 );
624
625
626 /**
627 Create a new string in HII Package List.
628
629 @param String The String to be added
630 @param HiiHandle The package list in the HII database to insert the
631 specified string.
632
633 @return The output string.
634
635 **/
636 EFI_STRING_ID
637 NewString (
638 IN CHAR16 *String,
639 IN EFI_HII_HANDLE HiiHandle
640 );
641
642 /**
643 Delete a string from HII Package List.
644
645 @param StringId Id of the string in HII database.
646 @param HiiHandle The HII package list handle.
647
648 @retval EFI_SUCCESS The string was deleted successfully.
649
650 **/
651 EFI_STATUS
652 DeleteString (
653 IN EFI_STRING_ID StringId,
654 IN EFI_HII_HANDLE HiiHandle
655 );
656
657 /**
658 Get the string based on the StringId and HII Package List Handle.
659
660 @param Token The String's ID.
661 @param HiiHandle The package list in the HII database to search for
662 the specified string.
663
664 @return The output string.
665
666 **/
667 CHAR16 *
668 GetToken (
669 IN EFI_STRING_ID Token,
670 IN EFI_HII_HANDLE HiiHandle
671 );
672
673 /**
674 Get Value for given Name from a NameValue Storage.
675
676 @param Storage The NameValue Storage.
677 @param Name The Name.
678 @param Value The retured Value.
679 @param GetValueFrom Where to get source value, from EditValue or Value.
680
681 @retval EFI_SUCCESS Value found for given Name.
682 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
683
684 **/
685 EFI_STATUS
686 GetValueByName (
687 IN BROWSER_STORAGE *Storage,
688 IN CHAR16 *Name,
689 IN OUT CHAR16 **Value,
690 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
691 );
692
693 /**
694 Set Value of given Name in a NameValue Storage.
695
696 @param Storage The NameValue Storage.
697 @param Name The Name.
698 @param Value The Value to set.
699 @param SetValueTo Whether update editValue or Value.
700 @param ReturnNode The node use the input name.
701
702 @retval EFI_SUCCESS Value found for given Name.
703 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
704
705 **/
706 EFI_STATUS
707 SetValueByName (
708 IN BROWSER_STORAGE *Storage,
709 IN CHAR16 *Name,
710 IN CHAR16 *Value,
711 IN GET_SET_QUESTION_VALUE_WITH SetValueTo,
712 OUT NAME_VALUE_NODE **ReturnNode
713 );
714
715 /**
716 Validate whether this question's value has changed.
717
718 @param FormSet FormSet data structure.
719 @param Form Form data structure.
720 @param Question Question to be initialized.
721 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
722
723 @retval TRUE Question's value has changed.
724 @retval FALSE Question's value has not changed
725
726 **/
727 BOOLEAN
728 IsQuestionValueChanged (
729 IN FORM_BROWSER_FORMSET *FormSet,
730 IN FORM_BROWSER_FORM *Form,
731 IN OUT FORM_BROWSER_STATEMENT *Question,
732 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
733 );
734
735 /**
736 Validate the FormSet. If the formset is not validate, remove it from the list.
737
738 @param FormSet The input FormSet which need to validate.
739
740 @retval TRUE The handle is validate.
741 @retval FALSE The handle is invalidate.
742
743 **/
744 BOOLEAN
745 ValidateFormSet (
746 FORM_BROWSER_FORMSET *FormSet
747 );
748
749 /**
750 Update the ValueChanged status for questions.
751
752 @param FormSet FormSet data structure.
753 @param Form Form data structure.
754 @param SettingScope Setting Scope for Default action.
755
756 **/
757 VOID
758 UpdateStatementStatus (
759 IN FORM_BROWSER_FORMSET *FormSet,
760 IN FORM_BROWSER_FORM *Form,
761 IN BROWSER_SETTING_SCOPE SettingScope
762 );
763
764 /**
765 Get Question's current Value.
766
767 @param FormSet FormSet data structure.
768 @param Form Form data structure.
769 @param Question Question to be initialized.
770 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
771
772 @retval EFI_SUCCESS The function completed successfully.
773
774 **/
775 EFI_STATUS
776 GetQuestionValue (
777 IN FORM_BROWSER_FORMSET *FormSet,
778 IN FORM_BROWSER_FORM *Form,
779 IN OUT FORM_BROWSER_STATEMENT *Question,
780 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
781 );
782
783 /**
784 Save Question Value to edit copy(cached) or Storage(uncached).
785
786 @param FormSet FormSet data structure.
787 @param Form Form data structure.
788 @param Question Pointer to the Question.
789 @param SetValueTo Update the question value to editbuffer , buffer or hii driver.
790
791 @retval EFI_SUCCESS The function completed successfully.
792
793 **/
794 EFI_STATUS
795 SetQuestionValue (
796 IN FORM_BROWSER_FORMSET *FormSet,
797 IN FORM_BROWSER_FORM *Form,
798 IN OUT FORM_BROWSER_STATEMENT *Question,
799 IN GET_SET_QUESTION_VALUE_WITH SetValueTo
800 );
801
802 /**
803 Perform inconsistent check for a Form.
804
805 @param FormSet FormSet data structure.
806 @param Form Form data structure.
807 @param Question The Question to be validated.
808 @param Type Validation type: InConsistent or NoSubmit
809
810 @retval EFI_SUCCESS Form validation pass.
811 @retval other Form validation failed.
812
813 **/
814 EFI_STATUS
815 ValidateQuestion (
816 IN FORM_BROWSER_FORMSET *FormSet,
817 IN FORM_BROWSER_FORM *Form,
818 IN FORM_BROWSER_STATEMENT *Question,
819 IN UINTN Type
820 );
821
822
823 /**
824 Discard data based on the input setting scope (Form, FormSet or System).
825
826 @param FormSet FormSet data structure.
827 @param Form Form data structure.
828 @param SettingScope Setting Scope for Discard action.
829
830 @retval EFI_SUCCESS The function completed successfully.
831 @retval EFI_UNSUPPORTED Unsupport SettingScope.
832
833 **/
834 EFI_STATUS
835 DiscardForm (
836 IN FORM_BROWSER_FORMSET *FormSet,
837 IN FORM_BROWSER_FORM *Form,
838 IN BROWSER_SETTING_SCOPE SettingScope
839 );
840
841 /**
842 Submit data based on the input Setting level (Form, FormSet or System).
843
844 @param FormSet FormSet data structure.
845 @param Form Form data structure.
846 @param SettingScope Setting Scope for Submit action.
847
848 @retval EFI_SUCCESS The function completed successfully.
849 @retval EFI_UNSUPPORTED Unsupport SettingScope.
850
851 **/
852 EFI_STATUS
853 SubmitForm (
854 IN FORM_BROWSER_FORMSET *FormSet,
855 IN FORM_BROWSER_FORM *Form,
856 IN BROWSER_SETTING_SCOPE SettingScope
857 );
858
859 /**
860 Reset Question to its default value.
861
862 @param FormSet The form set.
863 @param Form The form.
864 @param Question The question.
865 @param DefaultId The Class of the default.
866
867 @retval EFI_SUCCESS Question is reset to default value.
868
869 **/
870 EFI_STATUS
871 GetQuestionDefault (
872 IN FORM_BROWSER_FORMSET *FormSet,
873 IN FORM_BROWSER_FORM *Form,
874 IN FORM_BROWSER_STATEMENT *Question,
875 IN UINT16 DefaultId
876 );
877
878 /**
879 Get current setting of Questions.
880
881 @param FormSet FormSet data structure.
882
883 **/
884 VOID
885 InitializeCurrentSetting (
886 IN OUT FORM_BROWSER_FORMSET *FormSet
887 );
888
889 /**
890 Initialize the internal data structure of a FormSet.
891
892 @param Handle PackageList Handle
893 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
894 GUID), take the first FormSet found in package
895 list.
896 @param FormSet FormSet data structure.
897
898 @retval EFI_SUCCESS The function completed successfully.
899 @retval EFI_NOT_FOUND The specified FormSet could not be found.
900
901 **/
902 EFI_STATUS
903 InitializeFormSet (
904 IN EFI_HII_HANDLE Handle,
905 IN OUT EFI_GUID *FormSetGuid,
906 OUT FORM_BROWSER_FORMSET *FormSet
907 );
908
909 /**
910 Reset Questions to their initial value or default value in a Form, Formset or System.
911
912 GetDefaultValueScope parameter decides which questions will reset
913 to its default value.
914
915 @param FormSet FormSet data structure.
916 @param Form Form data structure.
917 @param DefaultId The Class of the default.
918 @param SettingScope Setting Scope for Default action.
919 @param GetDefaultValueScope Get default value scope.
920 @param Storage Get default value only for this storage.
921 @param RetrieveValueFirst Whether call the retrieve call back to
922 get the initial value before get default
923 value.
924 @param SkipGetAltCfg Whether skip the get altcfg string process.
925
926 @retval EFI_SUCCESS The function completed successfully.
927 @retval EFI_UNSUPPORTED Unsupport SettingScope.
928
929 **/
930 EFI_STATUS
931 ExtractDefault (
932 IN FORM_BROWSER_FORMSET *FormSet,
933 IN FORM_BROWSER_FORM *Form,
934 IN UINT16 DefaultId,
935 IN BROWSER_SETTING_SCOPE SettingScope,
936 IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
937 IN BROWSER_STORAGE *Storage,
938 IN BOOLEAN RetrieveValueFirst,
939 IN BOOLEAN SkipGetAltCfg
940 );
941
942 /**
943 Initialize Question's Edit copy from Storage.
944
945 @param Selection Selection contains the information about
946 the Selection, form and formset to be displayed.
947 Selection action may be updated in retrieve callback.
948 If Selection is NULL, only initialize Question value.
949 @param FormSet FormSet data structure.
950 @param Form Form data structure.
951
952 @retval EFI_SUCCESS The function completed successfully.
953
954 **/
955 EFI_STATUS
956 LoadFormConfig (
957 IN OUT UI_MENU_SELECTION *Selection,
958 IN FORM_BROWSER_FORMSET *FormSet,
959 IN FORM_BROWSER_FORM *Form
960 );
961
962 /**
963 Initialize Question's Edit copy from Storage for the whole Formset.
964
965 @param Selection Selection contains the information about
966 the Selection, form and formset to be displayed.
967 Selection action may be updated in retrieve callback.
968 If Selection is NULL, only initialize Question value.
969 @param FormSet FormSet data structure.
970
971 @retval EFI_SUCCESS The function completed successfully.
972
973 **/
974 EFI_STATUS
975 LoadFormSetConfig (
976 IN OUT UI_MENU_SELECTION *Selection,
977 IN FORM_BROWSER_FORMSET *FormSet
978 );
979
980 /**
981 Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
982
983 @param Storage The Storage to be conveted.
984 @param ConfigResp The returned <ConfigResp>.
985 @param ConfigRequest The ConfigRequest string.
986 @param GetEditBuf Get the data from editbuffer or buffer.
987
988 @retval EFI_SUCCESS Convert success.
989 @retval EFI_INVALID_PARAMETER Incorrect storage type.
990
991 **/
992 EFI_STATUS
993 StorageToConfigResp (
994 IN BROWSER_STORAGE *Storage,
995 IN CHAR16 **ConfigResp,
996 IN CHAR16 *ConfigRequest,
997 IN BOOLEAN GetEditBuf
998 );
999
1000 /**
1001 Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.
1002
1003 @param Storage The Storage to receive the settings.
1004 @param ConfigResp The <ConfigResp> to be converted.
1005
1006 @retval EFI_SUCCESS Convert success.
1007 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1008
1009 **/
1010 EFI_STATUS
1011 ConfigRespToStorage (
1012 IN BROWSER_STORAGE *Storage,
1013 IN CHAR16 *ConfigResp
1014 );
1015
1016 /**
1017 Fill storage's edit copy with settings requested from Configuration Driver.
1018
1019 @param FormSet FormSet data structure.
1020 @param Storage Buffer Storage.
1021
1022 **/
1023 VOID
1024 LoadStorage (
1025 IN FORM_BROWSER_FORMSET *FormSet,
1026 IN FORMSET_STORAGE *Storage
1027 );
1028
1029 /**
1030 Fetch the Ifr binary data of a FormSet.
1031
1032 @param Handle PackageList Handle
1033 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
1034 GUID), take the first FormSet found in package
1035 list.
1036 @param BinaryLength The length of the FormSet IFR binary.
1037 @param BinaryData The buffer designed to receive the FormSet.
1038
1039 @retval EFI_SUCCESS Buffer filled with the requested FormSet.
1040 BufferLength was updated.
1041 @retval EFI_INVALID_PARAMETER The handle is unknown.
1042 @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
1043 be found with the requested FormId.
1044
1045 **/
1046 EFI_STATUS
1047 GetIfrBinaryData (
1048 IN EFI_HII_HANDLE Handle,
1049 IN OUT EFI_GUID *FormSetGuid,
1050 OUT UINTN *BinaryLength,
1051 OUT UINT8 **BinaryData
1052 );
1053
1054 /**
1055 Save globals used by previous call to SendForm(). SendForm() may be called from
1056 HiiConfigAccess.Callback(), this will cause SendForm() be reentried.
1057 So, save globals of previous call to SendForm() and restore them upon exit.
1058
1059 **/
1060 VOID
1061 SaveBrowserContext (
1062 VOID
1063 );
1064
1065 /**
1066 Restore globals used by previous call to SendForm().
1067
1068 **/
1069 VOID
1070 RestoreBrowserContext (
1071 VOID
1072 );
1073
1074 /**
1075 This is the routine which an external caller uses to direct the browser
1076 where to obtain it's information.
1077
1078
1079 @param This The Form Browser protocol instanse.
1080 @param Handles A pointer to an array of Handles. If HandleCount > 1 we
1081 display a list of the formsets for the handles specified.
1082 @param HandleCount The number of Handles specified in Handle.
1083 @param FormSetGuid This field points to the EFI_GUID which must match the Guid
1084 field in the EFI_IFR_FORM_SET op-code for the specified
1085 forms-based package. If FormSetGuid is NULL, then this
1086 function will display the first found forms package.
1087 @param FormId This field specifies which EFI_IFR_FORM to render as the first
1088 displayable page. If this field has a value of 0x0000, then
1089 the forms browser will render the specified forms in their encoded order.
1090 ScreenDimenions - This allows the browser to be called so that it occupies a
1091 portion of the physical screen instead of dynamically determining the screen dimensions.
1092 ActionRequest - Points to the action recommended by the form.
1093 @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
1094 characters.
1095 @param ActionRequest Points to the action recommended by the form.
1096
1097 @retval EFI_SUCCESS The function completed successfully.
1098 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1099 @retval EFI_NOT_FOUND No valid forms could be found to display.
1100
1101 **/
1102 EFI_STATUS
1103 EFIAPI
1104 SendForm (
1105 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1106 IN EFI_HII_HANDLE *Handles,
1107 IN UINTN HandleCount,
1108 IN EFI_GUID *FormSetGuid, OPTIONAL
1109 IN UINT16 FormId, OPTIONAL
1110 IN CONST EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
1111 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OPTIONAL
1112 );
1113
1114 /**
1115 This function is called by a callback handler to retrieve uncommitted state
1116 data from the browser.
1117
1118 @param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL
1119 instance.
1120 @param ResultsDataSize A pointer to the size of the buffer associated
1121 with ResultsData.
1122 @param ResultsData A string returned from an IFR browser or
1123 equivalent. The results string will have no
1124 routing information in them.
1125 @param RetrieveData A BOOLEAN field which allows an agent to retrieve
1126 (if RetrieveData = TRUE) data from the uncommitted
1127 browser state information or set (if RetrieveData
1128 = FALSE) data in the uncommitted browser state
1129 information.
1130 @param VariableGuid An optional field to indicate the target variable
1131 GUID name to use.
1132 @param VariableName An optional field to indicate the target
1133 human-readable variable name.
1134
1135 @retval EFI_SUCCESS The results have been distributed or are awaiting
1136 distribution.
1137 @retval EFI_BUFFER_TOO_SMALL The ResultsDataSize specified was too small to
1138 contain the results data.
1139
1140 **/
1141 EFI_STATUS
1142 EFIAPI
1143 BrowserCallback (
1144 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1145 IN OUT UINTN *ResultsDataSize,
1146 IN OUT EFI_STRING ResultsData,
1147 IN BOOLEAN RetrieveData,
1148 IN CONST EFI_GUID *VariableGuid, OPTIONAL
1149 IN CONST CHAR16 *VariableName OPTIONAL
1150 );
1151
1152 /**
1153 Find menu which will show next time.
1154
1155 @param Selection On input, Selection tell setup browser the information
1156 about the Selection, form and formset to be displayed.
1157 On output, Selection return the screen item that is selected
1158 by user.
1159 @param SettingLevel Input Settting level, if it is FormLevel, just exit current form.
1160 else, we need to exit current formset.
1161
1162 @retval TRUE Exit current form.
1163 @retval FALSE User press ESC and keep in current form.
1164 **/
1165 BOOLEAN
1166 FindNextMenu (
1167 IN OUT UI_MENU_SELECTION *Selection,
1168 IN BROWSER_SETTING_SCOPE SettingLevel
1169 );
1170
1171 /**
1172 check whether the form need to update the NV.
1173
1174 @param Form Form data structure.
1175
1176 @retval TRUE Need to update the NV.
1177 @retval FALSE No need to update the NV.
1178 **/
1179 BOOLEAN
1180 IsNvUpdateRequiredForForm (
1181 IN FORM_BROWSER_FORM *Form
1182 );
1183
1184 /**
1185 check whether the formset need to update the NV.
1186
1187 @param FormSet FormSet data structure.
1188
1189 @retval TRUE Need to update the NV.
1190 @retval FALSE No need to update the NV.
1191 **/
1192 BOOLEAN
1193 IsNvUpdateRequiredForFormSet (
1194 IN FORM_BROWSER_FORMSET *FormSet
1195 );
1196
1197 /**
1198 Call the call back function for the question and process the return action.
1199
1200 @param Selection On input, Selection tell setup browser the information
1201 about the Selection, form and formset to be displayed.
1202 On output, Selection return the screen item that is selected
1203 by user.
1204 @param FormSet The formset this question belong to.
1205 @param Form The form this question belong to.
1206 @param Question The Question which need to call.
1207 @param Action The action request.
1208 @param SkipSaveOrDiscard Whether skip save or discard action.
1209
1210 @retval EFI_SUCCESS The call back function excutes successfully.
1211 @return Other value if the call back function failed to excute.
1212 **/
1213 EFI_STATUS
1214 ProcessCallBackFunction (
1215 IN OUT UI_MENU_SELECTION *Selection,
1216 IN FORM_BROWSER_FORMSET *FormSet,
1217 IN FORM_BROWSER_FORM *Form,
1218 IN FORM_BROWSER_STATEMENT *Question,
1219 IN EFI_BROWSER_ACTION Action,
1220 IN BOOLEAN SkipSaveOrDiscard
1221 );
1222
1223 /**
1224 Call the retrieve type call back function for one question to get the initialize data.
1225
1226 This function only used when in the initialize stage, because in this stage, the
1227 Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.
1228
1229 @param ConfigAccess The config access protocol produced by the hii driver.
1230 @param Statement The Question which need to call.
1231 @param FormSet The formset this question belong to.
1232
1233 @retval EFI_SUCCESS The call back function excutes successfully.
1234 @return Other value if the call back function failed to excute.
1235 **/
1236 EFI_STATUS
1237 ProcessRetrieveForQuestion (
1238 IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess,
1239 IN FORM_BROWSER_STATEMENT *Statement,
1240 IN FORM_BROWSER_FORMSET *FormSet
1241 );
1242
1243 /**
1244 Find the matched FormSet context in the backup maintain list based on HiiHandle.
1245
1246 @param Handle The Hii Handle.
1247
1248 @return the found FormSet context. If no found, NULL will return.
1249
1250 **/
1251 FORM_BROWSER_FORMSET *
1252 GetFormSetFromHiiHandle (
1253 EFI_HII_HANDLE Handle
1254 );
1255
1256 /**
1257 Check whether the input HII handle is the FormSet that is being used.
1258
1259 @param Handle The Hii Handle.
1260
1261 @retval TRUE HII handle is being used.
1262 @retval FALSE HII handle is not being used.
1263
1264 **/
1265 BOOLEAN
1266 IsHiiHandleInBrowserContext (
1267 EFI_HII_HANDLE Handle
1268 );
1269
1270 /**
1271 Configure what scope the hot key will impact.
1272 All hot keys have the same scope. The mixed hot keys with the different level are not supported.
1273 If no scope is set, the default scope will be FormSet level.
1274 After all registered hot keys are removed, previous Scope can reset to another level.
1275
1276 @param[in] Scope Scope level to be set.
1277
1278 @retval EFI_SUCCESS Scope is set correctly.
1279 @retval EFI_INVALID_PARAMETER Scope is not the valid value specified in BROWSER_SETTING_SCOPE.
1280 @retval EFI_UNSPPORTED Scope level is different from current one that the registered hot keys have.
1281
1282 **/
1283 EFI_STATUS
1284 EFIAPI
1285 SetScope (
1286 IN BROWSER_SETTING_SCOPE Scope
1287 );
1288
1289 /**
1290 Register the hot key with its browser action, or unregistered the hot key.
1291 Only support hot key that is not printable character (control key, function key, etc.).
1292 If the action value is zero, the hot key will be unregistered if it has been registered.
1293 If the same hot key has been registered, the new action and help string will override the previous ones.
1294
1295 @param[in] KeyData A pointer to a buffer that describes the keystroke
1296 information for the hot key. Its type is EFI_INPUT_KEY to
1297 be supported by all ConsoleIn devices.
1298 @param[in] Action Action value that describes what action will be trigged when the hot key is pressed.
1299 @param[in] DefaultId Specifies the type of defaults to retrieve, which is only for DEFAULT action.
1300 @param[in] HelpString Help string that describes the hot key information.
1301 Its value may be NULL for the unregistered hot key.
1302
1303 @retval EFI_SUCCESS Hot key is registered or unregistered.
1304 @retval EFI_INVALID_PARAMETER KeyData is NULL.
1305 @retval EFI_NOT_FOUND KeyData is not found to be unregistered.
1306 @retval EFI_UNSUPPORTED Key represents a printable character. It is conflicted with Browser.
1307 **/
1308 EFI_STATUS
1309 EFIAPI
1310 RegisterHotKey (
1311 IN EFI_INPUT_KEY *KeyData,
1312 IN UINT32 Action,
1313 IN UINT16 DefaultId,
1314 IN EFI_STRING HelpString OPTIONAL
1315 );
1316
1317 /**
1318 Register Exit handler function.
1319 When more than one handler function is registered, the latter one will override the previous one.
1320 When NULL handler is specified, the previous Exit handler will be unregistered.
1321
1322 @param[in] Handler Pointer to handler function.
1323
1324 **/
1325 VOID
1326 EFIAPI
1327 RegiserExitHandler (
1328 IN EXIT_HANDLER Handler
1329 );
1330
1331 /**
1332
1333 Check whether the browser data has been modified.
1334
1335 @retval TRUE Browser data is changed.
1336 @retval FALSE No browser data is changed.
1337
1338 **/
1339 BOOLEAN
1340 EFIAPI
1341 IsBrowserDataModified (
1342 VOID
1343 );
1344
1345 /**
1346
1347 Execute the action requested by the Action parameter.
1348
1349 @param[in] Action Execute the request action.
1350 @param[in] DefaultId The default Id info when need to load default value.
1351
1352 @retval EFI_SUCCESS Execute the request action succss.
1353 @retval EFI_INVALID_PARAMETER The input action value is invalid.
1354
1355 **/
1356 EFI_STATUS
1357 EFIAPI
1358 ExecuteAction (
1359 IN UINT32 Action,
1360 IN UINT16 DefaultId
1361 );
1362
1363 /**
1364 Create reminder to let user to choose save or discard the changed browser data.
1365 Caller can use it to actively check the changed browser data.
1366
1367 @retval BROWSER_NO_CHANGES No browser data is changed.
1368 @retval BROWSER_SAVE_CHANGES The changed browser data is saved.
1369 @retval BROWSER_DISCARD_CHANGES The changed browser data is discard.
1370 @retval BROWSER_KEEP_CURRENT Browser keep current changes.
1371
1372 **/
1373 UINT32
1374 EFIAPI
1375 SaveReminder (
1376 VOID
1377 );
1378
1379 /**
1380 Check whether the Reset Required for the browser
1381
1382 @retval TRUE Browser required to reset after exit.
1383 @retval FALSE Browser not need to reset after exit.
1384
1385 **/
1386 BOOLEAN
1387 EFIAPI
1388 IsResetRequired (
1389 VOID
1390 );
1391
1392 /**
1393 Find the registered HotKey based on KeyData.
1394
1395 @param[in] KeyData A pointer to a buffer that describes the keystroke
1396 information for the hot key.
1397
1398 @return The registered HotKey context. If no found, NULL will return.
1399 **/
1400 BROWSER_HOT_KEY *
1401 GetHotKeyFromRegisterList (
1402 IN EFI_INPUT_KEY *KeyData
1403 );
1404
1405 /**
1406
1407 Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
1408
1409 @param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.
1410
1411 @retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.
1412
1413 **/
1414 FORM_BROWSER_STATEMENT *
1415 GetBrowserStatement (
1416 IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement
1417 );
1418
1419 /**
1420 Password may be stored as encrypted by Configuration Driver. When change a
1421 password, user will be challenged with old password. To validate user input old
1422 password, we will send the clear text to Configuration Driver via Callback().
1423 Configuration driver is responsible to check the passed in password and return
1424 the validation result. If validation pass, state machine in password Callback()
1425 will transit from BROWSER_STATE_VALIDATE_PASSWORD to BROWSER_STATE_SET_PASSWORD.
1426 After user type in new password twice, Callback() will be invoked to send the
1427 new password to Configuration Driver.
1428
1429 @param Selection Pointer to UI_MENU_SELECTION.
1430 @param MenuOption The MenuOption for this password Question.
1431 @param String The clear text of password.
1432
1433 @retval EFI_NOT_AVAILABLE_YET Callback() request to terminate password input.
1434 @return In state of BROWSER_STATE_VALIDATE_PASSWORD:
1435 @retval EFI_SUCCESS Password correct, Browser will prompt for new
1436 password.
1437 @retval EFI_NOT_READY Password incorrect, Browser will show error
1438 message.
1439 @retval Other Browser will do nothing.
1440 @return In state of BROWSER_STATE_SET_PASSWORD:
1441 @retval EFI_SUCCESS Set password success.
1442 @retval Other Set password failed.
1443
1444 **/
1445 EFI_STATUS
1446 PasswordCallback (
1447 IN UI_MENU_SELECTION *Selection,
1448 IN FORM_BROWSER_STATEMENT *Question,
1449 IN CHAR16 *String
1450 );
1451
1452 /**
1453 Display error message for invalid password.
1454
1455 **/
1456 VOID
1457 PasswordInvalid (
1458 VOID
1459 );
1460
1461 /**
1462 The worker function that send the displays to the screen. On output,
1463 the selection made by user is returned.
1464
1465 @param Selection On input, Selection tell setup browser the information
1466 about the Selection, form and formset to be displayed.
1467 On output, Selection return the screen item that is selected
1468 by user.
1469
1470 @retval EFI_SUCCESS The page is displayed successfully.
1471 @return Other value if the page failed to be diplayed.
1472
1473 **/
1474 EFI_STATUS
1475 SetupBrowser (
1476 IN OUT UI_MENU_SELECTION *Selection
1477 );
1478
1479 /**
1480 Free up the resource allocated for all strings required
1481 by Setup Browser.
1482
1483 **/
1484 VOID
1485 FreeBrowserStrings (
1486 VOID
1487 );
1488
1489 /**
1490 Create a menu with specified formset GUID and form ID, and add it as a child
1491 of the given parent menu.
1492
1493 @param HiiHandle Hii handle related to this formset.
1494 @param FormSetGuid The Formset Guid of menu to be added.
1495 @param FormId The Form ID of menu to be added.
1496 @param QuestionId The question id of this menu to be added.
1497
1498 @return A pointer to the newly added menu or NULL if memory is insufficient.
1499
1500 **/
1501 FORM_ENTRY_INFO *
1502 UiAddMenuList (
1503 IN EFI_HII_HANDLE HiiHandle,
1504 IN EFI_GUID *FormSetGuid,
1505 IN UINT16 FormId,
1506 IN UINT16 QuestionId
1507 );
1508
1509 /**
1510 Search Menu with given FormSetGuid and FormId in all cached menu list.
1511
1512 @param HiiHandle HiiHandle for FormSet.
1513 @param FormSetGuid The Formset GUID of the menu to search.
1514 @param FormId The Form ID of menu to search.
1515
1516 @return A pointer to menu found or NULL if not found.
1517
1518 **/
1519 FORM_ENTRY_INFO *
1520 UiFindMenuList (
1521 IN EFI_HII_HANDLE HiiHandle,
1522 IN EFI_GUID *FormSetGuid,
1523 IN UINT16 FormId
1524 );
1525
1526 /**
1527 Free Menu list linked list.
1528
1529 @param MenuListHead One Menu list point in the menu list.
1530
1531 **/
1532 VOID
1533 UiFreeMenuList (
1534 LIST_ENTRY *MenuListHead
1535 );
1536
1537 /**
1538 Find parent menu for current menu.
1539
1540 @param CurrentMenu Current Menu
1541 @param SettingLevel Whether find parent menu in Form Level or Formset level.
1542 In form level, just find the parent menu;
1543 In formset level, find the parent menu which has different
1544 formset guid value.
1545
1546 @retval The parent menu for current menu.
1547 **/
1548 FORM_ENTRY_INFO *
1549 UiFindParentMenu (
1550 IN FORM_ENTRY_INFO *CurrentMenu,
1551 IN BROWSER_SETTING_SCOPE SettingLevel
1552 );
1553
1554 /**
1555 Validate the HiiHandle.
1556
1557 @param HiiHandle The input HiiHandle which need to validate.
1558
1559 @retval TRUE The handle is validate.
1560 @retval FALSE The handle is invalidate.
1561
1562 **/
1563 BOOLEAN
1564 ValidateHiiHandle (
1565 EFI_HII_HANDLE HiiHandle
1566 );
1567
1568 /**
1569 Copy current Menu list to the new menu list.
1570
1571 @param NewMenuListHead New create Menu list.
1572 @param CurrentMenuListHead Current Menu list.
1573
1574 **/
1575 VOID
1576 UiCopyMenuList (
1577 OUT LIST_ENTRY *NewMenuListHead,
1578 IN LIST_ENTRY *CurrentMenuListHead
1579 );
1580
1581 /**
1582 Search an Option of a Question by its value.
1583
1584 @param Question The Question
1585 @param OptionValue Value for Option to be searched.
1586
1587 @retval Pointer Pointer to the found Option.
1588 @retval NULL Option not found.
1589
1590 **/
1591 QUESTION_OPTION *
1592 ValueToOption (
1593 IN FORM_BROWSER_STATEMENT *Question,
1594 IN EFI_HII_VALUE *OptionValue
1595 );
1596 /**
1597 Return data element in an Array by its Index.
1598
1599 @param Array The data array.
1600 @param Type Type of the data in this array.
1601 @param Index Zero based index for data in this array.
1602
1603 @retval Value The data to be returned
1604
1605 **/
1606 UINT64
1607 GetArrayData (
1608 IN VOID *Array,
1609 IN UINT8 Type,
1610 IN UINTN Index
1611 );
1612
1613 /**
1614 Set value of a data element in an Array by its Index.
1615
1616 @param Array The data array.
1617 @param Type Type of the data in this array.
1618 @param Index Zero based index for data in this array.
1619 @param Value The value to be set.
1620
1621 **/
1622 VOID
1623 SetArrayData (
1624 IN VOID *Array,
1625 IN UINT8 Type,
1626 IN UINTN Index,
1627 IN UINT64 Value
1628 );
1629
1630 /**
1631 Compare two Hii value.
1632
1633 @param Value1 Expression value to compare on left-hand.
1634 @param Value2 Expression value to compare on right-hand.
1635 @param Result Return value after compare.
1636 retval 0 Two operators equal.
1637 return Positive value if Value1 is greater than Value2.
1638 retval Negative value if Value1 is less than Value2.
1639 @param HiiHandle Only required for string compare.
1640
1641 @retval other Could not perform compare on two values.
1642 @retval EFI_SUCCESS Compare the value success.
1643
1644 **/
1645 EFI_STATUS
1646 CompareHiiValue (
1647 IN EFI_HII_VALUE *Value1,
1648 IN EFI_HII_VALUE *Value2,
1649 OUT INTN *Result,
1650 IN EFI_HII_HANDLE HiiHandle OPTIONAL
1651 );
1652
1653 /**
1654 Perform Password check.
1655 Passwork may be encrypted by driver that requires the specific check.
1656
1657 @param Form Form where Password Statement is in.
1658 @param Statement Password statement
1659 @param PasswordString Password string to be checked. It may be NULL.
1660 NULL means to restore password.
1661 "" string can be used to checked whether old password does exist.
1662
1663 @return Status Status of Password check.
1664 **/
1665 EFI_STATUS
1666 EFIAPI
1667 PasswordCheck (
1668 IN FORM_DISPLAY_ENGINE_FORM *Form,
1669 IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,
1670 IN EFI_STRING PasswordString OPTIONAL
1671 );
1672
1673 /**
1674
1675 Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
1676
1677 @param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.
1678
1679 @retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.
1680
1681 **/
1682 FORM_BROWSER_STATEMENT *
1683 GetBrowserStatement (
1684 IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement
1685 );
1686
1687 /**
1688
1689 Initialize the Display form structure data.
1690
1691 **/
1692 VOID
1693 InitializeDisplayFormData (
1694 VOID
1695 );
1696
1697
1698 /**
1699 Base on the current formset info, clean the ConfigRequest string in browser storage.
1700
1701 @param FormSet Pointer of the FormSet
1702
1703 **/
1704 VOID
1705 CleanBrowserStorage (
1706 IN OUT FORM_BROWSER_FORMSET *FormSet
1707 );
1708
1709 /**
1710 Find HII Handle in the HII database associated with given Device Path.
1711
1712 If DevicePath is NULL, then ASSERT.
1713
1714 @param DevicePath Device Path associated with the HII package list
1715 handle.
1716 @param FormsetGuid The formset guid for this formset.
1717
1718 @retval Handle HII package list Handle associated with the Device
1719 Path.
1720 @retval NULL Hii Package list handle is not found.
1721
1722 **/
1723 EFI_HII_HANDLE
1724 DevicePathToHiiHandle (
1725 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
1726 IN EFI_GUID *FormsetGuid
1727 );
1728
1729 /**
1730 Adjust the config request info, remove the request elements which already in AllConfigRequest string.
1731
1732 @param Storage Form set Storage.
1733 @param Request The input request string.
1734 @param RespString Whether the input is ConfigRequest or ConfigResp format.
1735
1736 @retval TRUE Has element not covered by current used elements, need to continue to call ExtractConfig
1737 @retval FALSE All elements covered by current used elements.
1738
1739 **/
1740 BOOLEAN
1741 ConfigRequestAdjust (
1742 IN BROWSER_STORAGE *Storage,
1743 IN CHAR16 *Request,
1744 IN BOOLEAN RespString
1745 );
1746
1747 /**
1748 Perform question check.
1749
1750 If one question has more than one check, process form high priority to low.
1751
1752 @param FormSet FormSet data structure.
1753 @param Form Form data structure.
1754 @param Question The Question to be validated.
1755
1756 @retval EFI_SUCCESS Form validation pass.
1757 @retval other Form validation failed.
1758
1759 **/
1760 EFI_STATUS
1761 ValueChangedValidation (
1762 IN FORM_BROWSER_FORMSET *FormSet,
1763 IN FORM_BROWSER_FORM *Form,
1764 IN FORM_BROWSER_STATEMENT *Question
1765 );
1766
1767 /**
1768 Pop up the error info.
1769
1770 @param BrowserStatus The input browser status.
1771 @param HiiHandle The HiiHandle for this error opcode.
1772 @param OpCode The opcode use to get the erro info and timeout value.
1773 @param ErrorString Error string used by BROWSER_NO_SUBMIT_IF.
1774
1775 **/
1776 UINT32
1777 PopupErrorMessage (
1778 IN UINT32 BrowserStatus,
1779 IN EFI_HII_HANDLE HiiHandle,
1780 IN EFI_IFR_OP_HEADER *OpCode, OPTIONAL
1781 IN CHAR16 *ErrorString
1782 );
1783
1784 /**
1785 Check whether the result is TRUE or FALSE.
1786
1787 For the EFI_HII_VALUE value type is numeric, return TRUE if the
1788 value is not 0.
1789
1790 @param Result Input the result data.
1791
1792 @retval TRUE The result is TRUE.
1793 @retval FALSE The result is FALSE.
1794
1795 **/
1796 BOOLEAN
1797 IsTrue (
1798 IN EFI_HII_VALUE *Result
1799 );
1800
1801 /**
1802 Get Formset_storage base on the input varstoreid info.
1803
1804 @param FormSet Pointer of the current FormSet.
1805 @param VarStoreId Varstore ID info.
1806
1807 @return Pointer to a FORMSET_STORAGE data structure.
1808
1809 **/
1810 FORMSET_STORAGE *
1811 GetFstStgFromVarId (
1812 IN FORM_BROWSER_FORMSET *FormSet,
1813 IN EFI_VARSTORE_ID VarStoreId
1814 );
1815
1816 /**
1817 Get Formset_storage base on the input browser storage.
1818
1819 More than one formsets may share the same browser storage,
1820 this function just get the first formset storage which
1821 share the browser storage.
1822
1823 @param Storage browser storage info.
1824
1825 @return Pointer to a FORMSET_STORAGE data structure.
1826
1827
1828 **/
1829 FORMSET_STORAGE *
1830 GetFstStgFromBrsStg (
1831 IN BROWSER_STORAGE *Storage
1832 );
1833
1834 #endif