\r
import java.io.File;\r
import java.io.IOException;\r
-import java.math.BigInteger;\r
import java.util.ArrayList;\r
import java.util.Iterator;\r
import java.util.List;\r
**/\r
public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreprocessAction {\r
///\r
- /// FPD file is the root file.\r
+ /// FPD file path.\r
///\r
private String fpdFilePath;\r
\r
/**\r
Common function interface for outer.\r
\r
- @param fpdFilePath The fpd file path of current build or analysis.\r
+ @param fpdFilePath The fpd file path of current build or processing.\r
@param messageLevel The message level for this Action.\r
\r
@throws PlatformPreprocessBuildException \r
**/\r
public void perform(String fpdFilePath, int messageLevel) \r
throws PlatformPcdPreprocessBuildException {\r
- setFPDFilePath(fpdFilePath);\r
+ this.fpdFilePath = fpdFilePath;\r
setActionMessageLevel(messageLevel);\r
checkParameter();\r
execute();\r
try {\r
genPcdDatabaseSourceCode ();\r
} catch (EntityException exp) {\r
- throw new PlatformPcdPreprocessBuildException(errorMessageHeader + exp.getMessage());\r
+ throw new PlatformPcdPreprocessBuildException(errorMessageHeader + "\r\n" + exp.getMessage());\r
}\r
}\r
\r
\r
dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(),\r
tokenSpaceStrRet);\r
- if (dynamicPrimaryKey.equalsIgnoreCase(token.getPrimaryKeyString())) {\r
+ if (dynamicPrimaryKey.equals(token.getPrimaryKeyString())) {\r
return dynamicPcdBuildDataArray.get(index);\r
}\r
}\r
File file = null;\r
\r
if (fpdFilePath == null) {\r
- throw new PlatformPcdPreprocessBuildException("WorkspacePath and FPDFileName should be empty for CollectPCDAtion!");\r
+ throw new PlatformPcdPreprocessBuildException("FPDFileName should be empty for CollectPCDAtion!");\r
}\r
\r
if (fpdFilePath.length() == 0) {\r
- throw new PlatformPcdPreprocessBuildException("WorkspacePath and FPDFileName should be empty for CollectPCDAtion!");\r
+ throw new PlatformPcdPreprocessBuildException("FPDFileName should be empty for CollectPCDAtion!");\r
}\r
\r
file = new File(fpdFilePath);\r
throw new PlatformPcdPreprocessBuildException("FPD File " + fpdFilePath + " does not exist!");\r
}\r
}\r
-\r
- /**\r
- Test case function\r
-\r
- @param argv parameter from command line\r
- **/\r
- public static void main(String argv[]) throws PlatformPcdPreprocessBuildException {\r
- PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();\r
- String projectDir = "x:/edk2";\r
- ca.setFPDFilePath(projectDir + "/EdkNt32Pkg/Nt32.fpd");\r
- ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);\r
- GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",\r
- projectDir,\r
- "tools_def.txt");\r
- System.out.println("After initInfo!");\r
- FpdParserTask fpt = new FpdParserTask();\r
- fpt.parseFpdFile(new File(projectDir + "/EdkNt32Pkg/Nt32.fpd"));\r
- ca.execute();\r
- }\r
}\r
public PlatformPcdPreprocessAction() {\r
pcdDbManager = null;\r
errorString = null;\r
+ errorCount = 0;\r
}\r
\r
/**\r
public MemoryDatabaseManager getPcdDbManager() {\r
return pcdDbManager;\r
}\r
+\r
/**\r
Abstract function: retrieve module information from FPD file.\r
\r
In building environement, this function will be implementated by FpdParserTask.\r
\r
- @return List<ModuleInfo> the component array.\r
+ @return List<ModulePcdInfoFromFpd> the component array.\r
@throws PlatformPcdPreprocessException get all modules in <ModuleSA> in FPD file.\r
\r
**/\r
@throws PlatformPcdPreprocessException\r
Fail to get Guid information from SPD file.\r
**/\r
- public abstract String getGuidInfoFromSpd(String guidCName)\r
- throws PlatformPcdPreprocessException;\r
+ public abstract String getGuidInfoFromSpd(String guidCName) throws PlatformPcdPreprocessException;\r
\r
/**\r
Abstract function: Verification the PCD data.\r
@return String exception strings.\r
\r
**/\r
- public abstract String verifyDatum(String cName,\r
- String moduleName,\r
- String datum,\r
- Token.DATUM_TYPE datumType,\r
- int maxDatumSize);\r
+ public abstract String verifyDatum(String cName, String moduleName, String datum,\r
+ Token.DATUM_TYPE datumType, int maxDatumSize);\r
\r
/**\r
Abstract function: Get dynamic information for a token\r
**/\r
public void initPcdMemoryDbWithPlatformInfo()\r
throws PlatformPcdPreprocessException {\r
- int index = 0;\r
- int pcdIndex = 0;\r
+ int index;\r
+ int pcdIndex;\r
List<PcdBuildDefinition.PcdData> pcdBuildDataArray = new ArrayList<PcdBuildDefinition.PcdData>();\r
- PcdBuildDefinition.PcdData pcdBuildData = null;\r
+ PcdBuildDefinition.PcdData pcdBuildData;\r
Token token = null;\r
- List<ModulePcdInfoFromFpd> modules = null;\r
- String primaryKey = null;\r
- String exceptionString = null;\r
- UsageInstance usageInstance = null;\r
+ List<ModulePcdInfoFromFpd> modules;\r
+ String primaryKey;\r
+ String exceptionString;\r
+ UsageInstance usageInstance;\r
Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN;\r
Token.DATUM_TYPE datumType = Token.DATUM_TYPE.UNKNOWN;\r
- long tokenNumber = 0;\r
- String moduleName = null;\r
- String datum = null;\r
- int maxDatumSize = 0;\r
- String tokenSpaceStrRet = null;\r
+ long tokenNumber;\r
+ String moduleName;\r
+ String datum;\r
+ int maxDatumSize;\r
+ String tokenSpaceStrRet;\r
+ ModulePcdInfoFromFpd curModule;\r
\r
//\r
// ----------------------------------------------\r
// -------------------------------------------------------------------\r
//\r
for (index = 0; index < modules.size(); index++) {\r
- //\r
+ curModule = modules.get(index);\r
+\r
+ //\r
// It is legal for a module does not contains ANY pcd build definitions.\r
//\r
- if (modules.get(index).pcdBuildDefinition == null) {\r
+ if (curModule.pcdBuildDefinition == null) {\r
continue;\r
}\r
\r
- pcdBuildDataArray = modules.get(index).pcdBuildDefinition.getPcdDataList();\r
-\r
- moduleName = modules.get(index).usageId.moduleName;\r
+ pcdBuildDataArray = curModule.pcdBuildDefinition.getPcdDataList();\r
+ moduleName = curModule.usageId.moduleName;\r
\r
//\r
// ----------------------------------------------------------------------\r
// ------------------------------------------------\r
//\r
usageInstance = new UsageInstance(token,\r
- modules.get(index).usageId,\r
+ curModule.usageId,\r
pcdType,\r
datum,\r
maxDatumSize);\r
putError(String.format("PCD %s for module %s(%s) already exists in the database.\nPlease check all PCD build entries "+\r
"in the %s module's <ModuleSA> section to make sure there are no duplicated definitions in the FPD file!",\r
token.cName,\r
- modules.get(index).usageId.moduleGuid,\r
+ curModule.usageId.moduleGuid,\r
moduleName,\r
moduleName));\r
continue;\r
\r
switch (modulePcdType) {\r
case FEATURE_FLAG:\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "extern const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken";\r
+ // \r
hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",\r
parentToken.cName);\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_FixedAtBuild_PcdSampleToken";\r
+ // \r
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
parentToken.cName);\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "//#define _PCD_SET_MODE_8_PcdSampleToken ASSERT(FALSE) If is not allowed to set value...";\r
+ // \r
hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) If is not allowed to set value for a FEATURE_FLAG PCD\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName);\r
\r
if (!isBuildUsedLibrary) {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_VALUE_PcdSampleToken 0x1000"\r
+ // \r
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r
parentToken.cName,\r
printDatum);\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken = _PCD_VALUE_PcdSampleToken;"\r
+ // \r
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
parentToken.cName,\r
parentToken.cName);\r
break;\r
case FIXED_AT_BUILD:\r
if (isByteArray) {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "extern const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken";\r
+ // \r
hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",\r
parentToken.cName);\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_GET_MODE_8_PcdSampleToken (VOID*)_gPcd_FixedAtBuild_PcdSampleToken";\r
+ // \r
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
parentToken.cName);\r
} else {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "extern const UINT8 _gPcd_FixedAtBuild_PcdSampleToken";\r
+ // \r
hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
Token.getAutogendatumTypeString(parentToken.datumType),\r
parentToken.cName);\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_FixedAtBuild_PcdSampleToken";\r
+ // \r
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
parentToken.cName);\r
}\r
\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "//#define _PCD_SET_MODE_8_PcdSampleToken ASSERT(FALSE) If is not allowed to set value...";\r
+ // \r
hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName);\r
if (!isBuildUsedLibrary) {\r
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
if (isByteArray) {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_VALUE_PcdSampleToken (VOID*)_gPcd_FixedAtBuild_PcdSampleToken"\r
+ // \r
hAutogenStr += String.format("#define _PCD_VALUE_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r
parentToken.cName,\r
parentToken.cName);\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = 'dfdf';"\r
+ // \r
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",\r
parentToken.cName,\r
printDatum);\r
} else {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_VALUE_PcdSampleToken 0x222"\r
+ // \r
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r
parentToken.cName,\r
printDatum);\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+ // \r
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
Token.getAutogendatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
parentToken.cName);\r
}\r
} else {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_VALUE_PcdSampleToken 0x222"\r
+ // \r
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r
parentToken.cName,\r
printDatum);\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+ // \r
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
Token.getAutogendatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
break;\r
case PATCHABLE_IN_MODULE:\r
if (isByteArray) {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken[];"\r
+ // \r
hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",\r
parentToken.cName);\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_GET_MODE_8_PcdSampleToken (VOID*)_gPcd_BinaryPatch_PcdSampleToken"\r
+ // \r
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_BinaryPatch_%s\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
parentToken.cName);\r
} else {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken;"\r
+ // \r
hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
Token.getAutogendatumTypeString(parentToken.datumType),\r
parentToken.cName);\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_BinaryPatch_PcdSampleToken"\r
+ // \r
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
// Generate _PCD_SET_MODE_xx macro for using set BinaryPatch value via PcdSet macro\r
//\r
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_PcdSampleToken, (Buffer), (SizeOfBuffer))"\r
+ // \r
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_%s, (Buffer), (SizeOfBuffer))\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
parentToken.cName);\r
} else {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) (_gPcd_BinaryPatch_PcdSampleToken = (Value))"\r
+ // \r
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) (_gPcd_BinaryPatch_%s = (Value))\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
}\r
\r
if (!isBuildUsedLibrary) {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_VALUE_PcdSampleToken 0x111"\r
+ // \r
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r
parentToken.cName,\r
printDatum);\r
if (isByteArray) {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+ // \r
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[] = _PCD_VALUE_%s;\r\n",\r
parentToken.cName,\r
parentToken.cName);\r
} else {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+ // \r
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",\r
Token.getAutogendatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
\r
break;\r
case DYNAMIC:\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_GET_MODE_8_PcdSampleToken LibPcdGet%s(_PCD_TOKEN_PcdSampleToken)"\r
+ // \r
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGet%s(_PCD_TOKEN_%s)\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
parentToken.cName);\r
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r
+ // \r
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSet%s(_PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
parentToken.cName);\r
} else {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (Value))"\r
+ // \r
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSet%s(_PCD_TOKEN_%s, (Value))\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
guidStringCName = "_gPcd_TokenSpaceGuid_" +\r
parentToken.tokenSpaceName.toString().replaceAll("-", "_");\r
\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_GET_MODE_8_PcdSampleToken LibPcdGetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken)"\r
+ // \r
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
parentToken.cName);\r
\r
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r
+ // \r
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r
guidStringCName,\r
parentToken.cName);\r
} else {\r
+ //\r
+ // Example autogen string for following generation:\r
+ // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (Value))"\r
+ //\r
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (Value))\r\n",\r
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
parentToken.cName,\r