X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FSetupBrowserDxe%2FSetup.c;h=c7c7f9ae43eb780aede99081c6d567d51693f717;hb=6307a8b6dc054339db3b3d9733f2ce1a248b483c;hp=ba72d1220b594cb1857ed9bba97eee0ee1079a52;hpb=5a9f73bf065eda6b830445dc907e778f4a13d8d7;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index ba72d1220b..c7c7f9ae43 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -48,11 +48,13 @@ LIST_ENTRY gBrowserFormSetList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserFor LIST_ENTRY gBrowserHotKeyList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserHotKeyList); 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 @@ -255,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 @@ -278,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)) { @@ -300,6 +310,9 @@ LoadAllHiiFormset ( // Free resources, and restore gOldFormSet and gClassOfVfr // FreePool (HiiHandles); + + gFinishRetrieveCall = OldRetrieveValue; + mSystemLevelFormSet = OldFormset; } /** @@ -357,6 +370,7 @@ SendForm ( // SaveBrowserContext (); + gFinishRetrieveCall = FALSE; gResetRequired = FALSE; gExitRequired = FALSE; Status = EFI_SUCCESS; @@ -388,6 +402,7 @@ SendForm ( break; } Selection->FormSet = FormSet; + mSystemLevelFormSet = FormSet; // // Display this formset @@ -397,6 +412,7 @@ SendForm ( Status = SetupBrowser (Selection); gCurrentSelection = NULL; + mSystemLevelFormSet = NULL; // // If no data is changed, don't need to save current FormSet into the maintain list. @@ -580,7 +596,6 @@ BrowserCallback ( LIST_ENTRY *Link; BROWSER_STORAGE *Storage; FORMSET_STORAGE *FormsetStorage; - FORM_BROWSER_FORMSET *FormSet; UINTN TotalSize; BOOLEAN Found; @@ -630,6 +645,17 @@ 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; @@ -650,16 +676,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; } @@ -766,7 +791,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, @@ -1244,7 +1270,6 @@ GetQuestionValue ( BOOLEAN IsString; CHAR16 TemStr[5]; UINT8 DigitUint8; - UINT8 *TemBuffer; Status = EFI_SUCCESS; Value = NULL; @@ -1254,13 +1279,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 // @@ -1468,147 +1486,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; } // @@ -1676,13 +1665,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 // @@ -1859,111 +1841,78 @@ SetQuestionValue ( } } } 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); + // + // ::= + + "&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"="); - } + 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 = ConfigResp + StrLen (ConfigResp); - - 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. // @@ -2374,7 +2323,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. @@ -2453,7 +2403,8 @@ DiscardForm ( // // System Level Discard. // - + OldFormSet = mSystemLevelFormSet; + // // Discard changed value for each FormSet in the maintain list. // @@ -2464,6 +2415,9 @@ DiscardForm ( if (!ValidateFormSet(LocalFormSet)) { continue; } + + mSystemLevelFormSet = LocalFormSet; + DiscardForm (LocalFormSet, NULL, FormSetLevel); if (!IsHiiHandleInBrowserContext (LocalFormSet->HiiHandle)) { // @@ -2474,6 +2428,8 @@ DiscardForm ( DestroyFormSet (LocalFormSet); } } + + mSystemLevelFormSet = OldFormSet; } return EFI_SUCCESS; @@ -2503,8 +2459,6 @@ SubmitForm ( EFI_STRING Progress; BROWSER_STORAGE *Storage; FORMSET_STORAGE *FormSetStorage; - UINTN BufferSize; - UINT8 *TmpBuf; FORM_BROWSER_FORMSET *LocalFormSet; FORM_BROWSER_CONFIG_REQUEST *ConfigInfo; @@ -2556,72 +2510,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. @@ -2662,69 +2562,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 @@ -2809,9 +2659,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; } @@ -2830,7 +2678,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); // @@ -2855,8 +2707,8 @@ GetDefaultValueFromAltCfg ( StrCat (ConfigRequest, Question->VariableName); } - Status = FormSet->ConfigAccess->ExtractConfig ( - FormSet->ConfigAccess, + Status = mHiiConfigRouting->ExtractConfig ( + mHiiConfigRouting, ConfigRequest, &Progress, &Result @@ -2886,6 +2738,11 @@ GetDefaultValueFromAltCfg ( goto Done; } + if (ConfigResp == NULL) { + Status = EFI_NOT_FOUND; + goto Done; + } + // // Skip // @@ -3415,6 +3272,7 @@ ExtractDefault ( LIST_ENTRY *Link; FORM_BROWSER_STATEMENT *Question; FORM_BROWSER_FORMSET *LocalFormSet; + FORM_BROWSER_FORMSET *OldFormSet; Status = EFI_SUCCESS; @@ -3498,7 +3356,9 @@ ExtractDefault ( // Preload all Hii formset. // LoadAllHiiFormset(); - + + OldFormSet = mSystemLevelFormSet; + // // Set Default Value for each FormSet in the maintain list. // @@ -3509,8 +3369,13 @@ ExtractDefault ( if (!ValidateFormSet(LocalFormSet)) { continue; } + + mSystemLevelFormSet = LocalFormSet; + ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage, RetrieveValueFirst); } + + mSystemLevelFormSet = OldFormSet; } return EFI_SUCCESS; @@ -3641,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. // @@ -3665,7 +3531,7 @@ LoadFormConfig ( ); } - Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE); + Status = ProcessCallBackFunction(Selection, FormSet, Form, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE); } // @@ -3863,18 +3729,20 @@ CleanBrowserStorage ( 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; + ConfigRequest = FormSet->QuestionInited ? Storage->ConfigRequest : Storage->ConfigElements; + RemoveConfigRequest (Storage->BrowserStorage, 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->Initialized = FALSE; } - - ConfigRequest = FormSet->QuestionInited ? Storage->ConfigRequest : Storage->ConfigElements; - RemoveConfigRequest (Storage->BrowserStorage, ConfigRequest); } } @@ -4217,95 +4085,92 @@ 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) { + if (Storage->BrowserStorage->ConfigRequest != NULL) { ConfigRequestAdjust(Storage); 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); + // 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 // - // Input NULL for ConfigRequest field means sync all fields from editbuffer to buffer. - // - SynchronizeStorage(FormSet, Storage->BrowserStorage, NULL, TRUE); + 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); break; case EFI_HII_VARSTORE_BUFFER: case EFI_HII_VARSTORE_NAME_VALUE: // - // Skip if there is no RequestElement + // Skip if there is no RequestElement or data has initilized. // - if (Storage->ElementCount == 0) { + if (Storage->ElementCount == 0 || Storage->BrowserStorage->Initialized) { return; } + Storage->BrowserStorage->Initialized = TRUE; + ConfigRequest = Storage->ConfigRequest; + break; - // - // Adjust the ConfigRequest string, only the field not saved in BrowserStorage->AllConfig - // will used to call ExtractConfig. - // If not elements need to udpate, return. - // - if (!ConfigRequestAdjust(Storage)) { - return; - } - ASSERT (Storage->ConfigElements != NULL); + default: + return; + } - 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); - } - } + // + // Request current settings from Configuration Driver + // + Status = mHiiConfigRouting->ExtractConfig ( + mHiiConfigRouting, + ConfigRequest, + &Progress, + &Result + ); - if (EFI_ERROR (Status)) { - // - // Base on the configRequest string to get default value. - // - GetDefaultForFormset (FormSet, Storage->BrowserStorage, Storage->ConfigElements); - } + // + // 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); + } - SynchronizeStorage(FormSet, Storage->BrowserStorage, Storage->ConfigElements, TRUE); - break; + Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest); - default: - break; + // + // 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_EFI_VARIABLE_BUFFER) { + if (ConfigRequest != NULL) { + FreePool (ConfigRequest); + } } } @@ -4324,6 +4189,17 @@ 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) { + RemoveEntryList (&OldFormSet->Link); + DestroyFormSet (OldFormSet); + } + InsertTailList (&gBrowserFormSetList, &FormSet->Link); + // // Extract default from IFR binary for no storage questions. // @@ -4340,17 +4216,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); }