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