<Filename>org/tianocore/build/id/PlatformIdentification.java</Filename>\r
<Filename>org/tianocore/build/ModuleBuildFileGenerator.java</Filename>\r
<Filename>org/tianocore/build/OutputDirSetup.java</Filename>\r
- <Filename>org/tianocore/build/pcd/action/ActionMessage.java</Filename>\r
- <Filename>org/tianocore/build/pcd/action/BuildAction.java</Filename>\r
<Filename>org/tianocore/build/pcd/action/CollectPCDAction.java</Filename>\r
<Filename>org/tianocore/build/pcd/action/PCDAutoGenAction.java</Filename>\r
- <Filename>org/tianocore/build/pcd/action/ShowPCDDatabaseAction.java</Filename>\r
- <Filename>org/tianocore/build/pcd/action/UIAction.java</Filename>\r
- <Filename>org/tianocore/build/pcd/entity/DynamicTokenValue.java</Filename>\r
- <Filename>org/tianocore/build/pcd/entity/MemoryDatabaseManager.java</Filename>\r
- <Filename>org/tianocore/build/pcd/entity/SkuInstance.java</Filename>\r
- <Filename>org/tianocore/build/pcd/entity/Token.java</Filename>\r
- <Filename>org/tianocore/build/pcd/entity/UsageInstance.java</Filename>\r
- <Filename>org/tianocore/build/pcd/exception/BuildActionException.java</Filename>\r
- <Filename>org/tianocore/build/pcd/exception/EntityException.java</Filename>\r
- <Filename>org/tianocore/build/pcd/exception/UIException.java</Filename>\r
- <Filename>org/tianocore/build/pcd/ui/PCDDatabaseFrame.java</Filename>\r
<Filename>org/tianocore/build/toolchain/ConfigReader.java</Filename>\r
<Filename>org/tianocore/build/toolchain/ToolChainAttribute.java</Filename>\r
<Filename>org/tianocore/build/toolchain/ToolChainConfig.java</Filename>\r
<path id="classpath">\r
<fileset dir="${WORKSPACE}/Tools/Jars" includes="SurfaceArea.jar"/>\r
<fileset dir="${WORKSPACE}/Tools/Jars" includes="Common.jar"/>\r
+ <fileset dir="${WORKSPACE}/Tools/Jars" includes="PcdTools.jar"/>\r
<fileset dir="${env.XMLBEANS_HOME}/lib" includes="*.jar"/>\r
</path>\r
<property name="buildDir" value="build"/>\r
import org.tianocore.build.id.FpdModuleIdentification;\r
import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.id.PlatformIdentification;\r
-import org.tianocore.build.pcd.action.ActionMessage;\r
+import org.tianocore.pcd.action.ActionMessage;\r
import org.tianocore.build.pcd.action.CollectPCDAction;\r
import org.tianocore.build.toolchain.ToolChainAttribute;\r
import org.tianocore.build.toolchain.ToolChainElement;\r
import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.id.PackageIdentification;\r
import org.tianocore.build.id.PlatformIdentification;\r
-import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r
+import org.tianocore.pcd.entity.MemoryDatabaseManager;\r
import org.tianocore.build.toolchain.ToolChainAttribute;\r
import org.tianocore.build.toolchain.ToolChainConfig;\r
import org.tianocore.build.toolchain.ToolChainElement;\r
+++ /dev/null
-/** @file\r
- ActionMessage class.\r
-\r
- ActionMessage class take over all message for loging and waning. This class should\r
- dispatch message into different class according to instance class type.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-package org.tianocore.build.pcd.action;\r
-\r
-import org.apache.tools.ant.Task;\r
-import org.tianocore.build.pcd.action.BuildAction;\r
-\r
-/** ActionMessage class take over all message for loging and waning. This class \r
- should dispatch message into different Action class according to instance \r
- class type.\r
-**/\r
-public class ActionMessage {\r
- ///\r
- /// Macro definition for NULL messge level. \r
- /// In this meessage level, all message will be hidden.\r
- ///\r
- public final static int NULL_MESSAGE_LEVEL = 0; \r
- ///\r
- /// Macro definition for Log messge level.\r
- /// In this message level, Only log information will be shown.\r
- ///\r
- public final static int LOG_MESSAGE_LEVEL = 1;\r
- ///\r
- /// Macro definition for Warning message level. \r
- /// In this message level, log and waning message will be shown.\r
- ///\r
- public final static int WARNING_MESSAGE_LEVEL = 2;\r
- ///\r
- /// Macro definition for Debug mesage level.\r
- /// In this message level, log, warning, debug message will be shown.\r
- ///\r
- public final static int DEBUG_MESSAGE_LEVEL = 3;\r
- ///\r
- /// Macor definition for MAX message level.\r
- /// In this message level, all message will be shown.\r
- ///\r
- public final static int MAX_MESSAGE_LEVEL = 4;\r
- ///\r
- /// Current message level. It will control all message output for PCD tool.\r
- ///\r
- public static int messageLevel = NULL_MESSAGE_LEVEL;\r
-\r
- /**\r
- Log() function provide common log information functionality for all \r
- PCD tool includes all function\r
-\r
- This function will dispatch message to special class such as BuildAction\r
- Class, Entity Class etc.\r
- \r
- @param thisClass The class object who want log information.\r
- @param logStr The string contains log information.\r
- **/\r
- public static void log(Object thisClass, String logStr) {\r
- if(messageLevel < LOG_MESSAGE_LEVEL) {\r
- return;\r
- }\r
-\r
- if(thisClass instanceof Task) {\r
- BuildAction.logMsg(thisClass, "$$LOG$$:" + logStr);\r
- } else {\r
- System.out.println("$$LOG$$:" + logStr);\r
- }\r
- }\r
-\r
- /**\r
- Warning() function provide common warning information functionality for all \r
- PCD tool.\r
-\r
- This function will dispatch message to special class such as BuildAction\r
- Class, Entity Class etc.\r
- \r
- @param thisClass The class object who want warn information.\r
- @param warningStr The string contains warning information.\r
- **/ \r
- public static void warning(Object thisClass, String warningStr) {\r
- if(messageLevel < WARNING_MESSAGE_LEVEL) {\r
- return;\r
- }\r
-\r
- if(thisClass instanceof Task) {\r
- BuildAction.warningMsg(thisClass, "**WARNING**:" + warningStr);\r
- } else {\r
- System.out.println("**WARNING**:" + warningStr);\r
- }\r
- }\r
-\r
- /**\r
- Debug() function provide common Debug information functionality for all \r
- PCD tool.\r
-\r
- This function will dispatch message to special class such as BuildAction\r
- Class, Entity Class etc.\r
- \r
- @param thisClass The class object who want Debug information.\r
- @param debugStr The string contains Debug information.\r
- **/ \r
- public static void debug(Object thisClass, String debugStr) {\r
- if(messageLevel < DEBUG_MESSAGE_LEVEL) {\r
- return;\r
- }\r
-\r
- if(thisClass instanceof Task) {\r
- BuildAction.logMsg(thisClass, "%%DEBUG%%:" + debugStr);\r
- } else {\r
- System.out.println("%%DEBUG%%:" + debugStr);\r
- }\r
- }\r
-}\r
+++ /dev/null
-/** @file\r
- BuildAction class.\r
-\r
- BuildAction is the parent class for all action related to ant Task. This class will\r
- define some common utility functionality, such as logMsg, warningMsg..etc.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-package org.tianocore.build.pcd.action;\r
-\r
-import org.apache.tools.ant.Task;\r
-import org.apache.tools.ant.Project;\r
-import org.tianocore.build.pcd.exception.BuildActionException;\r
-\r
-/** BuildAction is the parent class for all action related to ant Task. This class will\r
- define some common utility functionality, such as logMsg, warningMsg..etc.\r
-**/\r
-abstract class BuildAction extends Task {\r
- ///\r
- /// Original message level before this action. This value will \r
- /// be restored when quit this action.\r
- ///\r
- private int originalMessageLevel;\r
-\r
- /**\r
- checkParameter function check all parameter valid.\r
-\r
- This function will be overrided by child class.\r
- **/\r
- abstract void checkParameter() throws BuildActionException;\r
-\r
- /**\r
- performAction is to execute the detail action.\r
- \r
- This function will be overrided by child class.\r
- **/\r
- abstract void performAction() throws BuildActionException;\r
-\r
- /**\r
- setMessageLevel function set current message for task instance object.\r
-\r
- The message should be restored when this action exit.\r
-\r
- @param messageLevel The message level for this action.\r
- **/\r
- public void setMessageLevel(int messageLevel) {\r
- originalMessageLevel = ActionMessage.messageLevel;\r
- ActionMessage.messageLevel = messageLevel;\r
- }\r
-\r
- /**\r
- logMsg function provide common log information functionality for all \r
- PCD tool extends from ANT task class.\r
-\r
- This function will use the log function in Ant task class.\r
- \r
- @param action The class object who want log information.\r
- @param logStr The string contains log information.\r
- **/\r
- public static void logMsg(Object action, String logStr) {\r
- ((Task) action).log(logStr, Project.MSG_INFO);\r
- }\r
-\r
- /**\r
- warningMsg function provide common warning information functionality for all \r
- PCD tool.\r
-\r
- This function will dispatch message to special class such as BuildAction\r
- Class, Entity Class etc.\r
- \r
- @param action The class object who want warn information.\r
- @param warningStr The string contains warning information.\r
- **/ \r
- public static void warningMsg(Object action, String warningStr) {\r
- ((Task) action).log(warningStr, Project.MSG_WARN);\r
- }\r
-\r
- /**\r
- execute function is the main flow for all build action class.\r
-\r
- This workflow will be:\r
- 1) Check paramet of this action.\r
- 2) Perform the child class action function.\r
- 3) Restore the message level.\r
- \r
- @throws BuildActionException\r
- **/ \r
- public void execute() throws BuildActionException {\r
- checkParameter();\r
- performAction();\r
-\r
- //\r
- // Restore orignal message level when exist the action.\r
- //\r
- ActionMessage.messageLevel = originalMessageLevel;\r
- }\r
-}\r
import org.tianocore.PcdBuildDefinitionDocument;\r
import org.tianocore.PcdBuildDefinitionDocument.PcdBuildDefinition;\r
import org.tianocore.PlatformSurfaceAreaDocument;\r
-import org.tianocore.build.autogen.CommonDefinition;\r
import org.tianocore.build.fpd.FpdParserTask;\r
import org.tianocore.build.global.GlobalData;\r
import org.tianocore.build.id.FpdModuleIdentification;\r
-import org.tianocore.build.pcd.action.ActionMessage;\r
-import org.tianocore.build.pcd.entity.DynamicTokenValue;\r
-import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r
-import org.tianocore.build.pcd.entity.SkuInstance;\r
-import org.tianocore.build.pcd.entity.Token;\r
-import org.tianocore.build.pcd.entity.UsageInstance;\r
-import org.tianocore.build.pcd.exception.EntityException;\r
+import org.tianocore.build.id.ModuleIdentification;\r
+import org.tianocore.pcd.action.ActionMessage;\r
+import org.tianocore.pcd.entity.CommonDefinition;\r
+import org.tianocore.pcd.entity.DynamicTokenValue;\r
+import org.tianocore.pcd.entity.MemoryDatabaseManager;\r
+import org.tianocore.pcd.entity.SkuInstance;\r
+import org.tianocore.pcd.entity.Token;\r
+import org.tianocore.pcd.entity.UsageIdentification;\r
+import org.tianocore.pcd.entity.UsageInstance;\r
+import org.tianocore.pcd.exception.EntityException;\r
\r
/**\r
CStructTypeDeclaration \r
String datum = null;\r
int maxDatumSize = 0;\r
String[] tokenSpaceStrRet = null;\r
+ UsageIdentification usageId = null;\r
+ ModuleIdentification moduleId = null;\r
\r
//\r
// ----------------------------------------------\r
// 2.1.4), Create an usage instance for this token.\r
// ------------------------------------------------\r
// \r
+ moduleId = modules.get(index).getModuleId().getModule();\r
+ usageId = new UsageIdentification (moduleId.getName(), \r
+ moduleId.getGuid(), \r
+ moduleId.getPackage().getName(), \r
+ moduleId.getPackage().getGuid(), \r
+ modules.get(index).getModuleId().getArch(),\r
+ moduleId.getVersion(),\r
+ moduleId.getModuleType());\r
usageInstance = new UsageInstance(token, \r
- modules.get(index).getModuleId().getModule(), \r
+ usageId,\r
pcdType,\r
- modules.get(index).getModuleId().getArch(), \r
datum,\r
maxDatumSize);\r
token.addUsageInstance(usageInstance);\r
import org.tianocore.build.global.GlobalData;\r
import org.tianocore.build.global.SurfaceAreaQuery;\r
import org.tianocore.build.id.ModuleIdentification;\r
-import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r
-import org.tianocore.build.pcd.entity.Token;\r
-import org.tianocore.build.pcd.entity.UsageInstance;\r
-import org.tianocore.build.pcd.exception.BuildActionException;\r
-import org.tianocore.build.pcd.exception.EntityException;\r
+import org.tianocore.pcd.entity.MemoryDatabaseManager;\r
+import org.tianocore.pcd.entity.Token;\r
+import org.tianocore.pcd.entity.UsageInstance;\r
+import org.tianocore.pcd.exception.BuildActionException;\r
+import org.tianocore.pcd.exception.EntityException;\r
+import org.tianocore.pcd.entity.UsageIdentification;\r
+import org.tianocore.pcd.action.BuildAction;\r
+import org.tianocore.pcd.action.ActionMessage;\r
\r
/** This class is to manage how to generate the PCD information into Autogen.c and\r
Autogen.h.\r
///\r
private MemoryDatabaseManager dbManager;\r
///\r
- /// The identification for a module.\r
+ /// The identification for a UsageInstance.\r
/// \r
- private ModuleIdentification moduleId;\r
+ private UsageIdentification usageId;\r
///\r
/// The arch of current module\r
/// \r
\r
@param moduleName the module name parameter.\r
**/\r
- public void setModuleId(ModuleIdentification moduleId) {\r
- this.moduleId = moduleId;\r
- }\r
-\r
- /**\r
- set Arch parameter.\r
- \r
- @param arch\r
- **/\r
- public void setArch(String arch) {\r
- this.arch = arch;\r
+ public void setUsageId(UsageIdentification usageId) {\r
+ this.usageId = usageId;\r
}\r
\r
/**\r
String arch,\r
boolean isBuildUsedLibrary,\r
String[] pcdNameArrayInMsa) {\r
+ UsageIdentification usageId = new UsageIdentification(moduleId.getName(), \r
+ moduleId.getGuid(), \r
+ moduleId.getPackage().getName(), \r
+ moduleId.getPackage().getGuid(), \r
+ arch, \r
+ moduleId.getVersion(), \r
+ moduleId.getModuleType());\r
dbManager = null;\r
hAutoGenString = "";\r
cAutoGenString = "";\r
\r
- setModuleId(moduleId);\r
- setArch(arch);\r
+ setUsageId(usageId);\r
setIsBuildUsedLibrary(isBuildUsedLibrary);\r
setPcdNameArrayInMsa(pcdNameArrayInMsa);\r
}\r
\r
@throws BuildActionException Bad parameter.\r
**/\r
- void checkParameter() throws BuildActionException {\r
+ public void checkParameter() throws BuildActionException {\r
\r
}\r
\r
\r
@throws BuildActionException Failed to execute this aciton class.\r
**/\r
- void performAction() throws BuildActionException {\r
+ public void performAction() throws BuildActionException {\r
ActionMessage.debug(this, \r
"Starting PCDAutoGenAction to generate autogen.h and autogen.c!...");\r
//\r
String[] guidStringArray = null;\r
String guidStringCName = null;\r
String guidString = null;\r
- String moduleName = moduleId.getName();\r
+ String moduleName = usageId.moduleName;\r
UsageInstance usageInstance = null;\r
boolean found = false;\r
\r
usageInstanceArray = null;\r
if (!isBuildUsedLibrary) {\r
- usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleId, arch);\r
+ usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(usageId);\r
dbManager.UsageInstanceContext = usageInstanceArray;\r
dbManager.CurrentModuleName = moduleName; \r
} else if ((pcdNameArrayInMsa != null) && (pcdNameArrayInMsa.length > 0)) {\r
// these library should be used to autogen.\r
// \r
if (usageContext == null) {\r
- usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleId, arch);\r
+ usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(usageId);\r
} else {\r
usageInstanceArray = new ArrayList<UsageInstance>();\r
\r
+++ /dev/null
-/** @file\r
- DynamicTokenValue class.\r
-\r
- This module contains the value type of a dynamic token.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/ \r
-package org.tianocore.build.pcd.entity;\r
-\r
-import java.util.List;\r
-import java.util.UUID;\r
-\r
-import org.tianocore.build.pcd.exception.EntityException;\r
-\r
-/** This class is to descript a value type of dynamic PCD.\r
- For a dynamic or dynamicEx type PCD data, the value type can be:\r
- 1) Hii type: the value of dynamic or dynamicEx is stored into a variable.\r
- 2) Vpd type: the value of dynamic or dynamicEx is stored into somewhere set\r
- by OEM.\r
- 3) Default type: the value of dynamic or dynamicEx is stored into PCD dynamic\r
- database.\r
-**/\r
-public class DynamicTokenValue {\r
- ///\r
- /// Enumeration macro defintion for value type.\r
- /// BUGBUG: Not use upcase charater is to facility for reading. It may be changed\r
- /// in coding review.\r
- public enum VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE}\r
-\r
- public VALUE_TYPE type;\r
-\r
- ///\r
- /// ---------------------------------------------------------------------\r
- /// Following member is for HII case.\r
- /// ---------------------------------------------------------------------\r
- ///\r
-\r
- ///\r
- /// variableName is valid only when this token support Hii functionality. variableName\r
- /// indicates the value of token is associated with what variable.\r
- /// variableName is defined in FPD.\r
- public List variableName;\r
-\r
- ///\r
- /// variableGuid is the GUID this token associated with.\r
- ///\r
- public UUID variableGuid;\r
-\r
- ///\r
- /// Variable offset indicate the associated variable's offset in NV storage.\r
- ///\r
- public String variableOffset;\r
-\r
- ///\r
- /// The default value for HII case.\r
- /// \r
- public String hiiDefaultValue;\r
-\r
- ///\r
- /// Following member is for VPD case.\r
- /// BUGBUG: Consider 64 bit integer by using java.math.BigInteger.\r
- /// \r
- public String vpdOffset;\r
-\r
- ///\r
- /// Following member is for default case.\r
- /// \r
- public String value;\r
-\r
- public DynamicTokenValue() {\r
- this.type = VALUE_TYPE.DEFAULT_TYPE;\r
- this.variableName = null;\r
- this.variableGuid = null;\r
- this.variableOffset = null;\r
- this.hiiDefaultValue = null;\r
-\r
- this.vpdOffset = null;\r
-\r
- this.value = null;\r
- }\r
-\r
- /**\r
- Set the HII case data.\r
- \r
- @param variableName\r
- @param variableGuid\r
- @param variableOffset\r
- @param hiiDefaultValue\r
- */\r
- public void setHiiData(List variableName,\r
- UUID variableGuid,\r
- String variableOffset,\r
- String hiiDefaultValue) {\r
- this.type = VALUE_TYPE.HII_TYPE;\r
-\r
- this.variableName = variableName;\r
- this.variableGuid = variableGuid;\r
- this.variableOffset = variableOffset;\r
- this.hiiDefaultValue = hiiDefaultValue;\r
- }\r
-\r
- /**\r
- Get the string like L"xxx" for a variable Name.\r
- \r
- BUGBUG: In fact, it is not correctly, variable name should be\r
- treated as unicode UINT16 array.\r
- \r
- @return String\r
- */\r
- public String getStringOfVariableName() \r
- throws EntityException {\r
- String str;\r
- int index, num;\r
- char ch;\r
-\r
- str = "";\r
- for (index = 0; index < variableName.size(); index ++) {\r
- num = Integer.decode(variableName.get(index).toString());\r
- if ((num > 127 ) || (num < 0)) {\r
- throw new EntityException(String.format("variable name contains >0x80 character, now is not support!"));\r
- }\r
- str += (char)num;\r
- }\r
-\r
- return str;\r
- }\r
-\r
- /**\r
- Set Vpd case data.\r
- \r
- @param vpdOffset\r
- */\r
- public void setVpdData(String vpdOffset) {\r
- this.type = VALUE_TYPE.VPD_TYPE;\r
-\r
- this.vpdOffset = vpdOffset;\r
- }\r
-\r
- /**\r
- Set default case data.\r
- \r
- @param value\r
- */\r
- public void setValue(String value) {\r
- this.type = VALUE_TYPE.DEFAULT_TYPE;\r
-\r
- this.value = value;\r
- }\r
-}\r
-\r
-\r
-\r
-\r
-\r
+++ /dev/null
-/** @file\r
- MemoryDatabaseManager class.\r
-\r
- Database hold all PCD information comes from SPD, MSA, FPD file in memory.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-package org.tianocore.build.pcd.entity;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.UUID;\r
-\r
-import org.tianocore.build.id.ModuleIdentification;\r
-import org.tianocore.build.pcd.exception.EntityException;\r
-\r
-/** Database hold all PCD information comes from SPD, MSA, FPD file in memory.\r
-**/\r
-public class MemoryDatabaseManager {\r
- ///\r
- /// Memory database. The string "cName + SpaceNameGuid" is primary key.\r
- /// memory database is in global scope, and it will be used for others PCD tools.\r
- ///\r
- private static Map<String, Token> memoryDatabase = null;\r
-\r
- ///\r
- /// Before build a module, the used libary will be build firstly, the PCD of these\r
- /// libarry is inheritted by the module, so stored module's PCD information as PCD\r
- /// context of building libary.\r
- /// \r
- public static List<UsageInstance> UsageInstanceContext = null;\r
-\r
- ///\r
- /// Current module name, if now is buiding library, this value indicate this library\r
- /// is for building what module.\r
- /// \r
- public static String CurrentModuleName = null;\r
-\r
- ///\r
- /// String for PCD PEIM and DXE autogen file\r
- /// \r
- public static String PcdPeimHString = "";\r
- public static String PcdPeimCString = "";\r
- public static String PcdDxeHString = "";\r
- public static String PcdDxeCString = "";\r
-\r
- /**\r
- Constructure function\r
- **/\r
- public MemoryDatabaseManager() {\r
- //\r
- // Allocate memory for new database in global scope.\r
- //\r
- if (memoryDatabase == null) {\r
- memoryDatabase = new HashMap<String, Token>();\r
- }\r
- }\r
-\r
- /**\r
- Judege whether token exists in memory database\r
- \r
- @param primaryKey the primaryKey for searching token\r
- \r
- @retval TRUE - token already exist in database.\r
- @retval FALSE - token does not exist in database.\r
- **/\r
- public boolean isTokenInDatabase(String primaryKey) {\r
- return (memoryDatabase.get(primaryKey) != null);\r
- }\r
-\r
- /**\r
- Add a pcd token into memory database.\r
- \r
- @param primaryKey the primary key for searching token\r
- @param token token instance\r
- **/\r
- public void addTokenToDatabase(String primaryKey, Token token) {\r
- memoryDatabase.put(primaryKey, token);\r
- }\r
-\r
- /**\r
- Get a token instance from memory database with primary key.\r
- \r
- @param primaryKey the primary key for searching token\r
- \r
- @return token instance.\r
- **/\r
- public Token getTokenByKey(String primaryKey) {\r
- return memoryDatabase.get(primaryKey);\r
- }\r
-\r
- /**\r
- Get the number of PCD token record in memory database.\r
- \r
- @return the number of PCD token record in memory database.\r
- **/\r
- public int getDBSize() {\r
- return memoryDatabase.size();\r
- }\r
-\r
- /**\r
- Get the token record array contained all PCD token in memory database.\r
- \r
- @return the token record array contained all PCD token in memory database.\r
- **/\r
- public Token[] getRecordArray() {\r
- Token[] tokenArray = null;\r
- Object[] dataArray = null;\r
- Map.Entry entry = null;\r
- int index = 0;\r
-\r
- if (memoryDatabase == null) {\r
- return null;\r
- }\r
-\r
- dataArray = memoryDatabase.entrySet().toArray();\r
- tokenArray = new Token[memoryDatabase.size()];\r
- for (index = 0; index < memoryDatabase.size(); index ++) {\r
- entry =(Map.Entry) dataArray [index];\r
- tokenArray[index] =(Token) entry.getValue();\r
- }\r
-\r
- return tokenArray;\r
- }\r
-\r
- /**\r
- Get record array only contains DYNAMIC or DYNAMIC_EX type PCD.\r
- \r
- @return ArrayList\r
- */\r
- private ArrayList getDynamicRecordArray() {\r
- Token[] tokenArray = getRecordArray();\r
- int index = 0;\r
- ArrayList<Token> al = new ArrayList<Token>();\r
-\r
- for (index = 0; index < tokenArray.length; index++) {\r
- if (tokenArray[index].isDynamicPCD) {\r
- al.add(tokenArray[index]);\r
- }\r
- }\r
-\r
- return al;\r
- }\r
-\r
-\r
- /**\r
- Get the token record array contained all PCD token referenced by PEI phase.\r
- The output array is sorted based on descending order of the size of alignment for each feilds.\r
-\r
- @return the token record array contained all PCD token referenced in PEI phase.\r
- @throws EntityException\r
- **/\r
- public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe) \r
- throws EntityException {\r
- int usageInstanceIndex = 0;\r
- int index = 0;\r
- ArrayList tokenArrayList = getDynamicRecordArray();\r
- Object[] usageInstanceArray = null;\r
- UsageInstance usageInstance = null;\r
-\r
- //pei = new ArrayList<Token>();\r
- //dxe = new ArrayList<Token>();\r
-\r
- for (index = 0; index < tokenArrayList.size(); index++) {\r
- boolean found = false;\r
- Token token = (Token) tokenArrayList.get(index);\r
- if (token.consumers != null) {\r
- usageInstanceArray = token.consumers.entrySet().toArray();\r
- for (usageInstanceIndex = 0; usageInstanceIndex < token.consumers.size(); usageInstanceIndex ++) {\r
- usageInstance =(UsageInstance) (((Map.Entry)usageInstanceArray[usageInstanceIndex]).getValue());\r
- if (usageInstance.isPeiPhaseComponent()) {\r
- pei.add(token);\r
- found = true;\r
- break;\r
- }\r
- }\r
- }\r
-\r
- //\r
- // If no PEI components reference the PCD entry, \r
- // we check if it is referenced in DXE driver. \r
- //\r
- if (!found) {\r
- if (token.consumers != null) {\r
- usageInstanceArray = token.consumers.entrySet().toArray();\r
- for (usageInstanceIndex = 0; usageInstanceIndex < token.consumers.size(); usageInstanceIndex ++) {\r
- usageInstance =(UsageInstance) (((Map.Entry)usageInstanceArray[usageInstanceIndex]).getValue());\r
- if (usageInstance.isDxePhaseComponent()) {\r
- dxe.add(token);\r
- found = true;\r
- break;\r
- }\r
- }\r
- }\r
- \r
- if (!found) {\r
- if (token.isDynamicPCD && token.consumers.size() == 0) {\r
- dxe.add(token);\r
- } else {\r
- //\r
- // We only support Dynamice(EX) type for PEI and DXE phase.\r
- // If it is not referenced in either PEI or DXE, throw exception now.\r
- //\r
- throw new EntityException("[PCD tool Internal Error] Dynamic(EX) PCD Entries are referenced in module that is not in PEI phase nor in DXE phase.");\r
- }\r
- }\r
- }\r
- }\r
-\r
- return;\r
- }\r
-\r
- /**\r
- Get all PCD record for a module according to module's name, module's GUID,\r
- package name, package GUID, arch, version information.\r
- \r
- @param moduleId the id of module.\r
- @param arch the architecture\r
- \r
- @return all usage instance for this module in memory database.\r
- **/\r
- public List<UsageInstance> getUsageInstanceArrayByModuleName(ModuleIdentification moduleId,\r
- String arch) {\r
-\r
- String primaryKey = UsageInstance.getPrimaryKey(moduleId, arch);\r
-\r
- return getUsageInstanceArrayByKeyString(primaryKey);\r
- }\r
-\r
- /**\r
- Get all PCD token for a usage instance according to primary key.\r
- \r
- @param primaryKey the primary key of usage instance.\r
- \r
- @return List<UsageInstance>\r
- */\r
- public List<UsageInstance> getUsageInstanceArrayByKeyString(String primaryKey) {\r
- Token[] tokenArray = null;\r
- int recordIndex = 0; \r
- UsageInstance usageInstance = null;\r
- List<UsageInstance> returnArray = new ArrayList<UsageInstance>();\r
-\r
- tokenArray = getRecordArray();\r
-\r
- //\r
- // Loop to find all PCD record related to current module\r
- //\r
- for (recordIndex = 0; recordIndex < getDBSize(); recordIndex ++) {\r
- if (tokenArray[recordIndex].consumers.size() != 0) {\r
- usageInstance = tokenArray[recordIndex].consumers.get(primaryKey);\r
- if (usageInstance != null) {\r
- returnArray.add(usageInstance);\r
- }\r
- }\r
- }\r
-\r
- return returnArray;\r
- }\r
-\r
- /**\r
- Get all modules name who contains PCD information\r
- \r
- @return Array for module name\r
- **/\r
- public List<String> getAllModuleArray()\r
- {\r
- int indexToken = 0;\r
- int usageIndex = 0;\r
- int moduleIndex = 0;\r
- Token[] tokenArray = null;\r
- Object[] usageInstanceArray = null;\r
- List<String> moduleNames = new ArrayList<String>();\r
- UsageInstance usageInstance = null;\r
- boolean bFound = false;\r
-\r
- tokenArray = getRecordArray();\r
- //\r
- // Find all consumer usage instance for retrieving module's name\r
- //\r
- for (indexToken = 0; indexToken < getDBSize(); indexToken ++) {\r
- usageInstanceArray = tokenArray[indexToken].consumers.entrySet().toArray();\r
- for (usageIndex = 0; usageIndex < tokenArray[indexToken].consumers.size(); usageIndex ++) {\r
- usageInstance = (UsageInstance)((Map.Entry)usageInstanceArray[usageIndex]).getValue();\r
- bFound = false;\r
- for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {\r
- if (moduleNames.get(moduleIndex).equalsIgnoreCase(usageInstance.getPrimaryKey())) {\r
- bFound = true;\r
- break;\r
- }\r
- }\r
- if (!bFound) {\r
- moduleNames.add(usageInstance.getPrimaryKey());\r
- }\r
- }\r
- }\r
- return moduleNames;\r
- }\r
-}\r
+++ /dev/null
-/** @file\r
- SkuInstance class.\r
-\r
- Sku instance contains ID and value, A pcd token maybe contains more than one Sku instance.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/ \r
-package org.tianocore.build.pcd.entity;\r
-\r
-/** Sku instance contains ID and value, A pcd token maybe contains more than one Sku instance.\r
-**/\r
-public class SkuInstance {\r
- ///\r
- /// The id number of this SKU instance\r
- ///\r
- public int id;\r
- ///\r
- /// The value of this SKU instance\r
- ///\r
- public DynamicTokenValue value;\r
-\r
- /**\r
- Constructure function\r
-\r
- @param id sku id \r
- @param value sku value for this id.\r
- **/\r
- public SkuInstance(int id, DynamicTokenValue value) {\r
- this.id = id;\r
- this.value = value;\r
- }\r
-\r
- public SkuInstance() {\r
- this.id = 0;\r
- this.value = new DynamicTokenValue();\r
- }\r
-}\r
+++ /dev/null
-/** @file\r
- Token class.\r
-\r
- This module contains all classes releted to PCD token.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/ \r
-package org.tianocore.build.pcd.entity;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.UUID;\r
-\r
-import org.tianocore.build.id.ModuleIdentification;\r
-import org.tianocore.build.pcd.exception.EntityException;\r
-\r
-/** This class is to descript a PCD token object. The information of a token mainly \r
- comes from MSA, SPD and setting produced by platform developer. \r
-**/\r
-public class Token {\r
- ///\r
- /// Enumeration macro defintion for PCD type.\r
- /// BUGBUG: Not use upcase charater is to facility for reading. It may be changed\r
- /// in coding review.\r
- public enum PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC, \r
- DYNAMIC_EX, UNKNOWN}\r
-\r
- ///\r
- /// Enumeration macro definition for datum type. All type mainly comes from ProcessBind.h.\r
- /// Wizard maybe expand this type as "int, unsigned int, short, unsigned short etc" in \r
- /// prompt dialog.\r
- ///\r
- public enum DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN}\r
-\r
- ///\r
- /// Enumeration macor defintion for usage of PCD\r
- ///\r
- public enum PCD_USAGE {ALWAYS_PRODUCED, ALWAYS_CONSUMED, SOMETIMES_PRODUCED,\r
- SOMETIMES_CONSUMED, UNKNOWN}\r
-\r
- ///\r
- /// cName is to identify a PCD entry and will be used for generating autogen.h/autogen.c.\r
- /// cName will be defined in MSA, SPD and FPD, can be regarded as primary key with token space guid.\r
- ///\r
- public String cName;\r
-\r
- ///\r
- /// Token space name is the guid defined by token itself in package or module level. This\r
- /// name mainly for DynamicEx type. For other PCD type token, his token space name is the \r
- /// assignedtokenSpaceName as follows.\r
- /// tokenSpaceName is defined in MSA, SPD, FPD, can be regarded as primary key with cName.\r
- ///\r
- public String tokenSpaceName;\r
-\r
- ///\r
- /// tokenNumber is allocated by platform. tokenNumber indicate an index for this token in\r
- /// platform token space. For Dynamic, dynamicEx type, this number will be re-adjust by\r
- /// PCD run-time database autogen tools.\r
- ///\r
- public long tokenNumber;\r
-\r
- ///\r
- /// This token number is retrieved from FPD file for DynamicEx type. \r
- /// \r
- public long dynamicExTokenNumber;\r
-\r
- ///\r
- /// All supported PCD type, this value can be retrieved from SPD\r
- /// Currently, only record all PCD type for this token in FPD file.\r
- /// \r
- public List<PCD_TYPE> supportedPcdType;\r
-\r
- ///\r
- /// If the token's item type is Dynamic or DynamicEx type, isDynamicPCD\r
- /// is true.\r
- /// \r
- public boolean isDynamicPCD;\r
-\r
- ///\r
- /// datumSize is to descript the fix size or max size for this token. \r
- /// datumSize is defined in SPD.\r
- ///\r
- public int datumSize;\r
-\r
- ///\r
- /// datum type is to descript what type can be expressed by a PCD token.\r
- /// For same PCD used in different module, the datum type should be unique.\r
- /// So it belong memeber to Token class.\r
- ///\r
- public DATUM_TYPE datumType;\r
-\r
- ///\r
- /// skuData contains all value for SkuNumber of token.\r
- /// This field is for Dynamic or DynamicEx type PCD, \r
- ///\r
- public List<SkuInstance> skuData;\r
-\r
- ///\r
- /// consumers array record all module private information who consume this PCD token.\r
- ///\r
- public Map<String, UsageInstance> consumers;\r
-\r
- /**\r
- Constructure function for Token class\r
- \r
- @param cName The name of token\r
- @param tokenSpaceName The name of token space, it is a guid string\r
- **/\r
- public Token(String cName, String tokenSpaceName) {\r
- UUID nullUUID = new UUID(0, 0);\r
-\r
- this.cName = cName;\r
- this.tokenSpaceName = tokenSpaceName;\r
- this.tokenNumber = 0;\r
- this.datumType = DATUM_TYPE.UNKNOWN;\r
- this.datumSize = -1;\r
- this.skuData = new ArrayList<SkuInstance>();\r
-\r
- this.consumers = new HashMap<String, UsageInstance>();\r
- this.supportedPcdType = new ArrayList<PCD_TYPE>();\r
- }\r
-\r
- /**\r
- updateSupportPcdType\r
- \r
- SupportPcdType should be gotten from SPD file actually, but now it just\r
- record all PCD type for this token in FPD file.\r
- \r
- @param pcdType new PCD type found in FPD file for this token.\r
- **/\r
- public void updateSupportPcdType(PCD_TYPE pcdType) {\r
- for (int index = 0; index < this.supportedPcdType.size(); index ++) {\r
- if (supportedPcdType.get(index) == pcdType) {\r
- return;\r
- }\r
- }\r
-\r
- //\r
- // If not found, add the pcd type to member variable supportedPcdType\r
- // \r
- supportedPcdType.add(pcdType);\r
- }\r
-\r
- /**\r
- Judge whether pcdType is belong to dynamic type. Dynamic type includes\r
- DYNAMIC and DYNAMIC_EX.\r
- \r
- @param pcdType the judged pcd type\r
- \r
- @return boolean\r
- */\r
- public static boolean isDynamic(PCD_TYPE pcdType) {\r
- if ((pcdType == PCD_TYPE.DYNAMIC ) ||\r
- (pcdType == PCD_TYPE.DYNAMIC_EX)) {\r
- return true;\r
- }\r
-\r
- return false;\r
- }\r
-\r
- public boolean isDynamicEx() {\r
- for (int i = 0; i < supportedPcdType.size(); i++) {\r
- if (supportedPcdType.get(i) == PCD_TYPE.DYNAMIC_EX) {\r
- return true;\r
- }\r
- }\r
- \r
- return false;\r
- }\r
-\r
- /**\r
- Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database\r
- \r
- @param cName Token name.\r
- @param tokenSpaceName The token space guid string defined in MSA or SPD\r
- \r
- @retval primary key for this token in token database.\r
- **/\r
- public static String getPrimaryKeyString(String cName, String tokenSpaceName) {\r
- if (tokenSpaceName == null) {\r
- return cName + "_nullTokenSpaceGuid";\r
- } else {\r
- return cName + "_" + tokenSpaceName.toString().replace('-', '_');\r
- }\r
- }\r
-\r
- /**\r
- If skudata list contains more than one data, then Sku mechanism is enable.\r
- \r
- @retval boolean if the number of sku data exceed to 1\r
- */\r
- public boolean isSkuEnable() {\r
- if (this.skuData.size() > 1) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- If Hii type for value of token\r
- \r
- @return boolean\r
- **/\r
- public boolean isHiiEnable() {\r
- if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- If Vpd type for value of token\r
- \r
- @return boolean\r
- **/\r
- public boolean isVpdEnable() {\r
- if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- Get the token primary key in token database.\r
- \r
- @return String\r
- */\r
- public String getPrimaryKeyString () {\r
- return Token.getPrimaryKeyString(cName, tokenSpaceName);\r
- }\r
-\r
- /**\r
- Judge datumType is valid\r
- \r
- @param type The datumType want to be judged.\r
- \r
- @retval TRUE - The type is valid.\r
- @retval FALSE - The type is invalid.\r
- **/\r
- public static boolean isValiddatumType(DATUM_TYPE type) {\r
- if ((type.ordinal() < DATUM_TYPE.UINT8.ordinal() ) || \r
- (type.ordinal() > DATUM_TYPE.POINTER.ordinal())) {\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- Judge pcdType is valid\r
- \r
- @param type The PCdType want to be judged.\r
- \r
- @retval TRUE - The type is valid.\r
- @retval FALSE - The type is invalid.\r
- **/\r
- public static boolean isValidpcdType(PCD_TYPE type) {\r
- if ((type.ordinal() < PCD_TYPE.FEATURE_FLAG.ordinal() ) || \r
- (type.ordinal() > PCD_TYPE.DYNAMIC_EX.ordinal())) {\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
- /**\r
- Add an usage instance for token\r
- \r
- @param usageInstance The usage instance\r
- \r
- @retval TRUE - Success to add usage instance.\r
- @retval FALSE - Fail to add usage instance\r
- **/\r
- public boolean addUsageInstance(UsageInstance usageInstance) throws EntityException {\r
- String exceptionStr;\r
-\r
- if (isUsageInstanceExist(usageInstance.moduleId, usageInstance.arch)) {\r
- exceptionStr = String.format("[PCD Collection Tool Exception] PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
- "in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!",\r
- usageInstance.parentToken.cName,\r
- usageInstance.moduleId.getName(),\r
- usageInstance.moduleId.getName());\r
- throw new EntityException(exceptionStr);\r
- }\r
-\r
- //\r
- // Put usage instance into usage instance database of this PCD token.\r
- // \r
- consumers.put(usageInstance.getPrimaryKey(), usageInstance);\r
-\r
- return true;\r
- }\r
-\r
- /**\r
- Judge whether exist an usage instance for this token\r
- \r
- @param moduleId The module identification for usage instance\r
- @param arch the architecture string\r
- \r
- @return boolean whether exist an usage instance for this token.\r
- */\r
- public boolean isUsageInstanceExist(ModuleIdentification moduleId,\r
- String arch) {\r
- String keyStr = UsageInstance.getPrimaryKey(moduleId, arch);\r
-\r
- return (consumers.get(keyStr) != null);\r
- }\r
-\r
- /**\r
- Get the PCD_TYPE according to the string of PCD_TYPE\r
- \r
- @param pcdTypeStr The string of PCD_TYPE\r
- \r
- @return PCD_TYPE\r
- **/\r
- public static PCD_TYPE getpcdTypeFromString(String pcdTypeStr) {\r
- if (pcdTypeStr == null) {\r
- return PCD_TYPE.UNKNOWN;\r
- }\r
-\r
- if (pcdTypeStr.equalsIgnoreCase("FEATURE_FLAG")) {\r
- return PCD_TYPE.FEATURE_FLAG;\r
- } else if (pcdTypeStr.equalsIgnoreCase("FIXED_AT_BUILD")) {\r
- return PCD_TYPE.FIXED_AT_BUILD;\r
- } else if (pcdTypeStr.equalsIgnoreCase("PATCHABLE_IN_MODULE")) {\r
- return PCD_TYPE.PATCHABLE_IN_MODULE;\r
- } else if (pcdTypeStr.equalsIgnoreCase("DYNAMIC")) {\r
- return PCD_TYPE.DYNAMIC;\r
- } else if (pcdTypeStr.equalsIgnoreCase("DYNAMIC_EX")) {\r
- return PCD_TYPE.DYNAMIC_EX;\r
- } else {\r
- return PCD_TYPE.UNKNOWN;\r
- }\r
- }\r
-\r
- /**\r
- Get the string of given datumType. This string will be used for generating autogen files\r
- \r
- @param datumType Given datumType\r
- \r
- @return The string of datum type.\r
- **/\r
- public static String getStringOfdatumType(DATUM_TYPE datumType) {\r
- switch (datumType) {\r
- case UINT8:\r
- return "UINT8";\r
- case UINT16:\r
- return "UINT16";\r
- case UINT32:\r
- return "UINT32";\r
- case UINT64:\r
- return "UINT64";\r
- case POINTER:\r
- return "POINTER";\r
- case BOOLEAN:\r
- return "BOOLEAN";\r
- }\r
- return "UNKNOWN";\r
- }\r
-\r
- /**\r
- Get the datumType according to a string.\r
- \r
- @param datumTypeStr The string of datumType\r
- \r
- @return DATUM_TYPE\r
- **/\r
- public static DATUM_TYPE getdatumTypeFromString(String datumTypeStr) {\r
- if (datumTypeStr.equalsIgnoreCase("UINT8")) {\r
- return DATUM_TYPE.UINT8;\r
- } else if (datumTypeStr.equalsIgnoreCase("UINT16")) {\r
- return DATUM_TYPE.UINT16;\r
- } else if (datumTypeStr.equalsIgnoreCase("UINT32")) {\r
- return DATUM_TYPE.UINT32;\r
- } else if (datumTypeStr.equalsIgnoreCase("UINT64")) {\r
- return DATUM_TYPE.UINT64;\r
- } else if (datumTypeStr.equalsIgnoreCase("VOID*")) {\r
- return DATUM_TYPE.POINTER;\r
- } else if (datumTypeStr.equalsIgnoreCase("BOOLEAN")) {\r
- return DATUM_TYPE.BOOLEAN;\r
- }\r
- return DATUM_TYPE.UNKNOWN;\r
- }\r
-\r
- /**\r
- Get string of given pcdType\r
- \r
- @param pcdType The given PcdType\r
- \r
- @return The string of PCD_TYPE.\r
- **/\r
- public static String getStringOfpcdType(PCD_TYPE pcdType) {\r
- switch (pcdType) {\r
- case FEATURE_FLAG:\r
- return "FEATURE_FLAG";\r
- case FIXED_AT_BUILD:\r
- return "FIXED_AT_BUILD";\r
- case PATCHABLE_IN_MODULE:\r
- return "PATCHABLE_IN_MODULE";\r
- case DYNAMIC:\r
- return "DYNAMIC";\r
- case DYNAMIC_EX:\r
- return "DYNAMIC_EX";\r
- }\r
- return "UNKNOWN";\r
- }\r
-\r
- /**\r
- Get the PCD_USAGE according to a string\r
- \r
- @param usageStr The string of PCD_USAGE\r
- \r
- @return The PCD_USAGE\r
- **/\r
- public static PCD_USAGE getUsageFromString(String usageStr) {\r
- if (usageStr == null) {\r
- return PCD_USAGE.UNKNOWN;\r
- }\r
-\r
- if (usageStr.equalsIgnoreCase("ALWAYS_PRODUCED")) {\r
- return PCD_USAGE.ALWAYS_PRODUCED;\r
- } else if (usageStr.equalsIgnoreCase("SOMETIMES_PRODUCED")) {\r
- return PCD_USAGE.SOMETIMES_PRODUCED;\r
- } else if (usageStr.equalsIgnoreCase("ALWAYS_CONSUMED")) {\r
- return PCD_USAGE.ALWAYS_CONSUMED;\r
- } else if (usageStr.equalsIgnoreCase("SOMETIMES_CONSUMED")) {\r
- return PCD_USAGE.SOMETIMES_CONSUMED;\r
- }\r
-\r
- return PCD_USAGE.UNKNOWN;\r
- }\r
-\r
- /**\r
- Get the string of given PCD_USAGE\r
- \r
- @param usage The given PCD_USAGE\r
- \r
- @return The string of PDC_USAGE.\r
- **/\r
- public static String getStringOfUsage(PCD_USAGE usage) {\r
- switch (usage) {\r
- case ALWAYS_PRODUCED:\r
- return "ALWAYS_PRODUCED";\r
- case ALWAYS_CONSUMED:\r
- return "ALWAYS_CONSUMED";\r
- case SOMETIMES_PRODUCED:\r
- return "SOMETIMES_PRODUCED";\r
- case SOMETIMES_CONSUMED:\r
- return "SOMETIMES_CONSUMED";\r
- }\r
- return "UNKNOWN";\r
- }\r
-\r
- /**\r
- Get the Defined datumType string for autogen. The string is for generating some MACROs in Autogen.h\r
- \r
- @param datumType The given datumType\r
-\r
- @return string of datum type for autogen.\r
- **/\r
- public static String GetAutogenDefinedatumTypeString(DATUM_TYPE datumType) {\r
- switch (datumType) {\r
- \r
- case UINT8:\r
- return "8";\r
- case UINT16:\r
- return "16";\r
- case BOOLEAN:\r
- return "BOOL";\r
- case POINTER:\r
- return "PTR";\r
- case UINT32:\r
- return "32";\r
- case UINT64:\r
- return "64";\r
- default:\r
- return null;\r
- }\r
- }\r
-\r
- /**\r
- Get the datumType String for Autogen. This string will be used for generating defintions of PCD token in autogen\r
- \r
- @param datumType The given datumType\r
-\r
- @return string of datum type.\r
- **/\r
-\r
- public static String getAutogendatumTypeString(DATUM_TYPE datumType) {\r
- switch (datumType) {\r
- case UINT8:\r
- return "UINT8";\r
- case UINT16:\r
- return "UINT16";\r
- case UINT32:\r
- return "UINT32";\r
- case UINT64:\r
- return "UINT64";\r
- case POINTER:\r
- return "VOID*";\r
- case BOOLEAN:\r
- return "BOOLEAN";\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- Get the datumType string for generating some MACROs in autogen file of Library\r
- \r
- @param datumType The given datumType\r
-\r
- @return String of datum for genrating bit charater.\r
- **/\r
- public static String getAutogenLibrarydatumTypeString(DATUM_TYPE datumType) {\r
- switch (datumType) {\r
- case UINT8:\r
- return "8";\r
- case UINT16:\r
- return "16";\r
- case BOOLEAN:\r
- return "Bool";\r
- case POINTER:\r
- return "Ptr";\r
- case UINT32:\r
- return "32";\r
- case UINT64:\r
- return "64";\r
- default:\r
- return null;\r
- }\r
- }\r
-\r
- /**\r
- Get the sku data who id is 0.\r
- \r
- @retval DynamicTokenValue the value of this dyanmic token.\r
- **/\r
- public DynamicTokenValue getDefaultSku() {\r
- DynamicTokenValue dynamicData;\r
- int index;\r
-\r
- for (index = 0; index < this.skuData.size(); index ++) {\r
- if (skuData.get(index).id == 0) {\r
- return skuData.get(index).value;\r
- }\r
- }\r
-\r
- return null;\r
- }\r
-\r
- /**\r
- Get the number of Sku data for this token\r
- \r
- @retval int the number of sku data\r
- **/\r
- public int getSkuIdCount () {\r
- return this.skuData.size();\r
- }\r
-\r
- /**\r
- Get the size of PCD value, this PCD is POINTER type.\r
- \r
- @param str the string of the value\r
- @param al \r
- **/\r
- private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {\r
- if (isValidNullValue(str)) {\r
- al.add(new Integer(0));\r
- } else {\r
- //\r
- // isValidNullValue has already make sure that str here\r
- // always contain a valid default value of the following 3\r
- // cases:\r
- // 1) "Hello world" //Assci string\r
- // 2) L"Hello" //Unicode string\r
- // 3) {0x01, 0x02, 0x03} //Byte stream\r
- //\r
- if (str.startsWith("\"")) {\r
- al.add(new Integer(str.length() - 2));\r
- } else if (str.startsWith("L\"")){\r
- //\r
- // Unicode is 2 bytes each.\r
- //\r
- al.add(new Integer((str.length() - 3) * 2));\r
- } else if (str.startsWith("{")) {\r
- //\r
- // We count the number of "," in the string.\r
- // The number of byte is one plus the number of \r
- // comma.\r
- //\r
- String str2 = str;\r
- \r
- int cnt = 0;\r
- int pos = 0;\r
- pos = str2.indexOf(",", 0);\r
- while (pos != -1) {\r
- cnt++;\r
- pos++;\r
- pos = str2.indexOf(",", pos);\r
- }\r
- cnt++;\r
- al.add(new Integer(cnt));\r
- }\r
- }\r
- }\r
-\r
- /**\r
- This method can be used to get the MAX and current size\r
- for pointer type dynamic(ex) PCD entry\r
- **/ \r
- public ArrayList<Integer> getPointerTypeSize () {\r
- ArrayList<Integer> al = new ArrayList<Integer>();\r
- \r
- //\r
- // For VPD_enabled and HII_enabled, we can only return the MAX size.\r
- // For the default DATA type dynamic PCD entry, we will return\r
- // the MAX size and current size for each SKU_ID.\r
- //\r
- al.add(new Integer(this.datumSize));\r
- \r
- if (!this.isVpdEnable()) {\r
- int idx;\r
- if (this.isHiiEnable()){\r
- for (idx = 0; idx < this.skuData.size(); idx++) {\r
- String str = this.skuData.get(idx).value.hiiDefaultValue;\r
- getCurrentSizeFromDefaultValue(str, al);\r
- }\r
- } else {\r
- for (idx = 0; idx < this.skuData.size(); idx++) {\r
- String str = this.skuData.get(idx).value.value;\r
- getCurrentSizeFromDefaultValue(str, al);\r
- }\r
- }\r
- }\r
- \r
- return al;\r
- }\r
-\r
- /**\r
- Get default value for a token, For HII type, HiiDefaultValue of default\r
- SKU 0 will be returned; For Default type, the defaultvalue of default SKU\r
- 0 will be returned.\r
- \r
- @return String\r
- */\r
- public String getDynamicDefaultValue() {\r
- DynamicTokenValue dynamicData = getDefaultSku();\r
- if (hasDefaultValue()) {\r
- switch (dynamicData.type) {\r
- case DEFAULT_TYPE:\r
- return dynamicData.value;\r
- }\r
- }\r
-\r
- return null;\r
- }\r
-\r
- //\r
- // BugBug: We need change this algorithm accordingly when schema is updated\r
- // to support no default value.\r
- //\r
- public boolean hasDefaultValue () {\r
- int value = 0;\r
- boolean isInteger = true;\r
- DynamicTokenValue dynamicValue = null;\r
-\r
- if (isSkuEnable()) {\r
- return true;\r
- }\r
- \r
- if (this.isDynamicPCD) {\r
- dynamicValue = getDefaultSku();\r
- switch (dynamicValue.type) {\r
- case HII_TYPE:\r
- return true;\r
- case VPD_TYPE:\r
- return true;\r
- case DEFAULT_TYPE:\r
- return !isValidNullValue(dynamicValue.value);\r
- }\r
- }\r
-\r
- return false;\r
- }\r
-\r
- /**\r
- Judge the value is NULL value. NULL value means the value is uninitialized value\r
- \r
- @param judgedValue\r
- \r
- @return boolean\r
- */\r
- public boolean isValidNullValue(String judgedValue) {\r
- String subStr;\r
- BigInteger bigIntValue;\r
-\r
- switch (datumType) {\r
- case UINT8:\r
- case UINT16:\r
- case UINT32:\r
- if (judgedValue.length() > 2) {\r
- if ((judgedValue.charAt(0) == '0') && \r
- ((judgedValue.charAt(1) == 'x') || (judgedValue.charAt(1) == 'X'))){\r
- subStr = judgedValue.substring(2, judgedValue.length());\r
- bigIntValue = new BigInteger(subStr, 16);\r
- } else {\r
- bigIntValue = new BigInteger(judgedValue);\r
- }\r
- } else {\r
- bigIntValue = new BigInteger(judgedValue);\r
- }\r
- if (bigIntValue.bitCount() == 0) {\r
- return true;\r
- }\r
- break;\r
- case UINT64:\r
- if (judgedValue.length() > 2){\r
- if ((judgedValue.charAt(0) == '0') && \r
- ((judgedValue.charAt(1) == 'x') ||\r
- (judgedValue.charAt(1) == 'X'))) {\r
- bigIntValue = new BigInteger(judgedValue.substring(2, judgedValue.length()), 16);\r
- if (bigIntValue.bitCount() == 0) {\r
- return true;\r
- }\r
- } else {\r
- bigIntValue = new BigInteger(judgedValue);\r
- if (bigIntValue.bitCount() == 0) {\r
- return true;\r
- }\r
- }\r
- } else {\r
- bigIntValue = new BigInteger(judgedValue);\r
- if (bigIntValue.bitCount() == 0) {\r
- return true;\r
- }\r
- }\r
- break;\r
- case BOOLEAN:\r
- if (judgedValue.equalsIgnoreCase("false")) {\r
- return true;\r
- }\r
- break;\r
- case POINTER:\r
- if (judgedValue.equalsIgnoreCase("") ||\r
- judgedValue.equalsIgnoreCase("\"\"") ||\r
- judgedValue.equalsIgnoreCase("L\"\"") ||\r
- (judgedValue.length() == 0) ||\r
- judgedValue.equalsIgnoreCase("{0}")) {\r
- return true;\r
- }\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- Is the string value in Unicode\r
- \r
- @return boolean\r
- **/\r
- public boolean isHiiDefaultValueUnicodeStringType() {\r
- DynamicTokenValue dynamicData = getDefaultSku();\r
- \r
- if (dynamicData == null)\r
- return false;\r
- \r
- return dynamicData.hiiDefaultValue.startsWith("L\"")\r
- && dynamicData.hiiDefaultValue.endsWith("\"");\r
- }\r
-\r
- /**\r
- Is the string value in ANSCI\r
- \r
- @return boolean\r
- **/\r
- public boolean isHiiDefaultValueASCIIStringType() {\r
- DynamicTokenValue dynamicData = getDefaultSku();\r
- \r
- if (dynamicData == null)\r
- return false;\r
- \r
- return dynamicData.hiiDefaultValue.startsWith("\"")\r
- && dynamicData.hiiDefaultValue.endsWith("\"");\r
- }\r
- \r
- /**\r
- Judege whether current value is UNICODE string type.\r
- @return boolean\r
- */\r
- public boolean isUnicodeStringType () {\r
- String str = getDynamicDefaultValue();\r
-\r
- if (str == null) {\r
- return false;\r
- }\r
-\r
- if (datumType == Token.DATUM_TYPE.POINTER &&\r
- str.startsWith("L\"") && \r
- str.endsWith("\"")) {\r
- return true;\r
- }\r
-\r
- return false;\r
- }\r
- \r
- public boolean isASCIIStringType () {\r
- String str = getDynamicDefaultValue();\r
-\r
- if (str == null) {\r
- return false;\r
- }\r
-\r
- if (datumType == Token.DATUM_TYPE.POINTER &&\r
- str.startsWith("\"") && \r
- str.endsWith("\"")) {\r
- return true;\r
- }\r
-\r
- return false;\r
- }\r
-\r
- public boolean isByteStreamType () {\r
- String str = getDynamicDefaultValue();\r
-\r
- if (str == null) {\r
- return false;\r
- }\r
-\r
- if (datumType == Token.DATUM_TYPE.POINTER &&\r
- str.startsWith("{") && \r
- str.endsWith("}")) {\r
- return true;\r
- }\r
-\r
- return false;\r
- \r
- }\r
-\r
- public String getStringTypeString () { \r
- return getDefaultSku().value.substring(2, getDefaultSku().value.length() - 1);\r
- }\r
-}\r
-\r
-\r
-\r
-\r
+++ /dev/null
-/** @file\r
- UsageInstance class.\r
-\r
- This class indicate an usage instance for a PCD token. This instance maybe a module\r
- or platform setting. When a module produce or cosume a PCD token, then this module\r
- is an usage instance for this PCD token.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/ \r
-package org.tianocore.build.pcd.entity;\r
-\r
-\r
-import java.util.UUID;\r
-\r
-import org.tianocore.ModuleTypeDef;\r
-import org.tianocore.build.autogen.CommonDefinition;\r
-import org.tianocore.build.id.ModuleIdentification;\r
-import org.tianocore.build.pcd.exception.EntityException;\r
-\r
-/**\r
- This class indicate an usage instance for a PCD token. This instance maybe a module\r
- or platform setting. When a module produce or cosume a PCD token, then this 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
- ///\r
- /// ModuleIdentification for Usage Instance\r
- /// \r
- public ModuleIdentification moduleId;\r
-\r
- ///\r
- /// Arch also is a key for a UsageInstance\r
- /// \r
- public String arch;\r
-\r
- ///\r
- /// The PCD type defined for module \r
- /// \r
- public Token.PCD_TYPE modulePcdType;\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
- /// 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 for UsageInstance\r
- \r
- @param parentToken The token instance for this usgaInstance\r
- @param id The identification for usage instance\r
- @param modulePcdType The PCD type for this usage instance\r
- @param value The value of this PCD in this usage instance\r
- @param maxDatumSize The max datum size of this PCD in this usage\r
- instance.\r
- **/\r
- public UsageInstance(Token parentToken,\r
- ModuleIdentification moduleId,\r
- Token.PCD_TYPE modulePcdType,\r
- String arch,\r
- String value,\r
- int maxDatumSize) {\r
- this.parentToken = parentToken;\r
- this.moduleId = moduleId;\r
- this.modulePcdType = modulePcdType;\r
- this.arch = arch;\r
- this.datum = value;\r
- this.maxDatumSize = maxDatumSize;\r
- }\r
-\r
- /**\r
- Get the primary key for usage instance array for every token.\r
- \r
- @param moduleId The module Identification for generating primary key\r
- @param arch Arch string\r
- \r
- @retval String The primary key for this usage instance\r
- **/\r
- public static String getPrimaryKey(ModuleIdentification moduleId,\r
- String arch) {\r
- String moduleName = moduleId.getName();\r
- String moduleGuid = moduleId.getGuid();\r
- String packageName = moduleId.getPackage().getName();\r
- String packageGuid = moduleId.getPackage().getGuid();\r
- String version = moduleId.getVersion();\r
-\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
- // BUGBUG: Because currently we can not get version from MSA, So ignore verison.\r
- // \r
- return(moduleName + "_" +\r
- ((moduleGuid != null) ? moduleGuid.toLowerCase() : "NullModuleGuid") + "_" +\r
- ((packageName != null) ? packageName : "NullPackageName") + "_" +\r
- ((packageGuid != null) ? packageGuid.toLowerCase() : "NullPackageGuid") + "_" +\r
- ((arch != null) ? arch : "NullArch") + "_" +\r
- "NullVersion");\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(moduleId, arch);\r
- }\r
-\r
- /**\r
- Judget whether current module is PEI driver\r
- \r
- @return boolean whether current module is PEI driver\r
- **/\r
- public boolean isPeiPhaseComponent() {\r
- int moduleType = CommonDefinition.getModuleType(moduleId.getModuleType());\r
-\r
- if ((moduleType == CommonDefinition.ModuleTypePeiCore) ||\r
- (moduleType == CommonDefinition.ModuleTypePeim)) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- Judge whether current module is DXE driver.\r
- \r
- @return boolean whether current module is DXE driver\r
- **/\r
- public boolean isDxePhaseComponent() {\r
- int moduleType = CommonDefinition.getModuleType(moduleId.getModuleType());\r
-\r
- if ((moduleType == CommonDefinition.ModuleTypeDxeDriver) ||\r
- (moduleType == CommonDefinition.ModuleTypeDxeRuntimeDriver) ||\r
- (moduleType == CommonDefinition.ModuleTypeDxeSalDriver) ||\r
- (moduleType == CommonDefinition.ModuleTypeDxeSmmDriver) ||\r
- (moduleType == CommonDefinition.ModuleTypeUefiDriver) ||\r
- (moduleType == CommonDefinition.ModuleTypeUefiApplication)\r
- ) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- Generate autogen string for header file and C code file.\r
- \r
- @param isBuildUsedLibrary whether the autogen is for library.\r
- **/\r
- public void generateAutoGen(boolean isBuildUsedLibrary) {\r
- String guidStringCName = null;\r
- boolean isByteArray = false;\r
- String printDatum = null;\r
- String tokenNumberString = null;\r
-\r
- hAutogenStr = "";\r
- cAutogenStr = "";\r
-\r
- if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
- //\r
- // For DYNAMIC_EX type PCD, use original token number in SPD or FPD to generate autogen\r
- // \r
- tokenNumberString = Long.toString(parentToken.dynamicExTokenNumber, 16);\r
- } else {\r
- //\r
- // For Others type PCD, use autogenerated token number to generate autogen\r
- // \r
- tokenNumberString = Long.toString(parentToken.tokenNumber, 16);\r
- }\r
-\r
- hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%s\r\n", parentToken.cName, tokenNumberString);\r
-\r
- //\r
- // Judge the value of this PCD is byte array type\r
- // \r
- if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {\r
- if (datum.trim().charAt(0) == '{') {\r
- isByteArray = true;\r
- }\r
- }\r
-\r
- //\r
- // "ULL" should be added to value's tail for UINT64 value\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
- hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", \r
- parentToken.cName);\r
- hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
- parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName);\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
- parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\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 (isByteArray) {\r
- hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",\r
- parentToken.cName);\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
- 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_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n", \r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName);\r
- }\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
- parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName);\r
- if (!isBuildUsedLibrary) {\r
- if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
- if (isByteArray) {\r
- hAutogenStr += String.format("#define _PCD_VALUE_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n", \r
- parentToken.cName, \r
- parentToken.cName);\r
- cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",\r
- parentToken.cName,\r
- printDatum);\r
- } else {\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 %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName);\r
- }\r
- } else {\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 %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
- if (isByteArray) {\r
- hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",\r
- parentToken.cName);\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
- hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
- Token.getAutogendatumTypeString(parentToken.datumType),\r
- parentToken.cName);\r
- hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",\r
- Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
- parentToken.cName,\r
- parentToken.cName); \r
- }\r
-\r
- //\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
- 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
- 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
- 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("#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
- 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
- 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
- Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
- parentToken.cName);\r
- }\r
- break;\r
- case DYNAMIC_EX:\r
- guidStringCName = "_gPcd_TokenSpaceGuid_" +\r
- parentToken.tokenSpaceName.toString().replaceAll("-", "_");\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
- Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
- guidStringCName,\r
- parentToken.cName);\r
-\r
- if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\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
- Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
- guidStringCName,\r
- parentToken.cName);\r
- } else {\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
- Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
- guidStringCName,\r
- parentToken.cName);\r
-\r
- }\r
- break;\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
- /**\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
+++ /dev/null
-/** @file\r
- BuildActionException class.\r
-\r
- BuildAction Exception deals with all build action exceptions.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/ \r
-package org.tianocore.build.pcd.exception;\r
-\r
-import org.apache.tools.ant.BuildException;\r
-\r
-/**\r
- BuildAction Exception deals with all build action exceptions.\r
-**/\r
-public class BuildActionException extends BuildException {\r
- static final long serialVersionUID = -7034897190740066939L;\r
- /**\r
- Constructure function\r
- \r
- @param reason exception message string.\r
- **/\r
- public BuildActionException(String reason) {\r
- super(reason);\r
- }\r
-}\r
+++ /dev/null
-/** @file\r
- EntityException class.\r
-\r
- The class handle the exception throwed by entity class.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/ \r
-package org.tianocore.build.pcd.exception;\r
-\r
-/**\r
- The class handle the exception throwed by entity class.\r
-**/\r
-public class EntityException extends Exception {\r
- static final long serialVersionUID = -8034897190740066939L;\r
- /**\r
- Constructure function\r
- \r
- @param expStr exception message string.\r
- **/\r
- public EntityException(String expStr) {\r
- super("[PCD EntityException]:" + expStr);\r
- }\r
-}\r
+++ /dev/null
-/** @file\r
- UIException class.\r
-\r
- The class handle the exception throwed by UI action class.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/ \r
-package org.tianocore.build.pcd.exception;\r
-\r
-/**\r
- The class handle the exception throwed by UI action class.\r
-**/\r
-public class UIException extends Exception {\r
- static final long serialVersionUID = -7034897190740066930L;\r
- /**\r
- Constructure function\r
- \r
- @param reason exception message string.\r
- **/\r
- public UIException(String reason) {\r
- super(reason);\r
- }\r
-}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" >\r
+ <MsaHeader>\r
+ <ModuleName>PcdTools</ModuleName>\r
+ <ModuleType>TOOL</ModuleType>\r
+ <GuidValue>95506773-88f3-475a-91a1-14ce0c847353</GuidValue>\r
+ <Version>2.0</Version>\r
+ <Abstract>This is the EFI/Tiano PCD Tool Resources Module</Abstract>\r
+ <Description>\r
+ This Module provdes the entity, action and exception package for PCD\r
+ tools, This package will be shared for building tools or wizard tools.\r
+ </Description>\r
+ <Copyright>Copyright 2005-2006, Intel Corporation</Copyright>\r
+ <License>\r
+All rights reserved.\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the \r
+BSD License which accompanies this distribution. The full text of the \r
+license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ </License>\r
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
+ </MsaHeader>\r
+ <ModuleDefinitions>\r
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+ <BinaryModule>false</BinaryModule>\r
+ <OutputFileBasename>NULL</OutputFileBasename>\r
+ </ModuleDefinitions>\r
+ <SourceFiles>\r
+ <Filename>build.xml</Filename>\r
+ <Filename>org/tianocore/pcd/action/ActionMessage.java</Filename>\r
+ <Filename>org/tianocore/pcd/action/BuildAction.java</Filename>\r
+ <Filename>org/tianocore/pcd/entity/DynamicTokenValue.java</Filename>\r
+ <Filename>org/tianocore/pcd/entity/MemoryDatabaseManager.java</Filename>\r
+ <Filename>org/tianocore/pcd/entity/SkuInstance.java</Filename>\r
+ <Filename>org/tianocore/pcd/entity/Token.java</Filename>\r
+ <Filename>org/tianocore/pcd/entity/UsageInstance.java</Filename>\r
+ <Filename>org/tianocore/pcd/exception/BuildActionException.java</Filename>\r
+ <Filename>org/tianocore/pcd/exception/EntityException.java</Filename>\r
+ <Filename>org/tianocore/pcd/exception/UIException.java</Filename>\r
+ </SourceFiles>\r
+</ModuleSurfaceArea>\r
--- /dev/null
+<?xml version="1.0"?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project name="PcdTools" default="PcdTools" basedir=".">\r
+\r
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
+ <property environment="env"/>\r
+ <property name="WORKSPACE" value="${env.WORKSPACE}"/>\r
+ <path id="classpath">\r
+ <fileset dir="${WORKSPACE}/Tools/Jars" includes="SurfaceArea.jar"/>\r
+ <fileset dir="${WORKSPACE}/Tools/Jars" includes="Common.jar"/>\r
+ <fileset dir="${env.XMLBEANS_HOME}/lib" includes="*.jar"/>\r
+ </path>\r
+ <property name="buildDir" value="build"/>\r
+ <property name="installLocation" value="${WORKSPACE}/Tools/Jars"/>\r
+ <target name="PcdTools" depends="install"/>\r
+ <target name="source">\r
+ <mkdir dir="${buildDir}"/>\r
+ <javac srcdir="." destdir="${buildDir}">\r
+ <classpath refid="classpath"/>\r
+ <compilerarg value="-Xlint"/>\r
+ </javac>\r
+ </target>\r
+ <target name="clean">\r
+ <delete dir="${buildDir}"/>\r
+ </target>\r
+ <target name="cleanall">\r
+ <delete dir="${buildDir}"/>\r
+ <delete file="${installLocation}/PcdTools.jar"/>\r
+ <if>\r
+ <available file="${installLocation}/PcdTools.jar"/>\r
+ <then>\r
+ <echo message="You must manually remove the file: ${installLocation}/PcdTools.jar"/>\r
+ <echo message="Java has already loaded the file, and cannot remove it within ANT!"/>\r
+ </then>\r
+ </if>\r
+ </target>\r
+ <target name="install" depends="source">\r
+ <jar destfile="${installLocation}/PcdTools.jar"\r
+ basedir="${buildDir}"\r
+ includes="**"\r
+ />\r
+ </target>\r
+</project>\r
--- /dev/null
+/** @file\r
+ ActionMessage class.\r
+\r
+ ActionMessage class take over all message for loging and waning. This class should\r
+ dispatch message into different class according to instance class type.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+package org.tianocore.pcd.action;\r
+\r
+import org.apache.tools.ant.Task;\r
+\r
+/** ActionMessage class take over all message for loging and waning. This class \r
+ should dispatch message into different Action class according to instance \r
+ class type.\r
+**/\r
+public class ActionMessage {\r
+ ///\r
+ /// Macro definition for NULL messge level. \r
+ /// In this meessage level, all message will be hidden.\r
+ ///\r
+ public final static int NULL_MESSAGE_LEVEL = 0; \r
+ ///\r
+ /// Macro definition for Log messge level.\r
+ /// In this message level, Only log information will be shown.\r
+ ///\r
+ public final static int LOG_MESSAGE_LEVEL = 1;\r
+ ///\r
+ /// Macro definition for Warning message level. \r
+ /// In this message level, log and waning message will be shown.\r
+ ///\r
+ public final static int WARNING_MESSAGE_LEVEL = 2;\r
+ ///\r
+ /// Macro definition for Debug mesage level.\r
+ /// In this message level, log, warning, debug message will be shown.\r
+ ///\r
+ public final static int DEBUG_MESSAGE_LEVEL = 3;\r
+ ///\r
+ /// Macor definition for MAX message level.\r
+ /// In this message level, all message will be shown.\r
+ ///\r
+ public final static int MAX_MESSAGE_LEVEL = 4;\r
+ ///\r
+ /// Current message level. It will control all message output for PCD tool.\r
+ ///\r
+ public static int messageLevel = NULL_MESSAGE_LEVEL;\r
+\r
+ /**\r
+ Log() function provide common log information functionality for all \r
+ PCD tool includes all function\r
+\r
+ This function will dispatch message to special class such as BuildAction\r
+ Class, Entity Class etc.\r
+ \r
+ @param thisClass The class object who want log information.\r
+ @param logStr The string contains log information.\r
+ **/\r
+ public static void log(Object thisClass, String logStr) {\r
+ if(messageLevel < LOG_MESSAGE_LEVEL) {\r
+ return;\r
+ }\r
+\r
+ if(thisClass instanceof Task) {\r
+ BuildAction.logMsg(thisClass, "$$LOG$$:" + logStr);\r
+ } else {\r
+ System.out.println("$$LOG$$:" + logStr);\r
+ }\r
+ }\r
+\r
+ /**\r
+ Warning() function provide common warning information functionality for all \r
+ PCD tool.\r
+\r
+ This function will dispatch message to special class such as BuildAction\r
+ Class, Entity Class etc.\r
+ \r
+ @param thisClass The class object who want warn information.\r
+ @param warningStr The string contains warning information.\r
+ **/ \r
+ public static void warning(Object thisClass, String warningStr) {\r
+ if(messageLevel < WARNING_MESSAGE_LEVEL) {\r
+ return;\r
+ }\r
+\r
+ if(thisClass instanceof Task) {\r
+ BuildAction.warningMsg(thisClass, "**WARNING**:" + warningStr);\r
+ } else {\r
+ System.out.println("**WARNING**:" + warningStr);\r
+ }\r
+ }\r
+\r
+ /**\r
+ Debug() function provide common Debug information functionality for all \r
+ PCD tool.\r
+\r
+ This function will dispatch message to special class such as BuildAction\r
+ Class, Entity Class etc.\r
+ \r
+ @param thisClass The class object who want Debug information.\r
+ @param debugStr The string contains Debug information.\r
+ **/ \r
+ public static void debug(Object thisClass, String debugStr) {\r
+ if(messageLevel < DEBUG_MESSAGE_LEVEL) {\r
+ return;\r
+ }\r
+\r
+ if(thisClass instanceof Task) {\r
+ BuildAction.logMsg(thisClass, "%%DEBUG%%:" + debugStr);\r
+ } else {\r
+ System.out.println("%%DEBUG%%:" + debugStr);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/** @file\r
+ BuildAction class.\r
+\r
+ BuildAction is the parent class for all action related to ant Task. This class will\r
+ define some common utility functionality, such as logMsg, warningMsg..etc.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+package org.tianocore.pcd.action;\r
+\r
+import org.apache.tools.ant.Task;\r
+import org.apache.tools.ant.Project;\r
+import org.tianocore.pcd.exception.BuildActionException;\r
+\r
+/** BuildAction is the parent class for all action related to ant Task. This class will\r
+ define some common utility functionality, such as logMsg, warningMsg..etc.\r
+**/\r
+public abstract class BuildAction extends Task {\r
+ ///\r
+ /// Original message level before this action. This value will \r
+ /// be restored when quit this action.\r
+ ///\r
+ private int originalMessageLevel;\r
+\r
+ /**\r
+ checkParameter function check all parameter valid.\r
+\r
+ This function will be overrided by child class.\r
+ **/\r
+ public abstract void checkParameter() throws BuildActionException;\r
+\r
+ /**\r
+ performAction is to execute the detail action.\r
+ \r
+ This function will be overrided by child class.\r
+ **/\r
+ public abstract void performAction() throws BuildActionException;\r
+\r
+ /**\r
+ setMessageLevel function set current message for task instance object.\r
+\r
+ The message should be restored when this action exit.\r
+\r
+ @param messageLevel The message level for this action.\r
+ **/\r
+ public void setMessageLevel(int messageLevel) {\r
+ originalMessageLevel = ActionMessage.messageLevel;\r
+ ActionMessage.messageLevel = messageLevel;\r
+ }\r
+\r
+ /**\r
+ logMsg function provide common log information functionality for all \r
+ PCD tool extends from ANT task class.\r
+\r
+ This function will use the log function in Ant task class.\r
+ \r
+ @param action The class object who want log information.\r
+ @param logStr The string contains log information.\r
+ **/\r
+ public static void logMsg(Object action, String logStr) {\r
+ ((Task) action).log(logStr, Project.MSG_INFO);\r
+ }\r
+\r
+ /**\r
+ warningMsg function provide common warning information functionality for all \r
+ PCD tool.\r
+\r
+ This function will dispatch message to special class such as BuildAction\r
+ Class, Entity Class etc.\r
+ \r
+ @param action The class object who want warn information.\r
+ @param warningStr The string contains warning information.\r
+ **/ \r
+ public static void warningMsg(Object action, String warningStr) {\r
+ ((Task) action).log(warningStr, Project.MSG_WARN);\r
+ }\r
+\r
+ /**\r
+ execute function is the main flow for all build action class.\r
+\r
+ This workflow will be:\r
+ 1) Check paramet of this action.\r
+ 2) Perform the child class action function.\r
+ 3) Restore the message level.\r
+ \r
+ @throws BuildActionException\r
+ **/ \r
+ public void execute() throws BuildActionException {\r
+ checkParameter();\r
+ performAction();\r
+\r
+ //\r
+ // Restore orignal message level when exist the action.\r
+ //\r
+ ActionMessage.messageLevel = originalMessageLevel;\r
+ }\r
+}\r
--- /dev/null
+/** @file\r
+ CommonDefinition class.\r
+\r
+ This class is to define some common marcos and funcions, which used by AutoGen.\r
+ \r
+ Copyright (c) 2006, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ \r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ **/\r
+package org.tianocore.pcd.entity;\r
+\r
+import java.util.HashSet;\r
+import java.util.Iterator;\r
+import java.util.LinkedHashSet;\r
+import java.util.Set;\r
+\r
+/**\r
+ CommonDefinition\r
+ \r
+ This class is to define some common marcos, which used by AutoGen.\r
+ \r
+**/\r
+public class CommonDefinition {\r
+ public final static String spdSuffix = ".spd";\r
+ public final static String mbdSuffix = ".mbd";\r
+ public final static String msaSuffix = ".msa";\r
+ public final static String LibraryStr = "LIBRARY";\r
+ public final static String autoGenHbegin = "extern int __make_me_compile_correctly;\r\n";\r
+ public final static String include = "#include";\r
+ public final static String autoGenCLine1 = "\r\n";\r
+ \r
+ public final static String autoGenCLine2 = "const UINT8 _gDebugPropertyMask "\r
+ + "= DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED"\r
+ + " | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED"\r
+ + " | DEBUG_PROPERTY_DEBUG_CODE_ENABLED;\r\n";\r
+\r
+ public final static String autoGenCLine3 = "const UINTN _gModuleDefaultErrorLevel"\r
+ + " = EFI_D_ERROR | EFI_D_LOAD;\r\n";\r
+ \r
+ public final static String autoGenHLine1 = "#define EFI_SPECIFICATION_VERSION 0x00020000\r\n";\r
+ public final static String autoGenHVersionDefault = "#define EFI_SPECIFICATION_VERSION 0x00000000\r\n";\r
+ public final static String autoGenHLine2 = "#define EDK_RELEASE_VERSION 0x00090000\r\n";\r
+ public final static String autoGenHReleaseDefault = "#define EDK_RELEASE_VERSION 0x00000000\r\n";\r
+\r
+ public final static String includeAutogenH = "#include <AutoGen.h>\r\n" ;\r
+ public final static String marcDefineStr = "#define ";\r
+\r
+ public final static String gEfi = "gEfi";\r
+ public final static String protocolGuid = "ProtocolGuid";\r
+ public final static String ppiGuid = "PpiGuid";\r
+ public final static String guidGuid = "Guid";\r
+\r
+ public final static String tianoR8FlashMapH = "TianoR8FlashMap.h";\r
+ public final static String flashMapH = "FlashMap.h";\r
+ \r
+ //\r
+ // AutoGen.h and AutoGen.c file's header\r
+ //\r
+ public final static String autogenHNotation = \r
+ "/**\r\n" +\r
+ " DO NOT EDIT\r\n" +\r
+ " FILE auto-generated by GenBuild tasks\r\n" +\r
+ " Module name:\r\n" +\r
+ " AutoGen.h\r\n" +\r
+ " Abstract:" +\r
+ " Auto-generated AutoGen.h for building module or library.\r\n" +\r
+ "**/\r\n\r\n";\r
+ \r
+ public final static String autogenCNotation = \r
+ "/**\r\n" +\r
+ " DO NOT EDIT\r\n" +\r
+ " FILE auto-generated by GenBuild tasks\r\n" +\r
+ " Module name:\r\n" +\r
+ " AutoGen.c\r\n" +\r
+ " Abstract:" +\r
+ " Auto-generated AutoGen.c for building module or library.\r\n" +\r
+ "**/\r\n\r\n";\r
+ \r
+ //\r
+ // module type\r
+ //\r
+ public final static int ModuleTypeBase = 0;\r
+ public final static int ModuleTypeSec = 1;\r
+ public final static int ModuleTypePeiCore = 2;\r
+ public final static int ModuleTypePeim = 3;\r
+ public final static int ModuleTypeDxeCore = 4;\r
+ public final static int ModuleTypeDxeDriver = 5;\r
+ public final static int ModuleTypeDxeRuntimeDriver = 6;\r
+ public final static int ModuleTypeDxeSmmDriver = 7;\r
+ public final static int ModuleTypeDxeSalDriver = 8;\r
+ public final static int ModuleTypeUefiDriver = 9;\r
+ public final static int ModuleTypeUefiApplication = 10;\r
+ public final static int ModuleTypeUnknown = 11;\r
+ \r
+ \r
+ //\r
+ // component type\r
+ // \r
+ public final static int ComponentTypeNull = 0;\r
+ public final static int ComponentTypeApriori = 1;\r
+ public final static int ComponentTypeSec = 2;\r
+ public final static int ComponentTypeLibrary = 3;\r
+ public final static int ComponentTypeFvImageFile = 4;\r
+ public final static int ComponentTypeBsDriver = 5;\r
+ public final static int ComponentTypeRtDriver = 6;\r
+ public final static int ComponentTypeSalRtDriver =7;\r
+ public final static int ComponentTypePe32Peim = 8;\r
+ public final static int ComponentTypePicPeim =9;\r
+ public final static int ComponentTypeCombinedPeimDriver =10;\r
+ public final static int ComponentTypePeiCore = 11;\r
+ public final static int ComponentTypeDxeCore = 12;\r
+ public final static int ComponentTypeApplication = 13;\r
+ public final static int ComponentTypeBsDriverEfi = 14;\r
+ public final static int ComponentTypeShellApp = 15;\r
+ public final static int ComponentTypeBinary =16;\r
+ public final static int ComponentTypeLogo = 17;\r
+ public final static int ComponentTypeCustomBuild = 18;\r
+ public final static int ComponentTypeUnknown = 19;\r
+\r
+ \r
+ //\r
+ // Usaged style\r
+ //\r
+ public final static String AlwaysConsumed = "ALWAYS_CONSUMED";\r
+ public final static String AlwaysProduced = "ALWAYS_PRODUCED";\r
+ \r
+\r
+ public static class MyEnum {\r
+ String moduleTypeStr;\r
+ int type;\r
+\r
+ MyEnum (String str, int type) {\r
+ this.type = type;\r
+ this.moduleTypeStr = str;\r
+ }\r
+\r
+ int ForInt(String str) {\r
+ if (str.equals(this.moduleTypeStr)) {\r
+ return this.type;\r
+ } else\r
+ return -1;\r
+ }\r
+ }\r
+ \r
+ //\r
+ // Module type\r
+ //\r
+ public static final MyEnum[] moduleEnum = new MyEnum[] {\r
+ new MyEnum("BASE", ModuleTypeBase),\r
+ new MyEnum("SEC", ModuleTypeSec),\r
+ new MyEnum("PEI_CORE", ModuleTypePeiCore),\r
+ new MyEnum("PEIM", ModuleTypePeim),\r
+ new MyEnum("DXE_CORE", ModuleTypeDxeCore),\r
+ new MyEnum("DXE_DRIVER", ModuleTypeDxeDriver),\r
+ new MyEnum("DXE_RUNTIME_DRIVER", ModuleTypeDxeRuntimeDriver),\r
+ new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver),\r
+ new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),\r
+ new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),\r
+ new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) };\r
+ \r
+ //\r
+ // Component type\r
+ //\r
+ public static final MyEnum[] componentEnum = new MyEnum[]{\r
+ new MyEnum("APRIORI", ComponentTypeApriori),\r
+ new MyEnum("SEC", ComponentTypeSec),\r
+ new MyEnum("LIBRARY", ComponentTypeLibrary),\r
+ new MyEnum("FV_IMAGE_FILE", ComponentTypeFvImageFile),\r
+ new MyEnum("BS_DRIVER", ComponentTypeBsDriver),\r
+ new MyEnum("RT_DRIVER", ComponentTypeRtDriver),\r
+ new MyEnum("SAL_RT_DRIVER", ComponentTypeSalRtDriver),\r
+ new MyEnum("PE32_PEIM", ComponentTypePe32Peim),\r
+ new MyEnum("PIC_PEIM", ComponentTypePicPeim),\r
+ new MyEnum("COMBINED_PEIM_DRIVER", ComponentTypeCombinedPeimDriver),\r
+ new MyEnum("PEI_CORE", ComponentTypePeiCore),\r
+ new MyEnum("DXE_CORE", ComponentTypeDxeCore),\r
+ new MyEnum("APPLICATION", ComponentTypeApplication),\r
+ new MyEnum("BS_DRIVER_EFI", ComponentTypeBsDriverEfi),\r
+ new MyEnum("SHELLAPP", ComponentTypeShellApp),\r
+ new MyEnum("BINARY", ComponentTypeBinary),\r
+ new MyEnum("LOGO", ComponentTypeLogo),\r
+ new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild)\r
+ };\r
+ \r
+ /**\r
+ getModuleType\r
+ \r
+ This function get the module type value according module type string.\r
+ \r
+ @param moduleTypeStr String of modlue type.\r
+ @return \r
+ **/\r
+ static public int getModuleType(String moduleTypeStr) {\r
+ int returnValue = -1;\r
+ for (int i = 0; i < CommonDefinition.moduleEnum.length; i++) {\r
+ returnValue = CommonDefinition.moduleEnum[i].ForInt(moduleTypeStr);\r
+ if (returnValue != -1) {\r
+ return returnValue;\r
+ }\r
+ }\r
+ return CommonDefinition.ModuleTypeUnknown;\r
+ }\r
+\r
+ /**\r
+ getComponentType\r
+ \r
+ This function get the component type value according commponet type \r
+ string.\r
+ \r
+ @param componentTypeStr String of component type.\r
+ @return\r
+ **/\r
+ static public int getComponentType (String componentTypeStr){\r
+ int returnValue = -1;\r
+ for (int i = 0; i < CommonDefinition.componentEnum.length; i++) {\r
+ returnValue = CommonDefinition.componentEnum[i].ForInt(componentTypeStr);\r
+ if (returnValue != -1) {\r
+ return returnValue;\r
+ }\r
+ }\r
+ return CommonDefinition.ComponentTypeUnknown;\r
+ }\r
+\r
+ /**\r
+ getComponentTypeString\r
+ \r
+ This function get the commponet type string according component type value.\r
+ \r
+ @param componentType Integer value of component type.\r
+ @return\r
+ **/\r
+ static public String getComponentTypeString (int componentType) {\r
+ if ((componentType > CommonDefinition.ComponentTypeUnknown) || \r
+ (componentType < CommonDefinition.ComponentTypeNull)) {\r
+ return null;\r
+ }\r
+ for (int index = 0; index < CommonDefinition.componentEnum.length; index ++) {\r
+ if (componentType == CommonDefinition.componentEnum[index].type) {\r
+ return CommonDefinition.componentEnum[index].moduleTypeStr;\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ isLibraryComponent \r
+ \r
+ This function is to check does componet is library according to commponet\r
+ type value.\r
+ \r
+ @param componentType Integer value of component type.\r
+ @return\r
+ **/\r
+ static public boolean isLibraryComponent (int componentType) {\r
+ if (ComponentTypeLibrary == componentType) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+ \r
+ /**\r
+ * formateGuidName\r
+ * \r
+ * This function is to formate GUID to ANSI c form.\r
+ * \r
+ * @param guidNameCon\r
+ * String of GUID.\r
+ * @return Formated GUID.\r
+ */\r
+ public static String formatGuidName(String guidNameConv) {\r
+ String[] strList;\r
+ String guid = "";\r
+ int index = 0;\r
+ if (guidNameConv\r
+ .matches("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}")) {\r
+ strList = guidNameConv.split("-");\r
+ guid = "0x" + strList[0] + ", ";\r
+ guid = guid + "0x" + strList[1] + ", ";\r
+ guid = guid + "0x" + strList[2] + ", ";\r
+ guid = guid + "{";\r
+ guid = guid + "0x" + strList[3].substring(0, 2) + ", ";\r
+ guid = guid + "0x" + strList[3].substring(2, 4);\r
+\r
+ while (index < strList[4].length()) {\r
+ guid = guid + ", ";\r
+ guid = guid + "0x" + strList[4].substring(index, index + 2);\r
+ index = index + 2;\r
+ }\r
+ guid = guid + "}";\r
+ return guid;\r
+ } else if (guidNameConv\r
+ .matches("0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},( )*0x[a-fA-F0-9]{1,4}(,( )*\\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\\})?")) {\r
+ strList = guidNameConv.split(",");\r
+\r
+ //\r
+ // chang Microsoft specific form to ANSI c form\r
+ //\r
+ for (int i = 0; i < 3; i++) {\r
+ guid = guid + strList[i] + ",";\r
+ }\r
+ guid = guid + "{";\r
+\r
+ for (int i = 3; i < strList.length; i++) {\r
+ if (i == strList.length - 1) {\r
+ guid = guid + strList[i];\r
+ } else {\r
+ guid = guid + strList[i] + ",";\r
+ }\r
+ }\r
+ guid = guid + "}";\r
+ return guid;\r
+ } else {\r
+ System.out\r
+ .println("Check GUID Value, it don't conform to the schema!!!");\r
+ return "0";\r
+\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Remove deuplicat string in list\r
+ * \r
+ * This function is to duplicat string in list\r
+ * \r
+ * @param String[]\r
+ * String list.\r
+ * @return String[] String list which remove the duplicate string.\r
+ */\r
+ public static String[] remDupString (String[] orgList){\r
+ Set<String> strList = new LinkedHashSet<String>();\r
+ String[] desList ;\r
+ if (orgList == null){\r
+ return new String[0];\r
+ }\r
+ for (int i = 0; i < orgList.length; i++){\r
+ strList.add(orgList[i]);\r
+ }\r
+ desList = new String[strList.size()];\r
+ Iterator item = strList.iterator();\r
+ int index = 0;\r
+ while (item.hasNext()){\r
+ desList[index] = (String)item.next();\r
+ index++;\r
+ }\r
+ return desList;\r
+ }\r
+ \r
+}
\ No newline at end of file
--- /dev/null
+/** @file\r
+ DynamicTokenValue class.\r
+\r
+ This module contains the value type of a dynamic token.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+package org.tianocore.pcd.entity;\r
+\r
+import java.util.List;\r
+import java.util.UUID;\r
+\r
+import org.tianocore.pcd.exception.EntityException;\r
+\r
+/** This class is to descript a value type of dynamic PCD.\r
+ For a dynamic or dynamicEx type PCD data, the value type can be:\r
+ 1) Hii type: the value of dynamic or dynamicEx is stored into a variable.\r
+ 2) Vpd type: the value of dynamic or dynamicEx is stored into somewhere set\r
+ by OEM.\r
+ 3) Default type: the value of dynamic or dynamicEx is stored into PCD dynamic\r
+ database.\r
+**/\r
+public class DynamicTokenValue {\r
+ ///\r
+ /// Enumeration macro defintion for value type.\r
+ /// BUGBUG: Not use upcase charater is to facility for reading. It may be changed\r
+ /// in coding review.\r
+ public enum VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE}\r
+\r
+ public VALUE_TYPE type;\r
+\r
+ ///\r
+ /// ---------------------------------------------------------------------\r
+ /// Following member is for HII case.\r
+ /// ---------------------------------------------------------------------\r
+ ///\r
+\r
+ ///\r
+ /// variableName is valid only when this token support Hii functionality. variableName\r
+ /// indicates the value of token is associated with what variable.\r
+ /// variableName is defined in FPD.\r
+ public List variableName;\r
+\r
+ ///\r
+ /// variableGuid is the GUID this token associated with.\r
+ ///\r
+ public UUID variableGuid;\r
+\r
+ ///\r
+ /// Variable offset indicate the associated variable's offset in NV storage.\r
+ ///\r
+ public String variableOffset;\r
+\r
+ ///\r
+ /// The default value for HII case.\r
+ /// \r
+ public String hiiDefaultValue;\r
+\r
+ ///\r
+ /// Following member is for VPD case.\r
+ /// BUGBUG: Consider 64 bit integer by using java.math.BigInteger.\r
+ /// \r
+ public String vpdOffset;\r
+\r
+ ///\r
+ /// Following member is for default case.\r
+ /// \r
+ public String value;\r
+\r
+ public DynamicTokenValue() {\r
+ this.type = VALUE_TYPE.DEFAULT_TYPE;\r
+ this.variableName = null;\r
+ this.variableGuid = null;\r
+ this.variableOffset = null;\r
+ this.hiiDefaultValue = null;\r
+\r
+ this.vpdOffset = null;\r
+\r
+ this.value = null;\r
+ }\r
+\r
+ /**\r
+ Set the HII case data.\r
+ \r
+ @param variableName\r
+ @param variableGuid\r
+ @param variableOffset\r
+ @param hiiDefaultValue\r
+ */\r
+ public void setHiiData(List variableName,\r
+ UUID variableGuid,\r
+ String variableOffset,\r
+ String hiiDefaultValue) {\r
+ this.type = VALUE_TYPE.HII_TYPE;\r
+\r
+ this.variableName = variableName;\r
+ this.variableGuid = variableGuid;\r
+ this.variableOffset = variableOffset;\r
+ this.hiiDefaultValue = hiiDefaultValue;\r
+ }\r
+\r
+ /**\r
+ Get the string like L"xxx" for a variable Name.\r
+ \r
+ BUGBUG: In fact, it is not correctly, variable name should be\r
+ treated as unicode UINT16 array.\r
+ \r
+ @return String\r
+ */\r
+ public String getStringOfVariableName() \r
+ throws EntityException {\r
+ String str;\r
+ int index, num;\r
+ char ch;\r
+\r
+ str = "";\r
+ for (index = 0; index < variableName.size(); index ++) {\r
+ num = Integer.decode(variableName.get(index).toString());\r
+ if ((num > 127 ) || (num < 0)) {\r
+ throw new EntityException(String.format("variable name contains >0x80 character, now is not support!"));\r
+ }\r
+ str += (char)num;\r
+ }\r
+\r
+ return str;\r
+ }\r
+\r
+ /**\r
+ Set Vpd case data.\r
+ \r
+ @param vpdOffset\r
+ */\r
+ public void setVpdData(String vpdOffset) {\r
+ this.type = VALUE_TYPE.VPD_TYPE;\r
+\r
+ this.vpdOffset = vpdOffset;\r
+ }\r
+\r
+ /**\r
+ Set default case data.\r
+ \r
+ @param value\r
+ */\r
+ public void setValue(String value) {\r
+ this.type = VALUE_TYPE.DEFAULT_TYPE;\r
+\r
+ this.value = value;\r
+ }\r
+}\r
+\r
+\r
+\r
+\r
+\r
--- /dev/null
+/** @file\r
+ MemoryDatabaseManager class.\r
+\r
+ Database hold all PCD information comes from SPD, MSA, FPD file in memory.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+package org.tianocore.pcd.entity;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.UUID;\r
+\r
+import org.tianocore.pcd.entity.UsageIdentification;\r
+import org.tianocore.pcd.exception.EntityException;\r
+\r
+/** Database hold all PCD information comes from SPD, MSA, FPD file in memory.\r
+**/\r
+public class MemoryDatabaseManager {\r
+ ///\r
+ /// Memory database. The string "cName + SpaceNameGuid" is primary key.\r
+ /// memory database is in global scope, and it will be used for others PCD tools.\r
+ ///\r
+ private static Map<String, Token> memoryDatabase = null;\r
+\r
+ ///\r
+ /// Before build a module, the used libary will be build firstly, the PCD of these\r
+ /// libarry is inheritted by the module, so stored module's PCD information as PCD\r
+ /// context of building libary.\r
+ /// \r
+ public static List<UsageInstance> UsageInstanceContext = null;\r
+\r
+ ///\r
+ /// Current module name, if now is buiding library, this value indicate this library\r
+ /// is for building what module.\r
+ /// \r
+ public static String CurrentModuleName = null;\r
+\r
+ ///\r
+ /// String for PCD PEIM and DXE autogen file\r
+ /// \r
+ public static String PcdPeimHString = "";\r
+ public static String PcdPeimCString = "";\r
+ public static String PcdDxeHString = "";\r
+ public static String PcdDxeCString = "";\r
+\r
+ /**\r
+ Constructure function\r
+ **/\r
+ public MemoryDatabaseManager() {\r
+ //\r
+ // Allocate memory for new database in global scope.\r
+ //\r
+ if (memoryDatabase == null) {\r
+ memoryDatabase = new HashMap<String, Token>();\r
+ }\r
+ }\r
+\r
+ /**\r
+ Judege whether token exists in memory database\r
+ \r
+ @param primaryKey the primaryKey for searching token\r
+ \r
+ @retval TRUE - token already exist in database.\r
+ @retval FALSE - token does not exist in database.\r
+ **/\r
+ public boolean isTokenInDatabase(String primaryKey) {\r
+ return (memoryDatabase.get(primaryKey) != null);\r
+ }\r
+\r
+ /**\r
+ Add a pcd token into memory database.\r
+ \r
+ @param primaryKey the primary key for searching token\r
+ @param token token instance\r
+ **/\r
+ public void addTokenToDatabase(String primaryKey, Token token) {\r
+ memoryDatabase.put(primaryKey, token);\r
+ }\r
+\r
+ /**\r
+ Get a token instance from memory database with primary key.\r
+ \r
+ @param primaryKey the primary key for searching token\r
+ \r
+ @return token instance.\r
+ **/\r
+ public Token getTokenByKey(String primaryKey) {\r
+ return memoryDatabase.get(primaryKey);\r
+ }\r
+\r
+ /**\r
+ Get the number of PCD token record in memory database.\r
+ \r
+ @return the number of PCD token record in memory database.\r
+ **/\r
+ public int getDBSize() {\r
+ return memoryDatabase.size();\r
+ }\r
+\r
+ /**\r
+ Get the token record array contained all PCD token in memory database.\r
+ \r
+ @return the token record array contained all PCD token in memory database.\r
+ **/\r
+ public Token[] getRecordArray() {\r
+ Token[] tokenArray = null;\r
+ Object[] dataArray = null;\r
+ Map.Entry entry = null;\r
+ int index = 0;\r
+\r
+ if (memoryDatabase == null) {\r
+ return null;\r
+ }\r
+\r
+ dataArray = memoryDatabase.entrySet().toArray();\r
+ tokenArray = new Token[memoryDatabase.size()];\r
+ for (index = 0; index < memoryDatabase.size(); index ++) {\r
+ entry =(Map.Entry) dataArray [index];\r
+ tokenArray[index] =(Token) entry.getValue();\r
+ }\r
+\r
+ return tokenArray;\r
+ }\r
+\r
+ /**\r
+ Get record array only contains DYNAMIC or DYNAMIC_EX type PCD.\r
+ \r
+ @return ArrayList\r
+ */\r
+ private ArrayList getDynamicRecordArray() {\r
+ Token[] tokenArray = getRecordArray();\r
+ int index = 0;\r
+ ArrayList<Token> al = new ArrayList<Token>();\r
+\r
+ for (index = 0; index < tokenArray.length; index++) {\r
+ if (tokenArray[index].isDynamicPCD) {\r
+ al.add(tokenArray[index]);\r
+ }\r
+ }\r
+\r
+ return al;\r
+ }\r
+\r
+\r
+ /**\r
+ Get the token record array contained all PCD token referenced by PEI phase.\r
+ The output array is sorted based on descending order of the size of alignment for each feilds.\r
+\r
+ @return the token record array contained all PCD token referenced in PEI phase.\r
+ @throws EntityException\r
+ **/\r
+ public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe) \r
+ throws EntityException {\r
+ int usageInstanceIndex = 0;\r
+ int index = 0;\r
+ ArrayList tokenArrayList = getDynamicRecordArray();\r
+ Object[] usageInstanceArray = null;\r
+ UsageInstance usageInstance = null;\r
+\r
+ //pei = new ArrayList<Token>();\r
+ //dxe = new ArrayList<Token>();\r
+\r
+ for (index = 0; index < tokenArrayList.size(); index++) {\r
+ boolean found = false;\r
+ Token token = (Token) tokenArrayList.get(index);\r
+ if (token.consumers != null) {\r
+ usageInstanceArray = token.consumers.entrySet().toArray();\r
+ for (usageInstanceIndex = 0; usageInstanceIndex < token.consumers.size(); usageInstanceIndex ++) {\r
+ usageInstance =(UsageInstance) (((Map.Entry)usageInstanceArray[usageInstanceIndex]).getValue());\r
+ if (usageInstance.isPeiPhaseComponent()) {\r
+ pei.add(token);\r
+ found = true;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // If no PEI components reference the PCD entry, \r
+ // we check if it is referenced in DXE driver. \r
+ //\r
+ if (!found) {\r
+ if (token.consumers != null) {\r
+ usageInstanceArray = token.consumers.entrySet().toArray();\r
+ for (usageInstanceIndex = 0; usageInstanceIndex < token.consumers.size(); usageInstanceIndex ++) {\r
+ usageInstance =(UsageInstance) (((Map.Entry)usageInstanceArray[usageInstanceIndex]).getValue());\r
+ if (usageInstance.isDxePhaseComponent()) {\r
+ dxe.add(token);\r
+ found = true;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ \r
+ if (!found) {\r
+ if (token.isDynamicPCD && token.consumers.size() == 0) {\r
+ dxe.add(token);\r
+ } else {\r
+ //\r
+ // We only support Dynamice(EX) type for PEI and DXE phase.\r
+ // If it is not referenced in either PEI or DXE, throw exception now.\r
+ //\r
+ throw new EntityException("[PCD tool Internal Error] Dynamic(EX) PCD Entries are referenced in module that is not in PEI phase nor in DXE phase.");\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ return;\r
+ }\r
+\r
+ /**\r
+ Get all PCD record for a module according to module's name, module's GUID,\r
+ package name, package GUID, arch, version information.\r
+ \r
+ @param usageId the id of UsageInstance.\r
+ \r
+ @return all usage instance for this module in memory database.\r
+ **/\r
+ public List<UsageInstance> getUsageInstanceArrayByModuleName(UsageIdentification usageId) {\r
+\r
+ String primaryKey = UsageInstance.getPrimaryKey(usageId);\r
+\r
+ return getUsageInstanceArrayByKeyString(primaryKey);\r
+ }\r
+\r
+ /**\r
+ Get all PCD token for a usage instance according to primary key.\r
+ \r
+ @param primaryKey the primary key of usage instance.\r
+ \r
+ @return List<UsageInstance>\r
+ */\r
+ public List<UsageInstance> getUsageInstanceArrayByKeyString(String primaryKey) {\r
+ Token[] tokenArray = null;\r
+ int recordIndex = 0; \r
+ UsageInstance usageInstance = null;\r
+ List<UsageInstance> returnArray = new ArrayList<UsageInstance>();\r
+\r
+ tokenArray = getRecordArray();\r
+\r
+ //\r
+ // Loop to find all PCD record related to current module\r
+ //\r
+ for (recordIndex = 0; recordIndex < getDBSize(); recordIndex ++) {\r
+ if (tokenArray[recordIndex].consumers.size() != 0) {\r
+ usageInstance = tokenArray[recordIndex].consumers.get(primaryKey);\r
+ if (usageInstance != null) {\r
+ returnArray.add(usageInstance);\r
+ }\r
+ }\r
+ }\r
+\r
+ return returnArray;\r
+ }\r
+\r
+ /**\r
+ Get all modules name who contains PCD information\r
+ \r
+ @return Array for module name\r
+ **/\r
+ public List<String> getAllModuleArray()\r
+ {\r
+ int indexToken = 0;\r
+ int usageIndex = 0;\r
+ int moduleIndex = 0;\r
+ Token[] tokenArray = null;\r
+ Object[] usageInstanceArray = null;\r
+ List<String> moduleNames = new ArrayList<String>();\r
+ UsageInstance usageInstance = null;\r
+ boolean bFound = false;\r
+\r
+ tokenArray = getRecordArray();\r
+ //\r
+ // Find all consumer usage instance for retrieving module's name\r
+ //\r
+ for (indexToken = 0; indexToken < getDBSize(); indexToken ++) {\r
+ usageInstanceArray = tokenArray[indexToken].consumers.entrySet().toArray();\r
+ for (usageIndex = 0; usageIndex < tokenArray[indexToken].consumers.size(); usageIndex ++) {\r
+ usageInstance = (UsageInstance)((Map.Entry)usageInstanceArray[usageIndex]).getValue();\r
+ bFound = false;\r
+ for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {\r
+ if (moduleNames.get(moduleIndex).equalsIgnoreCase(usageInstance.getPrimaryKey())) {\r
+ bFound = true;\r
+ break;\r
+ }\r
+ }\r
+ if (!bFound) {\r
+ moduleNames.add(usageInstance.getPrimaryKey());\r
+ }\r
+ }\r
+ }\r
+ return moduleNames;\r
+ }\r
+}\r
--- /dev/null
+/** @file\r
+ SkuInstance class.\r
+\r
+ Sku instance contains ID and value, A pcd token maybe contains more than one Sku instance.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+package org.tianocore.pcd.entity;\r
+\r
+/** Sku instance contains ID and value, A pcd token maybe contains more than one Sku instance.\r
+**/\r
+public class SkuInstance {\r
+ ///\r
+ /// The id number of this SKU instance\r
+ ///\r
+ public int id;\r
+ ///\r
+ /// The value of this SKU instance\r
+ ///\r
+ public DynamicTokenValue value;\r
+\r
+ /**\r
+ Constructure function\r
+\r
+ @param id sku id \r
+ @param value sku value for this id.\r
+ **/\r
+ public SkuInstance(int id, DynamicTokenValue value) {\r
+ this.id = id;\r
+ this.value = value;\r
+ }\r
+\r
+ public SkuInstance() {\r
+ this.id = 0;\r
+ this.value = new DynamicTokenValue();\r
+ }\r
+}\r
--- /dev/null
+/** @file\r
+ Token class.\r
+\r
+ This module contains all classes releted to PCD token.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+package org.tianocore.pcd.entity;\r
+\r
+import java.math.BigInteger;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.UUID;\r
+\r
+import org.tianocore.pcd.entity.UsageIdentification;\r
+import org.tianocore.pcd.exception.EntityException;\r
+\r
+/** This class is to descript a PCD token object. The information of a token mainly \r
+ comes from MSA, SPD and setting produced by platform developer. \r
+**/\r
+public class Token {\r
+ ///\r
+ /// Enumeration macro defintion for PCD type.\r
+ /// BUGBUG: Not use upcase charater is to facility for reading. It may be changed\r
+ /// in coding review.\r
+ public enum PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC, \r
+ DYNAMIC_EX, UNKNOWN}\r
+\r
+ ///\r
+ /// Enumeration macro definition for datum type. All type mainly comes from ProcessBind.h.\r
+ /// Wizard maybe expand this type as "int, unsigned int, short, unsigned short etc" in \r
+ /// prompt dialog.\r
+ ///\r
+ public enum DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN}\r
+\r
+ ///\r
+ /// Enumeration macor defintion for usage of PCD\r
+ ///\r
+ public enum PCD_USAGE {ALWAYS_PRODUCED, ALWAYS_CONSUMED, SOMETIMES_PRODUCED,\r
+ SOMETIMES_CONSUMED, UNKNOWN}\r
+\r
+ ///\r
+ /// cName is to identify a PCD entry and will be used for generating autogen.h/autogen.c.\r
+ /// cName will be defined in MSA, SPD and FPD, can be regarded as primary key with token space guid.\r
+ ///\r
+ public String cName;\r
+\r
+ ///\r
+ /// Token space name is the guid defined by token itself in package or module level. This\r
+ /// name mainly for DynamicEx type. For other PCD type token, his token space name is the \r
+ /// assignedtokenSpaceName as follows.\r
+ /// tokenSpaceName is defined in MSA, SPD, FPD, can be regarded as primary key with cName.\r
+ ///\r
+ public String tokenSpaceName;\r
+\r
+ ///\r
+ /// tokenNumber is allocated by platform. tokenNumber indicate an index for this token in\r
+ /// platform token space. For Dynamic, dynamicEx type, this number will be re-adjust by\r
+ /// PCD run-time database autogen tools.\r
+ ///\r
+ public long tokenNumber;\r
+\r
+ ///\r
+ /// This token number is retrieved from FPD file for DynamicEx type. \r
+ /// \r
+ public long dynamicExTokenNumber;\r
+\r
+ ///\r
+ /// All supported PCD type, this value can be retrieved from SPD\r
+ /// Currently, only record all PCD type for this token in FPD file.\r
+ /// \r
+ public List<PCD_TYPE> supportedPcdType;\r
+\r
+ ///\r
+ /// If the token's item type is Dynamic or DynamicEx type, isDynamicPCD\r
+ /// is true.\r
+ /// \r
+ public boolean isDynamicPCD;\r
+\r
+ ///\r
+ /// datumSize is to descript the fix size or max size for this token. \r
+ /// datumSize is defined in SPD.\r
+ ///\r
+ public int datumSize;\r
+\r
+ ///\r
+ /// datum type is to descript what type can be expressed by a PCD token.\r
+ /// For same PCD used in different module, the datum type should be unique.\r
+ /// So it belong memeber to Token class.\r
+ ///\r
+ public DATUM_TYPE datumType;\r
+\r
+ ///\r
+ /// skuData contains all value for SkuNumber of token.\r
+ /// This field is for Dynamic or DynamicEx type PCD, \r
+ ///\r
+ public List<SkuInstance> skuData;\r
+\r
+ ///\r
+ /// consumers array record all module private information who consume this PCD token.\r
+ ///\r
+ public Map<String, UsageInstance> consumers;\r
+\r
+ /**\r
+ Constructure function for Token class\r
+ \r
+ @param cName The name of token\r
+ @param tokenSpaceName The name of token space, it is a guid string\r
+ **/\r
+ public Token(String cName, String tokenSpaceName) {\r
+ this.cName = cName;\r
+ this.tokenSpaceName = tokenSpaceName;\r
+ this.tokenNumber = 0;\r
+ this.datumType = DATUM_TYPE.UNKNOWN;\r
+ this.datumSize = -1;\r
+ this.skuData = new ArrayList<SkuInstance>();\r
+\r
+ this.consumers = new HashMap<String, UsageInstance>();\r
+ this.supportedPcdType = new ArrayList<PCD_TYPE>();\r
+ }\r
+\r
+ /**\r
+ updateSupportPcdType\r
+ \r
+ SupportPcdType should be gotten from SPD file actually, but now it just\r
+ record all PCD type for this token in FPD file.\r
+ \r
+ @param pcdType new PCD type found in FPD file for this token.\r
+ **/\r
+ public void updateSupportPcdType(PCD_TYPE pcdType) {\r
+ for (int index = 0; index < this.supportedPcdType.size(); index ++) {\r
+ if (supportedPcdType.get(index) == pcdType) {\r
+ return;\r
+ }\r
+ }\r
+\r
+ //\r
+ // If not found, add the pcd type to member variable supportedPcdType\r
+ // \r
+ supportedPcdType.add(pcdType);\r
+ }\r
+\r
+ /**\r
+ Judge whether pcdType is belong to dynamic type. Dynamic type includes\r
+ DYNAMIC and DYNAMIC_EX.\r
+ \r
+ @param pcdType the judged pcd type\r
+ \r
+ @return boolean\r
+ */\r
+ public static boolean isDynamic(PCD_TYPE pcdType) {\r
+ if ((pcdType == PCD_TYPE.DYNAMIC ) ||\r
+ (pcdType == PCD_TYPE.DYNAMIC_EX)) {\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ public boolean isDynamicEx() {\r
+ for (int i = 0; i < supportedPcdType.size(); i++) {\r
+ if (supportedPcdType.get(i) == PCD_TYPE.DYNAMIC_EX) {\r
+ return true;\r
+ }\r
+ }\r
+ \r
+ return false;\r
+ }\r
+\r
+ /**\r
+ Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database\r
+ \r
+ @param cName Token name.\r
+ @param tokenSpaceName The token space guid string defined in MSA or SPD\r
+ \r
+ @retval primary key for this token in token database.\r
+ **/\r
+ public static String getPrimaryKeyString(String cName, String tokenSpaceName) {\r
+ if (tokenSpaceName == null) {\r
+ return cName + "_nullTokenSpaceGuid";\r
+ } else {\r
+ return cName + "_" + tokenSpaceName.toString().replace('-', '_');\r
+ }\r
+ }\r
+\r
+ /**\r
+ If skudata list contains more than one data, then Sku mechanism is enable.\r
+ \r
+ @retval boolean if the number of sku data exceed to 1\r
+ */\r
+ public boolean isSkuEnable() {\r
+ if (this.skuData.size() > 1) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ If Hii type for value of token\r
+ \r
+ @return boolean\r
+ **/\r
+ public boolean isHiiEnable() {\r
+ if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ If Vpd type for value of token\r
+ \r
+ @return boolean\r
+ **/\r
+ public boolean isVpdEnable() {\r
+ if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ Get the token primary key in token database.\r
+ \r
+ @return String\r
+ */\r
+ public String getPrimaryKeyString () {\r
+ return Token.getPrimaryKeyString(cName, tokenSpaceName);\r
+ }\r
+\r
+ /**\r
+ Judge datumType is valid\r
+ \r
+ @param type The datumType want to be judged.\r
+ \r
+ @retval TRUE - The type is valid.\r
+ @retval FALSE - The type is invalid.\r
+ **/\r
+ public static boolean isValiddatumType(DATUM_TYPE type) {\r
+ if ((type.ordinal() < DATUM_TYPE.UINT8.ordinal() ) || \r
+ (type.ordinal() > DATUM_TYPE.POINTER.ordinal())) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ Judge pcdType is valid\r
+ \r
+ @param type The PCdType want to be judged.\r
+ \r
+ @retval TRUE - The type is valid.\r
+ @retval FALSE - The type is invalid.\r
+ **/\r
+ public static boolean isValidpcdType(PCD_TYPE type) {\r
+ if ((type.ordinal() < PCD_TYPE.FEATURE_FLAG.ordinal() ) || \r
+ (type.ordinal() > PCD_TYPE.DYNAMIC_EX.ordinal())) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ Add an usage instance for token\r
+ \r
+ @param usageInstance The usage instance\r
+ \r
+ @retval TRUE - Success to add usage instance.\r
+ @retval FALSE - Fail to add usage instance\r
+ **/\r
+ public boolean addUsageInstance(UsageInstance usageInstance) throws EntityException {\r
+ String exceptionStr;\r
+\r
+ if (isUsageInstanceExist(usageInstance.usageId)) {\r
+ exceptionStr = String.format("[PCD Collection Tool Exception] PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
+ "in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!",\r
+ usageInstance.parentToken.cName,\r
+ usageInstance.usageId.moduleName,\r
+ usageInstance.usageId.moduleName);\r
+ throw new EntityException(exceptionStr);\r
+ }\r
+\r
+ //\r
+ // Put usage instance into usage instance database of this PCD token.\r
+ // \r
+ consumers.put(usageInstance.getPrimaryKey(), usageInstance);\r
+\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ Judge whether exist an usage instance for this token\r
+ \r
+ @param usageId The UsageInstance identification for usage instance\r
+ \r
+ @return boolean whether exist an usage instance for this token.\r
+ */\r
+ public boolean isUsageInstanceExist(UsageIdentification usageId) {\r
+ String keyStr = UsageInstance.getPrimaryKey(usageId);\r
+\r
+ return (consumers.get(keyStr) != null);\r
+ }\r
+\r
+ /**\r
+ Get the PCD_TYPE according to the string of PCD_TYPE\r
+ \r
+ @param pcdTypeStr The string of PCD_TYPE\r
+ \r
+ @return PCD_TYPE\r
+ **/\r
+ public static PCD_TYPE getpcdTypeFromString(String pcdTypeStr) {\r
+ if (pcdTypeStr == null) {\r
+ return PCD_TYPE.UNKNOWN;\r
+ }\r
+\r
+ if (pcdTypeStr.equalsIgnoreCase("FEATURE_FLAG")) {\r
+ return PCD_TYPE.FEATURE_FLAG;\r
+ } else if (pcdTypeStr.equalsIgnoreCase("FIXED_AT_BUILD")) {\r
+ return PCD_TYPE.FIXED_AT_BUILD;\r
+ } else if (pcdTypeStr.equalsIgnoreCase("PATCHABLE_IN_MODULE")) {\r
+ return PCD_TYPE.PATCHABLE_IN_MODULE;\r
+ } else if (pcdTypeStr.equalsIgnoreCase("DYNAMIC")) {\r
+ return PCD_TYPE.DYNAMIC;\r
+ } else if (pcdTypeStr.equalsIgnoreCase("DYNAMIC_EX")) {\r
+ return PCD_TYPE.DYNAMIC_EX;\r
+ } else {\r
+ return PCD_TYPE.UNKNOWN;\r
+ }\r
+ }\r
+\r
+ /**\r
+ Get the string of given datumType. This string will be used for generating autogen files\r
+ \r
+ @param datumType Given datumType\r
+ \r
+ @return The string of datum type.\r
+ **/\r
+ public static String getStringOfdatumType(DATUM_TYPE datumType) {\r
+ switch (datumType) {\r
+ case UINT8:\r
+ return "UINT8";\r
+ case UINT16:\r
+ return "UINT16";\r
+ case UINT32:\r
+ return "UINT32";\r
+ case UINT64:\r
+ return "UINT64";\r
+ case POINTER:\r
+ return "POINTER";\r
+ case BOOLEAN:\r
+ return "BOOLEAN";\r
+ }\r
+ return "UNKNOWN";\r
+ }\r
+\r
+ /**\r
+ Get the datumType according to a string.\r
+ \r
+ @param datumTypeStr The string of datumType\r
+ \r
+ @return DATUM_TYPE\r
+ **/\r
+ public static DATUM_TYPE getdatumTypeFromString(String datumTypeStr) {\r
+ if (datumTypeStr.equalsIgnoreCase("UINT8")) {\r
+ return DATUM_TYPE.UINT8;\r
+ } else if (datumTypeStr.equalsIgnoreCase("UINT16")) {\r
+ return DATUM_TYPE.UINT16;\r
+ } else if (datumTypeStr.equalsIgnoreCase("UINT32")) {\r
+ return DATUM_TYPE.UINT32;\r
+ } else if (datumTypeStr.equalsIgnoreCase("UINT64")) {\r
+ return DATUM_TYPE.UINT64;\r
+ } else if (datumTypeStr.equalsIgnoreCase("VOID*")) {\r
+ return DATUM_TYPE.POINTER;\r
+ } else if (datumTypeStr.equalsIgnoreCase("BOOLEAN")) {\r
+ return DATUM_TYPE.BOOLEAN;\r
+ }\r
+ return DATUM_TYPE.UNKNOWN;\r
+ }\r
+\r
+ /**\r
+ Get string of given pcdType\r
+ \r
+ @param pcdType The given PcdType\r
+ \r
+ @return The string of PCD_TYPE.\r
+ **/\r
+ public static String getStringOfpcdType(PCD_TYPE pcdType) {\r
+ switch (pcdType) {\r
+ case FEATURE_FLAG:\r
+ return "FEATURE_FLAG";\r
+ case FIXED_AT_BUILD:\r
+ return "FIXED_AT_BUILD";\r
+ case PATCHABLE_IN_MODULE:\r
+ return "PATCHABLE_IN_MODULE";\r
+ case DYNAMIC:\r
+ return "DYNAMIC";\r
+ case DYNAMIC_EX:\r
+ return "DYNAMIC_EX";\r
+ }\r
+ return "UNKNOWN";\r
+ }\r
+\r
+ /**\r
+ Get the PCD_USAGE according to a string\r
+ \r
+ @param usageStr The string of PCD_USAGE\r
+ \r
+ @return The PCD_USAGE\r
+ **/\r
+ public static PCD_USAGE getUsageFromString(String usageStr) {\r
+ if (usageStr == null) {\r
+ return PCD_USAGE.UNKNOWN;\r
+ }\r
+\r
+ if (usageStr.equalsIgnoreCase("ALWAYS_PRODUCED")) {\r
+ return PCD_USAGE.ALWAYS_PRODUCED;\r
+ } else if (usageStr.equalsIgnoreCase("SOMETIMES_PRODUCED")) {\r
+ return PCD_USAGE.SOMETIMES_PRODUCED;\r
+ } else if (usageStr.equalsIgnoreCase("ALWAYS_CONSUMED")) {\r
+ return PCD_USAGE.ALWAYS_CONSUMED;\r
+ } else if (usageStr.equalsIgnoreCase("SOMETIMES_CONSUMED")) {\r
+ return PCD_USAGE.SOMETIMES_CONSUMED;\r
+ }\r
+\r
+ return PCD_USAGE.UNKNOWN;\r
+ }\r
+\r
+ /**\r
+ Get the string of given PCD_USAGE\r
+ \r
+ @param usage The given PCD_USAGE\r
+ \r
+ @return The string of PDC_USAGE.\r
+ **/\r
+ public static String getStringOfUsage(PCD_USAGE usage) {\r
+ switch (usage) {\r
+ case ALWAYS_PRODUCED:\r
+ return "ALWAYS_PRODUCED";\r
+ case ALWAYS_CONSUMED:\r
+ return "ALWAYS_CONSUMED";\r
+ case SOMETIMES_PRODUCED:\r
+ return "SOMETIMES_PRODUCED";\r
+ case SOMETIMES_CONSUMED:\r
+ return "SOMETIMES_CONSUMED";\r
+ }\r
+ return "UNKNOWN";\r
+ }\r
+\r
+ /**\r
+ Get the Defined datumType string for autogen. The string is for generating some MACROs in Autogen.h\r
+ \r
+ @param datumType The given datumType\r
+\r
+ @return string of datum type for autogen.\r
+ **/\r
+ public static String GetAutogenDefinedatumTypeString(DATUM_TYPE datumType) {\r
+ switch (datumType) {\r
+ \r
+ case UINT8:\r
+ return "8";\r
+ case UINT16:\r
+ return "16";\r
+ case BOOLEAN:\r
+ return "BOOL";\r
+ case POINTER:\r
+ return "PTR";\r
+ case UINT32:\r
+ return "32";\r
+ case UINT64:\r
+ return "64";\r
+ default:\r
+ return null;\r
+ }\r
+ }\r
+\r
+ /**\r
+ Get the datumType String for Autogen. This string will be used for generating defintions of PCD token in autogen\r
+ \r
+ @param datumType The given datumType\r
+\r
+ @return string of datum type.\r
+ **/\r
+\r
+ public static String getAutogendatumTypeString(DATUM_TYPE datumType) {\r
+ switch (datumType) {\r
+ case UINT8:\r
+ return "UINT8";\r
+ case UINT16:\r
+ return "UINT16";\r
+ case UINT32:\r
+ return "UINT32";\r
+ case UINT64:\r
+ return "UINT64";\r
+ case POINTER:\r
+ return "VOID*";\r
+ case BOOLEAN:\r
+ return "BOOLEAN";\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ Get the datumType string for generating some MACROs in autogen file of Library\r
+ \r
+ @param datumType The given datumType\r
+\r
+ @return String of datum for genrating bit charater.\r
+ **/\r
+ public static String getAutogenLibrarydatumTypeString(DATUM_TYPE datumType) {\r
+ switch (datumType) {\r
+ case UINT8:\r
+ return "8";\r
+ case UINT16:\r
+ return "16";\r
+ case BOOLEAN:\r
+ return "Bool";\r
+ case POINTER:\r
+ return "Ptr";\r
+ case UINT32:\r
+ return "32";\r
+ case UINT64:\r
+ return "64";\r
+ default:\r
+ return null;\r
+ }\r
+ }\r
+\r
+ /**\r
+ Get the sku data who id is 0.\r
+ \r
+ @retval DynamicTokenValue the value of this dyanmic token.\r
+ **/\r
+ public DynamicTokenValue getDefaultSku() {\r
+ DynamicTokenValue dynamicData;\r
+ int index;\r
+\r
+ for (index = 0; index < this.skuData.size(); index ++) {\r
+ if (skuData.get(index).id == 0) {\r
+ return skuData.get(index).value;\r
+ }\r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ Get the number of Sku data for this token\r
+ \r
+ @retval int the number of sku data\r
+ **/\r
+ public int getSkuIdCount () {\r
+ return this.skuData.size();\r
+ }\r
+\r
+ /**\r
+ Get the size of PCD value, this PCD is POINTER type.\r
+ \r
+ @param str the string of the value\r
+ @param al \r
+ **/\r
+ private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {\r
+ if (isValidNullValue(str)) {\r
+ al.add(new Integer(0));\r
+ } else {\r
+ //\r
+ // isValidNullValue has already make sure that str here\r
+ // always contain a valid default value of the following 3\r
+ // cases:\r
+ // 1) "Hello world" //Assci string\r
+ // 2) L"Hello" //Unicode string\r
+ // 3) {0x01, 0x02, 0x03} //Byte stream\r
+ //\r
+ if (str.startsWith("\"")) {\r
+ al.add(new Integer(str.length() - 2));\r
+ } else if (str.startsWith("L\"")){\r
+ //\r
+ // Unicode is 2 bytes each.\r
+ //\r
+ al.add(new Integer((str.length() - 3) * 2));\r
+ } else if (str.startsWith("{")) {\r
+ //\r
+ // We count the number of "," in the string.\r
+ // The number of byte is one plus the number of \r
+ // comma.\r
+ //\r
+ String str2 = str;\r
+ \r
+ int cnt = 0;\r
+ int pos = 0;\r
+ pos = str2.indexOf(",", 0);\r
+ while (pos != -1) {\r
+ cnt++;\r
+ pos++;\r
+ pos = str2.indexOf(",", pos);\r
+ }\r
+ cnt++;\r
+ al.add(new Integer(cnt));\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ This method can be used to get the MAX and current size\r
+ for pointer type dynamic(ex) PCD entry\r
+ **/ \r
+ public ArrayList<Integer> getPointerTypeSize () {\r
+ ArrayList<Integer> al = new ArrayList<Integer>();\r
+ \r
+ //\r
+ // For VPD_enabled and HII_enabled, we can only return the MAX size.\r
+ // For the default DATA type dynamic PCD entry, we will return\r
+ // the MAX size and current size for each SKU_ID.\r
+ //\r
+ al.add(new Integer(this.datumSize));\r
+ \r
+ if (!this.isVpdEnable()) {\r
+ int idx;\r
+ if (this.isHiiEnable()){\r
+ for (idx = 0; idx < this.skuData.size(); idx++) {\r
+ String str = this.skuData.get(idx).value.hiiDefaultValue;\r
+ getCurrentSizeFromDefaultValue(str, al);\r
+ }\r
+ } else {\r
+ for (idx = 0; idx < this.skuData.size(); idx++) {\r
+ String str = this.skuData.get(idx).value.value;\r
+ getCurrentSizeFromDefaultValue(str, al);\r
+ }\r
+ }\r
+ }\r
+ \r
+ return al;\r
+ }\r
+\r
+ /**\r
+ Get default value for a token, For HII type, HiiDefaultValue of default\r
+ SKU 0 will be returned; For Default type, the defaultvalue of default SKU\r
+ 0 will be returned.\r
+ \r
+ @return String\r
+ */\r
+ public String getDynamicDefaultValue() {\r
+ DynamicTokenValue dynamicData = getDefaultSku();\r
+ if (hasDefaultValue()) {\r
+ switch (dynamicData.type) {\r
+ case DEFAULT_TYPE:\r
+ return dynamicData.value;\r
+ }\r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
+ //\r
+ // BugBug: We need change this algorithm accordingly when schema is updated\r
+ // to support no default value.\r
+ //\r
+ public boolean hasDefaultValue () {\r
+ int value = 0;\r
+ boolean isInteger = true;\r
+ DynamicTokenValue dynamicValue = null;\r
+\r
+ if (isSkuEnable()) {\r
+ return true;\r
+ }\r
+ \r
+ if (this.isDynamicPCD) {\r
+ dynamicValue = getDefaultSku();\r
+ switch (dynamicValue.type) {\r
+ case HII_TYPE:\r
+ return true;\r
+ case VPD_TYPE:\r
+ return true;\r
+ case DEFAULT_TYPE:\r
+ return !isValidNullValue(dynamicValue.value);\r
+ }\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ Judge the value is NULL value. NULL value means the value is uninitialized value\r
+ \r
+ @param judgedValue\r
+ \r
+ @return boolean\r
+ */\r
+ public boolean isValidNullValue(String judgedValue) {\r
+ String subStr;\r
+ BigInteger bigIntValue;\r
+\r
+ switch (datumType) {\r
+ case UINT8:\r
+ case UINT16:\r
+ case UINT32:\r
+ if (judgedValue.length() > 2) {\r
+ if ((judgedValue.charAt(0) == '0') && \r
+ ((judgedValue.charAt(1) == 'x') || (judgedValue.charAt(1) == 'X'))){\r
+ subStr = judgedValue.substring(2, judgedValue.length());\r
+ bigIntValue = new BigInteger(subStr, 16);\r
+ } else {\r
+ bigIntValue = new BigInteger(judgedValue);\r
+ }\r
+ } else {\r
+ bigIntValue = new BigInteger(judgedValue);\r
+ }\r
+ if (bigIntValue.bitCount() == 0) {\r
+ return true;\r
+ }\r
+ break;\r
+ case UINT64:\r
+ if (judgedValue.length() > 2){\r
+ if ((judgedValue.charAt(0) == '0') && \r
+ ((judgedValue.charAt(1) == 'x') ||\r
+ (judgedValue.charAt(1) == 'X'))) {\r
+ bigIntValue = new BigInteger(judgedValue.substring(2, judgedValue.length()), 16);\r
+ if (bigIntValue.bitCount() == 0) {\r
+ return true;\r
+ }\r
+ } else {\r
+ bigIntValue = new BigInteger(judgedValue);\r
+ if (bigIntValue.bitCount() == 0) {\r
+ return true;\r
+ }\r
+ }\r
+ } else {\r
+ bigIntValue = new BigInteger(judgedValue);\r
+ if (bigIntValue.bitCount() == 0) {\r
+ return true;\r
+ }\r
+ }\r
+ break;\r
+ case BOOLEAN:\r
+ if (judgedValue.equalsIgnoreCase("false")) {\r
+ return true;\r
+ }\r
+ break;\r
+ case POINTER:\r
+ if (judgedValue.equalsIgnoreCase("") ||\r
+ judgedValue.equalsIgnoreCase("\"\"") ||\r
+ judgedValue.equalsIgnoreCase("L\"\"") ||\r
+ (judgedValue.length() == 0) ||\r
+ judgedValue.equalsIgnoreCase("{0}")) {\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ Is the string value in Unicode\r
+ \r
+ @return boolean\r
+ **/\r
+ public boolean isHiiDefaultValueUnicodeStringType() {\r
+ DynamicTokenValue dynamicData = getDefaultSku();\r
+ \r
+ if (dynamicData == null)\r
+ return false;\r
+ \r
+ return dynamicData.hiiDefaultValue.startsWith("L\"")\r
+ && dynamicData.hiiDefaultValue.endsWith("\"");\r
+ }\r
+\r
+ /**\r
+ Is the string value in ANSCI\r
+ \r
+ @return boolean\r
+ **/\r
+ public boolean isHiiDefaultValueASCIIStringType() {\r
+ DynamicTokenValue dynamicData = getDefaultSku();\r
+ \r
+ if (dynamicData == null)\r
+ return false;\r
+ \r
+ return dynamicData.hiiDefaultValue.startsWith("\"")\r
+ && dynamicData.hiiDefaultValue.endsWith("\"");\r
+ }\r
+ \r
+ /**\r
+ Judege whether current value is UNICODE string type.\r
+ @return boolean\r
+ */\r
+ public boolean isUnicodeStringType () {\r
+ String str = getDynamicDefaultValue();\r
+\r
+ if (str == null) {\r
+ return false;\r
+ }\r
+\r
+ if (datumType == Token.DATUM_TYPE.POINTER &&\r
+ str.startsWith("L\"") && \r
+ str.endsWith("\"")) {\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ }\r
+ \r
+ public boolean isASCIIStringType () {\r
+ String str = getDynamicDefaultValue();\r
+\r
+ if (str == null) {\r
+ return false;\r
+ }\r
+\r
+ if (datumType == Token.DATUM_TYPE.POINTER &&\r
+ str.startsWith("\"") && \r
+ str.endsWith("\"")) {\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ public boolean isByteStreamType () {\r
+ String str = getDynamicDefaultValue();\r
+\r
+ if (str == null) {\r
+ return false;\r
+ }\r
+\r
+ if (datumType == Token.DATUM_TYPE.POINTER &&\r
+ str.startsWith("{") && \r
+ str.endsWith("}")) {\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ \r
+ }\r
+\r
+ public String getStringTypeString () { \r
+ return getDefaultSku().value.substring(2, getDefaultSku().value.length() - 1);\r
+ }\r
+}\r
+\r
+\r
+\r
+\r
--- /dev/null
+/** @file\r
+ UsageIdentification class.\r
+\r
+ This class an identification for a PCD UsageInstance.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+\r
+package org.tianocore.pcd.entity;\r
+\r
+/**\r
+ \r
+**/\r
+public class UsageIdentification {\r
+ ///\r
+ /// The module CName: one key of Identification\r
+ /// \r
+ public String moduleName;\r
+ /// \r
+ /// The module Guid String: one key of Identification\r
+ /// \r
+ public String moduleGuid;\r
+ /// \r
+ /// The package CName: one key of Identification \r
+ ///\r
+ public String packageName;\r
+ /// \r
+ /// The package Guid: one key of Identification\r
+ /// \r
+ public String packageGuid;\r
+ /// \r
+ /// Module's Arch: one key of Identification\r
+ /// \r
+ public String arch;\r
+ /// \r
+ /// Module's version: one key of Identification\r
+ /// \r
+ public String version;\r
+ ///\r
+ /// Module's type\r
+ /// \r
+ public String moduleType;\r
+\r
+ /**\r
+ Constructor function for UsageIdentification class.\r
+\r
+ @param moduleName The key of module's name\r
+ @param moduleGuid The key of module's GUID string\r
+ @param packageName The key of package's name\r
+ @param packageGuid The key of package's Guid\r
+ @param arch The architecture string\r
+ @param version The version String\r
+ @param moduleType The module type\r
+ **/\r
+ public UsageIdentification (String moduleName,\r
+ String moduleGuid,\r
+ String packageName,\r
+ String packageGuid,\r
+ String arch,\r
+ String version,\r
+ String moduleType) {\r
+ this.moduleName = moduleName;\r
+ this.moduleGuid = moduleGuid;\r
+ this.packageName = packageName;\r
+ this.packageGuid = packageGuid;\r
+ this.arch = arch;\r
+ this.version = version;\r
+ this.moduleType = moduleType;\r
+ }\r
+\r
+ /**\r
+ Generate the string for UsageIdentification\r
+\r
+ @return the string value for UsageIdentification\r
+ **/\r
+ public String toString() {\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
+ // BUGBUG: Because currently we can not get version from MSA, So ignore verison.\r
+ // \r
+ return(moduleName + "_" +\r
+ ((moduleGuid != null) ? moduleGuid.toLowerCase() : "NullModuleGuid") + "_" +\r
+ ((packageName != null) ? packageName : "NullPackageName") + "_" +\r
+ ((packageGuid != null) ? packageGuid.toLowerCase() : "NullPackageGuid") + "_" +\r
+ ((arch != null) ? arch : "NullArch") + "_" +\r
+ "NullVersion");\r
+ }\r
+}\r
--- /dev/null
+/** @file\r
+ UsageInstance class.\r
+\r
+ This class indicate an usage instance for a PCD token. This instance maybe a module\r
+ or platform setting. When a module produce or cosume a PCD token, then this module\r
+ is an usage instance for this PCD token.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+package org.tianocore.pcd.entity;\r
+\r
+\r
+import java.util.UUID;\r
+\r
+import org.tianocore.ModuleTypeDef;\r
+import org.tianocore.pcd.entity.CommonDefinition;\r
+import org.tianocore.pcd.entity.UsageIdentification;\r
+import org.tianocore.pcd.exception.EntityException;\r
+\r
+/**\r
+ This class indicate an usage instance for a PCD token. This instance maybe a module\r
+ or platform setting. When a module produce or cosume a PCD token, then this 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
+ ///\r
+ /// ModuleIdentification for Usage Instance\r
+ /// \r
+ public UsageIdentification usageId;\r
+\r
+ ///\r
+ /// Arch also is a key for a UsageInstance\r
+ /// \r
+ public String arch;\r
+\r
+ ///\r
+ /// The PCD type defined for module \r
+ /// \r
+ public Token.PCD_TYPE modulePcdType;\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
+ /// 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 for UsageInstance\r
+ \r
+ @param parentToken The token instance for this usgaInstance\r
+ @param id The identification for usage instance\r
+ @param modulePcdType The PCD type for this usage instance\r
+ @param value The value of this PCD in this usage instance\r
+ @param maxDatumSize The max datum size of this PCD in this usage\r
+ instance.\r
+ **/\r
+ public UsageInstance(Token parentToken,\r
+ UsageIdentification usageId,\r
+ Token.PCD_TYPE modulePcdType,\r
+ String value,\r
+ int maxDatumSize) {\r
+ this.parentToken = parentToken;\r
+ this.usageId = usageId;\r
+ this.modulePcdType = modulePcdType;\r
+ this.datum = value;\r
+ this.maxDatumSize = maxDatumSize;\r
+ }\r
+\r
+ /**\r
+ Get the primary key for usage instance array for every token.\r
+ \r
+ @param usageId The identification of UsageInstance\r
+ \r
+ @retval String The primary key for this usage instance\r
+ **/\r
+ public static String getPrimaryKey(UsageIdentification usageId) {\r
+ return usageId.toString();\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(usageId);\r
+ }\r
+\r
+ /**\r
+ Judget whether current module is PEI driver\r
+ \r
+ @return boolean whether current module is PEI driver\r
+ **/\r
+ public boolean isPeiPhaseComponent() {\r
+ int moduleType = CommonDefinition.getModuleType(usageId.moduleType);\r
+\r
+ if ((moduleType == CommonDefinition.ModuleTypePeiCore) ||\r
+ (moduleType == CommonDefinition.ModuleTypePeim)) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ Judge whether current module is DXE driver.\r
+ \r
+ @return boolean whether current module is DXE driver\r
+ **/\r
+ public boolean isDxePhaseComponent() {\r
+ int moduleType = CommonDefinition.getModuleType(usageId.moduleType);\r
+\r
+ if ((moduleType == CommonDefinition.ModuleTypeDxeDriver) ||\r
+ (moduleType == CommonDefinition.ModuleTypeDxeRuntimeDriver) ||\r
+ (moduleType == CommonDefinition.ModuleTypeDxeSalDriver) ||\r
+ (moduleType == CommonDefinition.ModuleTypeDxeSmmDriver) ||\r
+ (moduleType == CommonDefinition.ModuleTypeUefiDriver) ||\r
+ (moduleType == CommonDefinition.ModuleTypeUefiApplication)\r
+ ) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ Generate autogen string for header file and C code file.\r
+ \r
+ @param isBuildUsedLibrary whether the autogen is for library.\r
+ **/\r
+ public void generateAutoGen(boolean isBuildUsedLibrary) {\r
+ String guidStringCName = null;\r
+ boolean isByteArray = false;\r
+ String printDatum = null;\r
+ String tokenNumberString = null;\r
+\r
+ hAutogenStr = "";\r
+ cAutogenStr = "";\r
+\r
+ if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
+ //\r
+ // For DYNAMIC_EX type PCD, use original token number in SPD or FPD to generate autogen\r
+ // \r
+ tokenNumberString = Long.toString(parentToken.dynamicExTokenNumber, 16);\r
+ } else {\r
+ //\r
+ // For Others type PCD, use autogenerated token number to generate autogen\r
+ // \r
+ tokenNumberString = Long.toString(parentToken.tokenNumber, 16);\r
+ }\r
+\r
+ hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%s\r\n", parentToken.cName, tokenNumberString);\r
+\r
+ //\r
+ // Judge the value of this PCD is byte array type\r
+ // \r
+ if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {\r
+ if (datum.trim().charAt(0) == '{') {\r
+ isByteArray = true;\r
+ }\r
+ }\r
+\r
+ //\r
+ // "ULL" should be added to value's tail for UINT64 value\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
+ hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", \r
+ parentToken.cName);\r
+ hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r
+ parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+ parentToken.cName,\r
+ parentToken.cName);\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
+ parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\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 (isByteArray) {\r
+ hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",\r
+ parentToken.cName);\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
+ 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_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n", \r
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+ parentToken.cName,\r
+ parentToken.cName);\r
+ }\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
+ parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+ parentToken.cName);\r
+ if (!isBuildUsedLibrary) {\r
+ if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+ if (isByteArray) {\r
+ hAutogenStr += String.format("#define _PCD_VALUE_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n", \r
+ parentToken.cName, \r
+ parentToken.cName);\r
+ cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",\r
+ parentToken.cName,\r
+ printDatum);\r
+ } else {\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 %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
+ Token.getAutogendatumTypeString(parentToken.datumType),\r
+ parentToken.cName,\r
+ parentToken.cName);\r
+ }\r
+ } else {\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 %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
+ if (isByteArray) {\r
+ hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",\r
+ parentToken.cName);\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
+ hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
+ Token.getAutogendatumTypeString(parentToken.datumType),\r
+ parentToken.cName);\r
+ hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",\r
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+ parentToken.cName,\r
+ parentToken.cName); \r
+ }\r
+\r
+ //\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
+ 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
+ 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
+ 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("#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
+ 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
+ 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
+ Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
+ parentToken.cName);\r
+ }\r
+ break;\r
+ case DYNAMIC_EX:\r
+ guidStringCName = "_gPcd_TokenSpaceGuid_" +\r
+ parentToken.tokenSpaceName.toString().replaceAll("-", "_");\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
+ Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
+ guidStringCName,\r
+ parentToken.cName);\r
+\r
+ if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\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
+ Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
+ guidStringCName,\r
+ parentToken.cName);\r
+ } else {\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
+ Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
+ guidStringCName,\r
+ parentToken.cName);\r
+\r
+ }\r
+ break;\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
+ /**\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
--- /dev/null
+/** @file\r
+ BuildActionException class.\r
+\r
+ BuildAction Exception deals with all build action exceptions.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+package org.tianocore.pcd.exception;\r
+\r
+import org.apache.tools.ant.BuildException;\r
+\r
+/**\r
+ BuildAction Exception deals with all build action exceptions.\r
+**/\r
+public class BuildActionException extends BuildException {\r
+ static final long serialVersionUID = -7034897190740066939L;\r
+ /**\r
+ Constructure function\r
+ \r
+ @param reason exception message string.\r
+ **/\r
+ public BuildActionException(String reason) {\r
+ super(reason);\r
+ }\r
+}\r
--- /dev/null
+/** @file\r
+ EntityException class.\r
+\r
+ The class handle the exception throwed by entity class.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+package org.tianocore.pcd.exception;\r
+\r
+/**\r
+ The class handle the exception throwed by entity class.\r
+**/\r
+public class EntityException extends Exception {\r
+ static final long serialVersionUID = -8034897190740066939L;\r
+ /**\r
+ Constructure function\r
+ \r
+ @param expStr exception message string.\r
+ **/\r
+ public EntityException(String expStr) {\r
+ super("[PCD EntityException]:" + expStr);\r
+ }\r
+}\r
--- /dev/null
+/** @file\r
+ UIException class.\r
+\r
+ The class handle the exception throwed by UI action class.\r
+ \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+package org.tianocore.pcd.exception;\r
+\r
+/**\r
+ The class handle the exception throwed by UI action class.\r
+**/\r
+public class UIException extends Exception {\r
+ static final long serialVersionUID = -7034897190740066930L;\r
+ /**\r
+ Constructure function\r
+ \r
+ @param reason exception message string.\r
+ **/\r
+ public UIException(String reason) {\r
+ super(reason);\r
+ }\r
+}\r
<Filename>ToolResources.msa</Filename>\r
<Filename>JavaResources.msa</Filename>\r
<Filename>Source/Common/Common.msa</Filename>
+ <Filename>Source/PcdTools/PcdTools.msa</Filename>\r
<Filename>Source/Cpptasks/CppTasks.msa</Filename>
<Filename>Source/FrameworkTasks/FrameworkTasks.msa</Filename>
<Filename>Source/FrameworkWizard/FrameworkWizard.msa</Filename>
<filelist dir="."\r
files="\r
Source/Common/build.xml\r
+ Source/PcdTools/build.xml\r
Source/GenBuild/build.xml\r
Source/FrameworkTasks/build.xml\r
Source/Cpptasks/build.xml\r
Source/Cpptasks/build.xml\r
Source/FrameworkTasks/build.xml\r
Source/GenBuild/build.xml\r
+ Source/PcdTools/build.xml\r
Source/Common/build.xml\r
Source/SurfaceArea/build.xml\r
"/>\r
Source/Cpptasks/build.xml\r
Source/FrameworkTasks/build.xml\r
Source/GenBuild/build.xml\r
+ Source/PcdTools/build.xml\r
Source/Common/build.xml\r
Source/SurfaceArea/build.xml\r
"/>\r
@REM using the cpp-tasks to create our tools\r
@REM\r
set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\Common.jar\r
+set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\PcdTools.jar\r
set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\GenBuild.jar\r
set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\cpptasks.jar\r
set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\frameworktasks.jar\r
set CLASSPATH=%CLASSPATH%;%XMLBEANS_HOME%\lib\resolver.jar\r
set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\SurfaceArea.jar\r
set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\Common.jar\r
+set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\PcdTools.jar\r
set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\GenBuild.jar\r
set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\cpptasks.jar\r
set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\frameworktasks.jar\r
else
# These should be ok as they are.
-export CLASSPATH=$WORKSPACE/Tools/Jars/SurfaceArea.jar:$WORKSPACE/Tools/Jars/frameworktasks.jar:$WORKSPACE/Tools/Jars/cpptasks.jar:$WORKSPACE/Tools/Jars/GenBuild.jar:$XMLBEANS_HOME/lib/resolver.jar:$XMLBEANS_HOME/lib/xbean.jar:$XMLBEANS_HOME/lib/xmlpublic.jar:$XMLBEANS_HOME/lib/jsr173_1.0_api.jar:$XMLBEANS_HOME/lib/saxon8.jar:$XMLBEANS_HOME/lib/xbean_xpath.jar
+export CLASSPATH=$WORKSPACE/Tools/Jars/SurfaceArea.jar:$WORKSPACE/Tools/Jars/frameworktasks.jar:$WORKSPACE/Tools/Jars/cpptasks.jar:$WORKSPACE/Tools/Jars/PcdTools.jar:$WORKSPACE/Tools/Jars/GenBuild.jar:$XMLBEANS_HOME/lib/resolver.jar:$XMLBEANS_HOME/lib/xbean.jar:$XMLBEANS_HOME/lib/xmlpublic.jar:$XMLBEANS_HOME/lib/jsr173_1.0_api.jar:$XMLBEANS_HOME/lib/saxon8.jar:$XMLBEANS_HOME/lib/xbean_xpath.jar
export CLASSPATH=$CLASSPATH:$WORKSPACE/Tools/Jars/Common.jar
export CLASSPATH=$CLASSPATH:$WORKSPACE/Tools/Bin/FrameworkWizard.jar
export FRAMEWORK_TOOLS_PATH=$WORKSPACE/Tools/bin
"$1" = Rebuild -o \
"$1" = ForceRebuild -o \
! -e "$WORKSPACE/Tools/Jars/Common.jar" -o \
+ ! -e "$WORKSPACE/Tools/Jars/PcdTools.jar" -o \
! -e "$WORKSPACE/Tools/Jars/GenBuild.jar" -o \
! -e "$WORKSPACE/Tools/Jars/SurfaceArea.jar" -o \
! -e "$WORKSPACE/Tools/Jars/cpptasks.jar" -o \