Update the logic in browser core, use config routine protocol instead of config access protocol to get/set data with hii drivers.
Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14902 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -355,6 +355,9 @@ OutputConfigBody (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Length = TmpPtr - String;
|
Length = TmpPtr - String;
|
||||||
|
if (Length == 0) {
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
Result = AllocateCopyPool (Length * sizeof (CHAR16), String);
|
Result = AllocateCopyPool (Length * sizeof (CHAR16), String);
|
||||||
if (Result == NULL) {
|
if (Result == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
@ -1281,6 +1284,13 @@ IsThisVarstore (
|
|||||||
GuidStr = NULL;
|
GuidStr = NULL;
|
||||||
TempStr = NULL;
|
TempStr = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// If ConfigHdr has name field and varstore not has name, return FALSE.
|
||||||
|
//
|
||||||
|
if (Name == NULL && StrStr (ConfigHdr, L"NAME=&") == NULL) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *)VarstoreGuid, 1, &GuidStr);
|
GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *)VarstoreGuid, 1, &GuidStr);
|
||||||
if (Name != NULL) {
|
if (Name != NULL) {
|
||||||
GenerateSubStr (L"NAME=", StrLen (Name) * sizeof (CHAR16), (VOID *) Name, 2, &NameStr);
|
GenerateSubStr (L"NAME=", StrLen (Name) * sizeof (CHAR16), (VOID *) Name, 2, &NameStr);
|
||||||
@ -1317,6 +1327,130 @@ Done:
|
|||||||
return RetVal;
|
return RetVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function parses Form Package to get the efi varstore info according to the request ConfigHdr.
|
||||||
|
|
||||||
|
@param DataBaseRecord The DataBaseRecord instance contains the found Hii handle and package.
|
||||||
|
@param ConfigHdr Request string ConfigHdr. If it is NULL,
|
||||||
|
the first found varstore will be as ConfigHdr.
|
||||||
|
@retval TRUE This hii package is the reqeust one.
|
||||||
|
@retval FALSE This hii package is not the reqeust one.
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
IsThisPackageList (
|
||||||
|
IN HII_DATABASE_RECORD *DataBaseRecord,
|
||||||
|
IN EFI_STRING ConfigHdr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINTN IfrOffset;
|
||||||
|
UINTN PackageOffset;
|
||||||
|
EFI_IFR_OP_HEADER *IfrOpHdr;
|
||||||
|
CHAR16 *VarStoreName;
|
||||||
|
UINT8 *HiiFormPackage;
|
||||||
|
UINTN PackageSize;
|
||||||
|
EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
|
||||||
|
EFI_HII_PACKAGE_HEADER *PackageHeader;
|
||||||
|
EFI_IFR_VARSTORE *IfrVarStore;
|
||||||
|
EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore;
|
||||||
|
BOOLEAN FindVarstore;
|
||||||
|
|
||||||
|
HiiFormPackage = NULL;
|
||||||
|
VarStoreName = NULL;
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
FindVarstore = FALSE;
|
||||||
|
|
||||||
|
Status = GetFormPackageData(DataBaseRecord, &HiiFormPackage, &PackageSize);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER);
|
||||||
|
PackageOffset = IfrOffset;
|
||||||
|
PackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiFormPackage;
|
||||||
|
|
||||||
|
while (IfrOffset < PackageSize) {
|
||||||
|
//
|
||||||
|
// More than one form packages exist.
|
||||||
|
//
|
||||||
|
if (PackageOffset >= PackageHeader->Length) {
|
||||||
|
//
|
||||||
|
// Process the new form package.
|
||||||
|
//
|
||||||
|
PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);
|
||||||
|
IfrOffset += PackageOffset;
|
||||||
|
PackageHeader = (EFI_HII_PACKAGE_HEADER *) (HiiFormPackage + IfrOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset);
|
||||||
|
IfrOffset += IfrOpHdr->Length;
|
||||||
|
PackageOffset += IfrOpHdr->Length;
|
||||||
|
|
||||||
|
switch (IfrOpHdr->OpCode) {
|
||||||
|
|
||||||
|
case EFI_IFR_VARSTORE_OP:
|
||||||
|
IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr;
|
||||||
|
|
||||||
|
VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrVarStore->Name) * sizeof (CHAR16));
|
||||||
|
if (VarStoreName == NULL) {
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
AsciiStrToUnicodeStr ((CHAR8 *)IfrVarStore->Name, VarStoreName);
|
||||||
|
|
||||||
|
if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) {
|
||||||
|
FindVarstore = TRUE;
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EFI_IFR_VARSTORE_EFI_OP:
|
||||||
|
IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;
|
||||||
|
VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16));
|
||||||
|
if (VarStoreName == NULL) {
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
AsciiStrToUnicodeStr ((CHAR8 *)IfrEfiVarStore->Name, VarStoreName);
|
||||||
|
|
||||||
|
if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) {
|
||||||
|
FindVarstore = TRUE;
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EFI_IFR_VARSTORE_NAME_VALUE_OP:
|
||||||
|
IfrNameValueVarStore = (EFI_IFR_VARSTORE_NAME_VALUE *) IfrOpHdr;
|
||||||
|
|
||||||
|
if (IsThisVarstore (&IfrNameValueVarStore->Guid, NULL, ConfigHdr)) {
|
||||||
|
FindVarstore = TRUE;
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EFI_IFR_FORM_OP:
|
||||||
|
case EFI_IFR_FORM_MAP_OP:
|
||||||
|
//
|
||||||
|
// No matched varstore is found and directly return.
|
||||||
|
//
|
||||||
|
goto Done;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Done:
|
||||||
|
if (HiiFormPackage != NULL) {
|
||||||
|
FreePool (HiiFormPackage);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VarStoreName != NULL) {
|
||||||
|
FreePool (VarStoreName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FindVarstore;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check whether the this op code is required.
|
Check whether the this op code is required.
|
||||||
|
|
||||||
@ -2128,15 +2262,27 @@ ParseIfrData (
|
|||||||
//
|
//
|
||||||
// End Opcode is for Var question.
|
// End Opcode is for Var question.
|
||||||
//
|
//
|
||||||
if (BlockData != NULL && BlockData->Scope > 0) {
|
if (BlockData != NULL) {
|
||||||
|
if (BlockData->Scope > 0) {
|
||||||
BlockData->Scope--;
|
BlockData->Scope--;
|
||||||
}
|
}
|
||||||
|
if (BlockData->Scope == 0) {
|
||||||
|
BlockData = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (BlockData != NULL && BlockData->Scope > 0) {
|
if (BlockData != NULL) {
|
||||||
|
if (BlockData->Scope > 0) {
|
||||||
BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope);
|
BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (BlockData->Scope == 0) {
|
||||||
|
BlockData = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3204,6 +3350,7 @@ GetConfigRespFromEfiVarStore (
|
|||||||
BufferSize = 0;
|
BufferSize = 0;
|
||||||
VarStore = NULL;
|
VarStore = NULL;
|
||||||
VarStoreName = NULL;
|
VarStoreName = NULL;
|
||||||
|
*AccessProgress = Request;
|
||||||
|
|
||||||
VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16));
|
VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16));
|
||||||
if (VarStoreName == NULL) {
|
if (VarStoreName == NULL) {
|
||||||
@ -3537,6 +3684,7 @@ HiiConfigRoutingExtractConfig (
|
|||||||
BOOLEAN IsEfiVarStore;
|
BOOLEAN IsEfiVarStore;
|
||||||
EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo;
|
EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo;
|
||||||
EFI_STRING ErrorPtr;
|
EFI_STRING ErrorPtr;
|
||||||
|
UINTN DevicePathSize;
|
||||||
|
|
||||||
if (This == NULL || Progress == NULL || Results == NULL) {
|
if (This == NULL || Progress == NULL || Results == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
@ -3622,11 +3770,8 @@ HiiConfigRoutingExtractConfig (
|
|||||||
Database = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);
|
Database = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);
|
||||||
if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {
|
if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {
|
||||||
CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);
|
CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);
|
||||||
if (CompareMem (
|
DevicePathSize = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath);
|
||||||
DevicePath,
|
if ((CompareMem (DevicePath,CurrentDevicePath,DevicePathSize) == 0) && IsThisPackageList(Database, Request)) {
|
||||||
CurrentDevicePath,
|
|
||||||
GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)
|
|
||||||
) == 0) {
|
|
||||||
DriverHandle = Database->DriverHandle;
|
DriverHandle = Database->DriverHandle;
|
||||||
HiiHandle = Database->Handle;
|
HiiHandle = Database->Handle;
|
||||||
break;
|
break;
|
||||||
@ -4060,6 +4205,7 @@ HiiConfigRoutingRouteConfig (
|
|||||||
EFI_STRING AccessProgress;
|
EFI_STRING AccessProgress;
|
||||||
EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo;
|
EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo;
|
||||||
BOOLEAN IsEfiVarstore;
|
BOOLEAN IsEfiVarstore;
|
||||||
|
UINTN DevicePathSize;
|
||||||
|
|
||||||
if (This == NULL || Progress == NULL) {
|
if (This == NULL || Progress == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
@ -4131,11 +4277,8 @@ HiiConfigRoutingRouteConfig (
|
|||||||
|
|
||||||
if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {
|
if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {
|
||||||
CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);
|
CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);
|
||||||
if (CompareMem (
|
DevicePathSize = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath);
|
||||||
DevicePath,
|
if ((CompareMem (DevicePath,CurrentDevicePath,DevicePathSize) == 0) && IsThisPackageList(Database, Configuration)) {
|
||||||
CurrentDevicePath,
|
|
||||||
GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)
|
|
||||||
) == 0) {
|
|
||||||
DriverHandle = Database->DriverHandle;
|
DriverHandle = Database->DriverHandle;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1499,7 +1499,6 @@ ProcessQuestionConfig (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
CHAR16 *ConfigResp;
|
CHAR16 *ConfigResp;
|
||||||
CHAR16 *Progress;
|
CHAR16 *Progress;
|
||||||
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
|
|
||||||
|
|
||||||
if (Question->QuestionConfig == 0) {
|
if (Question->QuestionConfig == 0) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -1516,12 +1515,8 @@ ProcessQuestionConfig (
|
|||||||
//
|
//
|
||||||
// Send config to Configuration Driver
|
// Send config to Configuration Driver
|
||||||
//
|
//
|
||||||
ConfigAccess = Selection->FormSet->ConfigAccess;
|
Status = mHiiConfigRouting->RouteConfig (
|
||||||
if (ConfigAccess == NULL) {
|
mHiiConfigRouting,
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
Status = ConfigAccess->RouteConfig (
|
|
||||||
ConfigAccess,
|
|
||||||
ConfigResp,
|
ConfigResp,
|
||||||
&Progress
|
&Progress
|
||||||
);
|
);
|
||||||
|
@ -1270,7 +1270,6 @@ GetQuestionValue (
|
|||||||
BOOLEAN IsString;
|
BOOLEAN IsString;
|
||||||
CHAR16 TemStr[5];
|
CHAR16 TemStr[5];
|
||||||
UINT8 DigitUint8;
|
UINT8 DigitUint8;
|
||||||
UINT8 *TemBuffer;
|
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
Value = NULL;
|
Value = NULL;
|
||||||
@ -1487,14 +1486,6 @@ GetQuestionValue (
|
|||||||
FreePool (Value);
|
FreePool (Value);
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||
|
// <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||
|
||||||
// <ConfigHdr> + "&" + <VariableName>
|
// <ConfigHdr> + "&" + <VariableName>
|
||||||
@ -1517,8 +1508,11 @@ GetQuestionValue (
|
|||||||
StrCat (ConfigRequest, Question->VariableName);
|
StrCat (ConfigRequest, Question->VariableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = FormSet->ConfigAccess->ExtractConfig (
|
//
|
||||||
FormSet->ConfigAccess,
|
// Request current settings from Configuration Driver
|
||||||
|
//
|
||||||
|
Status = mHiiConfigRouting->ExtractConfig (
|
||||||
|
mHiiConfigRouting,
|
||||||
ConfigRequest,
|
ConfigRequest,
|
||||||
&Progress,
|
&Progress,
|
||||||
&Result
|
&Result
|
||||||
@ -1605,30 +1599,6 @@ GetQuestionValue (
|
|||||||
FreePool (Result);
|
FreePool (Result);
|
||||||
return Status;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Synchronize Edit Buffer
|
// Synchronize Edit Buffer
|
||||||
@ -1871,7 +1841,6 @@ SetQuestionValue (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (SetValueTo == GetSetValueWithHiiDriver) {
|
} else if (SetValueTo == GetSetValueWithHiiDriver) {
|
||||||
if (Storage->Type == EFI_HII_VARSTORE_BUFFER || Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
|
|
||||||
//
|
//
|
||||||
// <ConfigResp> ::= <ConfigHdr> + <BlockName> + "&VALUE=" + "<HexCh>StorageWidth * 2" ||
|
// <ConfigResp> ::= <ConfigHdr> + <BlockName> + "&VALUE=" + "<HexCh>StorageWidth * 2" ||
|
||||||
// <ConfigHdr> + "&" + <VariableName> + "=" + "<string>"
|
// <ConfigHdr> + "&" + <VariableName> + "=" + "<string>"
|
||||||
@ -1933,9 +1902,8 @@ SetQuestionValue (
|
|||||||
//
|
//
|
||||||
// Submit Question Value to Configuration Driver
|
// Submit Question Value to Configuration Driver
|
||||||
//
|
//
|
||||||
if (FormSet->ConfigAccess != NULL) {
|
Status = mHiiConfigRouting->RouteConfig (
|
||||||
Status = FormSet->ConfigAccess->RouteConfig (
|
mHiiConfigRouting,
|
||||||
FormSet->ConfigAccess,
|
|
||||||
ConfigResp,
|
ConfigResp,
|
||||||
&Progress
|
&Progress
|
||||||
);
|
);
|
||||||
@ -1943,39 +1911,8 @@ SetQuestionValue (
|
|||||||
FreePool (ConfigResp);
|
FreePool (ConfigResp);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
FreePool (ConfigResp);
|
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;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
// Sync storage, from editbuffer to buffer.
|
// Sync storage, from editbuffer to buffer.
|
||||||
//
|
//
|
||||||
@ -2522,8 +2459,6 @@ SubmitForm (
|
|||||||
EFI_STRING Progress;
|
EFI_STRING Progress;
|
||||||
BROWSER_STORAGE *Storage;
|
BROWSER_STORAGE *Storage;
|
||||||
FORMSET_STORAGE *FormSetStorage;
|
FORMSET_STORAGE *FormSetStorage;
|
||||||
UINTN BufferSize;
|
|
||||||
UINT8 *TmpBuf;
|
|
||||||
FORM_BROWSER_FORMSET *LocalFormSet;
|
FORM_BROWSER_FORMSET *LocalFormSet;
|
||||||
FORM_BROWSER_CONFIG_REQUEST *ConfigInfo;
|
FORM_BROWSER_CONFIG_REQUEST *ConfigInfo;
|
||||||
|
|
||||||
@ -2575,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 ||
|
Status = mHiiConfigRouting->RouteConfig (
|
||||||
Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
|
|
||||||
//
|
|
||||||
// Send <ConfigResp> 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,
|
mHiiConfigRouting,
|
||||||
ConfigResp,
|
ConfigResp,
|
||||||
TmpBuf,
|
|
||||||
&BufferSize,
|
|
||||||
&Progress
|
&Progress
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
FreePool (TmpBuf);
|
|
||||||
FreePool (ConfigResp);
|
FreePool (ConfigResp);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gRT->SetVariable (
|
|
||||||
Storage->Name,
|
|
||||||
&Storage->Guid,
|
|
||||||
Storage->Attributes,
|
|
||||||
Storage->Size,
|
|
||||||
TmpBuf
|
|
||||||
);
|
|
||||||
FreePool (TmpBuf);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
FreePool (ConfigResp);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FreePool (ConfigResp);
|
FreePool (ConfigResp);
|
||||||
//
|
//
|
||||||
// 3. Config success, update storage shadow Buffer, only update the data belong to this form.
|
// 3. Config success, update storage shadow Buffer, only update the data belong to this form.
|
||||||
@ -2681,69 +2562,19 @@ SubmitForm (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Storage->Type == EFI_HII_VARSTORE_BUFFER ||
|
|
||||||
Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// 2. Send <ConfigResp> to Configuration Driver
|
// 2. Send <ConfigResp> to Routine config Protocol.
|
||||||
//
|
//
|
||||||
if (FormSet->ConfigAccess != NULL) {
|
Status = mHiiConfigRouting->RouteConfig (
|
||||||
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,
|
mHiiConfigRouting,
|
||||||
ConfigResp,
|
ConfigResp,
|
||||||
TmpBuf,
|
|
||||||
&BufferSize,
|
|
||||||
&Progress
|
&Progress
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
FreePool (TmpBuf);
|
|
||||||
FreePool (ConfigResp);
|
FreePool (ConfigResp);
|
||||||
return Status;
|
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);
|
|
||||||
}
|
|
||||||
FreePool (ConfigResp);
|
FreePool (ConfigResp);
|
||||||
//
|
//
|
||||||
// 3. Config success, update storage shadow Buffer
|
// 3. Config success, update storage shadow Buffer
|
||||||
@ -2828,9 +2659,7 @@ GetDefaultValueFromAltCfg (
|
|||||||
Value = NULL;
|
Value = NULL;
|
||||||
Storage = Question->Storage;
|
Storage = Question->Storage;
|
||||||
|
|
||||||
if ((Storage == NULL) ||
|
if ((Storage == NULL) || (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE)) {
|
||||||
(Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) ||
|
|
||||||
(Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER)) {
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2849,7 +2678,11 @@ GetDefaultValueFromAltCfg (
|
|||||||
Dst = (UINT8 *) &Question->HiiValue.Value;
|
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);
|
IsString = (BOOLEAN) ((Question->HiiValue.Type == EFI_IFR_TYPE_STRING) ? TRUE : FALSE);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -2874,8 +2707,8 @@ GetDefaultValueFromAltCfg (
|
|||||||
StrCat (ConfigRequest, Question->VariableName);
|
StrCat (ConfigRequest, Question->VariableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = FormSet->ConfigAccess->ExtractConfig (
|
Status = mHiiConfigRouting->ExtractConfig (
|
||||||
FormSet->ConfigAccess,
|
mHiiConfigRouting,
|
||||||
ConfigRequest,
|
ConfigRequest,
|
||||||
&Progress,
|
&Progress,
|
||||||
&Result
|
&Result
|
||||||
@ -2905,6 +2738,11 @@ GetDefaultValueFromAltCfg (
|
|||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ConfigResp == NULL) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Skip <ConfigRequest>
|
// Skip <ConfigRequest>
|
||||||
//
|
//
|
||||||
@ -4257,26 +4095,6 @@ LoadStorage (
|
|||||||
ConfigRequestAdjust(Storage);
|
ConfigRequestAdjust(Storage);
|
||||||
return;
|
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;
|
break;
|
||||||
|
|
||||||
case EFI_HII_VARSTORE_BUFFER:
|
case EFI_HII_VARSTORE_BUFFER:
|
||||||
@ -4287,20 +4105,29 @@ LoadStorage (
|
|||||||
if (Storage->ElementCount == 0 || Storage->BrowserStorage->Initialized) {
|
if (Storage->ElementCount == 0 || Storage->BrowserStorage->Initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Storage->BrowserStorage->Initialized = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Status = EFI_NOT_FOUND;
|
|
||||||
if (FormSet->ConfigAccess != NULL) {
|
|
||||||
//
|
//
|
||||||
// Request current settings from Configuration Driver
|
// Request current settings from Configuration Driver
|
||||||
//
|
//
|
||||||
Status = FormSet->ConfigAccess->ExtractConfig (
|
Status = mHiiConfigRouting->ExtractConfig (
|
||||||
FormSet->ConfigAccess,
|
mHiiConfigRouting,
|
||||||
Storage->ConfigRequest,
|
Storage->ConfigRequest,
|
||||||
&Progress,
|
&Progress,
|
||||||
&Result
|
&Result
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
//
|
||||||
|
// 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 <ConfigAltResp> to <ConfigResp>
|
// Convert Result from <ConfigAltResp> to <ConfigResp>
|
||||||
//
|
//
|
||||||
@ -4312,24 +4139,13 @@ LoadStorage (
|
|||||||
Status = ConfigRespToStorage (Storage->BrowserStorage, Result);
|
Status = ConfigRespToStorage (Storage->BrowserStorage, Result);
|
||||||
FreePool (Result);
|
FreePool (Result);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
//
|
|
||||||
// Base on the configRequest string to get default value.
|
|
||||||
//
|
|
||||||
GetDefaultForFormset (FormSet, Storage->BrowserStorage, Storage->ConfigRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
SynchronizeStorage(FormSet, Storage->BrowserStorage, Storage->ConfigRequest, TRUE);
|
|
||||||
|
|
||||||
Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest);
|
Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest);
|
||||||
Storage->BrowserStorage->Initialized = TRUE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
//
|
||||||
break;
|
// Input NULL for ConfigRequest field means sync all fields from editbuffer to buffer.
|
||||||
}
|
//
|
||||||
|
SynchronizeStorage(FormSet, Storage->BrowserStorage, NULL, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user