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