MdeModulePkg:Set default string value

Previously construct Default Value in AltResp for string opcode is String Id,
Now change it to string value if the string opcode has default value.
This change is compatible for SetupBrowser to handle.And add default value
for string in DriverSample to test this case.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18337 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Dandan Bi 2015-08-27 08:35:19 +00:00 committed by dandanbi
parent 2bf63b20d2
commit e68c776bf8
3 changed files with 17 additions and 9 deletions

View File

@ -461,6 +461,7 @@ formset
help = STRING_TOKEN(STR_MY_STRING_HELP),
minsize = 6,
maxsize = 0x14,
default = STRING_TOKEN(STR_MY_STRING_DEFAULT),
endstring;
//

View File

@ -2056,11 +2056,6 @@ ParseIfrData (
if (EFI_ERROR (Status)) {
goto Done;
}
//
// No default value for string.
//
BlockData = NULL;
break;
case EFI_IFR_PASSWORD_OP:
@ -2850,6 +2845,7 @@ GetStorageWidth (
/**
Generate ConfigAltResp string base on the varstore info.
@param HiiHandle Hii Handle for this hii package.
@param ConfigHdr The config header for this varstore.
@param VarStorageData The varstore info.
@param DefaultIdArray The Default id array.
@ -2860,6 +2856,7 @@ GetStorageWidth (
**/
EFI_STATUS
GenerateAltConfigResp (
IN EFI_HII_HANDLE HiiHandle,
IN CHAR16 *ConfigHdr,
IN IFR_VARSTORAGE_DATA *VarStorageData,
IN IFR_DEFAULT_DATA *DefaultIdArray,
@ -2878,10 +2875,11 @@ GenerateAltConfigResp (
IFR_DEFAULT_DATA *DefaultValueData;
UINTN Width;
UINT8 *TmpBuffer;
CHAR16 *DefaultString;
BlockData = NULL;
DataExist = FALSE;
DefaultString = NULL;
//
// Add length for <ConfigHdr> + '\0'
//
@ -2993,10 +2991,19 @@ GenerateAltConfigResp (
// Convert Value to a hex string in "%x" format
// NOTE: This is in the opposite byte that GUID and PATH use
//
TmpBuffer = (UINT8 *) &(DefaultValueData->Value);
for (; Width > 0; Width--) {
if (BlockData->OpCode == EFI_IFR_STRING_OP){
DefaultString = InternalGetString(HiiHandle, DefaultValueData->Value.string);
TmpBuffer = (UINT8 *) DefaultString;
} else {
TmpBuffer = (UINT8 *) &(DefaultValueData->Value);
}
for (; Width > 0 && (TmpBuffer != NULL); Width--) {
StringPtr += UnicodeValueToString (StringPtr, PREFIX_ZERO | RADIX_HEX, TmpBuffer[Width - 1], 2);
}
if (DefaultString != NULL){
FreePool(DefaultString);
DefaultString = NULL;
}
}
}
}
@ -3218,7 +3225,7 @@ GetFullStringFromHiiFormPackages (
// Go through all VarStorageData Entry and get the DefaultId array for each one
// Then construct them all to : ConfigHdr AltConfigHdr ConfigBody AltConfigHdr ConfigBody
//
Status = GenerateAltConfigResp (ConfigHdr, VarStorageData, DefaultIdArray, &DefaultAltCfgResp);
Status = GenerateAltConfigResp (DataBaseRecord->Handle,ConfigHdr, VarStorageData, DefaultIdArray, &DefaultAltCfgResp);
if (EFI_ERROR (Status)) {
goto Done;
}