X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FSetupBrowserDxe%2FPresentation.c;h=0c5d1b40184980feaf9f3a68b720afbcdb675158;hb=0a18956d54cfe70b736b029c62ce53f29b903745;hp=b3a3d237614c661d2439fd5b8e566ecbd6f2bb79;hpb=70f1d5e75655dc71142d363df809c25d07c3e99d;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index b3a3d23761..0c5d1b4018 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -1,7 +1,8 @@ /** @file Utility functions for UI presentation. -Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -21,10 +22,9 @@ EFI_GUID mCurrentFormSetGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; UINT16 mCurrentFormId = 0; EFI_EVENT mValueChangedEvent = NULL; LIST_ENTRY mRefreshEventList = INITIALIZE_LIST_HEAD_VARIABLE (mRefreshEventList); -UINT32 gBrowserStatus = BROWSER_SUCCESS; -CHAR16 *gErrorInfo; UINT16 mCurFakeQestId; FORM_DISPLAY_ENGINE_FORM gDisplayFormData; +BOOLEAN mFinishRetrieveCall = FALSE; /** Evaluate all expressions in a Form. @@ -179,7 +179,7 @@ UpdateStatement ( **/ VOID EFIAPI -RefreshEventNotify( +RefreshEventNotifyForStatement( IN EFI_EVENT Event, IN VOID *Context ) @@ -191,6 +191,23 @@ RefreshEventNotify( gBS->SignalEvent (mValueChangedEvent); } +/** + Refresh the questions within this form. + + @param Event The event which has this function related. + @param Context The input context info related to this event or the status code return to the caller. +**/ +VOID +EFIAPI +RefreshEventNotifyForForm( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + gCurrentSelection->Action = UI_ACTION_REFRESH_FORMSET; + + gBS->SignalEvent (mValueChangedEvent); +} /** Create refresh hook event for statement which has refresh event or interval. @@ -199,7 +216,7 @@ RefreshEventNotify( **/ VOID -CreateRefreshEvent ( +CreateRefreshEventForStatement ( IN FORM_BROWSER_STATEMENT *Statement ) { @@ -213,7 +230,7 @@ CreateRefreshEvent ( Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - RefreshEventNotify, + RefreshEventNotifyForStatement, Statement, &Statement->RefreshGuid, &RefreshEvent); @@ -226,159 +243,36 @@ CreateRefreshEvent ( } /** - Perform value check for a question. - - @param Question The question need to do check. - @param Type Condition type need to check. - @param ErrorInfo Return info about the error. - - @retval The check result. -**/ -UINT32 -ConditionCheck ( - IN FORM_BROWSER_STATEMENT *Question, - IN UINT8 Type, - OUT STATEMENT_ERROR_INFO *ErrorInfo - ) -{ - EFI_STATUS Status; - LIST_ENTRY *Link; - FORM_EXPRESSION *Expression; - LIST_ENTRY *ListHead; - UINT32 RetVal; - - RetVal = STATEMENT_VALID; - ListHead = NULL; - - switch (Type) { - case EFI_HII_EXPRESSION_INCONSISTENT_IF: - ListHead = &Question->InconsistentListHead; - break; - - case EFI_HII_EXPRESSION_WARNING_IF: - ListHead = &Question->WarningListHead; - break; - - default: - ASSERT (FALSE); - return RetVal; - } - - ASSERT (ListHead != NULL); - Link = GetFirstNode (ListHead); - while (!IsNull (ListHead, Link)) { - Expression = FORM_EXPRESSION_FROM_LINK (Link); - Link = GetNextNode (ListHead, Link); - - // - // Evaluate the expression - // - Status = EvaluateExpression (gCurrentSelection->FormSet, gCurrentSelection->Form, Expression); - if (EFI_ERROR (Status)) { - continue; - } - - if ((Expression->Result.Type == EFI_IFR_TYPE_BOOLEAN) && Expression->Result.Value.b) { - ErrorInfo->StringId = Expression->Error; - switch (Type) { - case EFI_HII_EXPRESSION_INCONSISTENT_IF: - ErrorInfo->TimeOut = 0; - RetVal = INCOSISTENT_IF_TRUE; - break; - - case EFI_HII_EXPRESSION_WARNING_IF: - ErrorInfo->TimeOut = Expression->TimeOut; - RetVal = WARNING_IF_TRUE; - break; + Create refresh hook event for form which has refresh event or interval. - default: - ASSERT (FALSE); - break; - } - break; - } - } + @param Form The form need to check. - return RetVal; -} - -/** - Perform value check for a question. - - @param Form Form where Statement is in. - @param Statement Value will check for it. - @param InputValue New value will be checked. - @param ErrorInfo Return the error info for this check. - - @retval TRUE Input Value is valid. - @retval FALSE Input Value is invalid. **/ -UINT32 -EFIAPI -QuestionCheck ( - IN FORM_DISPLAY_ENGINE_FORM *Form, - IN FORM_DISPLAY_ENGINE_STATEMENT *Statement, - IN EFI_HII_VALUE *InputValue, - OUT STATEMENT_ERROR_INFO *ErrorInfo +VOID +CreateRefreshEventForForm ( + IN FORM_BROWSER_FORM *Form ) { - FORM_BROWSER_STATEMENT *Question; - EFI_HII_VALUE BackUpValue; - UINT8 *BackUpBuffer; - UINT32 RetVal; - - BackUpBuffer = NULL; - RetVal = STATEMENT_VALID; - - ASSERT (Form != NULL && Statement != NULL && InputValue != NULL && ErrorInfo != NULL); - - Question = GetBrowserStatement(Statement); - ASSERT (Question != NULL); - - // - // Back up the quesion value. - // - switch (Question->Operand) { - case EFI_IFR_ORDERED_LIST_OP: - BackUpBuffer = AllocateCopyPool (Question->StorageWidth, Question->BufferValue); - ASSERT (BackUpBuffer != NULL); - CopyMem (Question->BufferValue, InputValue->Buffer, Question->StorageWidth); - break; - - default: - CopyMem (&BackUpValue, &Question->HiiValue, sizeof (EFI_HII_VALUE)); - CopyMem (&Question->HiiValue, InputValue, sizeof (EFI_HII_VALUE)); - break; - } - - // - // Do the inconsistentif check. - // - if (!IsListEmpty (&Question->InconsistentListHead)) { - RetVal = ConditionCheck(Question, EFI_HII_EXPRESSION_INCONSISTENT_IF, ErrorInfo); - } - - // - // Do the warningif check. - // - if (RetVal == STATEMENT_VALID && !IsListEmpty (&Question->WarningListHead)) { - RetVal = ConditionCheck(Question, EFI_HII_EXPRESSION_WARNING_IF, ErrorInfo); - } + EFI_STATUS Status; + EFI_EVENT RefreshEvent; + FORM_BROWSER_REFRESH_EVENT_NODE *EventNode; // - // Restore the quesion value. + // If question has refresh guid, create the notify function. // - switch (Question->Operand) { - case EFI_IFR_ORDERED_LIST_OP: - CopyMem (Question->BufferValue, BackUpBuffer, Question->StorageWidth); - break; - - default: - CopyMem (&Question->HiiValue, &BackUpValue, sizeof (EFI_HII_VALUE)); - break; - } + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + RefreshEventNotifyForForm, + Form, + &Form->RefreshGuid, + &RefreshEvent); + ASSERT_EFI_ERROR (Status); - return RetVal; + EventNode = AllocateZeroPool (sizeof (FORM_BROWSER_REFRESH_EVENT_NODE)); + ASSERT (EventNode != NULL); + EventNode->RefreshEvent = RefreshEvent; + InsertTailList(&mRefreshEventList, &EventNode->Link); } /** @@ -464,8 +358,8 @@ InitializeDisplayStatement ( // // Create the refresh event process function. // - if (!CompareGuid (&Statement->RefreshGuid, &gZeroGuid)) { - CreateRefreshEvent (Statement); + if (!IsZeroGuid (&Statement->RefreshGuid)) { + CreateRefreshEventForStatement (Statement); } // @@ -479,7 +373,7 @@ InitializeDisplayStatement ( // Create the refresh guid hook event. // If the statement in this form has refresh event or refresh interval, browser will create this event for display engine. // - if ((!CompareGuid (&Statement->RefreshGuid, &gZeroGuid)) || (Statement->RefreshInterval != 0)) { + if ((!IsZeroGuid (&Statement->RefreshGuid)) || (Statement->RefreshInterval != 0)) { gDisplayFormData.FormRefreshEvent = mValueChangedEvent; } @@ -490,13 +384,6 @@ InitializeDisplayStatement ( DisplayStatement->PasswordCheck = PasswordCheck; } - // - // Save the validate check question for later use. - // - if (!IsListEmpty (&Statement->InconsistentListHead) || !IsListEmpty (&Statement->WarningListHead)) { - DisplayStatement->ValidateQuestion = QuestionCheck; - } - // // If this statement is nest in the subtitle, insert to the host statement. // else insert to the form it belongs to. @@ -561,8 +448,11 @@ UpdateHotkeyList ( HotKey = BROWSER_HOT_KEY_FROM_LINK (Link); CopyKey = AllocateCopyPool(sizeof (BROWSER_HOT_KEY), HotKey); + ASSERT (CopyKey != NULL); CopyKey->KeyData = AllocateCopyPool(sizeof (EFI_INPUT_KEY), HotKey->KeyData); + ASSERT (CopyKey->KeyData != NULL); CopyKey->HelpString = AllocateCopyPool(StrSize (HotKey->HelpString), HotKey->HelpString); + ASSERT (CopyKey->HelpString != NULL); InsertTailList(&gDisplayFormData.HotKeyListHead, &CopyKey->Link); @@ -656,6 +546,21 @@ AddStatementToDisplayForm ( InsertTailList(&gDisplayFormData.StatementListOSF, &DisplayStatement->DisplayLink); } + // + // treat formset as statement outside the form,get its opcode. + // + DisplayStatement = AllocateZeroPool (sizeof (FORM_DISPLAY_ENGINE_STATEMENT)); + ASSERT (DisplayStatement != NULL); + + DisplayStatement->Signature = FORM_DISPLAY_ENGINE_STATEMENT_SIGNATURE; + DisplayStatement->Version = FORM_DISPLAY_ENGINE_STATEMENT_VERSION_1; + DisplayStatement->OpCode = gCurrentSelection->FormSet->OpCode; + + InitializeListHead (&DisplayStatement->NestStatementList); + InitializeListHead (&DisplayStatement->OptionListHead); + + InsertTailList(&gDisplayFormData.StatementListOSF, &DisplayStatement->DisplayLink); + // // Process the statement in this form. // @@ -720,6 +625,16 @@ AddStatementToDisplayForm ( InsertTailList(&mRefreshEventList, &EventNode->Link); } + // + // Create the refresh event process function for Form. + // + if (!IsZeroGuid (&gCurrentSelection->Form->RefreshGuid)) { + CreateRefreshEventForForm (gCurrentSelection->Form); + if (gDisplayFormData.FormRefreshEvent == NULL) { + gDisplayFormData.FormRefreshEvent = mValueChangedEvent; + } + } + // // Update hotkey list field. // @@ -857,12 +772,6 @@ UpdateDisplayFormData ( gDisplayFormData.FormRefreshEvent = NULL; gDisplayFormData.HighLightedStatement = NULL; - gDisplayFormData.BrowserStatus = gBrowserStatus; - gDisplayFormData.ErrorString = gErrorInfo; - - gBrowserStatus = BROWSER_SUCCESS; - gErrorInfo = NULL; - UpdateDataChangedFlag (); AddStatementToDisplayForm (); @@ -984,6 +893,13 @@ UpdateStatementStatusForForm ( Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link); Link = GetNextNode (&Form->StatementListHead, Link); + // + // For password opcode, not set the the value changed flag. + // + if (Question->Operand == EFI_IFR_PASSWORD_OP) { + continue; + } + IsQuestionValueChanged(FormSet, Form, Question, GetSetValueWithBuffer); } } @@ -1072,8 +988,6 @@ ProcessAction ( IN UINT16 DefaultId ) { - EFI_STATUS Status; - // // This is caused by use press ESC, and it should not combine with other action type. // @@ -1090,15 +1004,12 @@ ProcessAction ( } if ((Action & BROWSER_ACTION_DEFAULT) == BROWSER_ACTION_DEFAULT) { - ExtractDefault (gCurrentSelection->FormSet, gCurrentSelection->Form, DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL, FALSE); + ExtractDefault (gCurrentSelection->FormSet, gCurrentSelection->Form, DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL, FALSE, FALSE); UpdateStatementStatus (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope); } if ((Action & BROWSER_ACTION_SUBMIT) == BROWSER_ACTION_SUBMIT) { - Status = SubmitForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope); - if (EFI_ERROR (Status)) { - gBrowserStatus = BROWSER_SUBMIT_FAIL; - } + SubmitForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope); } if ((Action & BROWSER_ACTION_RESET) == BROWSER_ACTION_RESET) { @@ -1353,7 +1264,8 @@ ProcessChangedData ( IN BROWSER_SETTING_SCOPE Scope ) { - BOOLEAN RetValue; + BOOLEAN RetValue; + EFI_STATUS Status; RetValue = TRUE; switch (mFormDisplay->ConfirmDataChange()) { @@ -1362,7 +1274,10 @@ ProcessChangedData ( break; case BROWSER_ACTION_SUBMIT: - SubmitForm (Selection->FormSet, Selection->Form, Scope); + Status = SubmitForm (Selection->FormSet, Selection->Form, Scope); + if (EFI_ERROR (Status)) { + RetValue = FALSE; + } break; case BROWSER_ACTION_NONE: @@ -1396,15 +1311,7 @@ FindParentFormSet ( FORM_ENTRY_INFO *ParentMenu; CurrentMenu = Selection->CurrentMenu; - ParentMenu = UiFindParentMenu(CurrentMenu); - - // - // Find a menu which has different formset guid with current. - // - while (ParentMenu != NULL && CompareGuid (&CurrentMenu->FormSetGuid, &ParentMenu->FormSetGuid)) { - CurrentMenu = ParentMenu; - ParentMenu = UiFindParentMenu(CurrentMenu); - } + ParentMenu = UiFindParentMenu(CurrentMenu, FormSetLevel); if (ParentMenu != NULL) { CopyMem (&Selection->FormSetGuid, &ParentMenu->FormSetGuid, sizeof (EFI_GUID)); @@ -1473,7 +1380,7 @@ ProcessGotoOpCode ( // // Not found the EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL protocol. // - gBrowserStatus = BROWSER_PROTOCOL_NOT_FOUND; + PopupErrorMessage(BROWSER_PROTOCOL_NOT_FOUND, NULL, NULL, NULL); FreePool (StringPtr); return Status; } @@ -1503,7 +1410,7 @@ ProcessGotoOpCode ( CopyMem (&Selection->FormSetGuid,&Statement->HiiValue.Value.ref.FormSetGuid, sizeof (EFI_GUID)); Selection->FormId = Statement->HiiValue.Value.ref.FormId; Selection->QuestionId = Statement->HiiValue.Value.ref.QuestionId; - } else if (!CompareGuid (&Statement->HiiValue.Value.ref.FormSetGuid, &gZeroGuid)) { + } else if (!IsZeroGuid (&Statement->HiiValue.Value.ref.FormSetGuid)) { if (Selection->Form->ModalForm) { return Status; } @@ -1550,7 +1457,7 @@ ProcessGotoOpCode ( // // Form is suppressed. // - gBrowserStatus = BROWSER_FORM_SUPPRESS; + PopupErrorMessage(BROWSER_FORM_SUPPRESS, NULL, NULL, NULL); return EFI_SUCCESS; } } @@ -1595,6 +1502,8 @@ ProcessQuestionConfig ( ConfigResp = GetToken (Question->QuestionConfig, Selection->FormSet->HiiHandle); if (ConfigResp == NULL) { return EFI_NOT_FOUND; + } else if (ConfigResp[0] == L'\0') { + return EFI_SUCCESS; } // @@ -1614,21 +1523,20 @@ ProcessQuestionConfig ( Process the user input data. @param UserInput The user input data. - @param ChangeHighlight Whether need to change the highlight statement. @retval EFI_SUCESSS This function always return successfully for now. **/ EFI_STATUS ProcessUserInput ( - IN USER_INPUT *UserInput, - IN BOOLEAN ChangeHighlight + IN USER_INPUT *UserInput ) { EFI_STATUS Status; FORM_BROWSER_STATEMENT *Statement; - Status = EFI_SUCCESS; + Status = EFI_SUCCESS; + Statement = NULL; // // When Exit from FormDisplay function, one of the below two cases must be true. @@ -1639,62 +1547,35 @@ ProcessUserInput ( // Remove the last highligh question id, this id will update when show next form. // gCurrentSelection->QuestionId = 0; + if (UserInput->SelectedStatement != NULL){ + Statement = GetBrowserStatement(UserInput->SelectedStatement); + ASSERT (Statement != NULL); + + // + // This question is the current user select one,record it and later + // show it as the highlight question. + // + gCurrentSelection->CurrentMenu->QuestionId = Statement->QuestionId; + // + // For statement like text, actio, it not has question id. + // So use FakeQuestionId to save the question. + // + if (gCurrentSelection->CurrentMenu->QuestionId == 0) { + mCurFakeQestId = Statement->FakeQuestionId; + } else { + mCurFakeQestId = 0; + } + } // // First process the Action field in USER_INPUT. // if (UserInput->Action != 0) { Status = ProcessAction (UserInput->Action, UserInput->DefaultId); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Clear the highlight info. - // gCurrentSelection->Statement = NULL; - - if (UserInput->SelectedStatement != NULL) { - Statement = GetBrowserStatement(UserInput->SelectedStatement); - ASSERT (Statement != NULL); - // - // Save the current highlight menu in the menu history data. - // which will be used when later browse back to this form. - // - gCurrentSelection->CurrentMenu->QuestionId = Statement->QuestionId; - // - // For statement like text, actio, it not has question id. - // So use FakeQuestionId to save the question. - // - if (gCurrentSelection->CurrentMenu->QuestionId == 0) { - mCurFakeQestId = Statement->FakeQuestionId; - } else { - mCurFakeQestId = 0; - } - } } else { - Statement = GetBrowserStatement(UserInput->SelectedStatement); ASSERT (Statement != NULL); - gCurrentSelection->Statement = Statement; - - if (ChangeHighlight) { - // - // This question is the current user select one,record it and later - // show it as the highlight question. - // - gCurrentSelection->CurrentMenu->QuestionId = Statement->QuestionId; - // - // For statement like text, actio, it not has question id. - // So use FakeQuestionId to save the question. - // - if (gCurrentSelection->CurrentMenu->QuestionId == 0) { - mCurFakeQestId = Statement->FakeQuestionId; - } else { - mCurFakeQestId = 0; - } - } - switch (Statement->Operand) { case EFI_IFR_REF_OP: Status = ProcessGotoOpCode(Statement, gCurrentSelection); @@ -1711,7 +1592,7 @@ ProcessUserInput ( // // Reset Question to default value specified by DefaultId // - Status = ExtractDefault (gCurrentSelection->FormSet, NULL, Statement->DefaultId, FormSetLevel, GetDefaultForAll, NULL, FALSE); + Status = ExtractDefault (gCurrentSelection->FormSet, NULL, Statement->DefaultId, FormSetLevel, GetDefaultForAll, NULL, FALSE, FALSE); UpdateStatementStatus (gCurrentSelection->FormSet, NULL, FormSetLevel); break; @@ -1781,7 +1662,6 @@ DisplayForm ( EFI_STATUS Status; USER_INPUT UserInput; FORM_ENTRY_INFO *CurrentMenu; - BOOLEAN ChangeHighlight; ZeroMem (&UserInput, sizeof (USER_INPUT)); @@ -1797,11 +1677,14 @@ DisplayForm ( gCurrentSelection->FormId, gCurrentSelection->QuestionId); ASSERT (CurrentMenu != NULL); } - gCurrentSelection->CurrentMenu = CurrentMenu; // - // Find currrent highlight statement. + // Back up the form view history data for this form. // + UiCopyMenuList(&gCurrentSelection->Form->FormViewListHead, &mPrivateData.FormBrowserEx2.FormViewHistoryHead); + + gCurrentSelection->CurrentMenu = CurrentMenu; + if (gCurrentSelection->QuestionId == 0) { // // Highlight not specified, fetch it from cached menu @@ -1809,9 +1692,6 @@ DisplayForm ( gCurrentSelection->QuestionId = CurrentMenu->QuestionId; } - // - // Evaluate all the Expressions in this Form - // Status = EvaluateFormExpressions (gCurrentSelection->FormSet, gCurrentSelection->Form); if (EFI_ERROR (Status)) { return Status; @@ -1819,33 +1699,15 @@ DisplayForm ( UpdateDisplayFormData (); - // - // Three possible status maybe return. - // - // EFI_INVALID_PARAMETER: The input dimension info is not valid. - // EFI_NOT_FOUND: The input value for oneof/orderedlist opcode is not valid - // and an valid value has return. - // EFI_SUCCESS: Success shows form and get user input in UserInput paramenter. - // + ASSERT (gDisplayFormData.BrowserStatus == BROWSER_SUCCESS); Status = mFormDisplay->FormDisplay (&gDisplayFormData, &UserInput); - if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) { + if (EFI_ERROR (Status)) { FreeDisplayFormData(); return Status; } - // - // If status is EFI_SUCCESS, means user has change the highlight menu and new user input return. - // in this case, browser need to change the highlight menu. - // If status is EFI_NOT_FOUND, means the input DisplayFormData has error for oneof/orderedlist - // opcode and new valid value has return, browser core need to adjust - // value for this opcode and shows this form again. - // - ChangeHighlight = (Status == EFI_SUCCESS ? TRUE :FALSE); - - Status = ProcessUserInput (&UserInput, ChangeHighlight); - + Status = ProcessUserInput (&UserInput); FreeDisplayFormData(); - return Status; } @@ -1973,7 +1835,7 @@ IsNvUpdateRequiredForForm ( BOOLEAN FindNextMenu ( IN OUT UI_MENU_SELECTION *Selection, - IN BROWSER_SETTING_SCOPE SettingLevel + IN BROWSER_SETTING_SCOPE SettingLevel ) { FORM_ENTRY_INFO *CurrentMenu; @@ -1981,31 +1843,16 @@ FindNextMenu ( BROWSER_SETTING_SCOPE Scope; CurrentMenu = Selection->CurrentMenu; - ParentMenu = NULL; Scope = FormSetLevel; - if (CurrentMenu != NULL && (ParentMenu = UiFindParentMenu(CurrentMenu)) != NULL) { - // - // we have a parent, so go to the parent menu - // - if (CompareGuid (&CurrentMenu->FormSetGuid, &ParentMenu->FormSetGuid)) { - if (SettingLevel == FormSetLevel) { - // - // Find a menu which has different formset guid with current. - // - while (CompareGuid (&CurrentMenu->FormSetGuid, &ParentMenu->FormSetGuid)) { - CurrentMenu = ParentMenu; - if ((ParentMenu = UiFindParentMenu(CurrentMenu)) == NULL) { - break; - } - } + ParentMenu = UiFindParentMenu(CurrentMenu, SettingLevel); + while (ParentMenu != NULL && !ValidateHiiHandle(ParentMenu->HiiHandle)) { + ParentMenu = UiFindParentMenu(ParentMenu, SettingLevel); + } - if (ParentMenu != NULL) { - Scope = FormSetLevel; - } - } else { - Scope = FormLevel; - } + if (ParentMenu != NULL) { + if (CompareGuid (&CurrentMenu->FormSetGuid, &ParentMenu->FormSetGuid)) { + Scope = FormLevel; } else { Scope = FormSetLevel; } @@ -2016,7 +1863,7 @@ FindNextMenu ( // if ((gBrowserSettingScope == FormLevel && IsNvUpdateRequiredForForm (Selection->Form)) || (gBrowserSettingScope == FormSetLevel && IsNvUpdateRequiredForFormSet(Selection->FormSet) && Scope == FormSetLevel)) { - if (!ProcessChangedData(Selection, Scope)) { + if (!ProcessChangedData(Selection, gBrowserSettingScope)) { return FALSE; } } @@ -2053,6 +1900,30 @@ FindNextMenu ( return TRUE; } +/** + Reconnect the controller. + + @param DriverHandle The controller handle which need to be reconnect. + + @retval TRUE do the reconnect behavior success. + @retval FALSE do the reconnect behavior failed. + +**/ +BOOLEAN +ReconnectController ( + IN EFI_HANDLE DriverHandle + ) +{ + EFI_STATUS Status; + + Status = gBS->DisconnectController(DriverHandle, NULL, NULL); + if (!EFI_ERROR (Status)) { + Status = gBS->ConnectController(DriverHandle, NULL, NULL, TRUE); + } + + return Status == EFI_SUCCESS; +} + /** Call the call back function for the question and process the return action. @@ -2066,8 +1937,8 @@ FindNextMenu ( @param Action The action request. @param SkipSaveOrDiscard Whether skip save or discard action. - @retval EFI_SUCCESS The call back function excutes successfully. - @return Other value if the call back function failed to excute. + @retval EFI_SUCCESS The call back function executes successfully. + @return Other value if the call back function failed to execute. **/ EFI_STATUS ProcessCallBackFunction ( @@ -2080,6 +1951,7 @@ ProcessCallBackFunction ( ) { EFI_STATUS Status; + EFI_STATUS InternalStatus; EFI_BROWSER_ACTION_REQUEST ActionRequest; EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; EFI_HII_VALUE *HiiValue; @@ -2092,6 +1964,7 @@ ProcessCallBackFunction ( BROWSER_SETTING_SCOPE SettingLevel; EFI_IFR_TYPE_VALUE BackUpValue; UINT8 *BackUpBuffer; + CHAR16 *NewString; ConfigAccess = FormSet->ConfigAccess; SubmitFormIsRequired = FALSE; @@ -2146,6 +2019,7 @@ ProcessCallBackFunction ( if (Action == EFI_BROWSER_ACTION_CHANGING) { if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) { BackUpBuffer = AllocateCopyPool(Statement->StorageWidth + sizeof(CHAR16), Statement->BufferValue); + ASSERT (BackUpBuffer != NULL); } else { CopyMem (&BackUpValue, &HiiValue->Value, sizeof (EFI_IFR_TYPE_VALUE)); } @@ -2161,10 +2035,28 @@ ProcessCallBackFunction ( &ActionRequest ); if (!EFI_ERROR (Status)) { + // + // Need to sync the value between Statement->HiiValue->Value and Statement->BufferValue + // + if (HiiValue->Type == EFI_IFR_TYPE_STRING) { + NewString = GetToken (Statement->HiiValue.Value.string, FormSet->HiiHandle); + ASSERT (NewString != NULL); + + ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth); + if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) { + ZeroMem (Statement->BufferValue, Statement->StorageWidth); + CopyMem (Statement->BufferValue, NewString, StrSize (NewString)); + } else { + CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth); + } + FreePool (NewString); + } + // // Only for EFI_BROWSER_ACTION_CHANGED need to handle this ActionRequest. // - if (Action == EFI_BROWSER_ACTION_CHANGED) { + switch (Action) { + case EFI_BROWSER_ACTION_CHANGED: switch (ActionRequest) { case EFI_BROWSER_ACTION_REQUEST_RESET: DiscardFormIsRequired = TRUE; @@ -2204,17 +2096,44 @@ ProcessCallBackFunction ( SettingLevel = FormLevel; break; + case EFI_BROWSER_ACTION_REQUEST_RECONNECT: + gCallbackReconnect = TRUE; + break; + default: break; } - } + break; - // - // According the spec, return value from call back of "changing" and - // "retrieve" should update to the question's temp buffer. - // - if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) { + case EFI_BROWSER_ACTION_CHANGING: + // + // Do the question validation. + // + Status = ValueChangedValidation (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement); + if (!EFI_ERROR (Status)) { + // + //check whether the question value changed compared with edit buffer before updating edit buffer + // if changed, set the ValueChanged flag to TRUE,in order to trig the CHANGED callback function + // + IsQuestionValueChanged(gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithEditBuffer); + // + // According the spec, return value from call back of "changing" and + // "retrieve" should update to the question's temp buffer. + // + SetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer); + } + break; + + case EFI_BROWSER_ACTION_RETRIEVE: + // + // According the spec, return value from call back of "changing" and + // "retrieve" should update to the question's temp buffer. + // SetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer); + break; + + default: + break; } } else { // @@ -2228,16 +2147,34 @@ ProcessCallBackFunction ( } else { CopyMem (&HiiValue->Value, &BackUpValue, sizeof (EFI_IFR_TYPE_VALUE)); } - - SetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer); + + // + // Do the question validation. + // + InternalStatus = ValueChangedValidation (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement); + if (!EFI_ERROR (InternalStatus)) { + // + //check whether the question value changed compared with edit buffer before updating edit buffer + // if changed, set the ValueChanged flag to TRUE,in order to trig the CHANGED callback function + // + IsQuestionValueChanged(gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithEditBuffer); + SetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer); + } } // // According the spec, return fail from call back of "changing" and // "retrieve", should restore the question's value. // - if ((Action == EFI_BROWSER_ACTION_CHANGING && Status != EFI_UNSUPPORTED) || - Action == EFI_BROWSER_ACTION_RETRIEVE) { + if (Action == EFI_BROWSER_ACTION_CHANGING && Status != EFI_UNSUPPORTED) { + if (Statement->Storage != NULL) { + GetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer); + } else if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) { + ProcessCallBackFunction (Selection, FormSet, Form, Question, EFI_BROWSER_ACTION_RETRIEVE, FALSE); + } + } + + if (Action == EFI_BROWSER_ACTION_RETRIEVE) { GetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer); } @@ -2252,6 +2189,37 @@ ProcessCallBackFunction ( if (BackUpBuffer != NULL) { FreePool (BackUpBuffer); } + + // + // If Question != NULL, means just process one question + // and if code reach here means this question has finished + // processing, so just break. + // + if (Question != NULL) { + break; + } + } + + if (gCallbackReconnect && (EFI_BROWSER_ACTION_CHANGED == Action)) { + // + // Confirm changes with user first. + // + if (IsNvUpdateRequiredForFormSet(FormSet)) { + if (BROWSER_ACTION_DISCARD == PopupErrorMessage(BROWSER_RECONNECT_SAVE_CHANGES, NULL, NULL, NULL)) { + gCallbackReconnect = FALSE; + DiscardFormIsRequired = TRUE; + } else { + SubmitFormIsRequired = TRUE; + } + } else { + PopupErrorMessage(BROWSER_RECONNECT_REQUIRED, NULL, NULL, NULL); + } + + // + // Exit current formset before do the reconnect. + // + NeedExit = TRUE; + SettingLevel = FormSetLevel; } if (SubmitFormIsRequired && !SkipSaveOrDiscard) { @@ -2277,20 +2245,23 @@ ProcessCallBackFunction ( @param ConfigAccess The config access protocol produced by the hii driver. @param Statement The Question which need to call. + @param FormSet The formset this question belong to. - @retval EFI_SUCCESS The call back function excutes successfully. - @return Other value if the call back function failed to excute. + @retval EFI_SUCCESS The call back function executes successfully. + @return Other value if the call back function failed to execute. **/ EFI_STATUS ProcessRetrieveForQuestion ( IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess, - IN FORM_BROWSER_STATEMENT *Statement + IN FORM_BROWSER_STATEMENT *Statement, + IN FORM_BROWSER_FORMSET *FormSet ) { EFI_STATUS Status; EFI_BROWSER_ACTION_REQUEST ActionRequest; EFI_HII_VALUE *HiiValue; EFI_IFR_TYPE_VALUE *TypeValue; + CHAR16 *NewString; Status = EFI_SUCCESS; ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; @@ -2317,6 +2288,20 @@ ProcessRetrieveForQuestion ( TypeValue, &ActionRequest ); + if (!EFI_ERROR (Status) && HiiValue->Type == EFI_IFR_TYPE_STRING) { + NewString = GetToken (Statement->HiiValue.Value.string, FormSet->HiiHandle); + ASSERT (NewString != NULL); + + ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth); + if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) { + ZeroMem (Statement->BufferValue, Statement->StorageWidth); + CopyMem (Statement->BufferValue, NewString, StrSize (NewString)); + } else { + CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth); + } + FreePool (NewString); + } + return Status; } @@ -2361,11 +2346,6 @@ SetupBrowser ( return Status; } - if ((Selection->Handle != mCurrentHiiHandle) || - (!CompareGuid (&Selection->FormSetGuid, &mCurrentFormSetGuid))) { - gFinishRetrieveCall = FALSE; - } - // // Initialize current settings of Questions in this FormSet // @@ -2382,8 +2362,16 @@ SetupBrowser ( mCurFakeQestId = 0; do { + + // + // Reset Status to prevent the next break from returning incorrect error status. + // + Status = EFI_SUCCESS; + // // IFR is updated, force to reparse the IFR binary + // This check is shared by EFI_BROWSER_ACTION_FORM_CLOSE and + // EFI_BROWSER_ACTION_RETRIEVE, so code place here. // if (mHiiPackageListUpdated) { Selection->Action = UI_ACTION_REFRESH_FORMSET; @@ -2422,7 +2410,7 @@ SetupBrowser ( // // Form is suppressed. // - gBrowserStatus = BROWSER_FORM_SUPPRESS; + PopupErrorMessage(BROWSER_FORM_SUPPRESS, NULL, NULL, NULL); Status = EFI_NOT_FOUND; goto Done; } @@ -2436,6 +2424,11 @@ SetupBrowser ( if (((Selection->Handle != mCurrentHiiHandle) || (!CompareGuid (&Selection->FormSetGuid, &mCurrentFormSetGuid)) || (Selection->FormId != mCurrentFormId))) { + // + // Update Retrieve flag. + // + mFinishRetrieveCall = FALSE; + // // Keep current form information // @@ -2444,13 +2437,13 @@ SetupBrowser ( mCurrentFormId = Selection->FormId; if (ConfigAccess != NULL) { - Status = ProcessCallBackFunction (Selection, gCurrentSelection->FormSet, Selection->Form, NULL, EFI_BROWSER_ACTION_FORM_OPEN, FALSE); + Status = ProcessCallBackFunction (Selection, Selection->FormSet, Selection->Form, NULL, EFI_BROWSER_ACTION_FORM_OPEN, FALSE); if (EFI_ERROR (Status)) { goto Done; } // - // IFR is updated during callback of open form, force to reparse the IFR binary + // IFR is updated during callback of EFI_BROWSER_ACTION_FORM_OPEN, force to reparse the IFR binary // if (mHiiPackageListUpdated) { Selection->Action = UI_ACTION_REFRESH_FORMSET; @@ -2468,18 +2461,27 @@ SetupBrowser ( goto Done; } - // - // Finish call RETRIEVE callback for this formset. - // - gFinishRetrieveCall = TRUE; + if (!mFinishRetrieveCall) { + // + // Finish call RETRIEVE callback for this form. + // + mFinishRetrieveCall = TRUE; - // - // IFR is updated during callback of read value, force to reparse the IFR binary - // - if (mHiiPackageListUpdated) { - Selection->Action = UI_ACTION_REFRESH_FORMSET; - mHiiPackageListUpdated = FALSE; - break; + if (ConfigAccess != NULL) { + Status = ProcessCallBackFunction (Selection, Selection->FormSet, Selection->Form, NULL, EFI_BROWSER_ACTION_RETRIEVE, FALSE); + if (EFI_ERROR (Status)) { + goto Done; + } + + // + // IFR is updated during callback of open form, force to reparse the IFR binary + // + if (mHiiPackageListUpdated) { + Selection->Action = UI_ACTION_REFRESH_FORMSET; + mHiiPackageListUpdated = FALSE; + break; + } + } } // @@ -2512,37 +2514,57 @@ SetupBrowser ( // if (EFI_ERROR (Status)) { // - // Cross reference will not be taken + // Cross reference will not be taken, restore all essential field // - Selection->FormId = Selection->Form->FormId; + Selection->Handle = mCurrentHiiHandle; + CopyMem (&Selection->FormSetGuid, &mCurrentFormSetGuid, sizeof (EFI_GUID)); + Selection->FormId = mCurrentFormId; Selection->QuestionId = 0; + Selection->Action = UI_ACTION_REFRESH_FORM; } } - // - // Verify whether question value has checked, update the ValueChanged flag in Question. - // - IsQuestionValueChanged(gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithBuffer); - if (!EFI_ERROR (Status) && Statement->Operand != EFI_IFR_REF_OP) { + if (!EFI_ERROR (Status) && + (Statement->Operand != EFI_IFR_REF_OP) && + ((Statement->Storage == NULL) || (Statement->Storage != NULL && Statement->ValueChanged))) { + // + // Only question value has been changed, browser will trig CHANGED callback. + // ProcessCallBackFunction(Selection, Selection->FormSet, Selection->Form, Statement, EFI_BROWSER_ACTION_CHANGED, FALSE); + // + //check whether the question value changed compared with buffer value + //if doesn't change ,set the ValueChanged flag to FALSE ,in order not to display the "configuration changed "information on the screen + // + IsQuestionValueChanged(gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithBuffer); } - } else if (Statement->Operand != EFI_IFR_PASSWORD_OP) { - SetQuestionValue (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithEditBuffer); + } else { // - // Verify whether question value has checked, update the ValueChanged flag in Question. + // Do the question validation. // - IsQuestionValueChanged(gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithBuffer); + Status = ValueChangedValidation (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement); + if (!EFI_ERROR (Status) && (Statement->Operand != EFI_IFR_PASSWORD_OP)) { + SetQuestionValue (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithEditBuffer); + // + // Verify whether question value has checked, update the ValueChanged flag in Question. + // + IsQuestionValueChanged(gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithBuffer); + } } // - // If question has EFI_IFR_FLAG_RESET_REQUIRED flag and without storage and process question success till here, - // trig the gResetFlag. + // If question has EFI_IFR_FLAG_RESET_REQUIRED/EFI_IFR_FLAG_RECONNECT_REQUIRED flag and without storage + // and process question success till here, trig the gResetFlag/gFlagReconnect. // if ((Status == EFI_SUCCESS) && - (Statement->Storage == NULL) && - ((Statement->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0)) { - gResetRequired = TRUE; + (Statement->Storage == NULL)) { + if ((Statement->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0) { + gResetRequired = TRUE; + } + + if ((Statement->QuestionFlags & EFI_IFR_FLAG_RECONNECT_REQUIRED) != 0) { + gFlagReconnect = TRUE; + } } }