Because Pcd entity, exception and some action package are shared by Building tools and Wizard Tools, so I move them to Tools/Source folder and generated PcdTools.jar,

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1160 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2
2006-07-31 18:55:26 +00:00
parent 58d8da3cf9
commit d14ebb4374
24 changed files with 645 additions and 118 deletions

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" >
<MsaHeader>
<ModuleName>PcdTools</ModuleName>
<ModuleType>TOOL</ModuleType>
<GuidValue>95506773-88f3-475a-91a1-14ce0c847353</GuidValue>
<Version>2.0</Version>
<Abstract>This is the EFI/Tiano PCD Tool Resources Module</Abstract>
<Description>
This Module provdes the entity, action and exception package for PCD
tools, This package will be shared for building tools or wizard tools.
</Description>
<Copyright>Copyright 2005-2006, Intel Corporation</Copyright>
<License>
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.
</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>NULL</OutputFileBasename>
</ModuleDefinitions>
<SourceFiles>
<Filename>build.xml</Filename>
<Filename>org/tianocore/pcd/action/ActionMessage.java</Filename>
<Filename>org/tianocore/pcd/action/BuildAction.java</Filename>
<Filename>org/tianocore/pcd/entity/DynamicTokenValue.java</Filename>
<Filename>org/tianocore/pcd/entity/MemoryDatabaseManager.java</Filename>
<Filename>org/tianocore/pcd/entity/SkuInstance.java</Filename>
<Filename>org/tianocore/pcd/entity/Token.java</Filename>
<Filename>org/tianocore/pcd/entity/UsageInstance.java</Filename>
<Filename>org/tianocore/pcd/exception/BuildActionException.java</Filename>
<Filename>org/tianocore/pcd/exception/EntityException.java</Filename>
<Filename>org/tianocore/pcd/exception/UIException.java</Filename>
</SourceFiles>
</ModuleSurfaceArea>

View File

@@ -0,0 +1,52 @@
<?xml version="1.0"?>
<!--
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.
-->
<project name="PcdTools" default="PcdTools" basedir=".">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE" value="${env.WORKSPACE}"/>
<path id="classpath">
<fileset dir="${WORKSPACE}/Tools/Jars" includes="SurfaceArea.jar"/>
<fileset dir="${WORKSPACE}/Tools/Jars" includes="Common.jar"/>
<fileset dir="${env.XMLBEANS_HOME}/lib" includes="*.jar"/>
</path>
<property name="buildDir" value="build"/>
<property name="installLocation" value="${WORKSPACE}/Tools/Jars"/>
<target name="PcdTools" depends="install"/>
<target name="source">
<mkdir dir="${buildDir}"/>
<javac srcdir="." destdir="${buildDir}">
<classpath refid="classpath"/>
<compilerarg value="-Xlint"/>
</javac>
</target>
<target name="clean">
<delete dir="${buildDir}"/>
</target>
<target name="cleanall">
<delete dir="${buildDir}"/>
<delete file="${installLocation}/PcdTools.jar"/>
<if>
<available file="${installLocation}/PcdTools.jar"/>
<then>
<echo message="You must manually remove the file: ${installLocation}/PcdTools.jar"/>
<echo message="Java has already loaded the file, and cannot remove it within ANT!"/>
</then>
</if>
</target>
<target name="install" depends="source">
<jar destfile="${installLocation}/PcdTools.jar"
basedir="${buildDir}"
includes="**"
/>
</target>
</project>

View File

@@ -0,0 +1,121 @@
/** @file
ActionMessage class.
ActionMessage class take over all message for loging and waning. This class should
dispatch message into different class according to instance class type.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.pcd.action;
import org.apache.tools.ant.Task;
/** ActionMessage class take over all message for loging and waning. This class
should dispatch message into different Action class according to instance
class type.
**/
public class ActionMessage {
///
/// Macro definition for NULL messge level.
/// In this meessage level, all message will be hidden.
///
public final static int NULL_MESSAGE_LEVEL = 0;
///
/// Macro definition for Log messge level.
/// In this message level, Only log information will be shown.
///
public final static int LOG_MESSAGE_LEVEL = 1;
///
/// Macro definition for Warning message level.
/// In this message level, log and waning message will be shown.
///
public final static int WARNING_MESSAGE_LEVEL = 2;
///
/// Macro definition for Debug mesage level.
/// In this message level, log, warning, debug message will be shown.
///
public final static int DEBUG_MESSAGE_LEVEL = 3;
///
/// Macor definition for MAX message level.
/// In this message level, all message will be shown.
///
public final static int MAX_MESSAGE_LEVEL = 4;
///
/// Current message level. It will control all message output for PCD tool.
///
public static int messageLevel = NULL_MESSAGE_LEVEL;
/**
Log() function provide common log information functionality for all
PCD tool includes all function
This function will dispatch message to special class such as BuildAction
Class, Entity Class etc.
@param thisClass The class object who want log information.
@param logStr The string contains log information.
**/
public static void log(Object thisClass, String logStr) {
if(messageLevel < LOG_MESSAGE_LEVEL) {
return;
}
if(thisClass instanceof Task) {
BuildAction.logMsg(thisClass, "$$LOG$$:" + logStr);
} else {
System.out.println("$$LOG$$:" + logStr);
}
}
/**
Warning() function provide common warning information functionality for all
PCD tool.
This function will dispatch message to special class such as BuildAction
Class, Entity Class etc.
@param thisClass The class object who want warn information.
@param warningStr The string contains warning information.
**/
public static void warning(Object thisClass, String warningStr) {
if(messageLevel < WARNING_MESSAGE_LEVEL) {
return;
}
if(thisClass instanceof Task) {
BuildAction.warningMsg(thisClass, "**WARNING**:" + warningStr);
} else {
System.out.println("**WARNING**:" + warningStr);
}
}
/**
Debug() function provide common Debug information functionality for all
PCD tool.
This function will dispatch message to special class such as BuildAction
Class, Entity Class etc.
@param thisClass The class object who want Debug information.
@param debugStr The string contains Debug information.
**/
public static void debug(Object thisClass, String debugStr) {
if(messageLevel < DEBUG_MESSAGE_LEVEL) {
return;
}
if(thisClass instanceof Task) {
BuildAction.logMsg(thisClass, "%%DEBUG%%:" + debugStr);
} else {
System.out.println("%%DEBUG%%:" + debugStr);
}
}
}

View File

@@ -0,0 +1,105 @@
/** @file
BuildAction class.
BuildAction is the parent class for all action related to ant Task. This class will
define some common utility functionality, such as logMsg, warningMsg..etc.
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 org.apache.tools.ant.Task;
import org.apache.tools.ant.Project;
import org.tianocore.pcd.exception.BuildActionException;
/** BuildAction is the parent class for all action related to ant Task. This class will
define some common utility functionality, such as logMsg, warningMsg..etc.
**/
public abstract class BuildAction extends Task {
///
/// Original message level before this action. This value will
/// be restored when quit this action.
///
private int originalMessageLevel;
/**
checkParameter function check all parameter valid.
This function will be overrided by child class.
**/
public abstract void checkParameter() throws BuildActionException;
/**
performAction is to execute the detail action.
This function will be overrided by child class.
**/
public abstract void performAction() throws BuildActionException;
/**
setMessageLevel function set current message for task instance object.
The message should be restored when this action exit.
@param messageLevel The message level for this action.
**/
public void setMessageLevel(int messageLevel) {
originalMessageLevel = ActionMessage.messageLevel;
ActionMessage.messageLevel = messageLevel;
}
/**
logMsg function provide common log information functionality for all
PCD tool extends from ANT task class.
This function will use the log function in Ant task class.
@param action The class object who want log information.
@param logStr The string contains log information.
**/
public static void logMsg(Object action, String logStr) {
((Task) action).log(logStr, Project.MSG_INFO);
}
/**
warningMsg function provide common warning information functionality for all
PCD tool.
This function will dispatch message to special class such as BuildAction
Class, Entity Class etc.
@param action The class object who want warn information.
@param warningStr The string contains warning information.
**/
public static void warningMsg(Object action, String warningStr) {
((Task) action).log(warningStr, Project.MSG_WARN);
}
/**
execute function is the main flow for all build action class.
This workflow will be:
1) Check paramet of this action.
2) Perform the child class action function.
3) Restore the message level.
@throws BuildActionException
**/
public void execute() throws BuildActionException {
checkParameter();
performAction();
//
// Restore orignal message level when exist the action.
//
ActionMessage.messageLevel = originalMessageLevel;
}
}

View File

@@ -0,0 +1,354 @@
/** @file
CommonDefinition class.
This class is to define some common marcos and funcions, which used by AutoGen.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.pcd.entity;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
/**
CommonDefinition
This class is to define some common marcos, which used by AutoGen.
**/
public class CommonDefinition {
public final static String spdSuffix = ".spd";
public final static String mbdSuffix = ".mbd";
public final static String msaSuffix = ".msa";
public final static String LibraryStr = "LIBRARY";
public final static String autoGenHbegin = "extern int __make_me_compile_correctly;\r\n";
public final static String include = "#include";
public final static String autoGenCLine1 = "\r\n";
public final static String autoGenCLine2 = "const UINT8 _gDebugPropertyMask "
+ "= DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED"
+ " | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED"
+ " | DEBUG_PROPERTY_DEBUG_CODE_ENABLED;\r\n";
public final static String autoGenCLine3 = "const UINTN _gModuleDefaultErrorLevel"
+ " = EFI_D_ERROR | EFI_D_LOAD;\r\n";
public final static String autoGenHLine1 = "#define EFI_SPECIFICATION_VERSION 0x00020000\r\n";
public final static String autoGenHVersionDefault = "#define EFI_SPECIFICATION_VERSION 0x00000000\r\n";
public final static String autoGenHLine2 = "#define EDK_RELEASE_VERSION 0x00090000\r\n";
public final static String autoGenHReleaseDefault = "#define EDK_RELEASE_VERSION 0x00000000\r\n";
public final static String includeAutogenH = "#include <AutoGen.h>\r\n" ;
public final static String marcDefineStr = "#define ";
public final static String gEfi = "gEfi";
public final static String protocolGuid = "ProtocolGuid";
public final static String ppiGuid = "PpiGuid";
public final static String guidGuid = "Guid";
public final static String tianoR8FlashMapH = "TianoR8FlashMap.h";
public final static String flashMapH = "FlashMap.h";
//
// AutoGen.h and AutoGen.c file's header
//
public final static String autogenHNotation =
"/**\r\n" +
" DO NOT EDIT\r\n" +
" FILE auto-generated by GenBuild tasks\r\n" +
" Module name:\r\n" +
" AutoGen.h\r\n" +
" Abstract:" +
" Auto-generated AutoGen.h for building module or library.\r\n" +
"**/\r\n\r\n";
public final static String autogenCNotation =
"/**\r\n" +
" DO NOT EDIT\r\n" +
" FILE auto-generated by GenBuild tasks\r\n" +
" Module name:\r\n" +
" AutoGen.c\r\n" +
" Abstract:" +
" Auto-generated AutoGen.c for building module or library.\r\n" +
"**/\r\n\r\n";
//
// module type
//
public final static int ModuleTypeBase = 0;
public final static int ModuleTypeSec = 1;
public final static int ModuleTypePeiCore = 2;
public final static int ModuleTypePeim = 3;
public final static int ModuleTypeDxeCore = 4;
public final static int ModuleTypeDxeDriver = 5;
public final static int ModuleTypeDxeRuntimeDriver = 6;
public final static int ModuleTypeDxeSmmDriver = 7;
public final static int ModuleTypeDxeSalDriver = 8;
public final static int ModuleTypeUefiDriver = 9;
public final static int ModuleTypeUefiApplication = 10;
public final static int ModuleTypeUnknown = 11;
//
// component type
//
public final static int ComponentTypeNull = 0;
public final static int ComponentTypeApriori = 1;
public final static int ComponentTypeSec = 2;
public final static int ComponentTypeLibrary = 3;
public final static int ComponentTypeFvImageFile = 4;
public final static int ComponentTypeBsDriver = 5;
public final static int ComponentTypeRtDriver = 6;
public final static int ComponentTypeSalRtDriver =7;
public final static int ComponentTypePe32Peim = 8;
public final static int ComponentTypePicPeim =9;
public final static int ComponentTypeCombinedPeimDriver =10;
public final static int ComponentTypePeiCore = 11;
public final static int ComponentTypeDxeCore = 12;
public final static int ComponentTypeApplication = 13;
public final static int ComponentTypeBsDriverEfi = 14;
public final static int ComponentTypeShellApp = 15;
public final static int ComponentTypeBinary =16;
public final static int ComponentTypeLogo = 17;
public final static int ComponentTypeCustomBuild = 18;
public final static int ComponentTypeUnknown = 19;
//
// Usaged style
//
public final static String AlwaysConsumed = "ALWAYS_CONSUMED";
public final static String AlwaysProduced = "ALWAYS_PRODUCED";
public static class MyEnum {
String moduleTypeStr;
int type;
MyEnum (String str, int type) {
this.type = type;
this.moduleTypeStr = str;
}
int ForInt(String str) {
if (str.equals(this.moduleTypeStr)) {
return this.type;
} else
return -1;
}
}
//
// Module type
//
public static final MyEnum[] moduleEnum = new MyEnum[] {
new MyEnum("BASE", ModuleTypeBase),
new MyEnum("SEC", ModuleTypeSec),
new MyEnum("PEI_CORE", ModuleTypePeiCore),
new MyEnum("PEIM", ModuleTypePeim),
new MyEnum("DXE_CORE", ModuleTypeDxeCore),
new MyEnum("DXE_DRIVER", ModuleTypeDxeDriver),
new MyEnum("DXE_RUNTIME_DRIVER", ModuleTypeDxeRuntimeDriver),
new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver),
new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),
new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) };
//
// Component type
//
public static final MyEnum[] componentEnum = new MyEnum[]{
new MyEnum("APRIORI", ComponentTypeApriori),
new MyEnum("SEC", ComponentTypeSec),
new MyEnum("LIBRARY", ComponentTypeLibrary),
new MyEnum("FV_IMAGE_FILE", ComponentTypeFvImageFile),
new MyEnum("BS_DRIVER", ComponentTypeBsDriver),
new MyEnum("RT_DRIVER", ComponentTypeRtDriver),
new MyEnum("SAL_RT_DRIVER", ComponentTypeSalRtDriver),
new MyEnum("PE32_PEIM", ComponentTypePe32Peim),
new MyEnum("PIC_PEIM", ComponentTypePicPeim),
new MyEnum("COMBINED_PEIM_DRIVER", ComponentTypeCombinedPeimDriver),
new MyEnum("PEI_CORE", ComponentTypePeiCore),
new MyEnum("DXE_CORE", ComponentTypeDxeCore),
new MyEnum("APPLICATION", ComponentTypeApplication),
new MyEnum("BS_DRIVER_EFI", ComponentTypeBsDriverEfi),
new MyEnum("SHELLAPP", ComponentTypeShellApp),
new MyEnum("BINARY", ComponentTypeBinary),
new MyEnum("LOGO", ComponentTypeLogo),
new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild)
};
/**
getModuleType
This function get the module type value according module type string.
@param moduleTypeStr String of modlue type.
@return
**/
static public int getModuleType(String moduleTypeStr) {
int returnValue = -1;
for (int i = 0; i < CommonDefinition.moduleEnum.length; i++) {
returnValue = CommonDefinition.moduleEnum[i].ForInt(moduleTypeStr);
if (returnValue != -1) {
return returnValue;
}
}
return CommonDefinition.ModuleTypeUnknown;
}
/**
getComponentType
This function get the component type value according commponet type
string.
@param componentTypeStr String of component type.
@return
**/
static public int getComponentType (String componentTypeStr){
int returnValue = -1;
for (int i = 0; i < CommonDefinition.componentEnum.length; i++) {
returnValue = CommonDefinition.componentEnum[i].ForInt(componentTypeStr);
if (returnValue != -1) {
return returnValue;
}
}
return CommonDefinition.ComponentTypeUnknown;
}
/**
getComponentTypeString
This function get the commponet type string according component type value.
@param componentType Integer value of component type.
@return
**/
static public String getComponentTypeString (int componentType) {
if ((componentType > CommonDefinition.ComponentTypeUnknown) ||
(componentType < CommonDefinition.ComponentTypeNull)) {
return null;
}
for (int index = 0; index < CommonDefinition.componentEnum.length; index ++) {
if (componentType == CommonDefinition.componentEnum[index].type) {
return CommonDefinition.componentEnum[index].moduleTypeStr;
}
}
return null;
}
/**
isLibraryComponent
This function is to check does componet is library according to commponet
type value.
@param componentType Integer value of component type.
@return
**/
static public boolean isLibraryComponent (int componentType) {
if (ComponentTypeLibrary == componentType) {
return true;
}
return false;
}
/**
* formateGuidName
*
* This function is to formate GUID to ANSI c form.
*
* @param guidNameCon
* String of GUID.
* @return Formated GUID.
*/
public static String formatGuidName(String guidNameConv) {
String[] strList;
String guid = "";
int index = 0;
if (guidNameConv
.matches("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}")) {
strList = guidNameConv.split("-");
guid = "0x" + strList[0] + ", ";
guid = guid + "0x" + strList[1] + ", ";
guid = guid + "0x" + strList[2] + ", ";
guid = guid + "{";
guid = guid + "0x" + strList[3].substring(0, 2) + ", ";
guid = guid + "0x" + strList[3].substring(2, 4);
while (index < strList[4].length()) {
guid = guid + ", ";
guid = guid + "0x" + strList[4].substring(index, index + 2);
index = index + 2;
}
guid = guid + "}";
return guid;
} else if (guidNameConv
.matches("0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},( )*0x[a-fA-F0-9]{1,4}(,( )*\\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\\})?")) {
strList = guidNameConv.split(",");
//
// chang Microsoft specific form to ANSI c form
//
for (int i = 0; i < 3; i++) {
guid = guid + strList[i] + ",";
}
guid = guid + "{";
for (int i = 3; i < strList.length; i++) {
if (i == strList.length - 1) {
guid = guid + strList[i];
} else {
guid = guid + strList[i] + ",";
}
}
guid = guid + "}";
return guid;
} else {
System.out
.println("Check GUID Value, it don't conform to the schema!!!");
return "0";
}
}
/**
* Remove deuplicat string in list
*
* This function is to duplicat string in list
*
* @param String[]
* String list.
* @return String[] String list which remove the duplicate string.
*/
public static String[] remDupString (String[] orgList){
Set<String> strList = new LinkedHashSet<String>();
String[] desList ;
if (orgList == null){
return new String[0];
}
for (int i = 0; i < orgList.length; i++){
strList.add(orgList[i]);
}
desList = new String[strList.size()];
Iterator item = strList.iterator();
int index = 0;
while (item.hasNext()){
desList[index] = (String)item.next();
index++;
}
return desList;
}
}

View File

@@ -0,0 +1,162 @@
/** @file
DynamicTokenValue class.
This module contains the value type of a dynamic token.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.pcd.entity;
import java.util.List;
import java.util.UUID;
import org.tianocore.pcd.exception.EntityException;
/** This class is to descript a value type of dynamic PCD.
For a dynamic or dynamicEx type PCD data, the value type can be:
1) Hii type: the value of dynamic or dynamicEx is stored into a variable.
2) Vpd type: the value of dynamic or dynamicEx is stored into somewhere set
by OEM.
3) Default type: the value of dynamic or dynamicEx is stored into PCD dynamic
database.
**/
public class DynamicTokenValue {
///
/// Enumeration macro defintion for value type.
/// BUGBUG: Not use upcase charater is to facility for reading. It may be changed
/// in coding review.
public enum VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE}
public VALUE_TYPE type;
///
/// ---------------------------------------------------------------------
/// Following member is for HII case.
/// ---------------------------------------------------------------------
///
///
/// variableName is valid only when this token support Hii functionality. variableName
/// indicates the value of token is associated with what variable.
/// variableName is defined in FPD.
public List variableName;
///
/// variableGuid is the GUID this token associated with.
///
public UUID variableGuid;
///
/// Variable offset indicate the associated variable's offset in NV storage.
///
public String variableOffset;
///
/// The default value for HII case.
///
public String hiiDefaultValue;
///
/// Following member is for VPD case.
/// BUGBUG: Consider 64 bit integer by using java.math.BigInteger.
///
public String vpdOffset;
///
/// Following member is for default case.
///
public String value;
public DynamicTokenValue() {
this.type = VALUE_TYPE.DEFAULT_TYPE;
this.variableName = null;
this.variableGuid = null;
this.variableOffset = null;
this.hiiDefaultValue = null;
this.vpdOffset = null;
this.value = null;
}
/**
Set the HII case data.
@param variableName
@param variableGuid
@param variableOffset
@param hiiDefaultValue
*/
public void setHiiData(List variableName,
UUID variableGuid,
String variableOffset,
String hiiDefaultValue) {
this.type = VALUE_TYPE.HII_TYPE;
this.variableName = variableName;
this.variableGuid = variableGuid;
this.variableOffset = variableOffset;
this.hiiDefaultValue = hiiDefaultValue;
}
/**
Get the string like L"xxx" for a variable Name.
BUGBUG: In fact, it is not correctly, variable name should be
treated as unicode UINT16 array.
@return String
*/
public String getStringOfVariableName()
throws EntityException {
String str;
int index, num;
char ch;
str = "";
for (index = 0; index < variableName.size(); index ++) {
num = Integer.decode(variableName.get(index).toString());
if ((num > 127 ) || (num < 0)) {
throw new EntityException(String.format("variable name contains >0x80 character, now is not support!"));
}
str += (char)num;
}
return str;
}
/**
Set Vpd case data.
@param vpdOffset
*/
public void setVpdData(String vpdOffset) {
this.type = VALUE_TYPE.VPD_TYPE;
this.vpdOffset = vpdOffset;
}
/**
Set default case data.
@param value
*/
public void setValue(String value) {
this.type = VALUE_TYPE.DEFAULT_TYPE;
this.value = value;
}
}

View File

@@ -0,0 +1,306 @@
/** @file
MemoryDatabaseManager class.
Database hold all PCD information comes from SPD, MSA, FPD file in memory.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.pcd.entity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.tianocore.pcd.entity.UsageIdentification;
import org.tianocore.pcd.exception.EntityException;
/** Database hold all PCD information comes from SPD, MSA, FPD file in memory.
**/
public class MemoryDatabaseManager {
///
/// Memory database. The string "cName + SpaceNameGuid" is primary key.
/// memory database is in global scope, and it will be used for others PCD tools.
///
private static Map<String, Token> memoryDatabase = null;
///
/// Before build a module, the used libary will be build firstly, the PCD of these
/// libarry is inheritted by the module, so stored module's PCD information as PCD
/// context of building libary.
///
public static List<UsageInstance> UsageInstanceContext = null;
///
/// Current module name, if now is buiding library, this value indicate this library
/// is for building what module.
///
public static String CurrentModuleName = null;
///
/// String for PCD PEIM and DXE autogen file
///
public static String PcdPeimHString = "";
public static String PcdPeimCString = "";
public static String PcdDxeHString = "";
public static String PcdDxeCString = "";
/**
Constructure function
**/
public MemoryDatabaseManager() {
//
// Allocate memory for new database in global scope.
//
if (memoryDatabase == null) {
memoryDatabase = new HashMap<String, Token>();
}
}
/**
Judege whether token exists in memory database
@param primaryKey the primaryKey for searching token
@retval TRUE - token already exist in database.
@retval FALSE - token does not exist in database.
**/
public boolean isTokenInDatabase(String primaryKey) {
return (memoryDatabase.get(primaryKey) != null);
}
/**
Add a pcd token into memory database.
@param primaryKey the primary key for searching token
@param token token instance
**/
public void addTokenToDatabase(String primaryKey, Token token) {
memoryDatabase.put(primaryKey, token);
}
/**
Get a token instance from memory database with primary key.
@param primaryKey the primary key for searching token
@return token instance.
**/
public Token getTokenByKey(String primaryKey) {
return memoryDatabase.get(primaryKey);
}
/**
Get the number of PCD token record in memory database.
@return the number of PCD token record in memory database.
**/
public int getDBSize() {
return memoryDatabase.size();
}
/**
Get the token record array contained all PCD token in memory database.
@return the token record array contained all PCD token in memory database.
**/
public Token[] getRecordArray() {
Token[] tokenArray = null;
Object[] dataArray = null;
Map.Entry entry = null;
int index = 0;
if (memoryDatabase == null) {
return null;
}
dataArray = memoryDatabase.entrySet().toArray();
tokenArray = new Token[memoryDatabase.size()];
for (index = 0; index < memoryDatabase.size(); index ++) {
entry =(Map.Entry) dataArray [index];
tokenArray[index] =(Token) entry.getValue();
}
return tokenArray;
}
/**
Get record array only contains DYNAMIC or DYNAMIC_EX type PCD.
@return ArrayList
*/
private ArrayList getDynamicRecordArray() {
Token[] tokenArray = getRecordArray();
int index = 0;
ArrayList<Token> al = new ArrayList<Token>();
for (index = 0; index < tokenArray.length; index++) {
if (tokenArray[index].isDynamicPCD) {
al.add(tokenArray[index]);
}
}
return al;
}
/**
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.
@return the token record array contained all PCD token referenced in PEI phase.
@throws EntityException
**/
public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe)
throws EntityException {
int usageInstanceIndex = 0;
int index = 0;
ArrayList tokenArrayList = getDynamicRecordArray();
Object[] usageInstanceArray = null;
UsageInstance usageInstance = null;
//pei = new ArrayList<Token>();
//dxe = new ArrayList<Token>();
for (index = 0; index < tokenArrayList.size(); index++) {
boolean found = false;
Token token = (Token) tokenArrayList.get(index);
if (token.consumers != null) {
usageInstanceArray = token.consumers.entrySet().toArray();
for (usageInstanceIndex = 0; usageInstanceIndex < token.consumers.size(); usageInstanceIndex ++) {
usageInstance =(UsageInstance) (((Map.Entry)usageInstanceArray[usageInstanceIndex]).getValue());
if (usageInstance.isPeiPhaseComponent()) {
pei.add(token);
found = true;
break;
}
}
}
//
// If no PEI components reference the PCD entry,
// we check if it is referenced in DXE driver.
//
if (!found) {
if (token.consumers != null) {
usageInstanceArray = token.consumers.entrySet().toArray();
for (usageInstanceIndex = 0; usageInstanceIndex < token.consumers.size(); usageInstanceIndex ++) {
usageInstance =(UsageInstance) (((Map.Entry)usageInstanceArray[usageInstanceIndex]).getValue());
if (usageInstance.isDxePhaseComponent()) {
dxe.add(token);
found = true;
break;
}
}
}
if (!found) {
if (token.isDynamicPCD && token.consumers.size() == 0) {
dxe.add(token);
} else {
//
// We only support Dynamice(EX) type for PEI and DXE phase.
// If it is not referenced in either PEI or DXE, throw exception now.
//
throw new EntityException("[PCD tool Internal Error] Dynamic(EX) PCD Entries are referenced in module that is not in PEI phase nor in DXE phase.");
}
}
}
}
return;
}
/**
Get all PCD record for a module according to module's name, module's GUID,
package name, package GUID, arch, version information.
@param usageId the id of UsageInstance.
@return all usage instance for this module in memory database.
**/
public List<UsageInstance> getUsageInstanceArrayByModuleName(UsageIdentification usageId) {
String primaryKey = UsageInstance.getPrimaryKey(usageId);
return getUsageInstanceArrayByKeyString(primaryKey);
}
/**
Get all PCD token for a usage instance according to primary key.
@param primaryKey the primary key of usage instance.
@return List<UsageInstance>
*/
public List<UsageInstance> getUsageInstanceArrayByKeyString(String primaryKey) {
Token[] tokenArray = null;
int recordIndex = 0;
UsageInstance usageInstance = null;
List<UsageInstance> returnArray = new ArrayList<UsageInstance>();
tokenArray = getRecordArray();
//
// Loop to find all PCD record related to current module
//
for (recordIndex = 0; recordIndex < getDBSize(); recordIndex ++) {
if (tokenArray[recordIndex].consumers.size() != 0) {
usageInstance = tokenArray[recordIndex].consumers.get(primaryKey);
if (usageInstance != null) {
returnArray.add(usageInstance);
}
}
}
return returnArray;
}
/**
Get all modules name who contains PCD information
@return Array for module name
**/
public List<String> getAllModuleArray()
{
int indexToken = 0;
int usageIndex = 0;
int moduleIndex = 0;
Token[] tokenArray = null;
Object[] usageInstanceArray = null;
List<String> moduleNames = new ArrayList<String>();
UsageInstance usageInstance = null;
boolean bFound = false;
tokenArray = getRecordArray();
//
// Find all consumer usage instance for retrieving module's name
//
for (indexToken = 0; indexToken < getDBSize(); indexToken ++) {
usageInstanceArray = tokenArray[indexToken].consumers.entrySet().toArray();
for (usageIndex = 0; usageIndex < tokenArray[indexToken].consumers.size(); usageIndex ++) {
usageInstance = (UsageInstance)((Map.Entry)usageInstanceArray[usageIndex]).getValue();
bFound = false;
for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {
if (moduleNames.get(moduleIndex).equalsIgnoreCase(usageInstance.getPrimaryKey())) {
bFound = true;
break;
}
}
if (!bFound) {
moduleNames.add(usageInstance.getPrimaryKey());
}
}
}
return moduleNames;
}
}

View File

@@ -0,0 +1,45 @@
/** @file
SkuInstance class.
Sku instance contains ID and value, A pcd token maybe contains more than one Sku instance.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.pcd.entity;
/** Sku instance contains ID and value, A pcd token maybe contains more than one Sku instance.
**/
public class SkuInstance {
///
/// The id number of this SKU instance
///
public int id;
///
/// The value of this SKU instance
///
public DynamicTokenValue value;
/**
Constructure function
@param id sku id
@param value sku value for this id.
**/
public SkuInstance(int id, DynamicTokenValue value) {
this.id = id;
this.value = value;
}
public SkuInstance() {
this.id = 0;
this.value = new DynamicTokenValue();
}
}

View File

@@ -0,0 +1,850 @@
/** @file
Token class.
This module contains all classes releted to PCD token.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.pcd.entity;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.tianocore.pcd.entity.UsageIdentification;
import org.tianocore.pcd.exception.EntityException;
/** This class is to descript a PCD token object. The information of a token mainly
comes from MSA, SPD and setting produced by platform developer.
**/
public class Token {
///
/// Enumeration macro defintion for PCD type.
/// BUGBUG: Not use upcase charater is to facility for reading. It may be changed
/// in coding review.
public enum PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC,
DYNAMIC_EX, UNKNOWN}
///
/// Enumeration macro definition for datum type. All type mainly comes from ProcessBind.h.
/// Wizard maybe expand this type as "int, unsigned int, short, unsigned short etc" in
/// prompt dialog.
///
public enum DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN}
///
/// Enumeration macor defintion for usage of PCD
///
public enum PCD_USAGE {ALWAYS_PRODUCED, ALWAYS_CONSUMED, SOMETIMES_PRODUCED,
SOMETIMES_CONSUMED, UNKNOWN}
///
/// cName is to identify a PCD entry and will be used for generating autogen.h/autogen.c.
/// cName will be defined in MSA, SPD and FPD, can be regarded as primary key with token space guid.
///
public String cName;
///
/// 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
/// assignedtokenSpaceName as follows.
/// tokenSpaceName is defined in MSA, SPD, FPD, can be regarded as primary key with cName.
///
public String tokenSpaceName;
///
/// tokenNumber is allocated by platform. tokenNumber indicate an index for this token in
/// platform token space. For Dynamic, dynamicEx type, this number will be re-adjust by
/// PCD run-time database autogen tools.
///
public long tokenNumber;
///
/// This token number is retrieved from FPD file for DynamicEx type.
///
public long dynamicExTokenNumber;
///
/// All supported PCD type, this value can be retrieved from SPD
/// Currently, only record all PCD type for this token in FPD file.
///
public List<PCD_TYPE> supportedPcdType;
///
/// If the token's item type is Dynamic or DynamicEx type, isDynamicPCD
/// is true.
///
public boolean isDynamicPCD;
///
/// datumSize is to descript the fix size or max size for this token.
/// datumSize is defined in SPD.
///
public int datumSize;
///
/// datum type is to descript what type can be expressed by a PCD token.
/// For same PCD used in different module, the datum type should be unique.
/// So it belong memeber to Token class.
///
public DATUM_TYPE datumType;
///
/// skuData contains all value for SkuNumber of token.
/// This field is for Dynamic or DynamicEx type PCD,
///
public List<SkuInstance> skuData;
///
/// consumers array record all module private information who consume this PCD token.
///
public Map<String, UsageInstance> consumers;
/**
Constructure function for Token class
@param cName The name of token
@param tokenSpaceName The name of token space, it is a guid string
**/
public Token(String cName, String tokenSpaceName) {
this.cName = cName;
this.tokenSpaceName = tokenSpaceName;
this.tokenNumber = 0;
this.datumType = DATUM_TYPE.UNKNOWN;
this.datumSize = -1;
this.skuData = new ArrayList<SkuInstance>();
this.consumers = new HashMap<String, UsageInstance>();
this.supportedPcdType = new ArrayList<PCD_TYPE>();
}
/**
updateSupportPcdType
SupportPcdType should be gotten from SPD file actually, but now it just
record all PCD type for this token in FPD file.
@param pcdType new PCD type found in FPD file for this token.
**/
public void updateSupportPcdType(PCD_TYPE pcdType) {
for (int index = 0; index < this.supportedPcdType.size(); index ++) {
if (supportedPcdType.get(index) == pcdType) {
return;
}
}
//
// If not found, add the pcd type to member variable supportedPcdType
//
supportedPcdType.add(pcdType);
}
/**
Judge whether pcdType is belong to dynamic type. Dynamic type includes
DYNAMIC and DYNAMIC_EX.
@param pcdType the judged pcd type
@return boolean
*/
public static boolean isDynamic(PCD_TYPE pcdType) {
if ((pcdType == PCD_TYPE.DYNAMIC ) ||
(pcdType == PCD_TYPE.DYNAMIC_EX)) {
return true;
}
return false;
}
public boolean isDynamicEx() {
for (int i = 0; i < supportedPcdType.size(); i++) {
if (supportedPcdType.get(i) == PCD_TYPE.DYNAMIC_EX) {
return true;
}
}
return false;
}
/**
Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database
@param cName Token name.
@param tokenSpaceName The token space guid string defined in MSA or SPD
@retval primary key for this token in token database.
**/
public static String getPrimaryKeyString(String cName, String tokenSpaceName) {
if (tokenSpaceName == null) {
return cName + "_nullTokenSpaceGuid";
} else {
return cName + "_" + tokenSpaceName.toString().replace('-', '_');
}
}
/**
If skudata list contains more than one data, then Sku mechanism is enable.
@retval boolean if the number of sku data exceed to 1
*/
public boolean isSkuEnable() {
if (this.skuData.size() > 1) {
return true;
}
return false;
}
/**
If Hii type for value of token
@return boolean
**/
public boolean isHiiEnable() {
if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {
return true;
}
return false;
}
/**
If Vpd type for value of token
@return boolean
**/
public boolean isVpdEnable() {
if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {
return true;
}
return false;
}
/**
Get the token primary key in token database.
@return String
*/
public String getPrimaryKeyString () {
return Token.getPrimaryKeyString(cName, tokenSpaceName);
}
/**
Judge datumType is valid
@param type The datumType want to be judged.
@retval TRUE - The type is valid.
@retval FALSE - The type is invalid.
**/
public static boolean isValiddatumType(DATUM_TYPE type) {
if ((type.ordinal() < DATUM_TYPE.UINT8.ordinal() ) ||
(type.ordinal() > DATUM_TYPE.POINTER.ordinal())) {
return false;
}
return true;
}
/**
Judge pcdType is valid
@param type The PCdType want to be judged.
@retval TRUE - The type is valid.
@retval FALSE - The type is invalid.
**/
public static boolean isValidpcdType(PCD_TYPE type) {
if ((type.ordinal() < PCD_TYPE.FEATURE_FLAG.ordinal() ) ||
(type.ordinal() > PCD_TYPE.DYNAMIC_EX.ordinal())) {
return false;
}
return true;
}
/**
Add an usage instance for token
@param usageInstance The usage instance
@retval TRUE - Success to add usage instance.
@retval FALSE - Fail to add usage instance
**/
public boolean addUsageInstance(UsageInstance usageInstance) throws EntityException {
String exceptionStr;
if (isUsageInstanceExist(usageInstance.usageId)) {
exceptionStr = String.format("[PCD Collection Tool Exception] PCD %s for module %s has already exist in database, Please check all PCD build entries "+
"in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!",
usageInstance.parentToken.cName,
usageInstance.usageId.moduleName,
usageInstance.usageId.moduleName);
throw new EntityException(exceptionStr);
}
//
// Put usage instance into usage instance database of this PCD token.
//
consumers.put(usageInstance.getPrimaryKey(), usageInstance);
return true;
}
/**
Judge whether exist an usage instance for this token
@param usageId The UsageInstance identification for usage instance
@return boolean whether exist an usage instance for this token.
*/
public boolean isUsageInstanceExist(UsageIdentification usageId) {
String keyStr = UsageInstance.getPrimaryKey(usageId);
return (consumers.get(keyStr) != null);
}
/**
Get the PCD_TYPE according to the string of PCD_TYPE
@param pcdTypeStr The string of PCD_TYPE
@return PCD_TYPE
**/
public static PCD_TYPE getpcdTypeFromString(String pcdTypeStr) {
if (pcdTypeStr == null) {
return PCD_TYPE.UNKNOWN;
}
if (pcdTypeStr.equalsIgnoreCase("FEATURE_FLAG")) {
return PCD_TYPE.FEATURE_FLAG;
} else if (pcdTypeStr.equalsIgnoreCase("FIXED_AT_BUILD")) {
return PCD_TYPE.FIXED_AT_BUILD;
} else if (pcdTypeStr.equalsIgnoreCase("PATCHABLE_IN_MODULE")) {
return PCD_TYPE.PATCHABLE_IN_MODULE;
} else if (pcdTypeStr.equalsIgnoreCase("DYNAMIC")) {
return PCD_TYPE.DYNAMIC;
} else if (pcdTypeStr.equalsIgnoreCase("DYNAMIC_EX")) {
return PCD_TYPE.DYNAMIC_EX;
} else {
return PCD_TYPE.UNKNOWN;
}
}
/**
Get the string of given datumType. This string will be used for generating autogen files
@param datumType Given datumType
@return The string of datum type.
**/
public static String getStringOfdatumType(DATUM_TYPE datumType) {
switch (datumType) {
case UINT8:
return "UINT8";
case UINT16:
return "UINT16";
case UINT32:
return "UINT32";
case UINT64:
return "UINT64";
case POINTER:
return "POINTER";
case BOOLEAN:
return "BOOLEAN";
}
return "UNKNOWN";
}
/**
Get the datumType according to a string.
@param datumTypeStr The string of datumType
@return DATUM_TYPE
**/
public static DATUM_TYPE getdatumTypeFromString(String datumTypeStr) {
if (datumTypeStr.equalsIgnoreCase("UINT8")) {
return DATUM_TYPE.UINT8;
} else if (datumTypeStr.equalsIgnoreCase("UINT16")) {
return DATUM_TYPE.UINT16;
} else if (datumTypeStr.equalsIgnoreCase("UINT32")) {
return DATUM_TYPE.UINT32;
} else if (datumTypeStr.equalsIgnoreCase("UINT64")) {
return DATUM_TYPE.UINT64;
} else if (datumTypeStr.equalsIgnoreCase("VOID*")) {
return DATUM_TYPE.POINTER;
} else if (datumTypeStr.equalsIgnoreCase("BOOLEAN")) {
return DATUM_TYPE.BOOLEAN;
}
return DATUM_TYPE.UNKNOWN;
}
/**
Get string of given pcdType
@param pcdType The given PcdType
@return The string of PCD_TYPE.
**/
public static String getStringOfpcdType(PCD_TYPE pcdType) {
switch (pcdType) {
case FEATURE_FLAG:
return "FEATURE_FLAG";
case FIXED_AT_BUILD:
return "FIXED_AT_BUILD";
case PATCHABLE_IN_MODULE:
return "PATCHABLE_IN_MODULE";
case DYNAMIC:
return "DYNAMIC";
case DYNAMIC_EX:
return "DYNAMIC_EX";
}
return "UNKNOWN";
}
/**
Get the PCD_USAGE according to a string
@param usageStr The string of PCD_USAGE
@return The PCD_USAGE
**/
public static PCD_USAGE getUsageFromString(String usageStr) {
if (usageStr == null) {
return PCD_USAGE.UNKNOWN;
}
if (usageStr.equalsIgnoreCase("ALWAYS_PRODUCED")) {
return PCD_USAGE.ALWAYS_PRODUCED;
} else if (usageStr.equalsIgnoreCase("SOMETIMES_PRODUCED")) {
return PCD_USAGE.SOMETIMES_PRODUCED;
} else if (usageStr.equalsIgnoreCase("ALWAYS_CONSUMED")) {
return PCD_USAGE.ALWAYS_CONSUMED;
} else if (usageStr.equalsIgnoreCase("SOMETIMES_CONSUMED")) {
return PCD_USAGE.SOMETIMES_CONSUMED;
}
return PCD_USAGE.UNKNOWN;
}
/**
Get the string of given PCD_USAGE
@param usage The given PCD_USAGE
@return The string of PDC_USAGE.
**/
public static String getStringOfUsage(PCD_USAGE usage) {
switch (usage) {
case ALWAYS_PRODUCED:
return "ALWAYS_PRODUCED";
case ALWAYS_CONSUMED:
return "ALWAYS_CONSUMED";
case SOMETIMES_PRODUCED:
return "SOMETIMES_PRODUCED";
case SOMETIMES_CONSUMED:
return "SOMETIMES_CONSUMED";
}
return "UNKNOWN";
}
/**
Get the Defined datumType string for autogen. The string is for generating some MACROs in Autogen.h
@param datumType The given datumType
@return string of datum type for autogen.
**/
public static String GetAutogenDefinedatumTypeString(DATUM_TYPE datumType) {
switch (datumType) {
case UINT8:
return "8";
case UINT16:
return "16";
case BOOLEAN:
return "BOOL";
case POINTER:
return "PTR";
case UINT32:
return "32";
case UINT64:
return "64";
default:
return null;
}
}
/**
Get the datumType String for Autogen. This string will be used for generating defintions of PCD token in autogen
@param datumType The given datumType
@return string of datum type.
**/
public static String getAutogendatumTypeString(DATUM_TYPE datumType) {
switch (datumType) {
case UINT8:
return "UINT8";
case UINT16:
return "UINT16";
case UINT32:
return "UINT32";
case UINT64:
return "UINT64";
case POINTER:
return "VOID*";
case BOOLEAN:
return "BOOLEAN";
}
return null;
}
/**
Get the datumType string for generating some MACROs in autogen file of Library
@param datumType The given datumType
@return String of datum for genrating bit charater.
**/
public static String getAutogenLibrarydatumTypeString(DATUM_TYPE datumType) {
switch (datumType) {
case UINT8:
return "8";
case UINT16:
return "16";
case BOOLEAN:
return "Bool";
case POINTER:
return "Ptr";
case UINT32:
return "32";
case UINT64:
return "64";
default:
return null;
}
}
/**
Get the sku data who id is 0.
@retval DynamicTokenValue the value of this dyanmic token.
**/
public DynamicTokenValue getDefaultSku() {
DynamicTokenValue dynamicData;
int index;
for (index = 0; index < this.skuData.size(); index ++) {
if (skuData.get(index).id == 0) {
return skuData.get(index).value;
}
}
return null;
}
/**
Get the number of Sku data for this token
@retval int the number of sku data
**/
public int getSkuIdCount () {
return this.skuData.size();
}
/**
Get the size of PCD value, this PCD is POINTER type.
@param str the string of the value
@param al
**/
private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {
if (isValidNullValue(str)) {
al.add(new Integer(0));
} else {
//
// isValidNullValue has already make sure that str here
// always contain a valid default value of the following 3
// cases:
// 1) "Hello world" //Assci string
// 2) L"Hello" //Unicode string
// 3) {0x01, 0x02, 0x03} //Byte stream
//
if (str.startsWith("\"")) {
al.add(new Integer(str.length() - 2));
} else if (str.startsWith("L\"")){
//
// Unicode is 2 bytes each.
//
al.add(new Integer((str.length() - 3) * 2));
} else if (str.startsWith("{")) {
//
// We count the number of "," in the string.
// The number of byte is one plus the number of
// comma.
//
String str2 = str;
int cnt = 0;
int pos = 0;
pos = str2.indexOf(",", 0);
while (pos != -1) {
cnt++;
pos++;
pos = str2.indexOf(",", pos);
}
cnt++;
al.add(new Integer(cnt));
}
}
}
/**
This method can be used to get the MAX and current size
for pointer type dynamic(ex) PCD entry
**/
public ArrayList<Integer> getPointerTypeSize () {
ArrayList<Integer> al = new ArrayList<Integer>();
//
// For VPD_enabled and HII_enabled, we can only return the MAX size.
// For the default DATA type dynamic PCD entry, we will return
// the MAX size and current size for each SKU_ID.
//
al.add(new Integer(this.datumSize));
if (!this.isVpdEnable()) {
int idx;
if (this.isHiiEnable()){
for (idx = 0; idx < this.skuData.size(); idx++) {
String str = this.skuData.get(idx).value.hiiDefaultValue;
getCurrentSizeFromDefaultValue(str, al);
}
} else {
for (idx = 0; idx < this.skuData.size(); idx++) {
String str = this.skuData.get(idx).value.value;
getCurrentSizeFromDefaultValue(str, al);
}
}
}
return al;
}
/**
Get default value for a token, For HII type, HiiDefaultValue of default
SKU 0 will be returned; For Default type, the defaultvalue of default SKU
0 will be returned.
@return String
*/
public String getDynamicDefaultValue() {
DynamicTokenValue dynamicData = getDefaultSku();
if (hasDefaultValue()) {
switch (dynamicData.type) {
case DEFAULT_TYPE:
return dynamicData.value;
}
}
return null;
}
//
// BugBug: We need change this algorithm accordingly when schema is updated
// to support no default value.
//
public boolean hasDefaultValue () {
int value = 0;
boolean isInteger = true;
DynamicTokenValue dynamicValue = null;
if (isSkuEnable()) {
return true;
}
if (this.isDynamicPCD) {
dynamicValue = getDefaultSku();
switch (dynamicValue.type) {
case HII_TYPE:
return true;
case VPD_TYPE:
return true;
case DEFAULT_TYPE:
return !isValidNullValue(dynamicValue.value);
}
}
return false;
}
/**
Judge the value is NULL value. NULL value means the value is uninitialized value
@param judgedValue
@return boolean
*/
public boolean isValidNullValue(String judgedValue) {
String subStr;
BigInteger bigIntValue;
switch (datumType) {
case UINT8:
case UINT16:
case UINT32:
if (judgedValue.length() > 2) {
if ((judgedValue.charAt(0) == '0') &&
((judgedValue.charAt(1) == 'x') || (judgedValue.charAt(1) == 'X'))){
subStr = judgedValue.substring(2, judgedValue.length());
bigIntValue = new BigInteger(subStr, 16);
} else {
bigIntValue = new BigInteger(judgedValue);
}
} else {
bigIntValue = new BigInteger(judgedValue);
}
if (bigIntValue.bitCount() == 0) {
return true;
}
break;
case UINT64:
if (judgedValue.length() > 2){
if ((judgedValue.charAt(0) == '0') &&
((judgedValue.charAt(1) == 'x') ||
(judgedValue.charAt(1) == 'X'))) {
bigIntValue = new BigInteger(judgedValue.substring(2, judgedValue.length()), 16);
if (bigIntValue.bitCount() == 0) {
return true;
}
} else {
bigIntValue = new BigInteger(judgedValue);
if (bigIntValue.bitCount() == 0) {
return true;
}
}
} else {
bigIntValue = new BigInteger(judgedValue);
if (bigIntValue.bitCount() == 0) {
return true;
}
}
break;
case BOOLEAN:
if (judgedValue.equalsIgnoreCase("false")) {
return true;
}
break;
case POINTER:
if (judgedValue.equalsIgnoreCase("") ||
judgedValue.equalsIgnoreCase("\"\"") ||
judgedValue.equalsIgnoreCase("L\"\"") ||
(judgedValue.length() == 0) ||
judgedValue.equalsIgnoreCase("{0}")) {
return true;
}
}
return false;
}
/**
Is the string value in Unicode
@return boolean
**/
public boolean isHiiDefaultValueUnicodeStringType() {
DynamicTokenValue dynamicData = getDefaultSku();
if (dynamicData == null)
return false;
return dynamicData.hiiDefaultValue.startsWith("L\"")
&& dynamicData.hiiDefaultValue.endsWith("\"");
}
/**
Is the string value in ANSCI
@return boolean
**/
public boolean isHiiDefaultValueASCIIStringType() {
DynamicTokenValue dynamicData = getDefaultSku();
if (dynamicData == null)
return false;
return dynamicData.hiiDefaultValue.startsWith("\"")
&& dynamicData.hiiDefaultValue.endsWith("\"");
}
/**
Judege whether current value is UNICODE string type.
@return boolean
*/
public boolean isUnicodeStringType () {
String str = getDynamicDefaultValue();
if (str == null) {
return false;
}
if (datumType == Token.DATUM_TYPE.POINTER &&
str.startsWith("L\"") &&
str.endsWith("\"")) {
return true;
}
return false;
}
public boolean isASCIIStringType () {
String str = getDynamicDefaultValue();
if (str == null) {
return false;
}
if (datumType == Token.DATUM_TYPE.POINTER &&
str.startsWith("\"") &&
str.endsWith("\"")) {
return true;
}
return false;
}
public boolean isByteStreamType () {
String str = getDynamicDefaultValue();
if (str == null) {
return false;
}
if (datumType == Token.DATUM_TYPE.POINTER &&
str.startsWith("{") &&
str.endsWith("}")) {
return true;
}
return false;
}
public String getStringTypeString () {
return getDefaultSku().value.substring(2, getDefaultSku().value.length() - 1);
}
}

View File

@@ -0,0 +1,97 @@
/** @file
UsageIdentification class.
This class an identification for a PCD UsageInstance.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.pcd.entity;
/**
**/
public class UsageIdentification {
///
/// The module CName: one key of Identification
///
public String moduleName;
///
/// The module Guid String: one key of Identification
///
public String moduleGuid;
///
/// The package CName: one key of Identification
///
public String packageName;
///
/// The package Guid: one key of Identification
///
public String packageGuid;
///
/// Module's Arch: one key of Identification
///
public String arch;
///
/// Module's version: one key of Identification
///
public String version;
///
/// Module's type
///
public String moduleType;
/**
Constructor function for UsageIdentification class.
@param moduleName The key of module's name
@param moduleGuid The key of module's GUID string
@param packageName The key of package's name
@param packageGuid The key of package's Guid
@param arch The architecture string
@param version The version String
@param moduleType The module type
**/
public UsageIdentification (String moduleName,
String moduleGuid,
String packageName,
String packageGuid,
String arch,
String version,
String moduleType) {
this.moduleName = moduleName;
this.moduleGuid = moduleGuid;
this.packageName = packageName;
this.packageGuid = packageGuid;
this.arch = arch;
this.version = version;
this.moduleType = moduleType;
}
/**
Generate the string for UsageIdentification
@return the string value for UsageIdentification
**/
public String toString() {
//
// Because currently transition schema not require write moduleGuid, package Name, Packge GUID in
// <ModuleSA> section, So currently no expect all paramter must be valid.
// BUGBUG: Because currently we can not get version from MSA, So ignore verison.
//
return(moduleName + "_" +
((moduleGuid != null) ? moduleGuid.toLowerCase() : "NullModuleGuid") + "_" +
((packageName != null) ? packageName : "NullPackageName") + "_" +
((packageGuid != null) ? packageGuid.toLowerCase() : "NullPackageGuid") + "_" +
((arch != null) ? arch : "NullArch") + "_" +
"NullVersion");
}
}

View File

@@ -0,0 +1,389 @@
/** @file
UsageInstance class.
This class indicate an usage instance for a PCD token. This instance maybe a module
or platform setting. When a module produce or cosume a PCD token, then this module
is an usage instance for this PCD token.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.pcd.entity;
import java.util.UUID;
import org.tianocore.ModuleTypeDef;
import org.tianocore.pcd.entity.CommonDefinition;
import org.tianocore.pcd.entity.UsageIdentification;
import org.tianocore.pcd.exception.EntityException;
/**
This class indicate an usage instance for a PCD token. This instance maybe a module
or platform setting. When a module produce or cosume a PCD token, then this module
is an usage instance for this PCD token.
**/
public class UsageInstance {
///
/// This parent that this usage instance belongs to.
///
public Token parentToken;
///
/// ModuleIdentification for Usage Instance
///
public UsageIdentification usageId;
///
/// Arch also is a key for a UsageInstance
///
public String arch;
///
/// The PCD type defined for module
///
public Token.PCD_TYPE modulePcdType;
///
/// The value of the PCD in this usage instance.
///
public String datum;
///
/// The maxDatumSize could be different for same PCD in different module
/// But this case is allow for FeatureFlag, FixedAtBuild, PatchableInModule
/// type.
///
public int maxDatumSize;
///
/// Autogen string for header file.
///
public String hAutogenStr;
///
/// Auotgen string for C code file.
///
public String cAutogenStr;
/**
Constructure function for UsageInstance
@param parentToken The token instance for this usgaInstance
@param id The identification for usage instance
@param modulePcdType The PCD type for this usage instance
@param value The value of this PCD in this usage instance
@param maxDatumSize The max datum size of this PCD in this usage
instance.
**/
public UsageInstance(Token parentToken,
UsageIdentification usageId,
Token.PCD_TYPE modulePcdType,
String value,
int maxDatumSize) {
this.parentToken = parentToken;
this.usageId = usageId;
this.modulePcdType = modulePcdType;
this.datum = value;
this.maxDatumSize = maxDatumSize;
}
/**
Get the primary key for usage instance array for every token.
@param usageId The identification of UsageInstance
@retval String The primary key for this usage instance
**/
public static String getPrimaryKey(UsageIdentification usageId) {
return usageId.toString();
}
/**
Get primary key string for this usage instance
@return String primary key string
**/
public String getPrimaryKey() {
return UsageInstance.getPrimaryKey(usageId);
}
/**
Judget whether current module is PEI driver
@return boolean whether current module is PEI driver
**/
public boolean isPeiPhaseComponent() {
int moduleType = CommonDefinition.getModuleType(usageId.moduleType);
if ((moduleType == CommonDefinition.ModuleTypePeiCore) ||
(moduleType == CommonDefinition.ModuleTypePeim)) {
return true;
}
return false;
}
/**
Judge whether current module is DXE driver.
@return boolean whether current module is DXE driver
**/
public boolean isDxePhaseComponent() {
int moduleType = CommonDefinition.getModuleType(usageId.moduleType);
if ((moduleType == CommonDefinition.ModuleTypeDxeDriver) ||
(moduleType == CommonDefinition.ModuleTypeDxeRuntimeDriver) ||
(moduleType == CommonDefinition.ModuleTypeDxeSalDriver) ||
(moduleType == CommonDefinition.ModuleTypeDxeSmmDriver) ||
(moduleType == CommonDefinition.ModuleTypeUefiDriver) ||
(moduleType == CommonDefinition.ModuleTypeUefiApplication)
) {
return true;
}
return false;
}
/**
Generate autogen string for header file and C code file.
@param isBuildUsedLibrary whether the autogen is for library.
**/
public void generateAutoGen(boolean isBuildUsedLibrary) {
String guidStringCName = null;
boolean isByteArray = false;
String printDatum = null;
String tokenNumberString = null;
hAutogenStr = "";
cAutogenStr = "";
if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {
//
// For DYNAMIC_EX type PCD, use original token number in SPD or FPD to generate autogen
//
tokenNumberString = Long.toString(parentToken.dynamicExTokenNumber, 16);
} else {
//
// For Others type PCD, use autogenerated token number to generate autogen
//
tokenNumberString = Long.toString(parentToken.tokenNumber, 16);
}
hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%s\r\n", parentToken.cName, tokenNumberString);
//
// Judge the value of this PCD is byte array type
//
if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {
if (datum.trim().charAt(0) == '{') {
isByteArray = true;
}
}
//
// "ULL" should be added to value's tail for UINT64 value
//
if (parentToken.datumType == Token.DATUM_TYPE.UINT64) {
printDatum = this.datum + "ULL";
} else {
printDatum = this.datum;
}
switch (modulePcdType) {
case FEATURE_FLAG:
hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",
parentToken.cName);
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",
parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) If is not allowed to set value for a FEATURE_FLAG PCD\r\n",
parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName);
if (!isBuildUsedLibrary) {
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
parentToken.cName,
printDatum);
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
parentToken.cName,
parentToken.cName);
}
break;
case FIXED_AT_BUILD:
if (isByteArray) {
hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",
parentToken.cName);
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
} else {
hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName);
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
}
hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\r\n",
parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName);
if (!isBuildUsedLibrary) {
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {
if (isByteArray) {
hAutogenStr += String.format("#define _PCD_VALUE_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n",
parentToken.cName,
parentToken.cName);
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",
parentToken.cName,
printDatum);
} else {
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
parentToken.cName,
printDatum);
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
}
} else {
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
parentToken.cName,
printDatum);
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
}
}
break;
case PATCHABLE_IN_MODULE:
if (isByteArray) {
hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",
parentToken.cName);
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_BinaryPatch_%s\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
} else {
hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName);
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
}
//
// Generate _PCD_SET_MODE_xx macro for using set BinaryPatch value via PcdSet macro
//
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_%s, (Buffer), (SizeOfBuffer))\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
} else {
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) (_gPcd_BinaryPatch_%s = (Value))\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
}
if (!isBuildUsedLibrary) {
hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",
parentToken.cName,
printDatum);
if (isByteArray) {
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[] = _PCD_VALUE_%s;\r\n",
parentToken.cName,
parentToken.cName);
} else {
cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",
Token.getAutogendatumTypeString(parentToken.datumType),
parentToken.cName,
parentToken.cName);
}
}
break;
case DYNAMIC:
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGet%s(_PCD_TOKEN_%s)\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),
parentToken.cName);
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSet%s(_PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),
parentToken.cName);
} else {
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSet%s(_PCD_TOKEN_%s, (Value))\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),
parentToken.cName);
}
break;
case DYNAMIC_EX:
guidStringCName = "_gPcd_TokenSpaceGuid_" +
parentToken.tokenSpaceName.toString().replaceAll("-", "_");
hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),
guidStringCName,
parentToken.cName);
if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),
guidStringCName,
parentToken.cName);
} else {
hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (Value))\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),
guidStringCName,
parentToken.cName);
}
break;
}
}
/**
Get the autogen string for header file.
@return The string of header file.
**/
public String getHAutogenStr() {
return hAutogenStr;
}
/**
Get the autogen string for C code file.
@return The string of C Code file.
**/
public String getCAutogenStr() {
return cAutogenStr;
}
}

View File

@@ -0,0 +1,33 @@
/** @file
BuildActionException class.
BuildAction Exception deals with all build action exceptions.
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.exception;
import org.apache.tools.ant.BuildException;
/**
BuildAction Exception deals with all build action exceptions.
**/
public class BuildActionException extends BuildException {
static final long serialVersionUID = -7034897190740066939L;
/**
Constructure function
@param reason exception message string.
**/
public BuildActionException(String reason) {
super(reason);
}
}

View File

@@ -0,0 +1,31 @@
/** @file
EntityException class.
The class handle the exception throwed by entity class.
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.exception;
/**
The class handle the exception throwed by entity class.
**/
public class EntityException extends Exception {
static final long serialVersionUID = -8034897190740066939L;
/**
Constructure function
@param expStr exception message string.
**/
public EntityException(String expStr) {
super("[PCD EntityException]:" + expStr);
}
}

View File

@@ -0,0 +1,31 @@
/** @file
UIException class.
The class handle the exception throwed by UI action class.
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.exception;
/**
The class handle the exception throwed by UI action class.
**/
public class UIException extends Exception {
static final long serialVersionUID = -7034897190740066930L;
/**
Constructure function
@param reason exception message string.
**/
public UIException(String reason) {
super(reason);
}
}