2 Private MACRO, structure and function definitions for Setup Browser module.
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
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.
22 #include <Protocol/SimpleTextOut.h>
23 #include <Protocol/SimpleTextIn.h>
24 #include <Protocol/FormBrowser2.h>
25 #include <Protocol/FormBrowserEx.h>
26 #include <Protocol/DevicePath.h>
27 #include <Protocol/UnicodeCollation.h>
28 #include <Protocol/HiiConfigAccess.h>
29 #include <Protocol/HiiConfigRouting.h>
30 #include <Protocol/HiiDatabase.h>
31 #include <Protocol/HiiString.h>
32 #include <Protocol/UserManager.h>
33 #include <Protocol/DevicePathFromText.h>
35 #include <Guid/MdeModuleHii.h>
36 #include <Guid/HiiPlatformSetupFormset.h>
37 #include <Guid/HiiFormMapMethodGuid.h>
39 #include <Library/PrintLib.h>
40 #include <Library/DebugLib.h>
41 #include <Library/BaseMemoryLib.h>
42 #include <Library/UefiRuntimeServicesTableLib.h>
43 #include <Library/UefiDriverEntryPoint.h>
44 #include <Library/UefiBootServicesTableLib.h>
45 #include <Library/BaseLib.h>
46 #include <Library/MemoryAllocationLib.h>
47 #include <Library/HiiLib.h>
48 #include <Library/PcdLib.h>
49 #include <Library/DevicePathLib.h>
54 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
57 extern UINT8 SetupBrowserStrings
[];
62 #define BANNER_HEIGHT 6
63 #define BANNER_COLUMNS 3
64 #define BANNER_LEFT_COLUMN_INDENT 1
66 #define FRONT_PAGE_HEADER_HEIGHT 6
67 #define NONE_FRONT_PAGE_HEADER_HEIGHT 3
68 #define LEFT_SKIPPED_COLUMNS 3
69 #define FOOTER_HEIGHT 4
70 #define STATUS_BAR_HEIGHT 1
71 #define SCROLL_ARROW_HEIGHT 1
72 #define POPUP_PAD_SPACE_COUNT 5
73 #define POPUP_FRAME_WIDTH 2
76 // Definition for function key setting
78 #define NONE_FUNCTION_KEY_SETTING 0
79 #define ENABLE_FUNCTION_KEY_SETTING 1
84 } FUNCTIION_KEY_SETTING
;
87 // Character definitions
89 #define CHAR_SPACE 0x0020
90 #define UPPER_LOWER_CASE_OFFSET 0x20
95 #define ONE_SECOND 10000000
98 // Display definitions
100 #define LEFT_HYPER_DELIMITER L'<'
101 #define RIGHT_HYPER_DELIMITER L'>'
103 #define LEFT_ONEOF_DELIMITER L'<'
104 #define RIGHT_ONEOF_DELIMITER L'>'
106 #define LEFT_NUMERIC_DELIMITER L'['
107 #define RIGHT_NUMERIC_DELIMITER L']'
109 #define LEFT_CHECKBOX_DELIMITER L'['
110 #define RIGHT_CHECKBOX_DELIMITER L']'
112 #define CHECK_ON L'X'
113 #define CHECK_OFF L' '
115 #define TIME_SEPARATOR L':'
116 #define DATE_SEPARATOR L'/'
118 #define YES_ANSWER L'Y'
119 #define NO_ANSWER L'N'
122 // This is the Input Error Message
124 #define INPUT_ERROR 1
127 // This is the NV RAM update required Message
129 #define NV_UPDATE_REQUIRED 2
132 // Refresh the Status Bar with flags
134 #define REFRESH_STATUS_BAR 0xff
137 // Incremental string lenght of ConfigRequest
139 #define CONFIG_REQUEST_STRING_INCREMENTAL 1024
142 // HII value compare result
144 #define HII_VALUE_UNDEFINED 0
145 #define HII_VALUE_EQUAL 1
146 #define HII_VALUE_LESS_THAN 2
147 #define HII_VALUE_GREATER_THAN 3
150 // Incremental size of stack for expression
152 #define EXPRESSION_STACK_SIZE_INCREMENT 0x100
154 #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))
157 #define SETUP_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'B', 'D', 'V')
166 EFI_FORM_BROWSER2_PROTOCOL FormBrowser2
;
168 EFI_FORM_BROWSER_EXTENSION_PROTOCOL FormBrowserEx
;
170 } SETUP_DRIVER_PRIVATE_DATA
;
173 EFI_STRING_ID Banner
[BANNER_HEIGHT
][BANNER_COLUMNS
];
177 // IFR relative definition
179 #define EFI_HII_EXPRESSION_INCONSISTENT_IF 0
180 #define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1
181 #define EFI_HII_EXPRESSION_GRAY_OUT_IF 2
182 #define EFI_HII_EXPRESSION_SUPPRESS_IF 3
183 #define EFI_HII_EXPRESSION_DISABLE_IF 4
184 #define EFI_HII_EXPRESSION_VALUE 5
185 #define EFI_HII_EXPRESSION_RULE 6
186 #define EFI_HII_EXPRESSION_READ 7
187 #define EFI_HII_EXPRESSION_WRITE 8
189 #define EFI_HII_VARSTORE_BUFFER 0
190 #define EFI_HII_VARSTORE_NAME_VALUE 1
191 #define EFI_HII_VARSTORE_EFI_VARIABLE 2
192 #define EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER 3
194 #define FORM_INCONSISTENT_VALIDATION 0
195 #define FORM_NO_SUBMIT_VALIDATION 1
197 #define FORMSET_CLASS_PLATFORM_SETUP 0x0001
198 #define FORMSET_CLASS_FRONT_PAGE 0x0002
204 EFI_IFR_TYPE_VALUE Value
;
207 #define NAME_VALUE_NODE_SIGNATURE SIGNATURE_32 ('N', 'V', 'S', 'T')
217 #define NAME_VALUE_NODE_FROM_LINK(a) CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)
219 #define BROWSER_STORAGE_SIGNATURE SIGNATURE_32 ('B', 'S', 'T', 'G')
225 UINT8 Type
; // Storage type
229 CHAR16
*Name
; // For EFI_IFR_VARSTORE
232 UINT8
*EditBuffer
; // Edit copy for Buffer Storage
234 LIST_ENTRY NameValueListHead
; // List of NAME_VALUE_NODE
236 UINT32 Attributes
; // For EFI_IFR_VARSTORE_EFI: EFI Variable attribute
238 CHAR16
*ConfigHdr
; // <ConfigHdr>
239 CHAR16
*ConfigRequest
; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
240 // <RequestElement> includes all fields which is used by current form sets.
241 UINTN SpareStrLen
; // Spare length of ConfigRequest string buffer
242 UINT8 ReferenceCount
; // How many form set storage refrence this storage.
245 #define BROWSER_STORAGE_FROM_LINK(a) CR (a, BROWSER_STORAGE, Link, BROWSER_STORAGE_SIGNATURE)
247 #define FORMSET_STORAGE_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'G')
255 BROWSER_STORAGE
*BrowserStorage
;
257 CHAR16
*ConfigRequest
; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
258 UINTN ElementCount
; // Number of <RequestElement> in the <ConfigRequest>
259 UINTN SpareStrLen
; // Spare length of ConfigRequest string buffer
262 #define FORMSET_STORAGE_FROM_LINK(a) CR (a, FORMSET_STORAGE, Link, FORMSET_STORAGE_SIGNATURE)
265 EFI_STRING_ID VarName
;
269 #define EXPRESSION_OPCODE_SIGNATURE SIGNATURE_32 ('E', 'X', 'O', 'P')
277 UINT8 Format
; // For EFI_IFR_TO_STRING, EFI_IFR_FIND
278 UINT8 Flags
; // For EFI_IFR_SPAN
279 UINT8 RuleId
; // For EFI_IFR_RULE_REF
281 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
283 EFI_QUESTION_ID QuestionId
; // For EFI_IFR_EQ_ID_ID, EFI_IFR_EQ_ID_VAL_LIST, EFI_IFR_QUESTION_REF1
284 EFI_QUESTION_ID QuestionId2
;
286 UINT16 ListLength
; // For EFI_IFR_EQ_ID_VAL_LIST
289 EFI_STRING_ID DevicePath
; // For EFI_IFR_QUESTION_REF3_2, EFI_IFR_QUESTION_REF3_3
292 BROWSER_STORAGE
*VarStorage
; // For EFI_IFR_SET, EFI_IFR_GET
293 VAR_STORE_INFO VarStoreInfo
;// For EFI_IFR_SET, EFI_IFR_GET
294 UINT8 ValueType
; // For EFI_IFR_SET, EFI_IFR_GET
295 UINT8 ValueWidth
; // For EFI_IFR_SET, EFI_IFR_GET
296 CHAR16
*ValueName
; // For EFI_IFR_SET, EFI_IFR_GET
297 LIST_ENTRY MapExpressionList
; // nested expressions inside of Map opcode.
300 #define EXPRESSION_OPCODE_FROM_LINK(a) CR (a, EXPRESSION_OPCODE, Link, EXPRESSION_OPCODE_SIGNATURE)
302 #define FORM_EXPRESSION_SIGNATURE SIGNATURE_32 ('F', 'E', 'X', 'P')
308 UINT8 Type
; // Type for this expression
310 UINT8 RuleId
; // For EFI_IFR_RULE only
311 EFI_STRING_ID Error
; // For EFI_IFR_NO_SUBMIT_IF, EFI_IFR_INCONSISTENT_IF only
313 EFI_HII_VALUE Result
; // Expression evaluation result
315 LIST_ENTRY OpCodeListHead
; // OpCodes consist of this expression (EXPRESSION_OPCODE)
318 #define FORM_EXPRESSION_FROM_LINK(a) CR (a, FORM_EXPRESSION, Link, FORM_EXPRESSION_SIGNATURE)
320 #define FORM_EXPRESSION_LIST_SIGNATURE SIGNATURE_32 ('F', 'E', 'X', 'R')
325 FORM_EXPRESSION
*Expression
[1]; // Array[Count] of expressions
326 } FORM_EXPRESSION_LIST
;
328 #define QUESTION_DEFAULT_SIGNATURE SIGNATURE_32 ('Q', 'D', 'F', 'T')
335 EFI_HII_VALUE Value
; // Default value
337 FORM_EXPRESSION
*ValueExpression
; // Not-NULL indicates default value is provided by EFI_IFR_VALUE
340 #define QUESTION_DEFAULT_FROM_LINK(a) CR (a, QUESTION_DEFAULT, Link, QUESTION_DEFAULT_SIGNATURE)
342 #define QUESTION_OPTION_SIGNATURE SIGNATURE_32 ('Q', 'O', 'P', 'T')
351 EFI_IMAGE_ID ImageId
;
353 FORM_EXPRESSION_LIST
*SuppressExpression
; // Non-NULL indicates nested inside of SuppressIf
356 #define QUESTION_OPTION_FROM_LINK(a) CR (a, QUESTION_OPTION, Link, QUESTION_OPTION_SIGNATURE)
372 #define FORM_BROWSER_STATEMENT_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'A')
378 UINT8 Operand
; // The operand (first byte) of this Statement or Question
383 EFI_STRING_ID Prompt
;
385 EFI_STRING_ID TextTwo
; // For EFI_IFR_TEXT
390 EFI_QUESTION_ID QuestionId
; // The value of zero is reserved
391 EFI_VARSTORE_ID VarStoreId
; // A value of zero indicates no variable storage
392 BROWSER_STORAGE
*Storage
;
393 VAR_STORE_INFO VarStoreInfo
;
396 CHAR16
*VariableName
; // Name/Value or EFI Variable name
397 CHAR16
*BlockName
; // Buffer storage block name: "OFFSET=...WIDTH=..."
399 EFI_HII_VALUE HiiValue
; // Edit copy for checkbox, numberic, oneof
400 UINT8
*BufferValue
; // Edit copy for string, password, orderedlist
401 UINT8 ValueType
; // Data type for orderedlist value array
404 // OpCode specific members
406 UINT8 Flags
; // for EFI_IFR_CHECKBOX, EFI_IFR_DATE, EFI_IFR_NUMERIC, EFI_IFR_ONE_OF,
407 // EFI_IFR_ORDERED_LIST, EFI_IFR_STRING,EFI_IFR_SUBTITLE,EFI_IFR_TIME, EFI_IFR_BANNER
408 UINT8 MaxContainers
; // for EFI_IFR_ORDERED_LIST
410 UINT16 BannerLineNumber
; // for EFI_IFR_BANNER, 1-based line number
411 EFI_STRING_ID QuestionConfig
; // for EFI_IFR_ACTION, if 0 then no configuration string will be processed
413 UINT64 Minimum
; // for EFI_IFR_ONE_OF/EFI_IFR_NUMERIC, it's Min/Max value
414 UINT64 Maximum
; // for EFI_IFR_STRING/EFI_IFR_PASSWORD, it's Min/Max length
417 EFI_DEFAULT_ID DefaultId
; // for EFI_IFR_RESET_BUTTON
418 EFI_GUID RefreshGuid
; // for EFI_IFR_REFRESH_ID
419 BOOLEAN Locked
; // Whether this statement is locked.
421 // Get from IFR parsing
423 FORM_EXPRESSION
*ValueExpression
; // nested EFI_IFR_VALUE, provide Question value and indicate Question is ReadOnly
424 LIST_ENTRY DefaultListHead
; // nested EFI_IFR_DEFAULT list (QUESTION_DEFAULT), provide default values
425 LIST_ENTRY OptionListHead
; // nested EFI_IFR_ONE_OF_OPTION list (QUESTION_OPTION)
427 EFI_IMAGE_ID ImageId
; // nested EFI_IFR_IMAGE
428 UINT8 RefreshInterval
; // nested EFI_IFR_REFRESH, refresh interval(in seconds) for Question value, 0 means no refresh
429 BOOLEAN InSubtitle
; // nesting inside of EFI_IFR_SUBTITLE
431 LIST_ENTRY InconsistentListHead
;// nested inconsistent expression list (FORM_EXPRESSION)
432 LIST_ENTRY NoSubmitListHead
; // nested nosubmit expression list (FORM_EXPRESSION)
433 FORM_EXPRESSION_LIST
*Expression
; // nesting inside of GrayOutIf/DisableIf/SuppressIf
435 FORM_EXPRESSION
*ReadExpression
; // nested EFI_IFR_READ, provide this question value by read expression.
436 FORM_EXPRESSION
*WriteExpression
; // nested EFI_IFR_WRITE, evaluate write expression after this question value is set.
437 } FORM_BROWSER_STATEMENT
;
439 #define FORM_BROWSER_STATEMENT_FROM_LINK(a) CR (a, FORM_BROWSER_STATEMENT, Link, FORM_BROWSER_STATEMENT_SIGNATURE)
441 #define FORM_BROWSER_CONFIG_REQUEST_SIGNATURE SIGNATURE_32 ('F', 'C', 'R', 'S')
446 CHAR16
*ConfigRequest
; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
447 UINTN ElementCount
; // Number of <RequestElement> in the <ConfigRequest>
450 BROWSER_STORAGE
*Storage
;
451 } FORM_BROWSER_CONFIG_REQUEST
;
452 #define FORM_BROWSER_CONFIG_REQUEST_FROM_LINK(a) CR (a, FORM_BROWSER_CONFIG_REQUEST, Link, FORM_BROWSER_CONFIG_REQUEST_SIGNATURE)
454 #define FORM_BROWSER_FORM_SIGNATURE SIGNATURE_32 ('F', 'F', 'R', 'M')
455 #define STANDARD_MAP_FORM_TYPE 0x01
461 UINT16 FormId
; // FormId of normal form or formmap form.
462 EFI_STRING_ID FormTitle
; // FormTile of normal form, or FormMapMethod title of formmap form.
463 UINT16 FormType
; // Specific form type for the different form.
465 EFI_IMAGE_ID ImageId
;
467 BOOLEAN ModalForm
; // Whether this is a modal form.
468 BOOLEAN Locked
; // Whether this form is locked.
470 BOOLEAN NvUpdateRequired
; // Whether this form has NV update request.
472 LIST_ENTRY ExpressionListHead
; // List of Expressions (FORM_EXPRESSION)
473 LIST_ENTRY StatementListHead
; // List of Statements and Questions (FORM_BROWSER_STATEMENT)
474 LIST_ENTRY ConfigRequestHead
; // List of configreques for all storage.
475 FORM_EXPRESSION_LIST
*SuppressExpression
; // nesting inside of SuppressIf
478 #define FORM_BROWSER_FORM_FROM_LINK(a) CR (a, FORM_BROWSER_FORM, Link, FORM_BROWSER_FORM_SIGNATURE)
480 #define FORMSET_DEFAULTSTORE_SIGNATURE SIGNATURE_32 ('F', 'D', 'F', 'S')
487 EFI_STRING_ID DefaultName
;
488 } FORMSET_DEFAULTSTORE
;
490 #define FORMSET_DEFAULTSTORE_FROM_LINK(a) CR (a, FORMSET_DEFAULTSTORE, Link, FORMSET_DEFAULTSTORE_SIGNATURE)
492 #define FORM_BROWSER_FORMSET_SIGNATURE SIGNATURE_32 ('F', 'B', 'F', 'S')
497 EFI_HII_HANDLE HiiHandle
; // unique id for formset.
498 EFI_HANDLE DriverHandle
;
499 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
500 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
502 UINTN IfrBinaryLength
;
503 UINT8
*IfrBinaryData
;
506 EFI_STRING_ID FormSetTitle
;
508 UINT8 NumberOfClassGuid
;
509 EFI_GUID ClassGuid
[3]; // Up to three ClassGuid
510 UINT16 Class
; // Tiano extended Class code
511 UINT16 SubClass
; // Tiano extended Subclass code
512 EFI_IMAGE_ID ImageId
;
514 FORM_BROWSER_STATEMENT
*StatementBuffer
; // Buffer for all Statements and Questions
515 EXPRESSION_OPCODE
*ExpressionBuffer
; // Buffer for all Expression OpCode
517 LIST_ENTRY StorageListHead
; // Storage list (FORMSET_STORAGE)
518 LIST_ENTRY DefaultStoreListHead
; // DefaultStore list (FORMSET_DEFAULTSTORE)
519 LIST_ENTRY FormListHead
; // Form list (FORM_BROWSER_FORM)
520 LIST_ENTRY ExpressionListHead
; // List of Expressions (FORM_EXPRESSION)
521 } FORM_BROWSER_FORMSET
;
523 #define FORM_BROWSER_FORMSET_FROM_LINK(a) CR (a, FORM_BROWSER_FORMSET, Link, FORM_BROWSER_FORMSET_SIGNATURE)
525 #define BROWSER_CONTEXT_SIGNATURE SIGNATURE_32 ('B', 'C', 'T', 'X')
532 // Globals defined in Setup.c
534 BANNER_DATA
*BannerData
;
536 UINTN FunctionKeySetting
;
537 BOOLEAN ResetRequired
;
539 EFI_SCREEN_DESCRIPTOR ScreenDimensions
;
541 CHAR16
*EnterCommitString
;
542 CHAR16
*EnterEscapeString
;
543 CHAR16
*EscapeString
;
544 CHAR16
*MoveHighlight
;
545 CHAR16
*MakeSelection
;
546 CHAR16
*DecNumericInput
;
547 CHAR16
*HexNumericInput
;
548 CHAR16
*ToggleCheckBox
;
549 CHAR16
*PromptForData
;
550 CHAR16
*PromptForPassword
;
551 CHAR16
*PromptForNewPassword
;
552 CHAR16
*ConfirmPassword
;
553 CHAR16
*ConfirmError
;
554 CHAR16
*PassowordInvalid
;
563 CHAR16
*AdjustNumber
;
565 CHAR16
*OptionMismatch
;
566 CHAR16
*FormSuppress
;
567 CHAR16
*ProtocolNotFound
;
568 CHAR16 PromptBlockWidth
;
569 CHAR16 OptionBlockWidth
;
570 CHAR16 HelpBlockWidth
;
571 FORM_BROWSER_FORMSET
*OldFormSet
;
574 // Globals defined in Ui.c
576 LIST_ENTRY MenuOption
;
577 VOID
*MenuRefreshHead
;
580 #define BROWSER_CONTEXT_FROM_LINK(a) CR (a, BROWSER_CONTEXT, Link, BROWSER_CONTEXT_SIGNATURE)
582 #define BROWSER_HOT_KEY_SIGNATURE SIGNATURE_32 ('B', 'H', 'K', 'S')
588 EFI_INPUT_KEY
*KeyData
;
591 IN EFI_STRING HelpString
;
594 #define BROWSER_HOT_KEY_FROM_LINK(a) CR (a, BROWSER_HOT_KEY, Link, BROWSER_HOT_KEY_SIGNATURE)
597 // Scope for get defaut value. It may be GetDefaultForNoStorage, GetDefaultForStorage or GetDefaultForAll.
600 GetDefaultForNoStorage
, // Get default value for question which not has storage.
601 GetDefaultForStorage
, // Get default value for question which has storage.
602 GetDefaultForAll
, // Get default value for all questions.
603 GetDefaultForMax
// Invalid value.
604 } BROWSER_GET_DEFAULT_VALUE
;
607 // Get/set question value from/to.
610 GetSetValueWithEditBuffer
, // Get/Set question value from/to editbuffer in the storage.
611 GetSetValueWithBuffer
, // Get/Set question value from/to buffer in the storage.
612 GetSetValueWithHiiDriver
, // Get/Set question value from/to hii driver.
613 GetSetValueWithMax
// Invalid value.
614 } GET_SET_QUESTION_VALUE_WITH
;
616 extern EFI_HII_DATABASE_PROTOCOL
*mHiiDatabase
;
617 extern EFI_HII_STRING_PROTOCOL
*mHiiString
;
618 extern EFI_HII_CONFIG_ROUTING_PROTOCOL
*mHiiConfigRouting
;
619 extern EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL
*mPathFromText
;
621 extern BANNER_DATA
*gBannerData
;
622 extern EFI_HII_HANDLE gFrontPageHandle
;
623 extern UINTN gClassOfVfr
;
624 extern UINTN gFunctionKeySetting
;
625 extern BOOLEAN gResetRequired
;
626 extern EFI_HII_HANDLE gHiiHandle
;
627 extern UINT16 gDirection
;
628 extern EFI_SCREEN_DESCRIPTOR gScreenDimensions
;
630 extern FORM_BROWSER_FORMSET
*gOldFormSet
;
631 extern LIST_ENTRY gBrowserFormSetList
;
632 extern LIST_ENTRY gBrowserHotKeyList
;
633 extern BROWSER_SETTING_SCOPE gBrowserSettingScope
;
634 extern EXIT_HANDLER ExitHandlerFunction
;
635 extern UINTN gFooterHeight
;
638 // Browser Global Strings
640 extern CHAR16
*gDiscardFailed
;
641 extern CHAR16
*gDefaultFailed
;
642 extern CHAR16
*gEnterString
;
643 extern CHAR16
*gEnterCommitString
;
644 extern CHAR16
*gEnterEscapeString
;
645 extern CHAR16
*gEscapeString
;
646 extern CHAR16
*gSaveFailed
;
647 extern CHAR16
*gMoveHighlight
;
648 extern CHAR16
*gMakeSelection
;
649 extern CHAR16
*gDecNumericInput
;
650 extern CHAR16
*gHexNumericInput
;
651 extern CHAR16
*gToggleCheckBox
;
652 extern CHAR16
*gPromptForData
;
653 extern CHAR16
*gPromptForPassword
;
654 extern CHAR16
*gPromptForNewPassword
;
655 extern CHAR16
*gConfirmPassword
;
656 extern CHAR16
*gConfirmError
;
657 extern CHAR16
*gPassowordInvalid
;
658 extern CHAR16
*gPressEnter
;
659 extern CHAR16
*gEmptyString
;
660 extern CHAR16
*gAreYouSure
;
661 extern CHAR16
*gYesResponse
;
662 extern CHAR16
*gNoResponse
;
663 extern CHAR16
*gMiniString
;
664 extern CHAR16
*gPlusString
;
665 extern CHAR16
*gMinusString
;
666 extern CHAR16
*gAdjustNumber
;
667 extern CHAR16
*gSaveChanges
;
668 extern CHAR16
*gOptionMismatch
;
669 extern CHAR16
*gFormSuppress
;
670 extern CHAR16
*gProtocolNotFound
;
672 extern CHAR16 gPromptBlockWidth
;
673 extern CHAR16 gOptionBlockWidth
;
674 extern CHAR16 gHelpBlockWidth
;
676 extern EFI_GUID gZeroGuid
;
677 extern EFI_GUID gTianoHiiIfrGuid
;
681 // Global Procedure Defines
685 Initialize the HII String Token to the correct values.
689 InitializeBrowserStrings (
694 Prints a unicode string to the default console,
697 @param String String pointer.
699 @return Length of string printed to the console
708 Prints a chracter to the default console,
711 @param Character Character to print.
713 @return Length of string printed to the console.
722 Prints a formatted unicode string to the default console, at
723 the supplied cursor position.
725 @param Column The cursor position to print the string at.
726 @param Row The cursor position to print the string at
727 @param Fmt Format string
728 @param ... Variable argument list for formating string.
730 @return Length of string printed to the console
743 Prints a unicode string to the default console, at
744 the supplied cursor position, using L"%s" format.
746 @param Column The cursor position to print the string at.
747 @param Row The cursor position to print the string at
748 @param String String pointer.
750 @return Length of string printed to the console
761 Prints a chracter to the default console, at
762 the supplied cursor position, using L"%c" format.
764 @param Column The cursor position to print the string at.
765 @param Row The cursor position to print the string at.
766 @param Character Character to print.
768 @return Length of string printed to the console.
779 Parse opcodes in the formset IFR binary.
781 @param FormSet Pointer of the FormSet data structure.
783 @retval EFI_SUCCESS Opcode parse success.
784 @retval Other Opcode parse fail.
789 IN FORM_BROWSER_FORMSET
*FormSet
793 Free resources allocated for a FormSet.
795 @param FormSet Pointer of the FormSet
800 IN OUT FORM_BROWSER_FORMSET
*FormSet
804 This function displays the page frame.
806 @param Selection Selection contains the information about
807 the Selection, form and formset to be displayed.
808 Selection action may be updated in retrieve callback.
812 IN UI_MENU_SELECTION
*Selection
816 Create a new string in HII Package List.
818 @param String The String to be added
819 @param HiiHandle The package list in the HII database to insert the
822 @return The output string.
828 IN EFI_HII_HANDLE HiiHandle
832 Delete a string from HII Package List.
834 @param StringId Id of the string in HII database.
835 @param HiiHandle The HII package list handle.
837 @retval EFI_SUCCESS The string was deleted successfully.
842 IN EFI_STRING_ID StringId
,
843 IN EFI_HII_HANDLE HiiHandle
847 Get the string based on the StringId and HII Package List Handle.
849 @param Token The String's ID.
850 @param HiiHandle The package list in the HII database to search for
851 the specified string.
853 @return The output string.
858 IN EFI_STRING_ID Token
,
859 IN EFI_HII_HANDLE HiiHandle
863 Draw a pop up windows based on the dimension, number of lines and
866 @param RequestedWidth The width of the pop-up.
867 @param NumberOfLines The number of lines.
868 @param Marker The variable argument list for the list of string to be printed.
873 IN UINTN RequestedWidth
,
874 IN UINTN NumberOfLines
,
879 Routine used to abstract a generic dialog interface and return the selected key or string
881 @param NumberOfLines The number of lines for the dialog box
882 @param HotKey Defines whether a single character is parsed
883 (TRUE) and returned in KeyValue or a string is
884 returned in StringBuffer. Two special characters
885 are considered when entering a string, a SCAN_ESC
886 and an CHAR_CARRIAGE_RETURN. SCAN_ESC terminates
887 string input and returns
888 @param MaximumStringSize The maximum size in bytes of a typed in string
889 (each character is a CHAR16) and the minimum
890 string returned is two bytes
891 @param StringBuffer The passed in pointer to the buffer which will
892 hold the typed in string if HotKey is FALSE
893 @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
894 @param ... A series of (quantity == NumberOfLines) text
895 strings which will be used to construct the dialog
898 @retval EFI_SUCCESS Displayed dialog and received user interaction
899 @retval EFI_INVALID_PARAMETER One of the parameters was invalid (e.g.
900 (StringBuffer == NULL) && (HotKey == FALSE))
901 @retval EFI_DEVICE_ERROR User typed in an ESC character to exit the routine
907 IN UINTN NumberOfLines
,
909 IN UINTN MaximumStringSize
,
910 OUT CHAR16
*StringBuffer
,
911 OUT EFI_INPUT_KEY
*KeyValue
,
916 Get Value for given Name from a NameValue Storage.
918 @param Storage The NameValue Storage.
919 @param Name The Name.
920 @param Value The retured Value.
921 @param GetValueFrom Where to get source value, from EditValue or Value.
923 @retval EFI_SUCCESS Value found for given Name.
924 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
929 IN BROWSER_STORAGE
*Storage
,
931 IN OUT CHAR16
**Value
,
932 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
936 Set Value of given Name in a NameValue Storage.
938 @param Storage The NameValue Storage.
939 @param Name The Name.
940 @param Value The Value to set.
941 @param SetValueTo Whether update editValue or Value.
943 @retval EFI_SUCCESS Value found for given Name.
944 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
949 IN BROWSER_STORAGE
*Storage
,
952 IN GET_SET_QUESTION_VALUE_WITH SetValueTo
956 Get Question's current Value.
958 @param FormSet FormSet data structure.
959 @param Form Form data structure.
960 @param Question Question to be initialized.
961 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
963 @retval EFI_SUCCESS The function completed successfully.
968 IN FORM_BROWSER_FORMSET
*FormSet
,
969 IN FORM_BROWSER_FORM
*Form
,
970 IN OUT FORM_BROWSER_STATEMENT
*Question
,
971 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
975 Save Question Value to edit copy(cached) or Storage(uncached).
977 @param FormSet FormSet data structure.
978 @param Form Form data structure.
979 @param Question Pointer to the Question.
980 @param SetValueTo Update the question value to editbuffer , buffer or hii driver.
982 @retval EFI_SUCCESS The function completed successfully.
987 IN FORM_BROWSER_FORMSET
*FormSet
,
988 IN FORM_BROWSER_FORM
*Form
,
989 IN OUT FORM_BROWSER_STATEMENT
*Question
,
990 IN GET_SET_QUESTION_VALUE_WITH SetValueTo
994 Perform inconsistent check for a Form.
996 @param FormSet FormSet data structure.
997 @param Form Form data structure.
998 @param Question The Question to be validated.
999 @param Type Validation type: InConsistent or NoSubmit
1001 @retval EFI_SUCCESS Form validation pass.
1002 @retval other Form validation failed.
1007 IN FORM_BROWSER_FORMSET
*FormSet
,
1008 IN FORM_BROWSER_FORM
*Form
,
1009 IN FORM_BROWSER_STATEMENT
*Question
,
1015 Discard data based on the input setting scope (Form, FormSet or System).
1017 @param FormSet FormSet data structure.
1018 @param Form Form data structure.
1019 @param SettingScope Setting Scope for Discard action.
1021 @retval EFI_SUCCESS The function completed successfully.
1022 @retval EFI_UNSUPPORTED Unsupport SettingScope.
1027 IN FORM_BROWSER_FORMSET
*FormSet
,
1028 IN FORM_BROWSER_FORM
*Form
,
1029 IN BROWSER_SETTING_SCOPE SettingScope
1033 Submit data based on the input Setting level (Form, FormSet or System).
1035 @param FormSet FormSet data structure.
1036 @param Form Form data structure.
1037 @param SettingScope Setting Scope for Submit action.
1039 @retval EFI_SUCCESS The function completed successfully.
1040 @retval EFI_UNSUPPORTED Unsupport SettingScope.
1045 IN FORM_BROWSER_FORMSET
*FormSet
,
1046 IN FORM_BROWSER_FORM
*Form
,
1047 IN BROWSER_SETTING_SCOPE SettingScope
1051 Reset Question to its default value.
1053 @param FormSet The form set.
1054 @param Form The form.
1055 @param Question The question.
1056 @param DefaultId The Class of the default.
1058 @retval EFI_SUCCESS Question is reset to default value.
1062 GetQuestionDefault (
1063 IN FORM_BROWSER_FORMSET
*FormSet
,
1064 IN FORM_BROWSER_FORM
*Form
,
1065 IN FORM_BROWSER_STATEMENT
*Question
,
1070 Get current setting of Questions.
1072 @param FormSet FormSet data structure.
1074 @retval EFI_SUCCESS The function completed successfully.
1078 InitializeCurrentSetting (
1079 IN OUT FORM_BROWSER_FORMSET
*FormSet
1083 Initialize the internal data structure of a FormSet.
1085 @param Handle PackageList Handle
1086 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
1087 GUID), take the first FormSet found in package
1089 @param FormSet FormSet data structure.
1090 @param UpdateGlobalVar Whether need to update the global variable.
1092 @retval EFI_SUCCESS The function completed successfully.
1093 @retval EFI_NOT_FOUND The specified FormSet could not be found.
1098 IN EFI_HII_HANDLE Handle
,
1099 IN OUT EFI_GUID
*FormSetGuid
,
1100 OUT FORM_BROWSER_FORMSET
*FormSet
,
1101 IN BOOLEAN UpdateGlobalVar
1105 Reset Questions to their initial value or default value in a Form, Formset or System.
1107 GetDefaultValueScope parameter decides which questions will reset
1108 to its default value.
1110 @param FormSet FormSet data structure.
1111 @param Form Form data structure.
1112 @param DefaultId The Class of the default.
1113 @param SettingScope Setting Scope for Default action.
1114 @param GetDefaultValueScope Get default value scope.
1115 @param Storage Get default value only for this storage.
1116 @param RetrieveValueFirst Whether call the retrieve call back to
1117 get the initial value before get default
1120 @retval EFI_SUCCESS The function completed successfully.
1121 @retval EFI_UNSUPPORTED Unsupport SettingScope.
1126 IN FORM_BROWSER_FORMSET
*FormSet
,
1127 IN FORM_BROWSER_FORM
*Form
,
1128 IN UINT16 DefaultId
,
1129 IN BROWSER_SETTING_SCOPE SettingScope
,
1130 IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope
,
1131 IN BROWSER_STORAGE
*Storage
,
1132 IN BOOLEAN RetrieveValueFirst
1136 Initialize Question's Edit copy from Storage.
1138 @param Selection Selection contains the information about
1139 the Selection, form and formset to be displayed.
1140 Selection action may be updated in retrieve callback.
1141 If Selection is NULL, only initialize Question value.
1142 @param FormSet FormSet data structure.
1143 @param Form Form data structure.
1145 @retval EFI_SUCCESS The function completed successfully.
1150 IN OUT UI_MENU_SELECTION
*Selection
,
1151 IN FORM_BROWSER_FORMSET
*FormSet
,
1152 IN FORM_BROWSER_FORM
*Form
1156 Initialize Question's Edit copy from Storage for the whole Formset.
1158 @param Selection Selection contains the information about
1159 the Selection, form and formset to be displayed.
1160 Selection action may be updated in retrieve callback.
1161 If Selection is NULL, only initialize Question value.
1162 @param FormSet FormSet data structure.
1164 @retval EFI_SUCCESS The function completed successfully.
1169 IN OUT UI_MENU_SELECTION
*Selection
,
1170 IN FORM_BROWSER_FORMSET
*FormSet
1174 Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
1176 @param Storage The Storage to be conveted.
1177 @param ConfigResp The returned <ConfigResp>.
1178 @param ConfigRequest The ConfigRequest string.
1180 @retval EFI_SUCCESS Convert success.
1181 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1185 StorageToConfigResp (
1186 IN BROWSER_STORAGE
*Storage
,
1187 IN CHAR16
**ConfigResp
,
1188 IN CHAR16
*ConfigRequest
1192 Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.
1194 @param Storage The Storage to receive the settings.
1195 @param ConfigResp The <ConfigResp> to be converted.
1197 @retval EFI_SUCCESS Convert success.
1198 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1202 ConfigRespToStorage (
1203 IN BROWSER_STORAGE
*Storage
,
1204 IN CHAR16
*ConfigResp
1208 Fill storage's edit copy with settings requested from Configuration Driver.
1210 @param FormSet FormSet data structure.
1211 @param Storage Buffer Storage.
1213 @retval EFI_SUCCESS The function completed successfully.
1218 IN FORM_BROWSER_FORMSET
*FormSet
,
1219 IN FORMSET_STORAGE
*Storage
1223 Fetch the Ifr binary data of a FormSet.
1225 @param Handle PackageList Handle
1226 @param FormSetGuid GUID of a formset. If not specified (NULL or zero
1227 GUID), take the first FormSet found in package
1229 @param BinaryLength The length of the FormSet IFR binary.
1230 @param BinaryData The buffer designed to receive the FormSet.
1232 @retval EFI_SUCCESS Buffer filled with the requested FormSet.
1233 BufferLength was updated.
1234 @retval EFI_INVALID_PARAMETER The handle is unknown.
1235 @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
1236 be found with the requested FormId.
1241 IN EFI_HII_HANDLE Handle
,
1242 IN OUT EFI_GUID
*FormSetGuid
,
1243 OUT UINTN
*BinaryLength
,
1244 OUT UINT8
**BinaryData
1248 Save globals used by previous call to SendForm(). SendForm() may be called from
1249 HiiConfigAccess.Callback(), this will cause SendForm() be reentried.
1250 So, save globals of previous call to SendForm() and restore them upon exit.
1254 SaveBrowserContext (
1259 Restore globals used by previous call to SendForm().
1263 RestoreBrowserContext (
1268 This is the routine which an external caller uses to direct the browser
1269 where to obtain it's information.
1272 @param This The Form Browser protocol instanse.
1273 @param Handles A pointer to an array of Handles. If HandleCount > 1 we
1274 display a list of the formsets for the handles specified.
1275 @param HandleCount The number of Handles specified in Handle.
1276 @param FormSetGuid This field points to the EFI_GUID which must match the Guid
1277 field in the EFI_IFR_FORM_SET op-code for the specified
1278 forms-based package. If FormSetGuid is NULL, then this
1279 function will display the first found forms package.
1280 @param FormId This field specifies which EFI_IFR_FORM to render as the first
1281 displayable page. If this field has a value of 0x0000, then
1282 the forms browser will render the specified forms in their encoded order.
1283 ScreenDimenions - This allows the browser to be called so that it occupies a
1284 portion of the physical screen instead of dynamically determining the screen dimensions.
1285 ActionRequest - Points to the action recommended by the form.
1286 @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
1288 @param ActionRequest Points to the action recommended by the form.
1290 @retval EFI_SUCCESS The function completed successfully.
1291 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
1292 @retval EFI_NOT_FOUND No valid forms could be found to display.
1298 IN CONST EFI_FORM_BROWSER2_PROTOCOL
*This
,
1299 IN EFI_HII_HANDLE
*Handles
,
1300 IN UINTN HandleCount
,
1301 IN EFI_GUID
*FormSetGuid
, OPTIONAL
1302 IN UINT16 FormId
, OPTIONAL
1303 IN CONST EFI_SCREEN_DESCRIPTOR
*ScreenDimensions
, OPTIONAL
1304 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest OPTIONAL
1308 This function is called by a callback handler to retrieve uncommitted state
1309 data from the browser.
1311 @param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL
1313 @param ResultsDataSize A pointer to the size of the buffer associated
1315 @param ResultsData A string returned from an IFR browser or
1316 equivalent. The results string will have no
1317 routing information in them.
1318 @param RetrieveData A BOOLEAN field which allows an agent to retrieve
1319 (if RetrieveData = TRUE) data from the uncommitted
1320 browser state information or set (if RetrieveData
1321 = FALSE) data in the uncommitted browser state
1323 @param VariableGuid An optional field to indicate the target variable
1325 @param VariableName An optional field to indicate the target
1326 human-readable variable name.
1328 @retval EFI_SUCCESS The results have been distributed or are awaiting
1330 @retval EFI_BUFFER_TOO_SMALL The ResultsDataSize specified was too small to
1331 contain the results data.
1337 IN CONST EFI_FORM_BROWSER2_PROTOCOL
*This
,
1338 IN OUT UINTN
*ResultsDataSize
,
1339 IN OUT EFI_STRING ResultsData
,
1340 IN BOOLEAN RetrieveData
,
1341 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
1342 IN CONST CHAR16
*VariableName OPTIONAL
1346 Find menu which will show next time.
1348 @param Selection On input, Selection tell setup browser the information
1349 about the Selection, form and formset to be displayed.
1350 On output, Selection return the screen item that is selected
1352 @param Repaint Whether need to repaint the menu.
1353 @param NewLine Whether need to show at new line.
1355 @retval TRUE Need return.
1356 @retval FALSE No need to return.
1360 IN OUT UI_MENU_SELECTION
*Selection
,
1361 IN BOOLEAN
*Repaint
,
1366 check whether the formset need to update the NV.
1368 @param FormSet FormSet data structure.
1369 @param SetValue Whether set new value or clear old value.
1373 UpdateNvInfoInForm (
1374 IN FORM_BROWSER_FORMSET
*FormSet
,
1379 check whether the formset need to update the NV.
1381 @param FormSet FormSet data structure.
1383 @retval TRUE Need to update the NV.
1384 @retval FALSE No need to update the NV.
1387 IsNvUpdateRequired (
1388 IN FORM_BROWSER_FORMSET
*FormSet
1392 Call the call back function for the question and process the return action.
1394 @param Selection On input, Selection tell setup browser the information
1395 about the Selection, form and formset to be displayed.
1396 On output, Selection return the screen item that is selected
1398 @param Statement The Question which need to call.
1399 @param Action The action request.
1400 @param SkipSaveOrDiscard Whether skip save or discard action.
1402 @retval EFI_SUCCESS The call back function excutes successfully.
1403 @return Other value if the call back function failed to excute.
1406 ProcessCallBackFunction (
1407 IN OUT UI_MENU_SELECTION
*Selection
,
1408 IN FORM_BROWSER_STATEMENT
*Question
,
1409 IN EFI_BROWSER_ACTION Action
,
1410 IN BOOLEAN SkipSaveOrDiscard
1414 Call the retrieve type call back function for one question to get the initialize data.
1416 This function only used when in the initialize stage, because in this stage, the
1417 Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.
1419 @param ConfigAccess The config access protocol produced by the hii driver.
1420 @param Statement The Question which need to call.
1422 @retval EFI_SUCCESS The call back function excutes successfully.
1423 @return Other value if the call back function failed to excute.
1426 ProcessRetrieveForQuestion (
1427 IN EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
,
1428 IN FORM_BROWSER_STATEMENT
*Statement
1432 Find the matched FormSet context in the backup maintain list based on HiiHandle.
1434 @param Handle The Hii Handle.
1436 @return the found FormSet context. If no found, NULL will return.
1439 FORM_BROWSER_FORMSET
*
1440 GetFormSetFromHiiHandle (
1441 EFI_HII_HANDLE Handle
1445 Check whether the input HII handle is the FormSet that is being used.
1447 @param Handle The Hii Handle.
1449 @retval TRUE HII handle is being used.
1450 @retval FALSE HII handle is not being used.
1454 IsHiiHandleInBrowserContext (
1455 EFI_HII_HANDLE Handle
1459 Configure what scope the hot key will impact.
1460 All hot keys have the same scope. The mixed hot keys with the different level are not supported.
1461 If no scope is set, the default scope will be FormSet level.
1462 After all registered hot keys are removed, previous Scope can reset to another level.
1464 @param[in] Scope Scope level to be set.
1466 @retval EFI_SUCCESS Scope is set correctly.
1467 @retval EFI_INVALID_PARAMETER Scope is not the valid value specified in BROWSER_SETTING_SCOPE.
1468 @retval EFI_UNSPPORTED Scope level is different from current one that the registered hot keys have.
1474 IN BROWSER_SETTING_SCOPE Scope
1478 Register the hot key with its browser action, or unregistered the hot key.
1479 Only support hot key that is not printable character (control key, function key, etc.).
1480 If the action value is zero, the hot key will be unregistered if it has been registered.
1481 If the same hot key has been registered, the new action and help string will override the previous ones.
1483 @param[in] KeyData A pointer to a buffer that describes the keystroke
1484 information for the hot key. Its type is EFI_INPUT_KEY to
1485 be supported by all ConsoleIn devices.
1486 @param[in] Action Action value that describes what action will be trigged when the hot key is pressed.
1487 @param[in] DefaultId Specifies the type of defaults to retrieve, which is only for DEFAULT action.
1488 @param[in] HelpString Help string that describes the hot key information.
1489 Its value may be NULL for the unregistered hot key.
1491 @retval EFI_SUCCESS Hot key is registered or unregistered.
1492 @retval EFI_INVALID_PARAMETER KeyData is NULL.
1493 @retval EFI_NOT_FOUND KeyData is not found to be unregistered.
1494 @retval EFI_UNSUPPORTED Key represents a printable character. It is conflicted with Browser.
1499 IN EFI_INPUT_KEY
*KeyData
,
1501 IN UINT16 DefaultId
,
1502 IN EFI_STRING HelpString OPTIONAL
1506 Register Exit handler function.
1507 When more than one handler function is registered, the latter one will override the previous one.
1508 When NULL handler is specified, the previous Exit handler will be unregistered.
1510 @param[in] Handler Pointer to handler function.
1515 RegiserExitHandler (
1516 IN EXIT_HANDLER Handler
1520 Create reminder to let user to choose save or discard the changed browser data.
1521 Caller can use it to actively check the changed browser data.
1523 @retval BROWSER_NO_CHANGES No browser data is changed.
1524 @retval BROWSER_SAVE_CHANGES The changed browser data is saved.
1525 @retval BROWSER_DISCARD_CHANGES The changed browser data is discard.
1535 Find the registered HotKey based on KeyData.
1537 @param[in] KeyData A pointer to a buffer that describes the keystroke
1538 information for the hot key.
1540 @return The registered HotKey context. If no found, NULL will return.
1543 GetHotKeyFromRegisterList (
1544 IN EFI_INPUT_KEY
*KeyData