Fix a bug when generate default value for byte array for FIXED_AT_BUILD, PATCHABLE_IN_MODULE type PCD.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@551 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2006-06-17 13:25:31 +00:00
parent 38ee8d9e66
commit 2435723ad9
2 changed files with 54 additions and 23 deletions

View File

@ -1978,7 +1978,7 @@ public class CollectPCDAction {
strValueArray = strValue.split(",");
for (index = 0; index < strValueArray.length; index ++) {
try{
value = Integer.decode(strValueArray[index]);
value = Integer.decode(strValueArray[index].trim());
} catch (NumberFormatException nfeEx) {
exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and "+
"it is byte array in fact. For every byte in array should be a valid"+

View File

@ -203,6 +203,7 @@ public class UsageInstance {
throws EntityException {
String guidStringArray[] = null;
String guidString = null;
boolean isByteArray = false;
hAutogenStr = "";
cAutogenStr = "";
@ -217,6 +218,12 @@ public class UsageInstance {
parentToken.cName, parentToken.tokenNumber);
}
if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {
if (datum.trim().charAt(0) == '{') {
isByteArray = true;
}
}
switch (modulePcdType) {
case FEATURE_FLAG:
if (isBuildUsedLibrary) {
@ -254,17 +261,29 @@ public class UsageInstance {
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
parentToken.cName,
datum.toString());
hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName);
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
hAutogenStr += String.format("#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
if (isByteArray) {
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = _PCD_VALUE_%s;\r\n",
parentToken.cName,
parentToken.cName);
hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",
parentToken.cName);
hAutogenStr += String.format("#define _PCD_MODE_%s_%s &_gPcd_FixedAtBuild_%s\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
} else {
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName);
hAutogenStr += String.format("#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
}
}
break;
case PATCHABLE_IN_MODULE:
@ -280,17 +299,29 @@ public class UsageInstance {
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
parentToken.cName,
datum.toString());
hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName);
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
hAutogenStr += String.format("#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
if (isByteArray) {
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[] = _PCD_VALUE_%s;\r\n",
parentToken.cName,
parentToken.cName);
hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",
parentToken.cName);
hAutogenStr += String.format("#define _PCD_MODE_%s_%s &_gPcd_BinaryPatch_%s\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
} else {
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName);
hAutogenStr += String.format("#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
}
}
break;