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