package org.tianocore.build.pcd.entity;\r
\r
\r
+import java.util.UUID;\r
+import org.tianocore.ModuleTypeDef;\r
import org.tianocore.build.pcd.exception.EntityException;\r
-import org.tianocore.build.pcd.action.ActionMessage;\r
-\r
-import org.tianocore.build.autogen.CommonDefinition;\r
\r
/**\r
This class indicate an usage instance for a PCD token. This instance maybe a module\r
is an usage instance for this PCD token.\r
**/\r
public class UsageInstance {\r
- ///\r
- /// This parent that this usage instance belongs to.\r
- ///\r
- public Token parentToken;\r
- ///\r
- /// The usage of this token for platform or module.\r
- ///\r
- public Token.PCD_USAGE usage;\r
- ///\r
- /// Whether this usage instance inherit from library\r
- ///\r
- public boolean isInherit;\r
- ///\r
- /// The pcd type of this token for module.\r
- ///\r
- public Token.PCD_TYPE modulePcdType;\r
- ///\r
- /// The name of the module who contains this PCD.\r
- ///\r
- public String moduleName;\r
- ///\r
- /// The name of the package whose module contains this PCD.\r
- ///\r
- public String packageName;\r
- ///\r
- /// The component type for this usage instance.\r
- ///\r
- public int componentType;\r
- ///\r
- /// The default value defined in MSA has high prior than defined in SPD.\r
- ///\r
- public Object defaultValueInMSA;\r
- ///\r
- /// The default value defined in SPD.\r
- ///\r
- public Object defaultValueInSPD;\r
- ///\r
- /// Help text in MSA\r
- ///\r
- public String helpTextInMSA;\r
- ///\r
- /// Help text in SPD\r
- ///\r
- public String helpTextInSPD;\r
- ///\r
- /// Autogen string for header file.\r
- ///\r
- public String hAutogenStr;\r
- /**\r
- * Auotgen string for C code file.\r
- */\r
- public String cAutogenStr;\r
-\r
- /**\r
- Constructure function\r
- \r
- @param parentToken Member variable.\r
- @param usage Member variable.\r
- @param pcdType Member variable.\r
- @param componentType Member variable.\r
- @param defaultValueInMSA Member variable.\r
- @param defaultValueInSPD Member variable.\r
- @param helpTextInMSA Member variable.\r
- @param helpTextInSPD Member variable.\r
- @param moduleName Member variable.\r
- @param packageName Member variable.\r
- @param isInherit Member variable.\r
- **/\r
- public UsageInstance(\r
- Token parentToken,\r
- Token.PCD_USAGE usage,\r
- Token.PCD_TYPE pcdType,\r
- int componentType,\r
- Object defaultValueInMSA,\r
- Object defaultValueInSPD,\r
- String helpTextInMSA,\r
- String helpTextInSPD,\r
- String moduleName,\r
- String packageName,\r
- boolean isInherit\r
- )\r
- {\r
- this.parentToken = parentToken;\r
- this.usage = usage;\r
- this.modulePcdType = pcdType;\r
- this.componentType = componentType;\r
- this.defaultValueInMSA = defaultValueInMSA;\r
- this.defaultValueInSPD = defaultValueInSPD;\r
- this.helpTextInMSA = helpTextInMSA;\r
- this.helpTextInSPD = helpTextInSPD;\r
- this.moduleName = moduleName;\r
- this.packageName = packageName;\r
- this.isInherit = isInherit;\r
- }\r
+ ///\r
+ /// This parent that this usage instance belongs to.\r
+ ///\r
+ public Token parentToken;\r
+\r
+ ///\r
+ /// The name of the module who contains this PCD.\r
+ ///\r
+ public String moduleName;\r
+\r
+ ///\r
+ /// The GUID of the module who contains this PCD. \r
+ /// \r
+ public UUID moduleGUID;\r
+\r
+ ///\r
+ /// The name of the package whose module contains this PCD.\r
+ ///\r
+ public String packageName;\r
+\r
+ ///\r
+ /// The GUID of the package whose module contains this PCD.\r
+ /// \r
+ public UUID packageGUID;\r
+\r
+ ///\r
+ /// The PCD type defined for module \r
+ /// \r
+ public Token.PCD_TYPE modulePcdType;\r
+\r
+ ///\r
+ /// The arch string of module contains this PCD\r
+ ///\r
+ public String arch;\r
+\r
+ ///\r
+ /// The version of module contains this PCD\r
+ /// \r
+ public String version;\r
+\r
+ ///\r
+ /// The module type for this usage instance.\r
+ ///\r
+ public ModuleTypeDef.Enum moduleType;\r
+\r
+ ///\r
+ /// The value of the PCD in this usage instance. \r
+ /// \r
+ public String datum;\r
+\r
+ ///\r
+ /// The maxDatumSize could be different for same PCD in different module\r
+ /// But this case is allow for FeatureFlag, FixedAtBuild, PatchableInModule\r
+ /// type.\r
+ /// \r
+ public int maxDatumSize;\r
\r
- /**\r
- Generate autogen string for header file and C code file.\r
- \r
- @throws EntityException Fail to generate.\r
- **/\r
- public void generateAutoGen() throws EntityException {\r
- Object value = null;\r
- int tokenNumber = 0;\r
-\r
- hAutogenStr = "";\r
- cAutogenStr = "";\r
-\r
- value = this.parentToken.datum;\r
-\r
- //\r
- // If this pcd token's PCD_TYPE is DYNAMIC_EX, use itself token space name \r
- // otherwices use assgined token space name from tool automatically.\r
- //\r
- if(parentToken.pcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
- tokenNumber = parentToken.tokenNumber;\r
- } else {\r
- tokenNumber = parentToken.assignedtokenNumber;\r
+ ///\r
+ /// Autogen string for header file.\r
+ ///\r
+ public String hAutogenStr;\r
+\r
+ ///\r
+ /// Auotgen string for C code file.\r
+ /// \r
+ public String cAutogenStr;\r
+\r
+ /**\r
+ Constructure function\r
+ \r
+ @param parentToken Member variable.\r
+ @param moduleName Member variable.\r
+ @param moduleGUID Member variable.\r
+ @param packageName Member variable.\r
+ @param packageGUID Member variable.\r
+ @param moduleType Member variable.\r
+ @param modulePcdType Member variable.\r
+ @param arch Member variable.\r
+ @param version Member variable.\r
+ @param value Member variable.\r
+ @param maxDatumSize Member variable.\r
+ */\r
+ public UsageInstance (Token parentToken,\r
+ String moduleName,\r
+ UUID moduleGUID,\r
+ String packageName,\r
+ UUID packageGUID,\r
+ ModuleTypeDef.Enum moduleType,\r
+ Token.PCD_TYPE modulePcdType,\r
+ String arch,\r
+ String version,\r
+ String value,\r
+ int maxDatumSize) {\r
+ this.parentToken = parentToken;\r
+ this.moduleName = moduleName;\r
+ this.moduleGUID = moduleGUID;\r
+ this.packageName = packageName;\r
+ this.packageGUID = packageGUID;\r
+ this.moduleType = moduleType;\r
+ this.modulePcdType = modulePcdType;\r
+ this.arch = arch;\r
+ this.version = version;\r
+ this.datum = value;\r
+ this.maxDatumSize = maxDatumSize;\r
}\r
\r
- hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%016x\r\n", \r
- parentToken.cName, tokenNumber);\r
+ /**\r
+ Get the primary key for usage instance array for every token.\r
+ \r
+ @param moduleName the name of module\r
+ @param moduleGUID the GUID name of module\r
+ @param packageName the name of package who contains this module\r
+ @param packageGUID the GUID name of package\r
+ @param arch the archtecture string\r
+ @param version the version of this module\r
+ \r
+ @return String primary key\r
+ */\r
+ public static String getPrimaryKey(String moduleName, \r
+ UUID moduleGUID, \r
+ String packageName, \r
+ UUID packageGUID,\r
+ String arch,\r
+ String version) {\r
+ //\r
+ // Because currently transition schema not require write moduleGuid, package Name, Packge GUID in\r
+ // <ModuleSA> section, So currently no expect all paramter must be valid.\r
+ return(moduleName + "_" +\r
+ ((moduleGUID != null) ? moduleGUID.toString() : "NullModuleGuid") + "_" +\r
+ ((packageName != null) ? packageName : "NullPackageName") + "_" +\r
+ ((packageGUID != null) ? packageGUID.toString() : "NullPackageGuid") + "_" +\r
+ ((arch != null) ? arch : "NullArch") + "_" +\r
+ ((version != null) ? version : "NullVersion"));\r
+ }\r
\r
- switch(modulePcdType) {\r
- case FEATURE_FLAG:\r
- //\r
- // BUGBUG: The judegement of module PCD type and platform PCD type should not be \r
- // done here, but in wizard tools, But here is just following something \r
- // PcdEmulation driver. \r
- //\r
- if(parentToken.pcdType.ordinal() > Token.PCD_TYPE.FEATURE_FLAG.ordinal()) {\r
- throw new EntityException(\r
- String.format(\r
- "%s:Platform PCD Type %d is not compatible with Module PCD Type %d\r\n",\r
- parentToken.cName,\r
- parentToken.pcdType.name(),\r
- modulePcdType.name()\r
- )\r
- );\r
- }\r
+ /**\r
+ Get primary key string for this usage instance\r
+ \r
+ @return String primary key string\r
+ **/\r
+ public String getPrimaryKey() {\r
+ return UsageInstance.getPrimaryKey(moduleName, moduleGUID, packageName, packageGUID, arch, version);\r
+ }\r
\r
- if(CommonDefinition.isLibraryComponent(componentType)) {\r
- hAutogenStr += String.format(\r
- "extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", \r
- parentToken.cName\r
- );\r
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
- parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- } else {\r
- hAutogenStr += String.format(\r
- "#define _PCD_VALUE_%s %s\r\n", \r
- parentToken.cName, \r
- value.toString()\r
- );\r
- hAutogenStr += String.format(\r
- "extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", \r
- parentToken.cName\r
- );\r
- cAutogenStr += String.format(\r
- "GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- }\r
- break;\r
- case FIXED_AT_BUILD:\r
+ /**\r
+ Judget whether current module is PEI driver\r
+ \r
+ @return boolean\r
+ */\r
+ public boolean isPeiPhaseComponent() {\r
+ if ((moduleType == ModuleTypeDef.PEI_CORE) ||\r
+ (moduleType == ModuleTypeDef.PEIM)) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+ \r
+ public boolean isDxePhaseComponent() {\r
//\r
- // BUGBUG: The judegement of module PCD type and platform PCD type should not be \r
- // done here, but in wizard tools, But here is just following something \r
- // PcdEmulation driver. \r
+ // BugBug: May need confirmation on which type of module can\r
+ // make use of Dynamic(EX) PCD entry.\r
//\r
- if(parentToken.pcdType.ordinal() > Token.PCD_TYPE.FIXED_AT_BUILD.ordinal()) {\r
- throw new EntityException(\r
- String.format(\r
- "%s:Platform PCD Type %d is not compatible with Module PCD Type %d\r\n",\r
- parentToken.cName,\r
- parentToken.pcdType.name(),\r
- modulePcdType.name()\r
- )\r
- );\r
+ if ((moduleType == ModuleTypeDef.DXE_DRIVER) ||\r
+ (moduleType == ModuleTypeDef.DXE_RUNTIME_DRIVER) ||\r
+ (moduleType == ModuleTypeDef.DXE_SAL_DRIVER) ||\r
+ (moduleType == ModuleTypeDef.DXE_SMM_DRIVER) ||\r
+ (moduleType == ModuleTypeDef.UEFI_DRIVER) ||\r
+ (moduleType == ModuleTypeDef.UEFI_APPLICATION)\r
+ ) {\r
+ return true;\r
}\r
+ return false;\r
+ }\r
\r
- if(CommonDefinition.isLibraryComponent(componentType)) {\r
- hAutogenStr += String.format(\r
- "extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName\r
- );\r
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- } else {\r
- hAutogenStr += String.format(\r
- "#define _PCD_VALUE_%s %s\r\n", \r
- parentToken.cName, \r
- value.toString()\r
- );\r
- hAutogenStr += String.format(\r
- "extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName\r
- );\r
- cAutogenStr += String.format(\r
- "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
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- }\r
- break;\r
- case PATCHABLE_IN_MODULE:\r
- //\r
- // BUGBUG: The judegement of module PCD type and platform PCD type should not be \r
- // done here, but in wizard tools, But here is just following something \r
- // PcdEmulation driver. \r
- //\r
- if(parentToken.pcdType.ordinal() > Token.PCD_TYPE.PATCHABLE_IN_MODULE.ordinal()) {\r
- throw new EntityException(\r
- String.format(\r
- "%s:Platform PCD Type %d is not compatible with Module PCD Type %d\r\n",\r
- parentToken.cName,\r
- parentToken.pcdType.name(),\r
- modulePcdType.name()\r
- )\r
- );\r
- }\r
+ /**\r
+ Generate autogen string for header file and C code file.\r
+ \r
+ @throws EntityException Fail to generate.\r
+ \r
+ @param isBuildUsedLibrary whether the autogen is for library.\r
+ */\r
+ public void generateAutoGen(boolean isBuildUsedLibrary) \r
+ throws EntityException {\r
+ String guidStringCName = null;\r
+ boolean isByteArray = false;\r
+ String printDatum = null;\r
\r
- if(CommonDefinition.isLibraryComponent(componentType)) {\r
- hAutogenStr += String.format(\r
- "extern %s _gPcd_BinaryPatch_%s;\r\n",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName\r
- );\r
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- } else {\r
- hAutogenStr += String.format(\r
- "#define _PCD_VALUE_%s %s\r\n", \r
- parentToken.cName, \r
- value\r
- );\r
- hAutogenStr += String.format(\r
- "extern %s _gPcd_BinaryPatch_%s;\r\n",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName\r
- );\r
- cAutogenStr += String.format(\r
- "GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- }\r
+ hAutogenStr = "";\r
+ cAutogenStr = "";\r
\r
- break;\r
- case DYNAMIC:\r
- //\r
- // BUGBUG: The judegement of module PCD type and platform PCD type should not be \r
- // done here, but in wizard tools, But here is just following something \r
- // PcdEmulation driver. \r
- //\r
- if(parentToken.pcdType.ordinal() > Token.PCD_TYPE.DYNAMIC.ordinal()) {\r
- throw new EntityException(\r
- String.format(\r
- "%s:Platform PCD Type %d is not compatible with Module PCD Type %d\r\n",\r
- parentToken.cName,\r
- parentToken.pcdType.name(),\r
- modulePcdType.name()\r
- )\r
- );\r
- }\r
- \r
- switch(parentToken.pcdType) {\r
+ if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
+ hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%016x\r\n", \r
+ parentToken.cName, parentToken.dynamicExTokenNumber);\r
+ } else {\r
+ hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%016x\r\n", \r
+ parentToken.cName, parentToken.tokenNumber);\r
+ }\r
+\r
+ if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {\r
+ if (datum.trim().charAt(0) == '{') {\r
+ isByteArray = true;\r
+ }\r
+ }\r
+\r
+ if (parentToken.datumType == Token.DATUM_TYPE.UINT64) {\r
+ printDatum = this.datum + "ULL";\r
+ } else {\r
+ printDatum = this.datum;\r
+ }\r
+\r
+ switch (modulePcdType) {\r
case FEATURE_FLAG:\r
- if(CommonDefinition.isLibraryComponent(componentType)) {\r
- hAutogenStr += String.format(\r
- "extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", \r
- parentToken.cName\r
- );\r
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- } else {\r
- hAutogenStr += String.format(\r
- "#define _PCD_VALUE_%s %s\r\n", \r
- parentToken.cName, \r
- value\r
- );\r
- hAutogenStr += String.format(\r
- "extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", \r
- parentToken.cName\r
- );\r
- cAutogenStr += String.format(\r
- "const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- }\r
- break;\r
+ hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", \r
+ parentToken.cName);\r
+ hAutogenStr += String.format("#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
+ parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+ parentToken.cName,\r
+ parentToken.cName);\r
+\r
+ if (!isBuildUsedLibrary) {\r
+ hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", \r
+ parentToken.cName, \r
+ printDatum);\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
+ }\r
+ break;\r
case FIXED_AT_BUILD:\r
- if(CommonDefinition.isLibraryComponent(componentType)) {\r
- hAutogenStr += String.format(\r
- "extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName\r
- );\r
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
-\r
- } else {\r
- hAutogenStr += String.format(\r
- "#define _PCD_VALUE_%s %s\r\n", \r
- parentToken.cName, \r
- value\r
- );\r
- hAutogenStr += String.format(\r
- "extern const %s _gPcd_FixedAtBuild_%s\r\n",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName\r
- );\r
- cAutogenStr += String.format(\r
- "const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- }\r
- break;\r
+ if (isByteArray) {\r
+ hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",\r
+ parentToken.cName);\r
+ hAutogenStr += String.format("#define _PCD_MODE_%s_%s &_gPcd_FixedAtBuild_%s\r\n", \r
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+ parentToken.cName,\r
+ parentToken.cName);\r
+ } else {\r
+ hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
+ Token.getAutogendatumTypeString(parentToken.datumType),\r
+ parentToken.cName);\r
+ hAutogenStr += String.format("#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n", \r
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+ parentToken.cName,\r
+ parentToken.cName);\r
+ }\r
+\r
+ if (!isBuildUsedLibrary) {\r
+ hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", \r
+ parentToken.cName, \r
+ printDatum);\r
+ if (isByteArray) {\r
+ cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = _PCD_VALUE_%s;\r\n",\r
+ parentToken.cName,\r
+ parentToken.cName);\r
+ } else {\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
+ }\r
+ break;\r
case PATCHABLE_IN_MODULE:\r
- hAutogenStr += String.format(\r
- "#define _PCD_VALUE_%s %s\r\n", \r
- parentToken.cName, \r
- value\r
- );\r
- hAutogenStr += String.format(\r
- "extern %s _gPcd_BinaryPatch_%s;\r\n",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- cAutogenStr += String.format(\r
- "%s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- hAutogenStr += String.format(\r
- "#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName\r
- );\r
- break;\r
+ if (isByteArray) {\r
+ hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",\r
+ parentToken.cName);\r
+ hAutogenStr += String.format("#define _PCD_MODE_%s_%s &_gPcd_BinaryPatch_%s\r\n",\r
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+ parentToken.cName,\r
+ parentToken.cName); \r
+ } else {\r
+ hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
+ Token.getAutogendatumTypeString(parentToken.datumType),\r
+ parentToken.cName);\r
+ hAutogenStr += String.format("#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",\r
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+ parentToken.cName,\r
+ parentToken.cName); \r
+ }\r
+\r
+ if (!isBuildUsedLibrary) {\r
+ hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", \r
+ parentToken.cName, \r
+ printDatum);\r
+ if (isByteArray) {\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
+ 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
+ parentToken.cName);\r
+ }\r
+ }\r
+\r
+ break;\r
case DYNAMIC:\r
- hAutogenStr += String.format(\r
- "#define _PCD_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
- );\r
- break;\r
- default:\r
- ActionMessage.log(\r
- this, \r
- "The PCD_TYPE setted by platform is unknown"\r
- );\r
- }\r
- break;\r
- case DYNAMIC_EX:\r
- break;\r
+ hAutogenStr += String.format("#define _PCD_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
+ break;\r
+ case DYNAMIC_EX:\r
+ guidStringCName = "_gPcd_TokenSpaceGuid_" +\r
+ parentToken.tokenSpaceName.toString().replaceAll("-", "_");\r
+ \r
+ hAutogenStr += String.format("#define _PCD_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n",\r
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+ parentToken.cName,\r
+ Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
+ guidStringCName,\r
+ parentToken.cName);\r
+\r
+ break;\r
+ }\r
}\r
- }\r
\r
- /**\r
- Get the autogen string for header file.\r
- \r
- @return The string of header file.\r
- **/\r
- public String getHAutogenStr() {\r
- return hAutogenStr;\r
- }\r
+ /**\r
+ Get the autogen string for header file.\r
+ \r
+ @return The string of header file.\r
+ **/\r
+ public String getHAutogenStr() {\r
+ return hAutogenStr;\r
+ }\r
\r
- /**\r
- Get the autogen string for C code file.\r
- \r
- @return The string of C Code file.\r
- **/\r
- public String getCAutogenStr() {\r
- return cAutogenStr;\r
- }\r
+ /**\r
+ Get the autogen string for C code file.\r
+ \r
+ @return The string of C Code file.\r
+ **/\r
+ public String getCAutogenStr() {\r
+ return cAutogenStr;\r
+ }\r
}\r
\r