X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FSetupBrowserDxe%2FPresentation.c;h=bad8b7b122ea72d567fc27a599c659ef607bb2f9;hb=4f467fd33b2fc682ed5f1932453d47110345534e;hp=e33081422bbfb5d6d2f17193d8299c66df36d5a0;hpb=b1239a2491262b1561f994d939b64beac37fe819;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index e33081422b..bad8b7b122 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -21,10 +21,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. @@ -225,162 +224,6 @@ CreateRefreshEvent ( InsertTailList(&mRefreshEventList, &EventNode->Link); } -/** - 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; - - default: - ASSERT (FALSE); - break; - } - break; - } - } - - 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 - ) -{ - 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); - } - - // - // Restore the quesion value. - // - 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; - } - - return RetVal; -} - /** Initialize the Display statement structure data. @@ -490,13 +333,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. @@ -857,12 +693,6 @@ UpdateDisplayFormData ( gDisplayFormData.FormRefreshEvent = NULL; gDisplayFormData.HighLightedStatement = NULL; - gDisplayFormData.BrowserStatus = gBrowserStatus; - gDisplayFormData.ErrorString = gErrorInfo; - - gBrowserStatus = BROWSER_SUCCESS; - gErrorInfo = NULL; - UpdateDataChangedFlag (); AddStatementToDisplayForm (); @@ -1097,7 +927,7 @@ ProcessAction ( if ((Action & BROWSER_ACTION_SUBMIT) == BROWSER_ACTION_SUBMIT) { Status = SubmitForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope); if (EFI_ERROR (Status)) { - gBrowserStatus = BROWSER_SUBMIT_FAIL; + PopupErrorMessage(BROWSER_SUBMIT_FAIL, NULL, NULL); } } @@ -1473,7 +1303,7 @@ ProcessGotoOpCode ( // // Not found the EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL protocol. // - gBrowserStatus = BROWSER_PROTOCOL_NOT_FOUND; + PopupErrorMessage(BROWSER_PROTOCOL_NOT_FOUND, NULL, NULL); FreePool (StringPtr); return Status; } @@ -1550,7 +1380,7 @@ ProcessGotoOpCode ( // // Form is suppressed. // - gBrowserStatus = BROWSER_FORM_SUPPRESS; + PopupErrorMessage(BROWSER_FORM_SUPPRESS, NULL, NULL); return EFI_SUCCESS; } } @@ -1957,70 +1787,6 @@ IsNvUpdateRequiredForForm ( return FALSE; } -/** - Check whether the storage data for current form set is changed. - - @param FormSet FormSet data structure. - - @retval TRUE Data is changed. - @retval FALSE Data is not changed. -**/ -BOOLEAN -IsStorageDataChangedForFormSet ( - IN FORM_BROWSER_FORMSET *FormSet - ) -{ - LIST_ENTRY *Link; - FORMSET_STORAGE *Storage; - BROWSER_STORAGE *BrowserStorage; - CHAR16 *ConfigRespNew; - CHAR16 *ConfigRespOld; - BOOLEAN RetVal; - - RetVal = FALSE; - ConfigRespNew = NULL; - ConfigRespOld = NULL; - - // - // Request current settings from Configuration Driver - // - Link = GetFirstNode (&FormSet->StorageListHead); - while (!IsNull (&FormSet->StorageListHead, Link)) { - Storage = FORMSET_STORAGE_FROM_LINK (Link); - Link = GetNextNode (&FormSet->StorageListHead, Link); - - BrowserStorage = Storage->BrowserStorage; - - if (BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) { - continue; - } - - if (Storage->ElementCount == 0) { - continue; - } - - StorageToConfigResp (BrowserStorage, &ConfigRespNew, Storage->ConfigRequest, TRUE); - StorageToConfigResp (BrowserStorage, &ConfigRespOld, Storage->ConfigRequest, FALSE); - ASSERT (ConfigRespNew != NULL && ConfigRespOld != NULL); - - if (StrCmp (ConfigRespNew, ConfigRespOld) != 0) { - RetVal = TRUE; - } - - FreePool (ConfigRespNew); - ConfigRespNew = NULL; - - FreePool (ConfigRespOld); - ConfigRespOld = NULL; - - if (RetVal) { - break; - } - } - - return RetVal; -} - /** Find menu which will show next time. @@ -2156,6 +1922,7 @@ ProcessCallBackFunction ( BROWSER_SETTING_SCOPE SettingLevel; EFI_IFR_TYPE_VALUE BackUpValue; UINT8 *BackUpBuffer; + CHAR16 *NewString; ConfigAccess = FormSet->ConfigAccess; SubmitFormIsRequired = FALSE; @@ -2225,10 +1992,27 @@ 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) { + 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; @@ -2271,14 +2055,32 @@ ProcessCallBackFunction ( 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)) { + // + // 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 { // @@ -2292,8 +2094,14 @@ ProcessCallBackFunction ( } else { CopyMem (&HiiValue->Value, &BackUpValue, sizeof (EFI_IFR_TYPE_VALUE)); } - - SetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer); + + // + // Do the question validation. + // + Status = ValueChangedValidation (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement); + if (!EFI_ERROR (Status)) { + SetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer); + } } // @@ -2341,6 +2149,7 @@ 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. @@ -2348,18 +2157,20 @@ ProcessCallBackFunction ( 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; - - if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) { + + if (((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) || ConfigAccess == NULL) { return EFI_UNSUPPORTED; } @@ -2381,6 +2192,19 @@ 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) { + CopyMem (Statement->BufferValue, NewString, StrSize (NewString)); + } else { + CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth); + } + FreePool (NewString); + } + return Status; } @@ -2425,11 +2249,6 @@ SetupBrowser ( return Status; } - if ((Selection->Handle != mCurrentHiiHandle) || - (!CompareGuid (&Selection->FormSetGuid, &mCurrentFormSetGuid))) { - gFinishRetrieveCall = FALSE; - } - // // Initialize current settings of Questions in this FormSet // @@ -2486,7 +2305,7 @@ SetupBrowser ( // // Form is suppressed. // - gBrowserStatus = BROWSER_FORM_SUPPRESS; + PopupErrorMessage(BROWSER_FORM_SUPPRESS, NULL, NULL); Status = EFI_NOT_FOUND; goto Done; } @@ -2497,10 +2316,14 @@ SetupBrowser ( // for each question with callback flag. // New form may be the first form, or the different form after another form close. // - if ((ConfigAccess != NULL) && - ((Selection->Handle != mCurrentHiiHandle) || + if (((Selection->Handle != mCurrentHiiHandle) || (!CompareGuid (&Selection->FormSetGuid, &mCurrentFormSetGuid)) || (Selection->FormId != mCurrentFormId))) { + // + // Update Retrieve flag. + // + mFinishRetrieveCall = FALSE; + // // Keep current form information // @@ -2508,18 +2331,20 @@ SetupBrowser ( CopyGuid (&mCurrentFormSetGuid, &Selection->FormSetGuid); mCurrentFormId = Selection->FormId; - Status = ProcessCallBackFunction (Selection, gCurrentSelection->FormSet, Selection->Form, NULL, EFI_BROWSER_ACTION_FORM_OPEN, FALSE); - if (EFI_ERROR (Status)) { - goto Done; - } + if (ConfigAccess != NULL) { + 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 - // - if (mHiiPackageListUpdated) { - Selection->Action = UI_ACTION_REFRESH_FORMSET; - mHiiPackageListUpdated = FALSE; - break; + // + // 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; + } } } @@ -2531,18 +2356,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; + } + } } // @@ -2582,18 +2416,28 @@ SetupBrowser ( } } + // + // 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) { ProcessCallBackFunction(Selection, Selection->FormSet, Selection->Form, Statement, EFI_BROWSER_ACTION_CHANGED, FALSE); } - } else if (Statement->Operand != EFI_IFR_PASSWORD_OP) { - SetQuestionValue (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithEditBuffer); + } else { + // + // Do the question validation. + // + 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); + } } - // - // 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.