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