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