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