X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FSetupBrowserDxe%2FSetup.c;h=d7536e7ba539f26ed5a100aa00f971d923b67e0b;hb=061d5462249664ba32d87803365c3355614b35b8;hp=c4dd18a04fd664e4320d71ffabad670625763088;hpb=7c6c064ca8ebb5baf5104e8a4764cd3c19ef8bf1;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index c4dd18a04f..d7536e7ba5 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -1,7 +1,7 @@ /** @file Entry and initialization module for the browser. -Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
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 @@ -46,29 +46,29 @@ UINTN gBrowserContextCount = 0; LIST_ENTRY gBrowserContextList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserContextList); LIST_ENTRY gBrowserFormSetList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserFormSetList); LIST_ENTRY gBrowserHotKeyList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserHotKeyList); -LIST_ENTRY gBrowserStorageList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserStorageList); +LIST_ENTRY gBrowserStorageList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserStorageList); +BOOLEAN gFinishRetrieveCall; BOOLEAN gResetRequired; BOOLEAN gExitRequired; BROWSER_SETTING_SCOPE gBrowserSettingScope = FormSetLevel; BOOLEAN mBrowserScopeFirstSet = TRUE; EXIT_HANDLER ExitHandlerFunction = NULL; +FORM_BROWSER_FORMSET *mSystemLevelFormSet; // // Browser Global Strings // CHAR16 *gEmptyString; - CHAR16 *mUnknownString = L"!"; EFI_GUID gZeroGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; -EFI_GUID gSetupBrowserGuid = { - 0xab368524, 0xb60c, 0x495b, {0xa0, 0x9, 0x12, 0xe8, 0x5b, 0x1a, 0xea, 0x32} -}; -FORM_BROWSER_FORMSET *gOldFormSet = NULL; -extern UINT32 gBrowserStatus; -extern CHAR16 *gErrorInfo; +extern UINT32 gBrowserStatus; +extern CHAR16 *gErrorInfo; +extern EFI_GUID mCurrentFormSetGuid; +extern EFI_HII_HANDLE mCurrentHiiHandle; +extern UINT16 mCurrentFormId; extern FORM_DISPLAY_ENGINE_FORM gDisplayFormData; /** @@ -257,6 +257,12 @@ LoadAllHiiFormset ( UINTN Index; EFI_GUID ZeroGuid; EFI_STATUS Status; + FORM_BROWSER_FORMSET *OldFormset; + BOOLEAN OldRetrieveValue; + + OldFormset = mSystemLevelFormSet; + OldRetrieveValue = gFinishRetrieveCall; + gFinishRetrieveCall = FALSE; // // Get all the Hii handles @@ -280,6 +286,8 @@ LoadAllHiiFormset ( // LocalFormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET)); ASSERT (LocalFormSet != NULL); + mSystemLevelFormSet = LocalFormSet; + ZeroMem (&ZeroGuid, sizeof (ZeroGuid)); Status = InitializeFormSet (HiiHandles[Index], &ZeroGuid, LocalFormSet); if (EFI_ERROR (Status) || IsListEmpty (&LocalFormSet->FormListHead)) { @@ -302,6 +310,9 @@ LoadAllHiiFormset ( // Free resources, and restore gOldFormSet and gClassOfVfr // FreePool (HiiHandles); + + gFinishRetrieveCall = OldRetrieveValue; + mSystemLevelFormSet = OldFormset; } /** @@ -359,6 +370,7 @@ SendForm ( // SaveBrowserContext (); + gFinishRetrieveCall = FALSE; gResetRequired = FALSE; gExitRequired = FALSE; Status = EFI_SUCCESS; @@ -390,6 +402,7 @@ SendForm ( break; } Selection->FormSet = FormSet; + mSystemLevelFormSet = FormSet; // // Display this formset @@ -399,11 +412,12 @@ SendForm ( Status = SetupBrowser (Selection); gCurrentSelection = NULL; + mSystemLevelFormSet = NULL; // // If no data is changed, don't need to save current FormSet into the maintain list. // - if (!IsNvUpdateRequiredForFormSet (FormSet) && !IsStorageDataChangedForFormSet(FormSet)) { + if (!IsNvUpdateRequiredForFormSet (FormSet)) { CleanBrowserStorage(FormSet); RemoveEntryList (&FormSet->Link); DestroyFormSet (FormSet); @@ -582,7 +596,6 @@ BrowserCallback ( LIST_ENTRY *Link; BROWSER_STORAGE *Storage; FORMSET_STORAGE *FormsetStorage; - FORM_BROWSER_FORMSET *FormSet; UINTN TotalSize; BOOLEAN Found; @@ -595,14 +608,6 @@ BrowserCallback ( Found = FALSE; Status = EFI_SUCCESS; - // - // If set browser data, pre load all hii formset to avoid set the varstore which is not - // saved in browser. - // - if (!RetrieveData && (gBrowserSettingScope == SystemLevel)) { - LoadAllHiiFormset(); - } - if (VariableGuid != NULL) { // // Try to find target storage in the current formset. @@ -632,11 +637,26 @@ BrowserCallback ( } } + if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE || + Storage->Type == EFI_HII_VARSTORE_BUFFER) { + if (mSystemLevelFormSet == NULL || mSystemLevelFormSet->HiiHandle == NULL) { + return EFI_NOT_FOUND; + } + + if (Storage->HiiHandle != mSystemLevelFormSet->HiiHandle) { + continue; + } + } + Status = ProcessStorage (&TotalSize, &ResultsData, RetrieveData, Storage); if (EFI_ERROR (Status)) { return Status; } + if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) { + ConfigRequestAdjust (Storage, ResultsData, TRUE); + } + // // Different formsets may have same varstore, so here just set the flag // not exit the circle. @@ -652,16 +672,15 @@ BrowserCallback ( // // GUID/Name is not specified, take the first storage in FormSet // - if (gCurrentSelection == NULL) { + if (mSystemLevelFormSet == NULL) { return EFI_NOT_READY; } // // Generate // - FormSet = gCurrentSelection->FormSet; - Link = GetFirstNode (&FormSet->StorageListHead); - if (IsNull (&FormSet->StorageListHead, Link)) { + Link = GetFirstNode (&mSystemLevelFormSet->StorageListHead); + if (IsNull (&mSystemLevelFormSet->StorageListHead, Link)) { return EFI_UNSUPPORTED; } @@ -768,7 +787,8 @@ InitializeSetup ( // // Install FormBrowserEx2 protocol // - InitializeListHead (&mPrivateData.FormBrowserEx2.FormViewHistoryHead); + InitializeListHead (&mPrivateData.FormBrowserEx2.FormViewHistoryHead); + InitializeListHead (&mPrivateData.FormBrowserEx2.OverrideQestListHead); mPrivateData.Handle = NULL; Status = gBS->InstallProtocolInterface ( &mPrivateData.Handle, @@ -1246,7 +1266,6 @@ GetQuestionValue ( BOOLEAN IsString; CHAR16 TemStr[5]; UINT8 DigitUint8; - UINT8 *TemBuffer; Status = EFI_SUCCESS; Value = NULL; @@ -1256,13 +1275,6 @@ GetQuestionValue ( return EFI_INVALID_PARAMETER; } - // - // Statement don't have storage, skip them - // - if (Question->QuestionId == 0) { - return Status; - } - // // Question value is provided by an Expression, evaluate it // @@ -1470,147 +1482,118 @@ GetQuestionValue ( FreePool (Value); } } else { - if (Storage->Type == EFI_HII_VARSTORE_BUFFER || Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) { - // - // Request current settings from Configuration Driver - // - if (FormSet->ConfigAccess == NULL) { - return EFI_NOT_FOUND; - } - - // - // ::= + || - // + "&" + - // - if (IsBufferStorage) { - Length = StrLen (Storage->ConfigHdr); - Length += StrLen (Question->BlockName); - } else { - Length = StrLen (Storage->ConfigHdr); - Length += StrLen (Question->VariableName) + 1; - } - ConfigRequest = AllocateZeroPool ((Length + 1) * sizeof (CHAR16)); - ASSERT (ConfigRequest != NULL); + // + // ::= + || + // + "&" + + // + if (IsBufferStorage) { + Length = StrLen (Storage->ConfigHdr); + Length += StrLen (Question->BlockName); + } else { + Length = StrLen (Storage->ConfigHdr); + Length += StrLen (Question->VariableName) + 1; + } + ConfigRequest = AllocateZeroPool ((Length + 1) * sizeof (CHAR16)); + ASSERT (ConfigRequest != NULL); - StrCpy (ConfigRequest, Storage->ConfigHdr); - if (IsBufferStorage) { - StrCat (ConfigRequest, Question->BlockName); - } else { - StrCat (ConfigRequest, L"&"); - StrCat (ConfigRequest, Question->VariableName); - } + StrCpy (ConfigRequest, Storage->ConfigHdr); + if (IsBufferStorage) { + StrCat (ConfigRequest, Question->BlockName); + } else { + StrCat (ConfigRequest, L"&"); + StrCat (ConfigRequest, Question->VariableName); + } - Status = FormSet->ConfigAccess->ExtractConfig ( - FormSet->ConfigAccess, - ConfigRequest, - &Progress, - &Result - ); - FreePool (ConfigRequest); - if (EFI_ERROR (Status)) { - return Status; - } + // + // Request current settings from Configuration Driver + // + Status = mHiiConfigRouting->ExtractConfig ( + mHiiConfigRouting, + ConfigRequest, + &Progress, + &Result + ); + FreePool (ConfigRequest); + if (EFI_ERROR (Status)) { + return Status; + } - // - // Skip - // - if (IsBufferStorage) { - Value = StrStr (Result, L"&VALUE"); - if (Value == NULL) { - FreePool (Result); - return EFI_NOT_FOUND; - } - // - // Skip "&VALUE" - // - Value = Value + 6; - } else { - Value = Result + Length; - } - if (*Value != '=') { + // + // Skip + // + if (IsBufferStorage) { + Value = StrStr (Result, L"&VALUE"); + if (Value == NULL) { FreePool (Result); return EFI_NOT_FOUND; } // - // Skip '=', point to value + // Skip "&VALUE" // - Value = Value + 1; + Value = Value + 6; + } else { + Value = Result + Length; + } + if (*Value != '=') { + FreePool (Result); + return EFI_NOT_FOUND; + } + // + // Skip '=', point to value + // + Value = Value + 1; + + // + // Suppress if any + // + StringPtr = Value; + while (*StringPtr != L'\0' && *StringPtr != L'&') { + StringPtr++; + } + *StringPtr = L'\0'; + LengthStr = StrLen (Value); + Status = EFI_SUCCESS; + if (!IsBufferStorage && IsString) { // - // Suppress if any + // Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD" + // Add string tail char L'\0' into Length // - StringPtr = Value; - while (*StringPtr != L'\0' && *StringPtr != L'&') { - StringPtr++; - } - *StringPtr = L'\0'; - - LengthStr = StrLen (Value); - Status = EFI_SUCCESS; - if (!IsBufferStorage && IsString) { + Length = StorageWidth + sizeof (CHAR16); + if (Length < ((LengthStr / 4 + 1) * 2)) { + Status = EFI_BUFFER_TOO_SMALL; + } else { + StringPtr = (CHAR16 *) Dst; + ZeroMem (TemStr, sizeof (TemStr)); + for (Index = 0; Index < LengthStr; Index += 4) { + StrnCpy (TemStr, Value + Index, 4); + StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr); + } // - // Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD" - // Add string tail char L'\0' into Length + // Add tailing L'\0' character // - Length = StorageWidth + sizeof (CHAR16); - if (Length < ((LengthStr / 4 + 1) * 2)) { - Status = EFI_BUFFER_TOO_SMALL; - } else { - StringPtr = (CHAR16 *) Dst; - ZeroMem (TemStr, sizeof (TemStr)); - for (Index = 0; Index < LengthStr; Index += 4) { - StrnCpy (TemStr, Value + Index, 4); - StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr); - } - // - // Add tailing L'\0' character - // - StringPtr[Index/4] = L'\0'; - } + StringPtr[Index/4] = L'\0'; + } + } else { + if (StorageWidth < ((LengthStr + 1) / 2)) { + Status = EFI_BUFFER_TOO_SMALL; } else { - if (StorageWidth < ((LengthStr + 1) / 2)) { - Status = EFI_BUFFER_TOO_SMALL; - } else { - ZeroMem (TemStr, sizeof (TemStr)); - for (Index = 0; Index < LengthStr; Index ++) { - TemStr[0] = Value[LengthStr - Index - 1]; - DigitUint8 = (UINT8) StrHexToUint64 (TemStr); - if ((Index & 1) == 0) { - Dst [Index/2] = DigitUint8; - } else { - Dst [Index/2] = (UINT8) ((DigitUint8 << 4) + Dst [Index/2]); - } + ZeroMem (TemStr, sizeof (TemStr)); + for (Index = 0; Index < LengthStr; Index ++) { + TemStr[0] = Value[LengthStr - Index - 1]; + DigitUint8 = (UINT8) StrHexToUint64 (TemStr); + if ((Index & 1) == 0) { + Dst [Index/2] = DigitUint8; + } else { + Dst [Index/2] = (UINT8) ((DigitUint8 << 4) + Dst [Index/2]); } } } + } - if (EFI_ERROR (Status)) { - FreePool (Result); - return Status; - } - } else if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) { - TemBuffer = NULL; - TemBuffer = AllocateZeroPool (Storage->Size); - if (TemBuffer == NULL) { - Status = EFI_OUT_OF_RESOURCES; - return Status; - } - Length = Storage->Size; - Status = gRT->GetVariable ( - Storage->Name, - &Storage->Guid, - NULL, - &Length, - TemBuffer - ); - if (EFI_ERROR (Status)) { - FreePool (TemBuffer); - return Status; - } - - CopyMem (Dst, TemBuffer + Question->VarStoreInfo.VarOffset, StorageWidth); - - FreePool (TemBuffer); + if (EFI_ERROR (Status)) { + FreePool (Result); + return Status; } // @@ -1678,13 +1661,6 @@ SetQuestionValue ( return EFI_INVALID_PARAMETER; } - // - // Statement don't have storage, skip them - // - if (Question->QuestionId == 0) { - return Status; - } - // // If Question value is provided by an Expression, then it is read only // @@ -1807,14 +1783,6 @@ SetQuestionValue ( // CopyMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth); } - // - // Check whether question value has been changed. - // - if (CompareMem (Storage->Buffer + Question->VarStoreInfo.VarOffset, Storage->EditBuffer + Question->VarStoreInfo.VarOffset, StorageWidth) != 0) { - Question->ValueChanged = TRUE; - } else { - Question->ValueChanged = FALSE; - } } else { if (IsString) { // @@ -1851,121 +1819,80 @@ SetQuestionValue ( if (EFI_ERROR (Status)) { return Status; } - // - // Check whether question value has been changed. - // - if (StrCmp (Node->Value, Node->EditValue) != 0) { - Question->ValueChanged = TRUE; - } else { - Question->ValueChanged = FALSE; - } } } else if (SetValueTo == GetSetValueWithHiiDriver) { - if (Storage->Type == EFI_HII_VARSTORE_BUFFER || Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) { - // - // ::= + + "&VALUE=" + "StorageWidth * 2" || - // + "&" + + "=" + "" - // - if (IsBufferStorage) { - Length = StrLen (Question->BlockName) + 7; - } else { - Length = StrLen (Question->VariableName) + 2; - } - if (!IsBufferStorage && IsString) { - Length += (StrLen ((CHAR16 *) Src) * 4); - } else { - Length += (StorageWidth * 2); - } - ConfigResp = AllocateZeroPool ((StrLen (Storage->ConfigHdr) + Length + 1) * sizeof (CHAR16)); - ASSERT (ConfigResp != NULL); - - StrCpy (ConfigResp, Storage->ConfigHdr); - if (IsBufferStorage) { - StrCat (ConfigResp, Question->BlockName); - StrCat (ConfigResp, L"&VALUE="); - } else { - StrCat (ConfigResp, L"&"); - StrCat (ConfigResp, Question->VariableName); - StrCat (ConfigResp, L"="); - } + // + // ::= + + "&VALUE=" + "StorageWidth * 2" || + // + "&" + + "=" + "" + // + if (IsBufferStorage) { + Length = StrLen (Question->BlockName) + 7; + } else { + Length = StrLen (Question->VariableName) + 2; + } + if (!IsBufferStorage && IsString) { + Length += (StrLen ((CHAR16 *) Src) * 4); + } else { + Length += (StorageWidth * 2); + } + ConfigResp = AllocateZeroPool ((StrLen (Storage->ConfigHdr) + Length + 1) * sizeof (CHAR16)); + ASSERT (ConfigResp != NULL); - Value = ConfigResp + StrLen (ConfigResp); + StrCpy (ConfigResp, Storage->ConfigHdr); + if (IsBufferStorage) { + StrCat (ConfigResp, Question->BlockName); + StrCat (ConfigResp, L"&VALUE="); + } else { + StrCat (ConfigResp, L"&"); + StrCat (ConfigResp, Question->VariableName); + StrCat (ConfigResp, L"="); + } - if (!IsBufferStorage && IsString) { - // - // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044" - // - TemName = (CHAR16 *) Src; - TemString = Value; - for (; *TemName != L'\0'; TemName++) { - TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4); - } - } else { - // - // Convert Buffer to Hex String - // - TemBuffer = Src + StorageWidth - 1; - TemString = Value; - for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) { - TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2); - } - } + Value = ConfigResp + StrLen (ConfigResp); + if (!IsBufferStorage && IsString) { // - // Convert to lower char. + // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044" // - for (TemString = Value; *Value != L'\0'; Value++) { - if (*Value >= L'A' && *Value <= L'Z') { - *Value = (CHAR16) (*Value - L'A' + L'a'); - } + TemName = (CHAR16 *) Src; + TemString = Value; + for (; *TemName != L'\0'; TemName++) { + TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4); } - + } else { // - // Submit Question Value to Configuration Driver + // Convert Buffer to Hex String // - if (FormSet->ConfigAccess != NULL) { - Status = FormSet->ConfigAccess->RouteConfig ( - FormSet->ConfigAccess, - ConfigResp, - &Progress - ); - if (EFI_ERROR (Status)) { - FreePool (ConfigResp); - return Status; - } - } - FreePool (ConfigResp); - - } else if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) { - TemBuffer = NULL; - TemBuffer = AllocateZeroPool(Storage->Size); - if (TemBuffer == NULL) { - Status = EFI_OUT_OF_RESOURCES; - return Status; + TemBuffer = Src + StorageWidth - 1; + TemString = Value; + for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) { + TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2); } - Length = Storage->Size; - Status = gRT->GetVariable ( - Storage->Name, - &Storage->Guid, - NULL, - &Length, - TemBuffer - ); - - CopyMem (TemBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth); - - Status = gRT->SetVariable ( - Storage->Name, - &Storage->Guid, - Storage->Attributes, - Storage->Size, - TemBuffer - ); - FreePool (TemBuffer); - if (EFI_ERROR (Status)){ - return Status; + } + + // + // Convert to lower char. + // + for (TemString = Value; *Value != L'\0'; Value++) { + if (*Value >= L'A' && *Value <= L'Z') { + *Value = (CHAR16) (*Value - L'A' + L'a'); } } + + // + // Submit Question Value to Configuration Driver + // + Status = mHiiConfigRouting->RouteConfig ( + mHiiConfigRouting, + ConfigResp, + &Progress + ); + if (EFI_ERROR (Status)) { + FreePool (ConfigResp); + return Status; + } + FreePool (ConfigResp); + // // Sync storage, from editbuffer to buffer. // @@ -2201,6 +2128,10 @@ SendDiscardInfoToDriver ( EFI_IFR_TYPE_VALUE *TypeValue; EFI_BROWSER_ACTION_REQUEST ActionRequest; + if (FormSet->ConfigAccess == NULL) { + return; + } + Link = GetFirstNode (&Form->StatementListHead); while (!IsNull (&Form->StatementListHead, Link)) { Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link); @@ -2376,7 +2307,8 @@ DiscardForm ( LIST_ENTRY *Link; FORMSET_STORAGE *Storage; FORM_BROWSER_CONFIG_REQUEST *ConfigInfo; - FORM_BROWSER_FORMSET *LocalFormSet; + FORM_BROWSER_FORMSET *LocalFormSet; + FORM_BROWSER_FORMSET *OldFormSet; // // Check the supported setting level. @@ -2455,7 +2387,8 @@ DiscardForm ( // // System Level Discard. // - + OldFormSet = mSystemLevelFormSet; + // // Discard changed value for each FormSet in the maintain list. // @@ -2466,6 +2399,9 @@ DiscardForm ( if (!ValidateFormSet(LocalFormSet)) { continue; } + + mSystemLevelFormSet = LocalFormSet; + DiscardForm (LocalFormSet, NULL, FormSetLevel); if (!IsHiiHandleInBrowserContext (LocalFormSet->HiiHandle)) { // @@ -2476,6 +2412,8 @@ DiscardForm ( DestroyFormSet (LocalFormSet); } } + + mSystemLevelFormSet = OldFormSet; } return EFI_SUCCESS; @@ -2505,8 +2443,6 @@ SubmitForm ( EFI_STRING Progress; BROWSER_STORAGE *Storage; FORMSET_STORAGE *FormSetStorage; - UINTN BufferSize; - UINT8 *TmpBuf; FORM_BROWSER_FORMSET *LocalFormSet; FORM_BROWSER_CONFIG_REQUEST *ConfigInfo; @@ -2558,72 +2494,18 @@ SubmitForm ( } // - // 2. Set value to hii driver or efi variable. + // 2. Set value to hii config routine protocol. // - if (Storage->Type == EFI_HII_VARSTORE_BUFFER || - Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) { - // - // Send to Configuration Driver - // - if (FormSet->ConfigAccess != NULL) { - Status = FormSet->ConfigAccess->RouteConfig ( - FormSet->ConfigAccess, - ConfigResp, - &Progress - ); - if (EFI_ERROR (Status)) { - FreePool (ConfigResp); - return Status; - } - } - } else if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) { - TmpBuf = NULL; - TmpBuf = AllocateZeroPool(Storage->Size); - if (TmpBuf == NULL) { - Status = EFI_OUT_OF_RESOURCES; - return Status; - } - - BufferSize = Storage->Size; - Status = gRT->GetVariable ( - Storage->Name, - &Storage->Guid, - NULL, - &BufferSize, - TmpBuf - ); - if (EFI_ERROR (Status)) { - FreePool (TmpBuf); - FreePool (ConfigResp); - return Status; - } - ASSERT (BufferSize == Storage->Size); - Status = mHiiConfigRouting->ConfigToBlock ( - mHiiConfigRouting, - ConfigResp, - TmpBuf, - &BufferSize, - &Progress - ); - if (EFI_ERROR (Status)) { - FreePool (TmpBuf); - FreePool (ConfigResp); - return Status; - } - - Status = gRT->SetVariable ( - Storage->Name, - &Storage->Guid, - Storage->Attributes, - Storage->Size, - TmpBuf - ); - FreePool (TmpBuf); - if (EFI_ERROR (Status)) { - FreePool (ConfigResp); - return Status; - } + Status = mHiiConfigRouting->RouteConfig ( + mHiiConfigRouting, + ConfigResp, + &Progress + ); + if (EFI_ERROR (Status)) { + FreePool (ConfigResp); + return Status; } + FreePool (ConfigResp); // // 3. Config success, update storage shadow Buffer, only update the data belong to this form. @@ -2664,69 +2546,19 @@ SubmitForm ( return Status; } - if (Storage->Type == EFI_HII_VARSTORE_BUFFER || - Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) { - - // - // 2. Send to Configuration Driver - // - if (FormSet->ConfigAccess != NULL) { - Status = FormSet->ConfigAccess->RouteConfig ( - FormSet->ConfigAccess, - ConfigResp, - &Progress - ); - if (EFI_ERROR (Status)) { - FreePool (ConfigResp); - return Status; - } - } - } else if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) { - // - // 1&2. Set the edit data to the variable. - // - TmpBuf = NULL; - TmpBuf = AllocateZeroPool (Storage->Size); - if (TmpBuf == NULL) { - Status = EFI_OUT_OF_RESOURCES; - return Status; - } - BufferSize = Storage->Size; - Status = gRT->GetVariable ( - Storage->Name, - &Storage->Guid, - NULL, - &BufferSize, - TmpBuf - ); - ASSERT (BufferSize == Storage->Size); - Status = mHiiConfigRouting->ConfigToBlock ( - mHiiConfigRouting, - ConfigResp, - TmpBuf, - &BufferSize, - &Progress - ); - if (EFI_ERROR (Status)) { - FreePool (TmpBuf); - FreePool (ConfigResp); - return Status; - } - - Status = gRT->SetVariable ( - Storage->Name, - &Storage->Guid, - Storage->Attributes, - Storage->Size, - TmpBuf - ); - if (EFI_ERROR (Status)) { - FreePool (TmpBuf); - FreePool (ConfigResp); - return Status; - } - FreePool (TmpBuf); + // + // 2. Send to Routine config Protocol. + // + Status = mHiiConfigRouting->RouteConfig ( + mHiiConfigRouting, + ConfigResp, + &Progress + ); + if (EFI_ERROR (Status)) { + FreePool (ConfigResp); + return Status; } + FreePool (ConfigResp); // // 3. Config success, update storage shadow Buffer @@ -2811,9 +2643,7 @@ GetDefaultValueFromAltCfg ( Value = NULL; Storage = Question->Storage; - if ((Storage == NULL) || - (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) || - (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) { + if ((Storage == NULL) || (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE)) { return Status; } @@ -2832,7 +2662,11 @@ GetDefaultValueFromAltCfg ( Dst = (UINT8 *) &Question->HiiValue.Value; } - IsBufferStorage = (BOOLEAN) ((Storage->Type == EFI_HII_VARSTORE_BUFFER) ? TRUE : FALSE); + if (Storage->Type == EFI_HII_VARSTORE_BUFFER || Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) { + IsBufferStorage = TRUE; + } else { + IsBufferStorage = FALSE; + } IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE); // @@ -2857,8 +2691,8 @@ GetDefaultValueFromAltCfg ( StrCat (ConfigRequest, Question->VariableName); } - Status = FormSet->ConfigAccess->ExtractConfig ( - FormSet->ConfigAccess, + Status = mHiiConfigRouting->ExtractConfig ( + mHiiConfigRouting, ConfigRequest, &Progress, &Result @@ -2888,6 +2722,11 @@ GetDefaultValueFromAltCfg ( goto Done; } + if (ConfigResp == NULL) { + Status = EFI_NOT_FOUND; + goto Done; + } + // // Skip // @@ -3154,6 +2993,7 @@ GetQuestionDefault ( EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; EFI_BROWSER_ACTION_REQUEST ActionRequest; INTN Action; + CHAR16 *NewString; Status = EFI_NOT_FOUND; StrValue = NULL; @@ -3191,6 +3031,19 @@ GetQuestionDefault ( &ActionRequest ); if (!EFI_ERROR (Status)) { + if (HiiValue->Type == EFI_IFR_TYPE_STRING) { + NewString = GetToken (Question->HiiValue.Value.string, FormSet->HiiHandle); + ASSERT (NewString != NULL); + + ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth); + if (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth) { + CopyMem (Question->BufferValue, NewString, StrSize (NewString)); + } else { + CopyMem (Question->BufferValue, NewString, Question->StorageWidth); + } + + FreePool (NewString); + } return Status; } } @@ -3417,6 +3270,7 @@ ExtractDefault ( LIST_ENTRY *Link; FORM_BROWSER_STATEMENT *Question; FORM_BROWSER_FORMSET *LocalFormSet; + FORM_BROWSER_FORMSET *OldFormSet; Status = EFI_SUCCESS; @@ -3467,7 +3321,7 @@ ExtractDefault ( // // Call the Retrieve call back to get the initial question value. // - Status = ProcessRetrieveForQuestion(FormSet->ConfigAccess, Question); + Status = ProcessRetrieveForQuestion(FormSet->ConfigAccess, Question, FormSet); } // @@ -3500,7 +3354,9 @@ ExtractDefault ( // Preload all Hii formset. // LoadAllHiiFormset(); - + + OldFormSet = mSystemLevelFormSet; + // // Set Default Value for each FormSet in the maintain list. // @@ -3511,8 +3367,13 @@ ExtractDefault ( if (!ValidateFormSet(LocalFormSet)) { continue; } + + mSystemLevelFormSet = LocalFormSet; + ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage, RetrieveValueFirst); } + + mSystemLevelFormSet = OldFormSet; } return EFI_SUCCESS; @@ -3590,6 +3451,8 @@ IsQuestionValueChanged ( FreePool (BackUpBuffer); } + Question->ValueChanged = ValueChanged; + return ValueChanged; } @@ -3643,7 +3506,8 @@ LoadFormConfig ( // Call the Retrieve call back function for all questions. // if ((FormSet->ConfigAccess != NULL) && (Selection != NULL) && - ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK)) { + ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK) && + !gFinishRetrieveCall) { // // Check QuestionValue does exist. // @@ -3667,14 +3531,9 @@ LoadFormConfig ( ); } - Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE); + Status = ProcessCallBackFunction(Selection, FormSet, Form, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE); } - // - // Update Question Value changed flag. - // - Question->ValueChanged = IsQuestionValueChanged(FormSet, Form, Question, GetSetValueWithBuffer); - Link = GetNextNode (&Form->StatementListHead, Link); } @@ -3858,25 +3717,26 @@ CleanBrowserStorage ( { LIST_ENTRY *Link; FORMSET_STORAGE *Storage; - CHAR16 *ConfigRequest; Link = GetFirstNode (&FormSet->StorageListHead); while (!IsNull (&FormSet->StorageListHead, Link)) { Storage = FORMSET_STORAGE_FROM_LINK (Link); Link = GetNextNode (&FormSet->StorageListHead, Link); - if ((Storage->BrowserStorage->Type != EFI_HII_VARSTORE_BUFFER) && - (Storage->BrowserStorage->Type != EFI_HII_VARSTORE_NAME_VALUE) && - (Storage->BrowserStorage->Type != EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) { - continue; - } + if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) { + if (Storage->ConfigRequest == NULL || Storage->BrowserStorage->ConfigRequest == NULL) { + continue; + } - if (Storage->ConfigRequest == NULL || Storage->BrowserStorage->ConfigRequest == NULL) { - continue; + RemoveConfigRequest (Storage->BrowserStorage, Storage->ConfigRequest); + } else if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER || + Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) { + if (Storage->BrowserStorage->ConfigRequest != NULL) { + FreePool (Storage->BrowserStorage->ConfigRequest); + Storage->BrowserStorage->ConfigRequest = NULL; + } + Storage->BrowserStorage->Initialized = FALSE; } - - ConfigRequest = FormSet->QuestionInited ? Storage->ConfigRequest : Storage->ConfigElements; - RemoveConfigRequest (Storage->BrowserStorage, ConfigRequest); } } @@ -3947,6 +3807,8 @@ AppendConfigRequest ( Adjust the config request info, remove the request elements which already in AllConfigRequest string. @param Storage Form set Storage. + @param Request The input request string. + @param RespString Whether the input is ConfigRequest or ConfigResp format. @retval TRUE Has element not covered by current used elements, need to continue to call ExtractConfig @retval FALSE All elements covered by current used elements. @@ -3954,30 +3816,37 @@ AppendConfigRequest ( **/ BOOLEAN ConfigRequestAdjust ( - IN FORMSET_STORAGE *Storage + IN BROWSER_STORAGE *Storage, + IN CHAR16 *Request, + IN BOOLEAN RespString ) { CHAR16 *RequestElement; CHAR16 *NextRequestElement; - CHAR16 *RetBuf; + CHAR16 *NextElementBakup; UINTN SpareBufLen; CHAR16 *SearchKey; + CHAR16 *ValueKey; BOOLEAN RetVal; + CHAR16 *ConfigRequest; SpareBufLen = 0; - RetBuf = NULL; RetVal = FALSE; + NextElementBakup = NULL; + ValueKey = NULL; - if (Storage->BrowserStorage->ConfigRequest == NULL) { - Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest); - if (Storage->ConfigElements != NULL) { - FreePool (Storage->ConfigElements); - } - Storage->ConfigElements = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest); + if (Request != NULL) { + ConfigRequest = Request; + } else { + ConfigRequest = Storage->ConfigRequest; + } + + if (Storage->ConfigRequest == NULL) { + Storage->ConfigRequest = AllocateCopyPool (StrSize (ConfigRequest), ConfigRequest); return TRUE; } - if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) { + if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) { // // "&Name1&Name2" section for EFI_HII_VARSTORE_NAME_VALUE storage // @@ -3987,26 +3856,22 @@ ConfigRequestAdjust ( // "&OFFSET=####&WIDTH=####" section for EFI_HII_VARSTORE_BUFFER storage // SearchKey = L"&OFFSET"; + ValueKey = L"&VALUE"; } - // - // Prepare the config header. - // - RetBuf = AllocateCopyPool(StrSize (Storage->BrowserStorage->ConfigHdr), Storage->BrowserStorage->ConfigHdr); - ASSERT (RetBuf != NULL); - // // Find SearchKey storage // - if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) { - RequestElement = StrStr (Storage->ConfigRequest, L"PATH"); + if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) { + RequestElement = StrStr (ConfigRequest, L"PATH"); ASSERT (RequestElement != NULL); RequestElement = StrStr (RequestElement, SearchKey); } else { - RequestElement = StrStr (Storage->ConfigRequest, SearchKey); + RequestElement = StrStr (ConfigRequest, SearchKey); } while (RequestElement != NULL) { + // // +1 to avoid find header itself. // @@ -4016,18 +3881,32 @@ ConfigRequestAdjust ( // The last Request element in configRequest string. // if (NextRequestElement != NULL) { + if (RespString && (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) { + NextElementBakup = NextRequestElement; + NextRequestElement = StrStr (RequestElement, ValueKey); + ASSERT (NextRequestElement != NULL); + } // // Replace "&" with '\0'. // *NextRequestElement = L'\0'; + } else { + if (RespString && (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) { + NextElementBakup = NextRequestElement; + NextRequestElement = StrStr (RequestElement, ValueKey); + ASSERT (NextRequestElement != NULL); + // + // Replace "&" with '\0'. + // + *NextRequestElement = L'\0'; + } } - if (!ElementValidation (Storage->BrowserStorage, RequestElement)) { + if (!ElementValidation (Storage, RequestElement)) { // // Add this element to the Storage->BrowserStorage->AllRequestElement. // - AppendConfigRequest(&Storage->BrowserStorage->ConfigRequest, &Storage->BrowserStorage->SpareStrLen, RequestElement); - AppendConfigRequest (&RetBuf, &SpareBufLen, RequestElement); + AppendConfigRequest(&Storage->ConfigRequest, &Storage->SpareStrLen, RequestElement); RetVal = TRUE; } @@ -4038,16 +3917,11 @@ ConfigRequestAdjust ( *NextRequestElement = L'&'; } - RequestElement = NextRequestElement; - } - - if (RetVal) { - if (Storage->ConfigElements != NULL) { - FreePool (Storage->ConfigElements); + if (RespString && (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) { + RequestElement = NextElementBakup; + } else { + RequestElement = NextRequestElement; } - Storage->ConfigElements = RetBuf; - } else { - FreePool (RetBuf); } return RetVal; @@ -4219,95 +4093,192 @@ LoadStorage ( EFI_STRING Progress; EFI_STRING Result; CHAR16 *StrPtr; + EFI_STRING ConfigRequest; + UINTN StrLen; + + ConfigRequest = NULL; switch (Storage->BrowserStorage->Type) { case EFI_HII_VARSTORE_EFI_VARIABLE: return; case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER: - if (Storage->BrowserStorage->ReferenceCount > 1) { - ConfigRequestAdjust(Storage); + if (Storage->BrowserStorage->ConfigRequest != NULL) { + ConfigRequestAdjust(Storage->BrowserStorage, Storage->ConfigRequest, FALSE); return; } - - Status = gRT->GetVariable ( - Storage->BrowserStorage->Name, - &Storage->BrowserStorage->Guid, - NULL, - (UINTN*)&Storage->BrowserStorage->Size, - Storage->BrowserStorage->EditBuffer - ); - // - // If get variable fail, extract default from IFR binary - // - if (EFI_ERROR (Status)) { - ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage->BrowserStorage, TRUE); - } - - Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest); - // - // Input NULL for ConfigRequest field means sync all fields from editbuffer to buffer. - // - SynchronizeStorage(FormSet, Storage->BrowserStorage, NULL, TRUE); break; case EFI_HII_VARSTORE_BUFFER: case EFI_HII_VARSTORE_NAME_VALUE: // - // Skip if there is no RequestElement + // Skip if there is no RequestElement. // if (Storage->ElementCount == 0) { return; } // - // Adjust the ConfigRequest string, only the field not saved in BrowserStorage->AllConfig - // will used to call ExtractConfig. - // If not elements need to udpate, return. + // Just update the ConfigRequest, if storage already initialized. // - if (!ConfigRequestAdjust(Storage)) { + if (Storage->BrowserStorage->Initialized) { + ConfigRequestAdjust(Storage->BrowserStorage, Storage->ConfigRequest, FALSE); return; } - ASSERT (Storage->ConfigElements != NULL); - Status = EFI_NOT_FOUND; - if (FormSet->ConfigAccess != NULL) { - // - // Request current settings from Configuration Driver - // - Status = FormSet->ConfigAccess->ExtractConfig ( - FormSet->ConfigAccess, - Storage->ConfigElements, - &Progress, - &Result - ); - - if (!EFI_ERROR (Status)) { - // - // Convert Result from to - // - StrPtr = StrStr (Result, L"&GUID="); - if (StrPtr != NULL) { - *StrPtr = L'\0'; - } - - Status = ConfigRespToStorage (Storage->BrowserStorage, Result); - FreePool (Result); - } - } + Storage->BrowserStorage->Initialized = TRUE; + break; - if (EFI_ERROR (Status)) { - // - // Base on the configRequest string to get default value. - // - GetDefaultForFormset (FormSet, Storage->BrowserStorage, Storage->ConfigElements); + default: + return; + } + + if (Storage->BrowserStorage->Type != EFI_HII_VARSTORE_NAME_VALUE) { + // + // Create the config request string to get all fields for this storage. + // Allocate and fill a buffer large enough to hold the template + // followed by "&OFFSET=0&WIDTH=WWWW"followed by a Null-terminator + // + StrLen = StrSize (Storage->BrowserStorage->ConfigHdr) + 20 * sizeof (CHAR16); + ConfigRequest = AllocateZeroPool (StrLen); + ASSERT (ConfigRequest != NULL); + UnicodeSPrint ( + ConfigRequest, + StrLen, + L"%s&OFFSET=0&WIDTH=%04x", + Storage->BrowserStorage->ConfigHdr, + Storage->BrowserStorage->Size); + } else { + ConfigRequest = Storage->ConfigRequest; + } + + // + // Request current settings from Configuration Driver + // + Status = mHiiConfigRouting->ExtractConfig ( + mHiiConfigRouting, + ConfigRequest, + &Progress, + &Result + ); + + // + // If get value fail, extract default from IFR binary + // + if (EFI_ERROR (Status)) { + ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage->BrowserStorage, TRUE); + } else { + // + // Convert Result from to + // + StrPtr = StrStr (Result, L"&GUID="); + if (StrPtr != NULL) { + *StrPtr = L'\0'; + } + + Status = ConfigRespToStorage (Storage->BrowserStorage, Result); + FreePool (Result); + } + + Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest); + + // + // Input NULL for ConfigRequest field means sync all fields from editbuffer to buffer. + // + SynchronizeStorage(FormSet, Storage->BrowserStorage, NULL, TRUE); + + if (Storage->BrowserStorage->Type != EFI_HII_VARSTORE_NAME_VALUE) { + if (ConfigRequest != NULL) { + FreePool (ConfigRequest); + } + } +} + +/** + Get Value changed status from old question. + + @param NewFormSet FormSet data structure. + @param OldQuestion Old question which has value changed. + +**/ +VOID +SyncStatusForQuestion ( + IN OUT FORM_BROWSER_FORMSET *NewFormSet, + IN FORM_BROWSER_STATEMENT *OldQuestion + ) +{ + LIST_ENTRY *Link; + LIST_ENTRY *QuestionLink; + FORM_BROWSER_FORM *Form; + FORM_BROWSER_STATEMENT *Question; + + // + // For each form in one formset. + // + Link = GetFirstNode (&NewFormSet->FormListHead); + while (!IsNull (&NewFormSet->FormListHead, Link)) { + Form = FORM_BROWSER_FORM_FROM_LINK (Link); + Link = GetNextNode (&NewFormSet->FormListHead, Link); + + // + // for each question in one form. + // + QuestionLink = GetFirstNode (&Form->StatementListHead); + while (!IsNull (&Form->StatementListHead, QuestionLink)) { + Question = FORM_BROWSER_STATEMENT_FROM_LINK (QuestionLink); + QuestionLink = GetNextNode (&Form->StatementListHead, QuestionLink); + + if (Question->QuestionId == OldQuestion->QuestionId) { + Question->ValueChanged = TRUE; + return; } + } + } +} - SynchronizeStorage(FormSet, Storage->BrowserStorage, Storage->ConfigElements, TRUE); - break; +/** + Get Value changed status from old formset. - default: - break; + @param NewFormSet FormSet data structure. + @param OldFormSet FormSet data structure. + +**/ +VOID +SyncStatusForFormSet ( + IN OUT FORM_BROWSER_FORMSET *NewFormSet, + IN FORM_BROWSER_FORMSET *OldFormSet + ) +{ + LIST_ENTRY *Link; + LIST_ENTRY *QuestionLink; + FORM_BROWSER_FORM *Form; + FORM_BROWSER_STATEMENT *Question; + + // + // For each form in one formset. + // + Link = GetFirstNode (&OldFormSet->FormListHead); + while (!IsNull (&OldFormSet->FormListHead, Link)) { + Form = FORM_BROWSER_FORM_FROM_LINK (Link); + Link = GetNextNode (&OldFormSet->FormListHead, Link); + + // + // for each question in one form. + // + QuestionLink = GetFirstNode (&Form->StatementListHead); + while (!IsNull (&Form->StatementListHead, QuestionLink)) { + Question = FORM_BROWSER_STATEMENT_FROM_LINK (QuestionLink); + QuestionLink = GetNextNode (&Form->StatementListHead, QuestionLink); + + if (!Question->ValueChanged) { + continue; + } + + // + // Find the same question in new formset and update the value changed flag. + // + SyncStatusForQuestion (NewFormSet, Question); + } } } @@ -4326,6 +4297,18 @@ InitializeCurrentSetting ( FORMSET_STORAGE *Storage; FORM_BROWSER_FORMSET *OldFormSet; + // + // Try to find pre FormSet in the maintain backup list. + // If old formset != NULL, destroy this formset. Add new formset to gBrowserFormSetList. + // + OldFormSet = GetFormSetFromHiiHandle (FormSet->HiiHandle); + if (OldFormSet != NULL) { + SyncStatusForFormSet (FormSet, OldFormSet); + RemoveEntryList (&OldFormSet->Link); + DestroyFormSet (OldFormSet); + } + InsertTailList (&gBrowserFormSetList, &FormSet->Link); + // // Extract default from IFR binary for no storage questions. // @@ -4342,17 +4325,6 @@ InitializeCurrentSetting ( Link = GetNextNode (&FormSet->StorageListHead, Link); } - - // - // Try to find pre FormSet in the maintain backup list. - // If old formset != NULL, destroy this formset. Add new formset to gBrowserFormSetList. - // - OldFormSet = GetFormSetFromHiiHandle (FormSet->HiiHandle); - if (OldFormSet != NULL) { - RemoveEntryList (&OldFormSet->Link); - DestroyFormSet (OldFormSet); - } - InsertTailList (&gBrowserFormSetList, &FormSet->Link); } @@ -4612,11 +4584,6 @@ SaveBrowserContext ( return; } - // - // Not support SendForm nest in another SendForm, assert here. - // - ASSERT (FALSE); - Context = AllocatePool (sizeof (BROWSER_CONTEXT)); ASSERT (Context != NULL); @@ -4625,9 +4592,12 @@ SaveBrowserContext ( // // Save FormBrowser context // + Context->Selection = gCurrentSelection; Context->ResetRequired = gResetRequired; Context->ExitRequired = gExitRequired; Context->HiiHandle = mCurrentHiiHandle; + Context->FormId = mCurrentFormId; + CopyGuid (&Context->FormSetGuid, &mCurrentFormSetGuid); // // Save the menu history data. @@ -4677,9 +4647,12 @@ RestoreBrowserContext ( // // Restore FormBrowser context // + gCurrentSelection = Context->Selection; gResetRequired = Context->ResetRequired; gExitRequired = Context->ExitRequired; mCurrentHiiHandle = Context->HiiHandle; + mCurrentFormId = Context->FormId; + CopyGuid (&mCurrentFormSetGuid, &Context->FormSetGuid); // // Restore the menu history data. @@ -4809,7 +4782,21 @@ PasswordCheck ( if (PasswordString == NULL) { return EFI_SUCCESS; } - + + // + // Check whether has preexisted password. + // + if (PasswordString[0] == 0) { + if (*((CHAR16 *) Question->BufferValue) == 0) { + return EFI_SUCCESS; + } else { + return EFI_NOT_READY; + } + } + + // + // Check whether the input password is same as preexisted password. + // if (StrnCmp (PasswordString, (CHAR16 *) Question->BufferValue, Question->StorageWidth/sizeof (CHAR16)) == 0) { return EFI_SUCCESS; } else { @@ -5038,21 +5025,27 @@ IsBrowserDataModified ( LIST_ENTRY *Link; FORM_BROWSER_FORMSET *FormSet; - if (gCurrentSelection == NULL) { - return FALSE; - } - switch (gBrowserSettingScope) { case FormLevel: + if (gCurrentSelection == NULL) { + return FALSE; + } return IsNvUpdateRequiredForForm (gCurrentSelection->Form); case FormSetLevel: + if (gCurrentSelection == NULL) { + return FALSE; + } return IsNvUpdateRequiredForFormSet (gCurrentSelection->FormSet); case SystemLevel: Link = GetFirstNode (&gBrowserFormSetList); while (!IsNull (&gBrowserFormSetList, Link)) { FormSet = FORM_BROWSER_FORMSET_FROM_LINK (Link); + if (!ValidateFormSet(FormSet)) { + continue; + } + if (IsNvUpdateRequiredForFormSet (FormSet)) { return TRUE; } @@ -5082,19 +5075,27 @@ ExecuteAction ( IN UINT16 DefaultId ) { - EFI_STATUS Status; + EFI_STATUS Status; + FORM_BROWSER_FORMSET *FormSet; + FORM_BROWSER_FORM *Form; - if (gCurrentSelection == NULL) { + if (gBrowserSettingScope < SystemLevel && gCurrentSelection == NULL) { return EFI_NOT_READY; } - Status = EFI_SUCCESS; + Status = EFI_SUCCESS; + FormSet = NULL; + Form = NULL; + if (gBrowserSettingScope < SystemLevel) { + FormSet = gCurrentSelection->FormSet; + Form = gCurrentSelection->Form; + } // // Executet the discard action. // if ((Action & BROWSER_ACTION_DISCARD) != 0) { - Status = DiscardForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope); + Status = DiscardForm (FormSet, Form, gBrowserSettingScope); if (EFI_ERROR (Status)) { return Status; } @@ -5104,17 +5105,18 @@ ExecuteAction ( // Executet the difault action. // if ((Action & BROWSER_ACTION_DEFAULT) != 0) { - Status = ExtractDefault (gCurrentSelection->FormSet, gCurrentSelection->Form, DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL, FALSE); + Status = ExtractDefault (FormSet, Form, DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL, FALSE); if (EFI_ERROR (Status)) { return Status; } + UpdateStatementStatus (FormSet, Form, gBrowserSettingScope); } // // Executet the submit action. // if ((Action & BROWSER_ACTION_SUBMIT) != 0) { - Status = SubmitForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope); + Status = SubmitForm (FormSet, Form, gBrowserSettingScope); if (EFI_ERROR (Status)) { return Status; } @@ -5131,7 +5133,7 @@ ExecuteAction ( // Executet the exit action. // if ((Action & BROWSER_ACTION_EXIT) != 0) { - DiscardForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope); + DiscardForm (FormSet, Form, gBrowserSettingScope); if (gBrowserSettingScope == SystemLevel) { if (ExitHandlerFunction != NULL) { ExitHandlerFunction (); @@ -5151,6 +5153,7 @@ ExecuteAction ( @retval BROWSER_NO_CHANGES No browser data is changed. @retval BROWSER_SAVE_CHANGES The changed browser data is saved. @retval BROWSER_DISCARD_CHANGES The changed browser data is discard. + @retval BROWSER_KEEP_CURRENT Browser keep current changes. **/ UINT32 @@ -5163,6 +5166,7 @@ SaveReminder ( FORM_BROWSER_FORMSET *FormSet; BOOLEAN IsDataChanged; UINT32 DataSavedAction; + UINT32 ConfirmRet; DataSavedAction = BROWSER_NO_CHANGES; IsDataChanged = FALSE; @@ -5190,13 +5194,18 @@ SaveReminder ( // If data is changed, prompt user to save or discard it. // do { - DataSavedAction = (UINT32) mFormDisplay->ConfirmDataChange(); + ConfirmRet = (UINT32) mFormDisplay->ConfirmDataChange(); - if (DataSavedAction == BROWSER_SAVE_CHANGES) { + if (ConfirmRet == BROWSER_ACTION_SUBMIT) { SubmitForm (NULL, NULL, SystemLevel); + DataSavedAction = BROWSER_SAVE_CHANGES; break; - } else if (DataSavedAction == BROWSER_DISCARD_CHANGES) { + } else if (ConfirmRet == BROWSER_ACTION_DISCARD) { DiscardForm (NULL, NULL, SystemLevel); + DataSavedAction = BROWSER_DISCARD_CHANGES; + break; + } else if (ConfirmRet == BROWSER_ACTION_NONE) { + DataSavedAction = BROWSER_KEEP_CURRENT; break; } } while (1);