]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
Improve coding style in MdeModulePkg.
[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 - 2010, Intel Corporation
5 All rights reserved. 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/DevicePath.h>
26 #include <Protocol/UnicodeCollation.h>
27 #include <Protocol/HiiConfigAccess.h>
28 #include <Protocol/HiiConfigRouting.h>
29 #include <Protocol/HiiDatabase.h>
30 #include <Protocol/HiiString.h>
31 #include <Protocol/UserManager.h>
32
33 #include <Guid/MdeModuleHii.h>
34 #include <Guid/HiiPlatformSetupFormset.h>
35
36 #include <Library/PrintLib.h>
37 #include <Library/DebugLib.h>
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/UefiRuntimeServicesTableLib.h>
40 #include <Library/UefiDriverEntryPoint.h>
41 #include <Library/UefiBootServicesTableLib.h>
42 #include <Library/BaseLib.h>
43 #include <Library/MemoryAllocationLib.h>
44 #include <Library/HiiLib.h>
45 #include <Library/PcdLib.h>
46 #include <Library/DevicePathLib.h>
47
48 #include "Colors.h"
49
50 //
51 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
52 //
53
54 extern UINT8 SetupBrowserStrings[];
55
56 //
57 // Screen definitions
58 //
59 #define BANNER_HEIGHT 6
60 #define BANNER_COLUMNS 3
61
62 #define FRONT_PAGE_HEADER_HEIGHT 6
63 #define NONE_FRONT_PAGE_HEADER_HEIGHT 3
64 #define LEFT_SKIPPED_COLUMNS 4
65 #define FOOTER_HEIGHT 4
66 #define STATUS_BAR_HEIGHT 1
67 #define SCROLL_ARROW_HEIGHT 1
68 #define POPUP_PAD_SPACE_COUNT 5
69 #define POPUP_FRAME_WIDTH 2
70
71 //
72 // Definition for function key setting
73 //
74 #define NONE_FUNCTION_KEY_SETTING 0
75 #define DEFAULT_FUNCTION_KEY_SETTING (FUNCTION_NINE | FUNCTION_TEN)
76
77 #define FUNCTION_NINE (1 << 2)
78 #define FUNCTION_TEN (1 << 3)
79
80 typedef struct {
81 EFI_GUID FormSetGuid;
82 UINTN KeySetting;
83 } FUNCTIION_KEY_SETTING;
84
85 //
86 // Character definitions
87 //
88 #define CHAR_SPACE 0x0020
89 #define UPPER_LOWER_CASE_OFFSET 0x20
90
91 //
92 // Time definitions
93 //
94 #define ONE_SECOND 10000000
95
96 //
97 // Display definitions
98 //
99 #define LEFT_HYPER_DELIMITER L'<'
100 #define RIGHT_HYPER_DELIMITER L'>'
101
102 #define LEFT_ONEOF_DELIMITER L'<'
103 #define RIGHT_ONEOF_DELIMITER L'>'
104
105 #define LEFT_NUMERIC_DELIMITER L'['
106 #define RIGHT_NUMERIC_DELIMITER L']'
107
108 #define LEFT_CHECKBOX_DELIMITER L'['
109 #define RIGHT_CHECKBOX_DELIMITER L']'
110
111 #define CHECK_ON L'X'
112 #define CHECK_OFF L' '
113
114 #define TIME_SEPARATOR L':'
115 #define DATE_SEPARATOR L'/'
116
117 #define YES_ANSWER L'Y'
118 #define NO_ANSWER L'N'
119
120 //
121 // This is the Input Error Message
122 //
123 #define INPUT_ERROR 1
124
125 //
126 // This is the NV RAM update required Message
127 //
128 #define NV_UPDATE_REQUIRED 2
129
130 //
131 // Refresh the Status Bar with flags
132 //
133 #define REFRESH_STATUS_BAR 0xff
134
135 //
136 // Incremental string lenght of ConfigRequest
137 //
138 #define CONFIG_REQUEST_STRING_INCREMENTAL 1024
139
140 //
141 // HII value compare result
142 //
143 #define HII_VALUE_UNDEFINED 0
144 #define HII_VALUE_EQUAL 1
145 #define HII_VALUE_LESS_THAN 2
146 #define HII_VALUE_GREATER_THAN 3
147
148 //
149 // Incremental size of stack for expression
150 //
151 #define EXPRESSION_STACK_SIZE_INCREMENT 0x100
152
153
154 #define EFI_SPECIFICATION_ERRATA_VERSION 0
155
156 #define EFI_IFR_SPECIFICATION_VERSION \
157 ((((EFI_SPECIFICATION_VERSION) >> 8) & 0xff00) | \
158 (((EFI_SPECIFICATION_VERSION) & 0xf) << 4) | \
159 ((EFI_SPECIFICATION_ERRATA_VERSION) & 0xf))
160
161 #define SETUP_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'B', 'D', 'V')
162 typedef struct {
163 UINT32 Signature;
164
165 EFI_HANDLE Handle;
166
167 //
168 // Produced protocol
169 //
170 EFI_FORM_BROWSER2_PROTOCOL FormBrowser2;
171
172 } SETUP_DRIVER_PRIVATE_DATA;
173
174 typedef struct {
175 EFI_STRING_ID Banner[BANNER_HEIGHT][BANNER_COLUMNS];
176 } BANNER_DATA;
177
178 //
179 // IFR relative definition
180 //
181 #define EFI_HII_EXPRESSION_INCONSISTENT_IF 0
182 #define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1
183 #define EFI_HII_EXPRESSION_GRAY_OUT_IF 2
184 #define EFI_HII_EXPRESSION_SUPPRESS_IF 3
185 #define EFI_HII_EXPRESSION_DISABLE_IF 4
186 #define EFI_HII_EXPRESSION_VALUE 5
187 #define EFI_HII_EXPRESSION_RULE 6
188
189 #define EFI_HII_VARSTORE_BUFFER 0
190 #define EFI_HII_VARSTORE_NAME_VALUE 1
191 #define EFI_HII_VARSTORE_EFI_VARIABLE 2
192
193 #define FORM_INCONSISTENT_VALIDATION 0
194 #define FORM_NO_SUBMIT_VALIDATION 1
195
196 #define FORMSET_CLASS_PLATFORM_SETUP 0x0001
197 #define FORMSET_CLASS_FRONT_PAGE 0x0002
198
199 typedef struct {
200 UINT8 Type;
201 EFI_IFR_TYPE_VALUE Value;
202 } EFI_HII_VALUE;
203
204 #define NAME_VALUE_NODE_SIGNATURE SIGNATURE_32 ('N', 'V', 'S', 'T')
205
206 typedef struct {
207 UINTN Signature;
208 LIST_ENTRY Link;
209 CHAR16 *Name;
210 CHAR16 *Value;
211 CHAR16 *EditValue;
212 } NAME_VALUE_NODE;
213
214 #define NAME_VALUE_NODE_FROM_LINK(a) CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)
215
216 #define FORMSET_STORAGE_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'G')
217
218 typedef struct {
219 UINTN Signature;
220 LIST_ENTRY Link;
221
222 UINT8 Type; // Storage type
223
224 UINT16 VarStoreId;
225 EFI_GUID Guid;
226
227 CHAR16 *Name; // For EFI_IFR_VARSTORE
228 UINT16 Size;
229 UINT8 *Buffer;
230 UINT8 *EditBuffer; // Edit copy for Buffer Storage
231
232 LIST_ENTRY NameValueListHead; // List of NAME_VALUE_NODE
233
234 UINT32 Attributes; // For EFI_IFR_VARSTORE_EFI: EFI Variable attribute
235
236 CHAR16 *ConfigHdr; // <ConfigHdr>
237 CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
238 UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
239 UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
240 } FORMSET_STORAGE;
241
242 #define FORMSET_STORAGE_FROM_LINK(a) CR (a, FORMSET_STORAGE, Link, FORMSET_STORAGE_SIGNATURE)
243
244 #define EXPRESSION_OPCODE_SIGNATURE SIGNATURE_32 ('E', 'X', 'O', 'P')
245
246 typedef struct {
247 UINTN Signature;
248 LIST_ENTRY Link;
249
250 UINT8 Operand;
251
252 UINT8 Format; // For EFI_IFR_TO_STRING, EFI_IFR_FIND
253 UINT8 Flags; // For EFI_IFR_SPAN
254 UINT8 RuleId; // For EFI_IFR_RULE_REF
255
256 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
257
258 EFI_QUESTION_ID QuestionId; // For EFI_IFR_EQ_ID_ID, EFI_IFR_EQ_ID_VAL_LIST, EFI_IFR_QUESTION_REF1
259 EFI_QUESTION_ID QuestionId2;
260
261 UINT16 ListLength; // For EFI_IFR_EQ_ID_VAL_LIST
262 UINT16 *ValueList;
263
264 EFI_STRING_ID DevicePath; // For EFI_IFR_QUESTION_REF3_2, EFI_IFR_QUESTION_REF3_3
265 EFI_GUID Guid;
266 } EXPRESSION_OPCODE;
267
268 #define EXPRESSION_OPCODE_FROM_LINK(a) CR (a, EXPRESSION_OPCODE, Link, EXPRESSION_OPCODE_SIGNATURE)
269
270 #define FORM_EXPRESSION_SIGNATURE SIGNATURE_32 ('F', 'E', 'X', 'P')
271
272 typedef struct {
273 UINTN Signature;
274 LIST_ENTRY Link;
275
276 UINT8 Type; // Type for this expression
277
278 UINT8 RuleId; // For EFI_IFR_RULE only
279 EFI_STRING_ID Error; // For EFI_IFR_NO_SUBMIT_IF, EFI_IFR_INCONSISTENT_IF only
280
281 EFI_HII_VALUE Result; // Expression evaluation result
282
283 LIST_ENTRY OpCodeListHead; // OpCodes consist of this expression (EXPRESSION_OPCODE)
284 } FORM_EXPRESSION;
285
286 #define FORM_EXPRESSION_FROM_LINK(a) CR (a, FORM_EXPRESSION, Link, FORM_EXPRESSION_SIGNATURE)
287
288 #define QUESTION_DEFAULT_SIGNATURE SIGNATURE_32 ('Q', 'D', 'F', 'T')
289
290 typedef struct {
291 UINTN Signature;
292 LIST_ENTRY Link;
293
294 UINT16 DefaultId;
295 EFI_HII_VALUE Value; // Default value
296
297 FORM_EXPRESSION *ValueExpression; // Not-NULL indicates default value is provided by EFI_IFR_VALUE
298 } QUESTION_DEFAULT;
299
300 #define QUESTION_DEFAULT_FROM_LINK(a) CR (a, QUESTION_DEFAULT, Link, QUESTION_DEFAULT_SIGNATURE)
301
302 #define QUESTION_OPTION_SIGNATURE SIGNATURE_32 ('Q', 'O', 'P', 'T')
303
304 typedef struct {
305 UINTN Signature;
306 LIST_ENTRY Link;
307
308 EFI_STRING_ID Text;
309 UINT8 Flags;
310 EFI_HII_VALUE Value;
311 EFI_IMAGE_ID ImageId;
312
313 FORM_EXPRESSION *SuppressExpression; // Non-NULL indicates nested inside of SuppressIf
314 } QUESTION_OPTION;
315
316 #define QUESTION_OPTION_FROM_LINK(a) CR (a, QUESTION_OPTION, Link, QUESTION_OPTION_SIGNATURE)
317
318 #define FORM_BROWSER_STATEMENT_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'A')
319
320 typedef union {
321 EFI_STRING_ID VarName;
322 UINT16 VarOffset;
323 } VAR_STORE_INFO;
324
325 typedef struct {
326 UINTN Signature;
327 LIST_ENTRY Link;
328
329 UINT8 Operand; // The operand (first byte) of this Statement or Question
330
331 //
332 // Statement Header
333 //
334 EFI_STRING_ID Prompt;
335 EFI_STRING_ID Help;
336 EFI_STRING_ID TextTwo; // For EFI_IFR_TEXT
337
338 //
339 // Question Header
340 //
341 EFI_QUESTION_ID QuestionId; // The value of zero is reserved
342 EFI_VARSTORE_ID VarStoreId; // A value of zero indicates no variable storage
343 FORMSET_STORAGE *Storage;
344 VAR_STORE_INFO VarStoreInfo;
345 UINT16 StorageWidth;
346 UINT8 QuestionFlags;
347 CHAR16 *VariableName; // Name/Value or EFI Variable name
348 CHAR16 *BlockName; // Buffer storage block name: "OFFSET=...WIDTH=..."
349
350 EFI_HII_VALUE HiiValue; // Edit copy for checkbox, numberic, oneof
351 UINT8 *BufferValue; // Edit copy for string, password, orderedlist
352 UINT8 ValueType; // Data type for orderedlist value array
353
354 //
355 // OpCode specific members
356 //
357 UINT8 Flags; // for EFI_IFR_CHECKBOX, EFI_IFR_DATE, EFI_IFR_NUMERIC, EFI_IFR_ONE_OF,
358 // EFI_IFR_ORDERED_LIST, EFI_IFR_STRING,EFI_IFR_SUBTITLE,EFI_IFR_TIME, EFI_IFR_BANNER
359 UINT8 MaxContainers; // for EFI_IFR_ORDERED_LIST
360
361 UINT16 BannerLineNumber; // for EFI_IFR_BANNER, 1-based line number
362 EFI_STRING_ID QuestionConfig; // for EFI_IFR_ACTION, if 0 then no configuration string will be processed
363
364 UINT64 Minimum; // for EFI_IFR_ONE_OF/EFI_IFR_NUMERIC, it's Min/Max value
365 UINT64 Maximum; // for EFI_IFR_STRING/EFI_IFR_PASSWORD, it's Min/Max length
366 UINT64 Step;
367
368 EFI_DEFAULT_ID DefaultId; // for EFI_IFR_RESET_BUTTON
369 EFI_FORM_ID RefFormId; // for EFI_IFR_REF
370 EFI_QUESTION_ID RefQuestionId; // for EFI_IFR_REF2
371 EFI_GUID RefFormSetId; // for EFI_IFR_REF3
372 EFI_STRING_ID RefDevicePath; // for EFI_IFR_REF4
373
374 //
375 // Get from IFR parsing
376 //
377 FORM_EXPRESSION *ValueExpression; // nested EFI_IFR_VALUE, provide Question value and indicate Question is ReadOnly
378 LIST_ENTRY DefaultListHead; // nested EFI_IFR_DEFAULT list (QUESTION_DEFAULT), provide default values
379 LIST_ENTRY OptionListHead; // nested EFI_IFR_ONE_OF_OPTION list (QUESTION_OPTION)
380
381 EFI_IMAGE_ID ImageId; // nested EFI_IFR_IMAGE
382 UINT8 RefreshInterval; // nested EFI_IFR_REFRESH, refresh interval(in seconds) for Question value, 0 means no refresh
383 BOOLEAN InSubtitle; // nesting inside of EFI_IFR_SUBTITLE
384
385 LIST_ENTRY InconsistentListHead;// nested inconsistent expression list (FORM_EXPRESSION)
386 LIST_ENTRY NoSubmitListHead; // nested nosubmit expression list (FORM_EXPRESSION)
387 FORM_EXPRESSION *GrayOutExpression; // nesting inside of GrayOutIf
388 FORM_EXPRESSION *SuppressExpression; // nesting inside of SuppressIf
389 FORM_EXPRESSION *DisableExpression; // nesting inside of DisableIf
390
391 } FORM_BROWSER_STATEMENT;
392
393 #define FORM_BROWSER_STATEMENT_FROM_LINK(a) CR (a, FORM_BROWSER_STATEMENT, Link, FORM_BROWSER_STATEMENT_SIGNATURE)
394
395 #define FORM_BROWSER_FORM_SIGNATURE SIGNATURE_32 ('F', 'F', 'R', 'M')
396
397 typedef struct {
398 UINTN Signature;
399 LIST_ENTRY Link;
400
401 UINT16 FormId;
402 EFI_STRING_ID FormTitle;
403
404 EFI_IMAGE_ID ImageId;
405
406 LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
407 LIST_ENTRY StatementListHead; // List of Statements and Questions (FORM_BROWSER_STATEMENT)
408 FORM_EXPRESSION *SuppressExpression; // nesting inside of SuppressIf
409 } FORM_BROWSER_FORM;
410
411 #define FORM_BROWSER_FORM_FROM_LINK(a) CR (a, FORM_BROWSER_FORM, Link, FORM_BROWSER_FORM_SIGNATURE)
412
413 #define FORMSET_DEFAULTSTORE_SIGNATURE SIGNATURE_32 ('F', 'D', 'F', 'S')
414
415 typedef struct {
416 UINTN Signature;
417 LIST_ENTRY Link;
418
419 UINT16 DefaultId;
420 EFI_STRING_ID DefaultName;
421 } FORMSET_DEFAULTSTORE;
422
423 #define FORMSET_DEFAULTSTORE_FROM_LINK(a) CR (a, FORMSET_DEFAULTSTORE, Link, FORMSET_DEFAULTSTORE_SIGNATURE)
424
425 typedef struct {
426 EFI_HII_HANDLE HiiHandle;
427 EFI_HANDLE DriverHandle;
428 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
429 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
430
431 UINTN IfrBinaryLength;
432 UINT8 *IfrBinaryData;
433
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 StorageListHead; // Storage list (FORMSET_STORAGE)
447 LIST_ENTRY DefaultStoreListHead; // DefaultStore list (FORMSET_DEFAULTSTORE)
448 LIST_ENTRY FormListHead; // Form list (FORM_BROWSER_FORM)
449 LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
450 } FORM_BROWSER_FORMSET;
451
452 #define BROWSER_CONTEXT_SIGNATURE SIGNATURE_32 ('B', 'C', 'T', 'X')
453
454 typedef struct {
455 UINTN Signature;
456 LIST_ENTRY Link;
457
458 //
459 // Globals defined in Setup.c
460 //
461 BANNER_DATA *BannerData;
462 UINTN ClassOfVfr;
463 UINTN FunctionKeySetting;
464 BOOLEAN ResetRequired;
465 BOOLEAN NvUpdateRequired;
466 UINT16 Direction;
467 EFI_SCREEN_DESCRIPTOR ScreenDimensions;
468 CHAR16 *FunctionNineString;
469 CHAR16 *FunctionTenString;
470 CHAR16 *EnterString;
471 CHAR16 *EnterCommitString;
472 CHAR16 *EnterEscapeString;
473 CHAR16 *EscapeString;
474 CHAR16 *SaveFailed;
475 CHAR16 *MoveHighlight;
476 CHAR16 *MakeSelection;
477 CHAR16 *DecNumericInput;
478 CHAR16 *HexNumericInput;
479 CHAR16 *ToggleCheckBox;
480 CHAR16 *PromptForData;
481 CHAR16 *PromptForPassword;
482 CHAR16 *PromptForNewPassword;
483 CHAR16 *ConfirmPassword;
484 CHAR16 *ConfirmError;
485 CHAR16 *PassowordInvalid;
486 CHAR16 *PressEnter;
487 CHAR16 *EmptyString;
488 CHAR16 *AreYouSure;
489 CHAR16 *YesResponse;
490 CHAR16 *NoResponse;
491 CHAR16 *MiniString;
492 CHAR16 *PlusString;
493 CHAR16 *MinusString;
494 CHAR16 *AdjustNumber;
495 CHAR16 *SaveChanges;
496 CHAR16 *OptionMismatch;
497 CHAR16 *FormSuppress;
498 CHAR16 PromptBlockWidth;
499 CHAR16 OptionBlockWidth;
500 CHAR16 HelpBlockWidth;
501 FORM_BROWSER_FORMSET *OldFormSet;
502
503 //
504 // Globals defined in Ui.c
505 //
506 LIST_ENTRY MenuOption;
507 VOID *MenuRefreshHead;
508 } BROWSER_CONTEXT;
509
510 #define BROWSER_CONTEXT_FROM_LINK(a) CR (a, BROWSER_CONTEXT, Link, BROWSER_CONTEXT_SIGNATURE)
511
512 extern EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
513 extern EFI_HII_STRING_PROTOCOL *mHiiString;
514 extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting;
515
516 extern BANNER_DATA *gBannerData;
517 extern EFI_HII_HANDLE gFrontPageHandle;
518 extern UINTN gClassOfVfr;
519 extern UINTN gFunctionKeySetting;
520 extern BOOLEAN gResetRequired;
521 extern BOOLEAN gNvUpdateRequired;
522 extern EFI_HII_HANDLE gHiiHandle;
523 extern UINT16 gDirection;
524 extern EFI_SCREEN_DESCRIPTOR gScreenDimensions;
525
526 extern FORM_BROWSER_FORMSET *gOldFormSet;
527
528 //
529 // Browser Global Strings
530 //
531 extern CHAR16 *gFunctionNineString;
532 extern CHAR16 *gFunctionTenString;
533 extern CHAR16 *gEnterString;
534 extern CHAR16 *gEnterCommitString;
535 extern CHAR16 *gEnterEscapeString;
536 extern CHAR16 *gEscapeString;
537 extern CHAR16 *gSaveFailed;
538 extern CHAR16 *gMoveHighlight;
539 extern CHAR16 *gMakeSelection;
540 extern CHAR16 *gDecNumericInput;
541 extern CHAR16 *gHexNumericInput;
542 extern CHAR16 *gToggleCheckBox;
543 extern CHAR16 *gPromptForData;
544 extern CHAR16 *gPromptForPassword;
545 extern CHAR16 *gPromptForNewPassword;
546 extern CHAR16 *gConfirmPassword;
547 extern CHAR16 *gConfirmError;
548 extern CHAR16 *gPassowordInvalid;
549 extern CHAR16 *gPressEnter;
550 extern CHAR16 *gEmptyString;
551 extern CHAR16 *gAreYouSure;
552 extern CHAR16 *gYesResponse;
553 extern CHAR16 *gNoResponse;
554 extern CHAR16 *gMiniString;
555 extern CHAR16 *gPlusString;
556 extern CHAR16 *gMinusString;
557 extern CHAR16 *gAdjustNumber;
558 extern CHAR16 *gSaveChanges;
559 extern CHAR16 *gOptionMismatch;
560 extern CHAR16 *gFormSuppress;
561
562 extern CHAR16 gPromptBlockWidth;
563 extern CHAR16 gOptionBlockWidth;
564 extern CHAR16 gHelpBlockWidth;
565
566 extern EFI_GUID gZeroGuid;
567 extern EFI_GUID gTianoHiiIfrGuid;
568
569 #include "Ui.h"
570 //
571 // Global Procedure Defines
572 //
573
574 /**
575 Initialize the HII String Token to the correct values.
576
577 **/
578 VOID
579 InitializeBrowserStrings (
580 VOID
581 );
582
583 /**
584 Prints a unicode string to the default console,
585 using L"%s" format.
586
587 @param String String pointer.
588
589 @return Length of string printed to the console
590
591 **/
592 UINTN
593 PrintString (
594 IN CHAR16 *String
595 );
596
597 /**
598 Prints a chracter to the default console,
599 using L"%c" format.
600
601 @param Character Character to print.
602
603 @return Length of string printed to the console.
604
605 **/
606 UINTN
607 PrintChar (
608 CHAR16 Character
609 );
610
611 /**
612 Prints a formatted unicode string to the default console, at
613 the supplied cursor position.
614
615 @param Column The cursor position to print the string at.
616 @param Row The cursor position to print the string at
617 @param Fmt Format string
618 @param ... Variable argument list for formating string.
619
620 @return Length of string printed to the console
621
622 **/
623 UINTN
624 PrintAt (
625 IN UINTN Column,
626 IN UINTN Row,
627 IN CHAR16 *Fmt,
628 ...
629 );
630
631 /**
632 Prints a unicode string to the default console, at
633 the supplied cursor position, using L"%s" format.
634
635 @param Column The cursor position to print the string at.
636 @param Row The cursor position to print the string at
637 @param String String pointer.
638
639 @return Length of string printed to the console
640
641 **/
642 UINTN
643 PrintStringAt (
644 IN UINTN Column,
645 IN UINTN Row,
646 IN CHAR16 *String
647 );
648
649 /**
650 Prints a chracter to the default console, at
651 the supplied cursor position, using L"%c" format.
652
653 @param Column The cursor position to print the string at.
654 @param Row The cursor position to print the string at.
655 @param Character Character to print.
656
657 @return Length of string printed to the console.
658
659 **/
660 UINTN
661 PrintCharAt (
662 IN UINTN Column,
663 IN UINTN Row,
664 CHAR16 Character
665 );
666
667 /**
668 Parse opcodes in the formset IFR binary.
669
670 @param FormSet Pointer of the FormSet data structure.
671
672 @retval EFI_SUCCESS Opcode parse success.
673 @retval Other Opcode parse fail.
674
675 **/
676 EFI_STATUS
677 ParseOpCodes (
678 IN FORM_BROWSER_FORMSET *FormSet
679 );
680
681 /**
682 Free resources allocated for a FormSet.
683
684 @param FormSet Pointer of the FormSet
685
686 **/
687 VOID
688 DestroyFormSet (
689 IN OUT FORM_BROWSER_FORMSET *FormSet
690 );
691
692 /**
693 This function displays the page frame.
694
695 **/
696 VOID
697 DisplayPageFrame (
698 VOID
699 );
700
701 /**
702 Create a new string in HII Package List.
703
704 @param String The String to be added
705 @param HiiHandle The package list in the HII database to insert the
706 specified string.
707
708 @return The output string.
709
710 **/
711 EFI_STRING_ID
712 NewString (
713 IN CHAR16 *String,
714 IN EFI_HII_HANDLE HiiHandle
715 );
716
717 /**
718 Delete a string from HII Package List.
719
720 @param StringId Id of the string in HII database.
721 @param HiiHandle The HII package list handle.
722
723 @retval EFI_SUCCESS The string was deleted successfully.
724
725 **/
726 EFI_STATUS
727 DeleteString (
728 IN EFI_STRING_ID StringId,
729 IN EFI_HII_HANDLE HiiHandle
730 );
731
732 /**
733 Get the string based on the StringId and HII Package List Handle.
734
735 @param Token The String's ID.
736 @param HiiHandle The package list in the HII database to search for
737 the specified string.
738
739 @return The output string.
740
741 **/
742 CHAR16 *
743 GetToken (
744 IN EFI_STRING_ID Token,
745 IN EFI_HII_HANDLE HiiHandle
746 );
747
748 /**
749 Draw a pop up windows based on the dimension, number of lines and
750 strings specified.
751
752 @param RequestedWidth The width of the pop-up.
753 @param NumberOfLines The number of lines.
754 @param Marker The variable argument list for the list of string to be printed.
755
756 **/
757 VOID
758 CreateSharedPopUp (
759 IN UINTN RequestedWidth,
760 IN UINTN NumberOfLines,
761 IN VA_LIST Marker
762 );
763
764 /**
765 Routine used to abstract a generic dialog interface and return the selected key or string
766
767 @param NumberOfLines The number of lines for the dialog box
768 @param HotKey Defines whether a single character is parsed
769 (TRUE) and returned in KeyValue or a string is
770 returned in StringBuffer. Two special characters
771 are considered when entering a string, a SCAN_ESC
772 and an CHAR_CARRIAGE_RETURN. SCAN_ESC terminates
773 string input and returns
774 @param MaximumStringSize The maximum size in bytes of a typed in string
775 (each character is a CHAR16) and the minimum
776 string returned is two bytes
777 @param StringBuffer The passed in pointer to the buffer which will
778 hold the typed in string if HotKey is FALSE
779 @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
780 @param ... A series of (quantity == NumberOfLines) text
781 strings which will be used to construct the dialog
782 box
783
784 @retval EFI_SUCCESS Displayed dialog and received user interaction
785 @retval EFI_INVALID_PARAMETER One of the parameters was invalid (e.g.
786 (StringBuffer == NULL) && (HotKey == FALSE))
787 @retval EFI_DEVICE_ERROR User typed in an ESC character to exit the routine
788
789 **/
790 EFI_STATUS
791 CreateDialog (
792 IN UINTN NumberOfLines,
793 IN BOOLEAN HotKey,
794 IN UINTN MaximumStringSize,
795 OUT CHAR16 *StringBuffer,
796 OUT EFI_INPUT_KEY *KeyValue,
797 ...
798 );
799
800 /**
801 Get Question's current Value.
802
803 @param FormSet FormSet data structure.
804 @param Form Form data structure.
805 @param Question Question to be initialized.
806 @param Cached TRUE: get from Edit copy FALSE: get from original
807 Storage
808
809 @retval EFI_SUCCESS The function completed successfully.
810
811 **/
812 EFI_STATUS
813 GetQuestionValue (
814 IN FORM_BROWSER_FORMSET *FormSet,
815 IN FORM_BROWSER_FORM *Form,
816 IN OUT FORM_BROWSER_STATEMENT *Question,
817 IN BOOLEAN Cached
818 );
819
820 /**
821 Save Question Value to edit copy(cached) or Storage(uncached).
822
823 @param FormSet FormSet data structure.
824 @param Form Form data structure.
825 @param Question Pointer to the Question.
826 @param Cached TRUE: set to Edit copy FALSE: set to original
827 Storage
828
829 @retval EFI_SUCCESS The function completed successfully.
830
831 **/
832 EFI_STATUS
833 SetQuestionValue (
834 IN FORM_BROWSER_FORMSET *FormSet,
835 IN FORM_BROWSER_FORM *Form,
836 IN OUT FORM_BROWSER_STATEMENT *Question,
837 IN BOOLEAN Cached
838 );
839
840 /**
841 Perform inconsistent check for a Form.
842
843 @param FormSet FormSet data structure.
844 @param Form Form data structure.
845 @param Question The Question to be validated.
846 @param Type Validation type: InConsistent or NoSubmit
847
848 @retval EFI_SUCCESS Form validation pass.
849 @retval other Form validation failed.
850
851 **/
852 EFI_STATUS
853 ValidateQuestion (
854 IN FORM_BROWSER_FORMSET *FormSet,
855 IN FORM_BROWSER_FORM *Form,
856 IN FORM_BROWSER_STATEMENT *Question,
857 IN UINTN Type
858 );
859
860 /**
861 Submit a Form.
862
863 @param FormSet FormSet data structure.
864 @param Form Form data structure.
865
866 @retval EFI_SUCCESS The function completed successfully.
867
868 **/
869 EFI_STATUS
870 SubmitForm (
871 IN FORM_BROWSER_FORMSET *FormSet,
872 IN FORM_BROWSER_FORM *Form
873 );
874
875 /**
876 Reset Question to its default value.
877
878 @param FormSet The form set.
879 @param Form The form.
880 @param Question The question.
881 @param DefaultId The Class of the default.
882
883 @retval EFI_SUCCESS Question is reset to default value.
884
885 **/
886 EFI_STATUS
887 GetQuestionDefault (
888 IN FORM_BROWSER_FORMSET *FormSet,
889 IN FORM_BROWSER_FORM *Form,
890 IN FORM_BROWSER_STATEMENT *Question,
891 IN UINT16 DefaultId
892 );
893
894 /**
895 Get current setting of Questions.
896
897 @param FormSet FormSet data structure.
898
899 @retval EFI_SUCCESS The function completed successfully.
900
901 **/
902 EFI_STATUS
903 InitializeCurrentSetting (
904 IN OUT FORM_BROWSER_FORMSET *FormSet
905 );
906
907 /**
908 Initialize the internal data structure of a FormSet.
909
910 @param Handle PackageList Handle
911 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
912 GUID), take the first FormSet found in package
913 list.
914 @param FormSet FormSet data structure.
915
916 @retval EFI_SUCCESS The function completed successfully.
917 @retval EFI_NOT_FOUND The specified FormSet could not be found.
918
919 **/
920 EFI_STATUS
921 InitializeFormSet (
922 IN EFI_HII_HANDLE Handle,
923 IN OUT EFI_GUID *FormSetGuid,
924 OUT FORM_BROWSER_FORMSET *FormSet
925 );
926
927 /**
928 Reset Questions in a Form to their default value.
929
930 @param FormSet FormSet data structure.
931 @param Form The Form which to be reset.
932 @param DefaultId The Class of the default.
933
934 @retval EFI_SUCCESS The function completed successfully.
935
936 **/
937 EFI_STATUS
938 ExtractFormDefault (
939 IN FORM_BROWSER_FORMSET *FormSet,
940 IN FORM_BROWSER_FORM *Form,
941 IN UINT16 DefaultId
942 );
943
944 /**
945 Initialize Question's Edit copy from Storage.
946
947 @param Selection Selection contains the information about
948 the Selection, form and formset to be displayed.
949 Selection action may be updated in retrieve callback.
950 @param FormSet FormSet data structure.
951 @param Form Form data structure.
952
953 @retval EFI_SUCCESS The function completed successfully.
954
955 **/
956 EFI_STATUS
957 LoadFormConfig (
958 IN OUT UI_MENU_SELECTION *Selection,
959 IN FORM_BROWSER_FORMSET *FormSet,
960 IN FORM_BROWSER_FORM *Form
961 );
962
963 /**
964 Initialize Question's Edit copy from Storage for the whole Formset.
965
966 @param Selection Selection contains the information about
967 the Selection, form and formset to be displayed.
968 Selection action may be updated in retrieve callback.
969 @param FormSet FormSet data structure.
970
971 @retval EFI_SUCCESS The function completed successfully.
972
973 **/
974 EFI_STATUS
975 LoadFormSetConfig (
976 IN OUT UI_MENU_SELECTION *Selection,
977 IN FORM_BROWSER_FORMSET *FormSet
978 );
979
980 /**
981 Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
982
983 @param Storage The Storage to be conveted.
984 @param ConfigResp The returned <ConfigResp>.
985
986 @retval EFI_SUCCESS Convert success.
987 @retval EFI_INVALID_PARAMETER Incorrect storage type.
988
989 **/
990 EFI_STATUS
991 StorageToConfigResp (
992 IN FORMSET_STORAGE *Storage,
993 IN CHAR16 **ConfigResp
994 );
995
996 /**
997 Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.
998
999 @param Storage The Storage to receive the settings.
1000 @param ConfigResp The <ConfigResp> to be converted.
1001
1002 @retval EFI_SUCCESS Convert success.
1003 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1004
1005 **/
1006 EFI_STATUS
1007 ConfigRespToStorage (
1008 IN FORMSET_STORAGE *Storage,
1009 IN CHAR16 *ConfigResp
1010 );
1011
1012 /**
1013 Fill storage's edit copy with settings requested from Configuration Driver.
1014
1015 @param FormSet FormSet data structure.
1016 @param Storage Buffer Storage.
1017
1018 @retval EFI_SUCCESS The function completed successfully.
1019
1020 **/
1021 EFI_STATUS
1022 LoadStorage (
1023 IN FORM_BROWSER_FORMSET *FormSet,
1024 IN FORMSET_STORAGE *Storage
1025 );
1026
1027 /**
1028 Fetch the Ifr binary data of a FormSet.
1029
1030 @param Handle PackageList Handle
1031 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
1032 GUID), take the first FormSet found in package
1033 list.
1034 @param BinaryLength The length of the FormSet IFR binary.
1035 @param BinaryData The buffer designed to receive the FormSet.
1036
1037 @retval EFI_SUCCESS Buffer filled with the requested FormSet.
1038 BufferLength was updated.
1039 @retval EFI_INVALID_PARAMETER The handle is unknown.
1040 @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
1041 be found with the requested FormId.
1042
1043 **/
1044 EFI_STATUS
1045 GetIfrBinaryData (
1046 IN EFI_HII_HANDLE Handle,
1047 IN OUT EFI_GUID *FormSetGuid,
1048 OUT UINTN *BinaryLength,
1049 OUT UINT8 **BinaryData
1050 );
1051
1052 /**
1053 Save globals used by previous call to SendForm(). SendForm() may be called from
1054 HiiConfigAccess.Callback(), this will cause SendForm() be reentried.
1055 So, save globals of previous call to SendForm() and restore them upon exit.
1056
1057 **/
1058 VOID
1059 SaveBrowserContext (
1060 VOID
1061 );
1062
1063 /**
1064 Restore globals used by previous call to SendForm().
1065
1066 **/
1067 VOID
1068 RestoreBrowserContext (
1069 VOID
1070 );
1071
1072 /**
1073 This is the routine which an external caller uses to direct the browser
1074 where to obtain it's information.
1075
1076
1077 @param This The Form Browser protocol instanse.
1078 @param Handles A pointer to an array of Handles. If HandleCount > 1 we
1079 display a list of the formsets for the handles specified.
1080 @param HandleCount The number of Handles specified in Handle.
1081 @param FormSetGuid This field points to the EFI_GUID which must match the Guid
1082 field in the EFI_IFR_FORM_SET op-code for the specified
1083 forms-based package. If FormSetGuid is NULL, then this
1084 function will display the first found forms package.
1085 @param FormId This field specifies which EFI_IFR_FORM to render as the first
1086 displayable page. If this field has a value of 0x0000, then
1087 the forms browser will render the specified forms in their encoded order.
1088 ScreenDimenions - This allows the browser to be called so that it occupies a
1089 portion of the physical screen instead of dynamically determining the screen dimensions.
1090 ActionRequest - Points to the action recommended by the form.
1091 @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
1092 characters.
1093 @param ActionRequest Points to the action recommended by the form.
1094
1095 @retval EFI_SUCCESS The function completed successfully.
1096 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1097 @retval EFI_NOT_FOUND No valid forms could be found to display.
1098
1099 **/
1100 EFI_STATUS
1101 EFIAPI
1102 SendForm (
1103 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1104 IN EFI_HII_HANDLE *Handles,
1105 IN UINTN HandleCount,
1106 IN EFI_GUID *FormSetGuid, OPTIONAL
1107 IN UINT16 FormId, OPTIONAL
1108 IN CONST EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
1109 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OPTIONAL
1110 );
1111
1112 /**
1113 This function is called by a callback handler to retrieve uncommitted state
1114 data from the browser.
1115
1116 @param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL
1117 instance.
1118 @param ResultsDataSize A pointer to the size of the buffer associated
1119 with ResultsData.
1120 @param ResultsData A string returned from an IFR browser or
1121 equivalent. The results string will have no
1122 routing information in them.
1123 @param RetrieveData A BOOLEAN field which allows an agent to retrieve
1124 (if RetrieveData = TRUE) data from the uncommitted
1125 browser state information or set (if RetrieveData
1126 = FALSE) data in the uncommitted browser state
1127 information.
1128 @param VariableGuid An optional field to indicate the target variable
1129 GUID name to use.
1130 @param VariableName An optional field to indicate the target
1131 human-readable variable name.
1132
1133 @retval EFI_SUCCESS The results have been distributed or are awaiting
1134 distribution.
1135 @retval EFI_BUFFER_TOO_SMALL The ResultsDataSize specified was too small to
1136 contain the results data.
1137
1138 **/
1139 EFI_STATUS
1140 EFIAPI
1141 BrowserCallback (
1142 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
1143 IN OUT UINTN *ResultsDataSize,
1144 IN OUT EFI_STRING ResultsData,
1145 IN BOOLEAN RetrieveData,
1146 IN CONST EFI_GUID *VariableGuid, OPTIONAL
1147 IN CONST CHAR16 *VariableName OPTIONAL
1148 );
1149
1150 #endif