mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-26 07:04:28 +02:00
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
This commit is contained in:
parent
af98370ea4
commit
bc2628416c
@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
ActionMessage class take over all message for loging and waning. This class should
|
ActionMessage class take over all message for loging and waning. This class should
|
||||||
dispatch message into different class according to instance class type.
|
dispatch message into different class according to instance class type.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
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;
|
package org.tianocore.pcd.action;
|
||||||
|
|
||||||
import org.apache.tools.ant.Task;
|
import org.apache.tools.ant.Task;
|
||||||
|
import org.tianocore.logger.EdkLog;
|
||||||
|
|
||||||
/** ActionMessage class take over all message for loging and waning. This class
|
/** ActionMessage class take over all message for loging and waning. This class
|
||||||
should dispatch message into different Action class according to instance
|
should dispatch message into different Action class according to instance
|
||||||
class type.
|
class type.
|
||||||
**/
|
**/
|
||||||
public class ActionMessage {
|
public class ActionMessage {
|
||||||
///
|
///
|
||||||
/// Macro definition for NULL messge level.
|
/// Macro definition for NULL messge level.
|
||||||
/// In this meessage level, all message will be hidden.
|
/// 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.
|
/// Macro definition for Log messge level.
|
||||||
/// In this message level, Only log information will be shown.
|
/// In this message level, Only log information will be shown.
|
||||||
///
|
///
|
||||||
public final static int LOG_MESSAGE_LEVEL = 1;
|
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.
|
/// In this message level, log and waning message will be shown.
|
||||||
///
|
///
|
||||||
public final static int WARNING_MESSAGE_LEVEL = 2;
|
public final static int WARNING_MESSAGE_LEVEL = 2;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Macro definition for Debug mesage level.
|
/// Macro definition for Debug mesage level.
|
||||||
/// In this message level, log, warning, debug message will be shown.
|
/// In this message level, log, warning, debug message will be shown.
|
||||||
///
|
///
|
||||||
public final static int DEBUG_MESSAGE_LEVEL = 3;
|
public final static int DEBUG_MESSAGE_LEVEL = 3;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Macor definition for MAX message level.
|
/// Macor definition for MAX message level.
|
||||||
/// In this message level, all message will be shown.
|
/// In this message level, all message will be shown.
|
||||||
///
|
///
|
||||||
public final static int MAX_MESSAGE_LEVEL = 4;
|
public final static int MAX_MESSAGE_LEVEL = 4;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Current message level. It will control all message output for PCD tool.
|
/// Current message level. It will control all message output for PCD tool.
|
||||||
///
|
///
|
||||||
public static int messageLevel = NULL_MESSAGE_LEVEL;
|
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
|
PCD tool includes all function
|
||||||
|
|
||||||
This function will dispatch message to special class such as BuildAction
|
This function will dispatch message to special class such as BuildAction
|
||||||
Class, Entity Class etc.
|
Class, Entity Class etc.
|
||||||
|
|
||||||
@param thisClass The class object who want log information.
|
@param thisClass The class object who want log information.
|
||||||
@param logStr The string contains 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.
|
PCD tool.
|
||||||
|
|
||||||
This function will dispatch message to special class such as BuildAction
|
This function will dispatch message to special class such as BuildAction
|
||||||
Class, Entity Class etc.
|
Class, Entity Class etc.
|
||||||
|
|
||||||
@param thisClass The class object who want warn information.
|
@param thisClass The class object who want warn information.
|
||||||
@param warningStr The string contains warning information.
|
@param warningStr The string contains warning information.
|
||||||
**/
|
**/
|
||||||
public static void warning(Object thisClass, String warningStr) {
|
public static void warning(Object thisClass, String warningStr) {
|
||||||
if(messageLevel < WARNING_MESSAGE_LEVEL) {
|
if(messageLevel < WARNING_MESSAGE_LEVEL) {
|
||||||
return;
|
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.
|
PCD tool.
|
||||||
|
|
||||||
This function will dispatch message to special class such as BuildAction
|
This function will dispatch message to special class such as BuildAction
|
||||||
Class, Entity Class etc.
|
Class, Entity Class etc.
|
||||||
|
|
||||||
@param thisClass The class object who want Debug information.
|
@param thisClass The class object who want Debug information.
|
||||||
@param debugStr The string contains Debug information.
|
@param debugStr The string contains Debug information.
|
||||||
**/
|
**/
|
||||||
public static void debug(Object thisClass, String debugStr) {
|
public static void debug(Object thisClass, String debugStr) {
|
||||||
if(messageLevel < DEBUG_MESSAGE_LEVEL) {
|
if(messageLevel < DEBUG_MESSAGE_LEVEL) {
|
||||||
return;
|
return;
|
||||||
|
@ -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<ModuleInfoFromFpd>
|
||||||
|
**/
|
||||||
|
public abstract List<ModulePcdInfoFromFpd> 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<DynamicPcdBuildDefinitions.PcdBuildData>
|
||||||
|
**/
|
||||||
|
public abstract List<DynamicPcdBuildDefinitions.PcdBuildData>
|
||||||
|
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<PcdBuildDefinition.PcdData> pcdBuildDataArray = new ArrayList<PcdBuildDefinition.PcdData>();
|
||||||
|
PcdBuildDefinition.PcdData pcdBuildData = null;
|
||||||
|
Token token = null;
|
||||||
|
List<ModulePcdInfoFromFpd> 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 <ModuleSA> 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 <FrameworkModules> in FPD file!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// 2), Loop all modules to process <PcdBuildDeclarations> 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 <Value> in sperated every <PcdBuildDefinition> in different <ModuleSA>,
|
||||||
|
// But if you write, the <Value> must be same as the value in <DynamicPcdBuildDefinitions>.
|
||||||
|
//
|
||||||
|
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 <ModuleSA> is "+
|
||||||
|
"not equal to the datum in <DynamicPcdBuildDefinitions>, it is "+
|
||||||
|
"illega! You could no set <Value> in <ModuleSA> 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 <MaxDatumSize> %d defined in <DynamicPcdBuildDefinitions>!",
|
||||||
|
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 <DynamicPcdBuildDefinition> 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<Token> 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 <PcdDynamicBuildDeclarations> in
|
||||||
|
FPD file.
|
||||||
|
|
||||||
|
@param moduleName The name of the module who use this PCD
|
||||||
|
@param token The token instance
|
||||||
|
@param datum The <datum> in module's PCD information
|
||||||
|
@param maxDatumSize The <maxDatumSize> 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<DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> 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 <DynamicPcdBuildDefinitions> "+
|
||||||
|
"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 <DynamicPcdBuildDefinitions> 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 <DynamicPcdBuildDefinictions>, 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 <DynamicPcdBuildDefinition> is " + skuInstance.value.value + ". They are must be same!"+
|
||||||
|
" or you could not define value for a dynamic PCD in every <ModuleSA>!";
|
||||||
|
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 <DynamicPcdBuildDefinitions> section in FPD "+
|
||||||
|
"file, who use HII, but there is no <VariableGuid> 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 <DynamicPcdBuildDefinitions> section in FPD "+
|
||||||
|
"file, who use HII, but there is no <VariableOffset> 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 <DynamicPcdBuildDefinitions> section in FPD "+
|
||||||
|
"file, who use HII, but there is no <HiiDefaultValue> 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<String> varNameList = new ArrayList<String>();
|
||||||
|
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 <DynamicPcdBuildDefinitions>, 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 <DynamicPcdBuildDefinitions> which unreferenced by
|
||||||
|
any <ModuleSA> in FPD file.
|
||||||
|
|
||||||
|
@return List<Token> Return PCD token
|
||||||
|
**/
|
||||||
|
private List<Token> getUnreferencedDynamicPcd () throws EntityException {
|
||||||
|
List<Token> tokenArray = new ArrayList<Token>();
|
||||||
|
Token token = null;
|
||||||
|
List<DynamicPcdBuildDefinitions.PcdBuildData> dynamicPcdBuildDataArray = null;
|
||||||
|
DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = null;
|
||||||
|
List<DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> 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 <DynamicPcdBuildDefinitions> section in FPD "+
|
||||||
|
"file, who use HII, but there is no <VariableGuid> 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 <DynamicPcdBuildDefinitions> section in FPD "+
|
||||||
|
"file, who use HII, but there is no <VariableOffset> 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 <DynamicPcdBuildDefinitions> section in FPD "+
|
||||||
|
"file, who use HII, but there is no <HiiDefaultValue> 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<String> varNameList = new ArrayList<String>();
|
||||||
|
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 <DynamicPcdBuildDefinitions>, 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,29 +2,28 @@
|
|||||||
CommonDefinition class.
|
CommonDefinition class.
|
||||||
|
|
||||||
This class is to define some common marcos and funcions, which used by AutoGen.
|
This class is to define some common marcos and funcions, which used by AutoGen.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
package org.tianocore.pcd.entity;
|
package org.tianocore.pcd.entity;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
CommonDefinition
|
CommonDefinition
|
||||||
|
|
||||||
This class is to define some common marcos, which used by AutoGen.
|
This class is to define some common marcos, which used by AutoGen.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
public class CommonDefinition {
|
public class CommonDefinition {
|
||||||
public final static String spdSuffix = ".spd";
|
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 autoGenHbegin = "extern int __make_me_compile_correctly;\r\n";
|
||||||
public final static String include = "#include";
|
public final static String include = "#include";
|
||||||
public final static String autoGenCLine1 = "\r\n";
|
public final static String autoGenCLine1 = "\r\n";
|
||||||
|
|
||||||
public final static String autoGenCLine2 = "const UINT8 _gDebugPropertyMask "
|
public final static String autoGenCLine2 = "const UINT8 _gDebugPropertyMask "
|
||||||
+ "= DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED"
|
+ "= DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED"
|
||||||
+ " | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED"
|
+ " | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED"
|
||||||
@ -42,7 +41,7 @@ public class CommonDefinition {
|
|||||||
|
|
||||||
public final static String autoGenCLine3 = "const UINTN _gModuleDefaultErrorLevel"
|
public final static String autoGenCLine3 = "const UINTN _gModuleDefaultErrorLevel"
|
||||||
+ " = EFI_D_ERROR | EFI_D_LOAD;\r\n";
|
+ " = EFI_D_ERROR | EFI_D_LOAD;\r\n";
|
||||||
|
|
||||||
public final static String autoGenHLine1 = "#define EFI_SPECIFICATION_VERSION 0x00020000\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 autoGenHVersionDefault = "#define EFI_SPECIFICATION_VERSION 0x00000000\r\n";
|
||||||
public final static String autoGenHLine2 = "#define EDK_RELEASE_VERSION 0x00090000\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 tianoR8FlashMapH = "TianoR8FlashMap.h";
|
||||||
public final static String flashMapH = "FlashMap.h";
|
public final static String flashMapH = "FlashMap.h";
|
||||||
|
|
||||||
//
|
//
|
||||||
// AutoGen.h and AutoGen.c file's header
|
// AutoGen.h and AutoGen.c file's header
|
||||||
//
|
//
|
||||||
public final static String autogenHNotation =
|
public final static String autogenHNotation =
|
||||||
"/**\r\n" +
|
"/**\r\n" +
|
||||||
" DO NOT EDIT\r\n" +
|
" DO NOT EDIT\r\n" +
|
||||||
" FILE auto-generated by GenBuild tasks\r\n" +
|
" FILE auto-generated by GenBuild tasks\r\n" +
|
||||||
@ -71,8 +70,8 @@ public class CommonDefinition {
|
|||||||
" Abstract:" +
|
" Abstract:" +
|
||||||
" Auto-generated AutoGen.h for building module or library.\r\n" +
|
" Auto-generated AutoGen.h for building module or library.\r\n" +
|
||||||
"**/\r\n\r\n";
|
"**/\r\n\r\n";
|
||||||
|
|
||||||
public final static String autogenCNotation =
|
public final static String autogenCNotation =
|
||||||
"/**\r\n" +
|
"/**\r\n" +
|
||||||
" DO NOT EDIT\r\n" +
|
" DO NOT EDIT\r\n" +
|
||||||
" FILE auto-generated by GenBuild tasks\r\n" +
|
" FILE auto-generated by GenBuild tasks\r\n" +
|
||||||
@ -81,7 +80,7 @@ public class CommonDefinition {
|
|||||||
" Abstract:" +
|
" Abstract:" +
|
||||||
" Auto-generated AutoGen.c for building module or library.\r\n" +
|
" Auto-generated AutoGen.c for building module or library.\r\n" +
|
||||||
"**/\r\n\r\n";
|
"**/\r\n\r\n";
|
||||||
|
|
||||||
//
|
//
|
||||||
// module type
|
// module type
|
||||||
//
|
//
|
||||||
@ -97,11 +96,11 @@ public class CommonDefinition {
|
|||||||
public final static int ModuleTypeUefiDriver = 9;
|
public final static int ModuleTypeUefiDriver = 9;
|
||||||
public final static int ModuleTypeUefiApplication = 10;
|
public final static int ModuleTypeUefiApplication = 10;
|
||||||
public final static int ModuleTypeUnknown = 11;
|
public final static int ModuleTypeUnknown = 11;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// component type
|
// component type
|
||||||
//
|
//
|
||||||
public final static int ComponentTypeNull = 0;
|
public final static int ComponentTypeNull = 0;
|
||||||
public final static int ComponentTypeApriori = 1;
|
public final static int ComponentTypeApriori = 1;
|
||||||
public final static int ComponentTypeSec = 2;
|
public final static int ComponentTypeSec = 2;
|
||||||
@ -123,13 +122,13 @@ public class CommonDefinition {
|
|||||||
public final static int ComponentTypeCustomBuild = 18;
|
public final static int ComponentTypeCustomBuild = 18;
|
||||||
public final static int ComponentTypeUnknown = 19;
|
public final static int ComponentTypeUnknown = 19;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Usaged style
|
// Usaged style
|
||||||
//
|
//
|
||||||
public final static String AlwaysConsumed = "ALWAYS_CONSUMED";
|
public final static String AlwaysConsumed = "ALWAYS_CONSUMED";
|
||||||
public final static String AlwaysProduced = "ALWAYS_PRODUCED";
|
public final static String AlwaysProduced = "ALWAYS_PRODUCED";
|
||||||
|
|
||||||
|
|
||||||
public static class MyEnum {
|
public static class MyEnum {
|
||||||
String moduleTypeStr;
|
String moduleTypeStr;
|
||||||
@ -147,7 +146,7 @@ public class CommonDefinition {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Module type
|
// Module type
|
||||||
//
|
//
|
||||||
@ -163,7 +162,7 @@ public class CommonDefinition {
|
|||||||
new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),
|
new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),
|
||||||
new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),
|
new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),
|
||||||
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) };
|
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) };
|
||||||
|
|
||||||
//
|
//
|
||||||
// Component type
|
// Component type
|
||||||
//
|
//
|
||||||
@ -187,14 +186,14 @@ public class CommonDefinition {
|
|||||||
new MyEnum("LOGO", ComponentTypeLogo),
|
new MyEnum("LOGO", ComponentTypeLogo),
|
||||||
new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild)
|
new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
getModuleType
|
getModuleType
|
||||||
|
|
||||||
This function get the module type value according module type string.
|
This function get the module type value according module type string.
|
||||||
|
|
||||||
@param moduleTypeStr String of modlue type.
|
@param moduleTypeStr String of modlue type.
|
||||||
@return
|
@return
|
||||||
**/
|
**/
|
||||||
static public int getModuleType(String moduleTypeStr) {
|
static public int getModuleType(String moduleTypeStr) {
|
||||||
int returnValue = -1;
|
int returnValue = -1;
|
||||||
@ -209,10 +208,10 @@ public class CommonDefinition {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
getComponentType
|
getComponentType
|
||||||
|
|
||||||
This function get the component type value according commponet type
|
This function get the component type value according commponet type
|
||||||
string.
|
string.
|
||||||
|
|
||||||
@param componentTypeStr String of component type.
|
@param componentTypeStr String of component type.
|
||||||
@return
|
@return
|
||||||
**/
|
**/
|
||||||
@ -229,14 +228,14 @@ public class CommonDefinition {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
getComponentTypeString
|
getComponentTypeString
|
||||||
|
|
||||||
This function get the commponet type string according component type value.
|
This function get the commponet type string according component type value.
|
||||||
|
|
||||||
@param componentType Integer value of component type.
|
@param componentType Integer value of component type.
|
||||||
@return
|
@return
|
||||||
**/
|
**/
|
||||||
static public String getComponentTypeString (int componentType) {
|
static public String getComponentTypeString (int componentType) {
|
||||||
if ((componentType > CommonDefinition.ComponentTypeUnknown) ||
|
if ((componentType > CommonDefinition.ComponentTypeUnknown) ||
|
||||||
(componentType < CommonDefinition.ComponentTypeNull)) {
|
(componentType < CommonDefinition.ComponentTypeNull)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -249,11 +248,11 @@ public class CommonDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
isLibraryComponent
|
isLibraryComponent
|
||||||
|
|
||||||
This function is to check does componet is library according to commponet
|
This function is to check does componet is library according to commponet
|
||||||
type value.
|
type value.
|
||||||
|
|
||||||
@param componentType Integer value of component type.
|
@param componentType Integer value of component type.
|
||||||
@return
|
@return
|
||||||
**/
|
**/
|
||||||
@ -263,12 +262,12 @@ public class CommonDefinition {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* formateGuidName
|
* formateGuidName
|
||||||
*
|
*
|
||||||
* This function is to formate GUID to ANSI c form.
|
* This function is to formate GUID to ANSI c form.
|
||||||
*
|
*
|
||||||
* @param guidNameCon
|
* @param guidNameCon
|
||||||
* String of GUID.
|
* String of GUID.
|
||||||
* @return Formated GUID.
|
* @return Formated GUID.
|
||||||
@ -322,12 +321,12 @@ public class CommonDefinition {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove deuplicat string in list
|
* Remove deuplicat string in list
|
||||||
*
|
*
|
||||||
* This function is to duplicat string in list
|
* This function is to duplicat string in list
|
||||||
*
|
*
|
||||||
* @param String[]
|
* @param String[]
|
||||||
* String list.
|
* String list.
|
||||||
* @return String[] String list which remove the duplicate string.
|
* @return String[] String list which remove the duplicate string.
|
||||||
@ -350,5 +349,5 @@ public class CommonDefinition {
|
|||||||
}
|
}
|
||||||
return desList;
|
return desList;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,17 +2,17 @@
|
|||||||
DynamicTokenValue class.
|
DynamicTokenValue class.
|
||||||
|
|
||||||
This module contains the value type of a dynamic token.
|
This module contains the value type of a dynamic token.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
package org.tianocore.pcd.entity;
|
package org.tianocore.pcd.entity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -61,40 +61,43 @@ public class DynamicTokenValue {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// The default value for HII case.
|
/// The default value for HII case.
|
||||||
///
|
///
|
||||||
public String hiiDefaultValue;
|
public String hiiDefaultValue;
|
||||||
|
|
||||||
///
|
///
|
||||||
|
/// ---------------------------------------------------------------------
|
||||||
/// Following member is for VPD case.
|
/// Following member is for VPD case.
|
||||||
/// BUGBUG: Consider 64 bit integer by using java.math.BigInteger.
|
/// ---------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
public String vpdOffset;
|
public String vpdOffset;
|
||||||
|
|
||||||
///
|
/// ---------------------------------------------------------------------
|
||||||
/// Following member is for default case.
|
/// Following member is for default case.
|
||||||
///
|
/// ---------------------------------------------------------------------
|
||||||
public String value;
|
public String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructor function for DynamicTokenValue class.
|
||||||
|
|
||||||
|
**/
|
||||||
public DynamicTokenValue() {
|
public DynamicTokenValue() {
|
||||||
this.type = VALUE_TYPE.DEFAULT_TYPE;
|
type = VALUE_TYPE.DEFAULT_TYPE;
|
||||||
this.variableName = null;
|
variableName = null;
|
||||||
this.variableGuid = null;
|
variableGuid = null;
|
||||||
this.variableOffset = null;
|
variableOffset = null;
|
||||||
this.hiiDefaultValue = null;
|
hiiDefaultValue = null;
|
||||||
|
vpdOffset = null;
|
||||||
this.vpdOffset = null;
|
value = null;
|
||||||
|
|
||||||
this.value = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the HII case data.
|
Set the HII case data.
|
||||||
|
|
||||||
@param variableName
|
@param variableName The variable name
|
||||||
@param variableGuid
|
@param variableGuid The variable guid
|
||||||
@param variableOffset
|
@param variableOffset The offset of value in this variable
|
||||||
@param hiiDefaultValue
|
@param hiiDefaultValue Default value for this PCD
|
||||||
*/
|
**/
|
||||||
public void setHiiData(List variableName,
|
public void setHiiData(List variableName,
|
||||||
UUID variableGuid,
|
UUID variableGuid,
|
||||||
String variableOffset,
|
String variableOffset,
|
||||||
@ -109,17 +112,16 @@ public class DynamicTokenValue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the string like L"xxx" for a variable Name.
|
Get the string like L"xxx" for a variable Name.
|
||||||
|
|
||||||
BUGBUG: In fact, it is not correctly, variable name should be
|
BUGBUG: In fact, it is not correctly, variable name should be
|
||||||
treated as unicode UINT16 array.
|
treated as unicode UINT16 array.
|
||||||
|
|
||||||
@return String
|
@return String
|
||||||
*/
|
*/
|
||||||
public String getStringOfVariableName()
|
public String getStringOfVariableName()
|
||||||
throws EntityException {
|
throws EntityException {
|
||||||
String str;
|
String str;
|
||||||
int index, num;
|
int index, num;
|
||||||
char ch;
|
|
||||||
|
|
||||||
str = "";
|
str = "";
|
||||||
for (index = 0; index < variableName.size(); index ++) {
|
for (index = 0; index < variableName.size(); index ++) {
|
||||||
@ -135,7 +137,7 @@ public class DynamicTokenValue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Set Vpd case data.
|
Set Vpd case data.
|
||||||
|
|
||||||
@param vpdOffset
|
@param vpdOffset
|
||||||
*/
|
*/
|
||||||
public void setVpdData(String vpdOffset) {
|
public void setVpdData(String vpdOffset) {
|
||||||
@ -146,7 +148,7 @@ public class DynamicTokenValue {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Set default case data.
|
Set default case data.
|
||||||
|
|
||||||
@param value
|
@param value
|
||||||
*/
|
*/
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
MemoryDatabaseManager class.
|
MemoryDatabaseManager class.
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
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.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.tianocore.pcd.entity.UsageIdentification;
|
import org.tianocore.pcd.entity.UsageIdentification;
|
||||||
import org.tianocore.pcd.exception.EntityException;
|
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 {
|
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
|
/// 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
|
/// libarry is inheritted by the module, so stored module's PCD information as PCD
|
||||||
/// context of building libary.
|
/// context of building libary.
|
||||||
///
|
///
|
||||||
public static List<UsageInstance> UsageInstanceContext = null;
|
public static List<UsageInstance> UsageInstanceContext = null;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Current module name, if now is buiding library, this value indicate this library
|
/// Current module name, if now is buiding library, this value indicate this library
|
||||||
/// is for building what module.
|
/// is for building what module.
|
||||||
///
|
///
|
||||||
public static String CurrentModuleName = null;
|
public static String CurrentModuleName = null;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// String for PCD PEIM and DXE autogen file
|
/// String for PCD PEIM and DXE autogen file
|
||||||
///
|
///
|
||||||
public static String PcdPeimHString = "";
|
public static String PcdPeimHString = "";
|
||||||
public static String PcdPeimCString = "";
|
public static String PcdPeimCString = "";
|
||||||
public static String PcdDxeHString = "";
|
public static String PcdDxeHString = "";
|
||||||
@ -68,9 +68,9 @@ public class MemoryDatabaseManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Judege whether token exists in memory database
|
Judege whether token exists in memory database
|
||||||
|
|
||||||
@param primaryKey the primaryKey for searching token
|
@param primaryKey the primaryKey for searching token
|
||||||
|
|
||||||
@retval TRUE - token already exist in database.
|
@retval TRUE - token already exist in database.
|
||||||
@retval FALSE - token does not 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.
|
Add a pcd token into memory database.
|
||||||
|
|
||||||
@param primaryKey the primary key for searching token
|
@param primaryKey the primary key for searching token
|
||||||
@param token token instance
|
@param token token instance
|
||||||
**/
|
**/
|
||||||
@ -90,9 +90,9 @@ public class MemoryDatabaseManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get a token instance from memory database with primary key.
|
Get a token instance from memory database with primary key.
|
||||||
|
|
||||||
@param primaryKey the primary key for searching token
|
@param primaryKey the primary key for searching token
|
||||||
|
|
||||||
@return token instance.
|
@return token instance.
|
||||||
**/
|
**/
|
||||||
public Token getTokenByKey(String primaryKey) {
|
public Token getTokenByKey(String primaryKey) {
|
||||||
@ -101,7 +101,7 @@ public class MemoryDatabaseManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the number of PCD token record in memory database.
|
Get the number of PCD token record in memory database.
|
||||||
|
|
||||||
@return the number of PCD token record in memory database.
|
@return the number of PCD token record in memory database.
|
||||||
**/
|
**/
|
||||||
public int getDBSize() {
|
public int getDBSize() {
|
||||||
@ -110,7 +110,7 @@ public class MemoryDatabaseManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the token record array contained all PCD token in memory database.
|
Get the token record array contained all PCD token in memory database.
|
||||||
|
|
||||||
@return 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() {
|
public Token[] getRecordArray() {
|
||||||
@ -135,7 +135,7 @@ public class MemoryDatabaseManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get record array only contains DYNAMIC or DYNAMIC_EX type PCD.
|
Get record array only contains DYNAMIC or DYNAMIC_EX type PCD.
|
||||||
|
|
||||||
@return ArrayList
|
@return ArrayList
|
||||||
*/
|
*/
|
||||||
private ArrayList getDynamicRecordArray() {
|
private ArrayList getDynamicRecordArray() {
|
||||||
@ -155,12 +155,12 @@ public class MemoryDatabaseManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the token record array contained all PCD token referenced by PEI phase.
|
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.
|
@return the token record array contained all PCD token referenced in PEI phase.
|
||||||
@throws EntityException
|
@throws EntityException
|
||||||
**/
|
**/
|
||||||
public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe)
|
public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe)
|
||||||
throws EntityException {
|
throws EntityException {
|
||||||
int usageInstanceIndex = 0;
|
int usageInstanceIndex = 0;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -187,8 +187,8 @@ public class MemoryDatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If no PEI components reference the PCD entry,
|
// If no PEI components reference the PCD entry,
|
||||||
// we check if it is referenced in DXE driver.
|
// we check if it is referenced in DXE driver.
|
||||||
//
|
//
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (token.consumers != null) {
|
if (token.consumers != null) {
|
||||||
@ -202,7 +202,7 @@ public class MemoryDatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (token.isDynamicPCD && token.consumers.size() == 0) {
|
if (token.isDynamicPCD && token.consumers.size() == 0) {
|
||||||
dxe.add(token);
|
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,
|
Get all PCD record for a module according to module's name, module's GUID,
|
||||||
package name, package GUID, arch, version information.
|
package name, package GUID, arch, version information.
|
||||||
|
|
||||||
@param usageId the id of UsageInstance.
|
@param usageId the id of UsageInstance.
|
||||||
|
|
||||||
@return all usage instance for this module in memory database.
|
@return all usage instance for this module in memory database.
|
||||||
**/
|
**/
|
||||||
public List<UsageInstance> getUsageInstanceArrayByModuleName(UsageIdentification usageId) {
|
public List<UsageInstance> getUsageInstanceArrayByModuleName(UsageIdentification usageId) {
|
||||||
@ -237,14 +237,14 @@ public class MemoryDatabaseManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get all PCD token for a usage instance according to primary key.
|
Get all PCD token for a usage instance according to primary key.
|
||||||
|
|
||||||
@param primaryKey the primary key of usage instance.
|
@param primaryKey the primary key of usage instance.
|
||||||
|
|
||||||
@return List<UsageInstance>
|
@return List<UsageInstance>
|
||||||
*/
|
*/
|
||||||
public List<UsageInstance> getUsageInstanceArrayByKeyString(String primaryKey) {
|
public List<UsageInstance> getUsageInstanceArrayByKeyString(String primaryKey) {
|
||||||
Token[] tokenArray = null;
|
Token[] tokenArray = null;
|
||||||
int recordIndex = 0;
|
int recordIndex = 0;
|
||||||
UsageInstance usageInstance = null;
|
UsageInstance usageInstance = null;
|
||||||
List<UsageInstance> returnArray = new ArrayList<UsageInstance>();
|
List<UsageInstance> returnArray = new ArrayList<UsageInstance>();
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ public class MemoryDatabaseManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get all modules name who contains PCD information
|
Get all modules name who contains PCD information
|
||||||
|
|
||||||
@return Array for module name
|
@return Array for module name
|
||||||
**/
|
**/
|
||||||
public List<String> getAllModuleArray()
|
public List<String> getAllModuleArray()
|
||||||
|
@ -22,6 +22,7 @@ public class SkuInstance {
|
|||||||
/// The id number of this SKU instance
|
/// The id number of this SKU instance
|
||||||
///
|
///
|
||||||
public int id;
|
public int id;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The value of this SKU instance
|
/// The value of this SKU instance
|
||||||
///
|
///
|
||||||
@ -38,6 +39,9 @@ public class SkuInstance {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Default constructor function.
|
||||||
|
**/
|
||||||
public SkuInstance() {
|
public SkuInstance() {
|
||||||
this.id = 0;
|
this.id = 0;
|
||||||
this.value = new DynamicTokenValue();
|
this.value = new DynamicTokenValue();
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
Token class.
|
Token class.
|
||||||
|
|
||||||
This module contains all classes releted to PCD token.
|
This module contains all classes releted to PCD token.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
package org.tianocore.pcd.entity;
|
package org.tianocore.pcd.entity;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -20,25 +20,24 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.tianocore.pcd.entity.UsageIdentification;
|
import org.tianocore.pcd.entity.UsageIdentification;
|
||||||
import org.tianocore.pcd.exception.EntityException;
|
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 {
|
public class Token {
|
||||||
///
|
///
|
||||||
/// Enumeration macro defintion for PCD type.
|
/// 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}
|
DYNAMIC_EX, UNKNOWN}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Enumeration macro definition for datum type. All type mainly comes from ProcessBind.h.
|
/// 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.
|
/// prompt dialog.
|
||||||
///
|
///
|
||||||
public enum DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN}
|
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
|
/// 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.
|
/// assignedtokenSpaceName as follows.
|
||||||
/// tokenSpaceName is defined in MSA, SPD, FPD, can be regarded as primary key with cName.
|
/// 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;
|
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;
|
public long dynamicExTokenNumber;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// All supported PCD type, this value can be retrieved from SPD
|
/// All supported PCD type, this value can be retrieved from SPD
|
||||||
/// Currently, only record all PCD type for this token in FPD file.
|
/// Currently, only record all PCD type for this token in FPD file.
|
||||||
///
|
///
|
||||||
public List<PCD_TYPE> supportedPcdType;
|
public List<PCD_TYPE> supportedPcdType;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// If the token's item type is Dynamic or DynamicEx type, isDynamicPCD
|
/// If the token's item type is Dynamic or DynamicEx type, isDynamicPCD
|
||||||
/// is true.
|
/// is true.
|
||||||
///
|
///
|
||||||
public boolean isDynamicPCD;
|
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.
|
/// datumSize is defined in SPD.
|
||||||
///
|
///
|
||||||
public int datumSize;
|
public int datumSize;
|
||||||
@ -102,7 +101,7 @@ public class Token {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// skuData contains all value for SkuNumber of 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<SkuInstance> skuData;
|
public List<SkuInstance> skuData;
|
||||||
|
|
||||||
@ -113,7 +112,7 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Constructure function for Token class
|
Constructure function for Token class
|
||||||
|
|
||||||
@param cName The name of token
|
@param cName The name of token
|
||||||
@param tokenSpaceName The name of token space, it is a guid string
|
@param tokenSpaceName The name of token space, it is a guid string
|
||||||
**/
|
**/
|
||||||
@ -131,10 +130,10 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
updateSupportPcdType
|
updateSupportPcdType
|
||||||
|
|
||||||
SupportPcdType should be gotten from SPD file actually, but now it just
|
SupportPcdType should be gotten from SPD file actually, but now it just
|
||||||
record all PCD type for this token in FPD file.
|
record all PCD type for this token in FPD file.
|
||||||
|
|
||||||
@param pcdType new PCD type found in FPD file for this token.
|
@param pcdType new PCD type found in FPD file for this token.
|
||||||
**/
|
**/
|
||||||
public void updateSupportPcdType(PCD_TYPE pcdType) {
|
public void updateSupportPcdType(PCD_TYPE pcdType) {
|
||||||
@ -146,16 +145,16 @@ public class Token {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// If not found, add the pcd type to member variable supportedPcdType
|
// If not found, add the pcd type to member variable supportedPcdType
|
||||||
//
|
//
|
||||||
supportedPcdType.add(pcdType);
|
supportedPcdType.add(pcdType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Judge whether pcdType is belong to dynamic type. Dynamic type includes
|
Judge whether pcdType is belong to dynamic type. Dynamic type includes
|
||||||
DYNAMIC and DYNAMIC_EX.
|
DYNAMIC and DYNAMIC_EX.
|
||||||
|
|
||||||
@param pcdType the judged pcd type
|
@param pcdType the judged pcd type
|
||||||
|
|
||||||
@return boolean
|
@return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean isDynamic(PCD_TYPE pcdType) {
|
public static boolean isDynamic(PCD_TYPE pcdType) {
|
||||||
@ -173,16 +172,16 @@ public class Token {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database
|
Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database
|
||||||
|
|
||||||
@param cName Token name.
|
@param cName Token name.
|
||||||
@param tokenSpaceName The token space guid string defined in MSA or SPD
|
@param tokenSpaceName The token space guid string defined in MSA or SPD
|
||||||
|
|
||||||
@retval primary key for this token in token database.
|
@retval primary key for this token in token database.
|
||||||
**/
|
**/
|
||||||
public static String getPrimaryKeyString(String cName, String tokenSpaceName) {
|
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.
|
If skudata list contains more than one data, then Sku mechanism is enable.
|
||||||
|
|
||||||
@retval boolean if the number of sku data exceed to 1
|
@retval boolean if the number of sku data exceed to 1
|
||||||
*/
|
*/
|
||||||
public boolean isSkuEnable() {
|
public boolean isSkuEnable() {
|
||||||
@ -207,7 +206,7 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
If Hii type for value of token
|
If Hii type for value of token
|
||||||
|
|
||||||
@return boolean
|
@return boolean
|
||||||
**/
|
**/
|
||||||
public boolean isHiiEnable() {
|
public boolean isHiiEnable() {
|
||||||
@ -219,7 +218,7 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
If Vpd type for value of token
|
If Vpd type for value of token
|
||||||
|
|
||||||
@return boolean
|
@return boolean
|
||||||
**/
|
**/
|
||||||
public boolean isVpdEnable() {
|
public boolean isVpdEnable() {
|
||||||
@ -231,7 +230,7 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the token primary key in token database.
|
Get the token primary key in token database.
|
||||||
|
|
||||||
@return String
|
@return String
|
||||||
*/
|
*/
|
||||||
public String getPrimaryKeyString () {
|
public String getPrimaryKeyString () {
|
||||||
@ -240,14 +239,14 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Judge datumType is valid
|
Judge datumType is valid
|
||||||
|
|
||||||
@param type The datumType want to be judged.
|
@param type The datumType want to be judged.
|
||||||
|
|
||||||
@retval TRUE - The type is valid.
|
@retval TRUE - The type is valid.
|
||||||
@retval FALSE - The type is invalid.
|
@retval FALSE - The type is invalid.
|
||||||
**/
|
**/
|
||||||
public static boolean isValiddatumType(DATUM_TYPE type) {
|
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())) {
|
(type.ordinal() > DATUM_TYPE.POINTER.ordinal())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -256,14 +255,14 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Judge pcdType is valid
|
Judge pcdType is valid
|
||||||
|
|
||||||
@param type The PCdType want to be judged.
|
@param type The PCdType want to be judged.
|
||||||
|
|
||||||
@retval TRUE - The type is valid.
|
@retval TRUE - The type is valid.
|
||||||
@retval FALSE - The type is invalid.
|
@retval FALSE - The type is invalid.
|
||||||
**/
|
**/
|
||||||
public static boolean isValidpcdType(PCD_TYPE type) {
|
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())) {
|
(type.ordinal() > PCD_TYPE.DYNAMIC_EX.ordinal())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -272,9 +271,9 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Add an usage instance for token
|
Add an usage instance for token
|
||||||
|
|
||||||
@param usageInstance The usage instance
|
@param usageInstance The usage instance
|
||||||
|
|
||||||
@retval TRUE - Success to add usage instance.
|
@retval TRUE - Success to add usage instance.
|
||||||
@retval FALSE - Fail 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.
|
// Put usage instance into usage instance database of this PCD token.
|
||||||
//
|
//
|
||||||
consumers.put(usageInstance.getPrimaryKey(), usageInstance);
|
consumers.put(usageInstance.getPrimaryKey(), usageInstance);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -300,9 +299,9 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Judge whether exist an usage instance for this token
|
Judge whether exist an usage instance for this token
|
||||||
|
|
||||||
@param usageId The UsageInstance identification for usage instance
|
@param usageId The UsageInstance identification for usage instance
|
||||||
|
|
||||||
@return boolean whether exist an usage instance for this token.
|
@return boolean whether exist an usage instance for this token.
|
||||||
*/
|
*/
|
||||||
public boolean isUsageInstanceExist(UsageIdentification usageId) {
|
public boolean isUsageInstanceExist(UsageIdentification usageId) {
|
||||||
@ -313,9 +312,9 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the PCD_TYPE according to the string of PCD_TYPE
|
Get the PCD_TYPE according to the string of PCD_TYPE
|
||||||
|
|
||||||
@param pcdTypeStr The string of PCD_TYPE
|
@param pcdTypeStr The string of PCD_TYPE
|
||||||
|
|
||||||
@return PCD_TYPE
|
@return PCD_TYPE
|
||||||
**/
|
**/
|
||||||
public static PCD_TYPE getpcdTypeFromString(String pcdTypeStr) {
|
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
|
Get the string of given datumType. This string will be used for generating autogen files
|
||||||
|
|
||||||
@param datumType Given datumType
|
@param datumType Given datumType
|
||||||
|
|
||||||
@return The string of datum type.
|
@return The string of datum type.
|
||||||
**/
|
**/
|
||||||
public static String getStringOfdatumType(DATUM_TYPE datumType) {
|
public static String getStringOfdatumType(DATUM_TYPE datumType) {
|
||||||
@ -365,9 +364,9 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the datumType according to a string.
|
Get the datumType according to a string.
|
||||||
|
|
||||||
@param datumTypeStr The string of datumType
|
@param datumTypeStr The string of datumType
|
||||||
|
|
||||||
@return DATUM_TYPE
|
@return DATUM_TYPE
|
||||||
**/
|
**/
|
||||||
public static DATUM_TYPE getdatumTypeFromString(String datumTypeStr) {
|
public static DATUM_TYPE getdatumTypeFromString(String datumTypeStr) {
|
||||||
@ -389,9 +388,9 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get string of given pcdType
|
Get string of given pcdType
|
||||||
|
|
||||||
@param pcdType The given PcdType
|
@param pcdType The given PcdType
|
||||||
|
|
||||||
@return The string of PCD_TYPE.
|
@return The string of PCD_TYPE.
|
||||||
**/
|
**/
|
||||||
public static String getStringOfpcdType(PCD_TYPE pcdType) {
|
public static String getStringOfpcdType(PCD_TYPE pcdType) {
|
||||||
@ -412,9 +411,9 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the PCD_USAGE according to a string
|
Get the PCD_USAGE according to a string
|
||||||
|
|
||||||
@param usageStr The string of PCD_USAGE
|
@param usageStr The string of PCD_USAGE
|
||||||
|
|
||||||
@return The PCD_USAGE
|
@return The PCD_USAGE
|
||||||
**/
|
**/
|
||||||
public static PCD_USAGE getUsageFromString(String usageStr) {
|
public static PCD_USAGE getUsageFromString(String usageStr) {
|
||||||
@ -437,9 +436,9 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the string of given PCD_USAGE
|
Get the string of given PCD_USAGE
|
||||||
|
|
||||||
@param usage The given PCD_USAGE
|
@param usage The given PCD_USAGE
|
||||||
|
|
||||||
@return The string of PDC_USAGE.
|
@return The string of PDC_USAGE.
|
||||||
**/
|
**/
|
||||||
public static String getStringOfUsage(PCD_USAGE 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
|
Get the Defined datumType string for autogen. The string is for generating some MACROs in Autogen.h
|
||||||
|
|
||||||
@param datumType The given datumType
|
@param datumType The given datumType
|
||||||
|
|
||||||
@return string of datum type for autogen.
|
@return string of datum type for autogen.
|
||||||
**/
|
**/
|
||||||
public static String GetAutogenDefinedatumTypeString(DATUM_TYPE datumType) {
|
public static String GetAutogenDefinedatumTypeString(DATUM_TYPE datumType) {
|
||||||
switch (datumType) {
|
switch (datumType) {
|
||||||
|
|
||||||
case UINT8:
|
case UINT8:
|
||||||
return "8";
|
return "8";
|
||||||
case UINT16:
|
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
|
Get the datumType String for Autogen. This string will be used for generating defintions of PCD token in autogen
|
||||||
|
|
||||||
@param datumType The given datumType
|
@param datumType The given datumType
|
||||||
|
|
||||||
@return string of datum type.
|
@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
|
Get the datumType string for generating some MACROs in autogen file of Library
|
||||||
|
|
||||||
@param datumType The given datumType
|
@param datumType The given datumType
|
||||||
|
|
||||||
@return String of datum for genrating bit charater.
|
@return String of datum for genrating bit charater.
|
||||||
@ -537,11 +536,10 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the sku data who id is 0.
|
Get the sku data who id is 0.
|
||||||
|
|
||||||
@retval DynamicTokenValue the value of this dyanmic token.
|
@retval DynamicTokenValue the value of this dyanmic token.
|
||||||
**/
|
**/
|
||||||
public DynamicTokenValue getDefaultSku() {
|
public DynamicTokenValue getDefaultSku() {
|
||||||
DynamicTokenValue dynamicData;
|
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
for (index = 0; index < this.skuData.size(); 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
|
Get the number of Sku data for this token
|
||||||
|
|
||||||
@retval int the number of sku data
|
@retval int the number of sku data
|
||||||
**/
|
**/
|
||||||
public int getSkuIdCount () {
|
public int getSkuIdCount () {
|
||||||
@ -564,9 +562,9 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the size of PCD value, this PCD is POINTER type.
|
Get the size of PCD value, this PCD is POINTER type.
|
||||||
|
|
||||||
@param str the string of the value
|
@param str the string of the value
|
||||||
@param al
|
@param al
|
||||||
**/
|
**/
|
||||||
private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {
|
private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {
|
||||||
if (isValidNullValue(str)) {
|
if (isValidNullValue(str)) {
|
||||||
@ -590,11 +588,11 @@ public class Token {
|
|||||||
} else if (str.startsWith("{")) {
|
} else if (str.startsWith("{")) {
|
||||||
//
|
//
|
||||||
// We count the number of "," in the string.
|
// 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.
|
// comma.
|
||||||
//
|
//
|
||||||
String str2 = str;
|
String str2 = str;
|
||||||
|
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
pos = str2.indexOf(",", 0);
|
pos = str2.indexOf(",", 0);
|
||||||
@ -612,17 +610,17 @@ public class Token {
|
|||||||
/**
|
/**
|
||||||
This method can be used to get the MAX and current size
|
This method can be used to get the MAX and current size
|
||||||
for pointer type dynamic(ex) PCD entry
|
for pointer type dynamic(ex) PCD entry
|
||||||
**/
|
**/
|
||||||
public ArrayList<Integer> getPointerTypeSize () {
|
public ArrayList<Integer> getPointerTypeSize () {
|
||||||
ArrayList<Integer> al = new ArrayList<Integer>();
|
ArrayList<Integer> al = new ArrayList<Integer>();
|
||||||
|
|
||||||
//
|
//
|
||||||
// For VPD_enabled and HII_enabled, we can only return the MAX size.
|
// For VPD_enabled and HII_enabled, we can only return the MAX size.
|
||||||
// For the default DATA type dynamic PCD entry, we will return
|
// For the default DATA type dynamic PCD entry, we will return
|
||||||
// the MAX size and current size for each SKU_ID.
|
// the MAX size and current size for each SKU_ID.
|
||||||
//
|
//
|
||||||
al.add(new Integer(this.datumSize));
|
al.add(new Integer(this.datumSize));
|
||||||
|
|
||||||
if (!this.isVpdEnable()) {
|
if (!this.isVpdEnable()) {
|
||||||
int idx;
|
int idx;
|
||||||
if (this.isHiiEnable()){
|
if (this.isHiiEnable()){
|
||||||
@ -637,7 +635,7 @@ public class Token {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return al;
|
return al;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,7 +643,7 @@ public class Token {
|
|||||||
Get default value for a token, For HII type, HiiDefaultValue of default
|
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
|
SKU 0 will be returned; For Default type, the defaultvalue of default SKU
|
||||||
0 will be returned.
|
0 will be returned.
|
||||||
|
|
||||||
@return String
|
@return String
|
||||||
*/
|
*/
|
||||||
public String getDynamicDefaultValue() {
|
public String getDynamicDefaultValue() {
|
||||||
@ -665,14 +663,12 @@ public class Token {
|
|||||||
// to support no default value.
|
// to support no default value.
|
||||||
//
|
//
|
||||||
public boolean hasDefaultValue () {
|
public boolean hasDefaultValue () {
|
||||||
int value = 0;
|
|
||||||
boolean isInteger = true;
|
|
||||||
DynamicTokenValue dynamicValue = null;
|
DynamicTokenValue dynamicValue = null;
|
||||||
|
|
||||||
if (isSkuEnable()) {
|
if (isSkuEnable()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isDynamicPCD) {
|
if (this.isDynamicPCD) {
|
||||||
dynamicValue = getDefaultSku();
|
dynamicValue = getDefaultSku();
|
||||||
switch (dynamicValue.type) {
|
switch (dynamicValue.type) {
|
||||||
@ -690,9 +686,9 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Judge the value is NULL value. NULL value means the value is uninitialized value
|
Judge the value is NULL value. NULL value means the value is uninitialized value
|
||||||
|
|
||||||
@param judgedValue
|
@param judgedValue
|
||||||
|
|
||||||
@return boolean
|
@return boolean
|
||||||
*/
|
*/
|
||||||
public boolean isValidNullValue(String judgedValue) {
|
public boolean isValidNullValue(String judgedValue) {
|
||||||
@ -704,7 +700,7 @@ public class Token {
|
|||||||
case UINT16:
|
case UINT16:
|
||||||
case UINT32:
|
case UINT32:
|
||||||
if (judgedValue.length() > 2) {
|
if (judgedValue.length() > 2) {
|
||||||
if ((judgedValue.charAt(0) == '0') &&
|
if ((judgedValue.charAt(0) == '0') &&
|
||||||
((judgedValue.charAt(1) == 'x') || (judgedValue.charAt(1) == 'X'))){
|
((judgedValue.charAt(1) == 'x') || (judgedValue.charAt(1) == 'X'))){
|
||||||
subStr = judgedValue.substring(2, judgedValue.length());
|
subStr = judgedValue.substring(2, judgedValue.length());
|
||||||
bigIntValue = new BigInteger(subStr, 16);
|
bigIntValue = new BigInteger(subStr, 16);
|
||||||
@ -720,7 +716,7 @@ public class Token {
|
|||||||
break;
|
break;
|
||||||
case UINT64:
|
case UINT64:
|
||||||
if (judgedValue.length() > 2){
|
if (judgedValue.length() > 2){
|
||||||
if ((judgedValue.charAt(0) == '0') &&
|
if ((judgedValue.charAt(0) == '0') &&
|
||||||
((judgedValue.charAt(1) == 'x') ||
|
((judgedValue.charAt(1) == 'x') ||
|
||||||
(judgedValue.charAt(1) == 'X'))) {
|
(judgedValue.charAt(1) == 'X'))) {
|
||||||
bigIntValue = new BigInteger(judgedValue.substring(2, judgedValue.length()), 16);
|
bigIntValue = new BigInteger(judgedValue.substring(2, judgedValue.length()), 16);
|
||||||
@ -759,34 +755,34 @@ public class Token {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Is the string value in Unicode
|
Is the string value in Unicode
|
||||||
|
|
||||||
@return boolean
|
@return boolean
|
||||||
**/
|
**/
|
||||||
public boolean isHiiDefaultValueUnicodeStringType() {
|
public boolean isHiiDefaultValueUnicodeStringType() {
|
||||||
DynamicTokenValue dynamicData = getDefaultSku();
|
DynamicTokenValue dynamicData = getDefaultSku();
|
||||||
|
|
||||||
if (dynamicData == null)
|
if (dynamicData == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return dynamicData.hiiDefaultValue.startsWith("L\"")
|
return dynamicData.hiiDefaultValue.startsWith("L\"")
|
||||||
&& dynamicData.hiiDefaultValue.endsWith("\"");
|
&& dynamicData.hiiDefaultValue.endsWith("\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Is the string value in ANSCI
|
Is the string value in ANSCI
|
||||||
|
|
||||||
@return boolean
|
@return boolean
|
||||||
**/
|
**/
|
||||||
public boolean isHiiDefaultValueASCIIStringType() {
|
public boolean isHiiDefaultValueASCIIStringType() {
|
||||||
DynamicTokenValue dynamicData = getDefaultSku();
|
DynamicTokenValue dynamicData = getDefaultSku();
|
||||||
|
|
||||||
if (dynamicData == null)
|
if (dynamicData == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return dynamicData.hiiDefaultValue.startsWith("\"")
|
return dynamicData.hiiDefaultValue.startsWith("\"")
|
||||||
&& dynamicData.hiiDefaultValue.endsWith("\"");
|
&& dynamicData.hiiDefaultValue.endsWith("\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Judege whether current value is UNICODE string type.
|
Judege whether current value is UNICODE string type.
|
||||||
@return boolean
|
@return boolean
|
||||||
@ -799,14 +795,14 @@ public class Token {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (datumType == Token.DATUM_TYPE.POINTER &&
|
if (datumType == Token.DATUM_TYPE.POINTER &&
|
||||||
str.startsWith("L\"") &&
|
str.startsWith("L\"") &&
|
||||||
str.endsWith("\"")) {
|
str.endsWith("\"")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isASCIIStringType () {
|
public boolean isASCIIStringType () {
|
||||||
String str = getDynamicDefaultValue();
|
String str = getDynamicDefaultValue();
|
||||||
|
|
||||||
@ -815,7 +811,7 @@ public class Token {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (datumType == Token.DATUM_TYPE.POINTER &&
|
if (datumType == Token.DATUM_TYPE.POINTER &&
|
||||||
str.startsWith("\"") &&
|
str.startsWith("\"") &&
|
||||||
str.endsWith("\"")) {
|
str.endsWith("\"")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -831,16 +827,16 @@ public class Token {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (datumType == Token.DATUM_TYPE.POINTER &&
|
if (datumType == Token.DATUM_TYPE.POINTER &&
|
||||||
str.startsWith("{") &&
|
str.startsWith("{") &&
|
||||||
str.endsWith("}")) {
|
str.endsWith("}")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStringTypeString () {
|
public String getStringTypeString () {
|
||||||
return getDefaultSku().value.substring(2, getDefaultSku().value.length() - 1);
|
return getDefaultSku().value.substring(2, getDefaultSku().value.length() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,33 +17,41 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
package org.tianocore.pcd.entity;
|
package org.tianocore.pcd.entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
The identification for a UsageInstance.
|
||||||
|
It should be extend from ModuleIdentification in future.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
public class UsageIdentification {
|
public class UsageIdentification {
|
||||||
///
|
///
|
||||||
/// The module CName: one key of Identification
|
/// The module CName: one key of Identification
|
||||||
///
|
///
|
||||||
public String moduleName;
|
public String moduleName;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The module Guid String: one key of Identification
|
/// The module Guid String: one key of Identification
|
||||||
///
|
///
|
||||||
public String moduleGuid;
|
public String moduleGuid;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The package CName: one key of Identification
|
/// The package CName: one key of Identification
|
||||||
///
|
///
|
||||||
public String packageName;
|
public String packageName;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The package Guid: one key of Identification
|
/// The package Guid: one key of Identification
|
||||||
///
|
///
|
||||||
public String packageGuid;
|
public String packageGuid;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Module's Arch: one key of Identification
|
/// Module's Arch: one key of Identification
|
||||||
///
|
///
|
||||||
public String arch;
|
public String arch;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Module's version: one key of Identification
|
/// Module's version: one key of Identification
|
||||||
///
|
///
|
||||||
public String version;
|
public String version;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Module's type
|
/// Module's type
|
||||||
///
|
///
|
||||||
|
@ -4,26 +4,21 @@
|
|||||||
This class indicate an usage instance for a PCD token. This instance maybe a module
|
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
|
or platform setting. When a module produce or cosume a PCD token, then this module
|
||||||
is an usage instance for this PCD token.
|
is an usage instance for this PCD token.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
package org.tianocore.pcd.entity;
|
package org.tianocore.pcd.entity;
|
||||||
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.tianocore.ModuleTypeDef;
|
|
||||||
import org.tianocore.pcd.entity.CommonDefinition;
|
import org.tianocore.pcd.entity.CommonDefinition;
|
||||||
import org.tianocore.pcd.entity.UsageIdentification;
|
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
|
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
|
/// ModuleIdentification for Usage Instance
|
||||||
///
|
///
|
||||||
public UsageIdentification usageId;
|
public UsageIdentification usageId;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Arch also is a key for a UsageInstance
|
/// Arch also is a key for a UsageInstance
|
||||||
///
|
///
|
||||||
public String arch;
|
public String arch;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The PCD type defined for module
|
/// The PCD type defined for module
|
||||||
///
|
///
|
||||||
public Token.PCD_TYPE modulePcdType;
|
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;
|
public String datum;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The maxDatumSize could be different for same PCD in different module
|
/// The maxDatumSize could be different for same PCD in different module
|
||||||
/// But this case is allow for FeatureFlag, FixedAtBuild, PatchableInModule
|
/// But this case is allow for FeatureFlag, FixedAtBuild, PatchableInModule
|
||||||
/// type.
|
/// type.
|
||||||
///
|
///
|
||||||
public int maxDatumSize;
|
public int maxDatumSize;
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -70,12 +65,12 @@ public class UsageInstance {
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// Auotgen string for C code file.
|
/// Auotgen string for C code file.
|
||||||
///
|
///
|
||||||
public String cAutogenStr;
|
public String cAutogenStr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructure function for UsageInstance
|
Constructure function for UsageInstance
|
||||||
|
|
||||||
@param parentToken The token instance for this usgaInstance
|
@param parentToken The token instance for this usgaInstance
|
||||||
@param id The identification for usage instance
|
@param id The identification for usage instance
|
||||||
@param modulePcdType The PCD type for this 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.
|
Get the primary key for usage instance array for every token.
|
||||||
|
|
||||||
@param usageId The identification of UsageInstance
|
@param usageId The identification of UsageInstance
|
||||||
|
|
||||||
@retval String The primary key for this usage instance
|
@retval String The primary key for this usage instance
|
||||||
**/
|
**/
|
||||||
public static String getPrimaryKey(UsageIdentification usageId) {
|
public static String getPrimaryKey(UsageIdentification usageId) {
|
||||||
@ -108,7 +103,7 @@ public class UsageInstance {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get primary key string for this usage instance
|
Get primary key string for this usage instance
|
||||||
|
|
||||||
@return String primary key string
|
@return String primary key string
|
||||||
**/
|
**/
|
||||||
public String getPrimaryKey() {
|
public String getPrimaryKey() {
|
||||||
@ -117,7 +112,7 @@ public class UsageInstance {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Judget whether current module is PEI driver
|
Judget whether current module is PEI driver
|
||||||
|
|
||||||
@return boolean whether current module is PEI driver
|
@return boolean whether current module is PEI driver
|
||||||
**/
|
**/
|
||||||
public boolean isPeiPhaseComponent() {
|
public boolean isPeiPhaseComponent() {
|
||||||
@ -132,7 +127,7 @@ public class UsageInstance {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Judge whether current module is DXE driver.
|
Judge whether current module is DXE driver.
|
||||||
|
|
||||||
@return boolean whether current module is DXE driver
|
@return boolean whether current module is DXE driver
|
||||||
**/
|
**/
|
||||||
public boolean isDxePhaseComponent() {
|
public boolean isDxePhaseComponent() {
|
||||||
@ -152,7 +147,7 @@ public class UsageInstance {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Generate autogen string for header file and C code file.
|
Generate autogen string for header file and C code file.
|
||||||
|
|
||||||
@param isBuildUsedLibrary whether the autogen is for library.
|
@param isBuildUsedLibrary whether the autogen is for library.
|
||||||
**/
|
**/
|
||||||
public void generateAutoGen(boolean isBuildUsedLibrary) {
|
public void generateAutoGen(boolean isBuildUsedLibrary) {
|
||||||
@ -167,12 +162,12 @@ public class UsageInstance {
|
|||||||
if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {
|
if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {
|
||||||
//
|
//
|
||||||
// For DYNAMIC_EX type PCD, use original token number in SPD or FPD to generate autogen
|
// For DYNAMIC_EX type PCD, use original token number in SPD or FPD to generate autogen
|
||||||
//
|
//
|
||||||
tokenNumberString = Long.toString(parentToken.dynamicExTokenNumber, 16);
|
tokenNumberString = Long.toString(parentToken.dynamicExTokenNumber, 16);
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// For Others type PCD, use autogenerated token number to generate autogen
|
// For Others type PCD, use autogenerated token number to generate autogen
|
||||||
//
|
//
|
||||||
tokenNumberString = Long.toString(parentToken.tokenNumber, 16);
|
tokenNumberString = Long.toString(parentToken.tokenNumber, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +175,7 @@ public class UsageInstance {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Judge the value of this PCD is byte array type
|
// Judge the value of this PCD is byte array type
|
||||||
//
|
//
|
||||||
if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {
|
if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {
|
||||||
if (datum.trim().charAt(0) == '{') {
|
if (datum.trim().charAt(0) == '{') {
|
||||||
isByteArray = true;
|
isByteArray = true;
|
||||||
@ -189,7 +184,7 @@ public class UsageInstance {
|
|||||||
|
|
||||||
//
|
//
|
||||||
// "ULL" should be added to value's tail for UINT64 value
|
// "ULL" should be added to value's tail for UINT64 value
|
||||||
//
|
//
|
||||||
if (parentToken.datumType == Token.DATUM_TYPE.UINT64) {
|
if (parentToken.datumType == Token.DATUM_TYPE.UINT64) {
|
||||||
printDatum = this.datum + "ULL";
|
printDatum = this.datum + "ULL";
|
||||||
} else {
|
} else {
|
||||||
@ -198,19 +193,19 @@ public class UsageInstance {
|
|||||||
|
|
||||||
switch (modulePcdType) {
|
switch (modulePcdType) {
|
||||||
case FEATURE_FLAG:
|
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);
|
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",
|
||||||
parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
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",
|
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);
|
parentToken.cName);
|
||||||
|
|
||||||
if (!isBuildUsedLibrary) {
|
if (!isBuildUsedLibrary) {
|
||||||
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
|
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
printDatum);
|
printDatum);
|
||||||
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
|
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
@ -221,7 +216,7 @@ public class UsageInstance {
|
|||||||
if (isByteArray) {
|
if (isByteArray) {
|
||||||
hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",
|
hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",
|
||||||
parentToken.cName);
|
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),
|
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
parentToken.cName);
|
parentToken.cName);
|
||||||
@ -229,27 +224,27 @@ public class UsageInstance {
|
|||||||
hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",
|
hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",
|
||||||
Token.getAutogendatumTypeString(parentToken.datumType),
|
Token.getAutogendatumTypeString(parentToken.datumType),
|
||||||
parentToken.cName);
|
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),
|
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
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",
|
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);
|
parentToken.cName);
|
||||||
if (!isBuildUsedLibrary) {
|
if (!isBuildUsedLibrary) {
|
||||||
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {
|
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {
|
||||||
if (isByteArray) {
|
if (isByteArray) {
|
||||||
hAutogenStr += String.format("#define _PCD_VALUE_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n",
|
hAutogenStr += String.format("#define _PCD_VALUE_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n",
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
parentToken.cName);
|
parentToken.cName);
|
||||||
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",
|
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
printDatum);
|
printDatum);
|
||||||
} else {
|
} else {
|
||||||
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
|
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
printDatum);
|
printDatum);
|
||||||
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
|
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
|
||||||
Token.getAutogendatumTypeString(parentToken.datumType),
|
Token.getAutogendatumTypeString(parentToken.datumType),
|
||||||
@ -257,8 +252,8 @@ public class UsageInstance {
|
|||||||
parentToken.cName);
|
parentToken.cName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
|
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
printDatum);
|
printDatum);
|
||||||
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
|
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
|
||||||
Token.getAutogendatumTypeString(parentToken.datumType),
|
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",
|
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_BinaryPatch_%s\r\n",
|
||||||
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
parentToken.cName);
|
parentToken.cName);
|
||||||
} else {
|
} else {
|
||||||
hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",
|
hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",
|
||||||
Token.getAutogendatumTypeString(parentToken.datumType),
|
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",
|
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",
|
||||||
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
parentToken.cName);
|
parentToken.cName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Generate _PCD_SET_MODE_xx macro for using set BinaryPatch value via PcdSet macro
|
// Generate _PCD_SET_MODE_xx macro for using set BinaryPatch value via PcdSet macro
|
||||||
//
|
//
|
||||||
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {
|
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",
|
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_%s, (Buffer), (SizeOfBuffer))\r\n",
|
||||||
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
||||||
@ -299,10 +294,10 @@ public class UsageInstance {
|
|||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
parentToken.cName);
|
parentToken.cName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isBuildUsedLibrary) {
|
if (!isBuildUsedLibrary) {
|
||||||
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
|
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
printDatum);
|
printDatum);
|
||||||
if (isByteArray) {
|
if (isByteArray) {
|
||||||
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[] = _PCD_VALUE_%s;\r\n",
|
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.
|
Get the autogen string for header file.
|
||||||
|
|
||||||
@return The string of header file.
|
@return The string of header file.
|
||||||
**/
|
**/
|
||||||
public String getHAutogenStr() {
|
public String getHAutogenStr() {
|
||||||
@ -379,7 +374,7 @@ public class UsageInstance {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Get the autogen string for C code file.
|
Get the autogen string for C code file.
|
||||||
|
|
||||||
@return The string of C Code file.
|
@return The string of C Code file.
|
||||||
**/
|
**/
|
||||||
public String getCAutogenStr() {
|
public String getCAutogenStr() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user