+ //\r
+ // Check if configuring Name/Value storage\r
+ //\r
+ if (StrStr (Configuration, L"OFFSET") == NULL) {\r
+ //\r
+ // Update Name/Value storage Names\r
+ //\r
+ Status = LoadNameValueNames (PrivateData);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Convert value for NameValueVar0\r
+ //\r
+ if ((Value = StrStr (Configuration, PrivateData->NameValueName[0])) != NULL) {\r
+ //\r
+ // Skip "Name="\r
+ //\r
+ Value += StrLen (PrivateData->NameValueName[0]);\r
+ Value++;\r
+ //\r
+ // Get Value String\r
+ //\r
+ StrPtr = StrStr (Value, L"&");\r
+ if (StrPtr == NULL) {\r
+ StrPtr = Value + StrLen (Value);\r
+ }\r
+ //\r
+ // Convert Value to Buffer data\r
+ //\r
+ DataBuffer = (UINT8 *) &PrivateData->Configuration.NameValueVar0;\r
+ ZeroMem (TemStr, sizeof (TemStr));\r
+ for (Index = 0, StrPtr --; StrPtr >= Value; StrPtr --, Index ++) {\r
+ TemStr[0] = *StrPtr;\r
+ DigitUint8 = (UINT8) StrHexToUint64 (TemStr);\r
+ if ((Index & 1) == 0) {\r
+ DataBuffer [Index/2] = DigitUint8;\r
+ } else {\r
+ DataBuffer [Index/2] = (UINT8) ((UINT8) (DigitUint8 << 4) + DataBuffer [Index/2]);\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // Convert value for NameValueVar1\r
+ //\r
+ if ((Value = StrStr (Configuration, PrivateData->NameValueName[1])) != NULL) {\r
+ //\r
+ // Skip "Name="\r
+ //\r
+ Value += StrLen (PrivateData->NameValueName[1]);\r
+ Value++;\r
+ //\r
+ // Get Value String\r
+ //\r
+ StrPtr = StrStr (Value, L"&");\r
+ if (StrPtr == NULL) {\r
+ StrPtr = Value + StrLen (Value);\r
+ }\r
+ //\r
+ // Convert Value to Buffer data\r
+ //\r
+ DataBuffer = (UINT8 *) &PrivateData->Configuration.NameValueVar1;\r
+ ZeroMem (TemStr, sizeof (TemStr));\r
+ for (Index = 0, StrPtr --; StrPtr >= Value; StrPtr --, Index ++) {\r
+ TemStr[0] = *StrPtr;\r
+ DigitUint8 = (UINT8) StrHexToUint64 (TemStr);\r
+ if ((Index & 1) == 0) {\r
+ DataBuffer [Index/2] = DigitUint8;\r
+ } else {\r
+ DataBuffer [Index/2] = (UINT8) ((UINT8) (DigitUint8 << 4) + DataBuffer [Index/2]);\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // Convert value for NameValueVar2\r
+ //\r
+ if ((Value = StrStr (Configuration, PrivateData->NameValueName[2])) != NULL) {\r
+ //\r
+ // Skip "Name="\r
+ //\r
+ Value += StrLen (PrivateData->NameValueName[2]);\r
+ Value++;\r
+ //\r
+ // Get Value String\r
+ //\r
+ StrPtr = StrStr (Value, L"&");\r
+ if (StrPtr == NULL) {\r
+ StrPtr = Value + StrLen (Value);\r
+ }\r
+ //\r
+ // Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD"\r
+ //\r
+ StrBuffer = (CHAR16 *) PrivateData->Configuration.NameValueVar2;\r
+ ZeroMem (TemStr, sizeof (TemStr));\r
+ while (Value < StrPtr) {\r
+ StrnCpy (TemStr, Value, 4);\r
+ *(StrBuffer++) = (CHAR16) StrHexToUint64 (TemStr);\r
+ Value += 4;\r
+ }\r
+ *StrBuffer = L'\0';\r
+ }\r
+\r
+ //\r
+ // Store Buffer Storage back to EFI variable\r
+ //\r
+ Status = gRT->SetVariable(\r
+ VariableName,\r
+ &mFormSetGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
+ sizeof (DRIVER_SAMPLE_CONFIGURATION),\r
+ &PrivateData->Configuration\r
+ );\r
+\r
+ return Status;\r
+ }\r
+\r