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