mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-25 22:54:51 +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
@ -17,6 +17,7 @@ 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
|
||||||
@ -28,26 +29,31 @@ public class ActionMessage {
|
|||||||
/// 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.
|
||||||
///
|
///
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,7 +15,6 @@
|
|||||||
**/
|
**/
|
||||||
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;
|
||||||
|
@ -65,36 +65,39 @@ public class DynamicTokenValue {
|
|||||||
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,
|
||||||
@ -119,7 +122,6 @@ public class DynamicTokenValue {
|
|||||||
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 ++) {
|
||||||
|
@ -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 {
|
||||||
///
|
///
|
||||||
|
@ -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();
|
||||||
|
@ -20,19 +20,18 @@ 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
|
/**
|
||||||
|
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.
|
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}
|
||||||
|
|
||||||
@ -541,7 +540,6 @@ public class Token {
|
|||||||
@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 ++) {
|
||||||
@ -665,8 +663,6 @@ 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()) {
|
||||||
|
@ -17,6 +17,8 @@ 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 {
|
||||||
@ -24,26 +26,32 @@ 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
|
||||||
///
|
///
|
||||||
|
@ -17,13 +17,8 @@ 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
|
||||||
@ -201,11 +196,11 @@ public class UsageInstance {
|
|||||||
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) {
|
||||||
@ -236,7 +231,7 @@ public class UsageInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user