3 Copyright (c) 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
30 #include <Protocol/Print.h>
31 #include <Protocol/SimpleTextOut.h>
32 #include <Protocol/SimpleTextIn.h>
33 #include <Protocol/FormBrowser2.h>
34 #include <Protocol/DevicePath.h>
35 #include <Protocol/UnicodeCollation.h>
36 #include <Protocol/HiiConfigAccess.h>
37 #include <Protocol/HiiConfigRouting.h>
38 #include <Protocol/HiiDatabase.h>
39 #include <Protocol/HiiString.h>
41 #include <MdeModuleHii.h>
43 #include <Library/GraphicsLib.h>
44 #include <Library/PrintLib.h>
45 #include <Library/DebugLib.h>
46 #include <Library/BaseMemoryLib.h>
47 #include <Library/UefiRuntimeServicesTableLib.h>
48 #include <Library/UefiDriverEntryPoint.h>
49 #include <Library/UefiBootServicesTableLib.h>
50 #include <Library/BaseLib.h>
51 #include <Library/MemoryAllocationLib.h>
52 #include <Library/IfrSupportLib.h>
53 #include <Library/ExtendedIfrSupportLib.h>
54 #include <Library/HiiLib.h>
55 #include <Library/ExtendedHiiLib.h>
61 //@MT:#include EFI_PROTOCOL_DEFINITION (HiiDatabase)
62 //@MT:#include EFI_PROTOCOL_DEFINITION (HiiString)
63 //@MT:#include EFI_PROTOCOL_DEFINITION (HiiConfigRouting)
64 //@MT:#include EFI_PROTOCOL_DEFINITION (HiiConfigAccess)
65 //@MT:#include EFI_PROTOCOL_DEFINITION (FormBrowser2)
67 //@MT:#include EFI_GUID_DEFINITION (GlobalVariable)
68 //@MT:#include EFI_PROTOCOL_DEFINITION (DevicePath)
69 //@MT:#include EFI_PROTOCOL_DEFINITION (SimpleTextOut)
70 //@MT:#include EFI_PROTOCOL_DEFINITION (SimpleTextIn)
71 //@MT:#include EFI_PROTOCOL_DEFINITION (Print)
72 //@MT:#include EFI_PROTOCOL_DEFINITION (UnicodeCollation)
75 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
78 extern UINT8 SetupBrowserStrings
[];
83 #define BANNER_HEIGHT 6
84 #define BANNER_COLUMNS 3
86 #define FRONT_PAGE_HEADER_HEIGHT 6
87 #define NONE_FRONT_PAGE_HEADER_HEIGHT 3
88 #define LEFT_SKIPPED_COLUMNS 4
89 #define FOOTER_HEIGHT 4
90 #define STATUS_BAR_HEIGHT 1
91 #define SCROLL_ARROW_HEIGHT 1
92 #define POPUP_PAD_SPACE_COUNT 5
93 #define POPUP_FRAME_WIDTH 2
96 // Definition for function key setting
98 #define NONE_FUNCTION_KEY_SETTING 0
99 #define DEFAULT_FUNCTION_KEY_SETTING (FUNCTION_ONE | FUNCTION_TWO | FUNCTION_NINE | FUNCTION_TEN)
101 #define FUNCTION_ONE (1 << 0)
102 #define FUNCTION_TWO (1 << 1)
103 #define FUNCTION_NINE (1 << 2)
104 #define FUNCTION_TEN (1 << 3)
107 EFI_GUID FormSetGuid
;
109 } FUNCTIION_KEY_SETTING
;
112 // Character definitions
114 #define CHAR_SPACE 0x0020
115 #define UPPER_LOWER_CASE_OFFSET 0x20
120 #define ONE_SECOND 10000000
123 // Display definitions
125 #define LEFT_HYPER_DELIMITER L'<'
126 #define RIGHT_HYPER_DELIMITER L'>'
128 #define LEFT_ONEOF_DELIMITER L'<'
129 #define RIGHT_ONEOF_DELIMITER L'>'
131 #define LEFT_NUMERIC_DELIMITER L'['
132 #define RIGHT_NUMERIC_DELIMITER L']'
134 #define LEFT_CHECKBOX_DELIMITER L'['
135 #define RIGHT_CHECKBOX_DELIMITER L']'
137 #define CHECK_ON L'X'
138 #define CHECK_OFF L' '
140 #define TIME_SEPARATOR L':'
141 #define DATE_SEPARATOR L'/'
143 #define YES_ANSWER L'Y'
144 #define NO_ANSWER L'N'
147 // This is the Input Error Message
149 #define INPUT_ERROR 1
152 // This is the NV RAM update required Message
154 #define NV_UPDATE_REQUIRED 2
157 // Refresh the Status Bar with flags
159 #define REFRESH_STATUS_BAR 0xff
162 // Incremental string lenght of ConfigRequest
164 #define CONFIG_REQUEST_STRING_INCREMENTAL 1024
167 // HII value compare result
169 #define HII_VALUE_UNDEFINED 0
170 #define HII_VALUE_EQUAL 1
171 #define HII_VALUE_LESS_THAN 2
172 #define HII_VALUE_GREATER_THAN 3
175 // Incremental size of stack for expression
177 #define EXPRESSION_STACK_SIZE_INCREMENT 0x100
180 #define EFI_SPECIFICATION_ERRATA_VERSION 0
182 #define EFI_IFR_SPECIFICATION_VERSION \
183 ((((EFI_SPECIFICATION_VERSION) >> 8) & 0xff00) | \
184 (((EFI_SPECIFICATION_VERSION) & 0xf) << 4) | \
185 ((EFI_SPECIFICATION_ERRATA_VERSION) & 0xf))
187 #define SETUP_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('F', 'B', 'D', 'V')
196 EFI_FORM_BROWSER2_PROTOCOL FormBrowser2
;
197 EFI_PRINT_PROTOCOL Print
;
199 } SETUP_DRIVER_PRIVATE_DATA
;
202 EFI_STRING_ID Banner
[BANNER_HEIGHT
][BANNER_COLUMNS
];
206 // IFR relative definition
208 #define EFI_HII_EXPRESSION_INCONSISTENT_IF 0
209 #define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1
210 #define EFI_HII_EXPRESSION_GRAY_OUT_IF 2
211 #define EFI_HII_EXPRESSION_SUPPRESS_IF 3
212 #define EFI_HII_EXPRESSION_DISABLE_IF 4
213 #define EFI_HII_EXPRESSION_VALUE 5
214 #define EFI_HII_EXPRESSION_RULE 6
216 #define EFI_HII_VARSTORE_BUFFER 0
217 #define EFI_HII_VARSTORE_NAME_VALUE 1
218 #define EFI_HII_VARSTORE_EFI_VARIABLE 2
220 #define FORM_INCONSISTENT_VALIDATION 0
221 #define FORM_NO_SUBMIT_VALIDATION 1
225 EFI_IFR_TYPE_VALUE Value
;
228 #define NAME_VALUE_NODE_SIGNATURE EFI_SIGNATURE_32 ('N', 'V', 'S', 'T')
238 #define NAME_VALUE_NODE_FROM_LINK(a) CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)
240 #define FORMSET_STORAGE_SIGNATURE EFI_SIGNATURE_32 ('F', 'S', 'T', 'G')
246 UINT8 Type
; // Storage type
251 CHAR16
*Name
; // For EFI_IFR_VARSTORE
254 UINT8
*EditBuffer
; // Edit copy for Buffer Storage
256 LIST_ENTRY NameValueListHead
; // List of NAME_VALUE_NODE
258 UINT32 Attributes
; // For EFI_IFR_VARSTORE_EFI: EFI Variable attribute
260 CHAR16
*ConfigHdr
; // <ConfigHdr>
261 CHAR16
*ConfigRequest
; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
262 UINTN ElementCount
; // Number of <RequestElement> in the <ConfigRequest>
263 UINTN SpareStrLen
; // Spare length of ConfigRequest string buffer
266 #define FORMSET_STORAGE_FROM_LINK(a) CR (a, FORMSET_STORAGE, Link, FORMSET_STORAGE_SIGNATURE)
268 #define EXPRESSION_OPCODE_SIGNATURE EFI_SIGNATURE_32 ('E', 'X', 'O', 'P')
276 UINT8 Format
; // For EFI_IFR_TO_STRING, EFI_IFR_FIND
277 UINT8 Flags
; // For EFI_IFR_SPAN
278 UINT8 RuleId
; // For EFI_IFR_RULE_REF
280 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
282 EFI_QUESTION_ID QuestionId
; // For EFI_IFR_EQ_ID_ID, EFI_IFR_EQ_ID_LIST, EFI_IFR_QUESTION_REF1
283 EFI_QUESTION_ID QuestionId2
;
285 UINT16 ListLength
; // For EFI_IFR_EQ_ID_LIST
288 EFI_STRING_ID DevicePath
; // For EFI_IFR_QUESTION_REF3_2, EFI_IFR_QUESTION_REF3_3
292 #define EXPRESSION_OPCODE_FROM_LINK(a) CR (a, EXPRESSION_OPCODE, Link, EXPRESSION_OPCODE_SIGNATURE)
294 #define FORM_EXPRESSION_SIGNATURE EFI_SIGNATURE_32 ('F', 'E', 'X', 'P')
300 UINT8 Type
; // Type for this expression
302 UINT8 RuleId
; // For EFI_IFR_RULE only
303 EFI_STRING_ID Error
; // For EFI_IFR_NO_SUBMIT_IF, EFI_IFR_INCONSISTENT_IF only
305 EFI_HII_VALUE Result
; // Expression evaluation result
307 LIST_ENTRY OpCodeListHead
; // OpCodes consist of this expression (EXPRESSION_OPCODE)
310 #define FORM_EXPRESSION_FROM_LINK(a) CR (a, FORM_EXPRESSION, Link, FORM_EXPRESSION_SIGNATURE)
312 #define QUESTION_DEFAULT_SIGNATURE EFI_SIGNATURE_32 ('Q', 'D', 'F', 'T')
319 EFI_HII_VALUE Value
; // Default value
321 FORM_EXPRESSION
*ValueExpression
; // Not-NULL indicates default value is provided by EFI_IFR_VALUE
324 #define QUESTION_DEFAULT_FROM_LINK(a) CR (a, QUESTION_DEFAULT, Link, QUESTION_DEFAULT_SIGNATURE)
326 #define QUESTION_OPTION_SIGNATURE EFI_SIGNATURE_32 ('Q', 'O', 'P', 'T')
335 EFI_IMAGE_ID ImageId
;
337 FORM_EXPRESSION
*SuppressExpression
; // Non-NULL indicates nested inside of SuppressIf
340 #define QUESTION_OPTION_FROM_LINK(a) CR (a, QUESTION_OPTION, Link, QUESTION_OPTION_SIGNATURE)
342 #define FORM_BROWSER_STATEMENT_SIGNATURE EFI_SIGNATURE_32 ('F', 'S', 'T', 'A')
347 UINT8 Operand
; // The operand (first byte) of this Statement or Question
352 EFI_STRING_ID Prompt
;
354 EFI_STRING_ID TextTwo
; // For EFI_IFR_TEXT
359 EFI_QUESTION_ID QuestionId
; // The value of zero is reserved
360 EFI_VARSTORE_ID VarStoreId
; // A value of zero indicates no variable storage
361 FORMSET_STORAGE
*Storage
;
363 EFI_STRING_ID VarName
;
368 CHAR16
*VariableName
; // Name/Value or EFI Variable name
369 CHAR16
*BlockName
; // Buffer storage block name: "OFFSET=...WIDTH=..."
371 EFI_HII_VALUE HiiValue
; // Edit copy for checkbox, numberic, oneof
372 UINT8
*BufferValue
; // Edit copy for string, password, orderedlist
375 // OpCode specific members
377 UINT8 Flags
; // for EFI_IFR_CHECKBOX, EFI_IFR_DATE, EFI_IFR_NUMERIC, EFI_IFR_ONE_OF,
378 // EFI_IFR_ORDERED_LIST, EFI_IFR_STRING,EFI_IFR_SUBTITLE,EFI_IFR_TIME, EFI_IFR_BANNER
379 UINT8 MaxContainers
; // for EFI_IFR_ORDERED_LIST
381 UINT16 BannerLineNumber
; // for EFI_IFR_BANNER, 1-based line number
382 EFI_STRING_ID QuestionConfig
; // for EFI_IFR_ACTION, if 0 then no configuration string will be processed
384 UINT64 Minimum
; // for EFI_IFR_ONE_OF/EFI_IFR_NUMERIC, it's Min/Max value
385 UINT64 Maximum
; // for EFI_IFR_STRING/EFI_IFR_PASSWORD, it's Min/Max length
388 EFI_DEFAULT_ID DefaultId
; // for EFI_IFR_RESET_BUTTON
389 EFI_FORM_ID RefFormId
; // for EFI_IFR_REF
390 EFI_QUESTION_ID RefQuestionId
; // for EFI_IFR_REF2
391 EFI_GUID RefFormSetId
; // for EFI_IFR_REF3
392 EFI_STRING_ID RefDevicePath
; // for EFI_IFR_REF4
395 // Get from IFR parsing
397 FORM_EXPRESSION
*ValueExpression
; // nested EFI_IFR_VALUE, provide Question value and indicate Question is ReadOnly
398 LIST_ENTRY DefaultListHead
; // nested EFI_IFR_DEFAULT list (QUESTION_DEFAULT), provide default values
399 LIST_ENTRY OptionListHead
; // nested EFI_IFR_ONE_OF_OPTION list (QUESTION_OPTION)
401 EFI_IMAGE_ID ImageId
; // nested EFI_IFR_IMAGE
402 UINT8 RefreshInterval
; // nested EFI_IFR_REFRESH, refresh interval(in seconds) for Question value, 0 means no refresh
403 BOOLEAN InSubtitle
; // nesting inside of EFI_IFR_SUBTITLE
405 LIST_ENTRY InconsistentListHead
;// nested inconsistent expression list (FORM_EXPRESSION)
406 LIST_ENTRY NoSubmitListHead
; // nested nosubmit expression list (FORM_EXPRESSION)
407 FORM_EXPRESSION
*GrayOutExpression
; // nesting inside of GrayOutIf
408 FORM_EXPRESSION
*SuppressExpression
; // nesting inside of SuppressIf
410 } FORM_BROWSER_STATEMENT
;
412 #define FORM_BROWSER_STATEMENT_FROM_LINK(a) CR (a, FORM_BROWSER_STATEMENT, Link, FORM_BROWSER_STATEMENT_SIGNATURE)
414 #define FORM_BROWSER_FORM_SIGNATURE EFI_SIGNATURE_32 ('F', 'F', 'R', 'M')
421 EFI_STRING_ID FormTitle
;
423 EFI_IMAGE_ID ImageId
;
425 LIST_ENTRY ExpressionListHead
; // List of Expressions (FORM_EXPRESSION)
426 LIST_ENTRY StatementListHead
; // List of Statements and Questions (FORM_BROWSER_STATEMENT)
429 #define FORM_BROWSER_FORM_FROM_LINK(a) CR (a, FORM_BROWSER_FORM, Link, FORM_BROWSER_FORM_SIGNATURE)
431 #define FORMSET_DEFAULTSTORE_SIGNATURE EFI_SIGNATURE_32 ('F', 'D', 'F', 'S')
438 EFI_STRING_ID DefaultName
;
439 } FORMSET_DEFAULTSTORE
;
441 #define FORMSET_DEFAULTSTORE_FROM_LINK(a) CR (a, FORMSET_DEFAULTSTORE, Link, FORMSET_DEFAULTSTORE_SIGNATURE)
444 EFI_HII_HANDLE HiiHandle
;
445 EFI_HANDLE DriverHandle
;
446 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
447 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
449 UINTN IfrBinaryLength
;
450 UINT8
*IfrBinaryData
;
453 EFI_STRING_ID FormSetTitle
;
457 EFI_IMAGE_ID ImageId
;
459 FORM_BROWSER_STATEMENT
*StatementBuffer
; // Buffer for all Statements and Questions
460 EXPRESSION_OPCODE
*ExpressionBuffer
; // Buffer for all Expression OpCode
462 LIST_ENTRY StorageListHead
; // Storage list (FORMSET_STORAGE)
463 LIST_ENTRY DefaultStoreListHead
; // DefaultStore list (FORMSET_DEFAULTSTORE)
464 LIST_ENTRY FormListHead
; // Form list (FORM_BROWSER_FORM)
465 } FORM_BROWSER_FORMSET
;
468 extern EFI_HII_DATABASE_PROTOCOL
*mHiiDatabase
;
469 extern EFI_HII_STRING_PROTOCOL
*mHiiString
;
470 extern EFI_HII_CONFIG_ROUTING_PROTOCOL
*mHiiConfigRouting
;
472 extern BANNER_DATA
*BannerData
;
473 extern EFI_HII_HANDLE FrontPageHandle
;
474 extern UINTN gClassOfVfr
;
475 extern UINTN gFunctionKeySetting
;
476 extern BOOLEAN gResetRequired
;
477 extern BOOLEAN gNvUpdateRequired
;
478 extern EFI_HII_HANDLE gHiiHandle
;
479 extern BOOLEAN gFirstIn
;
480 extern UINT16 gDirection
;
481 extern EFI_SCREEN_DESCRIPTOR gScreenDimensions
;
482 extern BOOLEAN gUpArrow
;
483 extern BOOLEAN gDownArrow
;
486 // Browser Global Strings
488 extern CHAR16
*gFunctionOneString
;
489 extern CHAR16
*gFunctionTwoString
;
490 extern CHAR16
*gFunctionNineString
;
491 extern CHAR16
*gFunctionTenString
;
492 extern CHAR16
*gEnterString
;
493 extern CHAR16
*gEnterCommitString
;
494 extern CHAR16
*gEscapeString
;
495 extern CHAR16
*gSaveFailed
;
496 extern CHAR16
*gMoveHighlight
;
497 extern CHAR16
*gMakeSelection
;
498 extern CHAR16
*gDecNumericInput
;
499 extern CHAR16
*gHexNumericInput
;
500 extern CHAR16
*gToggleCheckBox
;
501 extern CHAR16
*gPromptForData
;
502 extern CHAR16
*gPromptForPassword
;
503 extern CHAR16
*gPromptForNewPassword
;
504 extern CHAR16
*gConfirmPassword
;
505 extern CHAR16
*gConfirmError
;
506 extern CHAR16
*gPassowordInvalid
;
507 extern CHAR16
*gPressEnter
;
508 extern CHAR16
*gEmptyString
;
509 extern CHAR16
*gAreYouSure
;
510 extern CHAR16
*gYesResponse
;
511 extern CHAR16
*gNoResponse
;
512 extern CHAR16
*gMiniString
;
513 extern CHAR16
*gPlusString
;
514 extern CHAR16
*gMinusString
;
515 extern CHAR16
*gAdjustNumber
;
517 extern CHAR16 gPromptBlockWidth
;
518 extern CHAR16 gOptionBlockWidth
;
519 extern CHAR16 gHelpBlockWidth
;
521 extern EFI_GUID gZeroGuid
;
522 extern EFI_GUID gTianoHiiIfrGuid
;
525 // Global Procedure Defines
528 InitializeBrowserStrings (
579 IN FORM_BROWSER_FORMSET
*FormSet
585 IN OUT FORM_BROWSER_FORMSET
*FormSet
598 IN EFI_HII_HANDLE HiiHandle
604 IN EFI_STRING_ID StringId
,
605 IN EFI_HII_HANDLE HiiHandle
610 IN EFI_STRING_ID Token
,
611 IN EFI_HII_HANDLE HiiHandle
617 IN UINTN RequestedWidth
,
618 IN UINTN NumberOfLines
,
619 IN CHAR16
**ArrayOfStrings
625 IN UINTN NumberOfLines
,
627 IN UINTN MaximumStringSize
,
628 OUT CHAR16
*StringBuffer
,
629 OUT EFI_INPUT_KEY
*KeyValue
,
637 IN FORM_BROWSER_FORMSET
*FormSet
,
638 IN FORM_BROWSER_FORM
*Form
,
639 IN OUT FORM_BROWSER_STATEMENT
*Question
,
646 IN FORM_BROWSER_FORMSET
*FormSet
,
647 IN FORM_BROWSER_FORM
*Form
,
648 IN OUT FORM_BROWSER_STATEMENT
*Question
,
655 IN FORM_BROWSER_FORMSET
*FormSet
,
656 IN FORM_BROWSER_FORM
*Form
,
657 IN FORM_BROWSER_STATEMENT
*Question
,
664 IN FORM_BROWSER_FORMSET
*FormSet
,
665 IN FORM_BROWSER_FORM
*Form
671 IN FORM_BROWSER_FORMSET
*FormSet
,
672 IN FORM_BROWSER_FORM
*Form
,
673 IN FORM_BROWSER_STATEMENT
*Question
,
679 InitializeCurrentSetting (
680 IN OUT FORM_BROWSER_FORMSET
*FormSet
686 IN EFI_HII_HANDLE Handle
,
687 IN OUT EFI_GUID
*FormSetGuid
,
688 OUT FORM_BROWSER_FORMSET
*FormSet
694 IN FORM_BROWSER_FORMSET
*FormSet
,
695 IN FORM_BROWSER_FORM
*Form
,
702 IN FORM_BROWSER_FORMSET
*FormSet
,
703 IN FORM_BROWSER_FORM
*Form
708 StorageToConfigResp (
709 IN FORMSET_STORAGE
*Storage
,
710 IN CHAR16
**ConfigResp
715 ConfigRespToStorage (
716 IN FORMSET_STORAGE
*Storage
,
717 IN CHAR16
*ConfigResp
723 IN FORM_BROWSER_FORMSET
*FormSet
,
724 IN FORMSET_STORAGE
*Storage
730 IN EFI_HII_HANDLE Handle
,
731 IN OUT EFI_GUID
*FormSetGuid
,
732 OUT UINTN
*BinaryLength
,
733 OUT UINT8
**BinaryData
740 IN CONST EFI_FORM_BROWSER2_PROTOCOL
*This
,
741 IN EFI_HII_HANDLE
*Handles
,
742 IN UINTN HandleCount
,
743 IN EFI_GUID
*FormSetGuid
, OPTIONAL
744 IN UINT16 FormId
, OPTIONAL
745 IN CONST EFI_SCREEN_DESCRIPTOR
*ScreenDimensions
, OPTIONAL
746 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest OPTIONAL
753 IN CONST EFI_FORM_BROWSER2_PROTOCOL
*This
,
754 IN OUT UINTN
*ResultsDataSize
,
755 IN OUT EFI_STRING ResultsData
,
756 IN BOOLEAN RetrieveData
,
757 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
758 IN CONST CHAR16
*VariableName OPTIONAL