diff options
-rw-r--r-- | MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 179 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c | 9 | ||||
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 636 |
3 files changed, 389 insertions, 435 deletions
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 2ed02cdaa4..1fb16817b7 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -355,6 +355,9 @@ OutputConfigBody ( }
Length = TmpPtr - String;
+ if (Length == 0) {
+ return EFI_NOT_FOUND;
+ }
Result = AllocateCopyPool (Length * sizeof (CHAR16), String);
if (Result == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -1281,6 +1284,13 @@ IsThisVarstore ( GuidStr = 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);
if (Name != NULL) {
GenerateSubStr (L"NAME=", StrLen (Name) * sizeof (CHAR16), (VOID *) Name, 2, &NameStr);
@@ -1318,6 +1328,130 @@ Done: }
/**
+ 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.
@param RequestBlockArray The array includes all the request info or NULL.
@@ -2128,14 +2262,26 @@ ParseIfrData ( //
// End Opcode is for Var question.
//
- if (BlockData != NULL && BlockData->Scope > 0) {
- BlockData->Scope--;
+ if (BlockData != NULL) {
+ if (BlockData->Scope > 0) {
+ BlockData->Scope--;
+ }
+ if (BlockData->Scope == 0) {
+ BlockData = NULL;
+ }
}
+
break;
default:
- if (BlockData != NULL && BlockData->Scope > 0) {
- BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope);
+ if (BlockData != NULL) {
+ if (BlockData->Scope > 0) {
+ BlockData->Scope = (UINT8) (BlockData->Scope + IfrOpHdr->Scope);
+ }
+
+ if (BlockData->Scope == 0) {
+ BlockData = NULL;
+ }
}
break;
}
@@ -3200,10 +3346,11 @@ GetConfigRespFromEfiVarStore ( UINT8 *VarStore;
UINTN BufferSize;
- Status = EFI_SUCCESS;
- BufferSize = 0;
- VarStore = NULL;
- VarStoreName = NULL;
+ Status = EFI_SUCCESS;
+ BufferSize = 0;
+ VarStore = NULL;
+ VarStoreName = NULL;
+ *AccessProgress = Request;
VarStoreName = AllocateZeroPool (AsciiStrSize ((CHAR8 *)EfiVarStoreInfo->Name) * sizeof (CHAR16));
if (VarStoreName == NULL) {
@@ -3537,6 +3684,7 @@ HiiConfigRoutingExtractConfig ( BOOLEAN IsEfiVarStore;
EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo;
EFI_STRING ErrorPtr;
+ UINTN DevicePathSize;
if (This == NULL || Progress == NULL || Results == NULL) {
return EFI_INVALID_PARAMETER;
@@ -3622,11 +3770,8 @@ HiiConfigRoutingExtractConfig ( Database = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);
if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {
CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);
- if (CompareMem (
- DevicePath,
- CurrentDevicePath,
- GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)
- ) == 0) {
+ DevicePathSize = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath);
+ if ((CompareMem (DevicePath,CurrentDevicePath,DevicePathSize) == 0) && IsThisPackageList(Database, Request)) {
DriverHandle = Database->DriverHandle;
HiiHandle = Database->Handle;
break;
@@ -4060,6 +4205,7 @@ HiiConfigRoutingRouteConfig ( EFI_STRING AccessProgress;
EFI_IFR_VARSTORE_EFI *EfiVarStoreInfo;
BOOLEAN IsEfiVarstore;
+ UINTN DevicePathSize;
if (This == NULL || Progress == NULL) {
return EFI_INVALID_PARAMETER;
@@ -4131,11 +4277,8 @@ HiiConfigRoutingRouteConfig ( if ((DevicePathPkg = Database->PackageList->DevicePathPkg) != NULL) {
CurrentDevicePath = DevicePathPkg + sizeof (EFI_HII_PACKAGE_HEADER);
- if (CompareMem (
- DevicePath,
- CurrentDevicePath,
- GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath)
- ) == 0) {
+ DevicePathSize = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) CurrentDevicePath);
+ if ((CompareMem (DevicePath,CurrentDevicePath,DevicePathSize) == 0) && IsThisPackageList(Database, Configuration)) {
DriverHandle = Database->DriverHandle;
break;
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index 5e0187396a..fb3ff7b266 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -1499,7 +1499,6 @@ ProcessQuestionConfig ( EFI_STATUS Status;
CHAR16 *ConfigResp;
CHAR16 *Progress;
- EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
if (Question->QuestionConfig == 0) {
return EFI_SUCCESS;
@@ -1516,12 +1515,8 @@ ProcessQuestionConfig ( //
// Send config to Configuration Driver
//
- ConfigAccess = Selection->FormSet->ConfigAccess;
- if (ConfigAccess == NULL) {
- return EFI_UNSUPPORTED;
- }
- Status = ConfigAccess->RouteConfig (
- ConfigAccess,
+ Status = mHiiConfigRouting->RouteConfig (
+ mHiiConfigRouting,
ConfigResp,
&Progress
);
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index f8ea4ff01b..66238e055f 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -1270,7 +1270,6 @@ GetQuestionValue ( BOOLEAN IsString;
CHAR16 TemStr[5];
UINT8 DigitUint8;
- UINT8 *TemBuffer;
Status = EFI_SUCCESS;
Value = NULL;
@@ -1487,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;
- }
-
- //
- // <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||
- // <ConfigHdr> + "&" + <VariableName>
- //
- 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);
+ //
+ // <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||
+ // <ConfigHdr> + "&" + <VariableName>
+ //
+ 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 <ConfigRequest>
- //
- 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 <ConfigRequest>
+ //
+ 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 <AltResp> if any
+ //
+ StringPtr = Value;
+ while (*StringPtr != L'\0' && *StringPtr != L'&') {
+ StringPtr++;
+ }
+ *StringPtr = L'\0';
+ LengthStr = StrLen (Value);
+ Status = EFI_SUCCESS;
+ if (!IsBufferStorage && IsString) {
//
- // Suppress <AltResp> 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;
}
//
@@ -1871,111 +1841,78 @@ SetQuestionValue ( }
}
} 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" ||
- // <ConfigHdr> + "&" + <VariableName> + "=" + "<string>"
- //
- 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"=");
- }
+ //
+ // <ConfigResp> ::= <ConfigHdr> + <BlockName> + "&VALUE=" + "<HexCh>StorageWidth * 2" ||
+ // <ConfigHdr> + "&" + <VariableName> + "=" + "<string>"
+ //
+ 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.
//
@@ -2522,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;
@@ -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 ||
- 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,
- 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.
@@ -2681,69 +2562,19 @@ SubmitForm ( return Status;
}
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER ||
- Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
-
- //
- // 2. 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) {
- //
- // 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 <ConfigResp> 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
@@ -2828,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;
}
@@ -2849,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);
//
@@ -2874,8 +2707,8 @@ GetDefaultValueFromAltCfg ( StrCat (ConfigRequest, Question->VariableName);
}
- Status = FormSet->ConfigAccess->ExtractConfig (
- FormSet->ConfigAccess,
+ Status = mHiiConfigRouting->ExtractConfig (
+ mHiiConfigRouting,
ConfigRequest,
&Progress,
&Result
@@ -2905,6 +2738,11 @@ GetDefaultValueFromAltCfg ( goto Done;
}
+ if (ConfigResp == NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+
//
// Skip <ConfigRequest>
//
@@ -4257,26 +4095,6 @@ LoadStorage ( 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);
- //
- // 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:
@@ -4287,49 +4105,47 @@ LoadStorage ( if (Storage->ElementCount == 0 || Storage->BrowserStorage->Initialized) {
return;
}
-
- Status = EFI_NOT_FOUND;
- if (FormSet->ConfigAccess != NULL) {
- //
- // Request current settings from Configuration Driver
- //
- Status = FormSet->ConfigAccess->ExtractConfig (
- FormSet->ConfigAccess,
- Storage->ConfigRequest,
- &Progress,
- &Result
- );
-
- if (!EFI_ERROR (Status)) {
- //
- // Convert Result from <ConfigAltResp> to <ConfigResp>
- //
- StrPtr = StrStr (Result, L"&GUID=");
- if (StrPtr != NULL) {
- *StrPtr = L'\0';
- }
-
- Status = ConfigRespToStorage (Storage->BrowserStorage, 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->Initialized = TRUE;
break;
default:
- break;
+ return;
}
+
+ //
+ // Request current settings from Configuration Driver
+ //
+ Status = mHiiConfigRouting->ExtractConfig (
+ mHiiConfigRouting,
+ Storage->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 <ConfigAltResp> to <ConfigResp>
+ //
+ 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);
}
/**
|