From bc2628416cd8bb007c68520b2d45cf9601de0daa Mon Sep 17 00:00:00 2001 From: klu2 Date: Tue, 1 Aug 2006 14:53:02 +0000 Subject: [PATCH] Abstract the logic of Platform pcd preprocess according to FPD file to a class. And add a new class for building process extend this abstract class. (Missing check-in part) git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1170 6f19259b-4bc3-4df7-8a09-765794883524 --- .../tianocore/pcd/action/ActionMessage.java | 36 +- .../action/PlatformPcdPreprocessAction.java | 909 ++++++++++++++++++ .../pcd/entity/CommonDefinition.java | 77 +- .../pcd/entity/DynamicTokenValue.java | 60 +- .../pcd/entity/MemoryDatabaseManager.java | 52 +- .../org/tianocore/pcd/entity/SkuInstance.java | 4 + .../org/tianocore/pcd/entity/Token.java | 174 ++-- .../pcd/entity/UsageIdentification.java | 10 +- .../tianocore/pcd/entity/UsageInstance.java | 93 +- 9 files changed, 1167 insertions(+), 248 deletions(-) create mode 100644 Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/action/ActionMessage.java b/Tools/Source/PcdTools/org/tianocore/pcd/action/ActionMessage.java index 2b589e571a..3c4b467f7f 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/action/ActionMessage.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/action/ActionMessage.java @@ -3,13 +3,13 @@ ActionMessage class take over all message for loging and waning. This class should dispatch message into different class according to instance class type. - + Copyright (c) 2006, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php - + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. @@ -17,49 +17,55 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. package org.tianocore.pcd.action; import org.apache.tools.ant.Task; +import org.tianocore.logger.EdkLog; -/** ActionMessage class take over all message for loging and waning. This class - should dispatch message into different Action class according to instance +/** ActionMessage class take over all message for loging and waning. This class + should dispatch message into different Action class according to instance class type. **/ public class ActionMessage { /// - /// Macro definition for NULL messge level. + /// Macro definition for NULL messge level. /// In this meessage level, all message will be hidden. /// - public final static int NULL_MESSAGE_LEVEL = 0; + public final static int NULL_MESSAGE_LEVEL = 0; + /// /// Macro definition for Log messge level. /// In this message level, Only log information will be shown. /// public final static int LOG_MESSAGE_LEVEL = 1; + /// - /// Macro definition for Warning message level. + /// Macro definition for Warning message level. /// In this message level, log and waning message will be shown. /// public final static int WARNING_MESSAGE_LEVEL = 2; + /// /// Macro definition for Debug mesage level. /// In this message level, log, warning, debug message will be shown. /// public final static int DEBUG_MESSAGE_LEVEL = 3; + /// /// Macor definition for MAX message level. /// In this message level, all message will be shown. /// public final static int MAX_MESSAGE_LEVEL = 4; + /// /// Current message level. It will control all message output for PCD tool. /// public static int messageLevel = NULL_MESSAGE_LEVEL; /** - Log() function provide common log information functionality for all + Log() function provide common log information functionality for all PCD tool includes all function This function will dispatch message to special class such as BuildAction Class, Entity Class etc. - + @param thisClass The class object who want log information. @param logStr The string contains log information. **/ @@ -76,15 +82,15 @@ public class ActionMessage { } /** - Warning() function provide common warning information functionality for all + Warning() function provide common warning information functionality for all PCD tool. This function will dispatch message to special class such as BuildAction Class, Entity Class etc. - + @param thisClass The class object who want warn information. @param warningStr The string contains warning information. - **/ + **/ public static void warning(Object thisClass, String warningStr) { if(messageLevel < WARNING_MESSAGE_LEVEL) { return; @@ -98,15 +104,15 @@ public class ActionMessage { } /** - Debug() function provide common Debug information functionality for all + Debug() function provide common Debug information functionality for all PCD tool. This function will dispatch message to special class such as BuildAction Class, Entity Class etc. - + @param thisClass The class object who want Debug information. @param debugStr The string contains Debug information. - **/ + **/ public static void debug(Object thisClass, String debugStr) { if(messageLevel < DEBUG_MESSAGE_LEVEL) { return; diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java b/Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java new file mode 100644 index 0000000000..f455a9bce0 --- /dev/null +++ b/Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java @@ -0,0 +1,909 @@ +/** @file + PlatformPcdPreprocessAction class. + + The abstract parent class PlatformPcdPreprocessAction, This class is to collect platform's + pcd build information from fpd file. + This class will be extended by building tools and wizard tools. + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +package org.tianocore.pcd.action; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions; +import org.tianocore.PcdBuildDefinitionDocument.PcdBuildDefinition; +import org.tianocore.pcd.entity.MemoryDatabaseManager; +import org.tianocore.pcd.exception.EntityException; +import org.tianocore.pcd.entity.*; +import org.tianocore.pcd.entity.Token; + +/** + The abstract parent class PlatformPcdPreprocessAction, This class is to collect platform's + pcd build information from fpd file. + This class will be extended by building tools and wizard tools. + +**/ +public abstract class PlatformPcdPreprocessAction { + /// + /// PCD memory database + /// + private MemoryDatabaseManager pcdDbManager; + + /** + Set parameter pcdDbManager + + @param pcdDbManager + **/ + public void setPcdDbManager(MemoryDatabaseManager pcdDbManager) { + this.pcdDbManager = pcdDbManager; + } + + /** + Get parameter pcdDbManager + + @return MemoryDatabaseManager + **/ + public MemoryDatabaseManager getPcdDbManager() { + return pcdDbManager; + } + /** + Abstract function: retrieve module information from FPD file. + + In building environement, this function will be implementated by FpdParserTask. + + @return List + **/ + public abstract List getComponentsFromFpd() + throws EntityException; + + /** + Abstract function to get GUID string from SPD file. + + In building evnironment, this function will be implementated by GlobaData. + + @param guidCName the CName of GUID + + @return String[] Guid Info array contains CName and Guid String + **/ + public abstract String[] getGuidInfoFromSpd(String guidCName) + throws EntityException; + + /** + Abstract function: Verification the PCD data. + + In different environment, such as building environment and wizard environment, + it has different implementation according to optimization. + + @param cName + @param moduleName + @param datum + @param datumType + @param maxDatumSize + + @return String + **/ + public abstract String verifyDatum(String cName, + String moduleName, + String datum, + Token.DATUM_TYPE datumType, + int maxDatumSize); + + /** + Abstract function: Get dynamic information for a token + + @param token + @param moduleName + + @return DynamicPcdBuildDefinitions.PcdBuildData + **/ + public abstract DynamicPcdBuildDefinitions.PcdBuildData + getDynamicInfoFromFpd(Token token, + String moduleName) + throws EntityException; + + /** + Abstract function: Get all dynamic PCD information from FPD file. + + @return List + **/ + public abstract List + getAllDynamicPcdInfoFromFpd() + throws EntityException; + + /** + Collect all PCD information from FPD file into PCD memory database. + + **/ + public void initPcdMemoryDbWithPlatformInfo() + throws EntityException { + int index = 0; + int pcdIndex = 0; + List pcdBuildDataArray = new ArrayList(); + PcdBuildDefinition.PcdData pcdBuildData = null; + Token token = null; + List modules = null; + String primaryKey = null; + String exceptionString = null; + UsageInstance usageInstance = null; + Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN; + Token.DATUM_TYPE datumType = Token.DATUM_TYPE.UNKNOWN; + long tokenNumber = 0; + String moduleName = null; + String datum = null; + int maxDatumSize = 0; + String[] tokenSpaceStrRet = null; + + // + // ---------------------------------------------- + // 1), Get all from FPD file. + // ---------------------------------------------- + // + modules = getComponentsFromFpd(); + + if (modules == null) { + throw new EntityException("[FPD file error] No modules in FPD file, Please check whether there are elements in in FPD file!"); + } + + // + // ------------------------------------------------------------------- + // 2), Loop all modules to process for each module. + // ------------------------------------------------------------------- + // + for (index = 0; index < modules.size(); index ++) { + // + // It is legal for a module does not contains ANY pcd build definitions. + // + if (modules.get(index).pcdBuildDefinition == null) { + continue; + } + + pcdBuildDataArray = modules.get(index).pcdBuildDefinition.getPcdDataList(); + + moduleName = modules.get(index).usageId.moduleName; + + // + // ---------------------------------------------------------------------- + // 2.1), Loop all Pcd entry for a module and add it into memory database. + // ---------------------------------------------------------------------- + // + for (pcdIndex = 0; pcdIndex < pcdBuildDataArray.size(); pcdIndex ++) { + pcdBuildData = pcdBuildDataArray.get(pcdIndex); + + tokenSpaceStrRet = getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName()); + + if (tokenSpaceStrRet == null) { + throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName()); + } + + primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), tokenSpaceStrRet[1]); + pcdType = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString()); + datumType = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString()); + tokenNumber = Long.decode(pcdBuildData.getToken().toString()); + if (pcdBuildData.getValue() != null) { + datum = pcdBuildData.getValue().toString(); + } else { + datum = null; + } + maxDatumSize = pcdBuildData.getMaxDatumSize(); + + if ((pcdType == Token.PCD_TYPE.FEATURE_FLAG) && + (datumType != Token.DATUM_TYPE.BOOLEAN)){ + exceptionString = String.format("[FPD file error] For PCD %s in module %s, the PCD type is FEATRUE_FLAG but "+ + "datum type of this PCD entry is not BOOLEAN!", + pcdBuildData.getCName(), + moduleName); + throw new EntityException(exceptionString); + } + + // + // ------------------------------------------------------------------------------------------- + // 2.1.1), Do some necessary checking work for FixedAtBuild, FeatureFlag and PatchableInModule + // ------------------------------------------------------------------------------------------- + // + if (!Token.isDynamic(pcdType)) { + // + // Value is required. + // + if (datum == null) { + exceptionString = String.format("[FPD file error] There is no value for PCD entry %s in module %s!", + pcdBuildData.getCName(), + moduleName); + throw new EntityException(exceptionString); + } + + // + // Check whether the datum size is matched datum type. + // + if ((exceptionString = verifyDatum(pcdBuildData.getCName(), + moduleName, + datum, + datumType, + maxDatumSize)) != null) { + throw new EntityException(exceptionString); + } + } + + // + // --------------------------------------------------------------------------------- + // 2.1.2), Create token or update token information for current anaylized PCD data. + // --------------------------------------------------------------------------------- + // + if (pcdDbManager.isTokenInDatabase(primaryKey)) { + // + // If the token is already exist in database, do some necessary checking + // and add a usage instance into this token in database + // + token = pcdDbManager.getTokenByKey(primaryKey); + + // + // checking for DatumType, DatumType should be unique for one PCD used in different + // modules. + // + if (token.datumType != datumType) { + exceptionString = String.format("[FPD file error] The datum type of PCD entry %s is %s, which is different with %s defined in before!", + pcdBuildData.getCName(), + pcdBuildData.getDatumType().toString(), + Token.getStringOfdatumType(token.datumType)); + throw new EntityException(exceptionString); + } + + // + // Check token number is valid + // + if (tokenNumber != token.tokenNumber) { + exceptionString = String.format("[FPD file error] The token number of PCD entry %s in module %s is different with same PCD entry in other modules!", + pcdBuildData.getCName(), + moduleName); + throw new EntityException(exceptionString); + } + + // + // For same PCD used in different modules, the PCD type should all be dynamic or non-dynamic. + // + if (token.isDynamicPCD != Token.isDynamic(pcdType)) { + exceptionString = String.format("[FPD file error] For PCD entry %s in module %s, you define dynamic or non-dynamic PCD type which"+ + "is different with others module's", + token.cName, + moduleName); + throw new EntityException(exceptionString); + } + + if (token.isDynamicPCD) { + // + // Check datum is equal the datum in dynamic information. + // For dynamic PCD, you can do not write in sperated every in different , + // But if you write, the must be same as the value in . + // + if (!token.isSkuEnable() && + (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.DEFAULT_TYPE) && + (datum != null)) { + if (!datum.equalsIgnoreCase(token.getDefaultSku().value)) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in module %s, the datum in is "+ + "not equal to the datum in , it is "+ + "illega! You could no set in for a dynamic PCD!", + token.cName, + moduleName); + throw new EntityException(exceptionString); + } + } + + if ((maxDatumSize != 0) && + (maxDatumSize != token.datumSize)){ + exceptionString = String.format("[FPD file error] For dynamic PCD %s in module %s, the max datum size is %d which "+ + "is different with %d defined in !", + token.cName, + moduleName, + maxDatumSize, + token.datumSize); + throw new EntityException(exceptionString); + } + } + + } else { + // + // If the token is not in database, create a new token instance and add + // a usage instance into this token in database. + // + tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName()); + + if (tokenSpaceStrRet == null) { + throw new EntityException("Fail to get token space guid for token " + token.cName); + } + + token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]); + + token.datumType = datumType; + token.tokenNumber = tokenNumber; + token.isDynamicPCD = Token.isDynamic(pcdType); + token.datumSize = maxDatumSize; + + if (token.isDynamicPCD) { + // + // For Dynamic and Dynamic Ex type, need find the dynamic information + // in section in FPD file. + // + updateDynamicInformation(moduleName, + token, + datum, + maxDatumSize); + } + + pcdDbManager.addTokenToDatabase(primaryKey, token); + } + + // + // ----------------------------------------------------------------------------------- + // 2.1.3), Add the PcdType in current module into this Pcd token's supported PCD type. + // ----------------------------------------------------------------------------------- + // + token.updateSupportPcdType(pcdType); + + // + // ------------------------------------------------ + // 2.1.4), Create an usage instance for this token. + // ------------------------------------------------ + // + usageInstance = new UsageInstance(token, + modules.get(index).usageId, + pcdType, + datum, + maxDatumSize); + token.addUsageInstance(usageInstance); + } + } + + // + // ------------------------------------------------ + // 3), Add unreference dynamic_Ex pcd token into Pcd database. + // ------------------------------------------------ + // + List tokenArray = getUnreferencedDynamicPcd(); + if (tokenArray != null) { + for (index = 0; index < tokenArray.size(); index ++) { + pcdDbManager.addTokenToDatabase(tokenArray.get(index).getPrimaryKeyString(), + tokenArray.get(index)); + } + } + } + + /** + Update dynamic information for PCD entry. + + Dynamic information is retrieved from in + FPD file. + + @param moduleName The name of the module who use this PCD + @param token The token instance + @param datum The in module's PCD information + @param maxDatumSize The in module's PCD information + + @return Token + */ + private Token updateDynamicInformation(String moduleName, + Token token, + String datum, + int maxDatumSize) + throws EntityException { + int index = 0; + int offset; + String exceptionString = null; + SkuInstance skuInstance = null; + String temp; + boolean hasSkuId0 = false; + long tokenNumber = 0; + String hiiDefaultValue = null; + String[] variableGuidString = null; + + List skuInfoList = null; + DynamicPcdBuildDefinitions.PcdBuildData dynamicInfo = null; + + dynamicInfo = getDynamicInfoFromFpd(token, moduleName); + if (dynamicInfo == null) { + exceptionString = String.format("[FPD file error] For Dynamic PCD %s used by module %s, "+ + "there is no dynamic information in "+ + "in FPD file, but it is required!", + token.cName, + moduleName); + throw new EntityException(exceptionString); + } + + token.datumSize = dynamicInfo.getMaxDatumSize(); + + exceptionString = verifyDatum(token.cName, + moduleName, + null, + token.datumType, + token.datumSize); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + + if ((maxDatumSize != 0) && + (maxDatumSize != token.datumSize)) { + exceptionString = String.format("FPD file error] For dynamic PCD %s, the datum size in module %s is %d, but "+ + "the datum size in is %d, they are not match!", + token.cName, + moduleName, + maxDatumSize, + dynamicInfo.getMaxDatumSize()); + throw new EntityException(exceptionString); + } + tokenNumber = Long.decode(dynamicInfo.getToken().toString()); + if (tokenNumber != token.tokenNumber) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s, the token number in module %s is 0x%x, but"+ + "in , the token number is 0x%x, they are not match!", + token.cName, + moduleName, + token.tokenNumber, + tokenNumber); + throw new EntityException(exceptionString); + } + + token.dynamicExTokenNumber = tokenNumber; + + skuInfoList = dynamicInfo.getSkuInfoList(); + + // + // Loop all sku data + // + for (index = 0; index < skuInfoList.size(); index ++) { + skuInstance = new SkuInstance(); + // + // Although SkuId in schema is BigInteger, but in fact, sku id is 32 bit value. + // + temp = skuInfoList.get(index).getSkuId().toString(); + skuInstance.id = Integer.decode(temp); + if (skuInstance.id == 0) { + hasSkuId0 = true; + } + // + // Judge whether is DefaultGroup at first, because most case is DefautlGroup. + // + if (skuInfoList.get(index).getValue() != null) { + skuInstance.value.setValue(skuInfoList.get(index).getValue().toString()); + if ((exceptionString = verifyDatum(token.cName, + null, + skuInfoList.get(index).getValue().toString(), + token.datumType, + token.datumSize)) != null) { + throw new EntityException(exceptionString); + } + + token.skuData.add(skuInstance); + + // + // Judege wether is same of datum between module's information + // and dynamic information. + // + if (datum != null) { + if ((skuInstance.id == 0) && + !datum.toString().equalsIgnoreCase(skuInfoList.get(index).getValue().toString())) { + exceptionString = "[FPD file error] For dynamic PCD " + token.cName + ", the value in module " + moduleName + " is " + datum.toString() + " but the "+ + "value of sku 0 data in is " + skuInstance.value.value + ". They are must be same!"+ + " or you could not define value for a dynamic PCD in every !"; + throw new EntityException(exceptionString); + } + } + continue; + } + + // + // Judge whether is HII group case. + // + if (skuInfoList.get(index).getVariableName() != null) { + exceptionString = null; + if (skuInfoList.get(index).getVariableGuid() == null) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + "file, who use HII, but there is no defined for Sku %d data!", + token.cName, + index); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + } + + if (skuInfoList.get(index).getVariableOffset() == null) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + "file, who use HII, but there is no defined for Sku %d data!", + token.cName, + index); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + } + + if (skuInfoList.get(index).getHiiDefaultValue() == null) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + "file, who use HII, but there is no defined for Sku %d data!", + token.cName, + index); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + } + + if (skuInfoList.get(index).getHiiDefaultValue() != null) { + hiiDefaultValue = skuInfoList.get(index).getHiiDefaultValue().toString(); + } else { + hiiDefaultValue = null; + } + + if ((exceptionString = verifyDatum(token.cName, + null, + hiiDefaultValue, + token.datumType, + token.datumSize)) != null) { + throw new EntityException(exceptionString); + } + + offset = Integer.decode(skuInfoList.get(index).getVariableOffset()); + if (offset > 0xFFFF) { + throw new EntityException(String.format("[FPD file error] For dynamic PCD %s , the variable offset defined in sku %d data "+ + "exceed 64K, it is not allowed!", + token.cName, + index)); + } + + // + // Get variable guid string according to the name of guid which will be mapped into a GUID in SPD file. + // + variableGuidString = getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString()); + if (variableGuidString == null) { + throw new EntityException(String.format("[GUID Error] For dynamic PCD %s, the variable guid %s can be found in all SPD file!", + token.cName, + skuInfoList.get(index).getVariableGuid().toString())); + } + String variableStr = skuInfoList.get(index).getVariableName(); + Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}"); + Matcher matcher = pattern.matcher(variableStr); + List varNameList = new ArrayList(); + while (matcher.find()){ + String str = variableStr.substring(matcher.start(),matcher.end()); + varNameList.add(str); + } + + skuInstance.value.setHiiData(varNameList, + translateSchemaStringToUUID(variableGuidString[1]), + skuInfoList.get(index).getVariableOffset(), + skuInfoList.get(index).getHiiDefaultValue().toString()); + token.skuData.add(skuInstance); + continue; + } + + if (skuInfoList.get(index).getVpdOffset() != null) { + skuInstance.value.setVpdData(skuInfoList.get(index).getVpdOffset()); + token.skuData.add(skuInstance); + continue; + } + + exceptionString = String.format("[FPD file error] For dynamic PCD %s, the dynamic info must "+ + "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.", + token.cName); + throw new EntityException(exceptionString); + } + + if (!hasSkuId0) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in , there are "+ + "no sku id = 0 data, which is required for every dynamic PCD", + token.cName); + throw new EntityException(exceptionString); + } + + return token; + } + + /** + Get all dynamic PCD defined in which unreferenced by + any in FPD file. + + @return List Return PCD token + **/ + private List getUnreferencedDynamicPcd () throws EntityException { + List tokenArray = new ArrayList(); + Token token = null; + List dynamicPcdBuildDataArray = null; + DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = null; + List skuInfoList = null; + Token.PCD_TYPE pcdType; + SkuInstance skuInstance = null; + String primaryKey = null; + boolean hasSkuId0 = false; + int index, offset, index2; + String temp; + String exceptionString; + String hiiDefaultValue; + String tokenSpaceStrRet[]; + String variableGuidString[]; + + dynamicPcdBuildDataArray = getAllDynamicPcdInfoFromFpd(); + if (dynamicPcdBuildDataArray == null) { + return null; + } + + for (index2 = 0; index2 < dynamicPcdBuildDataArray.size(); index2 ++) { + pcdBuildData = dynamicPcdBuildDataArray.get(index2); + tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName()); + + if (tokenSpaceStrRet == null) { + throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName()); + } + + primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), + tokenSpaceStrRet[1]); + + if (pcdDbManager.isTokenInDatabase(primaryKey)) { + continue; + } + + pcdType = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString()); + if (pcdType != Token.PCD_TYPE.DYNAMIC_EX) { + throw new EntityException (String.format("[FPD file error] It not allowed for DYNAMIC PCD %s who is no used by any module", + pcdBuildData.getCName())); + } + + // + // Create new token for unreference dynamic PCD token + // + token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]); + token.datumSize = pcdBuildData.getMaxDatumSize(); + + + token.datumType = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString()); + token.tokenNumber = Long.decode(pcdBuildData.getToken().toString()); + token.dynamicExTokenNumber = token.tokenNumber; + token.isDynamicPCD = true; + token.updateSupportPcdType(pcdType); + + exceptionString = verifyDatum(token.cName, + null, + null, + token.datumType, + token.datumSize); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + + skuInfoList = pcdBuildData.getSkuInfoList(); + + // + // Loop all sku data + // + for (index = 0; index < skuInfoList.size(); index ++) { + skuInstance = new SkuInstance(); + // + // Although SkuId in schema is BigInteger, but in fact, sku id is 32 bit value. + // + temp = skuInfoList.get(index).getSkuId().toString(); + skuInstance.id = Integer.decode(temp); + if (skuInstance.id == 0) { + hasSkuId0 = true; + } + // + // Judge whether is DefaultGroup at first, because most case is DefautlGroup. + // + if (skuInfoList.get(index).getValue() != null) { + skuInstance.value.setValue(skuInfoList.get(index).getValue().toString()); + if ((exceptionString = verifyDatum(token.cName, + null, + skuInfoList.get(index).getValue().toString(), + token.datumType, + token.datumSize)) != null) { + throw new EntityException(exceptionString); + } + + token.skuData.add(skuInstance); + + continue; + } + + // + // Judge whether is HII group case. + // + if (skuInfoList.get(index).getVariableName() != null) { + exceptionString = null; + if (skuInfoList.get(index).getVariableGuid() == null) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + "file, who use HII, but there is no defined for Sku %d data!", + token.cName, + index); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + } + + if (skuInfoList.get(index).getVariableOffset() == null) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + "file, who use HII, but there is no defined for Sku %d data!", + token.cName, + index); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + } + + if (skuInfoList.get(index).getHiiDefaultValue() == null) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + "file, who use HII, but there is no defined for Sku %d data!", + token.cName, + index); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + } + + if (skuInfoList.get(index).getHiiDefaultValue() != null) { + hiiDefaultValue = skuInfoList.get(index).getHiiDefaultValue().toString(); + } else { + hiiDefaultValue = null; + } + + if ((exceptionString = verifyDatum(token.cName, + null, + hiiDefaultValue, + token.datumType, + token.datumSize)) != null) { + throw new EntityException(exceptionString); + } + + offset = Integer.decode(skuInfoList.get(index).getVariableOffset()); + if (offset > 0xFFFF) { + throw new EntityException(String.format("[FPD file error] For dynamic PCD %s , the variable offset defined in sku %d data "+ + "exceed 64K, it is not allowed!", + token.cName, + index)); + } + + // + // Get variable guid string according to the name of guid which will be mapped into a GUID in SPD file. + // + variableGuidString = this.getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString()); + if (variableGuidString == null) { + throw new EntityException(String.format("[GUID Error] For dynamic PCD %s, the variable guid %s can be found in all SPD file!", + token.cName, + skuInfoList.get(index).getVariableGuid().toString())); + } + String variableStr = skuInfoList.get(index).getVariableName(); + Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}"); + Matcher matcher = pattern.matcher(variableStr); + List varNameList = new ArrayList(); + while (matcher.find()){ + String str = variableStr.substring(matcher.start(),matcher.end()); + varNameList.add(str); + } + + skuInstance.value.setHiiData(varNameList, + translateSchemaStringToUUID(variableGuidString[1]), + skuInfoList.get(index).getVariableOffset(), + skuInfoList.get(index).getHiiDefaultValue().toString()); + token.skuData.add(skuInstance); + continue; + } + + if (skuInfoList.get(index).getVpdOffset() != null) { + skuInstance.value.setVpdData(skuInfoList.get(index).getVpdOffset()); + token.skuData.add(skuInstance); + continue; + } + + exceptionString = String.format("[FPD file error] For dynamic PCD %s, the dynamic info must "+ + "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.", + token.cName); + throw new EntityException(exceptionString); + } + + if (!hasSkuId0) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in , there are "+ + "no sku id = 0 data, which is required for every dynamic PCD", + token.cName); + throw new EntityException(exceptionString); + } + + tokenArray.add(token); + } + + return tokenArray; + } + + /** + Translate the schema string to UUID instance. + + In schema, the string of UUID is defined as following two types string: + 1) GuidArrayType: pattern = 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}( )*(\})? + + 2) GuidNamingConvention: pattern = + [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} + + This function will convert string and create uuid instance. + + @param uuidString UUID string in XML file + + @return UUID UUID instance + **/ + private UUID translateSchemaStringToUUID(String uuidString) + throws EntityException { + String temp; + String[] splitStringArray; + int index; + int chIndex; + int chLen; + + if (uuidString == null) { + return null; + } + + if (uuidString.length() == 0) { + return null; + } + + if (uuidString.equals("0") || + uuidString.equalsIgnoreCase("0x0")) { + return new UUID(0, 0); + } + + uuidString = uuidString.replaceAll("\\{", ""); + uuidString = uuidString.replaceAll("\\}", ""); + + // + // If the UUID schema string is GuidArrayType type then need translate + // to GuidNamingConvention type at first. + // + if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) { + splitStringArray = uuidString.split("," ); + if (splitStringArray.length != 11) { + throw new EntityException ("[FPD file error] Wrong format for UUID string: " + uuidString); + } + + // + // Remove blank space from these string and remove header string "0x" + // + for (index = 0; index < 11; index ++) { + splitStringArray[index] = splitStringArray[index].trim(); + splitStringArray[index] = splitStringArray[index].substring(2, splitStringArray[index].length()); + } + + // + // Add heading '0' to normalize the string length + // + for (index = 3; index < 11; index ++) { + chLen = splitStringArray[index].length(); + for (chIndex = 0; chIndex < 2 - chLen; chIndex ++) { + splitStringArray[index] = "0" + splitStringArray[index]; + } + } + + // + // construct the final GuidNamingConvention string + // + temp = String.format("%s-%s-%s-%s%s-%s%s%s%s%s%s", + splitStringArray[0], + splitStringArray[1], + splitStringArray[2], + splitStringArray[3], + splitStringArray[4], + splitStringArray[5], + splitStringArray[6], + splitStringArray[7], + splitStringArray[8], + splitStringArray[9], + splitStringArray[10]); + uuidString = temp; + } + + return UUID.fromString(uuidString); + } +} + diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/entity/CommonDefinition.java b/Tools/Source/PcdTools/org/tianocore/pcd/entity/CommonDefinition.java index c16bb04f10..aef640c608 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/entity/CommonDefinition.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/entity/CommonDefinition.java @@ -2,29 +2,28 @@ CommonDefinition class. This class is to define some common marcos and funcions, which used by AutoGen. - + Copyright (c) 2006, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php - + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ package org.tianocore.pcd.entity; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; /** CommonDefinition - + This class is to define some common marcos, which used by AutoGen. - + **/ public class CommonDefinition { public final static String spdSuffix = ".spd"; @@ -34,7 +33,7 @@ public class CommonDefinition { public final static String autoGenHbegin = "extern int __make_me_compile_correctly;\r\n"; public final static String include = "#include"; public final static String autoGenCLine1 = "\r\n"; - + public final static String autoGenCLine2 = "const UINT8 _gDebugPropertyMask " + "= DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED" + " | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED" @@ -42,7 +41,7 @@ public class CommonDefinition { public final static String autoGenCLine3 = "const UINTN _gModuleDefaultErrorLevel" + " = EFI_D_ERROR | EFI_D_LOAD;\r\n"; - + public final static String autoGenHLine1 = "#define EFI_SPECIFICATION_VERSION 0x00020000\r\n"; public final static String autoGenHVersionDefault = "#define EFI_SPECIFICATION_VERSION 0x00000000\r\n"; public final static String autoGenHLine2 = "#define EDK_RELEASE_VERSION 0x00090000\r\n"; @@ -58,11 +57,11 @@ public class CommonDefinition { public final static String tianoR8FlashMapH = "TianoR8FlashMap.h"; public final static String flashMapH = "FlashMap.h"; - + // // AutoGen.h and AutoGen.c file's header // - public final static String autogenHNotation = + public final static String autogenHNotation = "/**\r\n" + " DO NOT EDIT\r\n" + " FILE auto-generated by GenBuild tasks\r\n" + @@ -71,8 +70,8 @@ public class CommonDefinition { " Abstract:" + " Auto-generated AutoGen.h for building module or library.\r\n" + "**/\r\n\r\n"; - - public final static String autogenCNotation = + + public final static String autogenCNotation = "/**\r\n" + " DO NOT EDIT\r\n" + " FILE auto-generated by GenBuild tasks\r\n" + @@ -81,7 +80,7 @@ public class CommonDefinition { " Abstract:" + " Auto-generated AutoGen.c for building module or library.\r\n" + "**/\r\n\r\n"; - + // // module type // @@ -97,11 +96,11 @@ public class CommonDefinition { public final static int ModuleTypeUefiDriver = 9; public final static int ModuleTypeUefiApplication = 10; public final static int ModuleTypeUnknown = 11; - - + + // // component type - // + // public final static int ComponentTypeNull = 0; public final static int ComponentTypeApriori = 1; public final static int ComponentTypeSec = 2; @@ -123,13 +122,13 @@ public class CommonDefinition { public final static int ComponentTypeCustomBuild = 18; public final static int ComponentTypeUnknown = 19; - + // // Usaged style // public final static String AlwaysConsumed = "ALWAYS_CONSUMED"; public final static String AlwaysProduced = "ALWAYS_PRODUCED"; - + public static class MyEnum { String moduleTypeStr; @@ -147,7 +146,7 @@ public class CommonDefinition { return -1; } } - + // // Module type // @@ -163,7 +162,7 @@ public class CommonDefinition { new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver), new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver), new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) }; - + // // Component type // @@ -187,14 +186,14 @@ public class CommonDefinition { new MyEnum("LOGO", ComponentTypeLogo), new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild) }; - + /** getModuleType - + This function get the module type value according module type string. - + @param moduleTypeStr String of modlue type. - @return + @return **/ static public int getModuleType(String moduleTypeStr) { int returnValue = -1; @@ -209,10 +208,10 @@ public class CommonDefinition { /** getComponentType - - This function get the component type value according commponet type + + This function get the component type value according commponet type string. - + @param componentTypeStr String of component type. @return **/ @@ -229,14 +228,14 @@ public class CommonDefinition { /** getComponentTypeString - + This function get the commponet type string according component type value. - + @param componentType Integer value of component type. @return **/ static public String getComponentTypeString (int componentType) { - if ((componentType > CommonDefinition.ComponentTypeUnknown) || + if ((componentType > CommonDefinition.ComponentTypeUnknown) || (componentType < CommonDefinition.ComponentTypeNull)) { return null; } @@ -249,11 +248,11 @@ public class CommonDefinition { } /** - isLibraryComponent - + isLibraryComponent + This function is to check does componet is library according to commponet type value. - + @param componentType Integer value of component type. @return **/ @@ -263,12 +262,12 @@ public class CommonDefinition { } return false; } - + /** * formateGuidName - * + * * This function is to formate GUID to ANSI c form. - * + * * @param guidNameCon * String of GUID. * @return Formated GUID. @@ -322,12 +321,12 @@ public class CommonDefinition { } } - + /** * Remove deuplicat string in list - * + * * This function is to duplicat string in list - * + * * @param String[] * String list. * @return String[] String list which remove the duplicate string. @@ -350,5 +349,5 @@ public class CommonDefinition { } return desList; } - + } \ No newline at end of file diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java b/Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java index e8fb8e837d..175fb1a7f5 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java @@ -2,17 +2,17 @@ DynamicTokenValue class. This module contains the value type of a dynamic token. - + Copyright (c) 2006, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php - + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ +**/ package org.tianocore.pcd.entity; import java.util.List; @@ -61,40 +61,43 @@ public class DynamicTokenValue { /// /// The default value for HII case. - /// + /// public String hiiDefaultValue; /// + /// --------------------------------------------------------------------- /// Following member is for VPD case. - /// BUGBUG: Consider 64 bit integer by using java.math.BigInteger. - /// + /// --------------------------------------------------------------------- + /// public String vpdOffset; - /// + /// --------------------------------------------------------------------- /// Following member is for default case. - /// + /// --------------------------------------------------------------------- public String value; + /** + Constructor function for DynamicTokenValue class. + + **/ public DynamicTokenValue() { - this.type = VALUE_TYPE.DEFAULT_TYPE; - this.variableName = null; - this.variableGuid = null; - this.variableOffset = null; - this.hiiDefaultValue = null; - - this.vpdOffset = null; - - this.value = null; + type = VALUE_TYPE.DEFAULT_TYPE; + variableName = null; + variableGuid = null; + variableOffset = null; + hiiDefaultValue = null; + vpdOffset = null; + value = null; } /** Set the HII case data. - - @param variableName - @param variableGuid - @param variableOffset - @param hiiDefaultValue - */ + + @param variableName The variable name + @param variableGuid The variable guid + @param variableOffset The offset of value in this variable + @param hiiDefaultValue Default value for this PCD + **/ public void setHiiData(List variableName, UUID variableGuid, String variableOffset, @@ -109,17 +112,16 @@ public class DynamicTokenValue { /** Get the string like L"xxx" for a variable Name. - + BUGBUG: In fact, it is not correctly, variable name should be treated as unicode UINT16 array. - + @return String */ - public String getStringOfVariableName() + public String getStringOfVariableName() throws EntityException { String str; int index, num; - char ch; str = ""; for (index = 0; index < variableName.size(); index ++) { @@ -135,7 +137,7 @@ public class DynamicTokenValue { /** Set Vpd case data. - + @param vpdOffset */ public void setVpdData(String vpdOffset) { @@ -146,7 +148,7 @@ public class DynamicTokenValue { /** Set default case data. - + @param value */ public void setValue(String value) { diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/entity/MemoryDatabaseManager.java b/Tools/Source/PcdTools/org/tianocore/pcd/entity/MemoryDatabaseManager.java index 7a87469967..90d0db4aaa 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/entity/MemoryDatabaseManager.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/entity/MemoryDatabaseManager.java @@ -2,13 +2,13 @@ MemoryDatabaseManager class. Database hold all PCD information comes from SPD, MSA, FPD file in memory. - + Copyright (c) 2006, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php - + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. @@ -19,12 +19,12 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.UUID; import org.tianocore.pcd.entity.UsageIdentification; import org.tianocore.pcd.exception.EntityException; -/** Database hold all PCD information comes from SPD, MSA, FPD file in memory. +/** + Database hold all PCD information comes from SPD, MSA, FPD file in memory. **/ public class MemoryDatabaseManager { /// @@ -37,18 +37,18 @@ public class MemoryDatabaseManager { /// Before build a module, the used libary will be build firstly, the PCD of these /// libarry is inheritted by the module, so stored module's PCD information as PCD /// context of building libary. - /// + /// public static List UsageInstanceContext = null; /// /// Current module name, if now is buiding library, this value indicate this library /// is for building what module. - /// + /// public static String CurrentModuleName = null; /// /// String for PCD PEIM and DXE autogen file - /// + /// public static String PcdPeimHString = ""; public static String PcdPeimCString = ""; public static String PcdDxeHString = ""; @@ -68,9 +68,9 @@ public class MemoryDatabaseManager { /** Judege whether token exists in memory database - + @param primaryKey the primaryKey for searching token - + @retval TRUE - token already exist in database. @retval FALSE - token does not exist in database. **/ @@ -80,7 +80,7 @@ public class MemoryDatabaseManager { /** Add a pcd token into memory database. - + @param primaryKey the primary key for searching token @param token token instance **/ @@ -90,9 +90,9 @@ public class MemoryDatabaseManager { /** Get a token instance from memory database with primary key. - + @param primaryKey the primary key for searching token - + @return token instance. **/ public Token getTokenByKey(String primaryKey) { @@ -101,7 +101,7 @@ public class MemoryDatabaseManager { /** Get the number of PCD token record in memory database. - + @return the number of PCD token record in memory database. **/ public int getDBSize() { @@ -110,7 +110,7 @@ public class MemoryDatabaseManager { /** Get the token record array contained all PCD token in memory database. - + @return the token record array contained all PCD token in memory database. **/ public Token[] getRecordArray() { @@ -135,7 +135,7 @@ public class MemoryDatabaseManager { /** Get record array only contains DYNAMIC or DYNAMIC_EX type PCD. - + @return ArrayList */ private ArrayList getDynamicRecordArray() { @@ -155,12 +155,12 @@ public class MemoryDatabaseManager { /** Get the token record array contained all PCD token referenced by PEI phase. - The output array is sorted based on descending order of the size of alignment for each feilds. + The output array is sorted based on descending order of the size of alignment for each feilds. @return the token record array contained all PCD token referenced in PEI phase. @throws EntityException **/ - public void getTwoPhaseDynamicRecordArray(ArrayList pei, ArrayList dxe) + public void getTwoPhaseDynamicRecordArray(ArrayList pei, ArrayList dxe) throws EntityException { int usageInstanceIndex = 0; int index = 0; @@ -187,8 +187,8 @@ public class MemoryDatabaseManager { } // - // If no PEI components reference the PCD entry, - // we check if it is referenced in DXE driver. + // If no PEI components reference the PCD entry, + // we check if it is referenced in DXE driver. // if (!found) { if (token.consumers != null) { @@ -202,7 +202,7 @@ public class MemoryDatabaseManager { } } } - + if (!found) { if (token.isDynamicPCD && token.consumers.size() == 0) { dxe.add(token); @@ -223,9 +223,9 @@ public class MemoryDatabaseManager { /** Get all PCD record for a module according to module's name, module's GUID, package name, package GUID, arch, version information. - + @param usageId the id of UsageInstance. - + @return all usage instance for this module in memory database. **/ public List getUsageInstanceArrayByModuleName(UsageIdentification usageId) { @@ -237,14 +237,14 @@ public class MemoryDatabaseManager { /** Get all PCD token for a usage instance according to primary key. - + @param primaryKey the primary key of usage instance. - + @return List */ public List getUsageInstanceArrayByKeyString(String primaryKey) { Token[] tokenArray = null; - int recordIndex = 0; + int recordIndex = 0; UsageInstance usageInstance = null; List returnArray = new ArrayList(); @@ -267,7 +267,7 @@ public class MemoryDatabaseManager { /** Get all modules name who contains PCD information - + @return Array for module name **/ public List getAllModuleArray() diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/entity/SkuInstance.java b/Tools/Source/PcdTools/org/tianocore/pcd/entity/SkuInstance.java index 181e321b0a..f6292d7820 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/entity/SkuInstance.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/entity/SkuInstance.java @@ -22,6 +22,7 @@ public class SkuInstance { /// The id number of this SKU instance /// public int id; + /// /// The value of this SKU instance /// @@ -38,6 +39,9 @@ public class SkuInstance { this.value = value; } + /** + Default constructor function. + **/ public SkuInstance() { this.id = 0; this.value = new DynamicTokenValue(); diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/entity/Token.java b/Tools/Source/PcdTools/org/tianocore/pcd/entity/Token.java index 2e2a297aa0..8429dfd003 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/entity/Token.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/entity/Token.java @@ -2,17 +2,17 @@ Token class. This module contains all classes releted to PCD token. - + Copyright (c) 2006, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php - + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ +**/ package org.tianocore.pcd.entity; import java.math.BigInteger; @@ -20,25 +20,24 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.UUID; import org.tianocore.pcd.entity.UsageIdentification; import org.tianocore.pcd.exception.EntityException; -/** This class is to descript a PCD token object. The information of a token mainly - comes from MSA, SPD and setting produced by platform developer. +/** + This class is to descript a PCD token object. The information of a token mainly + comes from MSA, SPD and setting produced by platform developer. **/ public class Token { /// /// Enumeration macro defintion for PCD type. - /// BUGBUG: Not use upcase charater is to facility for reading. It may be changed - /// in coding review. - public enum PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC, + /// + public enum PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC, DYNAMIC_EX, UNKNOWN} /// /// Enumeration macro definition for datum type. All type mainly comes from ProcessBind.h. - /// Wizard maybe expand this type as "int, unsigned int, short, unsigned short etc" in + /// Wizard maybe expand this type as "int, unsigned int, short, unsigned short etc" in /// prompt dialog. /// public enum DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN} @@ -57,7 +56,7 @@ public class Token { /// /// Token space name is the guid defined by token itself in package or module level. This - /// name mainly for DynamicEx type. For other PCD type token, his token space name is the + /// name mainly for DynamicEx type. For other PCD type token, his token space name is the /// assignedtokenSpaceName as follows. /// tokenSpaceName is defined in MSA, SPD, FPD, can be regarded as primary key with cName. /// @@ -71,24 +70,24 @@ public class Token { public long tokenNumber; /// - /// This token number is retrieved from FPD file for DynamicEx type. - /// + /// This token number is retrieved from FPD file for DynamicEx type. + /// public long dynamicExTokenNumber; /// /// All supported PCD type, this value can be retrieved from SPD /// Currently, only record all PCD type for this token in FPD file. - /// + /// public List supportedPcdType; /// /// If the token's item type is Dynamic or DynamicEx type, isDynamicPCD /// is true. - /// + /// public boolean isDynamicPCD; /// - /// datumSize is to descript the fix size or max size for this token. + /// datumSize is to descript the fix size or max size for this token. /// datumSize is defined in SPD. /// public int datumSize; @@ -102,7 +101,7 @@ public class Token { /// /// skuData contains all value for SkuNumber of token. - /// This field is for Dynamic or DynamicEx type PCD, + /// This field is for Dynamic or DynamicEx type PCD, /// public List skuData; @@ -113,7 +112,7 @@ public class Token { /** Constructure function for Token class - + @param cName The name of token @param tokenSpaceName The name of token space, it is a guid string **/ @@ -131,10 +130,10 @@ public class Token { /** updateSupportPcdType - + SupportPcdType should be gotten from SPD file actually, but now it just record all PCD type for this token in FPD file. - + @param pcdType new PCD type found in FPD file for this token. **/ public void updateSupportPcdType(PCD_TYPE pcdType) { @@ -146,16 +145,16 @@ public class Token { // // If not found, add the pcd type to member variable supportedPcdType - // + // supportedPcdType.add(pcdType); } /** Judge whether pcdType is belong to dynamic type. Dynamic type includes DYNAMIC and DYNAMIC_EX. - + @param pcdType the judged pcd type - + @return boolean */ public static boolean isDynamic(PCD_TYPE pcdType) { @@ -173,16 +172,16 @@ public class Token { return true; } } - + return false; } /** Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database - + @param cName Token name. @param tokenSpaceName The token space guid string defined in MSA or SPD - + @retval primary key for this token in token database. **/ public static String getPrimaryKeyString(String cName, String tokenSpaceName) { @@ -195,7 +194,7 @@ public class Token { /** If skudata list contains more than one data, then Sku mechanism is enable. - + @retval boolean if the number of sku data exceed to 1 */ public boolean isSkuEnable() { @@ -207,7 +206,7 @@ public class Token { /** If Hii type for value of token - + @return boolean **/ public boolean isHiiEnable() { @@ -219,7 +218,7 @@ public class Token { /** If Vpd type for value of token - + @return boolean **/ public boolean isVpdEnable() { @@ -231,7 +230,7 @@ public class Token { /** Get the token primary key in token database. - + @return String */ public String getPrimaryKeyString () { @@ -240,14 +239,14 @@ public class Token { /** Judge datumType is valid - + @param type The datumType want to be judged. - + @retval TRUE - The type is valid. @retval FALSE - The type is invalid. **/ public static boolean isValiddatumType(DATUM_TYPE type) { - if ((type.ordinal() < DATUM_TYPE.UINT8.ordinal() ) || + if ((type.ordinal() < DATUM_TYPE.UINT8.ordinal() ) || (type.ordinal() > DATUM_TYPE.POINTER.ordinal())) { return false; } @@ -256,14 +255,14 @@ public class Token { /** Judge pcdType is valid - + @param type The PCdType want to be judged. - + @retval TRUE - The type is valid. @retval FALSE - The type is invalid. **/ public static boolean isValidpcdType(PCD_TYPE type) { - if ((type.ordinal() < PCD_TYPE.FEATURE_FLAG.ordinal() ) || + if ((type.ordinal() < PCD_TYPE.FEATURE_FLAG.ordinal() ) || (type.ordinal() > PCD_TYPE.DYNAMIC_EX.ordinal())) { return false; } @@ -272,9 +271,9 @@ public class Token { /** Add an usage instance for token - + @param usageInstance The usage instance - + @retval TRUE - Success to add usage instance. @retval FALSE - Fail to add usage instance **/ @@ -292,7 +291,7 @@ public class Token { // // Put usage instance into usage instance database of this PCD token. - // + // consumers.put(usageInstance.getPrimaryKey(), usageInstance); return true; @@ -300,9 +299,9 @@ public class Token { /** Judge whether exist an usage instance for this token - + @param usageId The UsageInstance identification for usage instance - + @return boolean whether exist an usage instance for this token. */ public boolean isUsageInstanceExist(UsageIdentification usageId) { @@ -313,9 +312,9 @@ public class Token { /** Get the PCD_TYPE according to the string of PCD_TYPE - + @param pcdTypeStr The string of PCD_TYPE - + @return PCD_TYPE **/ public static PCD_TYPE getpcdTypeFromString(String pcdTypeStr) { @@ -340,9 +339,9 @@ public class Token { /** Get the string of given datumType. This string will be used for generating autogen files - + @param datumType Given datumType - + @return The string of datum type. **/ public static String getStringOfdatumType(DATUM_TYPE datumType) { @@ -365,9 +364,9 @@ public class Token { /** Get the datumType according to a string. - + @param datumTypeStr The string of datumType - + @return DATUM_TYPE **/ public static DATUM_TYPE getdatumTypeFromString(String datumTypeStr) { @@ -389,9 +388,9 @@ public class Token { /** Get string of given pcdType - + @param pcdType The given PcdType - + @return The string of PCD_TYPE. **/ public static String getStringOfpcdType(PCD_TYPE pcdType) { @@ -412,9 +411,9 @@ public class Token { /** Get the PCD_USAGE according to a string - + @param usageStr The string of PCD_USAGE - + @return The PCD_USAGE **/ public static PCD_USAGE getUsageFromString(String usageStr) { @@ -437,9 +436,9 @@ public class Token { /** Get the string of given PCD_USAGE - + @param usage The given PCD_USAGE - + @return The string of PDC_USAGE. **/ public static String getStringOfUsage(PCD_USAGE usage) { @@ -458,14 +457,14 @@ public class Token { /** Get the Defined datumType string for autogen. The string is for generating some MACROs in Autogen.h - + @param datumType The given datumType @return string of datum type for autogen. **/ public static String GetAutogenDefinedatumTypeString(DATUM_TYPE datumType) { switch (datumType) { - + case UINT8: return "8"; case UINT16: @@ -485,7 +484,7 @@ public class Token { /** Get the datumType String for Autogen. This string will be used for generating defintions of PCD token in autogen - + @param datumType The given datumType @return string of datum type. @@ -511,7 +510,7 @@ public class Token { /** Get the datumType string for generating some MACROs in autogen file of Library - + @param datumType The given datumType @return String of datum for genrating bit charater. @@ -537,11 +536,10 @@ public class Token { /** Get the sku data who id is 0. - + @retval DynamicTokenValue the value of this dyanmic token. **/ public DynamicTokenValue getDefaultSku() { - DynamicTokenValue dynamicData; int index; for (index = 0; index < this.skuData.size(); index ++) { @@ -555,7 +553,7 @@ public class Token { /** Get the number of Sku data for this token - + @retval int the number of sku data **/ public int getSkuIdCount () { @@ -564,9 +562,9 @@ public class Token { /** Get the size of PCD value, this PCD is POINTER type. - + @param str the string of the value - @param al + @param al **/ private void getCurrentSizeFromDefaultValue (String str, ArrayList al) { if (isValidNullValue(str)) { @@ -590,11 +588,11 @@ public class Token { } else if (str.startsWith("{")) { // // We count the number of "," in the string. - // The number of byte is one plus the number of + // The number of byte is one plus the number of // comma. // String str2 = str; - + int cnt = 0; int pos = 0; pos = str2.indexOf(",", 0); @@ -612,17 +610,17 @@ public class Token { /** This method can be used to get the MAX and current size for pointer type dynamic(ex) PCD entry - **/ + **/ public ArrayList getPointerTypeSize () { ArrayList al = new ArrayList(); - + // // For VPD_enabled and HII_enabled, we can only return the MAX size. // For the default DATA type dynamic PCD entry, we will return // the MAX size and current size for each SKU_ID. // al.add(new Integer(this.datumSize)); - + if (!this.isVpdEnable()) { int idx; if (this.isHiiEnable()){ @@ -637,7 +635,7 @@ public class Token { } } } - + return al; } @@ -645,7 +643,7 @@ public class Token { Get default value for a token, For HII type, HiiDefaultValue of default SKU 0 will be returned; For Default type, the defaultvalue of default SKU 0 will be returned. - + @return String */ public String getDynamicDefaultValue() { @@ -665,14 +663,12 @@ public class Token { // to support no default value. // public boolean hasDefaultValue () { - int value = 0; - boolean isInteger = true; DynamicTokenValue dynamicValue = null; if (isSkuEnable()) { return true; } - + if (this.isDynamicPCD) { dynamicValue = getDefaultSku(); switch (dynamicValue.type) { @@ -690,9 +686,9 @@ public class Token { /** Judge the value is NULL value. NULL value means the value is uninitialized value - + @param judgedValue - + @return boolean */ public boolean isValidNullValue(String judgedValue) { @@ -704,7 +700,7 @@ public class Token { case UINT16: case UINT32: if (judgedValue.length() > 2) { - if ((judgedValue.charAt(0) == '0') && + if ((judgedValue.charAt(0) == '0') && ((judgedValue.charAt(1) == 'x') || (judgedValue.charAt(1) == 'X'))){ subStr = judgedValue.substring(2, judgedValue.length()); bigIntValue = new BigInteger(subStr, 16); @@ -720,7 +716,7 @@ public class Token { break; case UINT64: if (judgedValue.length() > 2){ - if ((judgedValue.charAt(0) == '0') && + if ((judgedValue.charAt(0) == '0') && ((judgedValue.charAt(1) == 'x') || (judgedValue.charAt(1) == 'X'))) { bigIntValue = new BigInteger(judgedValue.substring(2, judgedValue.length()), 16); @@ -759,34 +755,34 @@ public class Token { /** Is the string value in Unicode - + @return boolean **/ public boolean isHiiDefaultValueUnicodeStringType() { DynamicTokenValue dynamicData = getDefaultSku(); - + if (dynamicData == null) return false; - + return dynamicData.hiiDefaultValue.startsWith("L\"") && dynamicData.hiiDefaultValue.endsWith("\""); } /** Is the string value in ANSCI - + @return boolean **/ public boolean isHiiDefaultValueASCIIStringType() { DynamicTokenValue dynamicData = getDefaultSku(); - + if (dynamicData == null) return false; - + return dynamicData.hiiDefaultValue.startsWith("\"") && dynamicData.hiiDefaultValue.endsWith("\""); } - + /** Judege whether current value is UNICODE string type. @return boolean @@ -799,14 +795,14 @@ public class Token { } if (datumType == Token.DATUM_TYPE.POINTER && - str.startsWith("L\"") && + str.startsWith("L\"") && str.endsWith("\"")) { return true; } return false; } - + public boolean isASCIIStringType () { String str = getDynamicDefaultValue(); @@ -815,7 +811,7 @@ public class Token { } if (datumType == Token.DATUM_TYPE.POINTER && - str.startsWith("\"") && + str.startsWith("\"") && str.endsWith("\"")) { return true; } @@ -831,16 +827,16 @@ public class Token { } if (datumType == Token.DATUM_TYPE.POINTER && - str.startsWith("{") && + str.startsWith("{") && str.endsWith("}")) { return true; } return false; - + } - public String getStringTypeString () { + public String getStringTypeString () { return getDefaultSku().value.substring(2, getDefaultSku().value.length() - 1); } } diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/entity/UsageIdentification.java b/Tools/Source/PcdTools/org/tianocore/pcd/entity/UsageIdentification.java index 0f52b22d78..0c54525661 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/entity/UsageIdentification.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/entity/UsageIdentification.java @@ -17,33 +17,41 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. package org.tianocore.pcd.entity; /** - + The identification for a UsageInstance. + It should be extend from ModuleIdentification in future. + **/ public class UsageIdentification { /// /// The module CName: one key of Identification /// public String moduleName; + /// /// The module Guid String: one key of Identification /// public String moduleGuid; + /// /// The package CName: one key of Identification /// public String packageName; + /// /// The package Guid: one key of Identification /// public String packageGuid; + /// /// Module's Arch: one key of Identification /// public String arch; + /// /// Module's version: one key of Identification /// public String version; + /// /// Module's type /// diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/entity/UsageInstance.java b/Tools/Source/PcdTools/org/tianocore/pcd/entity/UsageInstance.java index a961d8807d..6fc66055eb 100644 --- a/Tools/Source/PcdTools/org/tianocore/pcd/entity/UsageInstance.java +++ b/Tools/Source/PcdTools/org/tianocore/pcd/entity/UsageInstance.java @@ -4,26 +4,21 @@ This class indicate an usage instance for a PCD token. This instance maybe a module or platform setting. When a module produce or cosume a PCD token, then this module is an usage instance for this PCD token. - + Copyright (c) 2006, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php - + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ +**/ package org.tianocore.pcd.entity; - -import java.util.UUID; - -import org.tianocore.ModuleTypeDef; import org.tianocore.pcd.entity.CommonDefinition; import org.tianocore.pcd.entity.UsageIdentification; -import org.tianocore.pcd.exception.EntityException; /** This class indicate an usage instance for a PCD token. This instance maybe a module @@ -38,29 +33,29 @@ public class UsageInstance { /// /// ModuleIdentification for Usage Instance - /// + /// public UsageIdentification usageId; /// /// Arch also is a key for a UsageInstance - /// + /// public String arch; /// - /// The PCD type defined for module - /// + /// The PCD type defined for module + /// public Token.PCD_TYPE modulePcdType; /// - /// The value of the PCD in this usage instance. - /// + /// The value of the PCD in this usage instance. + /// public String datum; /// /// The maxDatumSize could be different for same PCD in different module /// But this case is allow for FeatureFlag, FixedAtBuild, PatchableInModule /// type. - /// + /// public int maxDatumSize; /// @@ -70,12 +65,12 @@ public class UsageInstance { /// /// Auotgen string for C code file. - /// + /// public String cAutogenStr; /** Constructure function for UsageInstance - + @param parentToken The token instance for this usgaInstance @param id The identification for usage instance @param modulePcdType The PCD type for this usage instance @@ -97,9 +92,9 @@ public class UsageInstance { /** Get the primary key for usage instance array for every token. - + @param usageId The identification of UsageInstance - + @retval String The primary key for this usage instance **/ public static String getPrimaryKey(UsageIdentification usageId) { @@ -108,7 +103,7 @@ public class UsageInstance { /** Get primary key string for this usage instance - + @return String primary key string **/ public String getPrimaryKey() { @@ -117,7 +112,7 @@ public class UsageInstance { /** Judget whether current module is PEI driver - + @return boolean whether current module is PEI driver **/ public boolean isPeiPhaseComponent() { @@ -132,7 +127,7 @@ public class UsageInstance { /** Judge whether current module is DXE driver. - + @return boolean whether current module is DXE driver **/ public boolean isDxePhaseComponent() { @@ -152,7 +147,7 @@ public class UsageInstance { /** Generate autogen string for header file and C code file. - + @param isBuildUsedLibrary whether the autogen is for library. **/ public void generateAutoGen(boolean isBuildUsedLibrary) { @@ -167,12 +162,12 @@ public class UsageInstance { if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) { // // For DYNAMIC_EX type PCD, use original token number in SPD or FPD to generate autogen - // + // tokenNumberString = Long.toString(parentToken.dynamicExTokenNumber, 16); } else { // // For Others type PCD, use autogenerated token number to generate autogen - // + // tokenNumberString = Long.toString(parentToken.tokenNumber, 16); } @@ -180,7 +175,7 @@ public class UsageInstance { // // Judge the value of this PCD is byte array type - // + // if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) { if (datum.trim().charAt(0) == '{') { isByteArray = true; @@ -189,7 +184,7 @@ public class UsageInstance { // // "ULL" should be added to value's tail for UINT64 value - // + // if (parentToken.datumType == Token.DATUM_TYPE.UINT64) { printDatum = this.datum + "ULL"; } else { @@ -198,19 +193,19 @@ public class UsageInstance { switch (modulePcdType) { case FEATURE_FLAG: - hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", + hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n", parentToken.cName); hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n", - parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType), + Token.GetAutogenDefinedatumTypeString(parentToken.datumType), parentToken.cName, parentToken.cName); 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", - parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType), + Token.GetAutogenDefinedatumTypeString(parentToken.datumType), parentToken.cName); if (!isBuildUsedLibrary) { - hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", - parentToken.cName, + hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", + parentToken.cName, printDatum); cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n", parentToken.cName, @@ -221,7 +216,7 @@ public class UsageInstance { if (isByteArray) { hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n", parentToken.cName); - hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n", + hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n", Token.GetAutogenDefinedatumTypeString(parentToken.datumType), parentToken.cName, parentToken.cName); @@ -229,27 +224,27 @@ public class UsageInstance { hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n", Token.getAutogendatumTypeString(parentToken.datumType), parentToken.cName); - hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n", + hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n", Token.GetAutogenDefinedatumTypeString(parentToken.datumType), parentToken.cName, parentToken.cName); } 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", - parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType), + Token.GetAutogenDefinedatumTypeString(parentToken.datumType), parentToken.cName); if (!isBuildUsedLibrary) { if (parentToken.datumType == Token.DATUM_TYPE.POINTER) { if (isByteArray) { - hAutogenStr += String.format("#define _PCD_VALUE_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n", - parentToken.cName, + hAutogenStr += String.format("#define _PCD_VALUE_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n", + parentToken.cName, parentToken.cName); cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n", parentToken.cName, printDatum); } else { - hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", - parentToken.cName, + hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", + parentToken.cName, printDatum); cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n", Token.getAutogendatumTypeString(parentToken.datumType), @@ -257,8 +252,8 @@ public class UsageInstance { parentToken.cName); } } else { - hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", - parentToken.cName, + hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", + parentToken.cName, printDatum); cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n", Token.getAutogendatumTypeString(parentToken.datumType), @@ -274,7 +269,7 @@ public class UsageInstance { hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_BinaryPatch_%s\r\n", Token.GetAutogenDefinedatumTypeString(parentToken.datumType), parentToken.cName, - parentToken.cName); + parentToken.cName); } else { hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n", Token.getAutogendatumTypeString(parentToken.datumType), @@ -282,12 +277,12 @@ public class UsageInstance { hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n", Token.GetAutogenDefinedatumTypeString(parentToken.datumType), parentToken.cName, - parentToken.cName); + parentToken.cName); } // // Generate _PCD_SET_MODE_xx macro for using set BinaryPatch value via PcdSet macro - // + // if (parentToken.datumType == Token.DATUM_TYPE.POINTER) { hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_%s, (Buffer), (SizeOfBuffer))\r\n", Token.GetAutogenDefinedatumTypeString(parentToken.datumType), @@ -299,10 +294,10 @@ public class UsageInstance { parentToken.cName, parentToken.cName); } - + if (!isBuildUsedLibrary) { - hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", - parentToken.cName, + hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n", + parentToken.cName, printDatum); if (isByteArray) { cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[] = _PCD_VALUE_%s;\r\n", @@ -370,7 +365,7 @@ public class UsageInstance { /** Get the autogen string for header file. - + @return The string of header file. **/ public String getHAutogenStr() { @@ -379,7 +374,7 @@ public class UsageInstance { /** Get the autogen string for C code file. - + @return The string of C Code file. **/ public String getCAutogenStr() { -- 2.39.2