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