]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
337abb3fb6539207a8ff4a85e9d4b587e652a7e0
[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 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 BOOLEAN gFinishRetrieveCall;
551 extern LIST_ENTRY gBrowserFormSetList;
552 extern LIST_ENTRY gBrowserHotKeyList;
553 extern BROWSER_SETTING_SCOPE gBrowserSettingScope;
554 extern EXIT_HANDLER ExitHandlerFunction;
555 extern EFI_HII_HANDLE mCurrentHiiHandle;
556 extern SETUP_DRIVER_PRIVATE_DATA mPrivateData;
557 //
558 // Browser Global Strings
559 //
560 extern CHAR16 *gEmptyString;
561
562 extern EFI_GUID gZeroGuid;
563
564 extern UI_MENU_SELECTION *gCurrentSelection;
565
566 //
567 // Global Procedure Defines
568 //
569 #include "Expression.h"
570
571 /**
572 Initialize the HII String Token to the correct values.
573
574 **/
575 VOID
576 InitializeBrowserStrings (
577 VOID
578 );
579
580 /**
581 Parse opcodes in the formset IFR binary.
582
583 @param FormSet Pointer of the FormSet data structure.
584
585 @retval EFI_SUCCESS Opcode parse success.
586 @retval Other Opcode parse fail.
587
588 **/
589 EFI_STATUS
590 ParseOpCodes (
591 IN FORM_BROWSER_FORMSET *FormSet
592 );
593
594 /**
595 Free resources allocated for a FormSet.
596
597 @param FormSet Pointer of the FormSet
598
599 **/
600 VOID
601 DestroyFormSet (
602 IN OUT FORM_BROWSER_FORMSET *FormSet
603 );
604
605
606 /**
607 Create a new string in HII Package List.
608
609 @param String The String to be added
610 @param HiiHandle The package list in the HII database to insert the
611 specified string.
612
613 @return The output string.
614
615 **/
616 EFI_STRING_ID
617 NewString (
618 IN CHAR16 *String,
619 IN EFI_HII_HANDLE HiiHandle
620 );
621
622 /**
623 Delete a string from HII Package List.
624
625 @param StringId Id of the string in HII database.
626 @param HiiHandle The HII package list handle.
627
628 @retval EFI_SUCCESS The string was deleted successfully.
629
630 **/
631 EFI_STATUS
632 DeleteString (
633 IN EFI_STRING_ID StringId,
634 IN EFI_HII_HANDLE HiiHandle
635 );
636
637 /**
638 Get the string based on the StringId and HII Package List Handle.
639
640 @param Token The String's ID.
641 @param HiiHandle The package list in the HII database to search for
642 the specified string.
643
644 @return The output string.
645
646 **/
647 CHAR16 *
648 GetToken (
649 IN EFI_STRING_ID Token,
650 IN EFI_HII_HANDLE HiiHandle
651 );
652
653 /**
654 Get Value for given Name from a NameValue Storage.
655
656 @param Storage The NameValue Storage.
657 @param Name The Name.
658 @param Value The retured Value.
659 @param GetValueFrom Where to get source value, from EditValue or Value.
660
661 @retval EFI_SUCCESS Value found for given Name.
662 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
663
664 **/
665 EFI_STATUS
666 GetValueByName (
667 IN BROWSER_STORAGE *Storage,
668 IN CHAR16 *Name,
669 IN OUT CHAR16 **Value,
670 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
671 );
672
673 /**
674 Set Value of given Name in a NameValue Storage.
675
676 @param Storage The NameValue Storage.
677 @param Name The Name.
678 @param Value The Value to set.
679 @param SetValueTo Whether update editValue or Value.
680 @param ReturnNode The node use the input name.
681
682 @retval EFI_SUCCESS Value found for given Name.
683 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
684
685 **/
686 EFI_STATUS
687 SetValueByName (
688 IN BROWSER_STORAGE *Storage,
689 IN CHAR16 *Name,
690 IN CHAR16 *Value,
691 IN GET_SET_QUESTION_VALUE_WITH SetValueTo,
692 OUT NAME_VALUE_NODE **ReturnNode
693 );
694
695 /**
696 Validate whether this question's value has changed.
697
698 @param FormSet FormSet data structure.
699 @param Form Form data structure.
700 @param Question Question to be initialized.
701 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
702
703 @retval TRUE Question's value has changed.
704 @retval FALSE Question's value has not changed
705
706 **/
707 BOOLEAN
708 IsQuestionValueChanged (
709 IN FORM_BROWSER_FORMSET *FormSet,
710 IN FORM_BROWSER_FORM *Form,
711 IN OUT FORM_BROWSER_STATEMENT *Question,
712 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
713 );
714
715 /**
716 Get Question's current Value.
717
718 @param FormSet FormSet data structure.
719 @param Form Form data structure.
720 @param Question Question to be initialized.
721 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
722
723 @retval EFI_SUCCESS The function completed successfully.
724
725 **/
726 EFI_STATUS
727 GetQuestionValue (
728 IN FORM_BROWSER_FORMSET *FormSet,
729 IN FORM_BROWSER_FORM *Form,
730 IN OUT FORM_BROWSER_STATEMENT *Question,
731 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
732 );
733
734 /**
735 Save Question Value to edit copy(cached) or Storage(uncached).
736
737 @param FormSet FormSet data structure.
738 @param Form Form data structure.
739 @param Question Pointer to the Question.
740 @param SetValueTo Update the question value to editbuffer , buffer or hii driver.
741
742 @retval EFI_SUCCESS The function completed successfully.
743
744 **/
745 EFI_STATUS
746 SetQuestionValue (
747 IN FORM_BROWSER_FORMSET *FormSet,
748 IN FORM_BROWSER_FORM *Form,
749 IN OUT FORM_BROWSER_STATEMENT *Question,
750 IN GET_SET_QUESTION_VALUE_WITH SetValueTo
751 );
752
753 /**
754 Perform inconsistent check for a Form.
755
756 @param FormSet FormSet data structure.
757 @param Form Form data structure.
758 @param Question The Question to be validated.
759 @param Type Validation type: InConsistent or NoSubmit
760
761 @retval EFI_SUCCESS Form validation pass.
762 @retval other Form validation failed.
763
764 **/
765 EFI_STATUS
766 ValidateQuestion (
767 IN FORM_BROWSER_FORMSET *FormSet,
768 IN FORM_BROWSER_FORM *Form,
769 IN FORM_BROWSER_STATEMENT *Question,
770 IN UINTN Type
771 );
772
773
774 /**
775 Discard data based on the input setting scope (Form, FormSet or System).
776
777 @param FormSet FormSet data structure.
778 @param Form Form data structure.
779 @param SettingScope Setting Scope for Discard action.
780
781 @retval EFI_SUCCESS The function completed successfully.
782 @retval EFI_UNSUPPORTED Unsupport SettingScope.
783
784 **/
785 EFI_STATUS
786 DiscardForm (
787 IN FORM_BROWSER_FORMSET *FormSet,
788 IN FORM_BROWSER_FORM *Form,
789 IN BROWSER_SETTING_SCOPE SettingScope
790 );
791
792 /**
793 Submit data based on the input Setting level (Form, FormSet or System).
794
795 @param FormSet FormSet data structure.
796 @param Form Form data structure.
797 @param SettingScope Setting Scope for Submit action.
798
799 @retval EFI_SUCCESS The function completed successfully.
800 @retval EFI_UNSUPPORTED Unsupport SettingScope.
801
802 **/
803 EFI_STATUS
804 SubmitForm (
805 IN FORM_BROWSER_FORMSET *FormSet,
806 IN FORM_BROWSER_FORM *Form,
807 IN BROWSER_SETTING_SCOPE SettingScope
808 );
809
810 /**
811 Reset Question to its default value.
812
813 @param FormSet The form set.
814 @param Form The form.
815 @param Question The question.
816 @param DefaultId The Class of the default.
817
818 @retval EFI_SUCCESS Question is reset to default value.
819
820 **/
821 EFI_STATUS
822 GetQuestionDefault (
823 IN FORM_BROWSER_FORMSET *FormSet,
824 IN FORM_BROWSER_FORM *Form,
825 IN FORM_BROWSER_STATEMENT *Question,
826 IN UINT16 DefaultId
827 );
828
829 /**
830 Get current setting of Questions.
831
832 @param FormSet FormSet data structure.
833
834 **/
835 VOID
836 InitializeCurrentSetting (
837 IN OUT FORM_BROWSER_FORMSET *FormSet
838 );
839
840 /**
841 Initialize the internal data structure of a FormSet.
842
843 @param Handle PackageList Handle
844 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
845 GUID), take the first FormSet found in package
846 list.
847 @param FormSet FormSet data structure.
848
849 @retval EFI_SUCCESS The function completed successfully.
850 @retval EFI_NOT_FOUND The specified FormSet could not be found.
851
852 **/
853 EFI_STATUS
854 InitializeFormSet (
855 IN EFI_HII_HANDLE Handle,
856 IN OUT EFI_GUID *FormSetGuid,
857 OUT FORM_BROWSER_FORMSET *FormSet
858 );
859
860 /**
861 Reset Questions to their initial value or default value in a Form, Formset or System.
862
863 GetDefaultValueScope parameter decides which questions will reset
864 to its default value.
865
866 @param FormSet FormSet data structure.
867 @param Form Form data structure.
868 @param DefaultId The Class of the default.
869 @param SettingScope Setting Scope for Default action.
870 @param GetDefaultValueScope Get default value scope.
871 @param Storage Get default value only for this storage.
872 @param RetrieveValueFirst Whether call the retrieve call back to
873 get the initial value before get default
874 value.
875
876 @retval EFI_SUCCESS The function completed successfully.
877 @retval EFI_UNSUPPORTED Unsupport SettingScope.
878
879 **/
880 EFI_STATUS
881 ExtractDefault (
882 IN FORM_BROWSER_FORMSET *FormSet,
883 IN FORM_BROWSER_FORM *Form,
884 IN UINT16 DefaultId,
885 IN BROWSER_SETTING_SCOPE SettingScope,
886 IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
887 IN BROWSER_STORAGE *Storage,
888 IN BOOLEAN RetrieveValueFirst
889 );
890
891 /**
892 Initialize Question's Edit copy from Storage.
893
894 @param Selection Selection contains the information about
895 the Selection, form and formset to be displayed.
896 Selection action may be updated in retrieve callback.
897 If Selection is NULL, only initialize Question value.
898 @param FormSet FormSet data structure.
899 @param Form Form data structure.
900
901 @retval EFI_SUCCESS The function completed successfully.
902
903 **/
904 EFI_STATUS
905 LoadFormConfig (
906 IN OUT UI_MENU_SELECTION *Selection,
907 IN FORM_BROWSER_FORMSET *FormSet,
908 IN FORM_BROWSER_FORM *Form
909 );
910
911 /**
912 Initialize Question's Edit copy from Storage for the whole Formset.
913
914 @param Selection Selection contains the information about
915 the Selection, form and formset to be displayed.
916 Selection action may be updated in retrieve callback.
917 If Selection is NULL, only initialize Question value.
918 @param FormSet FormSet data structure.
919
920 @retval EFI_SUCCESS The function completed successfully.
921
922 **/
923 EFI_STATUS
924 LoadFormSetConfig (
925 IN OUT UI_MENU_SELECTION *Selection,
926 IN FORM_BROWSER_FORMSET *FormSet
927 );
928
929 /**
930 Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
931
932 @param Storage The Storage to be conveted.
933 @param ConfigResp The returned <ConfigResp>.
934 @param ConfigRequest The ConfigRequest string.
935 @param GetEditBuf Get the data from editbuffer or buffer.
936
937 @retval EFI_SUCCESS Convert success.
938 @retval EFI_INVALID_PARAMETER Incorrect storage type.
939
940 **/
941 EFI_STATUS
942 StorageToConfigResp (
943 IN BROWSER_STORAGE *Storage,
944 IN CHAR16 **ConfigResp,
945 IN CHAR16 *ConfigRequest,
946 IN BOOLEAN GetEditBuf
947 );
948
949 /**
950 Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.
951
952 @param Storage The Storage to receive the settings.
953 @param ConfigResp The <ConfigResp> to be converted.
954
955 @retval EFI_SUCCESS Convert success.
956 @retval EFI_INVALID_PARAMETER Incorrect storage type.
957
958 **/
959 EFI_STATUS
960 ConfigRespToStorage (
961 IN BROWSER_STORAGE *Storage,
962 IN CHAR16 *ConfigResp
963 );
964
965 /**
966 Fill storage's edit copy with settings requested from Configuration Driver.
967
968 @param FormSet FormSet data structure.
969 @param Storage Buffer Storage.
970
971 **/
972 VOID
973 LoadStorage (
974 IN FORM_BROWSER_FORMSET *FormSet,
975 IN FORMSET_STORAGE *Storage
976 );
977
978 /**
979 Fetch the Ifr binary data of a FormSet.
980
981 @param Handle PackageList Handle
982 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
983 GUID), take the first FormSet found in package
984 list.
985 @param BinaryLength The length of the FormSet IFR binary.
986 @param BinaryData The buffer designed to receive the FormSet.
987
988 @retval EFI_SUCCESS Buffer filled with the requested FormSet.
989 BufferLength was updated.
990 @retval EFI_INVALID_PARAMETER The handle is unknown.
991 @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
992 be found with the requested FormId.
993
994 **/
995 EFI_STATUS
996 GetIfrBinaryData (
997 IN EFI_HII_HANDLE Handle,
998 IN OUT EFI_GUID *FormSetGuid,
999 OUT UINTN *BinaryLength,
1000 OUT UINT8 **BinaryData
1001 );
1002
1003 /**
1004 Save globals used by previous call to SendForm(). SendForm() may be called from
1005 HiiConfigAccess.Callback(), this will cause SendForm() be reentried.
1006 So, save globals of previous call to SendForm() and restore them upon exit.
1007
1008 **/
1009 VOID
1010 SaveBrowserContext (
1011 VOID
1012 );
1013
1014 /**
1015 Restore globals used by previous call to SendForm().
1016
1017 **/
1018 VOID
1019 RestoreBrowserContext (
1020 VOID
1021 );
1022
1023 /**
1024 This is the routine which an external caller uses to direct the browser
1025 where to obtain it's information.
1026
1027
1028 @param This The Form Browser protocol instanse.
1029 @param Handles A pointer to an array of Handles. If HandleCount > 1 we
1030 display a list of the formsets for the handles specified.
1031 @param HandleCount The number of Handles specified in Handle.
1032 @param FormSetGuid This field points to the EFI_GUID which must match the Guid
1033 field in the EFI_IFR_FORM_SET op-code for the specified
1034 forms-based package. If FormSetGuid is NULL, then this
1035 function will display the first found forms package.
1036 @param FormId This field specifies which EFI_IFR_FORM to render as the first
1037 displayable page. If this field has a value of 0x0000, then
1038 the forms browser will render the specified forms in their encoded order.
1039 ScreenDimenions - This allows the browser to be called so that it occupies a
1040 portion of the physical screen instead of dynamically determining the screen dimensions.
1041 ActionRequest - Points to the action recommended by the form.
1042 @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
1043 characters.
1044 @param ActionRequest Points to the action recommended by the form.
1045
1046 @retval EFI_SUCCESS The function completed successfully.
1047 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1048 @retval EFI_NOT_FOUND No valid forms could be found to display.
1049
1050 **/
1051 EFI_STATUS
1052 EFIAPI
1053 SendForm (
1054 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1055 IN EFI_HII_HANDLE *Handles,
1056 IN UINTN HandleCount,
1057 IN EFI_GUID *FormSetGuid, OPTIONAL
1058 IN UINT16 FormId, OPTIONAL
1059 IN CONST EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
1060 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OPTIONAL
1061 );
1062
1063 /**
1064 This function is called by a callback handler to retrieve uncommitted state
1065 data from the browser.
1066
1067 @param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL
1068 instance.
1069 @param ResultsDataSize A pointer to the size of the buffer associated
1070 with ResultsData.
1071 @param ResultsData A string returned from an IFR browser or
1072 equivalent. The results string will have no
1073 routing information in them.
1074 @param RetrieveData A BOOLEAN field which allows an agent to retrieve
1075 (if RetrieveData = TRUE) data from the uncommitted
1076 browser state information or set (if RetrieveData
1077 = FALSE) data in the uncommitted browser state
1078 information.
1079 @param VariableGuid An optional field to indicate the target variable
1080 GUID name to use.
1081 @param VariableName An optional field to indicate the target
1082 human-readable variable name.
1083
1084 @retval EFI_SUCCESS The results have been distributed or are awaiting
1085 distribution.
1086 @retval EFI_BUFFER_TOO_SMALL The ResultsDataSize specified was too small to
1087 contain the results data.
1088
1089 **/
1090 EFI_STATUS
1091 EFIAPI
1092 BrowserCallback (
1093 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1094 IN OUT UINTN *ResultsDataSize,
1095 IN OUT EFI_STRING ResultsData,
1096 IN BOOLEAN RetrieveData,
1097 IN CONST EFI_GUID *VariableGuid, OPTIONAL
1098 IN CONST CHAR16 *VariableName OPTIONAL
1099 );
1100
1101 /**
1102 Find menu which will show next time.
1103
1104 @param Selection On input, Selection tell setup browser the information
1105 about the Selection, form and formset to be displayed.
1106 On output, Selection return the screen item that is selected
1107 by user.
1108 @param SettingLevel Input Settting level, if it is FormLevel, just exit current form.
1109 else, we need to exit current formset.
1110
1111 @retval TRUE Exit current form.
1112 @retval FALSE User press ESC and keep in current form.
1113 **/
1114 BOOLEAN
1115 FindNextMenu (
1116 IN OUT UI_MENU_SELECTION *Selection,
1117 IN BROWSER_SETTING_SCOPE SettingLevel
1118 );
1119
1120 /**
1121 check whether the form need to update the NV.
1122
1123 @param Form Form data structure.
1124
1125 @retval TRUE Need to update the NV.
1126 @retval FALSE No need to update the NV.
1127 **/
1128 BOOLEAN
1129 IsNvUpdateRequiredForForm (
1130 IN FORM_BROWSER_FORM *Form
1131 );
1132
1133 /**
1134 check whether the formset need to update the NV.
1135
1136 @param FormSet FormSet data structure.
1137
1138 @retval TRUE Need to update the NV.
1139 @retval FALSE No need to update the NV.
1140 **/
1141 BOOLEAN
1142 IsNvUpdateRequiredForFormSet (
1143 IN FORM_BROWSER_FORMSET *FormSet
1144 );
1145
1146 /**
1147 Check whether the storage data for current form set is changed.
1148
1149 @param FormSet FormSet data structure.
1150
1151 @retval TRUE Data is changed.
1152 @retval FALSE Data is not changed.
1153 **/
1154 BOOLEAN
1155 IsStorageDataChangedForFormSet (
1156 IN FORM_BROWSER_FORMSET *FormSet
1157 );
1158
1159 /**
1160 Call the call back function for the question and process the return action.
1161
1162 @param Selection On input, Selection tell setup browser the information
1163 about the Selection, form and formset to be displayed.
1164 On output, Selection return the screen item that is selected
1165 by user.
1166 @param FormSet The formset this question belong to.
1167 @param Form The form this question belong to.
1168 @param Question The Question which need to call.
1169 @param Action The action request.
1170 @param SkipSaveOrDiscard Whether skip save or discard action.
1171
1172 @retval EFI_SUCCESS The call back function excutes successfully.
1173 @return Other value if the call back function failed to excute.
1174 **/
1175 EFI_STATUS
1176 ProcessCallBackFunction (
1177 IN OUT UI_MENU_SELECTION *Selection,
1178 IN FORM_BROWSER_FORMSET *FormSet,
1179 IN FORM_BROWSER_FORM *Form,
1180 IN FORM_BROWSER_STATEMENT *Question,
1181 IN EFI_BROWSER_ACTION Action,
1182 IN BOOLEAN SkipSaveOrDiscard
1183 );
1184
1185 /**
1186 Call the retrieve type call back function for one question to get the initialize data.
1187
1188 This function only used when in the initialize stage, because in this stage, the
1189 Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.
1190
1191 @param ConfigAccess The config access protocol produced by the hii driver.
1192 @param Statement The Question which need to call.
1193
1194 @retval EFI_SUCCESS The call back function excutes successfully.
1195 @return Other value if the call back function failed to excute.
1196 **/
1197 EFI_STATUS
1198 ProcessRetrieveForQuestion (
1199 IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess,
1200 IN FORM_BROWSER_STATEMENT *Statement
1201 );
1202
1203 /**
1204 Find the matched FormSet context in the backup maintain list based on HiiHandle.
1205
1206 @param Handle The Hii Handle.
1207
1208 @return the found FormSet context. If no found, NULL will return.
1209
1210 **/
1211 FORM_BROWSER_FORMSET *
1212 GetFormSetFromHiiHandle (
1213 EFI_HII_HANDLE Handle
1214 );
1215
1216 /**
1217 Check whether the input HII handle is the FormSet that is being used.
1218
1219 @param Handle The Hii Handle.
1220
1221 @retval TRUE HII handle is being used.
1222 @retval FALSE HII handle is not being used.
1223
1224 **/
1225 BOOLEAN
1226 IsHiiHandleInBrowserContext (
1227 EFI_HII_HANDLE Handle
1228 );
1229
1230 /**
1231 Configure what scope the hot key will impact.
1232 All hot keys have the same scope. The mixed hot keys with the different level are not supported.
1233 If no scope is set, the default scope will be FormSet level.
1234 After all registered hot keys are removed, previous Scope can reset to another level.
1235
1236 @param[in] Scope Scope level to be set.
1237
1238 @retval EFI_SUCCESS Scope is set correctly.
1239 @retval EFI_INVALID_PARAMETER Scope is not the valid value specified in BROWSER_SETTING_SCOPE.
1240 @retval EFI_UNSPPORTED Scope level is different from current one that the registered hot keys have.
1241
1242 **/
1243 EFI_STATUS
1244 EFIAPI
1245 SetScope (
1246 IN BROWSER_SETTING_SCOPE Scope
1247 );
1248
1249 /**
1250 Register the hot key with its browser action, or unregistered the hot key.
1251 Only support hot key that is not printable character (control key, function key, etc.).
1252 If the action value is zero, the hot key will be unregistered if it has been registered.
1253 If the same hot key has been registered, the new action and help string will override the previous ones.
1254
1255 @param[in] KeyData A pointer to a buffer that describes the keystroke
1256 information for the hot key. Its type is EFI_INPUT_KEY to
1257 be supported by all ConsoleIn devices.
1258 @param[in] Action Action value that describes what action will be trigged when the hot key is pressed.
1259 @param[in] DefaultId Specifies the type of defaults to retrieve, which is only for DEFAULT action.
1260 @param[in] HelpString Help string that describes the hot key information.
1261 Its value may be NULL for the unregistered hot key.
1262
1263 @retval EFI_SUCCESS Hot key is registered or unregistered.
1264 @retval EFI_INVALID_PARAMETER KeyData is NULL.
1265 @retval EFI_NOT_FOUND KeyData is not found to be unregistered.
1266 @retval EFI_UNSUPPORTED Key represents a printable character. It is conflicted with Browser.
1267 **/
1268 EFI_STATUS
1269 EFIAPI
1270 RegisterHotKey (
1271 IN EFI_INPUT_KEY *KeyData,
1272 IN UINT32 Action,
1273 IN UINT16 DefaultId,
1274 IN EFI_STRING HelpString OPTIONAL
1275 );
1276
1277 /**
1278 Register Exit handler function.
1279 When more than one handler function is registered, the latter one will override the previous one.
1280 When NULL handler is specified, the previous Exit handler will be unregistered.
1281
1282 @param[in] Handler Pointer to handler function.
1283
1284 **/
1285 VOID
1286 EFIAPI
1287 RegiserExitHandler (
1288 IN EXIT_HANDLER Handler
1289 );
1290
1291 /**
1292
1293 Check whether the browser data has been modified.
1294
1295 @retval TRUE Browser data is changed.
1296 @retval FALSE No browser data is changed.
1297
1298 **/
1299 BOOLEAN
1300 EFIAPI
1301 IsBrowserDataModified (
1302 VOID
1303 );
1304
1305 /**
1306
1307 Execute the action requested by the Action parameter.
1308
1309 @param[in] Action Execute the request action.
1310 @param[in] DefaultId The default Id info when need to load default value.
1311
1312 @retval EFI_SUCCESS Execute the request action succss.
1313 @retval EFI_INVALID_PARAMETER The input action value is invalid.
1314
1315 **/
1316 EFI_STATUS
1317 EFIAPI
1318 ExecuteAction (
1319 IN UINT32 Action,
1320 IN UINT16 DefaultId
1321 );
1322
1323 /**
1324 Create reminder to let user to choose save or discard the changed browser data.
1325 Caller can use it to actively check the changed browser data.
1326
1327 @retval BROWSER_NO_CHANGES No browser data is changed.
1328 @retval BROWSER_SAVE_CHANGES The changed browser data is saved.
1329 @retval BROWSER_DISCARD_CHANGES The changed browser data is discard.
1330
1331 **/
1332 UINT32
1333 EFIAPI
1334 SaveReminder (
1335 VOID
1336 );
1337
1338 /**
1339 Find the registered HotKey based on KeyData.
1340
1341 @param[in] KeyData A pointer to a buffer that describes the keystroke
1342 information for the hot key.
1343
1344 @return The registered HotKey context. If no found, NULL will return.
1345 **/
1346 BROWSER_HOT_KEY *
1347 GetHotKeyFromRegisterList (
1348 IN EFI_INPUT_KEY *KeyData
1349 );
1350
1351 /**
1352
1353 Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
1354
1355 @param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.
1356
1357 @retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.
1358
1359 **/
1360 FORM_BROWSER_STATEMENT *
1361 GetBrowserStatement (
1362 IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement
1363 );
1364
1365 /**
1366 Password may be stored as encrypted by Configuration Driver. When change a
1367 password, user will be challenged with old password. To validate user input old
1368 password, we will send the clear text to Configuration Driver via Callback().
1369 Configuration driver is responsible to check the passed in password and return
1370 the validation result. If validation pass, state machine in password Callback()
1371 will transit from BROWSER_STATE_VALIDATE_PASSWORD to BROWSER_STATE_SET_PASSWORD.
1372 After user type in new password twice, Callback() will be invoked to send the
1373 new password to Configuration Driver.
1374
1375 @param Selection Pointer to UI_MENU_SELECTION.
1376 @param MenuOption The MenuOption for this password Question.
1377 @param String The clear text of password.
1378
1379 @retval EFI_NOT_AVAILABLE_YET Callback() request to terminate password input.
1380 @return In state of BROWSER_STATE_VALIDATE_PASSWORD:
1381 @retval EFI_SUCCESS Password correct, Browser will prompt for new
1382 password.
1383 @retval EFI_NOT_READY Password incorrect, Browser will show error
1384 message.
1385 @retval Other Browser will do nothing.
1386 @return In state of BROWSER_STATE_SET_PASSWORD:
1387 @retval EFI_SUCCESS Set password success.
1388 @retval Other Set password failed.
1389
1390 **/
1391 EFI_STATUS
1392 PasswordCallback (
1393 IN UI_MENU_SELECTION *Selection,
1394 IN FORM_BROWSER_STATEMENT *Question,
1395 IN CHAR16 *String
1396 );
1397
1398 /**
1399 Display error message for invalid password.
1400
1401 **/
1402 VOID
1403 PasswordInvalid (
1404 VOID
1405 );
1406
1407 /**
1408 The worker function that send the displays to the screen. On output,
1409 the selection made by user is returned.
1410
1411 @param Selection On input, Selection tell setup browser the information
1412 about the Selection, form and formset to be displayed.
1413 On output, Selection return the screen item that is selected
1414 by user.
1415
1416 @retval EFI_SUCCESS The page is displayed successfully.
1417 @return Other value if the page failed to be diplayed.
1418
1419 **/
1420 EFI_STATUS
1421 SetupBrowser (
1422 IN OUT UI_MENU_SELECTION *Selection
1423 );
1424
1425 /**
1426 Free up the resource allocated for all strings required
1427 by Setup Browser.
1428
1429 **/
1430 VOID
1431 FreeBrowserStrings (
1432 VOID
1433 );
1434
1435 /**
1436 Create a menu with specified formset GUID and form ID, and add it as a child
1437 of the given parent menu.
1438
1439 @param HiiHandle Hii handle related to this formset.
1440 @param FormSetGuid The Formset Guid of menu to be added.
1441 @param FormId The Form ID of menu to be added.
1442 @param QuestionId The question id of this menu to be added.
1443
1444 @return A pointer to the newly added menu or NULL if memory is insufficient.
1445
1446 **/
1447 FORM_ENTRY_INFO *
1448 UiAddMenuList (
1449 IN EFI_HII_HANDLE HiiHandle,
1450 IN EFI_GUID *FormSetGuid,
1451 IN UINT16 FormId,
1452 IN UINT16 QuestionId
1453 );
1454
1455 /**
1456 Search Menu with given FormSetGuid and FormId in all cached menu list.
1457
1458 @param HiiHandle HiiHandle for FormSet.
1459 @param FormSetGuid The Formset GUID of the menu to search.
1460 @param FormId The Form ID of menu to search.
1461
1462 @return A pointer to menu found or NULL if not found.
1463
1464 **/
1465 FORM_ENTRY_INFO *
1466 UiFindMenuList (
1467 IN EFI_HII_HANDLE HiiHandle,
1468 IN EFI_GUID *FormSetGuid,
1469 IN UINT16 FormId
1470 );
1471
1472 /**
1473 Free Menu list linked list.
1474
1475 @param MenuListHead One Menu list point in the menu list.
1476
1477 **/
1478 VOID
1479 UiFreeMenuList (
1480 LIST_ENTRY *MenuListHead
1481 );
1482
1483 /**
1484 Find parent menu for current menu.
1485
1486 @param CurrentMenu Current Menu
1487
1488 @retval The parent menu for current menu.
1489 **/
1490 FORM_ENTRY_INFO *
1491 UiFindParentMenu (
1492 IN FORM_ENTRY_INFO *CurrentMenu
1493 );
1494
1495 /**
1496 Search an Option of a Question by its value.
1497
1498 @param Question The Question
1499 @param OptionValue Value for Option to be searched.
1500
1501 @retval Pointer Pointer to the found Option.
1502 @retval NULL Option not found.
1503
1504 **/
1505 QUESTION_OPTION *
1506 ValueToOption (
1507 IN FORM_BROWSER_STATEMENT *Question,
1508 IN EFI_HII_VALUE *OptionValue
1509 );
1510 /**
1511 Return data element in an Array by its Index.
1512
1513 @param Array The data array.
1514 @param Type Type of the data in this array.
1515 @param Index Zero based index for data in this array.
1516
1517 @retval Value The data to be returned
1518
1519 **/
1520 UINT64
1521 GetArrayData (
1522 IN VOID *Array,
1523 IN UINT8 Type,
1524 IN UINTN Index
1525 );
1526
1527 /**
1528 Set value of a data element in an Array by its Index.
1529
1530 @param Array The data array.
1531 @param Type Type of the data in this array.
1532 @param Index Zero based index for data in this array.
1533 @param Value The value to be set.
1534
1535 **/
1536 VOID
1537 SetArrayData (
1538 IN VOID *Array,
1539 IN UINT8 Type,
1540 IN UINTN Index,
1541 IN UINT64 Value
1542 );
1543
1544 /**
1545 Compare two Hii value.
1546
1547 @param Value1 Expression value to compare on left-hand.
1548 @param Value2 Expression value to compare on right-hand.
1549 @param Result Return value after compare.
1550 retval 0 Two operators equal.
1551 return Positive value if Value1 is greater than Value2.
1552 retval Negative value if Value1 is less than Value2.
1553 @param HiiHandle Only required for string compare.
1554
1555 @retval other Could not perform compare on two values.
1556 @retval EFI_SUCCESS Compare the value success.
1557
1558 **/
1559 EFI_STATUS
1560 CompareHiiValue (
1561 IN EFI_HII_VALUE *Value1,
1562 IN EFI_HII_VALUE *Value2,
1563 OUT INTN *Result,
1564 IN EFI_HII_HANDLE HiiHandle OPTIONAL
1565 );
1566
1567 /**
1568 Perform Password check.
1569 Passwork may be encrypted by driver that requires the specific check.
1570
1571 @param Form Form where Password Statement is in.
1572 @param Statement Password statement
1573 @param PasswordString Password string to be checked. It may be NULL.
1574 NULL means to restore password.
1575 "" string can be used to checked whether old password does exist.
1576
1577 @return Status Status of Password check.
1578 **/
1579 EFI_STATUS
1580 EFIAPI
1581 PasswordCheck (
1582 IN FORM_DISPLAY_ENGINE_FORM *Form,
1583 IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,
1584 IN EFI_STRING PasswordString OPTIONAL
1585 );
1586
1587 /**
1588
1589 Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
1590
1591 @param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.
1592
1593 @retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.
1594
1595 **/
1596 FORM_BROWSER_STATEMENT *
1597 GetBrowserStatement (
1598 IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement
1599 );
1600
1601 /**
1602
1603 Initialize the Display form structure data.
1604
1605 **/
1606 VOID
1607 InitializeDisplayFormData (
1608 VOID
1609 );
1610
1611
1612 /**
1613 Base on the current formset info, clean the ConfigRequest string in browser storage.
1614
1615 @param FormSet Pointer of the FormSet
1616
1617 **/
1618 VOID
1619 CleanBrowserStorage (
1620 IN OUT FORM_BROWSER_FORMSET *FormSet
1621 );
1622
1623 /**
1624 Find HII Handle in the HII database associated with given Device Path.
1625
1626 If DevicePath is NULL, then ASSERT.
1627
1628 @param DevicePath Device Path associated with the HII package list
1629 handle.
1630 @param FormsetGuid The formset guid for this formset.
1631
1632 @retval Handle HII package list Handle associated with the Device
1633 Path.
1634 @retval NULL Hii Package list handle is not found.
1635
1636 **/
1637 EFI_HII_HANDLE
1638 DevicePathToHiiHandle (
1639 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
1640 IN EFI_GUID *FormsetGuid
1641 );
1642
1643 #endif