2 Entry and initialization module for the browser.
4 Copyright (c) 2007 - 2016, 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.
17 SETUP_DRIVER_PRIVATE_DATA mPrivateData
= {
18 SETUP_DRIVER_SIGNATURE
,
31 BROWSER_EXTENSION2_VERSION_1_1
,
35 IsBrowserDataModified
,
43 EFI_HII_DATABASE_PROTOCOL
*mHiiDatabase
;
44 EFI_HII_CONFIG_ROUTING_PROTOCOL
*mHiiConfigRouting
;
45 EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL
*mPathFromText
;
46 EDKII_FORM_DISPLAY_ENGINE_PROTOCOL
*mFormDisplay
;
48 UINTN gBrowserContextCount
= 0;
49 LIST_ENTRY gBrowserContextList
= INITIALIZE_LIST_HEAD_VARIABLE (gBrowserContextList
);
50 LIST_ENTRY gBrowserFormSetList
= INITIALIZE_LIST_HEAD_VARIABLE (gBrowserFormSetList
);
51 LIST_ENTRY gBrowserHotKeyList
= INITIALIZE_LIST_HEAD_VARIABLE (gBrowserHotKeyList
);
52 LIST_ENTRY gBrowserStorageList
= INITIALIZE_LIST_HEAD_VARIABLE (gBrowserStorageList
);
53 LIST_ENTRY gBrowserSaveFailFormSetList
= INITIALIZE_LIST_HEAD_VARIABLE (gBrowserSaveFailFormSetList
);
55 BOOLEAN mSystemSubmit
= FALSE
;
56 BOOLEAN gResetRequired
;
57 BOOLEAN gExitRequired
;
58 BOOLEAN gFlagReconnect
;
59 BOOLEAN gCallbackReconnect
;
60 BROWSER_SETTING_SCOPE gBrowserSettingScope
= FormSetLevel
;
61 BOOLEAN mBrowserScopeFirstSet
= TRUE
;
62 EXIT_HANDLER ExitHandlerFunction
= NULL
;
63 FORM_BROWSER_FORMSET
*mSystemLevelFormSet
;
66 // Browser Global Strings
69 CHAR16
*mUnknownString
= L
"!";
71 extern EFI_GUID mCurrentFormSetGuid
;
72 extern EFI_HII_HANDLE mCurrentHiiHandle
;
73 extern UINT16 mCurrentFormId
;
74 extern FORM_DISPLAY_ENGINE_FORM gDisplayFormData
;
77 Create a menu with specified formset GUID and form ID, and add it as a child
78 of the given parent menu.
80 @param HiiHandle Hii handle related to this formset.
81 @param FormSetGuid The Formset Guid of menu to be added.
82 @param FormId The Form ID of menu to be added.
83 @param QuestionId The question id of this menu to be added.
85 @return A pointer to the newly added menu or NULL if memory is insufficient.
90 IN EFI_HII_HANDLE HiiHandle
,
91 IN EFI_GUID
*FormSetGuid
,
96 FORM_ENTRY_INFO
*MenuList
;
98 MenuList
= AllocateZeroPool (sizeof (FORM_ENTRY_INFO
));
99 if (MenuList
== NULL
) {
103 MenuList
->Signature
= FORM_ENTRY_INFO_SIGNATURE
;
105 MenuList
->HiiHandle
= HiiHandle
;
106 CopyMem (&MenuList
->FormSetGuid
, FormSetGuid
, sizeof (EFI_GUID
));
107 MenuList
->FormId
= FormId
;
108 MenuList
->QuestionId
= QuestionId
;
111 // If parent is not specified, it is the root Form of a Formset
113 InsertTailList (&mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
, &MenuList
->Link
);
119 Return the form id for the input hiihandle and formset.
121 @param HiiHandle HiiHandle for FormSet.
122 @param FormSetGuid The Formset GUID of the menu to search.
124 @return First form's id for this form set.
129 IN EFI_HII_HANDLE HiiHandle
,
130 IN EFI_GUID
*FormSetGuid
134 FORM_BROWSER_FORM
*Form
;
136 Link
= GetFirstNode (&gCurrentSelection
->FormSet
->FormListHead
);
137 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
143 Search Menu with given FormSetGuid and FormId in all cached menu list.
145 @param HiiHandle HiiHandle for FormSet.
146 @param FormSetGuid The Formset GUID of the menu to search.
147 @param FormId The Form ID of menu to search.
149 @return A pointer to menu found or NULL if not found.
154 IN EFI_HII_HANDLE HiiHandle
,
155 IN EFI_GUID
*FormSetGuid
,
160 FORM_ENTRY_INFO
*MenuList
;
161 FORM_ENTRY_INFO
*RetMenu
;
162 EFI_FORM_ID FirstFormId
;
166 Link
= GetFirstNode (&mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
);
167 while (!IsNull (&mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
, Link
)) {
168 MenuList
= FORM_ENTRY_INFO_FROM_LINK (Link
);
169 Link
= GetNextNode (&mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
, Link
);
172 // If already find the menu, free the menus behind it.
174 if (RetMenu
!= NULL
) {
175 RemoveEntryList (&MenuList
->Link
);
181 // Find the same FromSet.
183 if (MenuList
->HiiHandle
== HiiHandle
) {
184 if (CompareGuid (&MenuList
->FormSetGuid
, &gZeroGuid
)) {
186 // FormSetGuid is not specified.
189 } else if (CompareGuid (&MenuList
->FormSetGuid
, FormSetGuid
)) {
190 if (MenuList
->FormId
== FormId
) {
192 } else if (FormId
== 0 || MenuList
->FormId
== 0 ) {
193 FirstFormId
= GetFirstFormId (HiiHandle
, FormSetGuid
);
194 if ((FormId
== 0 && FirstFormId
== MenuList
->FormId
) || (MenuList
->FormId
==0 && FirstFormId
== FormId
)) {
206 Find parent menu for current menu.
208 @param CurrentMenu Current Menu
209 @param SettingLevel Whether find parent menu in Form Level or Formset level.
210 In form level, just find the parent menu;
211 In formset level, find the parent menu which has different
214 @retval The parent menu for current menu.
218 IN FORM_ENTRY_INFO
*CurrentMenu
,
219 IN BROWSER_SETTING_SCOPE SettingLevel
222 FORM_ENTRY_INFO
*ParentMenu
;
225 ASSERT (SettingLevel
== FormLevel
|| SettingLevel
== FormSetLevel
);
227 if (CurrentMenu
== NULL
) {
232 Link
= &CurrentMenu
->Link
;
234 while (Link
->BackLink
!= &mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
) {
235 ParentMenu
= FORM_ENTRY_INFO_FROM_LINK (Link
->BackLink
);
237 if (SettingLevel
== FormLevel
) {
239 // For FormLevel, just find the parent menu, return.
244 if (!CompareGuid (&CurrentMenu
->FormSetGuid
, &ParentMenu
->FormSetGuid
)) {
246 // For SystemLevel, must find the menu which has different formset.
251 Link
= Link
->BackLink
;
255 // Not find the parent menu, just return NULL.
257 if (Link
->BackLink
== &mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
) {
265 Free Menu list linked list.
267 @param MenuListHead One Menu list point in the menu list.
272 LIST_ENTRY
*MenuListHead
275 FORM_ENTRY_INFO
*MenuList
;
277 while (!IsListEmpty (MenuListHead
)) {
278 MenuList
= FORM_ENTRY_INFO_FROM_LINK (MenuListHead
->ForwardLink
);
279 RemoveEntryList (&MenuList
->Link
);
286 Copy current Menu list to the new menu list.
288 @param NewMenuListHead New create Menu list.
289 @param CurrentMenuListHead Current Menu list.
294 OUT LIST_ENTRY
*NewMenuListHead
,
295 IN LIST_ENTRY
*CurrentMenuListHead
299 FORM_ENTRY_INFO
*MenuList
;
300 FORM_ENTRY_INFO
*NewMenuEntry
;
303 // If new menu list not empty, free it first.
305 UiFreeMenuList (NewMenuListHead
);
307 Link
= GetFirstNode (CurrentMenuListHead
);
308 while (!IsNull (CurrentMenuListHead
, Link
)) {
309 MenuList
= FORM_ENTRY_INFO_FROM_LINK (Link
);
310 Link
= GetNextNode (CurrentMenuListHead
, Link
);
312 NewMenuEntry
= AllocateZeroPool (sizeof (FORM_ENTRY_INFO
));
313 ASSERT (NewMenuEntry
!= NULL
);
314 NewMenuEntry
->Signature
= FORM_ENTRY_INFO_SIGNATURE
;
315 NewMenuEntry
->HiiHandle
= MenuList
->HiiHandle
;
316 CopyMem (&NewMenuEntry
->FormSetGuid
, &MenuList
->FormSetGuid
, sizeof (EFI_GUID
));
317 NewMenuEntry
->FormId
= MenuList
->FormId
;
318 NewMenuEntry
->QuestionId
= MenuList
->QuestionId
;
320 InsertTailList (NewMenuListHead
, &NewMenuEntry
->Link
);
325 Load all hii formset to the browser.
333 FORM_BROWSER_FORMSET
*LocalFormSet
;
334 EFI_HII_HANDLE
*HiiHandles
;
338 FORM_BROWSER_FORMSET
*OldFormset
;
340 OldFormset
= mSystemLevelFormSet
;
343 // Get all the Hii handles
345 HiiHandles
= HiiGetHiiHandles (NULL
);
346 ASSERT (HiiHandles
!= NULL
);
349 // Search for formset of each class type
351 for (Index
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
353 // Check HiiHandles[Index] does exist in global maintain list.
355 if (GetFormSetFromHiiHandle (HiiHandles
[Index
]) != NULL
) {
360 // Initilize FormSet Setting
362 LocalFormSet
= AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET
));
363 ASSERT (LocalFormSet
!= NULL
);
364 mSystemLevelFormSet
= LocalFormSet
;
366 ZeroMem (&ZeroGuid
, sizeof (ZeroGuid
));
367 Status
= InitializeFormSet (HiiHandles
[Index
], &ZeroGuid
, LocalFormSet
);
368 if (EFI_ERROR (Status
) || IsListEmpty (&LocalFormSet
->FormListHead
)) {
369 DestroyFormSet (LocalFormSet
);
372 InitializeCurrentSetting (LocalFormSet
);
375 // Initilize Questions' Value
377 Status
= LoadFormSetConfig (NULL
, LocalFormSet
);
378 if (EFI_ERROR (Status
)) {
379 DestroyFormSet (LocalFormSet
);
385 // Free resources, and restore gOldFormSet and gClassOfVfr
387 FreePool (HiiHandles
);
389 mSystemLevelFormSet
= OldFormset
;
393 Pop up the error info.
395 @param BrowserStatus The input browser status.
396 @param HiiHandle The Hiihandle for this opcode.
397 @param OpCode The opcode use to get the erro info and timeout value.
398 @param ErrorString Error string used by BROWSER_NO_SUBMIT_IF.
403 IN UINT32 BrowserStatus
,
404 IN EFI_HII_HANDLE HiiHandle
,
405 IN EFI_IFR_OP_HEADER
*OpCode
, OPTIONAL
406 IN CHAR16
*ErrorString
409 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
410 USER_INPUT UserInputData
;
414 if (OpCode
!= NULL
) {
415 Statement
= AllocateZeroPool (sizeof(FORM_DISPLAY_ENGINE_STATEMENT
));
416 ASSERT (Statement
!= NULL
);
417 Statement
->OpCode
= OpCode
;
418 gDisplayFormData
.HighLightedStatement
= Statement
;
422 // Used to compatible with old display engine.
423 // New display engine not use this field.
425 gDisplayFormData
.ErrorString
= ErrorString
;
426 gDisplayFormData
.BrowserStatus
= BrowserStatus
;
428 if (HiiHandle
!= NULL
) {
429 gDisplayFormData
.HiiHandle
= HiiHandle
;
432 mFormDisplay
->FormDisplay (&gDisplayFormData
, &UserInputData
);
434 gDisplayFormData
.BrowserStatus
= BROWSER_SUCCESS
;
435 gDisplayFormData
.ErrorString
= NULL
;
437 if (OpCode
!= NULL
) {
438 FreePool (Statement
);
441 return UserInputData
.Action
;
445 This is the routine which an external caller uses to direct the browser
446 where to obtain it's information.
449 @param This The Form Browser protocol instanse.
450 @param Handles A pointer to an array of Handles. If HandleCount > 1 we
451 display a list of the formsets for the handles specified.
452 @param HandleCount The number of Handles specified in Handle.
453 @param FormSetGuid This field points to the EFI_GUID which must match the Guid
454 field in the EFI_IFR_FORM_SET op-code for the specified
455 forms-based package. If FormSetGuid is NULL, then this
456 function will display the first found forms package.
457 @param FormId This field specifies which EFI_IFR_FORM to render as the first
458 displayable page. If this field has a value of 0x0000, then
459 the forms browser will render the specified forms in their encoded order.
460 @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
462 @param ActionRequest Points to the action recommended by the form.
464 @retval EFI_SUCCESS The function completed successfully.
465 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
466 @retval EFI_NOT_FOUND No valid forms could be found to display.
472 IN CONST EFI_FORM_BROWSER2_PROTOCOL
*This
,
473 IN EFI_HII_HANDLE
*Handles
,
474 IN UINTN HandleCount
,
475 IN EFI_GUID
*FormSetGuid
, OPTIONAL
476 IN UINT16 FormId
, OPTIONAL
477 IN CONST EFI_SCREEN_DESCRIPTOR
*ScreenDimensions
, OPTIONAL
478 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest OPTIONAL
482 UI_MENU_SELECTION
*Selection
;
484 FORM_BROWSER_FORMSET
*FormSet
;
485 FORM_ENTRY_INFO
*MenuList
;
489 // If EDKII_FORM_DISPLAY_ENGINE_PROTOCOL not found, return EFI_UNSUPPORTED.
491 if (mFormDisplay
== NULL
) {
492 DEBUG ((DEBUG_ERROR
, "Fatal Error! EDKII_FORM_DISPLAY_ENGINE_PROTOCOL not found!"));
493 return EFI_UNSUPPORTED
;
497 // Save globals used by SendForm()
499 SaveBrowserContext ();
501 gFlagReconnect
= FALSE
;
502 gResetRequired
= FALSE
;
503 gExitRequired
= FALSE
;
504 gCallbackReconnect
= FALSE
;
505 Status
= EFI_SUCCESS
;
507 gDisplayFormData
.ScreenDimensions
= (EFI_SCREEN_DESCRIPTOR
*) ScreenDimensions
;
509 for (Index
= 0; Index
< HandleCount
; Index
++) {
510 Selection
= AllocateZeroPool (sizeof (UI_MENU_SELECTION
));
511 ASSERT (Selection
!= NULL
);
513 Selection
->Handle
= Handles
[Index
];
514 if (FormSetGuid
!= NULL
) {
515 CopyMem (&Selection
->FormSetGuid
, FormSetGuid
, sizeof (EFI_GUID
));
516 Selection
->FormId
= FormId
;
518 CopyMem (&Selection
->FormSetGuid
, &gEfiHiiPlatformSetupFormsetGuid
, sizeof (EFI_GUID
));
522 FormSet
= AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET
));
523 ASSERT (FormSet
!= NULL
);
526 // Validate the HiiHandle
527 // if validate failed, find the first validate parent HiiHandle.
529 if (!ValidateHiiHandle(Selection
->Handle
)) {
530 FindNextMenu (Selection
, FormSetLevel
);
534 // Initialize internal data structures of FormSet
536 Status
= InitializeFormSet (Selection
->Handle
, &Selection
->FormSetGuid
, FormSet
);
537 if (EFI_ERROR (Status
) || IsListEmpty (&FormSet
->FormListHead
)) {
538 DestroyFormSet (FormSet
);
541 Selection
->FormSet
= FormSet
;
542 mSystemLevelFormSet
= FormSet
;
545 // Display this formset
547 gCurrentSelection
= Selection
;
549 Status
= SetupBrowser (Selection
);
551 gCurrentSelection
= NULL
;
552 mSystemLevelFormSet
= NULL
;
554 if (gFlagReconnect
|| gCallbackReconnect
) {
555 RetVal
= ReconnectController (FormSet
->DriverHandle
);
557 PopupErrorMessage(BROWSER_RECONNECT_FAIL
, NULL
, NULL
, NULL
);
559 gFlagReconnect
= FALSE
;
560 gCallbackReconnect
= FALSE
;
564 // If no data is changed, don't need to save current FormSet into the maintain list.
566 if (!IsNvUpdateRequiredForFormSet (FormSet
)) {
567 CleanBrowserStorage(FormSet
);
568 RemoveEntryList (&FormSet
->Link
);
569 DestroyFormSet (FormSet
);
572 if (EFI_ERROR (Status
)) {
575 } while (Selection
->Action
== UI_ACTION_REFRESH_FORMSET
);
577 FreePool (Selection
);
580 if (ActionRequest
!= NULL
) {
581 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
582 if (gResetRequired
) {
583 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_RESET
;
587 mFormDisplay
->ExitDisplay();
590 // Clear the menu history data.
592 while (!IsListEmpty (&mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
)) {
593 MenuList
= FORM_ENTRY_INFO_FROM_LINK (mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
.ForwardLink
);
594 RemoveEntryList (&MenuList
->Link
);
599 // Restore globals used by SendForm()
601 RestoreBrowserContext ();
607 Get or set data to the storage.
609 @param ResultsDataSize The size of the buffer associatedwith ResultsData.
610 @param ResultsData A string returned from an IFR browser or
611 equivalent. The results string will have no
612 routing information in them.
613 @param RetrieveData A BOOLEAN field which allows an agent to retrieve
614 (if RetrieveData = TRUE) data from the uncommitted
615 browser state information or set (if RetrieveData
616 = FALSE) data in the uncommitted browser state
618 @param Storage The pointer to the storage.
620 @retval EFI_SUCCESS The results have been distributed or are awaiting
626 IN OUT UINTN
*ResultsDataSize
,
627 IN OUT EFI_STRING
*ResultsData
,
628 IN BOOLEAN RetrieveData
,
629 IN BROWSER_STORAGE
*Storage
638 FORMSET_STORAGE
*BrowserStorage
;
642 // Generate <ConfigResp>
644 Status
= StorageToConfigResp (Storage
, &ConfigResp
, Storage
->ConfigRequest
, TRUE
);
645 if (EFI_ERROR (Status
)) {
650 // Skip <ConfigHdr> and '&' to point to <ConfigBody> when first copy the configbody.
651 // Also need to consider add "\0" at first time.
653 StrPtr
= StrStr (ConfigResp
, L
"PATH");
654 ASSERT (StrPtr
!= NULL
);
655 StrPtr
= StrStr (StrPtr
, L
"&");
657 BufferSize
= StrSize (StrPtr
);
660 // Copy the data if the input buffer is bigger enough.
662 if (*ResultsDataSize
>= BufferSize
) {
663 StrCpyS (*ResultsData
, *ResultsDataSize
/ sizeof (CHAR16
), StrPtr
);
666 *ResultsDataSize
= BufferSize
;
667 FreePool (ConfigResp
);
670 // Prepare <ConfigResp>
672 BrowserStorage
= GetFstStgFromBrsStg (Storage
);
673 ASSERT (BrowserStorage
!= NULL
);
674 TmpSize
= StrLen (*ResultsData
);
675 BufferSize
= (TmpSize
+ StrLen (BrowserStorage
->ConfigHdr
) + 2) * sizeof (CHAR16
);
676 MaxLen
= BufferSize
/ sizeof (CHAR16
);
677 ConfigResp
= AllocateZeroPool (BufferSize
);
678 ASSERT (ConfigResp
!= NULL
);
680 StrCpyS (ConfigResp
, MaxLen
, BrowserStorage
->ConfigHdr
);
681 StrCatS (ConfigResp
, MaxLen
, L
"&");
682 StrCatS (ConfigResp
, MaxLen
, *ResultsData
);
685 // Update Browser uncommited data
687 Status
= ConfigRespToStorage (Storage
, ConfigResp
);
688 FreePool (ConfigResp
);
689 if (EFI_ERROR (Status
)) {
698 This routine called this service in the browser to retrieve or set certain uncommitted
699 state information that resides in the open formsets.
701 @param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL
703 @param ResultsDataSize A pointer to the size of the buffer associated
705 @param ResultsData A string returned from an IFR browser or
706 equivalent. The results string will have no
707 routing information in them.
708 @param RetrieveData A BOOLEAN field which allows an agent to retrieve
709 (if RetrieveData = TRUE) data from the uncommitted
710 browser state information or set (if RetrieveData
711 = FALSE) data in the uncommitted browser state
713 @param VariableGuid An optional field to indicate the target variable
715 @param VariableName An optional field to indicate the target
716 human-readable variable name.
718 @retval EFI_SUCCESS The results have been distributed or are awaiting
720 @retval EFI_BUFFER_TOO_SMALL The ResultsDataSize specified was too small to
721 contain the results data.
727 IN CONST EFI_FORM_BROWSER2_PROTOCOL
*This
,
728 IN OUT UINTN
*ResultsDataSize
,
729 IN OUT EFI_STRING ResultsData
,
730 IN BOOLEAN RetrieveData
,
731 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
732 IN CONST CHAR16
*VariableName OPTIONAL
737 BROWSER_STORAGE
*Storage
;
738 FORMSET_STORAGE
*FormsetStorage
;
742 if (ResultsDataSize
== NULL
|| ResultsData
== NULL
) {
743 return EFI_INVALID_PARAMETER
;
746 TotalSize
= *ResultsDataSize
;
749 Status
= EFI_SUCCESS
;
751 if (VariableGuid
!= NULL
) {
753 // Try to find target storage in the current formset.
755 Link
= GetFirstNode (&gBrowserStorageList
);
756 while (!IsNull (&gBrowserStorageList
, Link
)) {
757 Storage
= BROWSER_STORAGE_FROM_LINK (Link
);
758 Link
= GetNextNode (&gBrowserStorageList
, Link
);
760 // Check the current storage.
762 if (!CompareGuid (&Storage
->Guid
, (EFI_GUID
*) VariableGuid
)) {
766 if (Storage
->Type
== EFI_HII_VARSTORE_BUFFER
||
767 Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
769 // Buffer storage require both GUID and Name
771 if (VariableName
== NULL
) {
772 return EFI_NOT_FOUND
;
775 if (StrCmp (Storage
->Name
, (CHAR16
*) VariableName
) != 0) {
780 if (Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
||
781 Storage
->Type
== EFI_HII_VARSTORE_BUFFER
) {
782 if (mSystemLevelFormSet
== NULL
|| mSystemLevelFormSet
->HiiHandle
== NULL
) {
783 return EFI_NOT_FOUND
;
786 if (Storage
->HiiHandle
!= mSystemLevelFormSet
->HiiHandle
) {
791 Status
= ProcessStorage (&TotalSize
, &ResultsData
, RetrieveData
, Storage
);
792 if (EFI_ERROR (Status
)) {
796 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
797 ConfigRequestAdjust (Storage
, ResultsData
, TRUE
);
801 // Different formsets may have same varstore, so here just set the flag
802 // not exit the circle.
809 return EFI_NOT_FOUND
;
813 // GUID/Name is not specified, take the first storage in FormSet
815 if (mSystemLevelFormSet
== NULL
) {
816 return EFI_NOT_READY
;
820 // Generate <ConfigResp>
822 Link
= GetFirstNode (&mSystemLevelFormSet
->StorageListHead
);
823 if (IsNull (&mSystemLevelFormSet
->StorageListHead
, Link
)) {
824 return EFI_UNSUPPORTED
;
827 FormsetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
829 Status
= ProcessStorage (&TotalSize
, &ResultsData
, RetrieveData
, FormsetStorage
->BrowserStorage
);
830 if (EFI_ERROR (Status
)) {
836 Status
= TotalSize
<= *ResultsDataSize
? EFI_SUCCESS
: EFI_BUFFER_TOO_SMALL
;
837 *ResultsDataSize
= TotalSize
;
846 Callback function for SimpleTextInEx protocol install events
848 @param Event the event that is signaled.
849 @param Context not used here.
854 FormDisplayCallback (
859 if (mFormDisplay
!= NULL
) {
863 gBS
->LocateProtocol (
864 &gEdkiiFormDisplayEngineProtocolGuid
,
866 (VOID
**) &mFormDisplay
871 Initialize Setup Browser driver.
873 @param ImageHandle The image handle.
874 @param SystemTable The system table.
876 @retval EFI_SUCCESS The Setup Browser module is initialized correctly..
877 @return Other value if failed to initialize the Setup Browser module.
883 IN EFI_HANDLE ImageHandle
,
884 IN EFI_SYSTEM_TABLE
*SystemTable
891 // Locate required Hii relative protocols
893 Status
= gBS
->LocateProtocol (
894 &gEfiHiiDatabaseProtocolGuid
,
896 (VOID
**) &mHiiDatabase
898 ASSERT_EFI_ERROR (Status
);
900 Status
= gBS
->LocateProtocol (
901 &gEfiHiiConfigRoutingProtocolGuid
,
903 (VOID
**) &mHiiConfigRouting
905 ASSERT_EFI_ERROR (Status
);
907 Status
= gBS
->LocateProtocol (
908 &gEfiDevicePathFromTextProtocolGuid
,
910 (VOID
**) &mPathFromText
914 // Install FormBrowser2 protocol
916 mPrivateData
.Handle
= NULL
;
917 Status
= gBS
->InstallProtocolInterface (
918 &mPrivateData
.Handle
,
919 &gEfiFormBrowser2ProtocolGuid
,
920 EFI_NATIVE_INTERFACE
,
921 &mPrivateData
.FormBrowser2
923 ASSERT_EFI_ERROR (Status
);
926 // Install FormBrowserEx2 protocol
928 InitializeListHead (&mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
);
929 InitializeListHead (&mPrivateData
.FormBrowserEx2
.OverrideQestListHead
);
930 mPrivateData
.Handle
= NULL
;
931 Status
= gBS
->InstallProtocolInterface (
932 &mPrivateData
.Handle
,
933 &gEdkiiFormBrowserEx2ProtocolGuid
,
934 EFI_NATIVE_INTERFACE
,
935 &mPrivateData
.FormBrowserEx2
937 ASSERT_EFI_ERROR (Status
);
939 Status
= gBS
->InstallProtocolInterface (
940 &mPrivateData
.Handle
,
941 &gEfiFormBrowserExProtocolGuid
,
942 EFI_NATIVE_INTERFACE
,
943 &mPrivateData
.FormBrowserEx
945 ASSERT_EFI_ERROR (Status
);
947 InitializeDisplayFormData ();
949 Status
= gBS
->LocateProtocol (
950 &gEdkiiFormDisplayEngineProtocolGuid
,
952 (VOID
**) &mFormDisplay
955 if (EFI_ERROR (Status
)) {
956 EfiCreateProtocolNotifyEvent (
957 &gEdkiiFormDisplayEngineProtocolGuid
,
970 Create a new string in HII Package List.
972 @param String The String to be added
973 @param HiiHandle The package list in the HII database to insert the
976 @return The output string.
982 IN EFI_HII_HANDLE HiiHandle
985 EFI_STRING_ID StringId
;
987 StringId
= HiiSetString (HiiHandle
, 0, String
, NULL
);
988 ASSERT (StringId
!= 0);
995 Delete a string from HII Package List.
997 @param StringId Id of the string in HII database.
998 @param HiiHandle The HII package list handle.
1000 @retval EFI_SUCCESS The string was deleted successfully.
1005 IN EFI_STRING_ID StringId
,
1006 IN EFI_HII_HANDLE HiiHandle
1011 NullChar
= CHAR_NULL
;
1012 HiiSetString (HiiHandle
, StringId
, &NullChar
, NULL
);
1018 Get the string based on the StringId and HII Package List Handle.
1020 @param Token The String's ID.
1021 @param HiiHandle The package list in the HII database to search for
1022 the specified string.
1024 @return The output string.
1029 IN EFI_STRING_ID Token
,
1030 IN EFI_HII_HANDLE HiiHandle
1035 if (HiiHandle
== NULL
) {
1039 String
= HiiGetString (HiiHandle
, Token
, NULL
);
1040 if (String
== NULL
) {
1041 String
= AllocateCopyPool (StrSize (mUnknownString
), mUnknownString
);
1042 ASSERT (String
!= NULL
);
1044 return (CHAR16
*) String
;
1049 Allocate new memory and then copy the Unicode string Source to Destination.
1051 @param Dest Location to copy string
1052 @param Src String to copy
1057 IN OUT CHAR16
**Dest
,
1061 if (*Dest
!= NULL
) {
1064 *Dest
= AllocateCopyPool (StrSize (Src
), Src
);
1065 ASSERT (*Dest
!= NULL
);
1070 Allocate new memory and concatinate Source on the end of Destination.
1072 @param Dest String to added to the end of.
1073 @param Src String to concatinate.
1078 IN OUT CHAR16
**Dest
,
1085 if (*Dest
== NULL
) {
1086 NewStringCpy (Dest
, Src
);
1090 MaxLen
= ( StrSize (*Dest
) + StrSize (Src
) - 1) / sizeof (CHAR16
);
1091 NewString
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
1092 ASSERT (NewString
!= NULL
);
1094 StrCpyS (NewString
, MaxLen
, *Dest
);
1095 StrCatS (NewString
, MaxLen
, Src
);
1102 Get Value for given Name from a NameValue Storage.
1104 @param Storage The NameValue Storage.
1105 @param Name The Name.
1106 @param Value The retured Value.
1107 @param GetValueFrom Where to get source value, from EditValue or Value.
1109 @retval EFI_SUCCESS Value found for given Name.
1110 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
1115 IN BROWSER_STORAGE
*Storage
,
1117 IN OUT CHAR16
**Value
,
1118 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
1122 NAME_VALUE_NODE
*Node
;
1124 if (GetValueFrom
!= GetSetValueWithEditBuffer
&& GetValueFrom
!= GetSetValueWithBuffer
) {
1125 return EFI_INVALID_PARAMETER
;
1130 Link
= GetFirstNode (&Storage
->NameValueListHead
);
1131 while (!IsNull (&Storage
->NameValueListHead
, Link
)) {
1132 Node
= NAME_VALUE_NODE_FROM_LINK (Link
);
1134 if (StrCmp (Name
, Node
->Name
) == 0) {
1135 if (GetValueFrom
== GetSetValueWithEditBuffer
) {
1136 NewStringCpy (Value
, Node
->EditValue
);
1138 NewStringCpy (Value
, Node
->Value
);
1143 Link
= GetNextNode (&Storage
->NameValueListHead
, Link
);
1146 return EFI_NOT_FOUND
;
1151 Set Value of given Name in a NameValue Storage.
1153 @param Storage The NameValue Storage.
1154 @param Name The Name.
1155 @param Value The Value to set.
1156 @param SetValueTo Whether update editValue or Value.
1157 @param ReturnNode The node use the input name.
1159 @retval EFI_SUCCESS Value found for given Name.
1160 @retval EFI_NOT_FOUND No such Name found in NameValue storage.
1165 IN BROWSER_STORAGE
*Storage
,
1168 IN GET_SET_QUESTION_VALUE_WITH SetValueTo
,
1169 OUT NAME_VALUE_NODE
**ReturnNode
1173 NAME_VALUE_NODE
*Node
;
1176 if (SetValueTo
!= GetSetValueWithEditBuffer
&& SetValueTo
!= GetSetValueWithBuffer
) {
1177 return EFI_INVALID_PARAMETER
;
1180 Link
= GetFirstNode (&Storage
->NameValueListHead
);
1181 while (!IsNull (&Storage
->NameValueListHead
, Link
)) {
1182 Node
= NAME_VALUE_NODE_FROM_LINK (Link
);
1184 if (StrCmp (Name
, Node
->Name
) == 0) {
1185 if (SetValueTo
== GetSetValueWithEditBuffer
) {
1186 Buffer
= Node
->EditValue
;
1188 Buffer
= Node
->Value
;
1190 if (Buffer
!= NULL
) {
1193 Buffer
= AllocateCopyPool (StrSize (Value
), Value
);
1194 ASSERT (Buffer
!= NULL
);
1195 if (SetValueTo
== GetSetValueWithEditBuffer
) {
1196 Node
->EditValue
= Buffer
;
1198 Node
->Value
= Buffer
;
1201 if (ReturnNode
!= NULL
) {
1208 Link
= GetNextNode (&Storage
->NameValueListHead
, Link
);
1211 return EFI_NOT_FOUND
;
1216 Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
1218 @param Storage The Storage to be conveted.
1219 @param ConfigResp The returned <ConfigResp>.
1220 @param ConfigRequest The ConfigRequest string.
1221 @param GetEditBuf Get the data from editbuffer or buffer.
1223 @retval EFI_SUCCESS Convert success.
1224 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1228 StorageToConfigResp (
1229 IN BROWSER_STORAGE
*Storage
,
1230 IN CHAR16
**ConfigResp
,
1231 IN CHAR16
*ConfigRequest
,
1232 IN BOOLEAN GetEditBuf
1236 EFI_STRING Progress
;
1238 NAME_VALUE_NODE
*Node
;
1240 FORMSET_STORAGE
*FormsetStorage
;
1242 Status
= EFI_SUCCESS
;
1244 switch (Storage
->Type
) {
1245 case EFI_HII_VARSTORE_BUFFER
:
1246 case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
:
1247 SourceBuf
= GetEditBuf
? Storage
->EditBuffer
: Storage
->Buffer
;
1248 Status
= mHiiConfigRouting
->BlockToConfig (
1258 case EFI_HII_VARSTORE_NAME_VALUE
:
1260 FormsetStorage
= GetFstStgFromBrsStg(Storage
);
1261 ASSERT (FormsetStorage
!= NULL
);
1262 NewStringCat (ConfigResp
, FormsetStorage
->ConfigHdr
);
1264 Link
= GetFirstNode (&Storage
->NameValueListHead
);
1265 while (!IsNull (&Storage
->NameValueListHead
, Link
)) {
1266 Node
= NAME_VALUE_NODE_FROM_LINK (Link
);
1268 if (StrStr (ConfigRequest
, Node
->Name
) != NULL
) {
1269 NewStringCat (ConfigResp
, L
"&");
1270 NewStringCat (ConfigResp
, Node
->Name
);
1271 NewStringCat (ConfigResp
, L
"=");
1273 NewStringCat (ConfigResp
, Node
->EditValue
);
1275 NewStringCat (ConfigResp
, Node
->Value
);
1278 Link
= GetNextNode (&Storage
->NameValueListHead
, Link
);
1282 case EFI_HII_VARSTORE_EFI_VARIABLE
:
1284 Status
= EFI_INVALID_PARAMETER
;
1293 Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.
1295 @param Storage The Storage to receive the settings.
1296 @param ConfigResp The <ConfigResp> to be converted.
1298 @retval EFI_SUCCESS Convert success.
1299 @retval EFI_INVALID_PARAMETER Incorrect storage type.
1303 ConfigRespToStorage (
1304 IN BROWSER_STORAGE
*Storage
,
1305 IN CHAR16
*ConfigResp
1309 EFI_STRING Progress
;
1315 Status
= EFI_SUCCESS
;
1317 switch (Storage
->Type
) {
1318 case EFI_HII_VARSTORE_BUFFER
:
1319 case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
:
1320 BufferSize
= Storage
->Size
;
1321 Status
= mHiiConfigRouting
->ConfigToBlock (
1324 Storage
->EditBuffer
,
1330 case EFI_HII_VARSTORE_NAME_VALUE
:
1331 StrPtr
= StrStr (ConfigResp
, L
"PATH");
1332 if (StrPtr
== NULL
) {
1335 StrPtr
= StrStr (ConfigResp
, L
"&");
1336 while (StrPtr
!= NULL
) {
1340 StrPtr
= StrPtr
+ 1;
1342 StrPtr
= StrStr (StrPtr
, L
"=");
1343 if (StrPtr
== NULL
) {
1351 StrPtr
= StrPtr
+ 1;
1353 StrPtr
= StrStr (StrPtr
, L
"&");
1354 if (StrPtr
!= NULL
) {
1357 SetValueByName (Storage
, Name
, Value
, GetSetValueWithEditBuffer
, NULL
);
1361 case EFI_HII_VARSTORE_EFI_VARIABLE
:
1363 Status
= EFI_INVALID_PARAMETER
;
1371 Convert the buffer value to HiiValue.
1373 @param Question The question.
1374 @param Value Unicode buffer save the question value.
1376 @retval Status whether convert the value success.
1381 IN OUT FORM_BROWSER_STATEMENT
*Question
,
1386 BOOLEAN IsBufferStorage
;
1398 IsString
= (BOOLEAN
) ((Question
->HiiValue
.Type
== EFI_IFR_TYPE_STRING
) ? TRUE
: FALSE
);
1399 if (Question
->Storage
->Type
== EFI_HII_VARSTORE_BUFFER
||
1400 Question
->Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
1401 IsBufferStorage
= TRUE
;
1403 IsBufferStorage
= FALSE
;
1407 // Question Value is provided by Buffer Storage or NameValue Storage
1409 if (Question
->BufferValue
!= NULL
) {
1411 // This Question is password or orderedlist
1413 Dst
= Question
->BufferValue
;
1416 // Other type of Questions
1418 Dst
= (UINT8
*) &Question
->HiiValue
.Value
;
1422 // Temp cut at the end of this section, end with '\0' or '&'.
1425 while (*StringPtr
!= L
'\0' && *StringPtr
!= L
'&') {
1428 TempChar
= *StringPtr
;
1431 LengthStr
= StrLen (Value
);
1432 Status
= EFI_SUCCESS
;
1433 if (!IsBufferStorage
&& IsString
) {
1435 // Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD"
1436 // Add string tail char L'\0' into Length
1438 Length
= Question
->StorageWidth
+ sizeof (CHAR16
);
1439 if (Length
< ((LengthStr
/ 4 + 1) * 2)) {
1440 Status
= EFI_BUFFER_TOO_SMALL
;
1442 DstBuf
= (CHAR16
*) Dst
;
1443 ZeroMem (TemStr
, sizeof (TemStr
));
1444 for (Index
= 0; Index
< LengthStr
; Index
+= 4) {
1445 StrnCpyS (TemStr
, sizeof (TemStr
) / sizeof (CHAR16
), Value
+ Index
, 4);
1446 DstBuf
[Index
/4] = (CHAR16
) StrHexToUint64 (TemStr
);
1449 // Add tailing L'\0' character
1451 DstBuf
[Index
/4] = L
'\0';
1454 if (Question
->StorageWidth
< ((LengthStr
+ 1) / 2)) {
1455 Status
= EFI_BUFFER_TOO_SMALL
;
1457 ZeroMem (TemStr
, sizeof (TemStr
));
1458 for (Index
= 0; Index
< LengthStr
; Index
++) {
1459 TemStr
[0] = Value
[LengthStr
- Index
- 1];
1460 DigitUint8
= (UINT8
) StrHexToUint64 (TemStr
);
1461 if ((Index
& 1) == 0) {
1462 Dst
[Index
/2] = DigitUint8
;
1464 Dst
[Index
/2] = (UINT8
) ((DigitUint8
<< 4) + Dst
[Index
/2]);
1470 *StringPtr
= TempChar
;
1476 Get Question's current Value.
1478 @param FormSet FormSet data structure.
1479 @param Form Form data structure.
1480 @param Question Question to be initialized.
1481 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
1483 @retval EFI_SUCCESS The function completed successfully.
1488 IN FORM_BROWSER_FORMSET
*FormSet
,
1489 IN FORM_BROWSER_FORM
*Form
,
1490 IN OUT FORM_BROWSER_STATEMENT
*Question
,
1491 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
1500 BROWSER_STORAGE
*Storage
;
1501 FORMSET_STORAGE
*FormsetStorage
;
1502 EFI_IFR_TYPE_VALUE
*QuestionValue
;
1503 CHAR16
*ConfigRequest
;
1508 BOOLEAN IsBufferStorage
;
1511 Status
= EFI_SUCCESS
;
1515 if (GetValueFrom
>= GetSetValueWithMax
) {
1516 return EFI_INVALID_PARAMETER
;
1520 // Question value is provided by an Expression, evaluate it
1522 if (Question
->ValueExpression
!= NULL
) {
1523 Status
= EvaluateExpression (FormSet
, Form
, Question
->ValueExpression
);
1524 if (!EFI_ERROR (Status
)) {
1525 if (Question
->ValueExpression
->Result
.Type
== EFI_IFR_TYPE_BUFFER
) {
1526 ASSERT (Question
->HiiValue
.Type
== EFI_IFR_TYPE_BUFFER
&& Question
->HiiValue
.Buffer
!= NULL
);
1527 if (Question
->StorageWidth
> Question
->ValueExpression
->Result
.BufferLen
) {
1528 CopyMem (Question
->HiiValue
.Buffer
, Question
->ValueExpression
->Result
.Buffer
, Question
->ValueExpression
->Result
.BufferLen
);
1529 Question
->HiiValue
.BufferLen
= Question
->ValueExpression
->Result
.BufferLen
;
1531 CopyMem (Question
->HiiValue
.Buffer
, Question
->ValueExpression
->Result
.Buffer
, Question
->StorageWidth
);
1532 Question
->HiiValue
.BufferLen
= Question
->StorageWidth
;
1534 FreePool (Question
->ValueExpression
->Result
.Buffer
);
1536 Question
->HiiValue
.Type
= Question
->ValueExpression
->Result
.Type
;
1537 CopyMem (&Question
->HiiValue
.Value
, &Question
->ValueExpression
->Result
.Value
, sizeof (EFI_IFR_TYPE_VALUE
));
1543 // Get question value by read expression.
1545 if (Question
->ReadExpression
!= NULL
&& Form
->FormType
== STANDARD_MAP_FORM_TYPE
) {
1546 Status
= EvaluateExpression (FormSet
, Form
, Question
->ReadExpression
);
1547 if (!EFI_ERROR (Status
) &&
1548 ((Question
->ReadExpression
->Result
.Type
< EFI_IFR_TYPE_OTHER
) || (Question
->ReadExpression
->Result
.Type
== EFI_IFR_TYPE_BUFFER
))) {
1550 // Only update question value to the valid result.
1552 if (Question
->ReadExpression
->Result
.Type
== EFI_IFR_TYPE_BUFFER
) {
1553 ASSERT (Question
->HiiValue
.Type
== EFI_IFR_TYPE_BUFFER
&& Question
->HiiValue
.Buffer
!= NULL
);
1554 if (Question
->StorageWidth
> Question
->ReadExpression
->Result
.BufferLen
) {
1555 CopyMem (Question
->HiiValue
.Buffer
, Question
->ReadExpression
->Result
.Buffer
, Question
->ReadExpression
->Result
.BufferLen
);
1556 Question
->HiiValue
.BufferLen
= Question
->ReadExpression
->Result
.BufferLen
;
1558 CopyMem (Question
->HiiValue
.Buffer
, Question
->ReadExpression
->Result
.Buffer
, Question
->StorageWidth
);
1559 Question
->HiiValue
.BufferLen
= Question
->StorageWidth
;
1561 FreePool (Question
->ReadExpression
->Result
.Buffer
);
1563 Question
->HiiValue
.Type
= Question
->ReadExpression
->Result
.Type
;
1564 CopyMem (&Question
->HiiValue
.Value
, &Question
->ReadExpression
->Result
.Value
, sizeof (EFI_IFR_TYPE_VALUE
));
1570 // Question value is provided by RTC
1572 Storage
= Question
->Storage
;
1573 QuestionValue
= &Question
->HiiValue
.Value
;
1574 if (Storage
== NULL
) {
1576 // It's a Question without storage, or RTC date/time
1578 if (Question
->Operand
== EFI_IFR_DATE_OP
|| Question
->Operand
== EFI_IFR_TIME_OP
) {
1580 // Date and time define the same Flags bit
1582 switch (Question
->Flags
& EFI_QF_DATE_STORAGE
) {
1583 case QF_DATE_STORAGE_TIME
:
1584 Status
= gRT
->GetTime (&EfiTime
, NULL
);
1587 case QF_DATE_STORAGE_WAKEUP
:
1588 Status
= gRT
->GetWakeupTime (&Enabled
, &Pending
, &EfiTime
);
1591 case QF_DATE_STORAGE_NORMAL
:
1594 // For date/time without storage
1599 if (EFI_ERROR (Status
)) {
1600 if (Question
->Operand
== EFI_IFR_DATE_OP
){
1601 QuestionValue
->date
.Year
= 0xff;
1602 QuestionValue
->date
.Month
= 0xff;
1603 QuestionValue
->date
.Day
= 0xff;
1605 QuestionValue
->time
.Hour
= 0xff;
1606 QuestionValue
->time
.Minute
= 0xff;
1607 QuestionValue
->time
.Second
= 0xff;
1612 if (Question
->Operand
== EFI_IFR_DATE_OP
) {
1613 QuestionValue
->date
.Year
= EfiTime
.Year
;
1614 QuestionValue
->date
.Month
= EfiTime
.Month
;
1615 QuestionValue
->date
.Day
= EfiTime
.Day
;
1617 QuestionValue
->time
.Hour
= EfiTime
.Hour
;
1618 QuestionValue
->time
.Minute
= EfiTime
.Minute
;
1619 QuestionValue
->time
.Second
= EfiTime
.Second
;
1627 // Question value is provided by EFI variable
1629 StorageWidth
= Question
->StorageWidth
;
1630 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
1631 if (Question
->BufferValue
!= NULL
) {
1632 Dst
= Question
->BufferValue
;
1634 Dst
= (UINT8
*) QuestionValue
;
1637 Status
= gRT
->GetVariable (
1638 Question
->VariableName
,
1645 // Always return success, even this EFI variable doesn't exist
1651 // Question Value is provided by Buffer Storage or NameValue Storage
1653 if (Question
->BufferValue
!= NULL
) {
1655 // This Question is password or orderedlist
1657 Dst
= Question
->BufferValue
;
1660 // Other type of Questions
1662 Dst
= (UINT8
*) &Question
->HiiValue
.Value
;
1665 if (Storage
->Type
== EFI_HII_VARSTORE_BUFFER
||
1666 Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
1667 IsBufferStorage
= TRUE
;
1669 IsBufferStorage
= FALSE
;
1671 if (GetValueFrom
== GetSetValueWithEditBuffer
|| GetValueFrom
== GetSetValueWithBuffer
) {
1672 if (IsBufferStorage
) {
1673 if (GetValueFrom
== GetSetValueWithEditBuffer
) {
1675 // Copy from storage Edit buffer
1677 CopyMem (Dst
, Storage
->EditBuffer
+ Question
->VarStoreInfo
.VarOffset
, StorageWidth
);
1680 // Copy from storage Edit buffer
1682 CopyMem (Dst
, Storage
->Buffer
+ Question
->VarStoreInfo
.VarOffset
, StorageWidth
);
1686 Status
= GetValueByName (Storage
, Question
->VariableName
, &Value
, GetValueFrom
);
1687 if (EFI_ERROR (Status
)) {
1691 ASSERT (Value
!= NULL
);
1692 Status
= BufferToValue (Question
, Value
);
1696 FormsetStorage
= GetFstStgFromVarId(FormSet
, Question
->VarStoreId
);
1697 ASSERT (FormsetStorage
!= NULL
);
1699 // <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||
1700 // <ConfigHdr> + "&" + <VariableName>
1702 if (IsBufferStorage
) {
1703 Length
= StrLen (FormsetStorage
->ConfigHdr
);
1704 Length
+= StrLen (Question
->BlockName
);
1706 Length
= StrLen (FormsetStorage
->ConfigHdr
);
1707 Length
+= StrLen (Question
->VariableName
) + 1;
1709 // Allocate buffer include '\0'
1710 MaxLen
= Length
+ 1;
1711 ConfigRequest
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
1712 ASSERT (ConfigRequest
!= NULL
);
1714 StrCpyS (ConfigRequest
, MaxLen
, FormsetStorage
->ConfigHdr
);
1715 if (IsBufferStorage
) {
1716 StrCatS (ConfigRequest
, MaxLen
, Question
->BlockName
);
1718 StrCatS (ConfigRequest
, MaxLen
, L
"&");
1719 StrCatS (ConfigRequest
, MaxLen
, Question
->VariableName
);
1723 // Request current settings from Configuration Driver
1725 Status
= mHiiConfigRouting
->ExtractConfig (
1731 FreePool (ConfigRequest
);
1732 if (EFI_ERROR (Status
)) {
1737 // Skip <ConfigRequest>
1739 if (IsBufferStorage
) {
1740 Value
= StrStr (Result
, L
"&VALUE");
1741 if (Value
== NULL
) {
1743 return EFI_NOT_FOUND
;
1750 Value
= Result
+ Length
;
1752 if (*Value
!= '=') {
1754 return EFI_NOT_FOUND
;
1757 // Skip '=', point to value
1761 Status
= BufferToValue (Question
, Value
);
1762 if (EFI_ERROR (Status
)) {
1768 // Synchronize Edit Buffer
1770 if (IsBufferStorage
) {
1771 CopyMem (Storage
->EditBuffer
+ Question
->VarStoreInfo
.VarOffset
, Dst
, StorageWidth
);
1773 SetValueByName (Storage
, Question
->VariableName
, Value
, GetSetValueWithEditBuffer
, NULL
);
1776 if (Result
!= NULL
) {
1786 Save Question Value to edit copy(cached) or Storage(uncached).
1788 @param FormSet FormSet data structure.
1789 @param Form Form data structure.
1790 @param Question Pointer to the Question.
1791 @param SetValueTo Update the question value to editbuffer , buffer or hii driver.
1793 @retval EFI_SUCCESS The function completed successfully.
1798 IN FORM_BROWSER_FORMSET
*FormSet
,
1799 IN FORM_BROWSER_FORM
*Form
,
1800 IN OUT FORM_BROWSER_STATEMENT
*Question
,
1801 IN GET_SET_QUESTION_VALUE_WITH SetValueTo
1811 BROWSER_STORAGE
*Storage
;
1812 FORMSET_STORAGE
*FormsetStorage
;
1813 EFI_IFR_TYPE_VALUE
*QuestionValue
;
1818 BOOLEAN IsBufferStorage
;
1824 NAME_VALUE_NODE
*Node
;
1827 Status
= EFI_SUCCESS
;
1830 if (SetValueTo
>= GetSetValueWithMax
) {
1831 return EFI_INVALID_PARAMETER
;
1835 // If Question value is provided by an Expression, then it is read only
1837 if (Question
->ValueExpression
!= NULL
) {
1842 // Before set question value, evaluate its write expression.
1844 if (Question
->WriteExpression
!= NULL
&& Form
->FormType
== STANDARD_MAP_FORM_TYPE
) {
1845 Status
= EvaluateExpression (FormSet
, Form
, Question
->WriteExpression
);
1846 if (EFI_ERROR (Status
)) {
1852 // Question value is provided by RTC
1854 Storage
= Question
->Storage
;
1855 QuestionValue
= &Question
->HiiValue
.Value
;
1856 if (Storage
== NULL
) {
1858 // It's a Question without storage, or RTC date/time
1860 if (Question
->Operand
== EFI_IFR_DATE_OP
|| Question
->Operand
== EFI_IFR_TIME_OP
) {
1862 // Date and time define the same Flags bit
1864 switch (Question
->Flags
& EFI_QF_DATE_STORAGE
) {
1865 case QF_DATE_STORAGE_TIME
:
1866 Status
= gRT
->GetTime (&EfiTime
, NULL
);
1869 case QF_DATE_STORAGE_WAKEUP
:
1870 Status
= gRT
->GetWakeupTime (&Enabled
, &Pending
, &EfiTime
);
1873 case QF_DATE_STORAGE_NORMAL
:
1876 // For date/time without storage
1881 if (EFI_ERROR (Status
)) {
1885 if (Question
->Operand
== EFI_IFR_DATE_OP
) {
1886 EfiTime
.Year
= QuestionValue
->date
.Year
;
1887 EfiTime
.Month
= QuestionValue
->date
.Month
;
1888 EfiTime
.Day
= QuestionValue
->date
.Day
;
1890 EfiTime
.Hour
= QuestionValue
->time
.Hour
;
1891 EfiTime
.Minute
= QuestionValue
->time
.Minute
;
1892 EfiTime
.Second
= QuestionValue
->time
.Second
;
1895 if ((Question
->Flags
& EFI_QF_DATE_STORAGE
) == QF_DATE_STORAGE_TIME
) {
1896 Status
= gRT
->SetTime (&EfiTime
);
1898 Status
= gRT
->SetWakeupTime (TRUE
, &EfiTime
);
1906 // Question value is provided by EFI variable
1908 StorageWidth
= Question
->StorageWidth
;
1909 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
1910 if (Question
->BufferValue
!= NULL
) {
1911 Src
= Question
->BufferValue
;
1913 Src
= (UINT8
*) QuestionValue
;
1916 Status
= gRT
->SetVariable (
1917 Question
->VariableName
,
1919 Storage
->Attributes
,
1927 // Question Value is provided by Buffer Storage or NameValue Storage
1929 if (Question
->BufferValue
!= NULL
) {
1930 Src
= Question
->BufferValue
;
1932 Src
= (UINT8
*) &Question
->HiiValue
.Value
;
1935 if (Storage
->Type
== EFI_HII_VARSTORE_BUFFER
||
1936 Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
1937 IsBufferStorage
= TRUE
;
1939 IsBufferStorage
= FALSE
;
1941 IsString
= (BOOLEAN
) ((Question
->HiiValue
.Type
== EFI_IFR_TYPE_STRING
) ? TRUE
: FALSE
);
1943 if (SetValueTo
== GetSetValueWithEditBuffer
|| SetValueTo
== GetSetValueWithBuffer
) {
1944 if (IsBufferStorage
) {
1945 if (SetValueTo
== GetSetValueWithEditBuffer
) {
1947 // Copy to storage edit buffer
1949 CopyMem (Storage
->EditBuffer
+ Question
->VarStoreInfo
.VarOffset
, Src
, StorageWidth
);
1950 } else if (SetValueTo
== GetSetValueWithBuffer
) {
1952 // Copy to storage edit buffer
1954 CopyMem (Storage
->Buffer
+ Question
->VarStoreInfo
.VarOffset
, Src
, StorageWidth
);
1959 // Allocate enough string buffer.
1962 BufferLen
= ((StrLen ((CHAR16
*) Src
) * 4) + 1) * sizeof (CHAR16
);
1963 Value
= AllocateZeroPool (BufferLen
);
1964 ASSERT (Value
!= NULL
);
1966 // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"
1968 TemName
= (CHAR16
*) Src
;
1970 for (; *TemName
!= L
'\0'; TemName
++) {
1971 TemString
+= UnicodeValueToString (TemString
, PREFIX_ZERO
| RADIX_HEX
, *TemName
, 4);
1974 BufferLen
= StorageWidth
* 2 + 1;
1975 Value
= AllocateZeroPool (BufferLen
* sizeof (CHAR16
));
1976 ASSERT (Value
!= NULL
);
1978 // Convert Buffer to Hex String
1980 TemBuffer
= Src
+ StorageWidth
- 1;
1982 for (Index
= 0; Index
< StorageWidth
; Index
++, TemBuffer
--) {
1983 TemString
+= UnicodeValueToString (TemString
, PREFIX_ZERO
| RADIX_HEX
, *TemBuffer
, 2);
1987 Status
= SetValueByName (Storage
, Question
->VariableName
, Value
, SetValueTo
, &Node
);
1989 if (EFI_ERROR (Status
)) {
1993 } else if (SetValueTo
== GetSetValueWithHiiDriver
) {
1995 // <ConfigResp> ::= <ConfigHdr> + <BlockName> + "&VALUE=" + "<HexCh>StorageWidth * 2" ||
1996 // <ConfigHdr> + "&" + <VariableName> + "=" + "<string>"
1998 if (IsBufferStorage
) {
1999 Length
= StrLen (Question
->BlockName
) + 7;
2001 Length
= StrLen (Question
->VariableName
) + 2;
2003 if (!IsBufferStorage
&& IsString
) {
2004 Length
+= (StrLen ((CHAR16
*) Src
) * 4);
2006 Length
+= (StorageWidth
* 2);
2008 FormsetStorage
= GetFstStgFromVarId(FormSet
, Question
->VarStoreId
);
2009 ASSERT (FormsetStorage
!= NULL
);
2010 MaxLen
= StrLen (FormsetStorage
->ConfigHdr
) + Length
+ 1;
2011 ConfigResp
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
2012 ASSERT (ConfigResp
!= NULL
);
2014 StrCpyS (ConfigResp
, MaxLen
, FormsetStorage
->ConfigHdr
);
2015 if (IsBufferStorage
) {
2016 StrCatS (ConfigResp
, MaxLen
, Question
->BlockName
);
2017 StrCatS (ConfigResp
, MaxLen
, L
"&VALUE=");
2019 StrCatS (ConfigResp
, MaxLen
, L
"&");
2020 StrCatS (ConfigResp
, MaxLen
, Question
->VariableName
);
2021 StrCatS (ConfigResp
, MaxLen
, L
"=");
2024 Value
= ConfigResp
+ StrLen (ConfigResp
);
2026 if (!IsBufferStorage
&& IsString
) {
2028 // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"
2030 TemName
= (CHAR16
*) Src
;
2032 for (; *TemName
!= L
'\0'; TemName
++) {
2033 TemString
+= UnicodeValueToString (TemString
, PREFIX_ZERO
| RADIX_HEX
, *TemName
, 4);
2037 // Convert Buffer to Hex String
2039 TemBuffer
= Src
+ StorageWidth
- 1;
2041 for (Index
= 0; Index
< StorageWidth
; Index
++, TemBuffer
--) {
2042 TemString
+= UnicodeValueToString (TemString
, PREFIX_ZERO
| RADIX_HEX
, *TemBuffer
, 2);
2047 // Convert to lower char.
2049 for (TemString
= Value
; *Value
!= L
'\0'; Value
++) {
2050 if (*Value
>= L
'A' && *Value
<= L
'Z') {
2051 *Value
= (CHAR16
) (*Value
- L
'A' + L
'a');
2056 // Submit Question Value to Configuration Driver
2058 Status
= mHiiConfigRouting
->RouteConfig (
2063 if (EFI_ERROR (Status
)) {
2064 FreePool (ConfigResp
);
2067 FreePool (ConfigResp
);
2070 // Sync storage, from editbuffer to buffer.
2072 CopyMem (Storage
->Buffer
+ Question
->VarStoreInfo
.VarOffset
, Src
, StorageWidth
);
2080 Perform nosubmitif check for a Form.
2082 @param FormSet FormSet data structure.
2083 @param Form Form data structure.
2084 @param Question The Question to be validated.
2085 @param Type Validation type: NoSubmit
2087 @retval EFI_SUCCESS Form validation pass.
2088 @retval other Form validation failed.
2093 IN FORM_BROWSER_FORMSET
*FormSet
,
2094 IN FORM_BROWSER_FORM
*Form
,
2095 IN FORM_BROWSER_STATEMENT
*Question
,
2101 LIST_ENTRY
*ListHead
;
2102 FORM_EXPRESSION
*Expression
;
2103 UINT32 BrowserStatus
;
2106 BrowserStatus
= BROWSER_SUCCESS
;
2110 case EFI_HII_EXPRESSION_INCONSISTENT_IF
:
2111 ListHead
= &Question
->InconsistentListHead
;
2114 case EFI_HII_EXPRESSION_WARNING_IF
:
2115 ListHead
= &Question
->WarningListHead
;
2118 case EFI_HII_EXPRESSION_NO_SUBMIT_IF
:
2119 ListHead
= &Question
->NoSubmitListHead
;
2124 return EFI_UNSUPPORTED
;
2127 Link
= GetFirstNode (ListHead
);
2128 while (!IsNull (ListHead
, Link
)) {
2129 Expression
= FORM_EXPRESSION_FROM_LINK (Link
);
2132 // Evaluate the expression
2134 Status
= EvaluateExpression (FormSet
, Form
, Expression
);
2135 if (EFI_ERROR (Status
)) {
2139 if (IsTrue (&Expression
->Result
)) {
2141 case EFI_HII_EXPRESSION_INCONSISTENT_IF
:
2142 BrowserStatus
= BROWSER_INCONSISTENT_IF
;
2145 case EFI_HII_EXPRESSION_WARNING_IF
:
2146 BrowserStatus
= BROWSER_WARNING_IF
;
2149 case EFI_HII_EXPRESSION_NO_SUBMIT_IF
:
2150 BrowserStatus
= BROWSER_NO_SUBMIT_IF
;
2152 // This code only used to compatible with old display engine,
2153 // New display engine will not use this field.
2155 if (Expression
->Error
!= 0) {
2156 ErrorStr
= GetToken (Expression
->Error
, FormSet
->HiiHandle
);
2165 if (!((Type
== EFI_HII_EXPRESSION_NO_SUBMIT_IF
) && mSystemSubmit
)) {
2167 // If in system submit process and for no_submit_if check, not popup this error message.
2168 // Will process this fail again later in not system submit process.
2170 PopupErrorMessage(BrowserStatus
, FormSet
->HiiHandle
, Expression
->OpCode
, ErrorStr
);
2173 if (ErrorStr
!= NULL
) {
2174 FreePool (ErrorStr
);
2177 if (Type
== EFI_HII_EXPRESSION_WARNING_IF
) {
2180 return EFI_NOT_READY
;
2184 Link
= GetNextNode (ListHead
, Link
);
2191 Perform question check.
2193 If one question has more than one check, process form high priority to low.
2194 Only one error info will be popup.
2196 @param FormSet FormSet data structure.
2197 @param Form Form data structure.
2198 @param Question The Question to be validated.
2200 @retval EFI_SUCCESS Form validation pass.
2201 @retval other Form validation failed.
2205 ValueChangedValidation (
2206 IN FORM_BROWSER_FORMSET
*FormSet
,
2207 IN FORM_BROWSER_FORM
*Form
,
2208 IN FORM_BROWSER_STATEMENT
*Question
2213 Status
= EFI_SUCCESS
;
2216 // Do the inconsistentif check.
2218 if (!IsListEmpty (&Question
->InconsistentListHead
)) {
2219 Status
= ValidateQuestion (FormSet
, Form
, Question
, EFI_HII_EXPRESSION_INCONSISTENT_IF
);
2220 if (EFI_ERROR (Status
)) {
2226 // Do the warningif check.
2228 if (!IsListEmpty (&Question
->WarningListHead
)) {
2229 Status
= ValidateQuestion (FormSet
, Form
, Question
, EFI_HII_EXPRESSION_WARNING_IF
);
2236 Perform NoSubmit check for each Form in FormSet.
2238 @param FormSet FormSet data structure.
2239 @param CurrentForm Current input form data structure.
2240 @param Statement The statement for this check.
2242 @retval EFI_SUCCESS Form validation pass.
2243 @retval other Form validation failed.
2248 IN FORM_BROWSER_FORMSET
*FormSet
,
2249 IN OUT FORM_BROWSER_FORM
**CurrentForm
,
2250 OUT FORM_BROWSER_STATEMENT
**Statement
2255 FORM_BROWSER_STATEMENT
*Question
;
2256 FORM_BROWSER_FORM
*Form
;
2257 LIST_ENTRY
*LinkForm
;
2259 LinkForm
= GetFirstNode (&FormSet
->FormListHead
);
2260 while (!IsNull (&FormSet
->FormListHead
, LinkForm
)) {
2261 Form
= FORM_BROWSER_FORM_FROM_LINK (LinkForm
);
2262 LinkForm
= GetNextNode (&FormSet
->FormListHead
, LinkForm
);
2264 if (*CurrentForm
!= NULL
&& *CurrentForm
!= Form
) {
2268 Link
= GetFirstNode (&Form
->StatementListHead
);
2269 while (!IsNull (&Form
->StatementListHead
, Link
)) {
2270 Question
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
2271 Status
= ValidateQuestion (FormSet
, Form
, Question
, EFI_HII_EXPRESSION_NO_SUBMIT_IF
);
2272 if (EFI_ERROR (Status
)) {
2273 if (*CurrentForm
== NULL
) {
2274 *CurrentForm
= Form
;
2276 if (Statement
!= NULL
) {
2277 *Statement
= Question
;
2282 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
2290 Fill storage's edit copy with settings requested from Configuration Driver.
2292 @param Storage The storage which need to sync.
2293 @param ConfigRequest The config request string which used to sync storage.
2294 @param SyncOrRestore Sync the buffer to editbuffer or Restore the
2295 editbuffer to buffer
2296 if TRUE, copy the editbuffer to the buffer.
2297 if FALSE, copy the buffer to the editbuffer.
2299 @retval EFI_SUCCESS The function completed successfully.
2303 SynchronizeStorage (
2304 OUT BROWSER_STORAGE
*Storage
,
2305 IN CHAR16
*ConfigRequest
,
2306 IN BOOLEAN SyncOrRestore
2310 EFI_STRING Progress
;
2314 NAME_VALUE_NODE
*Node
;
2318 Status
= EFI_SUCCESS
;
2321 if (Storage
->Type
== EFI_HII_VARSTORE_BUFFER
||
2322 (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
)) {
2323 BufferSize
= Storage
->Size
;
2325 if (SyncOrRestore
) {
2326 Src
= Storage
->EditBuffer
;
2327 Dst
= Storage
->Buffer
;
2329 Src
= Storage
->Buffer
;
2330 Dst
= Storage
->EditBuffer
;
2333 if (ConfigRequest
!= NULL
) {
2334 Status
= mHiiConfigRouting
->BlockToConfig(
2342 if (EFI_ERROR (Status
)) {
2346 Status
= mHiiConfigRouting
->ConfigToBlock (
2353 if (Result
!= NULL
) {
2357 CopyMem (Dst
, Src
, BufferSize
);
2359 } else if (Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
2360 Link
= GetFirstNode (&Storage
->NameValueListHead
);
2361 while (!IsNull (&Storage
->NameValueListHead
, Link
)) {
2362 Node
= NAME_VALUE_NODE_FROM_LINK (Link
);
2364 if ((ConfigRequest
!= NULL
&& StrStr (ConfigRequest
, Node
->Name
) != NULL
) ||
2365 (ConfigRequest
== NULL
)) {
2366 if (SyncOrRestore
) {
2367 NewStringCpy (&Node
->Value
, Node
->EditValue
);
2369 NewStringCpy (&Node
->EditValue
, Node
->Value
);
2373 Link
= GetNextNode (&Storage
->NameValueListHead
, Link
);
2381 When discard the question value, call the callback function with Changed type
2382 to inform the hii driver.
2384 @param FormSet FormSet data structure.
2385 @param Form Form data structure.
2389 SendDiscardInfoToDriver (
2390 IN FORM_BROWSER_FORMSET
*FormSet
,
2391 IN FORM_BROWSER_FORM
*Form
2395 FORM_BROWSER_STATEMENT
*Question
;
2396 EFI_IFR_TYPE_VALUE
*TypeValue
;
2397 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
2399 if (FormSet
->ConfigAccess
== NULL
) {
2403 Link
= GetFirstNode (&Form
->StatementListHead
);
2404 while (!IsNull (&Form
->StatementListHead
, Link
)) {
2405 Question
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
2406 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
2408 if (Question
->Storage
== NULL
|| Question
->Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
2412 if ((Question
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) {
2416 if (Question
->Operand
== EFI_IFR_PASSWORD_OP
) {
2420 if (!Question
->ValueChanged
) {
2425 // Restore the question value before call the CHANGED callback type.
2427 GetQuestionValue (FormSet
, Form
, Question
, GetSetValueWithEditBuffer
);
2429 if (Question
->Operand
== EFI_IFR_STRING_OP
){
2430 HiiSetString (FormSet
->HiiHandle
, Question
->HiiValue
.Value
.string
, (CHAR16
*)Question
->BufferValue
, NULL
);
2433 if (Question
->HiiValue
.Type
== EFI_IFR_TYPE_BUFFER
) {
2434 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Question
->BufferValue
;
2436 TypeValue
= &Question
->HiiValue
.Value
;
2439 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
2440 FormSet
->ConfigAccess
->Callback (
2441 FormSet
->ConfigAccess
,
2442 EFI_BROWSER_ACTION_CHANGED
,
2443 Question
->QuestionId
,
2444 Question
->HiiValue
.Type
,
2452 When submit the question value, call the callback function with Submitted type
2453 to inform the hii driver.
2455 @param FormSet FormSet data structure.
2456 @param Form Form data structure.
2460 SubmitCallbackForForm (
2461 IN FORM_BROWSER_FORMSET
*FormSet
,
2462 IN FORM_BROWSER_FORM
*Form
2466 FORM_BROWSER_STATEMENT
*Question
;
2467 EFI_IFR_TYPE_VALUE
*TypeValue
;
2468 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
2470 if (FormSet
->ConfigAccess
== NULL
) {
2474 Link
= GetFirstNode (&Form
->StatementListHead
);
2475 while (!IsNull (&Form
->StatementListHead
, Link
)) {
2476 Question
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
2477 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
2479 if (Question
->Storage
== NULL
|| Question
->Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
2483 if ((Question
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != EFI_IFR_FLAG_CALLBACK
) {
2487 if (Question
->Operand
== EFI_IFR_PASSWORD_OP
) {
2491 if (Question
->HiiValue
.Type
== EFI_IFR_TYPE_BUFFER
) {
2492 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Question
->BufferValue
;
2494 TypeValue
= &Question
->HiiValue
.Value
;
2497 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
2498 FormSet
->ConfigAccess
->Callback (
2499 FormSet
->ConfigAccess
,
2500 EFI_BROWSER_ACTION_SUBMITTED
,
2501 Question
->QuestionId
,
2502 Question
->HiiValue
.Type
,
2510 When value set Success, call the submit callback function.
2512 @param FormSet FormSet data structure.
2513 @param Form Form data structure.
2518 IN FORM_BROWSER_FORMSET
*FormSet
,
2519 IN FORM_BROWSER_FORM
*Form
2522 FORM_BROWSER_FORM
*CurrentForm
;
2526 SubmitCallbackForForm(FormSet
, Form
);
2530 Link
= GetFirstNode (&FormSet
->FormListHead
);
2531 while (!IsNull (&FormSet
->FormListHead
, Link
)) {
2532 CurrentForm
= FORM_BROWSER_FORM_FROM_LINK (Link
);
2533 Link
= GetNextNode (&FormSet
->FormListHead
, Link
);
2535 SubmitCallbackForForm(FormSet
, CurrentForm
);
2540 Validate the HiiHandle.
2542 @param HiiHandle The input HiiHandle which need to validate.
2544 @retval TRUE The handle is validate.
2545 @retval FALSE The handle is invalidate.
2550 EFI_HII_HANDLE HiiHandle
2553 EFI_HII_HANDLE
*HiiHandles
;
2557 if (HiiHandle
== NULL
) {
2563 HiiHandles
= HiiGetHiiHandles (NULL
);
2564 ASSERT (HiiHandles
!= NULL
);
2566 for (Index
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
2567 if (HiiHandles
[Index
] == HiiHandle
) {
2573 FreePool (HiiHandles
);
2579 Validate the FormSet. If the formset is not validate, remove it from the list.
2581 @param FormSet The input FormSet which need to validate.
2583 @retval TRUE The handle is validate.
2584 @retval FALSE The handle is invalidate.
2589 FORM_BROWSER_FORMSET
*FormSet
2594 ASSERT (FormSet
!= NULL
);
2596 Find
= ValidateHiiHandle(FormSet
->HiiHandle
);
2598 // Should not remove the formset which is being used.
2600 if (!Find
&& (FormSet
!= gCurrentSelection
->FormSet
)) {
2601 CleanBrowserStorage(FormSet
);
2602 RemoveEntryList (&FormSet
->Link
);
2603 DestroyFormSet (FormSet
);
2609 Check whether need to enable the reset flag in form level.
2610 Also clean all ValueChanged flag in question.
2612 @param SetFlag Whether need to set the Reset Flag.
2613 @param FormSet FormSet data structure.
2614 @param Form Form data structure.
2620 IN FORM_BROWSER_FORMSET
*FormSet
,
2621 IN FORM_BROWSER_FORM
*Form
2625 FORM_BROWSER_STATEMENT
*Question
;
2628 Link
= GetFirstNode (&Form
->StatementListHead
);
2629 while (!IsNull (&Form
->StatementListHead
, Link
)) {
2630 Question
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
2631 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
2633 if (!Question
->ValueChanged
) {
2637 OldValue
= Question
->ValueChanged
;
2640 // Compare the buffer and editbuffer data to see whether the data has been saved.
2642 Question
->ValueChanged
= IsQuestionValueChanged(FormSet
, Form
, Question
, GetSetValueWithBothBuffer
);
2645 // Only the changed data has been saved, then need to set the reset flag.
2647 if (SetFlag
&& OldValue
&& !Question
->ValueChanged
) {
2648 if ((Question
->QuestionFlags
& EFI_IFR_FLAG_RESET_REQUIRED
) != 0) {
2649 gResetRequired
= TRUE
;
2652 if ((Question
->QuestionFlags
& EFI_IFR_FLAG_RECONNECT_REQUIRED
) != 0) {
2653 gFlagReconnect
= TRUE
;
2660 Check whether need to enable the reset flag.
2661 Also clean ValueChanged flag for all statements.
2663 Form level or formset level, only one.
2665 @param SetFlag Whether need to set the Reset Flag.
2666 @param FormSet FormSet data structure.
2667 @param Form Form data structure.
2671 ValueChangeResetFlagUpdate (
2673 IN FORM_BROWSER_FORMSET
*FormSet
,
2674 IN FORM_BROWSER_FORM
*Form
2677 FORM_BROWSER_FORM
*CurrentForm
;
2681 UpdateFlagForForm(SetFlag
, FormSet
, Form
);
2685 Link
= GetFirstNode (&FormSet
->FormListHead
);
2686 while (!IsNull (&FormSet
->FormListHead
, Link
)) {
2687 CurrentForm
= FORM_BROWSER_FORM_FROM_LINK (Link
);
2688 Link
= GetNextNode (&FormSet
->FormListHead
, Link
);
2690 UpdateFlagForForm(SetFlag
, FormSet
, CurrentForm
);
2695 Base on the return Progress string to find the form.
2697 Base on the first return Offset/Width (Name) string to find the form
2698 which keep this string.
2700 @param FormSet FormSet data structure.
2701 @param Storage Storage which has this Progress string.
2702 @param Progress The Progress string which has the first fail string.
2703 @param RetForm The return form for this progress string.
2704 @param RetQuestion The return question for the error progress string.
2706 @retval TRUE Find the error form and statement for this error progress string.
2707 @retval FALSE Not find the error form.
2711 FindQuestionFromProgress (
2712 IN FORM_BROWSER_FORMSET
*FormSet
,
2713 IN BROWSER_STORAGE
*Storage
,
2714 IN EFI_STRING Progress
,
2715 OUT FORM_BROWSER_FORM
**RetForm
,
2716 OUT FORM_BROWSER_STATEMENT
**RetQuestion
2720 LIST_ENTRY
*LinkStorage
;
2721 LIST_ENTRY
*LinkStatement
;
2722 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
2723 FORM_BROWSER_FORM
*Form
;
2725 FORM_BROWSER_STATEMENT
*Statement
;
2727 ASSERT ((*Progress
== '&') || (*Progress
== 'G'));
2731 *RetQuestion
= NULL
;
2734 // Skip the first "&" or the ConfigHdr part.
2736 if (*Progress
== '&') {
2740 // Prepare the "NAME" or "OFFSET=0x####&WIDTH=0x####" string.
2742 if (Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
2744 // For Name/Value type, Skip the ConfigHdr part.
2746 EndStr
= StrStr (Progress
, L
"PATH=");
2747 ASSERT (EndStr
!= NULL
);
2748 while (*EndStr
!= '&') {
2755 // For Buffer type, Skip the ConfigHdr part.
2757 EndStr
= StrStr (Progress
, L
"&OFFSET=");
2758 ASSERT (EndStr
!= NULL
);
2762 Progress
= EndStr
+ 1;
2766 // Prepare the "NAME" or "OFFSET=0x####&WIDTH=0x####" string.
2768 if (Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
2770 // For Name/Value type, the data is "&Fred=16&George=16&Ron=12" formset,
2771 // here, just keep the "Fred" string.
2773 EndStr
= StrStr (Progress
, L
"=");
2774 ASSERT (EndStr
!= NULL
);
2778 // For Buffer type, the data is "OFFSET=0x####&WIDTH=0x####&VALUE=0x####",
2779 // here, just keep the "OFFSET=0x####&WIDTH=0x####" string.
2781 EndStr
= StrStr (Progress
, L
"&VALUE=");
2782 ASSERT (EndStr
!= NULL
);
2787 // Search in the form list.
2789 Link
= GetFirstNode (&FormSet
->FormListHead
);
2790 while (!IsNull (&FormSet
->FormListHead
, Link
)) {
2791 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
2792 Link
= GetNextNode (&FormSet
->FormListHead
, Link
);
2795 // Search in the ConfigReqeust list in this form.
2797 LinkStorage
= GetFirstNode (&Form
->ConfigRequestHead
);
2798 while (!IsNull (&Form
->ConfigRequestHead
, LinkStorage
)) {
2799 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (LinkStorage
);
2800 LinkStorage
= GetNextNode (&Form
->ConfigRequestHead
, LinkStorage
);
2802 if (Storage
!= ConfigInfo
->Storage
) {
2806 if (StrStr (ConfigInfo
->ConfigRequest
, Progress
) != NULL
) {
2808 // Find the OffsetWidth string in this form.
2815 if (*RetForm
!= NULL
) {
2816 LinkStatement
= GetFirstNode (&Form
->StatementListHead
);
2817 while (!IsNull (&Form
->StatementListHead
, LinkStatement
)) {
2818 Statement
= FORM_BROWSER_STATEMENT_FROM_LINK (LinkStatement
);
2819 LinkStatement
= GetNextNode (&Form
->StatementListHead
, LinkStatement
);
2821 if (Statement
->BlockName
!= NULL
&& StrStr (Statement
->BlockName
, Progress
) != NULL
) {
2822 *RetQuestion
= Statement
;
2826 if (Statement
->VariableName
!= NULL
&& StrStr (Statement
->VariableName
, Progress
) != NULL
) {
2827 *RetQuestion
= Statement
;
2833 if (*RetForm
!= NULL
) {
2839 // restore the OffsetWidth string to the original format.
2841 if (Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
2847 return (BOOLEAN
) (*RetForm
!= NULL
);
2851 Base on the return Progress string to get the SyncConfigRequest and RestoreConfigRequest
2852 for form and formset.
2854 @param Storage Storage which has this Progress string.
2855 @param ConfigRequest The ConfigRequest string.
2856 @param Progress The Progress string which has the first fail string.
2857 @param RestoreConfigRequest Return the RestoreConfigRequest string.
2858 @param SyncConfigRequest Return the SyncConfigRequest string.
2862 GetSyncRestoreConfigRequest(
2863 IN BROWSER_STORAGE
*Storage
,
2864 IN EFI_STRING ConfigRequest
,
2865 IN EFI_STRING Progress
,
2866 OUT EFI_STRING
*RestoreConfigRequest
,
2867 OUT EFI_STRING
*SyncConfigRequest
2871 EFI_STRING ConfigHdrEndStr
;
2872 EFI_STRING ElementStr
;
2874 UINTN RestoreEleSize
;
2877 ASSERT ((*Progress
== L
'&') || (*Progress
== L
'G'));
2879 // If the Progress starts with ConfigHdr, means the failure is in the first name / value pair.
2880 // Need to restore all the fields in the ConfigRequest.
2882 if (*Progress
== L
'G') {
2883 *RestoreConfigRequest
= AllocateCopyPool (StrSize (ConfigRequest
), ConfigRequest
);
2884 ASSERT (*RestoreConfigRequest
!= NULL
);
2889 // Find the first fail "NAME" or "OFFSET=0x####&WIDTH=0x####" string.
2891 if (Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
2893 // For Name/Value type, the data is "&Fred=16&George=16&Ron=12" formset,
2894 // here, just keep the "Fred" string.
2896 EndStr
= StrStr (Progress
, L
"=");
2897 ASSERT (EndStr
!= NULL
);
2900 // Find the ConfigHdr in ConfigRequest.
2902 ConfigHdrEndStr
= StrStr (ConfigRequest
, L
"PATH=");
2903 ASSERT (ConfigHdrEndStr
!= NULL
);
2904 while (*ConfigHdrEndStr
!= L
'&') {
2909 // For Buffer type, the data is "OFFSET=0x####&WIDTH=0x####&VALUE=0x####",
2910 // here, just keep the "OFFSET=0x####&WIDTH=0x####" string.
2912 EndStr
= StrStr (Progress
, L
"&VALUE=");
2913 ASSERT (EndStr
!= NULL
);
2916 // Find the ConfigHdr in ConfigRequest.
2918 ConfigHdrEndStr
= StrStr (ConfigRequest
, L
"&OFFSET=");
2921 // Find the first fail pair in the ConfigRequest.
2923 ElementStr
= StrStr (ConfigRequest
, Progress
);
2924 ASSERT (ElementStr
!= NULL
);
2926 // To get the RestoreConfigRequest.
2928 RestoreEleSize
= StrSize (ElementStr
);
2929 TotalSize
= (ConfigHdrEndStr
- ConfigRequest
) * sizeof (CHAR16
) + RestoreEleSize
+ sizeof (CHAR16
);
2930 *RestoreConfigRequest
= AllocateZeroPool (TotalSize
);
2931 ASSERT (*RestoreConfigRequest
!= NULL
);
2932 StrnCpyS (*RestoreConfigRequest
, TotalSize
/ sizeof (CHAR16
), ConfigRequest
, ConfigHdrEndStr
- ConfigRequest
);
2933 StrCatS (*RestoreConfigRequest
, TotalSize
/ sizeof (CHAR16
), ElementStr
);
2935 // To get the SyncConfigRequest.
2937 SyncSize
= StrSize (ConfigRequest
) - RestoreEleSize
+ sizeof (CHAR16
);
2938 *SyncConfigRequest
= AllocateZeroPool (SyncSize
);
2939 ASSERT (*SyncConfigRequest
!= NULL
);
2940 StrnCpyS (*SyncConfigRequest
, SyncSize
/ sizeof (CHAR16
), ConfigRequest
, SyncSize
/ sizeof (CHAR16
) - 1);
2943 // restore the Progress string to the original format.
2945 if (Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
2953 Popup an save error info and get user input.
2955 @param TitleId The form title id.
2956 @param HiiHandle The hii handle for this package.
2958 @retval UINT32 The user select option for the save fail.
2959 BROWSER_ACTION_DISCARD or BROWSER_ACTION_JUMP_TO_FORMSET
2963 IN EFI_STRING_ID TitleId
,
2964 IN EFI_HII_HANDLE HiiHandle
2968 CHAR16
*StringBuffer
;
2971 FormTitle
= GetToken (TitleId
, HiiHandle
);
2973 StringBuffer
= AllocateZeroPool (256 * sizeof (CHAR16
));
2974 ASSERT (StringBuffer
!= NULL
);
2978 24 * sizeof (CHAR16
) + StrSize (FormTitle
),
2979 L
"Submit Fail For Form: %s.",
2983 RetVal
= PopupErrorMessage(BROWSER_SUBMIT_FAIL
, NULL
, NULL
, StringBuffer
);
2985 FreePool (StringBuffer
);
2986 FreePool (FormTitle
);
2992 Popup an NO_SUBMIT_IF error info and get user input.
2994 @param TitleId The form title id.
2995 @param HiiHandle The hii handle for this package.
2997 @retval UINT32 The user select option for the save fail.
2998 BROWSER_ACTION_DISCARD or BROWSER_ACTION_JUMP_TO_FORMSET
3001 ConfirmNoSubmitFail (
3002 IN EFI_STRING_ID TitleId
,
3003 IN EFI_HII_HANDLE HiiHandle
3007 CHAR16
*StringBuffer
;
3010 FormTitle
= GetToken (TitleId
, HiiHandle
);
3012 StringBuffer
= AllocateZeroPool (256 * sizeof (CHAR16
));
3013 ASSERT (StringBuffer
!= NULL
);
3017 24 * sizeof (CHAR16
) + StrSize (FormTitle
),
3018 L
"NO_SUBMIT_IF error For Form: %s.",
3022 RetVal
= PopupErrorMessage(BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
, NULL
, NULL
, StringBuffer
);
3024 FreePool (StringBuffer
);
3025 FreePool (FormTitle
);
3031 Discard data based on the input setting scope (Form, FormSet or System).
3033 @param FormSet FormSet data structure.
3034 @param Form Form data structure.
3035 @param SettingScope Setting Scope for Discard action.
3037 @retval EFI_SUCCESS The function completed successfully.
3038 @retval EFI_UNSUPPORTED Unsupport SettingScope.
3043 IN FORM_BROWSER_FORMSET
*FormSet
,
3044 IN FORM_BROWSER_FORM
*Form
,
3045 IN BROWSER_SETTING_SCOPE SettingScope
3049 FORMSET_STORAGE
*Storage
;
3050 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
3051 FORM_BROWSER_FORMSET
*LocalFormSet
;
3052 FORM_BROWSER_FORMSET
*OldFormSet
;
3055 // Check the supported setting level.
3057 if (SettingScope
>= MaxLevel
) {
3058 return EFI_UNSUPPORTED
;
3061 if (SettingScope
== FormLevel
&& IsNvUpdateRequiredForForm (Form
)) {
3063 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
3064 while (!IsNull (&Form
->ConfigRequestHead
, Link
)) {
3065 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
3066 Link
= GetNextNode (&Form
->ConfigRequestHead
, Link
);
3068 if (ConfigInfo
->Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
3073 // Skip if there is no RequestElement
3075 if (ConfigInfo
->ElementCount
== 0) {
3080 // Prepare <ConfigResp>
3082 SynchronizeStorage(ConfigInfo
->Storage
, ConfigInfo
->ConfigRequest
, FALSE
);
3085 // Call callback with Changed type to inform the driver.
3087 SendDiscardInfoToDriver (FormSet
, Form
);
3090 ValueChangeResetFlagUpdate (FALSE
, FormSet
, Form
);
3091 } else if (SettingScope
== FormSetLevel
&& IsNvUpdateRequiredForFormSet (FormSet
)) {
3094 // Discard Buffer storage or Name/Value storage
3096 Link
= GetFirstNode (&FormSet
->StorageListHead
);
3097 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
3098 Storage
= FORMSET_STORAGE_FROM_LINK (Link
);
3099 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
3101 if (Storage
->BrowserStorage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
3106 // Skip if there is no RequestElement
3108 if (Storage
->ElementCount
== 0) {
3112 SynchronizeStorage(Storage
->BrowserStorage
, Storage
->ConfigRequest
, FALSE
);
3115 Link
= GetFirstNode (&FormSet
->FormListHead
);
3116 while (!IsNull (&FormSet
->FormListHead
, Link
)) {
3117 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
3118 Link
= GetNextNode (&FormSet
->FormListHead
, Link
);
3121 // Call callback with Changed type to inform the driver.
3123 SendDiscardInfoToDriver (FormSet
, Form
);
3126 ValueChangeResetFlagUpdate(FALSE
, FormSet
, NULL
);
3127 } else if (SettingScope
== SystemLevel
) {
3129 // System Level Discard.
3131 OldFormSet
= mSystemLevelFormSet
;
3134 // Discard changed value for each FormSet in the maintain list.
3136 Link
= GetFirstNode (&gBrowserFormSetList
);
3137 while (!IsNull (&gBrowserFormSetList
, Link
)) {
3138 LocalFormSet
= FORM_BROWSER_FORMSET_FROM_LINK (Link
);
3139 Link
= GetNextNode (&gBrowserFormSetList
, Link
);
3140 if (!ValidateFormSet(LocalFormSet
)) {
3144 mSystemLevelFormSet
= LocalFormSet
;
3146 DiscardForm (LocalFormSet
, NULL
, FormSetLevel
);
3147 if (!IsHiiHandleInBrowserContext (LocalFormSet
->HiiHandle
)) {
3149 // Remove maintain backup list after discard except for the current using FormSet.
3151 CleanBrowserStorage(LocalFormSet
);
3152 RemoveEntryList (&LocalFormSet
->Link
);
3153 DestroyFormSet (LocalFormSet
);
3157 mSystemLevelFormSet
= OldFormSet
;
3164 Submit data for a form.
3166 @param FormSet FormSet data structure.
3167 @param Form Form data structure.
3169 @retval EFI_SUCCESS The function completed successfully.
3170 @retval EFI_UNSUPPORTED Unsupport SettingScope.
3175 IN FORM_BROWSER_FORMSET
*FormSet
,
3176 IN FORM_BROWSER_FORM
*Form
3181 EFI_STRING ConfigResp
;
3182 EFI_STRING Progress
;
3183 BROWSER_STORAGE
*Storage
;
3184 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
3186 if (!IsNvUpdateRequiredForForm (Form
)) {
3190 Status
= NoSubmitCheck (FormSet
, &Form
, NULL
);
3191 if (EFI_ERROR (Status
)) {
3195 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
3196 while (!IsNull (&Form
->ConfigRequestHead
, Link
)) {
3197 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
3198 Link
= GetNextNode (&Form
->ConfigRequestHead
, Link
);
3200 Storage
= ConfigInfo
->Storage
;
3201 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
3206 // Skip if there is no RequestElement
3208 if (ConfigInfo
->ElementCount
== 0) {
3213 // 1. Prepare <ConfigResp>
3215 Status
= StorageToConfigResp (ConfigInfo
->Storage
, &ConfigResp
, ConfigInfo
->ConfigRequest
, TRUE
);
3216 if (EFI_ERROR (Status
)) {
3221 // 2. Set value to hii config routine protocol.
3223 Status
= mHiiConfigRouting
->RouteConfig (
3228 FreePool (ConfigResp
);
3230 if (EFI_ERROR (Status
)) {
3232 // Submit fail, to get the RestoreConfigRequest and SyncConfigRequest.
3234 GetSyncRestoreConfigRequest (ConfigInfo
->Storage
, ConfigInfo
->ConfigRequest
, Progress
, &ConfigInfo
->RestoreConfigRequest
, &ConfigInfo
->SyncConfigRequest
);
3235 InsertTailList (&gBrowserSaveFailFormSetList
, &ConfigInfo
->SaveFailLink
);
3240 // 3. Config success, update storage shadow Buffer, only update the data belong to this form.
3242 SynchronizeStorage (ConfigInfo
->Storage
, ConfigInfo
->ConfigRequest
, TRUE
);
3246 // 4. Process the save failed storage.
3248 if (!IsListEmpty (&gBrowserSaveFailFormSetList
)) {
3249 if (ConfirmSaveFail (Form
->FormTitle
, FormSet
->HiiHandle
) == BROWSER_ACTION_DISCARD
) {
3250 Link
= GetFirstNode (&gBrowserSaveFailFormSetList
);
3251 while (!IsNull (&gBrowserSaveFailFormSetList
, Link
)) {
3252 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_SAVE_FAIL_LINK (Link
);
3253 Link
= GetNextNode (&gBrowserSaveFailFormSetList
, Link
);
3255 // Process the submit fail question, base on the RestoreConfigRequest to restore the EditBuffer
3256 // base on the SyncConfigRequest to Sync the buffer.
3258 SynchronizeStorage (ConfigInfo
->Storage
, ConfigInfo
->RestoreConfigRequest
, FALSE
);
3259 FreePool (ConfigInfo
->RestoreConfigRequest
);
3260 ConfigInfo
->RestoreConfigRequest
= NULL
;
3261 if (ConfigInfo
->SyncConfigRequest
!= NULL
) {
3262 SynchronizeStorage(ConfigInfo
->Storage
, ConfigInfo
->SyncConfigRequest
, TRUE
);
3263 FreePool (ConfigInfo
->SyncConfigRequest
);
3264 ConfigInfo
->SyncConfigRequest
= NULL
;
3267 Status
= EFI_SUCCESS
;
3270 Status
= EFI_UNSUPPORTED
;
3274 // Free Form save fail list.
3276 while (!IsListEmpty (&gBrowserSaveFailFormSetList
)) {
3277 Link
= GetFirstNode (&gBrowserSaveFailFormSetList
);
3278 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_SAVE_FAIL_LINK (Link
);
3279 RemoveEntryList (&ConfigInfo
->SaveFailLink
);
3284 // 5. Update the NV flag.
3286 ValueChangeResetFlagUpdate(TRUE
, FormSet
, Form
);
3289 // 6 Call callback with Submitted type to inform the driver.
3291 SubmitCallback (FormSet
, Form
);
3297 Submit data for a formset.
3299 @param FormSet FormSet data structure.
3300 @param SkipProcessFail Whether skip to process the save failed storage.
3301 If submit formset is called when do system level save,
3302 set this value to true and process the failed formset
3304 if submit formset is called when do formset level save,
3305 set the value to false and process the failed storage
3306 right after process all storages for this formset.
3308 @retval EFI_SUCCESS The function completed successfully.
3309 @retval EFI_UNSUPPORTED Unsupport SettingScope.
3314 IN FORM_BROWSER_FORMSET
*FormSet
,
3315 IN BOOLEAN SkipProcessFail
3320 EFI_STRING ConfigResp
;
3321 EFI_STRING Progress
;
3322 BROWSER_STORAGE
*Storage
;
3323 FORMSET_STORAGE
*FormSetStorage
;
3324 FORM_BROWSER_FORM
*Form
;
3325 BOOLEAN HasInserted
;
3326 FORM_BROWSER_STATEMENT
*Question
;
3328 HasInserted
= FALSE
;
3330 if (!IsNvUpdateRequiredForFormSet (FormSet
)) {
3335 Status
= NoSubmitCheck (FormSet
, &Form
, &Question
);
3336 if (EFI_ERROR (Status
)) {
3337 if (SkipProcessFail
) {
3339 // Process NO_SUBMIT check first, so insert it at head.
3341 FormSet
->SaveFailForm
= Form
;
3342 FormSet
->SaveFailStatement
= Question
;
3343 InsertHeadList (&gBrowserSaveFailFormSetList
, &FormSet
->SaveFailLink
);
3352 // Submit Buffer storage or Name/Value storage
3354 Link
= GetFirstNode (&FormSet
->StorageListHead
);
3355 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
3356 FormSetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
3357 Storage
= FormSetStorage
->BrowserStorage
;
3358 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
3360 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
3365 // Skip if there is no RequestElement
3367 if (FormSetStorage
->ElementCount
== 0) {
3372 // 1. Prepare <ConfigResp>
3374 Status
= StorageToConfigResp (Storage
, &ConfigResp
, FormSetStorage
->ConfigRequest
, TRUE
);
3375 if (EFI_ERROR (Status
)) {
3380 // 2. Send <ConfigResp> to Routine config Protocol.
3382 Status
= mHiiConfigRouting
->RouteConfig (
3387 if (EFI_ERROR (Status
)) {
3389 // Submit fail, to get the RestoreConfigRequest and SyncConfigRequest.
3391 GetSyncRestoreConfigRequest (FormSetStorage
->BrowserStorage
, FormSetStorage
->ConfigRequest
, Progress
, &FormSetStorage
->RestoreConfigRequest
, &FormSetStorage
->SyncConfigRequest
);
3392 InsertTailList (&FormSet
->SaveFailStorageListHead
, &FormSetStorage
->SaveFailLink
);
3395 // Call submit formset for system level, save the formset info
3396 // and process later.
3398 FindQuestionFromProgress(FormSet
, Storage
, Progress
, &Form
, &Question
);
3399 ASSERT (Form
!= NULL
&& Question
!= NULL
);
3400 FormSet
->SaveFailForm
= Form
;
3401 FormSet
->SaveFailStatement
= Question
;
3402 if (SkipProcessFail
) {
3403 InsertTailList (&gBrowserSaveFailFormSetList
, &FormSet
->SaveFailLink
);
3408 FreePool (ConfigResp
);
3412 FreePool (ConfigResp
);
3414 // 3. Config success, update storage shadow Buffer
3416 SynchronizeStorage (Storage
, FormSetStorage
->ConfigRequest
, TRUE
);
3420 // 4. Has save fail storage need to handle.
3423 if (!SkipProcessFail
) {
3425 // If not in system level, just handl the save failed storage here.
3427 if (ConfirmSaveFail (Form
->FormTitle
, FormSet
->HiiHandle
) == BROWSER_ACTION_DISCARD
) {
3428 Link
= GetFirstNode (&FormSet
->SaveFailStorageListHead
);
3429 while (!IsNull (&FormSet
->SaveFailStorageListHead
, Link
)) {
3430 FormSetStorage
= FORMSET_STORAGE_FROM_SAVE_FAIL_LINK (Link
);
3431 Storage
= FormSetStorage
->BrowserStorage
;
3432 Link
= GetNextNode (&FormSet
->SaveFailStorageListHead
, Link
);
3434 // Process the submit fail question, base on the RestoreConfigRequest to restore the EditBuffer
3435 // base on the SyncConfigRequest to Sync the buffer.
3437 SynchronizeStorage (FormSetStorage
->BrowserStorage
, FormSetStorage
->RestoreConfigRequest
, FALSE
);
3438 FreePool (FormSetStorage
->RestoreConfigRequest
);
3439 FormSetStorage
->RestoreConfigRequest
= NULL
;
3440 if (FormSetStorage
->SyncConfigRequest
!= NULL
) {
3441 SynchronizeStorage(FormSetStorage
->BrowserStorage
, FormSetStorage
->SyncConfigRequest
, TRUE
);
3442 FreePool (FormSetStorage
->SyncConfigRequest
);
3443 FormSetStorage
->SyncConfigRequest
= NULL
;
3446 Status
= EFI_SUCCESS
;
3449 UiCopyMenuList(&mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
, &Form
->FormViewListHead
);
3451 gCurrentSelection
->Action
= UI_ACTION_REFRESH_FORMSET
;
3452 gCurrentSelection
->Handle
= FormSet
->HiiHandle
;
3453 CopyGuid (&gCurrentSelection
->FormSetGuid
, &FormSet
->Guid
);
3454 gCurrentSelection
->FormId
= Form
->FormId
;
3455 gCurrentSelection
->QuestionId
= Question
->QuestionId
;
3457 Status
= EFI_UNSUPPORTED
;
3461 // Free FormSet save fail list.
3463 while (!IsListEmpty (&FormSet
->SaveFailStorageListHead
)) {
3464 Link
= GetFirstNode (&FormSet
->SaveFailStorageListHead
);
3465 FormSetStorage
= FORMSET_STORAGE_FROM_SAVE_FAIL_LINK (Link
);
3466 RemoveEntryList (&FormSetStorage
->SaveFailLink
);
3470 // If in system level, just return error and handle the failed formset later.
3472 Status
= EFI_UNSUPPORTED
;
3477 // 5. Update the NV flag.
3479 ValueChangeResetFlagUpdate(TRUE
, FormSet
, NULL
);
3482 // 6. Call callback with Submitted type to inform the driver.
3484 SubmitCallback (FormSet
, NULL
);
3490 Submit data for all formsets.
3492 @retval EFI_SUCCESS The function completed successfully.
3493 @retval EFI_UNSUPPORTED Unsupport SettingScope.
3503 LIST_ENTRY
*StorageLink
;
3504 FORMSET_STORAGE
*FormSetStorage
;
3505 FORM_BROWSER_FORM
*Form
;
3506 FORM_BROWSER_FORMSET
*LocalFormSet
;
3507 UINT32 UserSelection
;
3508 FORM_BROWSER_STATEMENT
*Question
;
3510 mSystemSubmit
= TRUE
;
3511 Link
= GetFirstNode (&gBrowserFormSetList
);
3512 while (!IsNull (&gBrowserFormSetList
, Link
)) {
3513 LocalFormSet
= FORM_BROWSER_FORMSET_FROM_LINK (Link
);
3514 Link
= GetNextNode (&gBrowserFormSetList
, Link
);
3515 if (!ValidateFormSet(LocalFormSet
)) {
3519 Status
= SubmitForFormSet (LocalFormSet
, TRUE
);
3520 if (EFI_ERROR (Status
)) {
3525 // Remove maintain backup list after save except for the current using FormSet.
3527 if (!IsHiiHandleInBrowserContext (LocalFormSet
->HiiHandle
)) {
3528 CleanBrowserStorage(LocalFormSet
);
3529 RemoveEntryList (&LocalFormSet
->Link
);
3530 DestroyFormSet (LocalFormSet
);
3533 mSystemSubmit
= FALSE
;
3535 Status
= EFI_SUCCESS
;
3538 // Process the save failed formsets.
3540 Link
= GetFirstNode (&gBrowserSaveFailFormSetList
);
3541 while (!IsNull (&gBrowserSaveFailFormSetList
, Link
)) {
3542 LocalFormSet
= FORM_BROWSER_FORMSET_FROM_SAVE_FAIL_LINK (Link
);
3543 Link
= GetNextNode (&gBrowserSaveFailFormSetList
, Link
);
3545 if (!ValidateFormSet(LocalFormSet
)) {
3549 Form
= LocalFormSet
->SaveFailForm
;
3550 Question
= LocalFormSet
->SaveFailStatement
;
3553 // Confirm with user, get user input.
3555 if (IsListEmpty (&LocalFormSet
->SaveFailStorageListHead
)) {
3557 // NULL for SaveFailStorageListHead means error caused by NO_SUBMIT_IF check.
3559 UserSelection
= ConfirmNoSubmitFail (Form
->FormTitle
, LocalFormSet
->HiiHandle
);
3561 UserSelection
= ConfirmSaveFail (Form
->FormTitle
, LocalFormSet
->HiiHandle
);
3564 if (UserSelection
== BROWSER_ACTION_DISCARD
) {
3565 if (IsListEmpty (&LocalFormSet
->SaveFailStorageListHead
)) {
3566 StorageLink
= GetFirstNode (&LocalFormSet
->StorageListHead
);
3567 while (!IsNull (&LocalFormSet
->StorageListHead
, StorageLink
)) {
3568 FormSetStorage
= FORMSET_STORAGE_FROM_LINK (StorageLink
);
3569 StorageLink
= GetNextNode (&LocalFormSet
->StorageListHead
, StorageLink
);
3571 SynchronizeStorage(FormSetStorage
->BrowserStorage
, FormSetStorage
->ConfigRequest
, FALSE
);
3574 StorageLink
= GetFirstNode (&LocalFormSet
->SaveFailStorageListHead
);
3575 while (!IsNull (&LocalFormSet
->SaveFailStorageListHead
, StorageLink
)) {
3576 FormSetStorage
= FORMSET_STORAGE_FROM_SAVE_FAIL_LINK (StorageLink
);
3577 StorageLink
= GetNextNode (&LocalFormSet
->SaveFailStorageListHead
, StorageLink
);
3579 // Process the submit fail question, base on the RestoreConfigRequest to restore the EditBuffer
3580 // base on the SyncConfigRequest to Sync the buffer.
3582 SynchronizeStorage (FormSetStorage
->BrowserStorage
, FormSetStorage
->RestoreConfigRequest
, FALSE
);
3583 FreePool (FormSetStorage
->RestoreConfigRequest
);
3584 FormSetStorage
->RestoreConfigRequest
= NULL
;
3585 if ( FormSetStorage
->SyncConfigRequest
!= NULL
) {
3586 SynchronizeStorage (FormSetStorage
->BrowserStorage
, FormSetStorage
->SyncConfigRequest
, TRUE
);
3587 FreePool (FormSetStorage
->SyncConfigRequest
);
3588 FormSetStorage
->SyncConfigRequest
= NULL
;
3593 if (!IsHiiHandleInBrowserContext (LocalFormSet
->HiiHandle
)) {
3594 CleanBrowserStorage(LocalFormSet
);
3595 RemoveEntryList (&LocalFormSet
->Link
);
3596 RemoveEntryList (&LocalFormSet
->SaveFailLink
);
3597 DestroyFormSet (LocalFormSet
);
3599 ValueChangeResetFlagUpdate(FALSE
, LocalFormSet
, NULL
);
3602 if (IsListEmpty (&LocalFormSet
->SaveFailStorageListHead
)) {
3603 NoSubmitCheck (LocalFormSet
, &Form
, &Question
);
3606 UiCopyMenuList(&mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
, &Form
->FormViewListHead
);
3608 gCurrentSelection
->Action
= UI_ACTION_REFRESH_FORMSET
;
3609 gCurrentSelection
->Handle
= LocalFormSet
->HiiHandle
;
3610 CopyGuid (&gCurrentSelection
->FormSetGuid
, &LocalFormSet
->Guid
);
3611 gCurrentSelection
->FormId
= Form
->FormId
;
3612 gCurrentSelection
->QuestionId
= Question
->QuestionId
;
3614 Status
= EFI_UNSUPPORTED
;
3620 // Clean the list which will not process.
3622 while (!IsListEmpty (&gBrowserSaveFailFormSetList
)) {
3623 Link
= GetFirstNode (&gBrowserSaveFailFormSetList
);
3624 LocalFormSet
= FORM_BROWSER_FORMSET_FROM_SAVE_FAIL_LINK (Link
);
3625 RemoveEntryList (&LocalFormSet
->SaveFailLink
);
3627 while (!IsListEmpty (&LocalFormSet
->SaveFailStorageListHead
)) {
3628 StorageLink
= GetFirstNode (&LocalFormSet
->SaveFailStorageListHead
);
3629 FormSetStorage
= FORMSET_STORAGE_FROM_SAVE_FAIL_LINK (StorageLink
);
3630 RemoveEntryList (&FormSetStorage
->SaveFailLink
);
3638 Submit data based on the input Setting level (Form, FormSet or System).
3640 @param FormSet FormSet data structure.
3641 @param Form Form data structure.
3642 @param SettingScope Setting Scope for Submit action.
3644 @retval EFI_SUCCESS The function completed successfully.
3645 @retval EFI_UNSUPPORTED Unsupport SettingScope.
3650 IN FORM_BROWSER_FORMSET
*FormSet
,
3651 IN FORM_BROWSER_FORM
*Form
,
3652 IN BROWSER_SETTING_SCOPE SettingScope
3657 switch (SettingScope
) {
3659 Status
= SubmitForForm(FormSet
, Form
);
3663 Status
= SubmitForFormSet (FormSet
, FALSE
);
3667 Status
= SubmitForSystem ();
3671 Status
= EFI_UNSUPPORTED
;
3679 Converts the unicode character of the string from uppercase to lowercase.
3680 This is a internal function.
3682 @param ConfigString String to be converted
3688 IN EFI_STRING ConfigString
3694 ASSERT (ConfigString
!= NULL
);
3697 // Convert all hex digits in range [A-F] in the configuration header to [a-f]
3699 for (String
= ConfigString
, Lower
= FALSE
; *String
!= L
'\0'; String
++) {
3700 if (*String
== L
'=') {
3702 } else if (*String
== L
'&') {
3704 } else if (Lower
&& *String
>= L
'A' && *String
<= L
'F') {
3705 *String
= (CHAR16
) (*String
- L
'A' + L
'a');
3711 Find the point in the ConfigResp string for this question.
3713 @param Question The question.
3714 @param ConfigResp Get ConfigResp string.
3716 @retval point to the offset where is for this question.
3720 GetOffsetFromConfigResp (
3721 IN FORM_BROWSER_STATEMENT
*Question
,
3722 IN CHAR16
*ConfigResp
3725 CHAR16
*RequestElement
;
3729 // Type is EFI_HII_VARSTORE_NAME_VALUE.
3731 if (Question
->Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
3732 RequestElement
= StrStr (ConfigResp
, Question
->VariableName
);
3733 if (RequestElement
!= NULL
) {
3735 // Skip the "VariableName=" field.
3737 RequestElement
+= StrLen (Question
->VariableName
) + 1;
3740 return RequestElement
;
3744 // Type is EFI_HII_VARSTORE_EFI_VARIABLE or EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
3748 // 1. Directly use Question->BlockName to find.
3750 RequestElement
= StrStr (ConfigResp
, Question
->BlockName
);
3751 if (RequestElement
!= NULL
) {
3753 // Skip the "Question->BlockName&VALUE=" field.
3755 RequestElement
+= StrLen (Question
->BlockName
) + StrLen (L
"&VALUE=");
3756 return RequestElement
;
3760 // 2. Change all hex digits in Question->BlockName to lower and compare again.
3762 BlockData
= AllocateCopyPool (StrSize(Question
->BlockName
), Question
->BlockName
);
3763 ASSERT (BlockData
!= NULL
);
3764 HiiToLower (BlockData
);
3765 RequestElement
= StrStr (ConfigResp
, BlockData
);
3766 FreePool (BlockData
);
3768 if (RequestElement
!= NULL
) {
3770 // Skip the "Question->BlockName&VALUE=" field.
3772 RequestElement
+= StrLen (Question
->BlockName
) + StrLen (L
"&VALUE=");
3775 return RequestElement
;
3779 Get Question default value from AltCfg string.
3781 @param FormSet The form set.
3782 @param Form The form
3783 @param Question The question.
3785 @retval EFI_SUCCESS Question is reset to default value.
3789 GetDefaultValueFromAltCfg (
3790 IN FORM_BROWSER_FORMSET
*FormSet
,
3791 IN FORM_BROWSER_FORM
*Form
,
3792 IN OUT FORM_BROWSER_STATEMENT
*Question
3795 BROWSER_STORAGE
*Storage
;
3796 FORMSET_STORAGE
*FormSetStorage
;
3800 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
3802 Storage
= Question
->Storage
;
3803 if ((Storage
== NULL
) || (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
)) {
3804 return EFI_NOT_FOUND
;
3808 // Try to get AltCfg string from form. If not found it, then
3809 // try to get it from formset.
3812 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
3813 while (!IsNull (&Form
->ConfigRequestHead
, Link
)) {
3814 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
3815 Link
= GetNextNode (&Form
->ConfigRequestHead
, Link
);
3817 if (Storage
== ConfigInfo
->Storage
) {
3818 ConfigResp
= ConfigInfo
->ConfigAltResp
;
3823 if (ConfigResp
== NULL
) {
3824 Link
= GetFirstNode (&FormSet
->StorageListHead
);
3825 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
3826 FormSetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
3827 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
3829 if (Storage
== FormSetStorage
->BrowserStorage
) {
3830 ConfigResp
= FormSetStorage
->ConfigAltResp
;
3836 if (ConfigResp
== NULL
) {
3837 return EFI_NOT_FOUND
;
3840 Value
= GetOffsetFromConfigResp (Question
, ConfigResp
);
3841 if (Value
== NULL
) {
3842 return EFI_NOT_FOUND
;
3845 return BufferToValue (Question
, Value
);
3849 Get default Id value used for browser.
3851 @param DefaultId The default id value used by hii.
3853 @retval Browser used default value.
3857 GetDefaultIdForCallBack (
3861 if (DefaultId
== EFI_HII_DEFAULT_CLASS_STANDARD
) {
3862 return EFI_BROWSER_ACTION_DEFAULT_STANDARD
;
3863 } else if (DefaultId
== EFI_HII_DEFAULT_CLASS_MANUFACTURING
) {
3864 return EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING
;
3865 } else if (DefaultId
== EFI_HII_DEFAULT_CLASS_SAFE
) {
3866 return EFI_BROWSER_ACTION_DEFAULT_SAFE
;
3867 } else if (DefaultId
>= EFI_HII_DEFAULT_CLASS_PLATFORM_BEGIN
&& DefaultId
< EFI_HII_DEFAULT_CLASS_PLATFORM_BEGIN
+ 0x1000) {
3868 return EFI_BROWSER_ACTION_DEFAULT_PLATFORM
+ DefaultId
- EFI_HII_DEFAULT_CLASS_PLATFORM_BEGIN
;
3869 } else if (DefaultId
>= EFI_HII_DEFAULT_CLASS_HARDWARE_BEGIN
&& DefaultId
< EFI_HII_DEFAULT_CLASS_HARDWARE_BEGIN
+ 0x1000) {
3870 return EFI_BROWSER_ACTION_DEFAULT_HARDWARE
+ DefaultId
- EFI_HII_DEFAULT_CLASS_HARDWARE_BEGIN
;
3871 } else if (DefaultId
>= EFI_HII_DEFAULT_CLASS_FIRMWARE_BEGIN
&& DefaultId
< EFI_HII_DEFAULT_CLASS_FIRMWARE_BEGIN
+ 0x1000) {
3872 return EFI_BROWSER_ACTION_DEFAULT_FIRMWARE
+ DefaultId
- EFI_HII_DEFAULT_CLASS_FIRMWARE_BEGIN
;
3881 Return data element in an Array by its Index.
3883 @param Array The data array.
3884 @param Type Type of the data in this array.
3885 @param Index Zero based index for data in this array.
3887 @retval Value The data to be returned
3899 ASSERT (Array
!= NULL
);
3903 case EFI_IFR_TYPE_NUM_SIZE_8
:
3904 Data
= (UINT64
) *(((UINT8
*) Array
) + Index
);
3907 case EFI_IFR_TYPE_NUM_SIZE_16
:
3908 Data
= (UINT64
) *(((UINT16
*) Array
) + Index
);
3911 case EFI_IFR_TYPE_NUM_SIZE_32
:
3912 Data
= (UINT64
) *(((UINT32
*) Array
) + Index
);
3915 case EFI_IFR_TYPE_NUM_SIZE_64
:
3916 Data
= (UINT64
) *(((UINT64
*) Array
) + Index
);
3928 Set value of a data element in an Array by its Index.
3930 @param Array The data array.
3931 @param Type Type of the data in this array.
3932 @param Index Zero based index for data in this array.
3933 @param Value The value to be set.
3945 ASSERT (Array
!= NULL
);
3948 case EFI_IFR_TYPE_NUM_SIZE_8
:
3949 *(((UINT8
*) Array
) + Index
) = (UINT8
) Value
;
3952 case EFI_IFR_TYPE_NUM_SIZE_16
:
3953 *(((UINT16
*) Array
) + Index
) = (UINT16
) Value
;
3956 case EFI_IFR_TYPE_NUM_SIZE_32
:
3957 *(((UINT32
*) Array
) + Index
) = (UINT32
) Value
;
3960 case EFI_IFR_TYPE_NUM_SIZE_64
:
3961 *(((UINT64
*) Array
) + Index
) = (UINT64
) Value
;
3970 Search an Option of a Question by its value.
3972 @param Question The Question
3973 @param OptionValue Value for Option to be searched.
3975 @retval Pointer Pointer to the found Option.
3976 @retval NULL Option not found.
3981 IN FORM_BROWSER_STATEMENT
*Question
,
3982 IN EFI_HII_VALUE
*OptionValue
3986 QUESTION_OPTION
*Option
;
3989 Link
= GetFirstNode (&Question
->OptionListHead
);
3990 while (!IsNull (&Question
->OptionListHead
, Link
)) {
3991 Option
= QUESTION_OPTION_FROM_LINK (Link
);
3993 if ((CompareHiiValue (&Option
->Value
, OptionValue
, &Result
, NULL
) == EFI_SUCCESS
) && (Result
== 0)) {
3995 // Check the suppressif condition, only a valid option can be return.
3997 if ((Option
->SuppressExpression
== NULL
) ||
3998 ((EvaluateExpressionList(Option
->SuppressExpression
, FALSE
, NULL
, NULL
) == ExpressFalse
))) {
4003 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
4011 Reset Question to its default value.
4013 @param FormSet The form set.
4014 @param Form The form.
4015 @param Question The question.
4016 @param DefaultId The Class of the default.
4018 @retval EFI_SUCCESS Question is reset to default value.
4022 GetQuestionDefault (
4023 IN FORM_BROWSER_FORMSET
*FormSet
,
4024 IN FORM_BROWSER_FORM
*Form
,
4025 IN FORM_BROWSER_STATEMENT
*Question
,
4031 QUESTION_DEFAULT
*Default
;
4032 QUESTION_OPTION
*Option
;
4033 EFI_HII_VALUE
*HiiValue
;
4035 EFI_STRING StrValue
;
4036 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
4037 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
4040 EFI_IFR_TYPE_VALUE
*TypeValue
;
4042 Status
= EFI_NOT_FOUND
;
4046 // Statement don't have storage, skip them
4048 if (Question
->QuestionId
== 0) {
4053 // There are Five ways to specify default value for a Question:
4054 // 1, use call back function (highest priority)
4055 // 2, use ExtractConfig function
4056 // 3, use nested EFI_IFR_DEFAULT
4057 // 4, set flags of EFI_ONE_OF_OPTION (provide Standard and Manufacturing default)
4058 // 5, set flags of EFI_IFR_CHECKBOX (provide Standard and Manufacturing default) (lowest priority)
4060 HiiValue
= &Question
->HiiValue
;
4061 TypeValue
= &HiiValue
->Value
;
4062 if (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
) {
4064 // For orderedlist, need to pass the BufferValue to Callback function.
4066 TypeValue
= (EFI_IFR_TYPE_VALUE
*) Question
->BufferValue
;
4070 // Get Question defaut value from call back function.
4072 ConfigAccess
= FormSet
->ConfigAccess
;
4073 Action
= GetDefaultIdForCallBack (DefaultId
);
4074 if ((Action
> 0) && ((Question
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) != 0) && (ConfigAccess
!= NULL
)) {
4075 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
4076 Status
= ConfigAccess
->Callback (
4079 Question
->QuestionId
,
4084 if (!EFI_ERROR (Status
)) {
4085 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
4086 NewString
= GetToken (Question
->HiiValue
.Value
.string
, FormSet
->HiiHandle
);
4087 ASSERT (NewString
!= NULL
);
4089 ASSERT (StrLen (NewString
) * sizeof (CHAR16
) <= Question
->StorageWidth
);
4090 if (StrLen (NewString
) * sizeof (CHAR16
) <= Question
->StorageWidth
) {
4091 CopyMem (Question
->BufferValue
, NewString
, StrSize (NewString
));
4093 CopyMem (Question
->BufferValue
, NewString
, Question
->StorageWidth
);
4096 FreePool (NewString
);
4103 // Get default value from altcfg string.
4105 if (ConfigAccess
!= NULL
) {
4106 Status
= GetDefaultValueFromAltCfg(FormSet
, Form
, Question
);
4107 if (!EFI_ERROR (Status
)) {
4113 // EFI_IFR_DEFAULT has highest priority
4115 if (!IsListEmpty (&Question
->DefaultListHead
)) {
4116 Link
= GetFirstNode (&Question
->DefaultListHead
);
4117 while (!IsNull (&Question
->DefaultListHead
, Link
)) {
4118 Default
= QUESTION_DEFAULT_FROM_LINK (Link
);
4120 if (Default
->DefaultId
== DefaultId
) {
4121 if (Default
->ValueExpression
!= NULL
) {
4123 // Default is provided by an Expression, evaluate it
4125 Status
= EvaluateExpression (FormSet
, Form
, Default
->ValueExpression
);
4126 if (EFI_ERROR (Status
)) {
4130 if (Default
->ValueExpression
->Result
.Type
== EFI_IFR_TYPE_BUFFER
) {
4131 ASSERT (HiiValue
->Type
== EFI_IFR_TYPE_BUFFER
&& Question
->BufferValue
!= NULL
);
4132 if (Question
->StorageWidth
> Default
->ValueExpression
->Result
.BufferLen
) {
4133 CopyMem (Question
->HiiValue
.Buffer
, Default
->ValueExpression
->Result
.Buffer
, Default
->ValueExpression
->Result
.BufferLen
);
4134 Question
->HiiValue
.BufferLen
= Default
->ValueExpression
->Result
.BufferLen
;
4136 CopyMem (Question
->HiiValue
.Buffer
, Default
->ValueExpression
->Result
.Buffer
, Question
->StorageWidth
);
4137 Question
->HiiValue
.BufferLen
= Question
->StorageWidth
;
4139 FreePool (Default
->ValueExpression
->Result
.Buffer
);
4141 HiiValue
->Type
= Default
->ValueExpression
->Result
.Type
;
4142 CopyMem (&HiiValue
->Value
, &Default
->ValueExpression
->Result
.Value
, sizeof (EFI_IFR_TYPE_VALUE
));
4145 // Default value is embedded in EFI_IFR_DEFAULT
4147 if (Default
->Value
.Type
== EFI_IFR_TYPE_BUFFER
) {
4148 ASSERT (HiiValue
->Buffer
!= NULL
);
4149 CopyMem (HiiValue
->Buffer
, Default
->Value
.Buffer
, Default
->Value
.BufferLen
);
4151 CopyMem (HiiValue
, &Default
->Value
, sizeof (EFI_HII_VALUE
));
4155 if (HiiValue
->Type
== EFI_IFR_TYPE_STRING
) {
4156 StrValue
= HiiGetString (FormSet
->HiiHandle
, HiiValue
->Value
.string
, NULL
);
4157 if (StrValue
== NULL
) {
4158 return EFI_NOT_FOUND
;
4160 if (Question
->StorageWidth
> StrSize (StrValue
)) {
4161 CopyMem (Question
->BufferValue
, StrValue
, StrSize (StrValue
));
4163 CopyMem (Question
->BufferValue
, StrValue
, Question
->StorageWidth
);
4170 Link
= GetNextNode (&Question
->DefaultListHead
, Link
);
4175 // EFI_ONE_OF_OPTION
4177 if ((Question
->Operand
== EFI_IFR_ONE_OF_OP
) && !IsListEmpty (&Question
->OptionListHead
)) {
4178 if (DefaultId
<= EFI_HII_DEFAULT_CLASS_MANUFACTURING
) {
4180 // OneOfOption could only provide Standard and Manufacturing default
4182 Link
= GetFirstNode (&Question
->OptionListHead
);
4183 while (!IsNull (&Question
->OptionListHead
, Link
)) {
4184 Option
= QUESTION_OPTION_FROM_LINK (Link
);
4185 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
4187 if ((Option
->SuppressExpression
!= NULL
) &&
4188 EvaluateExpressionList(Option
->SuppressExpression
, FALSE
, NULL
, NULL
) != ExpressFalse
) {
4192 if (((DefaultId
== EFI_HII_DEFAULT_CLASS_STANDARD
) && ((Option
->Flags
& EFI_IFR_OPTION_DEFAULT
) != 0)) ||
4193 ((DefaultId
== EFI_HII_DEFAULT_CLASS_MANUFACTURING
) && ((Option
->Flags
& EFI_IFR_OPTION_DEFAULT_MFG
) != 0))
4195 CopyMem (HiiValue
, &Option
->Value
, sizeof (EFI_HII_VALUE
));
4204 // EFI_IFR_CHECKBOX - lowest priority
4206 if (Question
->Operand
== EFI_IFR_CHECKBOX_OP
) {
4207 if (DefaultId
<= EFI_HII_DEFAULT_CLASS_MANUFACTURING
) {
4209 // Checkbox could only provide Standard and Manufacturing default
4211 if (((DefaultId
== EFI_HII_DEFAULT_CLASS_STANDARD
) && ((Question
->Flags
& EFI_IFR_CHECKBOX_DEFAULT
) != 0)) ||
4212 ((DefaultId
== EFI_HII_DEFAULT_CLASS_MANUFACTURING
) && ((Question
->Flags
& EFI_IFR_CHECKBOX_DEFAULT_MFG
) != 0))
4214 HiiValue
->Value
.b
= TRUE
;
4216 HiiValue
->Value
.b
= FALSE
;
4224 // For Questions without default
4226 Status
= EFI_NOT_FOUND
;
4227 switch (Question
->Operand
) {
4228 case EFI_IFR_NUMERIC_OP
:
4230 // Take minimum value as numeric default value
4232 if ((Question
->Flags
& EFI_IFR_DISPLAY
) == 0) {
4234 // In EFI_IFR_DISPLAY_INT_DEC type, should check value with int* type.
4236 switch (Question
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
4237 case EFI_IFR_NUMERIC_SIZE_1
:
4238 if (((INT8
) HiiValue
->Value
.u8
< (INT8
) Question
->Minimum
) || ((INT8
) HiiValue
->Value
.u8
> (INT8
) Question
->Maximum
)) {
4239 HiiValue
->Value
.u8
= (UINT8
) Question
->Minimum
;
4240 Status
= EFI_SUCCESS
;
4243 case EFI_IFR_NUMERIC_SIZE_2
:
4244 if (((INT16
) HiiValue
->Value
.u16
< (INT16
) Question
->Minimum
) || ((INT16
) HiiValue
->Value
.u16
> (INT16
) Question
->Maximum
)) {
4245 HiiValue
->Value
.u16
= (UINT16
) Question
->Minimum
;
4246 Status
= EFI_SUCCESS
;
4249 case EFI_IFR_NUMERIC_SIZE_4
:
4250 if (((INT32
) HiiValue
->Value
.u32
< (INT32
) Question
->Minimum
) || ((INT32
) HiiValue
->Value
.u32
> (INT32
) Question
->Maximum
)) {
4251 HiiValue
->Value
.u32
= (UINT32
) Question
->Minimum
;
4252 Status
= EFI_SUCCESS
;
4255 case EFI_IFR_NUMERIC_SIZE_8
:
4256 if (((INT64
) HiiValue
->Value
.u64
< (INT64
) Question
->Minimum
) || ((INT64
) HiiValue
->Value
.u64
> (INT64
) Question
->Maximum
)) {
4257 HiiValue
->Value
.u64
= Question
->Minimum
;
4258 Status
= EFI_SUCCESS
;
4265 if ((HiiValue
->Value
.u64
< Question
->Minimum
) || (HiiValue
->Value
.u64
> Question
->Maximum
)) {
4266 HiiValue
->Value
.u64
= Question
->Minimum
;
4267 Status
= EFI_SUCCESS
;
4272 case EFI_IFR_ONE_OF_OP
:
4274 // Take first oneof option as oneof's default value
4276 if (ValueToOption (Question
, HiiValue
) == NULL
) {
4277 Link
= GetFirstNode (&Question
->OptionListHead
);
4278 while (!IsNull (&Question
->OptionListHead
, Link
)) {
4279 Option
= QUESTION_OPTION_FROM_LINK (Link
);
4280 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
4282 if ((Option
->SuppressExpression
!= NULL
) &&
4283 EvaluateExpressionList(Option
->SuppressExpression
, FALSE
, NULL
, NULL
) != ExpressFalse
) {
4287 CopyMem (HiiValue
, &Option
->Value
, sizeof (EFI_HII_VALUE
));
4288 Status
= EFI_SUCCESS
;
4294 case EFI_IFR_ORDERED_LIST_OP
:
4296 // Take option sequence in IFR as ordered list's default value
4299 Link
= GetFirstNode (&Question
->OptionListHead
);
4300 while (!IsNull (&Question
->OptionListHead
, Link
)) {
4301 Status
= EFI_SUCCESS
;
4302 Option
= QUESTION_OPTION_FROM_LINK (Link
);
4303 Link
= GetNextNode (&Question
->OptionListHead
, Link
);
4305 if ((Option
->SuppressExpression
!= NULL
) &&
4306 EvaluateExpressionList(Option
->SuppressExpression
, FALSE
, NULL
, NULL
) != ExpressFalse
) {
4310 SetArrayData (Question
->BufferValue
, Question
->ValueType
, Index
, Option
->Value
.Value
.u64
);
4313 if (Index
>= Question
->MaxContainers
) {
4327 Get AltCfg string for current form.
4329 @param FormSet Form data structure.
4330 @param Form Form data structure.
4331 @param DefaultId The Class of the default.
4332 @param BrowserStorage The input request storage for the questions.
4336 ExtractAltCfgForForm (
4337 IN FORM_BROWSER_FORMSET
*FormSet
,
4338 IN FORM_BROWSER_FORM
*Form
,
4339 IN UINT16 DefaultId
,
4340 IN BROWSER_STORAGE
*BrowserStorage
4348 BROWSER_STORAGE
*Storage
;
4349 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
4350 FORMSET_STORAGE
*FormSetStorage
;
4353 // Check whether has get AltCfg string for this formset.
4354 // If yes, no need to get AltCfg for form.
4356 Link
= GetFirstNode (&FormSet
->StorageListHead
);
4357 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
4358 FormSetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
4359 Storage
= FormSetStorage
->BrowserStorage
;
4360 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
4361 if (BrowserStorage
!= NULL
&& BrowserStorage
!= Storage
) {
4365 if (Storage
->Type
!= EFI_HII_VARSTORE_EFI_VARIABLE
&&
4366 FormSetStorage
->ElementCount
!= 0 &&
4367 FormSetStorage
->HasCallAltCfg
) {
4373 // Get AltCfg string for each form.
4375 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
4376 while (!IsNull (&Form
->ConfigRequestHead
, Link
)) {
4377 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
4378 Link
= GetNextNode (&Form
->ConfigRequestHead
, Link
);
4380 Storage
= ConfigInfo
->Storage
;
4381 if (BrowserStorage
!= NULL
&& BrowserStorage
!= Storage
) {
4385 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
4390 // 1. Skip if there is no RequestElement
4392 if (ConfigInfo
->ElementCount
== 0) {
4397 // 2. Get value through hii config routine protocol.
4399 Status
= mHiiConfigRouting
->ExtractConfig (
4401 ConfigInfo
->ConfigRequest
,
4405 if (EFI_ERROR (Status
)) {
4410 // 3. Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)
4411 // Get the default configuration string according to the default ID.
4413 Status
= mHiiConfigRouting
->GetAltConfig (
4419 &DefaultId
, // it can be NULL to get the current setting.
4423 if (EFI_ERROR (Status
)) {
4427 ConfigInfo
->ConfigAltResp
= ConfigResp
;
4432 Clean AltCfg string for current form.
4434 @param Form Form data structure.
4438 CleanAltCfgForForm (
4439 IN FORM_BROWSER_FORM
*Form
4443 FORM_BROWSER_CONFIG_REQUEST
*ConfigInfo
;
4445 Link
= GetFirstNode (&Form
->ConfigRequestHead
);
4446 while (!IsNull (&Form
->ConfigRequestHead
, Link
)) {
4447 ConfigInfo
= FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link
);
4448 Link
= GetNextNode (&Form
->ConfigRequestHead
, Link
);
4450 if (ConfigInfo
->ConfigAltResp
!= NULL
) {
4451 FreePool (ConfigInfo
->ConfigAltResp
);
4452 ConfigInfo
->ConfigAltResp
= NULL
;
4458 Get AltCfg string for current formset.
4460 @param FormSet Form data structure.
4461 @param DefaultId The Class of the default.
4462 @param BrowserStorage The input request storage for the questions.
4466 ExtractAltCfgForFormSet (
4467 IN FORM_BROWSER_FORMSET
*FormSet
,
4468 IN UINT16 DefaultId
,
4469 IN BROWSER_STORAGE
*BrowserStorage
4477 BROWSER_STORAGE
*Storage
;
4478 FORMSET_STORAGE
*FormSetStorage
;
4480 Link
= GetFirstNode (&FormSet
->StorageListHead
);
4481 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
4482 FormSetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
4483 Storage
= FormSetStorage
->BrowserStorage
;
4484 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
4486 if (BrowserStorage
!= NULL
&& BrowserStorage
!= Storage
) {
4490 if (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE
) {
4495 // 1. Skip if there is no RequestElement
4497 if (FormSetStorage
->ElementCount
== 0) {
4501 FormSetStorage
->HasCallAltCfg
= TRUE
;
4504 // 2. Get value through hii config routine protocol.
4506 Status
= mHiiConfigRouting
->ExtractConfig (
4508 FormSetStorage
->ConfigRequest
,
4512 if (EFI_ERROR (Status
)) {
4517 // 3. Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)
4518 // Get the default configuration string according to the default ID.
4520 Status
= mHiiConfigRouting
->GetAltConfig (
4526 &DefaultId
, // it can be NULL to get the current setting.
4531 if (EFI_ERROR (Status
)) {
4535 FormSetStorage
->ConfigAltResp
= ConfigResp
;
4541 Clean AltCfg string for current formset.
4543 @param FormSet Form data structure.
4547 CleanAltCfgForFormSet (
4548 IN FORM_BROWSER_FORMSET
*FormSet
4552 FORMSET_STORAGE
*FormSetStorage
;
4554 Link
= GetFirstNode (&FormSet
->StorageListHead
);
4555 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
4556 FormSetStorage
= FORMSET_STORAGE_FROM_LINK (Link
);
4557 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
4559 if (FormSetStorage
->ConfigAltResp
!= NULL
) {
4560 FreePool (FormSetStorage
->ConfigAltResp
);
4561 FormSetStorage
->ConfigAltResp
= NULL
;
4564 FormSetStorage
->HasCallAltCfg
= FALSE
;
4569 Reset Questions to their initial value or default value in a Form, Formset or System.
4571 GetDefaultValueScope parameter decides which questions will reset
4572 to its default value.
4574 @param FormSet FormSet data structure.
4575 @param Form Form data structure.
4576 @param DefaultId The Class of the default.
4577 @param SettingScope Setting Scope for Default action.
4578 @param GetDefaultValueScope Get default value scope.
4579 @param Storage Get default value only for this storage.
4580 @param RetrieveValueFirst Whether call the retrieve call back to
4581 get the initial value before get default
4583 @param SkipGetAltCfg Whether skip the get altcfg string process.
4585 @retval EFI_SUCCESS The function completed successfully.
4586 @retval EFI_UNSUPPORTED Unsupport SettingScope.
4591 IN FORM_BROWSER_FORMSET
*FormSet
,
4592 IN FORM_BROWSER_FORM
*Form
,
4593 IN UINT16 DefaultId
,
4594 IN BROWSER_SETTING_SCOPE SettingScope
,
4595 IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope
,
4596 IN BROWSER_STORAGE
*Storage OPTIONAL
,
4597 IN BOOLEAN RetrieveValueFirst
,
4598 IN BOOLEAN SkipGetAltCfg
4602 LIST_ENTRY
*FormLink
;
4604 FORM_BROWSER_STATEMENT
*Question
;
4605 FORM_BROWSER_FORMSET
*LocalFormSet
;
4606 FORM_BROWSER_FORMSET
*OldFormSet
;
4608 Status
= EFI_SUCCESS
;
4611 // Check the supported setting level.
4613 if (SettingScope
>= MaxLevel
|| GetDefaultValueScope
>= GetDefaultForMax
) {
4614 return EFI_UNSUPPORTED
;
4617 if (GetDefaultValueScope
== GetDefaultForStorage
&& Storage
== NULL
) {
4618 return EFI_UNSUPPORTED
;
4621 if (SettingScope
== FormLevel
) {
4623 // Prepare the AltCfg String for form.
4625 if (!SkipGetAltCfg
&& (GetDefaultValueScope
!= GetDefaultForNoStorage
)) {
4626 ExtractAltCfgForForm (FormSet
, Form
, DefaultId
, Storage
);
4630 // Extract Form default
4632 Link
= GetFirstNode (&Form
->StatementListHead
);
4633 while (!IsNull (&Form
->StatementListHead
, Link
)) {
4634 Question
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
4635 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
4638 // If get default value only for this storage, check the storage first.
4640 if ((GetDefaultValueScope
== GetDefaultForStorage
) && (Question
->Storage
!= Storage
)) {
4645 // If get default value only for no storage question, just skip the question which has storage.
4647 if ((GetDefaultValueScope
== GetDefaultForNoStorage
) && (Question
->Storage
!= NULL
)) {
4652 // If Question is disabled, don't reset it to default
4654 if (Question
->Expression
!= NULL
) {
4655 if (EvaluateExpressionList(Question
->Expression
, TRUE
, FormSet
, Form
) == ExpressDisable
) {
4660 if (RetrieveValueFirst
) {
4662 // Call the Retrieve call back to get the initial question value.
4664 Status
= ProcessRetrieveForQuestion(FormSet
->ConfigAccess
, Question
, FormSet
);
4668 // If not request to get the initial value or get initial value fail, then get default value.
4670 if (!RetrieveValueFirst
|| EFI_ERROR (Status
)) {
4671 Status
= GetQuestionDefault (FormSet
, Form
, Question
, DefaultId
);
4672 if (EFI_ERROR (Status
)) {
4678 // Synchronize Buffer storage's Edit buffer
4680 if ((Question
->Storage
!= NULL
) &&
4681 (Question
->Storage
->Type
!= EFI_HII_VARSTORE_EFI_VARIABLE
)) {
4682 SetQuestionValue (FormSet
, Form
, Question
, GetSetValueWithEditBuffer
);
4687 // Clean the AltCfg String.
4689 if (!SkipGetAltCfg
&& (GetDefaultValueScope
!= GetDefaultForNoStorage
)) {
4690 CleanAltCfgForForm(Form
);
4692 } else if (SettingScope
== FormSetLevel
) {
4694 // Prepare the AltCfg String for formset.
4696 if (!SkipGetAltCfg
&& (GetDefaultValueScope
!= GetDefaultForNoStorage
)) {
4697 ExtractAltCfgForFormSet (FormSet
, DefaultId
, Storage
);
4700 FormLink
= GetFirstNode (&FormSet
->FormListHead
);
4701 while (!IsNull (&FormSet
->FormListHead
, FormLink
)) {
4702 Form
= FORM_BROWSER_FORM_FROM_LINK (FormLink
);
4703 ExtractDefault (FormSet
, Form
, DefaultId
, FormLevel
, GetDefaultValueScope
, Storage
, RetrieveValueFirst
, SkipGetAltCfg
);
4704 FormLink
= GetNextNode (&FormSet
->FormListHead
, FormLink
);
4708 // Clean the AltCfg String.
4710 if (!SkipGetAltCfg
&& (GetDefaultValueScope
!= GetDefaultForNoStorage
)) {
4711 CleanAltCfgForFormSet (FormSet
);
4713 } else if (SettingScope
== SystemLevel
) {
4715 // Preload all Hii formset.
4717 LoadAllHiiFormset();
4719 OldFormSet
= mSystemLevelFormSet
;
4722 // Set Default Value for each FormSet in the maintain list.
4724 Link
= GetFirstNode (&gBrowserFormSetList
);
4725 while (!IsNull (&gBrowserFormSetList
, Link
)) {
4726 LocalFormSet
= FORM_BROWSER_FORMSET_FROM_LINK (Link
);
4727 Link
= GetNextNode (&gBrowserFormSetList
, Link
);
4728 if (!ValidateFormSet(LocalFormSet
)) {
4732 mSystemLevelFormSet
= LocalFormSet
;
4734 ExtractDefault (LocalFormSet
, NULL
, DefaultId
, FormSetLevel
, GetDefaultValueScope
, Storage
, RetrieveValueFirst
, SkipGetAltCfg
);
4737 mSystemLevelFormSet
= OldFormSet
;
4745 Validate whether this question's value has changed.
4747 @param FormSet FormSet data structure.
4748 @param Form Form data structure.
4749 @param Question Question to be initialized.
4750 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.
4752 @retval TRUE Question's value has changed.
4753 @retval FALSE Question's value has not changed
4757 IsQuestionValueChanged (
4758 IN FORM_BROWSER_FORMSET
*FormSet
,
4759 IN FORM_BROWSER_FORM
*Form
,
4760 IN OUT FORM_BROWSER_STATEMENT
*Question
,
4761 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
4764 EFI_HII_VALUE BackUpValue
;
4765 CHAR8
*BackUpBuffer
;
4766 EFI_HII_VALUE BackUpValue2
;
4767 CHAR8
*BackUpBuffer2
;
4769 BOOLEAN ValueChanged
;
4773 // For quetion without storage, always mark it as data not changed.
4775 if (Question
->Storage
== NULL
&& Question
->Operand
!= EFI_IFR_TIME_OP
&& Question
->Operand
!= EFI_IFR_DATE_OP
) {
4779 BackUpBuffer
= NULL
;
4780 BackUpBuffer2
= NULL
;
4781 ValueChanged
= FALSE
;
4783 switch (Question
->Operand
) {
4784 case EFI_IFR_ORDERED_LIST_OP
:
4785 BufferWidth
= Question
->StorageWidth
;
4786 BackUpBuffer
= AllocateCopyPool (BufferWidth
, Question
->BufferValue
);
4787 ASSERT (BackUpBuffer
!= NULL
);
4790 case EFI_IFR_STRING_OP
:
4791 case EFI_IFR_PASSWORD_OP
:
4792 BufferWidth
= (UINTN
) Question
->Maximum
* sizeof (CHAR16
);
4793 BackUpBuffer
= AllocateCopyPool (BufferWidth
, Question
->BufferValue
);
4794 ASSERT (BackUpBuffer
!= NULL
);
4801 CopyMem (&BackUpValue
, &Question
->HiiValue
, sizeof (EFI_HII_VALUE
));
4803 if (GetValueFrom
== GetSetValueWithBothBuffer
) {
4804 Status
= GetQuestionValue (FormSet
, Form
, Question
, GetSetValueWithEditBuffer
);
4805 ASSERT_EFI_ERROR(Status
);
4807 switch (Question
->Operand
) {
4808 case EFI_IFR_ORDERED_LIST_OP
:
4809 BufferWidth
= Question
->StorageWidth
;
4810 BackUpBuffer2
= AllocateCopyPool (BufferWidth
, Question
->BufferValue
);
4811 ASSERT (BackUpBuffer2
!= NULL
);
4814 case EFI_IFR_STRING_OP
:
4815 case EFI_IFR_PASSWORD_OP
:
4816 BufferWidth
= (UINTN
) Question
->Maximum
* sizeof (CHAR16
);
4817 BackUpBuffer2
= AllocateCopyPool (BufferWidth
, Question
->BufferValue
);
4818 ASSERT (BackUpBuffer2
!= NULL
);
4825 CopyMem (&BackUpValue2
, &Question
->HiiValue
, sizeof (EFI_HII_VALUE
));
4827 Status
= GetQuestionValue (FormSet
, Form
, Question
, GetSetValueWithBuffer
);
4828 ASSERT_EFI_ERROR(Status
);
4830 if (CompareMem (&BackUpValue2
, &Question
->HiiValue
, sizeof (EFI_HII_VALUE
)) != 0 ||
4831 CompareMem (BackUpBuffer2
, Question
->BufferValue
, BufferWidth
) != 0) {
4832 ValueChanged
= TRUE
;
4835 Status
= GetQuestionValue (FormSet
, Form
, Question
, GetValueFrom
);
4836 ASSERT_EFI_ERROR(Status
);
4838 if (CompareMem (&BackUpValue
, &Question
->HiiValue
, sizeof (EFI_HII_VALUE
)) != 0 ||
4839 CompareMem (BackUpBuffer
, Question
->BufferValue
, BufferWidth
) != 0) {
4840 ValueChanged
= TRUE
;
4844 CopyMem (&Question
->HiiValue
, &BackUpValue
, sizeof (EFI_HII_VALUE
));
4845 if (BackUpBuffer
!= NULL
) {
4846 CopyMem (Question
->BufferValue
, BackUpBuffer
, BufferWidth
);
4847 FreePool (BackUpBuffer
);
4850 if (BackUpBuffer2
!= NULL
) {
4851 FreePool (BackUpBuffer2
);
4854 Question
->ValueChanged
= ValueChanged
;
4856 return ValueChanged
;
4860 Initialize Question's Edit copy from Storage.
4862 @param Selection Selection contains the information about
4863 the Selection, form and formset to be displayed.
4864 Selection action may be updated in retrieve callback.
4865 If Selection is NULL, only initialize Question value.
4866 @param FormSet FormSet data structure.
4867 @param Form Form data structure.
4869 @retval EFI_SUCCESS The function completed successfully.
4874 IN OUT UI_MENU_SELECTION
*Selection
,
4875 IN FORM_BROWSER_FORMSET
*FormSet
,
4876 IN FORM_BROWSER_FORM
*Form
4881 FORM_BROWSER_STATEMENT
*Question
;
4883 Link
= GetFirstNode (&Form
->StatementListHead
);
4884 while (!IsNull (&Form
->StatementListHead
, Link
)) {
4885 Question
= FORM_BROWSER_STATEMENT_FROM_LINK (Link
);
4888 // Initialize local copy of Value for each Question
4890 if (Question
->Operand
== EFI_IFR_PASSWORD_OP
&& (Question
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
)== 0) {
4891 Status
= GetQuestionValue (FormSet
, Form
, Question
, GetSetValueWithHiiDriver
);
4893 Status
= GetQuestionValue (FormSet
, Form
, Question
, GetSetValueWithEditBuffer
);
4895 if (EFI_ERROR (Status
)) {
4899 if ((Question
->Operand
== EFI_IFR_STRING_OP
) || (Question
->Operand
== EFI_IFR_PASSWORD_OP
)) {
4900 HiiSetString (FormSet
->HiiHandle
, Question
->HiiValue
.Value
.string
, (CHAR16
*)Question
->BufferValue
, NULL
);
4903 Link
= GetNextNode (&Form
->StatementListHead
, Link
);
4910 Initialize Question's Edit copy from Storage for the whole Formset.
4912 @param Selection Selection contains the information about
4913 the Selection, form and formset to be displayed.
4914 Selection action may be updated in retrieve callback.
4915 If Selection is NULL, only initialize Question value.
4916 @param FormSet FormSet data structure.
4918 @retval EFI_SUCCESS The function completed successfully.
4923 IN OUT UI_MENU_SELECTION
*Selection
,
4924 IN FORM_BROWSER_FORMSET
*FormSet
4929 FORM_BROWSER_FORM
*Form
;
4931 Link
= GetFirstNode (&FormSet
->FormListHead
);
4932 while (!IsNull (&FormSet
->FormListHead
, Link
)) {
4933 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
4936 // Initialize local copy of Value for each Form
4938 Status
= LoadFormConfig (Selection
, FormSet
, Form
);
4939 if (EFI_ERROR (Status
)) {
4943 Link
= GetNextNode (&FormSet
->FormListHead
, Link
);
4947 // Finished question initialization.
4949 FormSet
->QuestionInited
= TRUE
;
4955 Remove the Request element from the Config Request.
4957 @param Storage Pointer to the browser storage.
4958 @param RequestElement The pointer to the Request element.
4963 IN OUT BROWSER_STORAGE
*Storage
,
4964 IN CHAR16
*RequestElement
4970 ASSERT (Storage
->ConfigRequest
!= NULL
&& RequestElement
!= NULL
);
4972 NewStr
= StrStr (Storage
->ConfigRequest
, RequestElement
);
4974 if (NewStr
== NULL
) {
4979 // Remove this element from this ConfigRequest.
4982 NewStr
+= StrLen (RequestElement
);
4983 CopyMem (DestStr
, NewStr
, StrSize (NewStr
));
4985 Storage
->SpareStrLen
+= StrLen (RequestElement
);
4989 Adjust config request in storage, remove the request elements existed in the input ConfigRequest.
4991 @param Storage Pointer to the formset storage.
4992 @param ConfigRequest The pointer to the Request element.
4996 RemoveConfigRequest (
4997 FORMSET_STORAGE
*Storage
,
4998 CHAR16
*ConfigRequest
5001 CHAR16
*RequestElement
;
5002 CHAR16
*NextRequestElement
;
5006 // No request element in it, just return.
5008 if (ConfigRequest
== NULL
) {
5012 if (Storage
->BrowserStorage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
5014 // "&Name1&Name2" section for EFI_HII_VARSTORE_NAME_VALUE storage
5019 // "&OFFSET=####&WIDTH=####" section for EFI_HII_VARSTORE_BUFFER storage
5021 SearchKey
= L
"&OFFSET";
5025 // Find SearchKey storage
5027 if (Storage
->BrowserStorage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
5028 RequestElement
= StrStr (ConfigRequest
, L
"PATH");
5029 ASSERT (RequestElement
!= NULL
);
5030 RequestElement
= StrStr (RequestElement
, SearchKey
);
5032 RequestElement
= StrStr (ConfigRequest
, SearchKey
);
5035 while (RequestElement
!= NULL
) {
5037 // +1 to avoid find header itself.
5039 NextRequestElement
= StrStr (RequestElement
+ 1, SearchKey
);
5042 // The last Request element in configRequest string.
5044 if (NextRequestElement
!= NULL
) {
5046 // Replace "&" with '\0'.
5048 *NextRequestElement
= L
'\0';
5051 RemoveElement (Storage
->BrowserStorage
, RequestElement
);
5053 if (NextRequestElement
!= NULL
) {
5055 // Restore '&' with '\0' for later used.
5057 *NextRequestElement
= L
'&';
5060 RequestElement
= NextRequestElement
;
5064 // If no request element remain, just remove the ConfigRequest string.
5066 if (StrCmp (Storage
->BrowserStorage
->ConfigRequest
, Storage
->ConfigHdr
) == 0) {
5067 FreePool (Storage
->BrowserStorage
->ConfigRequest
);
5068 Storage
->BrowserStorage
->ConfigRequest
= NULL
;
5069 Storage
->BrowserStorage
->SpareStrLen
= 0;
5074 Base on the current formset info, clean the ConfigRequest string in browser storage.
5076 @param FormSet Pointer of the FormSet
5080 CleanBrowserStorage (
5081 IN OUT FORM_BROWSER_FORMSET
*FormSet
5085 FORMSET_STORAGE
*Storage
;
5087 Link
= GetFirstNode (&FormSet
->StorageListHead
);
5088 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
5089 Storage
= FORMSET_STORAGE_FROM_LINK (Link
);
5090 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
5092 if (Storage
->BrowserStorage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
) {
5093 if (Storage
->ConfigRequest
== NULL
|| Storage
->BrowserStorage
->ConfigRequest
== NULL
) {
5097 RemoveConfigRequest (Storage
, Storage
->ConfigRequest
);
5098 } else if (Storage
->BrowserStorage
->Type
== EFI_HII_VARSTORE_BUFFER
||
5099 Storage
->BrowserStorage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
5100 if (Storage
->BrowserStorage
->ConfigRequest
!= NULL
) {
5101 FreePool (Storage
->BrowserStorage
->ConfigRequest
);
5102 Storage
->BrowserStorage
->ConfigRequest
= NULL
;
5104 Storage
->BrowserStorage
->Initialized
= FALSE
;
5110 Check whether current element in the ConfigReqeust string.
5112 @param BrowserStorage Storage which includes ConfigReqeust.
5113 @param RequestElement New element need to check.
5115 @retval TRUE The Element is in the ConfigReqeust string.
5116 @retval FALSE The Element not in the configReqeust String.
5121 BROWSER_STORAGE
*BrowserStorage
,
5122 CHAR16
*RequestElement
5125 return StrStr (BrowserStorage
->ConfigRequest
, RequestElement
) != NULL
? TRUE
: FALSE
;
5129 Append the Request element to the Config Request.
5131 @param ConfigRequest Current ConfigRequest info.
5132 @param SpareStrLen Current remain free buffer for config reqeust.
5133 @param RequestElement New Request element.
5137 AppendConfigRequest (
5138 IN OUT CHAR16
**ConfigRequest
,
5139 IN OUT UINTN
*SpareStrLen
,
5140 IN CHAR16
*RequestElement
5148 StrLength
= StrLen (RequestElement
);
5149 StringSize
= (*ConfigRequest
!= NULL
) ? StrSize (*ConfigRequest
) : sizeof (CHAR16
);
5150 MaxLen
= StringSize
/ sizeof (CHAR16
) + *SpareStrLen
;
5153 // Append <RequestElement> to <ConfigRequest>
5155 if (StrLength
> *SpareStrLen
) {
5157 // Old String buffer is not sufficient for RequestElement, allocate a new one
5159 MaxLen
= StringSize
/ sizeof (CHAR16
) + CONFIG_REQUEST_STRING_INCREMENTAL
;
5160 NewStr
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
5161 ASSERT (NewStr
!= NULL
);
5163 if (*ConfigRequest
!= NULL
) {
5164 CopyMem (NewStr
, *ConfigRequest
, StringSize
);
5165 FreePool (*ConfigRequest
);
5167 *ConfigRequest
= NewStr
;
5168 *SpareStrLen
= CONFIG_REQUEST_STRING_INCREMENTAL
;
5171 StrCatS (*ConfigRequest
, MaxLen
, RequestElement
);
5172 *SpareStrLen
-= StrLength
;
5176 Adjust the config request info, remove the request elements which already in AllConfigRequest string.
5178 @param Storage Form set Storage.
5179 @param Request The input request string.
5180 @param RespString Whether the input is ConfigRequest or ConfigResp format.
5182 @retval TRUE Has element not covered by current used elements, need to continue to call ExtractConfig
5183 @retval FALSE All elements covered by current used elements.
5187 ConfigRequestAdjust (
5188 IN BROWSER_STORAGE
*Storage
,
5190 IN BOOLEAN RespString
5193 CHAR16
*RequestElement
;
5194 CHAR16
*NextRequestElement
;
5195 CHAR16
*NextElementBakup
;
5199 CHAR16
*ConfigRequest
;
5202 NextElementBakup
= NULL
;
5205 if (Request
!= NULL
) {
5206 ConfigRequest
= Request
;
5208 ConfigRequest
= Storage
->ConfigRequest
;
5211 if (Storage
->ConfigRequest
== NULL
) {
5212 Storage
->ConfigRequest
= AllocateCopyPool (StrSize (ConfigRequest
), ConfigRequest
);
5216 if (Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
5218 // "&Name1&Name2" section for EFI_HII_VARSTORE_NAME_VALUE storage
5223 // "&OFFSET=####&WIDTH=####" section for EFI_HII_VARSTORE_BUFFER storage
5225 SearchKey
= L
"&OFFSET";
5226 ValueKey
= L
"&VALUE";
5230 // Find SearchKey storage
5232 if (Storage
->Type
== EFI_HII_VARSTORE_NAME_VALUE
) {
5233 RequestElement
= StrStr (ConfigRequest
, L
"PATH");
5234 ASSERT (RequestElement
!= NULL
);
5235 RequestElement
= StrStr (RequestElement
, SearchKey
);
5237 RequestElement
= StrStr (ConfigRequest
, SearchKey
);
5240 while (RequestElement
!= NULL
) {
5243 // +1 to avoid find header itself.
5245 NextRequestElement
= StrStr (RequestElement
+ 1, SearchKey
);
5248 // The last Request element in configRequest string.
5250 if (NextRequestElement
!= NULL
) {
5251 if (RespString
&& (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
)) {
5252 NextElementBakup
= NextRequestElement
;
5253 NextRequestElement
= StrStr (RequestElement
, ValueKey
);
5254 ASSERT (NextRequestElement
!= NULL
);
5257 // Replace "&" with '\0'.
5259 *NextRequestElement
= L
'\0';
5261 if (RespString
&& (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
)) {
5262 NextElementBakup
= NextRequestElement
;
5263 NextRequestElement
= StrStr (RequestElement
, ValueKey
);
5264 ASSERT (NextRequestElement
!= NULL
);
5266 // Replace "&" with '\0'.
5268 *NextRequestElement
= L
'\0';
5272 if (!ElementValidation (Storage
, RequestElement
)) {
5274 // Add this element to the Storage->BrowserStorage->AllRequestElement.
5276 AppendConfigRequest(&Storage
->ConfigRequest
, &Storage
->SpareStrLen
, RequestElement
);
5280 if (NextRequestElement
!= NULL
) {
5282 // Restore '&' with '\0' for later used.
5284 *NextRequestElement
= L
'&';
5287 if (RespString
&& (Storage
->Type
== EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
)) {
5288 RequestElement
= NextElementBakup
;
5290 RequestElement
= NextRequestElement
;
5298 Fill storage's edit copy with settings requested from Configuration Driver.
5300 @param FormSet FormSet data structure.
5301 @param Storage Buffer Storage.
5306 IN FORM_BROWSER_FORMSET
*FormSet
,
5307 IN FORMSET_STORAGE
*Storage
5311 EFI_STRING Progress
;
5314 EFI_STRING ConfigRequest
;
5317 ConfigRequest
= NULL
;
5319 switch (Storage
->BrowserStorage
->Type
) {
5320 case EFI_HII_VARSTORE_EFI_VARIABLE
:
5323 case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER
:
5324 if (Storage
->BrowserStorage
->ConfigRequest
!= NULL
) {
5325 ConfigRequestAdjust(Storage
->BrowserStorage
, Storage
->ConfigRequest
, FALSE
);
5330 case EFI_HII_VARSTORE_BUFFER
:
5331 case EFI_HII_VARSTORE_NAME_VALUE
:
5333 // Skip if there is no RequestElement.
5335 if (Storage
->ElementCount
== 0) {
5340 // Just update the ConfigRequest, if storage already initialized.
5342 if (Storage
->BrowserStorage
->Initialized
) {
5343 ConfigRequestAdjust(Storage
->BrowserStorage
, Storage
->ConfigRequest
, FALSE
);
5347 Storage
->BrowserStorage
->Initialized
= TRUE
;
5354 if (Storage
->BrowserStorage
->Type
!= EFI_HII_VARSTORE_NAME_VALUE
) {
5356 // Create the config request string to get all fields for this storage.
5357 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
5358 // followed by "&OFFSET=0&WIDTH=WWWW"followed by a Null-terminator
5360 StrLen
= StrSize (Storage
->ConfigHdr
) + 20 * sizeof (CHAR16
);
5361 ConfigRequest
= AllocateZeroPool (StrLen
);
5362 ASSERT (ConfigRequest
!= NULL
);
5366 L
"%s&OFFSET=0&WIDTH=%04x",
5368 Storage
->BrowserStorage
->Size
);
5370 ConfigRequest
= Storage
->ConfigRequest
;
5374 // Request current settings from Configuration Driver
5376 Status
= mHiiConfigRouting
->ExtractConfig (
5384 // If get value fail, extract default from IFR binary
5386 if (EFI_ERROR (Status
)) {
5387 ExtractDefault (FormSet
, NULL
, EFI_HII_DEFAULT_CLASS_STANDARD
, FormSetLevel
, GetDefaultForStorage
, Storage
->BrowserStorage
, TRUE
, TRUE
);
5390 // Convert Result from <ConfigAltResp> to <ConfigResp>
5392 StrPtr
= StrStr (Result
, L
"&GUID=");
5393 if (StrPtr
!= NULL
) {
5397 Status
= ConfigRespToStorage (Storage
->BrowserStorage
, Result
);
5401 Storage
->BrowserStorage
->ConfigRequest
= AllocateCopyPool (StrSize (Storage
->ConfigRequest
), Storage
->ConfigRequest
);
5404 // Input NULL for ConfigRequest field means sync all fields from editbuffer to buffer.
5406 SynchronizeStorage(Storage
->BrowserStorage
, NULL
, TRUE
);
5408 if (Storage
->BrowserStorage
->Type
!= EFI_HII_VARSTORE_NAME_VALUE
) {
5409 if (ConfigRequest
!= NULL
) {
5410 FreePool (ConfigRequest
);
5416 Get Value changed status from old question.
5418 @param NewFormSet FormSet data structure.
5419 @param OldQuestion Old question which has value changed.
5423 SyncStatusForQuestion (
5424 IN OUT FORM_BROWSER_FORMSET
*NewFormSet
,
5425 IN FORM_BROWSER_STATEMENT
*OldQuestion
5429 LIST_ENTRY
*QuestionLink
;
5430 FORM_BROWSER_FORM
*Form
;
5431 FORM_BROWSER_STATEMENT
*Question
;
5434 // For each form in one formset.
5436 Link
= GetFirstNode (&NewFormSet
->FormListHead
);
5437 while (!IsNull (&NewFormSet
->FormListHead
, Link
)) {
5438 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
5439 Link
= GetNextNode (&NewFormSet
->FormListHead
, Link
);
5442 // for each question in one form.
5444 QuestionLink
= GetFirstNode (&Form
->StatementListHead
);
5445 while (!IsNull (&Form
->StatementListHead
, QuestionLink
)) {
5446 Question
= FORM_BROWSER_STATEMENT_FROM_LINK (QuestionLink
);
5447 QuestionLink
= GetNextNode (&Form
->StatementListHead
, QuestionLink
);
5449 if (Question
->QuestionId
== OldQuestion
->QuestionId
) {
5450 Question
->ValueChanged
= TRUE
;
5458 Get Value changed status from old formset.
5460 @param NewFormSet FormSet data structure.
5461 @param OldFormSet FormSet data structure.
5465 SyncStatusForFormSet (
5466 IN OUT FORM_BROWSER_FORMSET
*NewFormSet
,
5467 IN FORM_BROWSER_FORMSET
*OldFormSet
5471 LIST_ENTRY
*QuestionLink
;
5472 FORM_BROWSER_FORM
*Form
;
5473 FORM_BROWSER_STATEMENT
*Question
;
5476 // For each form in one formset.
5478 Link
= GetFirstNode (&OldFormSet
->FormListHead
);
5479 while (!IsNull (&OldFormSet
->FormListHead
, Link
)) {
5480 Form
= FORM_BROWSER_FORM_FROM_LINK (Link
);
5481 Link
= GetNextNode (&OldFormSet
->FormListHead
, Link
);
5484 // for each question in one form.
5486 QuestionLink
= GetFirstNode (&Form
->StatementListHead
);
5487 while (!IsNull (&Form
->StatementListHead
, QuestionLink
)) {
5488 Question
= FORM_BROWSER_STATEMENT_FROM_LINK (QuestionLink
);
5489 QuestionLink
= GetNextNode (&Form
->StatementListHead
, QuestionLink
);
5491 if (!Question
->ValueChanged
) {
5496 // Find the same question in new formset and update the value changed flag.
5498 SyncStatusForQuestion (NewFormSet
, Question
);
5504 Get current setting of Questions.
5506 @param FormSet FormSet data structure.
5510 InitializeCurrentSetting (
5511 IN OUT FORM_BROWSER_FORMSET
*FormSet
5515 FORMSET_STORAGE
*Storage
;
5516 FORM_BROWSER_FORMSET
*OldFormSet
;
5519 // Try to find pre FormSet in the maintain backup list.
5520 // If old formset != NULL, destroy this formset. Add new formset to gBrowserFormSetList.
5522 OldFormSet
= GetFormSetFromHiiHandle (FormSet
->HiiHandle
);
5523 if (OldFormSet
!= NULL
) {
5524 SyncStatusForFormSet (FormSet
, OldFormSet
);
5525 RemoveEntryList (&OldFormSet
->Link
);
5526 DestroyFormSet (OldFormSet
);
5528 InsertTailList (&gBrowserFormSetList
, &FormSet
->Link
);
5531 // Extract default from IFR binary for no storage questions.
5533 ExtractDefault (FormSet
, NULL
, EFI_HII_DEFAULT_CLASS_STANDARD
, FormSetLevel
, GetDefaultForNoStorage
, NULL
, TRUE
, FALSE
);
5536 // Request current settings from Configuration Driver
5538 Link
= GetFirstNode (&FormSet
->StorageListHead
);
5539 while (!IsNull (&FormSet
->StorageListHead
, Link
)) {
5540 Storage
= FORMSET_STORAGE_FROM_LINK (Link
);
5542 LoadStorage (FormSet
, Storage
);
5544 Link
= GetNextNode (&FormSet
->StorageListHead
, Link
);
5550 Fetch the Ifr binary data of a FormSet.
5552 @param Handle PackageList Handle
5553 @param FormSetGuid On input, GUID or class GUID of a formset. If not
5554 specified (NULL or zero GUID), take the first
5555 FormSet with class GUID EFI_HII_PLATFORM_SETUP_FORMSET_GUID
5556 found in package list.
5557 On output, GUID of the formset found(if not NULL).
5558 @param BinaryLength The length of the FormSet IFR binary.
5559 @param BinaryData The buffer designed to receive the FormSet.
5561 @retval EFI_SUCCESS Buffer filled with the requested FormSet.
5562 BufferLength was updated.
5563 @retval EFI_INVALID_PARAMETER The handle is unknown.
5564 @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
5565 be found with the requested FormId.
5570 IN EFI_HII_HANDLE Handle
,
5571 IN OUT EFI_GUID
*FormSetGuid
,
5572 OUT UINTN
*BinaryLength
,
5573 OUT UINT8
**BinaryData
5577 EFI_HII_PACKAGE_LIST_HEADER
*HiiPackageList
;
5583 UINT32 PackageListLength
;
5584 EFI_HII_PACKAGE_HEADER PackageHeader
;
5586 UINT8 NumberOfClassGuid
;
5587 BOOLEAN ClassGuidMatch
;
5588 EFI_GUID
*ClassGuid
;
5589 EFI_GUID
*ComparingGuid
;
5593 ZeroMem (&PackageHeader
, sizeof (EFI_HII_PACKAGE_HEADER
));
5596 // if FormSetGuid is NULL or zero GUID, return first Setup FormSet in the package list
5598 if (FormSetGuid
== NULL
) {
5599 ComparingGuid
= &gZeroGuid
;
5601 ComparingGuid
= FormSetGuid
;
5605 // Get HII PackageList
5608 HiiPackageList
= NULL
;
5609 Status
= mHiiDatabase
->ExportPackageLists (mHiiDatabase
, Handle
, &BufferSize
, HiiPackageList
);
5610 if (Status
== EFI_BUFFER_TOO_SMALL
) {
5611 HiiPackageList
= AllocatePool (BufferSize
);
5612 ASSERT (HiiPackageList
!= NULL
);
5614 Status
= mHiiDatabase
->ExportPackageLists (mHiiDatabase
, Handle
, &BufferSize
, HiiPackageList
);
5616 if (EFI_ERROR (Status
)) {
5619 ASSERT (HiiPackageList
!= NULL
);
5622 // Get Form package from this HII package List
5624 Offset
= sizeof (EFI_HII_PACKAGE_LIST_HEADER
);
5626 CopyMem (&PackageListLength
, &HiiPackageList
->PackageLength
, sizeof (UINT32
));
5628 ClassGuidMatch
= FALSE
;
5629 while (Offset
< PackageListLength
) {
5630 Package
= ((UINT8
*) HiiPackageList
) + Offset
;
5631 CopyMem (&PackageHeader
, Package
, sizeof (EFI_HII_PACKAGE_HEADER
));
5633 if (PackageHeader
.Type
== EFI_HII_PACKAGE_FORMS
) {
5635 // Search FormSet in this Form Package
5637 Offset2
= sizeof (EFI_HII_PACKAGE_HEADER
);
5638 while (Offset2
< PackageHeader
.Length
) {
5639 OpCodeData
= Package
+ Offset2
;
5641 if (((EFI_IFR_OP_HEADER
*) OpCodeData
)->OpCode
== EFI_IFR_FORM_SET_OP
) {
5643 // Try to compare against formset GUID
5645 if (CompareGuid (FormSetGuid
, &gZeroGuid
) ||
5646 CompareGuid (ComparingGuid
, (EFI_GUID
*)(OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
)))) {
5650 if (((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
> OFFSET_OF (EFI_IFR_FORM_SET
, Flags
)) {
5652 // Try to compare against formset class GUID
5654 NumberOfClassGuid
= (UINT8
) (((EFI_IFR_FORM_SET
*) OpCodeData
)->Flags
& 0x3);
5655 ClassGuid
= (EFI_GUID
*) (OpCodeData
+ sizeof (EFI_IFR_FORM_SET
));
5656 for (Index
= 0; Index
< NumberOfClassGuid
; Index
++) {
5657 if (CompareGuid (ComparingGuid
, ClassGuid
+ Index
)) {
5658 ClassGuidMatch
= TRUE
;
5662 if (ClassGuidMatch
) {
5665 } else if (ComparingGuid
== &gEfiHiiPlatformSetupFormsetGuid
) {
5666 ClassGuidMatch
= TRUE
;
5671 Offset2
+= ((EFI_IFR_OP_HEADER
*) OpCodeData
)->Length
;
5674 if (Offset2
< PackageHeader
.Length
) {
5676 // Target formset found
5682 Offset
+= PackageHeader
.Length
;
5685 if (Offset
>= PackageListLength
) {
5687 // Form package not found in this Package List
5689 FreePool (HiiPackageList
);
5690 return EFI_NOT_FOUND
;
5693 if (FormSetGuid
!= NULL
) {
5695 // Return the FormSet GUID
5697 CopyMem (FormSetGuid
, &((EFI_IFR_FORM_SET
*) OpCodeData
)->Guid
, sizeof (EFI_GUID
));
5701 // To determine the length of a whole FormSet IFR binary, one have to parse all the Opcodes
5702 // in this FormSet; So, here just simply copy the data from start of a FormSet to the end
5703 // of the Form Package.
5705 *BinaryLength
= PackageHeader
.Length
- Offset2
;
5706 *BinaryData
= AllocateCopyPool (*BinaryLength
, OpCodeData
);
5708 FreePool (HiiPackageList
);
5710 if (*BinaryData
== NULL
) {
5711 return EFI_OUT_OF_RESOURCES
;
5719 Initialize the internal data structure of a FormSet.
5721 @param Handle PackageList Handle
5722 @param FormSetGuid On input, GUID or class GUID of a formset. If not
5723 specified (NULL or zero GUID), take the first
5724 FormSet with class GUID EFI_HII_PLATFORM_SETUP_FORMSET_GUID
5725 found in package list.
5726 On output, GUID of the formset found(if not NULL).
5727 @param FormSet FormSet data structure.
5729 @retval EFI_SUCCESS The function completed successfully.
5730 @retval EFI_NOT_FOUND The specified FormSet could not be found.
5735 IN EFI_HII_HANDLE Handle
,
5736 IN OUT EFI_GUID
*FormSetGuid
,
5737 OUT FORM_BROWSER_FORMSET
*FormSet
5741 EFI_HANDLE DriverHandle
;
5743 Status
= GetIfrBinaryData (Handle
, FormSetGuid
, &FormSet
->IfrBinaryLength
, &FormSet
->IfrBinaryData
);
5744 if (EFI_ERROR (Status
)) {
5748 FormSet
->Signature
= FORM_BROWSER_FORMSET_SIGNATURE
;
5749 FormSet
->HiiHandle
= Handle
;
5750 CopyMem (&FormSet
->Guid
, FormSetGuid
, sizeof (EFI_GUID
));
5751 FormSet
->QuestionInited
= FALSE
;
5754 // Retrieve ConfigAccess Protocol associated with this HiiPackageList
5756 Status
= mHiiDatabase
->GetPackageListHandle (mHiiDatabase
, Handle
, &DriverHandle
);
5757 if (EFI_ERROR (Status
)) {
5760 FormSet
->DriverHandle
= DriverHandle
;
5761 Status
= gBS
->HandleProtocol (
5763 &gEfiHiiConfigAccessProtocolGuid
,
5764 (VOID
**) &FormSet
->ConfigAccess
5766 if (EFI_ERROR (Status
)) {
5768 // Configuration Driver don't attach ConfigAccess protocol to its HII package
5769 // list, then there will be no configuration action required
5771 FormSet
->ConfigAccess
= NULL
;
5775 // Parse the IFR binary OpCodes
5777 Status
= ParseOpCodes (FormSet
);
5784 Save globals used by previous call to SendForm(). SendForm() may be called from
5785 HiiConfigAccess.Callback(), this will cause SendForm() be reentried.
5786 So, save globals of previous call to SendForm() and restore them upon exit.
5790 SaveBrowserContext (
5794 BROWSER_CONTEXT
*Context
;
5795 FORM_ENTRY_INFO
*MenuList
;
5796 FORM_BROWSER_FORMSET
*FormSet
;
5798 gBrowserContextCount
++;
5799 if (gBrowserContextCount
== 1) {
5801 // This is not reentry of SendForm(), no context to save
5806 Context
= AllocatePool (sizeof (BROWSER_CONTEXT
));
5807 ASSERT (Context
!= NULL
);
5809 Context
->Signature
= BROWSER_CONTEXT_SIGNATURE
;
5812 // Save FormBrowser context
5814 Context
->Selection
= gCurrentSelection
;
5815 Context
->ResetRequired
= gResetRequired
;
5816 Context
->FlagReconnect
= gFlagReconnect
;
5817 Context
->CallbackReconnect
= gCallbackReconnect
;
5818 Context
->ExitRequired
= gExitRequired
;
5819 Context
->HiiHandle
= mCurrentHiiHandle
;
5820 Context
->FormId
= mCurrentFormId
;
5821 CopyGuid (&Context
->FormSetGuid
, &mCurrentFormSetGuid
);
5822 Context
->SystemLevelFormSet
= mSystemLevelFormSet
;
5823 Context
->CurFakeQestId
= mCurFakeQestId
;
5824 Context
->HiiPackageListUpdated
= mHiiPackageListUpdated
;
5825 Context
->FinishRetrieveCall
= mFinishRetrieveCall
;
5828 // Save the menu history data.
5830 InitializeListHead(&Context
->FormHistoryList
);
5831 while (!IsListEmpty (&mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
)) {
5832 MenuList
= FORM_ENTRY_INFO_FROM_LINK (mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
.ForwardLink
);
5833 RemoveEntryList (&MenuList
->Link
);
5835 InsertTailList(&Context
->FormHistoryList
, &MenuList
->Link
);
5839 // Save formset list.
5841 InitializeListHead(&Context
->FormSetList
);
5842 while (!IsListEmpty (&gBrowserFormSetList
)) {
5843 FormSet
= FORM_BROWSER_FORMSET_FROM_LINK (gBrowserFormSetList
.ForwardLink
);
5844 RemoveEntryList (&FormSet
->Link
);
5846 InsertTailList(&Context
->FormSetList
, &FormSet
->Link
);
5850 // Insert to FormBrowser context list
5852 InsertHeadList (&gBrowserContextList
, &Context
->Link
);
5857 Restore globals used by previous call to SendForm().
5861 RestoreBrowserContext (
5866 BROWSER_CONTEXT
*Context
;
5867 FORM_ENTRY_INFO
*MenuList
;
5868 FORM_BROWSER_FORMSET
*FormSet
;
5870 ASSERT (gBrowserContextCount
!= 0);
5871 gBrowserContextCount
--;
5872 if (gBrowserContextCount
== 0) {
5874 // This is not reentry of SendForm(), no context to restore
5879 ASSERT (!IsListEmpty (&gBrowserContextList
));
5881 Link
= GetFirstNode (&gBrowserContextList
);
5882 Context
= BROWSER_CONTEXT_FROM_LINK (Link
);
5885 // Restore FormBrowser context
5887 gCurrentSelection
= Context
->Selection
;
5888 gResetRequired
= Context
->ResetRequired
;
5889 gFlagReconnect
= Context
->FlagReconnect
;
5890 gCallbackReconnect
= Context
->CallbackReconnect
;
5891 gExitRequired
= Context
->ExitRequired
;
5892 mCurrentHiiHandle
= Context
->HiiHandle
;
5893 mCurrentFormId
= Context
->FormId
;
5894 CopyGuid (&mCurrentFormSetGuid
, &Context
->FormSetGuid
);
5895 mSystemLevelFormSet
= Context
->SystemLevelFormSet
;
5896 mCurFakeQestId
= Context
->CurFakeQestId
;
5897 mHiiPackageListUpdated
= Context
->HiiPackageListUpdated
;
5898 mFinishRetrieveCall
= Context
->FinishRetrieveCall
;
5901 // Restore the menu history data.
5903 while (!IsListEmpty (&Context
->FormHistoryList
)) {
5904 MenuList
= FORM_ENTRY_INFO_FROM_LINK (Context
->FormHistoryList
.ForwardLink
);
5905 RemoveEntryList (&MenuList
->Link
);
5907 InsertTailList(&mPrivateData
.FormBrowserEx2
.FormViewHistoryHead
, &MenuList
->Link
);
5911 // Restore the Formset data.
5913 while (!IsListEmpty (&Context
->FormSetList
)) {
5914 FormSet
= FORM_BROWSER_FORMSET_FROM_LINK (Context
->FormSetList
.ForwardLink
);
5915 RemoveEntryList (&FormSet
->Link
);
5917 InsertTailList(&gBrowserFormSetList
, &FormSet
->Link
);
5921 // Remove from FormBrowser context list
5923 RemoveEntryList (&Context
->Link
);
5924 gBS
->FreePool (Context
);
5928 Find the matched FormSet context in the backup maintain list based on HiiHandle.
5930 @param Handle The Hii Handle.
5932 @return the found FormSet context. If no found, NULL will return.
5935 FORM_BROWSER_FORMSET
*
5936 GetFormSetFromHiiHandle (
5937 EFI_HII_HANDLE Handle
5941 FORM_BROWSER_FORMSET
*FormSet
;
5943 Link
= GetFirstNode (&gBrowserFormSetList
);
5944 while (!IsNull (&gBrowserFormSetList
, Link
)) {
5945 FormSet
= FORM_BROWSER_FORMSET_FROM_LINK (Link
);
5946 Link
= GetNextNode (&gBrowserFormSetList
, Link
);
5947 if (!ValidateFormSet(FormSet
)) {
5950 if (FormSet
->HiiHandle
== Handle
) {
5959 Check whether the input HII handle is the FormSet that is being used.
5961 @param Handle The Hii Handle.
5963 @retval TRUE HII handle is being used.
5964 @retval FALSE HII handle is not being used.
5968 IsHiiHandleInBrowserContext (
5969 EFI_HII_HANDLE Handle
5973 BROWSER_CONTEXT
*Context
;
5976 // HiiHandle is Current FormSet.
5978 if (mCurrentHiiHandle
== Handle
) {
5983 // Check whether HiiHandle is in BrowserContext.
5985 Link
= GetFirstNode (&gBrowserContextList
);
5986 while (!IsNull (&gBrowserContextList
, Link
)) {
5987 Context
= BROWSER_CONTEXT_FROM_LINK (Link
);
5988 if (Context
->HiiHandle
== Handle
) {
5990 // HiiHandle is in BrowserContext
5994 Link
= GetNextNode (&gBrowserContextList
, Link
);
6001 Perform Password check.
6002 Passwork may be encrypted by driver that requires the specific check.
6004 @param Form Form where Password Statement is in.
6005 @param Statement Password statement
6006 @param PasswordString Password string to be checked. It may be NULL.
6007 NULL means to restore password.
6008 "" string can be used to checked whether old password does exist.
6010 @return Status Status of Password check.
6015 IN FORM_DISPLAY_ENGINE_FORM
*Form
,
6016 IN FORM_DISPLAY_ENGINE_STATEMENT
*Statement
,
6017 IN EFI_STRING PasswordString OPTIONAL
6021 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
6022 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
6023 EFI_IFR_TYPE_VALUE IfrTypeValue
;
6024 FORM_BROWSER_STATEMENT
*Question
;
6026 ConfigAccess
= gCurrentSelection
->FormSet
->ConfigAccess
;
6027 Question
= GetBrowserStatement(Statement
);
6028 ASSERT (Question
!= NULL
);
6030 if ((Question
->QuestionFlags
& EFI_IFR_FLAG_CALLBACK
) == EFI_IFR_FLAG_CALLBACK
) {
6031 if (ConfigAccess
== NULL
) {
6032 return EFI_UNSUPPORTED
;
6035 if (PasswordString
== NULL
) {
6040 // Check whether has preexisted password.
6042 if (PasswordString
[0] == 0) {
6043 if (*((CHAR16
*) Question
->BufferValue
) == 0) {
6046 return EFI_NOT_READY
;
6051 // Check whether the input password is same as preexisted password.
6053 if (StrnCmp (PasswordString
, (CHAR16
*) Question
->BufferValue
, Question
->StorageWidth
/sizeof (CHAR16
)) == 0) {
6056 return EFI_NOT_READY
;
6061 // Prepare password string in HII database
6063 if (PasswordString
!= NULL
) {
6064 IfrTypeValue
.string
= NewString (PasswordString
, gCurrentSelection
->FormSet
->HiiHandle
);
6066 IfrTypeValue
.string
= 0;
6070 // Send password to Configuration Driver for validation
6072 Status
= ConfigAccess
->Callback (
6074 EFI_BROWSER_ACTION_CHANGING
,
6075 Question
->QuestionId
,
6076 Question
->HiiValue
.Type
,
6082 // Remove password string from HII database
6084 if (PasswordString
!= NULL
) {
6085 DeleteString (IfrTypeValue
.string
, gCurrentSelection
->FormSet
->HiiHandle
);
6092 Find the registered HotKey based on KeyData.
6094 @param[in] KeyData A pointer to a buffer that describes the keystroke
6095 information for the hot key.
6097 @return The registered HotKey context. If no found, NULL will return.
6100 GetHotKeyFromRegisterList (
6101 IN EFI_INPUT_KEY
*KeyData
6105 BROWSER_HOT_KEY
*HotKey
;
6107 Link
= GetFirstNode (&gBrowserHotKeyList
);
6108 while (!IsNull (&gBrowserHotKeyList
, Link
)) {
6109 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
6110 if (HotKey
->KeyData
->ScanCode
== KeyData
->ScanCode
) {
6113 Link
= GetNextNode (&gBrowserHotKeyList
, Link
);
6120 Configure what scope the hot key will impact.
6121 All hot keys have the same scope. The mixed hot keys with the different level are not supported.
6122 If no scope is set, the default scope will be FormSet level.
6123 After all registered hot keys are removed, previous Scope can reset to another level.
6125 @param[in] Scope Scope level to be set.
6127 @retval EFI_SUCCESS Scope is set correctly.
6128 @retval EFI_INVALID_PARAMETER Scope is not the valid value specified in BROWSER_SETTING_SCOPE.
6129 @retval EFI_UNSPPORTED Scope level is different from current one that the registered hot keys have.
6135 IN BROWSER_SETTING_SCOPE Scope
6138 if (Scope
>= MaxLevel
) {
6139 return EFI_INVALID_PARAMETER
;
6143 // When no hot key registered in system or on the first setting,
6144 // Scope can be set.
6146 if (mBrowserScopeFirstSet
|| IsListEmpty (&gBrowserHotKeyList
)) {
6147 gBrowserSettingScope
= Scope
;
6148 mBrowserScopeFirstSet
= FALSE
;
6149 } else if (Scope
!= gBrowserSettingScope
) {
6150 return EFI_UNSUPPORTED
;
6157 Register the hot key with its browser action, or unregistered the hot key.
6158 Only support hot key that is not printable character (control key, function key, etc.).
6159 If the action value is zero, the hot key will be unregistered if it has been registered.
6160 If the same hot key has been registered, the new action and help string will override the previous ones.
6162 @param[in] KeyData A pointer to a buffer that describes the keystroke
6163 information for the hot key. Its type is EFI_INPUT_KEY to
6164 be supported by all ConsoleIn devices.
6165 @param[in] Action Action value that describes what action will be trigged when the hot key is pressed.
6166 @param[in] DefaultId Specifies the type of defaults to retrieve, which is only for DEFAULT action.
6167 @param[in] HelpString Help string that describes the hot key information.
6168 Its value may be NULL for the unregistered hot key.
6170 @retval EFI_SUCCESS Hot key is registered or unregistered.
6171 @retval EFI_INVALID_PARAMETER KeyData is NULL or HelpString is NULL on register.
6172 @retval EFI_NOT_FOUND KeyData is not found to be unregistered.
6173 @retval EFI_UNSUPPORTED Key represents a printable character. It is conflicted with Browser.
6174 @retval EFI_ALREADY_STARTED Key already been registered for one hot key.
6179 IN EFI_INPUT_KEY
*KeyData
,
6181 IN UINT16 DefaultId
,
6182 IN EFI_STRING HelpString OPTIONAL
6185 BROWSER_HOT_KEY
*HotKey
;
6188 // Check input parameters.
6190 if (KeyData
== NULL
|| KeyData
->UnicodeChar
!= CHAR_NULL
||
6191 (Action
!= BROWSER_ACTION_UNREGISTER
&& HelpString
== NULL
)) {
6192 return EFI_INVALID_PARAMETER
;
6196 // Check whether the input KeyData is in BrowserHotKeyList.
6198 HotKey
= GetHotKeyFromRegisterList (KeyData
);
6201 // Unregister HotKey
6203 if (Action
== BROWSER_ACTION_UNREGISTER
) {
6204 if (HotKey
!= NULL
) {
6206 // The registered HotKey is found.
6207 // Remove it from List, and free its resource.
6209 RemoveEntryList (&HotKey
->Link
);
6210 FreePool (HotKey
->KeyData
);
6211 FreePool (HotKey
->HelpString
);
6215 // The registered HotKey is not found.
6217 return EFI_NOT_FOUND
;
6221 if (HotKey
!= NULL
) {
6222 return EFI_ALREADY_STARTED
;
6226 // Create new Key, and add it into List.
6228 HotKey
= AllocateZeroPool (sizeof (BROWSER_HOT_KEY
));
6229 ASSERT (HotKey
!= NULL
);
6230 HotKey
->Signature
= BROWSER_HOT_KEY_SIGNATURE
;
6231 HotKey
->KeyData
= AllocateCopyPool (sizeof (EFI_INPUT_KEY
), KeyData
);
6232 InsertTailList (&gBrowserHotKeyList
, &HotKey
->Link
);
6235 // Fill HotKey information.
6237 HotKey
->Action
= Action
;
6238 HotKey
->DefaultId
= DefaultId
;
6239 if (HotKey
->HelpString
!= NULL
) {
6240 FreePool (HotKey
->HelpString
);
6242 HotKey
->HelpString
= AllocateCopyPool (StrSize (HelpString
), HelpString
);
6248 Register Exit handler function.
6249 When more than one handler function is registered, the latter one will override the previous one.
6250 When NULL handler is specified, the previous Exit handler will be unregistered.
6252 @param[in] Handler Pointer to handler function.
6257 RegiserExitHandler (
6258 IN EXIT_HANDLER Handler
6261 ExitHandlerFunction
= Handler
;
6266 Check whether the browser data has been modified.
6268 @retval TRUE Browser data is modified.
6269 @retval FALSE No browser data is modified.
6274 IsBrowserDataModified (
6279 FORM_BROWSER_FORMSET
*FormSet
;
6281 switch (gBrowserSettingScope
) {
6283 if (gCurrentSelection
== NULL
) {
6286 return IsNvUpdateRequiredForForm (gCurrentSelection
->Form
);
6289 if (gCurrentSelection
== NULL
) {
6292 return IsNvUpdateRequiredForFormSet (gCurrentSelection
->FormSet
);
6295 Link
= GetFirstNode (&gBrowserFormSetList
);
6296 while (!IsNull (&gBrowserFormSetList
, Link
)) {
6297 FormSet
= FORM_BROWSER_FORMSET_FROM_LINK (Link
);
6298 if (!ValidateFormSet(FormSet
)) {
6302 if (IsNvUpdateRequiredForFormSet (FormSet
)) {
6305 Link
= GetNextNode (&gBrowserFormSetList
, Link
);
6315 Execute the action requested by the Action parameter.
6317 @param[in] Action Execute the request action.
6318 @param[in] DefaultId The default Id info when need to load default value. Only used when Action is BROWSER_ACTION_DEFAULT.
6320 @retval EFI_SUCCESS Execute the request action succss.
6321 @retval EFI_INVALID_PARAMETER The input action value is invalid.
6332 FORM_BROWSER_FORMSET
*FormSet
;
6333 FORM_BROWSER_FORM
*Form
;
6335 if (gBrowserSettingScope
< SystemLevel
&& gCurrentSelection
== NULL
) {
6336 return EFI_NOT_READY
;
6339 Status
= EFI_SUCCESS
;
6342 if (gBrowserSettingScope
< SystemLevel
) {
6343 FormSet
= gCurrentSelection
->FormSet
;
6344 Form
= gCurrentSelection
->Form
;
6348 // Executet the discard action.
6350 if ((Action
& BROWSER_ACTION_DISCARD
) != 0) {
6351 Status
= DiscardForm (FormSet
, Form
, gBrowserSettingScope
);
6352 if (EFI_ERROR (Status
)) {
6358 // Executet the difault action.
6360 if ((Action
& BROWSER_ACTION_DEFAULT
) != 0) {
6361 Status
= ExtractDefault (FormSet
, Form
, DefaultId
, gBrowserSettingScope
, GetDefaultForAll
, NULL
, FALSE
, FALSE
);
6362 if (EFI_ERROR (Status
)) {
6365 UpdateStatementStatus (FormSet
, Form
, gBrowserSettingScope
);
6369 // Executet the submit action.
6371 if ((Action
& BROWSER_ACTION_SUBMIT
) != 0) {
6372 Status
= SubmitForm (FormSet
, Form
, gBrowserSettingScope
);
6373 if (EFI_ERROR (Status
)) {
6379 // Executet the reset action.
6381 if ((Action
& BROWSER_ACTION_RESET
) != 0) {
6382 gResetRequired
= TRUE
;
6386 // Executet the exit action.
6388 if ((Action
& BROWSER_ACTION_EXIT
) != 0) {
6389 DiscardForm (FormSet
, Form
, gBrowserSettingScope
);
6390 if (gBrowserSettingScope
== SystemLevel
) {
6391 if (ExitHandlerFunction
!= NULL
) {
6392 ExitHandlerFunction ();
6396 gExitRequired
= TRUE
;
6403 Create reminder to let user to choose save or discard the changed browser data.
6404 Caller can use it to actively check the changed browser data.
6406 @retval BROWSER_NO_CHANGES No browser data is changed.
6407 @retval BROWSER_SAVE_CHANGES The changed browser data is saved.
6408 @retval BROWSER_DISCARD_CHANGES The changed browser data is discard.
6409 @retval BROWSER_KEEP_CURRENT Browser keep current changes.
6419 FORM_BROWSER_FORMSET
*FormSet
;
6420 BOOLEAN IsDataChanged
;
6421 UINT32 DataSavedAction
;
6424 DataSavedAction
= BROWSER_NO_CHANGES
;
6425 IsDataChanged
= FALSE
;
6426 Link
= GetFirstNode (&gBrowserFormSetList
);
6427 while (!IsNull (&gBrowserFormSetList
, Link
)) {
6428 FormSet
= FORM_BROWSER_FORMSET_FROM_LINK (Link
);
6429 Link
= GetNextNode (&gBrowserFormSetList
, Link
);
6430 if (!ValidateFormSet(FormSet
)) {
6433 if (IsNvUpdateRequiredForFormSet (FormSet
)) {
6434 IsDataChanged
= TRUE
;
6440 // No data is changed. No save is required.
6442 if (!IsDataChanged
) {
6443 return DataSavedAction
;
6447 // If data is changed, prompt user to save or discard it.
6450 ConfirmRet
= (UINT32
) mFormDisplay
->ConfirmDataChange();
6452 if (ConfirmRet
== BROWSER_ACTION_SUBMIT
) {
6453 SubmitForm (NULL
, NULL
, SystemLevel
);
6454 DataSavedAction
= BROWSER_SAVE_CHANGES
;
6456 } else if (ConfirmRet
== BROWSER_ACTION_DISCARD
) {
6457 DiscardForm (NULL
, NULL
, SystemLevel
);
6458 DataSavedAction
= BROWSER_DISCARD_CHANGES
;
6460 } else if (ConfirmRet
== BROWSER_ACTION_NONE
) {
6461 DataSavedAction
= BROWSER_KEEP_CURRENT
;
6466 return DataSavedAction
;
6470 Check whether the Reset Required for the browser
6472 @retval TRUE Browser required to reset after exit.
6473 @retval FALSE Browser not need to reset after exit.
6482 return gResetRequired
;