summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqouyang <qouyang@6f19259b-4bc3-4df7-8a09-765794883524>2006-06-30 19:56:10 +0000
committerqouyang <qouyang@6f19259b-4bc3-4df7-8a09-765794883524>2006-06-30 19:56:10 +0000
commit136adffc5cd7efb21a38a980ff361edaa29629b3 (patch)
treed739587ce2c697ba0c645ef9625d82e5f4e923e5
parent1ea046d4c4a07e1fbffa43eb46fd7004ed8aed16 (diff)
downloadedk2-136adffc5cd7efb21a38a980ff361edaa29629b3.zip
edk2-136adffc5cd7efb21a38a980ff361edaa29629b3.tar.gz
edk2-136adffc5cd7efb21a38a980ff361edaa29629b3.tar.bz2
New tool.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@692 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--EdkNt32Pkg/EdkNt32Pkg.spd1
-rw-r--r--EdkNt32Pkg/Library/Nt32PeCoffLoaderLib/Nt32PeCoffLoaderLib.msa4
-rw-r--r--EdkNt32Pkg/Nt32.fpd24
-rw-r--r--Tools/Conf/BuildMacro.xml2
-rw-r--r--Tools/Source/GenBuild/GenBuild.tasks8
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/FileProcess.java1
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java19
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java3816
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java34
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/exception/GenBuildException.java4
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java4
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java20
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java125
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/global/Spd.java38
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java106
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java166
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java223
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/pcd/action/ShowPCDDatabaseAction.java2
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java21
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java2
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java2
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainKey.java2
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java2
23 files changed, 2528 insertions, 2098 deletions
diff --git a/EdkNt32Pkg/EdkNt32Pkg.spd b/EdkNt32Pkg/EdkNt32Pkg.spd
index bdf264d..532ecea 100644
--- a/EdkNt32Pkg/EdkNt32Pkg.spd
+++ b/EdkNt32Pkg/EdkNt32Pkg.spd
@@ -70,6 +70,7 @@
<IncludePkgHeader ModuleType="DXE_SMM_DRIVER">Include/WinNtDxe.h</IncludePkgHeader>
<IncludePkgHeader ModuleType="DXE_SAL_DRIVER">Include/WinNtDxe.h</IncludePkgHeader>
<IncludePkgHeader ModuleType="UEFI_DRIVER">Include/WinNtDxe.h</IncludePkgHeader>
+ <IncludePkgHeader ModuleType="USER_DEFINED">Include/WinNtPeim.h</IncludePkgHeader>
</PackageHeaders>
<GuidDeclarations>
<Entry Name="WinNtVirtualDisks">
diff --git a/EdkNt32Pkg/Library/Nt32PeCoffLoaderLib/Nt32PeCoffLoaderLib.msa b/EdkNt32Pkg/Library/Nt32PeCoffLoaderLib/Nt32PeCoffLoaderLib.msa
index 3b3c5ee..e09d161 100644
--- a/EdkNt32Pkg/Library/Nt32PeCoffLoaderLib/Nt32PeCoffLoaderLib.msa
+++ b/EdkNt32Pkg/Library/Nt32PeCoffLoaderLib/Nt32PeCoffLoaderLib.msa
@@ -35,9 +35,9 @@
<Package PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3"/>
</PackageDependencies>
<PPIs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <Ppi Usage="ALWAYS_CONSUMED">
+ <!--<Ppi Usage="ALWAYS_CONSUMED">
<PpiCName>PeCoffLoader</PpiCName>
- </Ppi>
+ </Ppi>-->
</PPIs>
<Externs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
diff --git a/EdkNt32Pkg/Nt32.fpd b/EdkNt32Pkg/Nt32.fpd
index f1ed57c..448beb5 100644
--- a/EdkNt32Pkg/Nt32.fpd
+++ b/EdkNt32Pkg/Nt32.fpd
@@ -5733,14 +5733,6 @@
<MaxDatumSize>4</MaxDatumSize>
<Value>0x5678</Value>
</PcdData>
- <PcdData ItemType="DYNAMIC">
- <C_Name>PcdWinNtDynamicUINT32</C_Name>
- <Token>0x0001000e</Token>
- <TokenSpaceGuidCName>Fix_Me</TokenSpaceGuidCName>
- <DatumType>UINT32</DatumType>
- <MaxDatumSize>4</MaxDatumSize>
- <Value>0x0</Value>
- </PcdData>
</PcdBuildDefinition>
<ModuleSaBuildOptions>
<FvBinding>FV_RECOVERY</FvBinding>
@@ -6576,17 +6568,6 @@
</SkuInfo>
</PcdBuildData>
<PcdBuildData ItemType="DYNAMIC">
- <C_Name>PcdWinNtDynamicUINT32</C_Name>
- <Token>0x0001000e</Token>
- <TokenSpaceGuidCName>Fix_Me</TokenSpaceGuidCName>
- <DatumType>UINT32</DatumType>
- <MaxDatumSize>4</MaxDatumSize>
- <SkuInfo>
- <SkuId>0</SkuId>
- <Value>0x0</Value>
- </SkuInfo>
- </PcdBuildData>
- <PcdBuildData ItemType="DYNAMIC">
<C_Name>PcdKentTestDynamicUINT32</C_Name>
<Token>0x0001000e</Token>
<TokenSpaceGuidCName>Fix_Me</TokenSpaceGuidCName>
@@ -6594,10 +6575,7 @@
<MaxDatumSize>4</MaxDatumSize>
<SkuInfo>
<SkuId>0</SkuId>
- <VariableName>0x0062 0x006F 0x006F 0x0074 0x006D 0x006F 0x0064 0x0065</VariableName>
- <VariableGuid>WinNPassThrough</VariableGuid>
- <VariableOffset>0x123</VariableOffset>
- <HiiDefaultValue>0x123</HiiDefaultValue>
+ <Value>0x2</Value>
</SkuInfo>
</PcdBuildData>
</DynamicPcdBuildDefinitions>
diff --git a/Tools/Conf/BuildMacro.xml b/Tools/Conf/BuildMacro.xml
index 7904180..3c20e60 100644
--- a/Tools/Conf/BuildMacro.xml
+++ b/Tools/Conf/BuildMacro.xml
@@ -493,7 +493,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
</targetfiles>
<sequential>
- <vfrcompile createIfrBinFile="on" createListFile="on" outPutDir="${DEST_DIR_DEBUG}" vfrFile="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}">
+ <vfrcompile createIfrBinFile="on" createListFile="on" outPutDir="${DEST_DIR_DEBUG}/@{FILEPATH}" vfrFile="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}">
<EXTRA.INC/>
</vfrcompile>
diff --git a/Tools/Source/GenBuild/GenBuild.tasks b/Tools/Source/GenBuild/GenBuild.tasks
index c767cfb..4d812e6 100644
--- a/Tools/Source/GenBuild/GenBuild.tasks
+++ b/Tools/Source/GenBuild/GenBuild.tasks
@@ -1,11 +1,11 @@
FPDParser = org.tianocore.build.fpd.FpdParserTask
bl = org.tianocore.build.global.VariableTask
-bf = org.tianocore.build.global.LibBuildFileGenerator
GenBuild = org.tianocore.build.GenBuildTask
-ToolChainSetup = org.tianocore.build.toolchain.ToolChainTask
-Expand = org.tianocore.build.ExpandTask
-OutputDirSetup = org.tianocore.build.OutputDirSetupTask
+FrameworkBuild = org.tianocore.build.FrameworkBuildTask
OnDependency = org.tianocore.build.global.OnDependency
+ToolChainSetup = org.tianocore.build.toolchain.ToolChainTask
+OutputDirSetup = org.tianocore.build.OutputDirSetup
sourcefiles = org.tianocore.build.global.DpFileList
targetfiles = org.tianocore.build.global.DpFileList
file = org.tianocore.build.global.DpFile
+DefaultBuildFileGenerator = org.tianocore.build.tools.DefaultBuildFileGenerator
diff --git a/Tools/Source/GenBuild/org/tianocore/build/FileProcess.java b/Tools/Source/GenBuild/org/tianocore/build/FileProcess.java
index e615802..e0a0fff 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/FileProcess.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/FileProcess.java
@@ -64,6 +64,7 @@ public class FileProcess {
{".s", "", "ASM" },
{".uni", "", "UNI" },
{".vfr", "", "VFR" },
+ {".Vfr", "", "VFR" },
{".dxs", "", "DPX"},
{".fv", "", "FV" },
{".efi", "", "EFI" },
diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
index 0e807f8..9eb509b 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
@@ -32,8 +32,9 @@ import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.taskdefs.Property;
import org.apache.xmlbeans.XmlObject;
-import org.tianocore.build.exception.EdkException;
+import org.tianocore.build.autogen.AutoGen;
import org.tianocore.build.fpd.FpdParserTask;
+import org.tianocore.build.global.GenBuildLogger;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.OutputManager;
import org.tianocore.build.global.SurfaceAreaQuery;
@@ -42,6 +43,8 @@ import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification;
import org.tianocore.build.id.PlatformIdentification;
import org.tianocore.build.tools.ModuleItem;
+import org.tianocore.exception.EdkException;
+import org.tianocore.logger.EdkLog;
/**
<p>
@@ -115,7 +118,14 @@ public class GenBuildTask extends Ant {
From module build, exception from module surface area invalid.
**/
public void execute() throws BuildException {
- try{
+ //
+ // set Logger
+ //
+ GenBuildLogger logger = new GenBuildLogger(getProject());
+ EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
+ EdkLog.setLogger(logger);
+ // remove !!
+ try {
pushProperties();
//
// Enable all specified properties
@@ -524,8 +534,9 @@ public class GenBuildTask extends Ant {
//
// AutoGen
//
-// AutoGen autogen = new AutoGen(getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId);
-// autogen.genAutogen();
+
+ AutoGen autogen = new AutoGen(getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch());
+ autogen.genAutogen();
//
diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
index 9587554..7de80e6 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
@@ -26,8 +26,9 @@ import org.tianocore.GuidsDocument;
import org.tianocore.LibraryClassDocument.LibraryClass;
import org.tianocore.PPIsDocument;
import org.tianocore.ProtocolsDocument;
-//import org.tianocore.build.pcd.action.PCDAutoGenAction;
+import org.tianocore.build.pcd.action.PCDAutoGenAction;
import org.tianocore.build.exception.*;
+import org.tianocore.logger.EdkLog;
import org.apache.tools.ant.BuildException;
import org.apache.xmlbeans.XmlObject;
@@ -37,6 +38,7 @@ import java.io.FileWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -46,812 +48,889 @@ import java.util.Set;
* area or library surface area.
*/
public class AutoGen {
- // /
- // / The output path of Autogen.h and Autogen.c
- // /
- private String outputPath;
-
- // /
- // / The base name of module or library.
- // /
- private ModuleIdentification moduleId;
-
- // /
- // / The build architecture
- // /
- private String arch;
-
- // /
- // / PcdAutogen instance which is used to manage how to generate the PCD
- // / information.
- // /
-// private PCDAutoGenAction myPcdAutogen;
-
- // /
- // / The protocl list which records in module or library surface area and
- // / it's dependence on library instance surface area.
- // /
- private Set<String> mProtocolList = new HashSet<String>();
-
- // /
- // / The Ppi list which recorded in module or library surface area and its
- // / dependency on library instance surface area.
- // /
- private Set<String> mPpiList = new HashSet<String>();
-
- // /
- // / The Guid list which recoreded in module or library surface are and it's
- // / dependence on library instance surface area.
- // /
- private Set<String> mGuidList = new HashSet<String>();
-
- /**
- * Construct function
- *
- * This function mainly initialize some member variable.
- *
- * @param outputPath
- * Output path of AutoGen file.
- * @param baseName
- * Module base name.
- * @param arch
- * Target architecture.
- */
- public AutoGen(String outputPath, ModuleIdentification moduleId, String arch) {
- this.outputPath = outputPath;
- this.moduleId = moduleId;
- this.arch = arch;
-
- }
-
- /**
- * saveFile function
- *
- * This function save the content in stringBuffer to file.
- *
- * @param fileName
- * The name of file.
- * @param fileBuffer
- * The content of AutoGen file in buffer.
- * @return "true" successful, "false" failed.
- */
- private boolean saveFile(String fileName, StringBuffer fileBuffer) {
- try {
- File autoGenH = new File(fileName);
-
- //
- // if the file exists, compare their content
- //
- if (autoGenH.exists()) {
- FileReader fIn = new FileReader(autoGenH);
- char[] oldFileBuffer = new char[(int) autoGenH.length()];
- fIn.read(oldFileBuffer, 0, (int) autoGenH.length());
- fIn.close();
-
- //
- // if we got the same file, don't re-generate it to prevent
- // sources depending on it from re-building
- //
- if (fileBuffer.toString().compareTo(new String(oldFileBuffer)) == 0) {
- return true;
- }
- }
- FileWriter fOut = new FileWriter(autoGenH);
- fOut.write(fileBuffer.toString());
- fOut.close();
- } catch (Exception e) {
- return false;
- }
- return true;
- }
-
- /**
- * genAutogen function
- *
- * This function call libGenAutoGen or moduleGenAutogen function, which
- * dependence on generate library autogen or module autogen.
- *
- * @throws BuildException
- * Failed to creat AutoGen.c & AutoGen.h.
- */
- public void genAutogen() throws BuildException {
- try {
- //
- // If outputPath do not exist, create it.
- //
- File path = new File(outputPath);
- path.mkdirs();
-
- //
- // Check current is library or not, then call the corresponding
- // function.
- //
- if (this.moduleId.isLibrary()) {
- libGenAutogen();
- } else {
- moduleGenAutogen();
- }
-
- } catch (Exception e) {
- throw new BuildException(
- "Failed to create AutoGen.c & AutoGen.h!\n"
- + e.getMessage());
- }
- }
-
- /**
- * moduleGenAutogen function
- *
- * This function generates AutoGen.c & AutoGen.h for module.
- *
- * @throws BuildException
- * Faile to create module AutoGen.c & AutoGen.h.
- */
- void moduleGenAutogen() throws BuildException {
-
- try {
- moduleGenAutogenC();
- moduleGenAutogenH();
- } catch (Exception e) {
- throw new BuildException(
- "Faile to create module AutoGen.c & AutoGen.h!\n"
- + e.getMessage());
- }
- }
-
- /**
- * libGenAutogen function
- *
- * This function generates AutoGen.c & AutoGen.h for library.
- *
- * @throws BuildException
- * Faile to create library AutoGen.c & AutoGen.h
- */
- void libGenAutogen() throws BuildException {
- try {
- libGenAutogenC();
- libGenAutogenH();
- } catch (Exception e) {
- throw new BuildException(
- "Faile to create library AutoGen.c & AutoGen.h!\n"
- + e.getMessage());
- }
- }
-
- /**
- * moduleGenAutogenH
- *
- * This function generates AutoGen.h for module.
- *
- * @throws BuildException
- * Failed to generate AutoGen.h.
- */
- void moduleGenAutogenH() throws AutoGenException {
-
- Set<String> libClassIncludeH;
- String moduleType;
- // List<String> headerFileList;
- Set<String> headerFileList;
- Iterator item;
- StringBuffer fileBuffer = new StringBuffer(8192);
-
- //
- // Write Autogen.h header notation
- //
- fileBuffer.append(CommonDefinition.autogenHNotation);
-
- //
- // Add #ifndef ${BaseName}_AUTOGENH
- // #def ${BseeName}_AUTOGENH
- //
- fileBuffer.append("#ifndef " + this.moduleId.getName().toUpperCase()
- + "_AUTOGENH\r\n");
- fileBuffer.append("#define " + this.moduleId.getName().toUpperCase()
- + "_AUTOGENH\r\n\r\n");
-
- //
- // Write the specification version and release version at the begine
- // of autogen.h file.
- // Note: the specification version and release version should
- // be got from module surface area instead of hard code by it's
- // moduleType.
- //
- moduleType = SurfaceAreaQuery.getModuleType();
- switch (CommonDefinition.getModuleType(moduleType)) {
- case CommonDefinition.ModuleTypeDxeCore:
- case CommonDefinition.ModuleTypeDxeDriver:
- case CommonDefinition.ModuleTypeDxeRuntimeDriver:
- case CommonDefinition.ModuleTypeDxeSmmDriver:
- case CommonDefinition.ModuleTypeDxeSalDriver:
- case CommonDefinition.ModuleTypeUefiDriver:
- case CommonDefinition.ModuleTypeUefiApplication:
- fileBuffer.append(CommonDefinition.autoGenHLine1);
- break;
- default:
- fileBuffer.append(CommonDefinition.autoGenHVersionDefault);
- break;
- }
- switch (CommonDefinition.getModuleType(moduleType)) {
- case CommonDefinition.ModuleTypeUefiDriver:
- case CommonDefinition.ModuleTypeUefiApplication:
- fileBuffer.append(CommonDefinition.autoGenHReleaseDefault);
- break;
- default:
- fileBuffer.append(CommonDefinition.autoGenHLine2);
- break;
- }
-
- //
- // Add "extern int __make_me_compile_correctly;" at begin of
- // AutoGen.h.
- //
- fileBuffer.append(CommonDefinition.autoGenHbegin);
-
- //
- // Write consumed package's mdouleInfo related .h file to autogen.h
- //
-// PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
-// .getDependencePkg(this.arch);
- PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery.getDependencePkg(null);
- if (consumedPkgIdList != null) {
- headerFileList = depPkgToAutogenH(consumedPkgIdList, moduleType);
- item = headerFileList.iterator();
- while (item.hasNext()){
- fileBuffer.append(item.next().toString());
- }
- }
-
- //
- // Write library class's related *.h file to autogen.h.
- //
- String[] libClassList = SurfaceAreaQuery
- .getLibraryClasses(CommonDefinition.AlwaysConsumed);
- if (libClassList != null) {
- libClassIncludeH = LibraryClassToAutogenH(libClassList);
- item = libClassIncludeH.iterator();
- while (item.hasNext()){
- fileBuffer.append(item.next().toString());
- }
- }
-
- libClassList = SurfaceAreaQuery
- .getLibraryClasses(CommonDefinition.AlwaysProduced);
- if (libClassList != null) {
- libClassIncludeH = LibraryClassToAutogenH(libClassList);
- item = libClassIncludeH.iterator();
- while (item.hasNext()){
- fileBuffer.append(item.next().toString());
- }
- }
- fileBuffer.append("\r\n");
-
- //
- // Write PCD autogen information to AutoGen.h.
- //
-// if (this.myPcdAutogen != null) {
-// fileBuffer.append(this.myPcdAutogen.OutputH());
-// }
-
- //
- // Append the #endif at AutoGen.h
- //
- fileBuffer.append("#endif\r\n");
-
- //
- // Save string buffer content in AutoGen.h.
- //
- if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {
- throw new BuildException("Failed to generate AutoGen.h !!!");
- }
- }
-
- /**
- * moduleGenAutogenC
- *
- * This function generates AutoGen.c for module.
- *
- * @throws BuildException
- * Failed to generate AutoGen.c.
- */
- void moduleGenAutogenC() throws AutoGenException {
-
- StringBuffer fileBuffer = new StringBuffer(8192);
- //
- // Write Autogen.c header notation
- //
- fileBuffer.append(CommonDefinition.autogenCNotation);
-
- //
- // Write #include <AutoGen.h> at beginning of AutoGen.c
- //
- fileBuffer.append(CommonDefinition.includeAutogenH);
-
- //
- // Get the native MSA file infomation. Since before call autogen,
- // the MSA native <Externs> information were overrided. So before
- // process <Externs> it should be set the DOC as the Native MSA info.
- //
- Map<String, XmlObject> doc = GlobalData.getNativeMsa(this.moduleId);
- SurfaceAreaQuery.push(doc);
- //
- // Write <Extern> DriverBinding/ComponentName/DriverConfiguration/DriverDialog
- // to AutoGen.c
- //
-
- ExternsDriverBindingToAutoGenC(fileBuffer);
-
- //
- // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
- // to Autogen.c
+ // /
+ // / The output path of Autogen.h and Autogen.c
+ // /
+ private String outputPath;
+
+ // /
+ // / The base name of module or library.
+ // /
+ private ModuleIdentification moduleId;
+
+ // /
+ // / The build architecture
+ // /
+ private String arch;
+
+ // /
+ // / PcdAutogen instance which is used to manage how to generate the PCD
+ // / information.
+ // /
+ private PCDAutoGenAction myPcdAutogen;
+
+ // /
+ // / The protocl list which records in module or library surface area and
+ // / it's dependence on library instance surface area.
+ // /
+ private Set<String> mProtocolList = new HashSet<String>();
+
+ // /
+ // / The Ppi list which recorded in module or library surface area and its
+ // / dependency on library instance surface area.
+ // /
+ private Set<String> mPpiList = new HashSet<String>();
+
+ // /
+ // / The Guid list which recoreded in module or library surface area and it's
+ // / dependence on library instance surface area.
+ // /
+ private Set<String> mGuidList = new HashSet<String>();
+
+ //
+ // The dependence package list which recoreded in module or library surface
+ // area and it's dependence on library instance surface are.
+ //
+ private List<PackageIdentification> mDepPkgList = new LinkedList<PackageIdentification>();
+ /**
+ * Construct function
+ *
+ * This function mainly initialize some member variable.
+ *
+ * @param outputPath
+ * Output path of AutoGen file.
+ * @param baseName
+ * Module base name.
+ * @param arch
+ * Target architecture.
+ */
+ public AutoGen(String outputPath, ModuleIdentification moduleId, String arch) {
+ this.outputPath = outputPath;
+ this.moduleId = moduleId;
+ this.arch = arch;
+
+ }
+
+ /**
+ * saveFile function
+ *
+ * This function save the content in stringBuffer to file.
+ *
+ * @param fileName
+ * The name of file.
+ * @param fileBuffer
+ * The content of AutoGen file in buffer.
+ * @return "true" successful, "false" failed.
+ */
+ private boolean saveFile(String fileName, StringBuffer fileBuffer) {
+ try {
+ File autoGenH = new File(fileName);
+
+ //
+ // if the file exists, compare their content
+ //
+ if (autoGenH.exists()) {
+ FileReader fIn = new FileReader(autoGenH);
+ char[] oldFileBuffer = new char[(int) autoGenH.length()];
+ fIn.read(oldFileBuffer, 0, (int) autoGenH.length());
+ fIn.close();
+
+ //
+ // if we got the same file, don't re-generate it to prevent
+ // sources depending on it from re-building
+ //
+ if (fileBuffer.toString().compareTo(new String(oldFileBuffer)) == 0) {
+ return true;
+ }
+ }
+ FileWriter fOut = new FileWriter(autoGenH);
+ fOut.write(fileBuffer.toString());
+ fOut.close();
+ } catch (Exception e) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * genAutogen function
+ *
+ * This function call libGenAutoGen or moduleGenAutogen function, which
+ * dependence on generate library autogen or module autogen.
+ *
+ * @throws BuildException
+ * Failed to creat AutoGen.c & AutoGen.h.
+ */
+ public void genAutogen() throws BuildException {
+ try {
+ //
+ // If outputPath do not exist, create it.
+ //
+ File path = new File(outputPath);
+ path.mkdirs();
+
+ //
+ // Check current is library or not, then call the corresponding
+ // function.
+ //
+ if (this.moduleId.isLibrary()) {
+ libGenAutogen();
+ } else {
+ moduleGenAutogen();
+ }
+
+ } catch (Exception e) {
+ throw new BuildException(
+ "Failed to create AutoGen.c & AutoGen.h!\n"
+ + e.getMessage());
+ }
+ }
+
+ /**
+ * moduleGenAutogen function
+ *
+ * This function generates AutoGen.c & AutoGen.h for module.
+ *
+ * @throws BuildException
+ * Faile to create module AutoGen.c & AutoGen.h.
+ */
+ void moduleGenAutogen() throws BuildException {
+
+ try {
+ moduleGenAutogenC();
+ moduleGenAutogenH();
+ } catch (Exception e) {
+ throw new BuildException(
+ "Faile to create module AutoGen.c & AutoGen.h!\n"
+ + e.getMessage());
+ }
+ }
+
+ /**
+ * libGenAutogen function
+ *
+ * This function generates AutoGen.c & AutoGen.h for library.
+ *
+ * @throws BuildException
+ * Faile to create library AutoGen.c & AutoGen.h
+ */
+ void libGenAutogen() throws BuildException {
+ try {
+ libGenAutogenC();
+ libGenAutogenH();
+ } catch (Exception e) {
+ throw new BuildException(
+ "Faile to create library AutoGen.c & AutoGen.h!\n"
+ + e.getMessage());
+ }
+ }
+
+ /**
+ * moduleGenAutogenH
+ *
+ * This function generates AutoGen.h for module.
+ *
+ * @throws BuildException
+ * Failed to generate AutoGen.h.
+ */
+ void moduleGenAutogenH() throws AutoGenException {
+
+ Set<String> libClassIncludeH;
+ String moduleType;
+ // List<String> headerFileList;
+ List<String> headerFileList;
+ Iterator item;
+ StringBuffer fileBuffer = new StringBuffer(8192);
+
+ //
+ // Write Autogen.h header notation
+ //
+ fileBuffer.append(CommonDefinition.autogenHNotation);
+
+ //
+ // Add #ifndef ${BaseName}_AUTOGENH
+ // #def ${BseeName}_AUTOGENH
+ //
+ fileBuffer.append("#ifndef " + this.moduleId.getName().toUpperCase()
+ + "_AUTOGENH\r\n");
+ fileBuffer.append("#define " + this.moduleId.getName().toUpperCase()
+ + "_AUTOGENH\r\n\r\n");
+
+ //
+ // Write the specification version and release version at the begine
+ // of autogen.h file.
+ // Note: the specification version and release version should
+ // be got from module surface area instead of hard code by it's
+ // moduleType.
+ //
+ moduleType = SurfaceAreaQuery.getModuleType();
+// switch (CommonDefinition.getModuleType(moduleType)) {
+// case CommonDefinition.ModuleTypeDxeCore:
+// case CommonDefinition.ModuleTypeDxeDriver:
+// case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+// case CommonDefinition.ModuleTypeDxeSmmDriver:
+// case CommonDefinition.ModuleTypeDxeSalDriver:
+// case CommonDefinition.ModuleTypeUefiDriver:
+// case CommonDefinition.ModuleTypeUefiApplication:
+// fileBuffer.append(CommonDefinition.autoGenHLine1);
+// break;
+// default:
+// fileBuffer.append(CommonDefinition.autoGenHVersionDefault);
+// break;
+// }
+// switch (CommonDefinition.getModuleType(moduleType)) {
+// case CommonDefinition.ModuleTypeUefiDriver:
+// case CommonDefinition.ModuleTypeUefiApplication:
+// fileBuffer.append(CommonDefinition.autoGenHReleaseDefault);
+// break;
+// default:
+// fileBuffer.append(CommonDefinition.autoGenHLine2);
+// break;
+// }
+
+ //
+ // Add "extern int __make_me_compile_correctly;" at begin of
+ // AutoGen.h.
+ //
+ fileBuffer.append(CommonDefinition.autoGenHbegin);
+
+ //
+ // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
//
- ExternCallBackToAutoGenC(fileBuffer);
-
- //
- // Write EntryPoint to autgoGen.c
- //
- String[] entryPointList = SurfaceAreaQuery.getModuleEntryPointArray();
- if (entryPointList != null) {
- EntryPointToAutoGen(entryPointList, fileBuffer);
- }
-
- //
- // Restore the DOC which include the FPD module info.
- //
- SurfaceAreaQuery.pop();
-
- //
- // Write Guid to autogen.c
- //
- String guid = CommonDefinition.formatGuidName(SurfaceAreaQuery.getModuleGuid());
-
- fileBuffer
- .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
- if (guid == null) {
- throw new AutoGenException("Guid value must set!\n");
- }
-
- //
- // Formate Guid as ANSI c form.Example:
- // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
- // 0xf0}}
- //
-
- fileBuffer.append(guid);
- fileBuffer.append("};\r\n");
-
- //
- // Generate library instance consumed protocol, guid, ppi, pcd list.
- // Save those to this.protocolList, this.ppiList, this.pcdList,
- // this.guidList. Write Consumed library constructor and desconstuct to
- // autogen.c
- //
- LibInstanceToAutogenC(fileBuffer);
-
- //
- // Write consumed ppi, guid, protocol to autogen.c
- //
- ProtocolGuidToAutogenC(fileBuffer);
- PpiGuidToAutogenC(fileBuffer);
- GuidGuidToAutogenC(fileBuffer);
-
- //
- // Call pcd autogen. PCDAutoGenAction tool only need module name and
- // isPcdEmulatedDriver as parameter. Library inherits PCD and module's
- // PCD information has been collected in FPDParser task by
- // CollectPCDAction.
- // Note : when PCD image tool ready,
- // isPCDEmulatedDriver parameter will be removed.
- //
-// try {
-// this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),
-// moduleId.getName().equalsIgnoreCase("PcdEmulatorPeim"));
-// this.myPcdAutogen.execute();
-// } catch (Exception e) {
-// throw new BuildException("PCD Autogen failed:" + e.getMessage());
-// }
-//
-// if (this.myPcdAutogen != null) {
-// fileBuffer.append(this.myPcdAutogen.OutputC());
-// }
-
- if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {
- throw new BuildException("Failed to generate AutoGen.c !!!");
- }
-
- }
-
- /**
- * libGenAutogenH
- *
- * This function generates AutoGen.h for library.
- *
- * @throws BuildException
- * Failed to generate AutoGen.c.
- */
- void libGenAutogenH() throws AutoGenException {
-
- Set<String> libClassIncludeH;
- String moduleType;
- Set<String> headerFileList;
- Iterator item;
- StringBuffer fileBuffer = new StringBuffer(10240);
-
- //
- // Write Autogen.h header notation
- //
- fileBuffer.append(CommonDefinition.autogenHNotation);
-
- //
- // Add #ifndef ${BaseName}_AUTOGENH
- // #def ${BseeName}_AUTOGENH
- //
- fileBuffer.append("#ifndef " + this.moduleId.getName().toUpperCase()
- + "_AUTOGENH\r\n");
- fileBuffer.append("#define " + this.moduleId.getName().toUpperCase()
- + "_AUTOGENH\r\n\r\n");
-
- //
- // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
- // to autogen.h file.
- // Note: the specification version and release version should
- // be get from module surface area instead of hard code.
- //
- fileBuffer.append(CommonDefinition.autoGenHbegin);
String[] specList = SurfaceAreaQuery.getExternSpecificaiton();
- for (int i = 0; i < specList.length; i++){
- fileBuffer.append(CommonDefinition.marcDefineStr + specList[i] + "\r\n");
- }
-// fileBuffer.append(CommonDefinition.autoGenHLine1);
-// fileBuffer.append(CommonDefinition.autoGenHLine2);
-
- //
- // Write consumed package's mdouleInfo related *.h file to autogen.h.
- //
- moduleType = SurfaceAreaQuery.getModuleType();
- PackageIdentification[] cosumedPkglist = SurfaceAreaQuery
- .getDependencePkg(this.arch);
- headerFileList = depPkgToAutogenH(cosumedPkglist, moduleType);
- item = headerFileList.iterator();
- while (item.hasNext()){
- fileBuffer.append(item.next().toString());
+ for (int i = 0; i < specList.length; i++) {
+ fileBuffer.append(CommonDefinition.marcDefineStr + specList[i]
+ + "\r\n");
}
+ //
+ // Write consumed package's mdouleInfo related .h file to autogen.h
+ //
+ // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
+ // .getDependencePkg(this.arch);
+ PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
+ .getDependencePkg(null);
+ if (consumedPkgIdList != null) {
+ headerFileList = depPkgToAutogenH(consumedPkgIdList, moduleType);
+ item = headerFileList.iterator();
+ while (item.hasNext()) {
+ fileBuffer.append(item.next().toString());
+ }
+ }
+
+ //
+ // Write library class's related *.h file to autogen.h.
+ //
+ String[] libClassList = SurfaceAreaQuery
+ .getLibraryClasses(CommonDefinition.AlwaysConsumed);
+ if (libClassList != null) {
+ libClassIncludeH = LibraryClassToAutogenH(libClassList);
+ item = libClassIncludeH.iterator();
+ while (item.hasNext()) {
+ fileBuffer.append(item.next().toString());
+ }
+ }
+
+ libClassList = SurfaceAreaQuery
+ .getLibraryClasses(CommonDefinition.AlwaysProduced);
+ if (libClassList != null) {
+ libClassIncludeH = LibraryClassToAutogenH(libClassList);
+ item = libClassIncludeH.iterator();
+ while (item.hasNext()) {
+ fileBuffer.append(item.next().toString());
+ }
+ }
+ fileBuffer.append("\r\n");
+
+ //
+ // Write PCD autogen information to AutoGen.h.
+ //
+ if (this.myPcdAutogen != null) {
+ fileBuffer.append("\r\n");
+ fileBuffer.append(this.myPcdAutogen.OutputH());
+ }
+
+ //
+ // Append the #endif at AutoGen.h
+ //
+ fileBuffer.append("#endif\r\n");
+
+ //
+ // Save string buffer content in AutoGen.h.
+ //
+ if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {
+ throw new BuildException("Failed to generate AutoGen.h !!!");
+ }
+ }
+
+ /**
+ * moduleGenAutogenC
+ *
+ * This function generates AutoGen.c for module.
+ *
+ * @throws BuildException
+ * Failed to generate AutoGen.c.
+ */
+ void moduleGenAutogenC() throws AutoGenException {
+
+ StringBuffer fileBuffer = new StringBuffer(8192);
+ //
+ // Write Autogen.c header notation
+ //
+ fileBuffer.append(CommonDefinition.autogenCNotation);
+
+ //
+ // Write #include <AutoGen.h> at beginning of AutoGen.c
+ //
+ fileBuffer.append(CommonDefinition.includeAutogenH);
+
+ //
+ // Get the native MSA file infomation. Since before call autogen,
+ // the MSA native <Externs> information were overrided. So before
+ // process <Externs> it should be set the DOC as the Native MSA info.
+ //
+ Map<String, XmlObject> doc = GlobalData.getNativeMsa(this.moduleId);
+ SurfaceAreaQuery.push(doc);
+ //
+ // Write <Extern>
+ // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
+ // to AutoGen.c
+ //
+
+ ExternsDriverBindingToAutoGenC(fileBuffer);
+
+ //
+ // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
+ // to Autogen.c
+ //
+ ExternCallBackToAutoGenC(fileBuffer);
+
+ //
+ // Write EntryPoint to autgoGen.c
+ //
+ String[] entryPointList = SurfaceAreaQuery.getModuleEntryPointArray();
+ EntryPointToAutoGen(CommonDefinition.remDupString(entryPointList), fileBuffer);
+
+
+ //
+ // Restore the DOC which include the FPD module info.
+ //
+ SurfaceAreaQuery.pop();
+
+ //
+ // Write Guid to autogen.c
+ //
+ String guid = CommonDefinition.formatGuidName(SurfaceAreaQuery
+ .getModuleGuid());
+
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
+ if (guid == null) {
+ throw new AutoGenException("Guid value must set!\n");
+ }
+
+ //
+ // Formate Guid as ANSI c form.Example:
+ // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
+ // 0xf0}}
+ //
+
+ fileBuffer.append(guid);
+ fileBuffer.append("};\r\n");
+
+ //
+ // Generate library instance consumed protocol, guid, ppi, pcd list.
+ // Save those to this.protocolList, this.ppiList, this.pcdList,
+ // this.guidList. Write Consumed library constructor and desconstuct to
+ // autogen.c
+ //
+ LibInstanceToAutogenC(fileBuffer);
+
//
- // Write library class's related *.h file to autogen.h
+ // Get module dependent Package identification.
//
- String[] libClassList = SurfaceAreaQuery
- .getLibraryClasses(CommonDefinition.AlwaysConsumed);
- if (libClassList != null) {
- libClassIncludeH = LibraryClassToAutogenH(libClassList);
- item = libClassIncludeH.iterator();
- while (item.hasNext()){
- fileBuffer.append(item.next().toString());
- }
- }
-
- libClassList = SurfaceAreaQuery
- .getLibraryClasses(CommonDefinition.AlwaysProduced);
- if (libClassList != null) {
- libClassIncludeH = LibraryClassToAutogenH(libClassList);
- item = libClassIncludeH.iterator();
- while (item.hasNext()){
- fileBuffer.append(item.next().toString());
+ PackageIdentification[] packages = SurfaceAreaQuery.getDependencePkg(this.arch);
+ for (int i = 0; i < packages.length; i++){
+ if (!this.mDepPkgList.contains(packages[i])){
+ this.mDepPkgList.add(packages[i]);
}
+
}
- fileBuffer.append("\r\n");
-
- //
- // Write PCD information to library AutoGen.h.
- //
-// if (this.myPcdAutogen != null) {
-// fileBuffer.append(this.myPcdAutogen.OutputH());
-// }
-
- //
- // Append the #endif at AutoGen.h
- //
- fileBuffer.append("#endif\r\n");
-
- //
- // Save content of string buffer to AutoGen.h file.
- //
- if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {
- throw new BuildException("Failed to generate AutoGen.h !!!");
- }
- }
-
- /**
- * libGenAutogenC
- *
- * This function generates AutoGen.h for library.
- *
- * @throws BuildException
- * Failed to generate AutoGen.c.
- */
- void libGenAutogenC() throws BuildException {
- StringBuffer fileBuffer = new StringBuffer(10240);
-
- //
- // Write Autogen.c header notation
- //
- fileBuffer.append(CommonDefinition.autogenCNotation);
-
- fileBuffer.append(CommonDefinition.autoGenCLine1);
- fileBuffer.append("\r\n");
-
- //
- // Call pcd autogen. PCDAutoGenAction tool only need module name and
- // isPcdEmulatedDriver as parameter. Library inherit PCD and module's
- // PCD information has been collected in FPDParser task by
- // CollectPCDAction.
- // Note : when PCD image tool ready,
- // isPCDEmulatedDriver parameter will be removed.
- //
- try {
-// this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),
-// this.moduleId.getName().equalsIgnoreCase("PcdEmulatorPeim"));
-// this.myPcdAutogen.execute();
-// this.myPcdAutogen = new PCDAutoGenAction(this.moduleId,);
- } catch (Exception e) {
- throw new BuildException(e.getMessage());
- }
-
-// if (this.myPcdAutogen != null) {
-// fileBuffer.append(this.myPcdAutogen.OutputC());
-// }
-
- if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {
- throw new BuildException("Failed to generate AutoGen.c !!!");
- }
- }
-
- /**
- * LibraryClassToAutogenH
- *
- * This function returns *.h files declared by library classes which are
- * consumed or produced by current build module or library.
- *
- * @param libClassList
- * List of library class which consumed or produce by current
- * build module or library.
- * @return includeStrList List of *.h file.
- */
- Set<String> LibraryClassToAutogenH(String[] libClassList) throws AutoGenException{
- Set<String> includStrList = new HashSet<String>();
- String includerName[];
- String str = "";
-
- //
- // Get include file from GlobalData's SPDTable according to
- // library class name.
- //
-
- for (int i = 0; i < libClassList.length; i++) {
- includerName = GlobalData.getLibraryClassHeaderFiles(
- SurfaceAreaQuery.getDependencePkg(this.arch),
- libClassList[i]);
- if (includerName == null){
- throw new AutoGenException("Can not find library class [" + libClassList[i] + "] declaration in every packages. ");
- }
- for (int j = 0; j < includerName.length; j++) {
- String includeNameStr = includerName[j];
- if (includeNameStr != null) {
- str = CommonDefinition.include + " " + "<";
- str = str + includeNameStr + ">\r\n";
- includStrList.add(str);
- includeNameStr = null;
+
+ //
+ // Write consumed ppi, guid, protocol to autogen.c
+ //
+ ProtocolGuidToAutogenC(fileBuffer);
+ PpiGuidToAutogenC(fileBuffer);
+ GuidGuidToAutogenC(fileBuffer);
+
+ //
+ // Call pcd autogen. PCDAutoGenAction tool only need module name and
+ // isPcdEmulatedDriver as parameter. Library inherits PCD and module's
+ // PCD information has been collected in FPDParser task by
+ // CollectPCDAction.
+ // Note : when PCD image tool ready,
+ // isPCDEmulatedDriver parameter will be removed.
+ //
+ try {
+// this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),
+// moduleId.getGuid(), moduleId.getPackage().getName(), moduleId.getPackage().getGuid(),this.arch,moduleId.getVersion(),false, null);
+ this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),null,null,null, this.arch,null,false, null);
+ this.myPcdAutogen.execute();
+ } catch (Exception e) {
+ throw new BuildException("PCD Autogen failed:" + e.getMessage());
+ }
+
+ if (this.myPcdAutogen != null) {
+ fileBuffer.append("\r\n");
+ fileBuffer.append(this.myPcdAutogen.OutputC());
+ }
+
+ if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {
+ throw new BuildException("Failed to generate AutoGen.c !!!");
+ }
+
+ }
+
+ /**
+ * libGenAutogenH
+ *
+ * This function generates AutoGen.h for library.
+ *
+ * @throws BuildException
+ * Failed to generate AutoGen.c.
+ */
+ void libGenAutogenH() throws AutoGenException {
+
+ Set<String> libClassIncludeH;
+ String moduleType;
+ List<String> headerFileList;
+ Iterator item;
+ StringBuffer fileBuffer = new StringBuffer(10240);
+
+ //
+ // Write Autogen.h header notation
+ //
+ fileBuffer.append(CommonDefinition.autogenHNotation);
+
+ //
+ // Add #ifndef ${BaseName}_AUTOGENH
+ // #def ${BseeName}_AUTOGENH
+ //
+ fileBuffer.append("#ifndef " + this.moduleId.getName().toUpperCase()
+ + "_AUTOGENH\r\n");
+ fileBuffer.append("#define " + this.moduleId.getName().toUpperCase()
+ + "_AUTOGENH\r\n\r\n");
+
+ //
+ // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
+ // to autogen.h file.
+ // Note: the specification version and release version should
+ // be get from module surface area instead of hard code.
+ //
+ fileBuffer.append(CommonDefinition.autoGenHbegin);
+ String[] specList = SurfaceAreaQuery.getExternSpecificaiton();
+ for (int i = 0; i < specList.length; i++) {
+ fileBuffer.append(CommonDefinition.marcDefineStr + specList[i]
+ + "\r\n");
+ }
+ // fileBuffer.append(CommonDefinition.autoGenHLine1);
+ // fileBuffer.append(CommonDefinition.autoGenHLine2);
+
+ //
+ // Write consumed package's mdouleInfo related *.h file to autogen.h.
+ //
+ moduleType = SurfaceAreaQuery.getModuleType();
+ PackageIdentification[] cosumedPkglist = SurfaceAreaQuery
+ .getDependencePkg(this.arch);
+ headerFileList = depPkgToAutogenH(cosumedPkglist, moduleType);
+ item = headerFileList.iterator();
+ while (item.hasNext()) {
+ fileBuffer.append(item.next().toString());
+ }
+ //
+ // Write library class's related *.h file to autogen.h
+ //
+ String[] libClassList = SurfaceAreaQuery
+ .getLibraryClasses(CommonDefinition.AlwaysConsumed);
+ if (libClassList != null) {
+ libClassIncludeH = LibraryClassToAutogenH(libClassList);
+ item = libClassIncludeH.iterator();
+ while (item.hasNext()) {
+ fileBuffer.append(item.next().toString());
+ }
+ }
+
+ libClassList = SurfaceAreaQuery
+ .getLibraryClasses(CommonDefinition.AlwaysProduced);
+ if (libClassList != null) {
+ libClassIncludeH = LibraryClassToAutogenH(libClassList);
+ item = libClassIncludeH.iterator();
+ while (item.hasNext()) {
+ fileBuffer.append(item.next().toString());
+ }
+ }
+ fileBuffer.append("\r\n");
+
+ //
+ // Write PCD information to library AutoGen.h.
+ //
+ if (this.myPcdAutogen != null) {
+ fileBuffer.append("\r\n");
+ fileBuffer.append(this.myPcdAutogen.OutputH());
+ }
+
+ //
+ // Append the #endif at AutoGen.h
+ //
+ fileBuffer.append("#endif\r\n");
+
+ //
+ // Save content of string buffer to AutoGen.h file.
+ //
+ if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {
+ throw new BuildException("Failed to generate AutoGen.h !!!");
+ }
+ }
+
+ /**
+ * libGenAutogenC
+ *
+ * This function generates AutoGen.h for library.
+ *
+ * @throws BuildException
+ * Failed to generate AutoGen.c.
+ */
+ void libGenAutogenC() throws BuildException {
+ StringBuffer fileBuffer = new StringBuffer(10240);
+
+ //
+ // Write Autogen.c header notation
+ //
+ fileBuffer.append(CommonDefinition.autogenCNotation);
+
+ fileBuffer.append(CommonDefinition.autoGenCLine1);
+ fileBuffer.append("\r\n");
+
+ //
+ // Call pcd autogen. PCDAutoGenAction tool only need module name and
+ // isPcdEmulatedDriver as parameter. Library inherit PCD and module's
+ // PCD information has been collected in FPDParser task by
+ // CollectPCDAction.
+ // Note : when PCD image tool ready,
+ // isPCDEmulatedDriver parameter will be removed.
+ //
+ try {
+// this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),
+// this.moduleId.getGuid(),moduleId.getPackage().getName(),moduleId.getPackage().getGuid(), this.arch, moduleId.getVersion(),true, SurfaceAreaQuery.getModulePcdEntryNameArray());
+ this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),
+ null,
+ null,
+ null,
+ this.arch,
+ null,
+ true,
+ SurfaceAreaQuery.getModulePcdEntryNameArray());
+
+ this.myPcdAutogen.execute();
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+
+ if (this.myPcdAutogen != null) {
+ fileBuffer.append("\r\n");
+ fileBuffer.append(this.myPcdAutogen.OutputC());
+ }
+
+ if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {
+ throw new BuildException("Failed to generate AutoGen.c !!!");
+ }
+ }
+
+ /**
+ * LibraryClassToAutogenH
+ *
+ * This function returns *.h files declared by library classes which are
+ * consumed or produced by current build module or library.
+ *
+ * @param libClassList
+ * List of library class which consumed or produce by current
+ * build module or library.
+ * @return includeStrList List of *.h file.
+ */
+ Set<String> LibraryClassToAutogenH(String[] libClassList)
+ throws AutoGenException {
+ Set<String> includStrList = new HashSet<String>();
+ String includerName[];
+ String str = "";
+
+ //
+ // Get include file from GlobalData's SPDTable according to
+ // library class name.
+ //
+
+ for (int i = 0; i < libClassList.length; i++) {
+ includerName = GlobalData.getLibraryClassHeaderFiles(
+ SurfaceAreaQuery.getDependencePkg(this.arch),
+ libClassList[i]);
+ if (includerName == null) {
+ throw new AutoGenException("Can not find library class ["
+ + libClassList[i] + "] declaration in every packages. ");
+ }
+ for (int j = 0; j < includerName.length; j++) {
+ String includeNameStr = includerName[j];
+ if (includeNameStr != null) {
+ str = CommonDefinition.include + " " + "<";
+ str = str + includeNameStr + ">\r\n";
+ includStrList.add(str);
+ includeNameStr = null;
+ }
+ }
+ }
+ return includStrList;
+ }
+
+ /**
+ * IncludesToAutogenH
+ *
+ * This function add include file in AutoGen.h file.
+ *
+ * @param packageNameList
+ * List of module depended package.
+ * @param moduleType
+ * Module type.
+ * @return
+ */
+ List<String> depPkgToAutogenH(PackageIdentification[] packageNameList,
+ String moduleType) throws AutoGenException {
+
+ List<String> includeStrList = new LinkedList<String>();
+ String pkgHeader;
+ String includeStr = "";
+
+ //
+ // Get include file from moduleInfo file
+ //
+ for (int i = 0; i < packageNameList.length; i++) {
+ pkgHeader = GlobalData.getPackageHeaderFiles(packageNameList[i],
+ moduleType);
+ if (pkgHeader == null) {
+ throw new AutoGenException("Can not find package ["
+ + packageNameList[i]
+ + "] declaration in every packages. ");
+ } else if (!pkgHeader.equalsIgnoreCase("")) {
+ includeStr = CommonDefinition.include + " <" + pkgHeader
+ + ">\r\n";
+ includeStrList.add(includeStr);
+ }
+ }
+
+ return includeStrList;
+ }
+
+ /**
+ * EntryPointToAutoGen
+ *
+ * This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
+ * information in mas to AutoGen.c
+ *
+ * @param entryPointList
+ * List of entry point.
+ * @param fileBuffer
+ * String buffer fo AutoGen.c.
+ * @throws Exception
+ */
+ void EntryPointToAutoGen(String[] entryPointList, StringBuffer fileBuffer)
+ throws BuildException {
+
+ String typeStr = SurfaceAreaQuery.getModuleType();
+
+ //
+ // The parameters and return value of entryPoint is difference
+ // for difference module type.
+ //
+ switch (CommonDefinition.getModuleType(typeStr)) {
+
+ case CommonDefinition.ModuleTypePeiCore:
+ if (entryPointList == null ||entryPointList.length != 1 ) {
+ throw new BuildException(
+ "Module type = 'PEI_CORE', only have one module entry point!");
+ } else {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
+ fileBuffer
+ .append(" IN VOID *OldCoreData\r\n");
+ fileBuffer.append(" );\r\n\r\n");
+
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
+ fileBuffer
+ .append(" IN VOID *OldCoreData\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ fileBuffer.append(" return ");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
+ fileBuffer.append("}\r\n\r\n");
+ }
+ break;
+
+ case CommonDefinition.ModuleTypeDxeCore:
+ fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
+ if (entryPointList == null || entryPointList.length != 1) {
+ throw new BuildException(
+ "Module type = 'DXE_CORE', only have one module entry point!");
+ } else {
+
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (\n");
+ fileBuffer.append(" IN VOID *HobStart\r\n");
+ fileBuffer.append(" );\r\n\r\n");
+
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer.append(" IN VOID *HobStart\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ fileBuffer.append(" ");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (HobStart);\r\n");
+ fileBuffer.append("}\r\n\r\n");
+ }
+ break;
+
+ case CommonDefinition.ModuleTypePeim:
+ int entryPointCount = 0;
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
+ if (entryPointList == null) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ fileBuffer.append(" return EFI_SUCCESS;\r\n");
+ fileBuffer.append("}\r\n\r\n");
+ break;
+ }
+ for (int i = 0; i < entryPointList.length; i++) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ fileBuffer.append(" );\r\n");
+ entryPointCount++;
+
+ }
+
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ if (entryPointCount == 1) {
+ fileBuffer.append(" return ");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (FfsHeader, PeiServices);\r\n");
+ } else {
+ fileBuffer.append(" EFI_STATUS Status;\r\n");
+ fileBuffer.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
+ fileBuffer.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (FfsHeader, PeiServices);\r\n");
+ fileBuffer
+ .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
+ fileBuffer.append(" CombinedStatus = Status;\r\n");
+ fileBuffer.append(" }\r\n\r\n");
+ } else {
+ break;
+ }
+ }
+ fileBuffer.append(" return CombinedStatus;\r\n");
+ }
+ fileBuffer.append("}\r\n\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ entryPointCount = 0;
+ //
+ // If entryPoint is null, create an empty ProcessModuleEntryPointList
+ // function.
+ //
+ if (entryPointList == null || entryPointList.length == 0){
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
+ fileBuffer.append(Integer.toString(entryPointCount));
+ fileBuffer.append(";\r\n");
+ fileBuffer
+ .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
+ fileBuffer
+ .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
+
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ fileBuffer.append(" return EFI_SUCCESS;\r\n");
+ fileBuffer.append("}\r\n\r\n");
+ break;
+ } else {
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" );\r\n");
+ entryPointCount++;
+ } else {
+ break;
+ }
}
- }
- }
- return includStrList;
- }
-
- /**
- * IncludesToAutogenH
- *
- * This function add include file in AutoGen.h file.
- *
- * @param packageNameList
- * List of module depended package.
- * @param moduleType
- * Module type.
- * @return
- */
- Set<String> depPkgToAutogenH(PackageIdentification[] packageNameList,
- String moduleType) throws AutoGenException{
-
- Set<String> includeStrList = new HashSet<String>();
- String pkgHeader;
- String includeStr = "";
-
- //
- // Get include file from moduleInfo file
- //
- for (int i = 0; i < packageNameList.length; i++){
-// pkgHeader = GlobalData.getPackageHeaderFiles(packageNameList[i], moduleType);
-// if (pkgHeader == null){
-// throw new AutoGenException("Can not find package [" + packageNameList[i] + "] declaration in every packages. ");
-// }else if (!pkgHeader.equalsIgnoreCase("")){
-// includeStr = CommonDefinition.include + "<" + pkgHeader + ">\r\n";
-// includeStrList.add(includeStr);
-// }
- }
-
- return includeStrList;
- }
-
- /**
- * EntryPointToAutoGen
- *
- * This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
- * information in mas to AutoGen.c
- *
- * @param entryPointList
- * List of entry point.
- * @param fileBuffer
- * String buffer fo AutoGen.c.
- * @throws Exception
- */
- void EntryPointToAutoGen(String[] entryPointList, StringBuffer fileBuffer)
- throws BuildException {
-
- String typeStr = SurfaceAreaQuery.getModuleType();
-
- //
- // The parameters and return value of entryPoint is difference
- // for difference module type.
- //
- switch (CommonDefinition.getModuleType(typeStr)) {
-
- case CommonDefinition.ModuleTypePeiCore:
- if (entryPointList.length != 1 || entryPointList[0].equals("")) {
- throw new BuildException(
- "Module type = 'PEI_CORE', only have one module entry point!");
- } else {
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append(entryPointList[0]);
- fileBuffer.append(" (\r\n");
- fileBuffer
- .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
fileBuffer
- .append(" IN VOID *OldCoreData\r\n");
- fileBuffer.append(" );\r\n\r\n");
-
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
+ fileBuffer.append(Integer.toString(entryPointCount));
+ fileBuffer.append(";\r\n");
fileBuffer
- .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
+ .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
fileBuffer
- .append(" IN VOID *OldCoreData\r\n");
- fileBuffer.append(" )\r\n\r\n");
- fileBuffer.append("{\r\n");
- fileBuffer.append(" return ");
- fileBuffer.append(entryPointList[0]);
- fileBuffer.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
- fileBuffer.append("}\r\n\r\n");
- }
- break;
-
- case CommonDefinition.ModuleTypeDxeCore:
- fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
- if (entryPointList.length != 1 || entryPointList[0].equals("")) {
- throw new BuildException(
- "Module type = 'DXE_CORE', only have one module entry point!");
- } else {
+ .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
- fileBuffer.append("VOID\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append(entryPointList[0]);
- fileBuffer.append(" (\n");
- fileBuffer.append(" IN VOID *HobStart\r\n");
- fileBuffer.append(" );\r\n\r\n");
-
- fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFI_STATUS\r\n");
fileBuffer.append("EFIAPI\r\n");
fileBuffer.append("ProcessModuleEntryPointList (\r\n");
- fileBuffer.append(" IN VOID *HobStart\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
fileBuffer.append(" )\r\n\r\n");
fileBuffer.append("{\r\n");
- fileBuffer.append(" ");
- fileBuffer.append(entryPointList[0]);
- fileBuffer.append(" (HobStart);\r\n");
- fileBuffer.append("}\r\n\r\n");
- }
- break;
-
- case CommonDefinition.ModuleTypePeim:
- int entryPointCount = 0;
- fileBuffer
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append(entryPointList[i]);
- fileBuffer.append(" (\r\n");
- fileBuffer
- .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
- fileBuffer
- .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
- fileBuffer.append(" );\r\n");
- entryPointCount++;
- } else {
- break;
- }
- }
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append("ProcessModuleEntryPointList (\r\n");
- fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
- fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
- fileBuffer.append(" )\r\n\r\n");
- fileBuffer.append("{\r\n");
-
- if (entryPointCount == 0) {
- fileBuffer.append(" return EFI_SUCCESS;\r\n");
- } else if (entryPointCount == 1) {
- fileBuffer.append(" return ");
- fileBuffer.append(entryPointList[0]);
- fileBuffer.append(" (FfsHeader, PeiServices);\r\n");
- } else {
- fileBuffer.append(" EFI_STATUS Status;\r\n");
- fileBuffer.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
- fileBuffer.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
+
for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
- fileBuffer.append(" Status = ");
- fileBuffer.append(entryPointList[i]);
- fileBuffer.append(" (FfsHeader, PeiServices);\r\n");
- fileBuffer
- .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
- fileBuffer.append(" CombinedStatus = Status;\r\n");
- fileBuffer.append(" }\r\n\r\n");
- } else {
- break;
- }
- }
- fileBuffer.append(" return CombinedStatus;\r\n");
- }
- fileBuffer.append("}\r\n\r\n");
- break;
-
- case CommonDefinition.ModuleTypeDxeSmmDriver:
- entryPointCount = 0;
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append(entryPointList[i]);
- fileBuffer.append(" (\r\n");
- fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
- fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
- fileBuffer.append(" );\r\n");
- entryPointCount++;
- } else {
- break;
- }
- }
- fileBuffer
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
- fileBuffer.append(Integer.toString(entryPointCount));
- fileBuffer.append(";\r\n");
- fileBuffer
- .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
- fileBuffer
- .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
-
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append("ProcessModuleEntryPointList (\r\n");
- fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
- fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
- fileBuffer.append(" )\r\n\r\n");
- fileBuffer.append("{\r\n");
-
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
fileBuffer
.append(" if (SetJump (&mJumpContext) == 0) {\r\n");
fileBuffer.append(" ExitDriver (");
@@ -859,72 +938,78 @@ public class AutoGen {
fileBuffer.append(" (ImageHandle, SystemTable));\r\n");
fileBuffer.append(" ASSERT (FALSE);\r\n");
fileBuffer.append(" }\r\n");
- } else {
- break;
+
}
- }
- fileBuffer.append(" return mDriverEntryPointStatus;\r\n");
- fileBuffer.append("}\r\n\r\n");
-
- fileBuffer.append("VOID\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append("ExitDriver (\r\n");
- fileBuffer.append(" IN EFI_STATUS Status\n");
- fileBuffer.append(" )\r\n\r\n");
- fileBuffer.append("{\r\n");
- fileBuffer
- .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
- fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n");
- fileBuffer.append(" }\r\n");
- fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
- fileBuffer.append(" ASSERT (FALSE);\r\n");
- fileBuffer.append("}\r\n\r\n");
-
- //
- // Add "ModuleUnloadImage" for DxeSmmDriver module type;
- //
- entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
- entryPointCount = 0;
-
- fileBuffer
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
- fileBuffer.append(Integer.toString(entryPointCount));
- fileBuffer.append(";\r\n\r\n");
+ fileBuffer.append(" return mDriverEntryPointStatus;\r\n");
+ fileBuffer.append("}\r\n\r\n");
- if (entryPointList != null) {
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append(entryPointList[i]);
- fileBuffer.append(" (\r\n");
- fileBuffer
- .append(" EFI_HANDLE ImageHandle\r\n");
- fileBuffer.append(" );\r\n");
- } else {
- break;
- }
- }
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ExitDriver (\r\n");
+ fileBuffer.append(" IN EFI_STATUS Status\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ fileBuffer
+ .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
+ fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n");
+ fileBuffer.append(" }\r\n");
+ fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
+ fileBuffer.append(" ASSERT (FALSE);\r\n");
+ fileBuffer.append("}\r\n\r\n");
+
}
-
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append("ProcessModuleUnloadList (\r\n");
- fileBuffer.append(" EFI_HANDLE ImageHandle\r\n");
- fileBuffer.append(" )\r\n");
- fileBuffer.append("{\r\n");
-
- if (entryPointCount == 0) {
- fileBuffer.append(" return EFI_SUCCESS;\r\n");
- } else if (entryPointCount == 1) {
- fileBuffer.append(" return ");
- fileBuffer.append(entryPointList[0]);
- fileBuffer.append("(ImageHandle);\r\n");
- } else {
- fileBuffer.append(" EFI_STATUS Status;\r\n\r\n");
- fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n");
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
+
+
+ //
+ // Add "ModuleUnloadImage" for DxeSmmDriver module type;
+ //
+ entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
+ entryPointList = CommonDefinition.remDupString(entryPointList);
+ entryPointCount = 0;
+
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
+ fileBuffer.append(Integer.toString(entryPointCount));
+ fileBuffer.append(";\r\n\r\n");
+
+ if (entryPointList != null) {
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" );\r\n");
+ } else {
+ break;
+ }
+ }
+ }
+
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleUnloadList (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" )\r\n");
+ fileBuffer.append("{\r\n");
+
+ if (entryPointCount == 0) {
+ fileBuffer.append(" return EFI_SUCCESS;\r\n");
+ } else if (entryPointCount == 1) {
+ fileBuffer.append(" return ");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ } else {
+ fileBuffer.append(" EFI_STATUS Status;\r\n\r\n");
+ fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n");
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (i == 0){
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ }else{
fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
fileBuffer.append(" ");
fileBuffer.append(entryPointList[i]);
@@ -934,24 +1019,39 @@ public class AutoGen {
fileBuffer.append(entryPointList[i]);
fileBuffer.append("(ImageHandle);\r\n");
fileBuffer.append(" }\r\n");
- } else {
- break;
}
- }
- fileBuffer.append(" return Status;\r\n");
- }
- fileBuffer.append("}\r\n\r\n");
- break;
-
- case CommonDefinition.ModuleTypeDxeRuntimeDriver:
- case CommonDefinition.ModuleTypeDxeDriver:
- case CommonDefinition.ModuleTypeDxeSalDriver:
- case CommonDefinition.ModuleTypeUefiDriver:
- case CommonDefinition.ModuleTypeUefiApplication:
- entryPointCount = 0;
- fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
+ }
+ fileBuffer.append(" return Status;\r\n");
+ }
+ fileBuffer.append("}\r\n\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ entryPointCount = 0;
+ fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
+ //
+ // If entry point is null, create a empty ProcessModuleEntryPointList function.
+ //
+ if (entryPointList == null || entryPointList.length == 0){
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ fileBuffer.append(" return EFI_SUCCESS;\r\n");
+ fileBuffer.append("}\r\n");
+
+ }else {
+ for (int i = 0; i < entryPointList.length; i++) {
+
fileBuffer.append("EFI_STATUS\r\n");
fileBuffer.append("EFIAPI\r\n");
fileBuffer.append(entryPointList[i]);
@@ -960,1000 +1060,1030 @@ public class AutoGen {
fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
fileBuffer.append(" );\r\n");
entryPointCount++;
- } else {
- break;
- }
- }
-
- fileBuffer
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
- fileBuffer.append(Integer.toString(entryPointCount));
- fileBuffer.append(";\r\n");
- if (entryPointCount > 1) {
- fileBuffer
- .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
- fileBuffer
- .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
- }
- fileBuffer.append("\n");
-
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append("ProcessModuleEntryPointList (\r\n");
- fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
- fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
- fileBuffer.append(" )\r\n\r\n");
- fileBuffer.append("{\r\n");
-
- if (entryPointCount == 0) {
- fileBuffer.append(" return EFI_SUCCESS;\r\n");
- } else if (entryPointCount == 1) {
- fileBuffer.append(" return (");
- fileBuffer.append(entryPointList[0]);
- fileBuffer.append(" (ImageHandle, SystemTable));\r\n");
- } else {
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
- fileBuffer
- .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
- fileBuffer.append(" ExitDriver (");
- fileBuffer.append(entryPointList[i]);
- fileBuffer.append(" (ImageHandle, SystemTable));\r\n");
- fileBuffer.append(" ASSERT (FALSE);\r\n");
- fileBuffer.append(" }\r\n");
- } else {
- break;
- }
}
- fileBuffer.append(" return mDriverEntryPointStatus;\r\n");
- }
- fileBuffer.append("}\r\n\r\n");
-
- fileBuffer.append("VOID\n");
- fileBuffer.append("EFIAPI\n");
- fileBuffer.append("ExitDriver (\r\n");
- fileBuffer.append(" IN EFI_STATUS Status\n");
- fileBuffer.append(" )\r\n\r\n");
- fileBuffer.append("{\r\n");
- if (entryPointCount <= 1) {
- fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
- fileBuffer
- .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
- fileBuffer.append(" }\r\n");
- fileBuffer
- .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
- } else {
- fileBuffer
- .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
- fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n");
- fileBuffer.append(" }\r\n");
- fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
- fileBuffer.append(" ASSERT (FALSE);\r\n");
- }
- fileBuffer.append("}\r\n\r\n");
- //
- // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
- //
- entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
- entryPointCount = 0;
- if (entryPointList != null) {
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append(entryPointList[i]);
- fileBuffer.append(" (\r\n");
- fileBuffer
- .append(" EFI_HANDLE ImageHandle\r\n");
- fileBuffer.append(" );\r\n");
- entryPointCount++;
- } else {
- break;
- }
- }
- }
-
- fileBuffer
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
- fileBuffer.append(Integer.toString(entryPointCount));
- fileBuffer.append(";\r\n\r\n");
-
- if (entryPointList != null) {
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append(entryPointList[i]);
- fileBuffer.append(" (\r\n");
- fileBuffer
- .append(" EFI_HANDLE ImageHandle\r\n");
- fileBuffer.append(" );\r\n");
- } else {
- break;
- }
- }
- }
-
- fileBuffer.append("EFI_STATUS\n");
- fileBuffer.append("EFIAPI\n");
- fileBuffer.append("ProcessModuleUnloadList (\r\n");
- fileBuffer.append(" EFI_HANDLE ImageHandle\r\n");
- fileBuffer.append(" )\r\n");
- fileBuffer.append("{\r\n");
-
- if (entryPointCount == 0) {
- fileBuffer.append(" return EFI_SUCCESS;\r\n");
- } else if (entryPointCount == 1) {
- fileBuffer.append(" return ");
- fileBuffer.append(entryPointList[0]);
- fileBuffer.append("(ImageHandle);\r\n");
- } else {
- fileBuffer.append(" EFI_STATUS Status;\r\n\r\n");
- fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n");
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
- fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
- fileBuffer.append(" ");
- fileBuffer.append(entryPointList[i]);
- fileBuffer.append("(ImageHandle);\r\n");
- fileBuffer.append(" } else {\r\n");
- fileBuffer.append(" Status = ");
- fileBuffer.append(entryPointList[i]);
- fileBuffer.append("(ImageHandle);\r\n");
- fileBuffer.append(" }\r\n");
- } else {
- break;
- }
- }
- fileBuffer.append(" return Status;\r\n");
- }
- fileBuffer.append("}\r\n\r\n");
- break;
- }
- }
-
- /**
- * PpiGuidToAutogenc
- *
- * This function gets GUIDs from SPD file accrodeing to <PPIs> information
- * and write those GUIDs to AutoGen.c.
- *
- * @param fileBuffer
- * String Buffer for Autogen.c file.
- * @throws BuildException
- * Guid must set value!
- */
- void PpiGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {
- String[] cNameGuid = null;
-
- //
- // Get the all PPI adn PPI Notify from MSA file,
- // then add those PPI ,and PPI Notify name to list.
- //
- String[] ppiList = SurfaceAreaQuery.getPpiArray(null);
- for (int i = 0; i < ppiList.length; i++) {
- this.mPpiList.add(ppiList[i]);
- }
-
- String[] ppiNotifyList = SurfaceAreaQuery.getPpiNotifyArray(null);
- for (int i = 0; i < ppiNotifyList.length; i++) {
- this.mPpiList.add(ppiNotifyList[i]);
- }
-
- //
- // Find CNAME and GUID from dependence SPD file and write to Autogen.c
- //
- Iterator ppiIterator = this.mPpiList.iterator();
- String ppiKeyWord = null;
- while (ppiIterator.hasNext()) {
- ppiKeyWord = ppiIterator.next().toString();
- cNameGuid = GlobalData
- .getPpiGuid(SurfaceAreaQuery.getDependencePkg(this.arch),
- ppiKeyWord);
- if (cNameGuid != null) {
fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
- fileBuffer.append(cNameGuid[0]);
- fileBuffer.append(" = { ");
- fileBuffer.append(cNameGuid[1]);
- fileBuffer.append(" } ;");
- } else {
- //
- // If can't find Ppi GUID declaration in every package
- //
- throw new AutoGenException("Can not find Ppi GUID [" + ppiKeyWord + "] declaration in every packages. ");
- }
- }
- }
-
- /**
- * ProtocolGuidToAutogenc
- *
- * This function gets GUIDs from SPD file accrodeing to <Protocol>
- * information and write those GUIDs to AutoGen.c.
- *
- * @param fileBuffer
- * String Buffer for Autogen.c file.
- * @throws BuildException
- * Protocol name must set.
- */
- void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws BuildException {
- String[] cNameGuid = null;
-
- String[] protocolList = SurfaceAreaQuery.getProtocolArray(this.arch);
-
- //
- // Add result to Autogen global list.
- //
- for (int i = 0; i < protocolList.length; i++) {
- this.mProtocolList.add(protocolList[i]);
- }
-
- String[] protocolNotifyList = SurfaceAreaQuery
- .getProtocolNotifyArray(this.arch);
-
- for (int i = 0; i < protocolNotifyList.length; i++) {
- this.mProtocolList.add(protocolNotifyList[i]);
- }
-
- //
- // Get the NAME and GUID from dependence SPD and write to Autogen.c
- //
- Iterator protocolIterator = this.mPpiList.iterator();
- String protocolKeyWord = null;
- while (protocolIterator.hasNext()) {
- protocolKeyWord = protocolIterator.next().toString();
- cNameGuid = GlobalData.getProtocolGuid(SurfaceAreaQuery
- .getDependencePkg(this.arch), protocolKeyWord);
- if (cNameGuid != null) {
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
- fileBuffer.append(cNameGuid[0]);
- fileBuffer.append(" = { ");
- fileBuffer.append(cNameGuid[1]);
- fileBuffer.append(" } ;");
- } else {
- //
- // If can't find protocol GUID declaration in every package
- //
- throw new BuildException("Can not find protocol Guid [" + cNameGuid + "] declaration in every packages. ");
- }
- }
- }
-
- /**
- * GuidGuidToAutogenc
- *
- * This function gets GUIDs from SPD file accrodeing to <Guids> information
- * and write those GUIDs to AutoGen.c.
- *
- * @param fileBuffer
- * String Buffer for Autogen.c file.
- *
- */
- void GuidGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {
- String[] cNameGuid = null;
- String guidKeyWord = null;
-
- String[] guidList = SurfaceAreaQuery.getGuidEntryArray(this.arch);
-
- for (int i = 0; i < guidList.length; i++) {
- this.mGuidList.add(guidList[i]);
- }
-
- Iterator guidIterator = this.mGuidList.iterator();
- while (guidIterator.hasNext()) {
- guidKeyWord = guidIterator.next().toString();
- cNameGuid = GlobalData.getGuid(SurfaceAreaQuery
- .getDependencePkg(this.arch), guidKeyWord);
-
- if (cNameGuid != null) {
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
- fileBuffer.append(cNameGuid[0]);
- fileBuffer.append(" = { ");
- fileBuffer.append(cNameGuid[1]);
- fileBuffer.append("} ;");
- }else {
- //
- // If can't find GUID declaration in every package
- //
- throw new AutoGenException("Can not find Guid [" + guidKeyWord + "] declaration in every packages. ");
- }
-
- }
- }
-
- /**
- * LibInstanceToAutogenC
- *
- * This function adds dependent library instance to autogen.c,which
- * includeing library's constructor, destructor, and library dependent ppi,
- * protocol, guid, pcd information.
- *
- * @param fileBuffer
- * String buffer for AutoGen.c
- * @throws BuildException
- */
- void LibInstanceToAutogenC(StringBuffer fileBuffer) throws BuildException {
- int index;
-
- String moduleType = SurfaceAreaQuery.getModuleType();
- List<String> libConstructList = new ArrayList<String>();
- List<String> libDestructList = new ArrayList<String>();
-
- String libConstructName = null;
- String libDestructName = null;
- ModuleIdentification[] libraryIdList = SurfaceAreaQuery.getLibraryInstance(this.arch);
-
- try {
- if (libraryIdList != null) {
- //
- // Reorder library instance sequence.
- //
- AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList, this.arch);
- List<ModuleIdentification> orderList = libOrder.orderLibInstance();
-
- if (orderList != null) {
- //
- // Process library instance one by one.
- //
- for (int i = 0; i < orderList.size(); i++) {
-
- //
- // Get library instance basename.
- //
- ModuleIdentification libInstanceId = orderList.get(i);
-
- //
- // Get override map
- //
- Map<String, XmlObject> libDoc = GlobalData
- .getDoc(libInstanceId, this.arch);
- SurfaceAreaQuery.push(libDoc);
-
- //
- // Get <PPis>, <Protocols>, <Guids> list of this library
- // instance.
- //
- String[] ppiList = SurfaceAreaQuery
- .getPpiArray(null);
- String[] ppiNotifyList = SurfaceAreaQuery
- .getPpiNotifyArray(null);
- String[] protocolList = SurfaceAreaQuery
- .getProtocolArray(null);
- String[] protocolNotifyList = SurfaceAreaQuery
- .getProtocolNotifyArray(null);
- String[] guidList = SurfaceAreaQuery
- .getGuidEntryArray(null);
-
- //
- // Add those ppi, protocol, guid in global ppi,
- // protocol, guid
- // list.
- //
- for (index = 0; index < ppiList.length; index++) {
- this.mPpiList.add(ppiList[index]);
- }
-
- for (index = 0; index < ppiNotifyList.length; index++) {
- this.mPpiList.add(ppiNotifyList[index]);
- }
-
- for (index = 0; index < protocolList.length; index++) {
- this.mProtocolList.add(protocolList[index]);
- }
-
- for (index = 0; index < protocolNotifyList.length; index++) {
- this.mProtocolList.add(protocolNotifyList[index]);
- }
-
- for (index = 0; index < guidList.length; index++) {
- this.mGuidList.add(guidList[index]);
- }
-
- //
- // If not yet parse this library instance's constructor
- // element,parse it.
- //
- libConstructName = SurfaceAreaQuery
- .getLibConstructorName();
- libDestructName = SurfaceAreaQuery
- .getLibDestructorName();
-
- SurfaceAreaQuery.pop();
- //
- // Add dependent library instance constructor function.
- //
- if (libConstructName != null) {
- libConstructList.add(libConstructName);
- }
- //
- // Add dependent library instance destructor fuction.
- //
- if (libDestructName != null) {
- libDestructList.add(libDestructName);
- }
- }
-
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
+ fileBuffer.append(Integer.toString(entryPointCount));
+ fileBuffer.append(";\r\n");
+ if (entryPointCount > 1) {
+ fileBuffer
+ .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
+ fileBuffer
+ .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
}
+ fileBuffer.append("\n");
- //
- // Add library constructor to AutoGen.c
- //
- LibConstructorToAutogenC(libConstructList, moduleType,
- fileBuffer/* autogenC */);
- //
- // Add library destructor to AutoGen.c
- //
- LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);
- }
-
- } catch (Exception e) {
- throw new BuildException(e.getMessage());
- }
- }
-
- /**
- * LibConstructorToAutogenc
- *
- * This function writes library constructor list to AutoGen.c. The library
- * constructor's parameter and return value depend on module type.
- *
- * @param libInstanceList
- * List of library construct name.
- * @param moduleType
- * Module type.
- * @param fileBuffer
- * String buffer for AutoGen.c
- * @throws Exception
- */
- void LibConstructorToAutogenC(List<String> libInstanceList,
- String moduleType, StringBuffer fileBuffer) throws Exception {
- boolean isFirst = true;
-
- //
- // The library constructor's parameter and return value depend on
- // module type.
- //
- for (int i = 0; i < libInstanceList.size(); i++) {
- switch (CommonDefinition.getModuleType(moduleType)) {
- case CommonDefinition.ModuleTypeBase:
- fileBuffer.append("RETURN_STATUS\r\n");
- fileBuffer.append(libInstanceList.get(i));
- fileBuffer.append(" (\r\n");
- fileBuffer.append(" VOID\r\n");
- fileBuffer.append(" );\r\n");
- break;
-
- case CommonDefinition.ModuleTypePeiCore:
- case CommonDefinition.ModuleTypePeim:
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append(libInstanceList.get(i));
- fileBuffer.append(" (\r\n");
- fileBuffer
- .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
- fileBuffer
- .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
- fileBuffer.append(" );\r\n");
- break;
-
- case CommonDefinition.ModuleTypeDxeCore:
- case CommonDefinition.ModuleTypeDxeDriver:
- case CommonDefinition.ModuleTypeDxeRuntimeDriver:
- case CommonDefinition.ModuleTypeDxeSmmDriver:
- case CommonDefinition.ModuleTypeDxeSalDriver:
- case CommonDefinition.ModuleTypeUefiDriver:
- case CommonDefinition.ModuleTypeUefiApplication:
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append(libInstanceList.get(i));
- fileBuffer.append(" (\r\n");
- fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
- fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
- fileBuffer.append(" );\r\n");
- break;
- }
- }
-
- //
- // Add ProcessLibraryConstructorList in AutoGen.c
- //
- fileBuffer.append("VOID\r\n");
- fileBuffer.append("ProcessLibraryConstructorList (\r\n");
- switch (CommonDefinition.getModuleType(moduleType)) {
- case CommonDefinition.ModuleTypeBase:
- fileBuffer.append(" VOID\r\n");
- break;
-
- case CommonDefinition.ModuleTypePeiCore:
- case CommonDefinition.ModuleTypePeim:
- fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
- fileBuffer
- .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
- break;
-
- case CommonDefinition.ModuleTypeDxeCore:
- case CommonDefinition.ModuleTypeDxeDriver:
- case CommonDefinition.ModuleTypeDxeRuntimeDriver:
- case CommonDefinition.ModuleTypeDxeSmmDriver:
- case CommonDefinition.ModuleTypeDxeSalDriver:
- case CommonDefinition.ModuleTypeUefiDriver:
- case CommonDefinition.ModuleTypeUefiApplication:
- fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
- fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
- break;
- }
-
- fileBuffer.append(" )\r\n");
- fileBuffer.append("{\r\n");
-
- for (int i = 0; i < libInstanceList.size(); i++) {
- if (isFirst) {
- fileBuffer.append(" EFI_STATUS Status;\r\n");
- fileBuffer.append("\r\n");
- isFirst = false;
- }
- switch (CommonDefinition.getModuleType(moduleType)) {
- case CommonDefinition.ModuleTypeBase:
- fileBuffer.append(" Status = ");
- fileBuffer.append(libInstanceList.get(i));
- fileBuffer.append("();\r\n");
- fileBuffer.append(" VOID\r\n");
- break;
- case CommonDefinition.ModuleTypePeiCore:
- case CommonDefinition.ModuleTypePeim:
- fileBuffer.append(" Status = ");
- fileBuffer.append(libInstanceList.get(i));
- fileBuffer.append(" (FfsHeader, PeiServices);\r\n");
- break;
- case CommonDefinition.ModuleTypeDxeCore:
- case CommonDefinition.ModuleTypeDxeDriver:
- case CommonDefinition.ModuleTypeDxeRuntimeDriver:
- case CommonDefinition.ModuleTypeDxeSmmDriver:
- case CommonDefinition.ModuleTypeDxeSalDriver:
- case CommonDefinition.ModuleTypeUefiDriver:
- case CommonDefinition.ModuleTypeUefiApplication:
- fileBuffer.append(" Status = ");
- fileBuffer.append(libInstanceList.get(i));
- fileBuffer.append(" (ImageHandle, SystemTable);\r\n");
- break;
- }
- fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n");
- }
- fileBuffer.append("}\r\n");
- }
-
- /**
- * LibDestructorToAutogenc
- *
- * This function writes library destructor list to AutoGen.c. The library
- * destructor's parameter and return value depend on module type.
- *
- * @param libInstanceList
- * List of library destructor name.
- * @param moduleType
- * Module type.
- * @param fileBuffer
- * String buffer for AutoGen.c
- * @throws Exception
- */
- void LibDestructorToAutogenC(List<String> libInstanceList,
- String moduleType, StringBuffer fileBuffer) throws Exception {
- boolean isFirst = true;
- for (int i = 0; i < libInstanceList.size(); i++) {
- switch (CommonDefinition.getModuleType(moduleType)) {
- case CommonDefinition.ModuleTypeBase:
- fileBuffer.append("RETURN_STATUS\n");
- fileBuffer.append(libInstanceList.get(i));
- fileBuffer.append(" (\r\n");
- fileBuffer.append(" VOID\r\n");
- fileBuffer.append(" );\r\n");
- break;
- case CommonDefinition.ModuleTypePeiCore:
- case CommonDefinition.ModuleTypePeim:
fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append(libInstanceList.get(i));
- fileBuffer.append(" (\r\n");
- fileBuffer
- .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
- fileBuffer
- .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
- fileBuffer.append(" );\r\n");
- break;
- case CommonDefinition.ModuleTypeDxeCore:
- case CommonDefinition.ModuleTypeDxeDriver:
- case CommonDefinition.ModuleTypeDxeRuntimeDriver:
- case CommonDefinition.ModuleTypeDxeSmmDriver:
- case CommonDefinition.ModuleTypeDxeSalDriver:
- case CommonDefinition.ModuleTypeUefiDriver:
- case CommonDefinition.ModuleTypeUefiApplication:
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append(libInstanceList.get(i));
- fileBuffer.append(" (\r\n");
- fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
- fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
- fileBuffer.append(" );\r\n");
- break;
- }
- }
-
- //
- // Write ProcessLibraryDestructor list to autogen.c
- //
- switch (CommonDefinition.getModuleType(moduleType)) {
- case CommonDefinition.ModuleTypeBase:
- case CommonDefinition.ModuleTypePeiCore:
- case CommonDefinition.ModuleTypePeim:
- break;
- case CommonDefinition.ModuleTypeDxeCore:
- case CommonDefinition.ModuleTypeDxeDriver:
- case CommonDefinition.ModuleTypeDxeRuntimeDriver:
- case CommonDefinition.ModuleTypeDxeSmmDriver:
- case CommonDefinition.ModuleTypeDxeSalDriver:
- case CommonDefinition.ModuleTypeUefiDriver:
- case CommonDefinition.ModuleTypeUefiApplication:
- fileBuffer.append("VOID\r\n");
- fileBuffer.append("ProcessLibraryDestructorList (\r\n");
- fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
- fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
- fileBuffer.append(" )\r\n");
- fileBuffer.append("{\r\n");
-
- for (int i = 0; i < libInstanceList.size(); i++) {
- if (isFirst) {
- fileBuffer.append(" EFI_STATUS Status;\r\n");
- fileBuffer.append("\r\n");
- isFirst = false;
- }
- fileBuffer.append(" Status = ");
- fileBuffer.append(libInstanceList.get(i));
- fileBuffer.append("(ImageHandle, SystemTable);\r\n");
- fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n");
- }
- fileBuffer.append("}\r\n");
- break;
- }
- }
-
- /**
- * ExternsDriverBindingToAutoGenC
- *
- * This function is to write DRIVER_BINDING, COMPONENT_NAME,
- * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
- *
- * @param fileBuffer
- * String buffer for AutoGen.c
- */
- void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer)
- throws BuildException {
-
- //
- // Check what <extern> contains. And the number of following elements
- // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
- // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
- //
-
- String[] drvBindList = SurfaceAreaQuery.getDriverBindingArray();
-
- //
- // If component name protocol,component configuration protocol,
- // component diagnostic protocol is not null or empty, check
- // if every one have the same number of the driver binding protocol.
- //
- if (drvBindList == null || drvBindList.length == 0) {
- return;
- }
-
- String[] compNamList = SurfaceAreaQuery.getComponentNameArray();
- String[] compConfList = SurfaceAreaQuery.getDriverConfigArray();
- String[] compDiagList = SurfaceAreaQuery.getDriverDiagArray();
-
- int BitMask = 0;
-
- //
- // Write driver binding protocol extern to autogen.c
- //
- for (int i = 0; i < drvBindList.length; i++) {
- fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
- fileBuffer.append(drvBindList[i]);
- fileBuffer.append(";\r\n");
- }
-
- //
- // Write component name protocol extern to autogen.c
- //
- if (compNamList != null && compNamList.length != 0) {
- if (drvBindList.length != compNamList.length) {
- throw new BuildException(
- "Different number of Driver Binding and Component Name protocols!");
- }
-
- BitMask |= 0x01;
- for (int i = 0; i < compNamList.length; i++) {
- fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
- fileBuffer.append(compNamList[i]);
- fileBuffer.append(";\r\n");
- }
- }
-
- //
- // Write driver configration protocol extern to autogen.c
- //
- if (compConfList != null && compConfList.length != 0) {
- if (drvBindList.length != compConfList.length) {
- throw new BuildException(
- "Different number of Driver Binding and Driver Configuration protocols!");
- }
-
- BitMask |= 0x02;
- for (int i = 0; i < compConfList.length; i++) {
- fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
- fileBuffer.append(compConfList[i]);
- fileBuffer.append(";\r\n");
- }
- }
-
- //
- // Write driver dignastic protocol extern to autogen.c
- //
- if (compDiagList != null && compDiagList.length != 0) {
- if (drvBindList.length != compDiagList.length) {
- throw new BuildException(
- "Different number of Driver Binding and Driver Configuration protocols!");
- }
-
- BitMask |= 0x04;
- for (int i = 0; i < compDiagList.length; i++) {
- fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
- fileBuffer.append(compDiagList[i]);
- fileBuffer.append(";\r\n");
- }
- }
-
- //
- // Write driver module protocol bitmask.
- //
- fileBuffer
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
- fileBuffer.append(Integer.toString(BitMask));
- fileBuffer.append(";\r\n");
-
- //
- // Write driver module protocol list entry
- //
- fileBuffer
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
-
- fileBuffer.append(Integer.toString(drvBindList.length));
- fileBuffer.append(";\r\n");
-
- //
- // Write drive module protocol list to autogen.c
- //
- fileBuffer
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
- for (int i = 0; i < drvBindList.length; i++) {
- if (i != 0) {
- fileBuffer.append(",");
- }
- fileBuffer.append("\r\n {\r\n");
- fileBuffer.append(" &");
- fileBuffer.append(drvBindList[i]);
- fileBuffer.append(", \r\n");
-
- if (compNamList != null) {
- fileBuffer.append(" &");
- fileBuffer.append(compNamList[i]);
- fileBuffer.append(", \r\n");
- } else {
- fileBuffer.append(" NULL, \r\n");
- }
-
- if (compConfList != null) {
- fileBuffer.append(" &");
- fileBuffer.append(compConfList[i]);
- fileBuffer.append(", \r\n");
- } else {
- fileBuffer.append(" NULL, \r\n");
- }
-
- if (compDiagList != null) {
- fileBuffer.append(" &");
- fileBuffer.append(compDiagList[i]);
- fileBuffer.append(", \r\n");
- } else {
- fileBuffer.append(" NULL, \r\n");
- }
- fileBuffer.append(" }");
- }
- fileBuffer.append("\r\n};\r\n");
- }
-
- /**
- * ExternCallBackToAutoGenC
- *
- * This function adds <SetVirtualAddressMapCallBack> and
- * <ExitBootServicesCallBack> infomation to AutoGen.c
- *
- * @param fileBuffer
- * String buffer for AutoGen.c
- * @throws BuildException
- */
- void ExternCallBackToAutoGenC(StringBuffer fileBuffer)
- throws BuildException {
- String[] setVirtualList = SurfaceAreaQuery
- .getSetVirtualAddressMapCallBackArray();
- String[] exitBootList = SurfaceAreaQuery
- .getExitBootServicesCallBackArray();
- String moduleType = SurfaceAreaQuery.getModuleType();
- boolean UefiOrDxeModule = false;
- int Count = 0;
- int i;
-
- switch (CommonDefinition.getModuleType(moduleType)) {
- case CommonDefinition.ModuleTypeDxeDriver:
- case CommonDefinition.ModuleTypeDxeRuntimeDriver:
- case CommonDefinition.ModuleTypeDxeSalDriver:
- case CommonDefinition.ModuleTypeUefiDriver:
- case CommonDefinition.ModuleTypeUefiApplication:
- //
- // Entry point lib for these module types needs to know the count
- // of entryPoint.
- //
- UefiOrDxeModule = true;
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
- //
- // If the list is not valid or has no entries set count to zero else
- // set count to the number of valid entries
- //
- Count = 0;
- if (setVirtualList != null) {
- for (i = 0; i < setVirtualList.length; i++) {
- if (setVirtualList[i].equalsIgnoreCase("")) {
- break;
+ if (entryPointCount == 1) {
+ fileBuffer.append(" return (");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (ImageHandle, SystemTable));\r\n");
+ } else {
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer
+ .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
+ fileBuffer.append(" ExitDriver (");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (ImageHandle, SystemTable));\r\n");
+ fileBuffer.append(" ASSERT (FALSE);\r\n");
+ fileBuffer.append(" }\r\n");
+ } else {
+ break;
+ }
}
+ fileBuffer.append(" return mDriverEntryPointStatus;\r\n");
}
- Count = i;
- }
-
- fileBuffer.append(Integer.toString(Count));
- fileBuffer.append(";\r\n\r\n");
- break;
- default:
- break;
- }
+ fileBuffer.append("}\r\n\r\n");
- if (setVirtualList == null) {
- if (UefiOrDxeModule) {
- //
- // No data so make a NULL list
- //
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
- fileBuffer.append(" NULL\r\n");
- fileBuffer.append("};\r\n\r\n");
- }
- } else {
- //
- // Write SetVirtualAddressMap function definition.
- //
- for (i = 0; i < setVirtualList.length; i++) {
- if (setVirtualList[i].equalsIgnoreCase("")) {
- break;
- }
- fileBuffer.append("VOID\r\n");
+ fileBuffer.append("VOID\n");
fileBuffer.append("EFIAPI\n");
- fileBuffer.append(setVirtualList[i]);
- fileBuffer.append(" (\r\n");
- fileBuffer.append(" IN EFI_EVENT Event,\r\n");
- fileBuffer.append(" IN VOID *Context\r\n");
- fileBuffer.append(" );\r\n\r\n");
- }
-
- //
- // Write SetVirtualAddressMap entry point array.
- //
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
- for (i = 0; i < setVirtualList.length; i++) {
- if (setVirtualList[i].equalsIgnoreCase("")) {
- break;
- }
-
- if (i == 0) {
- fileBuffer.append("\r\n ");
+ fileBuffer.append("ExitDriver (\r\n");
+ fileBuffer.append(" IN EFI_STATUS Status\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ if (entryPointCount <= 1) {
+ fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
+ fileBuffer
+ .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
+ fileBuffer.append(" }\r\n");
+ fileBuffer
+ .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
} else {
- fileBuffer.append(",\r\n ");
+ fileBuffer
+ .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
+ fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n");
+ fileBuffer.append(" }\r\n");
+ fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
+ fileBuffer.append(" ASSERT (FALSE);\r\n");
}
+ fileBuffer.append("}\r\n\r\n");
- fileBuffer.append(setVirtualList[i]);
}
- if (Count == 0) {
- fileBuffer.append("\r\n NULL");
- }
- fileBuffer.append("\r\n};\r\n\r\n");
- }
-
- if (UefiOrDxeModule) {
- //
- // Entry point lib for these module types needs to know the count.
- //
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
-
+
+ //
+ // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
+ //
+ entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
//
- // If the list is not valid or has no entries set count to zero else
- // set count to the number of valid entries.
+ // Remover duplicate unload entry point.
//
- Count = 0;
- if (exitBootList != null) {
- if (setVirtualList != null) {
- for (i = 0; i < exitBootList.length; i++) {
- if (exitBootList[i].equalsIgnoreCase("")) {
- break;
+ entryPointList = CommonDefinition.remDupString(entryPointList);
+ entryPointCount = 0;
+ if (entryPointList != null) {
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" );\r\n");
+ entryPointCount++;
+ } else {
+ break;
+ }
+ }
+ }
+
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
+ fileBuffer.append(Integer.toString(entryPointCount));
+ fileBuffer.append(";\r\n\r\n");
+
+ if (entryPointList != null) {
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" );\r\n");
+ } else {
+ break;
+ }
+ }
+ }
+
+ fileBuffer.append("EFI_STATUS\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleUnloadList (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" )\r\n");
+ fileBuffer.append("{\r\n");
+
+ if (entryPointCount == 0) {
+ fileBuffer.append(" return EFI_SUCCESS;\r\n");
+ } else if (entryPointCount == 1) {
+ fileBuffer.append(" return ");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ } else {
+ fileBuffer.append(" EFI_STATUS Status;\r\n\r\n");
+ fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n");
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
+ fileBuffer.append(" ");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ fileBuffer.append(" } else {\r\n");
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ fileBuffer.append(" }\r\n");
+ } else {
+ break;
+ }
+ }
+ fileBuffer.append(" return Status;\r\n");
+ }
+ fileBuffer.append("}\r\n\r\n");
+ break;
+ }
+ }
+
+ /**
+ * PpiGuidToAutogenc
+ *
+ * This function gets GUIDs from SPD file accrodeing to <PPIs> information
+ * and write those GUIDs to AutoGen.c.
+ *
+ * @param fileBuffer
+ * String Buffer for Autogen.c file.
+ * @throws BuildException
+ * Guid must set value!
+ */
+ void PpiGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {
+ String[] cNameGuid = null;
+
+ //
+ // Get the all PPI adn PPI Notify from MSA file,
+ // then add those PPI ,and PPI Notify name to list.
+ //
+
+ String[] ppiList = SurfaceAreaQuery.getPpiArray(this.arch);
+ for (int i = 0; i < ppiList.length; i++) {
+ this.mPpiList.add(ppiList[i]);
+ }
+
+ String[] ppiNotifyList = SurfaceAreaQuery.getPpiNotifyArray(this.arch);
+ for (int i = 0; i < ppiNotifyList.length; i++) {
+ this.mPpiList.add(ppiNotifyList[i]);
+ }
+
+ //
+ // Find CNAME and GUID from dependence SPD file and write to Autogen.c
+ //
+ Iterator ppiIterator = this.mPpiList.iterator();
+ String ppiKeyWord = null;
+ while (ppiIterator.hasNext()) {
+ ppiKeyWord = ppiIterator.next().toString();
+ cNameGuid = GlobalData.getPpiGuid(this.mDepPkgList, ppiKeyWord);
+ if (cNameGuid != null) {
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
+ fileBuffer.append(cNameGuid[0]);
+ fileBuffer.append(" = { ");
+ fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));
+ fileBuffer.append(" } ;");
+ } else {
+ //
+ // If can't find Ppi GUID declaration in every package
+ //
+ throw new AutoGenException("Can not find Ppi GUID ["
+ + ppiKeyWord + "] declaration in every packages. ");
+ }
+ }
+ }
+
+ /**
+ * ProtocolGuidToAutogenc
+ *
+ * This function gets GUIDs from SPD file accrodeing to <Protocol>
+ * information and write those GUIDs to AutoGen.c.
+ *
+ * @param fileBuffer
+ * String Buffer for Autogen.c file.
+ * @throws BuildException
+ * Protocol name must set.
+ */
+ void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws BuildException {
+ String[] cNameGuid = null;
+
+ String[] protocolList = SurfaceAreaQuery.getProtocolArray(this.arch);
+
+ //
+ // Add result to Autogen global list.
+ //
+ for (int i = 0; i < protocolList.length; i++) {
+ this.mProtocolList.add(protocolList[i]);
+ }
+
+ String[] protocolNotifyList = SurfaceAreaQuery
+ .getProtocolNotifyArray(this.arch);
+
+ for (int i = 0; i < protocolNotifyList.length; i++) {
+ this.mProtocolList.add(protocolNotifyList[i]);
+ }
+
+ //
+ // Get the NAME and GUID from dependence SPD and write to Autogen.c
+ //
+ Iterator protocolIterator = this.mProtocolList.iterator();
+ String protocolKeyWord = null;
+
+
+ while (protocolIterator.hasNext()) {
+ protocolKeyWord = protocolIterator.next().toString();
+ cNameGuid = GlobalData.getProtocolGuid(this.mDepPkgList, protocolKeyWord);
+ if (cNameGuid != null) {
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
+ fileBuffer.append(cNameGuid[0]);
+ fileBuffer.append(" = { ");
+ fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));
+ fileBuffer.append(" } ;");
+ } else {
+ //
+ // If can't find protocol GUID declaration in every package
+ //
+ throw new BuildException("Can not find protocol Guid ["
+ + protocolKeyWord + "] declaration in every packages. ");
+ }
+ }
+ }
+
+ /**
+ * GuidGuidToAutogenc
+ *
+ * This function gets GUIDs from SPD file accrodeing to <Guids> information
+ * and write those GUIDs to AutoGen.c.
+ *
+ * @param fileBuffer
+ * String Buffer for Autogen.c file.
+ *
+ */
+ void GuidGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {
+ String[] cNameGuid = null;
+ String guidKeyWord = null;
+
+ String[] guidList = SurfaceAreaQuery.getGuidEntryArray(this.arch);
+
+ for (int i = 0; i < guidList.length; i++) {
+ this.mGuidList.add(guidList[i]);
+ }
+
+
+ Iterator guidIterator = this.mGuidList.iterator();
+ while (guidIterator.hasNext()) {
+ guidKeyWord = guidIterator.next().toString();
+ cNameGuid = GlobalData.getGuid(this.mDepPkgList, guidKeyWord);
+
+ if (cNameGuid != null) {
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
+ fileBuffer.append(cNameGuid[0]);
+ fileBuffer.append(" = { ");
+ fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));
+ fileBuffer.append("} ;");
+ } else {
+ //
+ // If can't find GUID declaration in every package
+ //
+ throw new AutoGenException("Can not find Guid [" + guidKeyWord
+ + "] declaration in every packages. ");
+ }
+
+ }
+ }
+
+ /**
+ * LibInstanceToAutogenC
+ *
+ * This function adds dependent library instance to autogen.c,which
+ * includeing library's constructor, destructor, and library dependent ppi,
+ * protocol, guid, pcd information.
+ *
+ * @param fileBuffer
+ * String buffer for AutoGen.c
+ * @throws BuildException
+ */
+ void LibInstanceToAutogenC(StringBuffer fileBuffer) throws BuildException {
+ int index;
+
+ String moduleType = SurfaceAreaQuery.getModuleType();
+ List<String> libConstructList = new ArrayList<String>();
+ List<String> libDestructList = new ArrayList<String>();
+
+ String libConstructName = null;
+ String libDestructName = null;
+ ModuleIdentification[] libraryIdList = SurfaceAreaQuery
+ .getLibraryInstance(this.arch);
+
+ try {
+ if (libraryIdList != null) {
+ //
+ // Reorder library instance sequence.
+ //
+ AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList,
+ this.arch);
+ List<ModuleIdentification> orderList = libOrder
+ .orderLibInstance();
+
+ if (orderList != null) {
+ //
+ // Process library instance one by one.
+ //
+ for (int i = 0; i < orderList.size(); i++) {
+
+ //
+ // Get library instance basename.
+ //
+ ModuleIdentification libInstanceId = orderList.get(i);
+
+ //
+ // Get override map
+ //
+
+ Map<String, XmlObject> libDoc = GlobalData.getDoc(
+ libInstanceId, this.arch);
+ SurfaceAreaQuery.push(libDoc);
+
+ //
+ // Get <PPis>, <Protocols>, <Guids> list of this library
+ // instance.
+ //
+ String[] ppiList = SurfaceAreaQuery.getPpiArray(this.arch);
+ String[] ppiNotifyList = SurfaceAreaQuery
+ .getPpiNotifyArray(this.arch);
+ String[] protocolList = SurfaceAreaQuery
+ .getProtocolArray(this.arch);
+ String[] protocolNotifyList = SurfaceAreaQuery
+ .getProtocolNotifyArray(this.arch);
+ String[] guidList = SurfaceAreaQuery
+ .getGuidEntryArray(this.arch);
+ PackageIdentification[] pkgList = SurfaceAreaQuery.getDependencePkg(this.arch);
+
+ //
+ // Add those ppi, protocol, guid in global ppi,
+ // protocol, guid
+ // list.
+ //
+ for (index = 0; index < ppiList.length; index++) {
+ this.mPpiList.add(ppiList[index]);
+ }
+
+ for (index = 0; index < ppiNotifyList.length; index++) {
+ this.mPpiList.add(ppiNotifyList[index]);
+ }
+
+ for (index = 0; index < protocolList.length; index++) {
+ this.mProtocolList.add(protocolList[index]);
+ }
+
+ for (index = 0; index < protocolNotifyList.length; index++) {
+ this.mProtocolList.add(protocolNotifyList[index]);
+ }
+
+ for (index = 0; index < guidList.length; index++) {
+ this.mGuidList.add(guidList[index]);
+ }
+ for (index = 0; index < pkgList.length; index++){
+ if (!this.mDepPkgList.contains(pkgList[index])){
+ this.mDepPkgList.add(pkgList[index]);
+ }
}
- }
- Count = i;
- }
- }
- fileBuffer.append(Integer.toString(Count));
- fileBuffer.append(";\r\n\r\n");
- }
- if (exitBootList == null) {
- if (UefiOrDxeModule) {
- //
- // No data so make a NULL list.
- //
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
- fileBuffer.append(" NULL\r\n");
- fileBuffer.append("};\r\n\r\n");
- }
- } else {
+ //
+ // If not yet parse this library instance's constructor
+ // element,parse it.
+ //
+ libConstructName = SurfaceAreaQuery
+ .getLibConstructorName();
+ libDestructName = SurfaceAreaQuery
+ .getLibDestructorName();
+
+ SurfaceAreaQuery.pop();
+ //
+ // Add dependent library instance constructor function.
+ //
+ if (libConstructName != null) {
+ libConstructList.add(libConstructName);
+ }
+ //
+ // Add dependent library instance destructor fuction.
+ //
+ if (libDestructName != null) {
+ libDestructList.add(libDestructName);
+ }
+ }
+
+ }
+
+ //
+ // Add library constructor to AutoGen.c
+ //
+ LibConstructorToAutogenC(libConstructList, moduleType,
+ fileBuffer/* autogenC */);
+ //
+ // Add library destructor to AutoGen.c
+ //
+ LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);
+ }
+
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+ }
+
+ /**
+ * LibConstructorToAutogenc
+ *
+ * This function writes library constructor list to AutoGen.c. The library
+ * constructor's parameter and return value depend on module type.
+ *
+ * @param libInstanceList
+ * List of library construct name.
+ * @param moduleType
+ * Module type.
+ * @param fileBuffer
+ * String buffer for AutoGen.c
+ * @throws Exception
+ */
+ void LibConstructorToAutogenC(List<String> libInstanceList,
+ String moduleType, StringBuffer fileBuffer) throws Exception {
+ boolean isFirst = true;
+
+ //
+ // The library constructor's parameter and return value depend on
+ // module type.
+ //
+ for (int i = 0; i < libInstanceList.size(); i++) {
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeBase:
+ fileBuffer.append("RETURN_STATUS\r\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" VOID\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypePeiCore:
+ case CommonDefinition.ModuleTypePeim:
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+ }
+ }
+
+ //
+ // Add ProcessLibraryConstructorList in AutoGen.c
+ //
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("ProcessLibraryConstructorList (\r\n");
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeBase:
+ fileBuffer.append(" VOID\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypePeiCore:
+ case CommonDefinition.ModuleTypePeim:
+ fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
+ break;
+ }
+
+ fileBuffer.append(" )\r\n");
+ fileBuffer.append("{\r\n");
+ //
+ // If no constructor function, return EFI_SUCCESS.
+ //
+ //if (libInstanceList.size() == 0){
+ // fileBuffer.append(" return EFI_SUCCESS;\r\n");
+ //}
+ for (int i = 0; i < libInstanceList.size(); i++) {
+ if (isFirst) {
+ fileBuffer.append(" EFI_STATUS Status;\r\n");
+ fileBuffer.append(" Status = EFI_SUCCESS;\r\n");
+ fileBuffer.append("\r\n");
+ isFirst = false;
+ }
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeBase:
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append("();\r\n");
+ fileBuffer.append(" VOID\r\n");
+ break;
+ case CommonDefinition.ModuleTypePeiCore:
+ case CommonDefinition.ModuleTypePeim:
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (FfsHeader, PeiServices);\r\n");
+ break;
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (ImageHandle, SystemTable);\r\n");
+ break;
+ default:
+ EdkLog.log(EdkLog.EDK_INFO,"Autogen don't know how to deal with module type -"+ moduleType + " !");
+ }
+ fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n");
+ }
+ fileBuffer.append("}\r\n");
+ }
+
+ /**
+ * LibDestructorToAutogenc
+ *
+ * This function writes library destructor list to AutoGen.c. The library
+ * destructor's parameter and return value depend on module type.
+ *
+ * @param libInstanceList
+ * List of library destructor name.
+ * @param moduleType
+ * Module type.
+ * @param fileBuffer
+ * String buffer for AutoGen.c
+ * @throws Exception
+ */
+ void LibDestructorToAutogenC(List<String> libInstanceList,
+ String moduleType, StringBuffer fileBuffer) throws Exception {
+ boolean isFirst = true;
+ for (int i = 0; i < libInstanceList.size(); i++) {
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeBase:
+ fileBuffer.append("RETURN_STATUS\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" VOID\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+ case CommonDefinition.ModuleTypePeiCore:
+ case CommonDefinition.ModuleTypePeim:
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+ }
+ }
+
+ //
+ // Write ProcessLibraryDestructor list to autogen.c
+ //
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeBase:
+ case CommonDefinition.ModuleTypePeiCore:
+ case CommonDefinition.ModuleTypePeim:
+ break;
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("ProcessLibraryDestructorList (\r\n");
+ fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" )\r\n");
+ fileBuffer.append("{\r\n");
//
- // Write DriverExitBootServices function definition.
+ // If no library destructor function, return EFI_SUCCESS.
//
- for (i = 0; i < exitBootList.length; i++) {
- if (exitBootList[i].equalsIgnoreCase("")) {
- break;
- }
-
- fileBuffer.append("VOID\r\n");
- fileBuffer.append("EFIAPI\n");
- fileBuffer.append(exitBootList[i]);
- fileBuffer.append(" (\r\n");
- fileBuffer.append(" IN EFI_EVENT Event,\r\n");
- fileBuffer.append(" IN VOID *Context\r\n");
- fileBuffer.append(" );\r\n\r\n");
- }
-
- //
- // Write DriverExitBootServices entry point array.
- //
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
- for (i = 0; i < exitBootList.length; i++) {
- if (exitBootList[i].equalsIgnoreCase("")) {
- break;
- }
-
- if (i == 0) {
- fileBuffer.append("\r\n ");
- } else {
- fileBuffer.append(",\r\n ");
- }
- fileBuffer.append(exitBootList[i]);
- }
- if (Count == 0) {
- fileBuffer.append("\r\n NULL");
- }
- fileBuffer.append("\r\n};\r\n\r\n");
- }
-
- }
+
+ for (int i = 0; i < libInstanceList.size(); i++) {
+ if (isFirst) {
+ fileBuffer.append(" EFI_STATUS Status;\r\n");
+ fileBuffer.append(" Status = EFI_SUCCESS;\r\n");
+ fileBuffer.append("\r\n");
+ isFirst = false;
+ }
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append("(ImageHandle, SystemTable);\r\n");
+ fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n");
+ }
+ fileBuffer.append("}\r\n");
+ break;
+ }
+ }
+
+ /**
+ * ExternsDriverBindingToAutoGenC
+ *
+ * This function is to write DRIVER_BINDING, COMPONENT_NAME,
+ * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
+ *
+ * @param fileBuffer
+ * String buffer for AutoGen.c
+ */
+ void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer)
+ throws BuildException {
+
+ //
+ // Check what <extern> contains. And the number of following elements
+ // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
+ // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
+ //
+
+ String[] drvBindList = SurfaceAreaQuery.getDriverBindingArray();
+
+ //
+ // If component name protocol,component configuration protocol,
+ // component diagnostic protocol is not null or empty, check
+ // if every one have the same number of the driver binding protocol.
+ //
+ if (drvBindList == null || drvBindList.length == 0) {
+ return;
+ }
+
+ String[] compNamList = SurfaceAreaQuery.getComponentNameArray();
+ String[] compConfList = SurfaceAreaQuery.getDriverConfigArray();
+ String[] compDiagList = SurfaceAreaQuery.getDriverDiagArray();
+
+ int BitMask = 0;
+
+ //
+ // Write driver binding protocol extern to autogen.c
+ //
+ for (int i = 0; i < drvBindList.length; i++) {
+ fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
+ fileBuffer.append(drvBindList[i]);
+ fileBuffer.append(";\r\n");
+ }
+
+ //
+ // Write component name protocol extern to autogen.c
+ //
+ if (compNamList != null && compNamList.length != 0) {
+ if (drvBindList.length != compNamList.length) {
+ throw new BuildException(
+ "Different number of Driver Binding and Component Name protocols!");
+ }
+
+ BitMask |= 0x01;
+ for (int i = 0; i < compNamList.length; i++) {
+ fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
+ fileBuffer.append(compNamList[i]);
+ fileBuffer.append(";\r\n");
+ }
+ }
+
+ //
+ // Write driver configration protocol extern to autogen.c
+ //
+ if (compConfList != null && compConfList.length != 0) {
+ if (drvBindList.length != compConfList.length) {
+ throw new BuildException(
+ "Different number of Driver Binding and Driver Configuration protocols!");
+ }
+
+ BitMask |= 0x02;
+ for (int i = 0; i < compConfList.length; i++) {
+ fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
+ fileBuffer.append(compConfList[i]);
+ fileBuffer.append(";\r\n");
+ }
+ }
+
+ //
+ // Write driver dignastic protocol extern to autogen.c
+ //
+ if (compDiagList != null && compDiagList.length != 0) {
+ if (drvBindList.length != compDiagList.length) {
+ throw new BuildException(
+ "Different number of Driver Binding and Driver Configuration protocols!");
+ }
+
+ BitMask |= 0x04;
+ for (int i = 0; i < compDiagList.length; i++) {
+ fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
+ fileBuffer.append(compDiagList[i]);
+ fileBuffer.append(";\r\n");
+ }
+ }
+
+ //
+ // Write driver module protocol bitmask.
+ //
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
+ fileBuffer.append(Integer.toString(BitMask));
+ fileBuffer.append(";\r\n");
+
+ //
+ // Write driver module protocol list entry
+ //
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
+
+ fileBuffer.append(Integer.toString(drvBindList.length));
+ fileBuffer.append(";\r\n");
+
+ //
+ // Write drive module protocol list to autogen.c
+ //
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
+ for (int i = 0; i < drvBindList.length; i++) {
+ if (i != 0) {
+ fileBuffer.append(",");
+ }
+ fileBuffer.append("\r\n {\r\n");
+ fileBuffer.append(" &");
+ fileBuffer.append(drvBindList[i]);
+ fileBuffer.append(", \r\n");
+
+ if (compNamList != null) {
+ fileBuffer.append(" &");
+ fileBuffer.append(compNamList[i]);
+ fileBuffer.append(", \r\n");
+ } else {
+ fileBuffer.append(" NULL, \r\n");
+ }
+
+ if (compConfList != null) {
+ fileBuffer.append(" &");
+ fileBuffer.append(compConfList[i]);
+ fileBuffer.append(", \r\n");
+ } else {
+ fileBuffer.append(" NULL, \r\n");
+ }
+
+ if (compDiagList != null) {
+ fileBuffer.append(" &");
+ fileBuffer.append(compDiagList[i]);
+ fileBuffer.append(", \r\n");
+ } else {
+ fileBuffer.append(" NULL, \r\n");
+ }
+ fileBuffer.append(" }");
+ }
+ fileBuffer.append("\r\n};\r\n");
+ }
+
+ /**
+ * ExternCallBackToAutoGenC
+ *
+ * This function adds <SetVirtualAddressMapCallBack> and
+ * <ExitBootServicesCallBack> infomation to AutoGen.c
+ *
+ * @param fileBuffer
+ * String buffer for AutoGen.c
+ * @throws BuildException
+ */
+ void ExternCallBackToAutoGenC(StringBuffer fileBuffer)
+ throws BuildException {
+ String[] setVirtualList = SurfaceAreaQuery
+ .getSetVirtualAddressMapCallBackArray();
+ String[] exitBootList = SurfaceAreaQuery
+ .getExitBootServicesCallBackArray();
+ String moduleType = SurfaceAreaQuery.getModuleType();
+ boolean UefiOrDxeModule = false;
+ int Count = 0;
+ int i;
+
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ //
+ // Entry point lib for these module types needs to know the count
+ // of entryPoint.
+ //
+ UefiOrDxeModule = true;
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
+
+ //
+ // If the list is not valid or has no entries set count to zero else
+ // set count to the number of valid entries
+ //
+ Count = 0;
+ if (setVirtualList != null) {
+ for (i = 0; i < setVirtualList.length; i++) {
+ if (setVirtualList[i].equalsIgnoreCase("")) {
+ break;
+ }
+ }
+ Count = i;
+ }
+
+ fileBuffer.append(Integer.toString(Count));
+ fileBuffer.append(";\r\n\r\n");
+ break;
+ default:
+ break;
+ }
+
+ if (setVirtualList == null) {
+ if (UefiOrDxeModule) {
+ //
+ // No data so make a NULL list
+ //
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
+ fileBuffer.append(" NULL\r\n");
+ fileBuffer.append("};\r\n\r\n");
+ }
+ } else {
+ //
+ // Write SetVirtualAddressMap function definition.
+ //
+ for (i = 0; i < setVirtualList.length; i++) {
+ if (setVirtualList[i].equalsIgnoreCase("")) {
+ break;
+ }
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(setVirtualList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" IN EFI_EVENT Event,\r\n");
+ fileBuffer.append(" IN VOID *Context\r\n");
+ fileBuffer.append(" );\r\n\r\n");
+ }
+
+ //
+ // Write SetVirtualAddressMap entry point array.
+ //
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
+ for (i = 0; i < setVirtualList.length; i++) {
+ if (setVirtualList[i].equalsIgnoreCase("")) {
+ break;
+ }
+
+ if (i == 0) {
+ fileBuffer.append("\r\n ");
+ } else {
+ fileBuffer.append(",\r\n ");
+ }
+
+ fileBuffer.append(setVirtualList[i]);
+ }
+ //
+ // If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER
+ // UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of
+ // _gDriverSetVirtualAddressMapEvent list.
+ //
+ if (!UefiOrDxeModule) {
+ fileBuffer.append(",\r\n NULL");
+ }
+ fileBuffer.append("\r\n};\r\n\r\n");
+ }
+
+ if (UefiOrDxeModule) {
+ //
+ // Entry point lib for these module types needs to know the count.
+ //
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
+
+ //
+ // If the list is not valid or has no entries set count to zero else
+ // set count to the number of valid entries.
+ //
+ Count = 0;
+ if (exitBootList != null) {
+ if (setVirtualList != null) {
+ for (i = 0; i < exitBootList.length; i++) {
+ if (exitBootList[i].equalsIgnoreCase("")) {
+ break;
+ }
+ }
+ Count = i;
+ }
+ }
+ fileBuffer.append(Integer.toString(Count));
+ fileBuffer.append(";\r\n\r\n");
+ }
+
+ if (exitBootList == null) {
+ if (UefiOrDxeModule) {
+ //
+ // No data so make a NULL list.
+ //
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
+ fileBuffer.append(" NULL\r\n");
+ fileBuffer.append("};\r\n\r\n");
+ }
+ } else {
+ //
+ // Write DriverExitBootServices function definition.
+ //
+ for (i = 0; i < exitBootList.length; i++) {
+ if (exitBootList[i].equalsIgnoreCase("")) {
+ break;
+ }
+
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(exitBootList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" IN EFI_EVENT Event,\r\n");
+ fileBuffer.append(" IN VOID *Context\r\n");
+ fileBuffer.append(" );\r\n\r\n");
+ }
+
+ //
+ // Write DriverExitBootServices entry point array.
+ //
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
+ for (i = 0; i < exitBootList.length; i++) {
+ if (exitBootList[i].equalsIgnoreCase("")) {
+ break;
+ }
+
+ if (i == 0) {
+ fileBuffer.append("\r\n ");
+ } else {
+ fileBuffer.append(",\r\n ");
+ }
+ fileBuffer.append(exitBootList[i]);
+ }
+ if (!UefiOrDxeModule) {
+ fileBuffer.append(",\r\n NULL");
+ }
+ fileBuffer.append("\r\n};\r\n\r\n");
+ }
+
+ }
} \ No newline at end of file
diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java
index f449cb3..ad245ed 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java
@@ -15,6 +15,10 @@
**/
package org.tianocore.build.autogen;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
/**
CommonDefinition
@@ -149,7 +153,7 @@ public class CommonDefinition {
new MyEnum("PEI_CORE", ModuleTypePeiCore),
new MyEnum("PEIM", ModuleTypePeim),
new MyEnum("DXE_CORE", ModuleTypeDxeCore),
- new MyEnum("DXE_DRIVER", ModuleTypeDxeRuntimeDriver),
+ new MyEnum("DXE_DRIVER", ModuleTypeDxeDriver),
new MyEnum("DXE_RUNTIME_DRIVER", ModuleTypeDxeRuntimeDriver),
new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver),
new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),
@@ -315,4 +319,32 @@ public class CommonDefinition {
}
}
+ /**
+ * Remove deuplicat string in list
+ *
+ * This function is to duplicat string in list
+ *
+ * @param String[]
+ * String list.
+ * @return String[] String list which remove the duplicate string.
+ */
+ public static String[] remDupString (String[] orgList){
+ Set<String> strList = new HashSet<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;
+ }
+
} \ No newline at end of file
diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/GenBuildException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/GenBuildException.java
index ac75ca8..7ae0580 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/exception/GenBuildException.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/exception/GenBuildException.java
@@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.build.exception;
-import org.tianocore.build.exception.EdkException;
+import org.tianocore.exception.EdkException;
/**
The class handle the exception throwed by entity class.
@@ -35,6 +35,6 @@ public class GenBuildException extends EdkException {
super();
}
public GenBuildException(Exception e, String message){
-// super(e, message);
+ super(e, message);
}
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java
index 3ab2fcf..2daa871 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java
@@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.build.exception;
-import org.tianocore.build.exception.EdkException;
+import org.tianocore.exception.EdkException;
/**
The class handle the exception throwed by entity class.
@@ -36,6 +36,6 @@ public class TianoToolsException extends EdkException {
}
public TianoToolsException (Exception e, String message){
-// super(e, message);
+ super(e, message);
}
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
index 59bb47f..5d829c9 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
@@ -33,16 +33,19 @@ import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.taskdefs.Property;
import org.apache.xmlbeans.XmlObject;
-import org.tianocore.build.exception.EdkException;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.OutputManager;
import org.tianocore.build.global.SurfaceAreaQuery;
import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PlatformIdentification;
+import org.tianocore.build.pcd.action.ActionMessage;
+import org.tianocore.build.pcd.action.CollectPCDAction;
+import org.tianocore.build.pcd.exception.EntityException;
import org.tianocore.build.toolchain.ToolChainAttribute;
import org.tianocore.build.toolchain.ToolChainElement;
import org.tianocore.build.toolchain.ToolChainMap;
+import org.tianocore.exception.EdkException;
/**
<code>FpdParserTask</code> is an ANT task. The main function is parsing Framework
@@ -146,6 +149,18 @@ public class FpdParserTask extends Task {
parseFpdFile();
//
+ // Pcd Collection. Call CollectPCDAction to collect pcd info.
+ //
+ try {
+ System.out.println("Begin PCD collecttion!");
+ CollectPCDAction ca = new CollectPCDAction();
+ ca.perform(GlobalData.getWorkspacePath(),platformId.getFpdFile().getPath(),ActionMessage.NULL_MESSAGE_LEVEL);
+ System.out.println("End PCD collection!");
+ } catch (Exception e){
+ throw new BuildException(e.getMessage());
+ }
+
+ //
// Prepare BUILD_DIR
//
isUnified = OutputManager.getInstance().prepareBuildDir(getProject());
@@ -187,6 +202,7 @@ public class FpdParserTask extends Task {
//
// Ant call ${PLATFORM}_build.xml
//
+
Ant ant = new Ant();
ant.setProject(getProject());
ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");
@@ -391,7 +407,7 @@ public class FpdParserTask extends Task {
**/
private void parseModuleSAFiles() throws EdkException{
Map<FpdModuleIdentification, Map<String, XmlObject>> moduleSAs = SurfaceAreaQuery.getFpdModules();
- System.out.println("Nubmer: ##" + moduleSAs.size());
+
//
// For every Module lists in FPD file.
//
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
index 99cccc3..e843362 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
@@ -21,20 +21,21 @@ import org.apache.xmlbeans.XmlObject;
import org.tianocore.DbPathAndFilename;
import org.tianocore.FrameworkDatabaseDocument;
import org.tianocore.ModuleSurfaceAreaDocument;
+import org.tianocore.PcdBuildDefinitionDocument;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
-import org.tianocore.build.exception.EdkException;
import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification;
import org.tianocore.build.id.PlatformIdentification;
+import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
import org.tianocore.build.toolchain.ToolChainAttribute;
import org.tianocore.build.toolchain.ToolChainConfig;
import org.tianocore.build.toolchain.ToolChainElement;
import org.tianocore.build.toolchain.ToolChainInfo;
import org.tianocore.build.toolchain.ToolChainKey;
import org.tianocore.build.toolchain.ToolChainMap;
-//import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
-//import org.tianocore.logger.EdkLog;
+import org.tianocore.exception.EdkException;
+import org.tianocore.logger.EdkLog;
import java.io.File;
import java.util.HashMap;
@@ -130,7 +131,7 @@ public class GlobalData {
private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainOption = new HashMap<FpdModuleIdentification, ToolChainMap>();
private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainFamilyOption = new HashMap<FpdModuleIdentification, ToolChainMap>();
-// private static final MemoryDatabasseManager pcdDbManager = new MemoryDatabaseManager();
+ private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();
@@ -341,7 +342,7 @@ public class GlobalData {
//
// First part: get the MSA files info
//
- doc = getNativeMsa(moduleId);
+ doc.putAll(getNativeMsa(moduleId));
//
// Second part: put build options
@@ -413,6 +414,7 @@ public class GlobalData {
msaMap.put("PPIs", cloneXmlObject(msa.getPPIs(), true));
msaMap.put("Guids", cloneXmlObject(msa.getGuids(), true));
msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true));
+ msaMap.put("PcdCoded", cloneXmlObject(msa.getPcdCoded(), true));
return msaMap;
}
catch (Exception ex){
@@ -507,15 +509,16 @@ public class GlobalData {
/**
* return two values: {cName, GuidValue}
*/
- public static String[] getGuid(PackageIdentification[] packages, String name)
+ public static String[] getGuid(List<PackageIdentification> packages, String name)
throws BuildException {
if (packages == null) {
// throw Exception or not????
return new String[0];
}
String[] result = null;
- for (int i = 0; i < packages.length; i++) {
- Spd spd = spdTable.get(packages[i]);
+ Iterator item = packages.iterator();
+ while (item.hasNext()){
+ Spd spd = spdTable.get(item.next());
//
// If find one package defined the GUID
//
@@ -523,20 +526,22 @@ public class GlobalData {
return result;
}
}
+
return null;
}
/**
* return two values: {cName, GuidValue}
*/
- public static String[] getPpiGuid(PackageIdentification[] packages,
+ public static String[] getPpiGuid(List<PackageIdentification> packages,
String name) throws BuildException {
if (packages == null) {
return new String[0];
}
String[] result = null;
- for (int i = 0; i < packages.length; i++) {
- Spd spd = spdTable.get(packages[i]);
+ Iterator item = packages.iterator();
+ while (item.hasNext()){
+ Spd spd = spdTable.get(item.next());
//
// If find one package defined the Ppi GUID
//
@@ -551,18 +556,19 @@ public class GlobalData {
/**
* return two values: {cName, GuidValue}
*/
- public static String[] getProtocolGuid(PackageIdentification[] packages,
+ public static String[] getProtocolGuid(List<PackageIdentification> packages,
String name) throws BuildException {
if (packages == null) {
return new String[0];
}
String[] result = null;
- for (int i = 0; i < packages.length; i++) {
- Spd spd = spdTable.get(packages[i]);
+ Iterator item = packages.iterator();
+ while (item.hasNext()){
+ Spd spd = spdTable.get(item.next());
//
// If find one package defined the protocol GUID
//
- if ((result = spd.getProtocol(name)) != null) {
+ if ((result = spd.getProtocol(name))!= null){
return result;
}
}
@@ -750,52 +756,61 @@ public class GlobalData {
//
// for PCD
//
-// public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {
-// return pcdDbManager;
-// }
+ public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {
+ return pcdDbManager;
+ }
//
- // For PCD
+ // For PCD get tokenSpaceGUid
//
- /**
- *
- * @param guidName
- * @return
- */
-// public synchronized static String[] getGuidInfoGuid(String guidName) {
-// String[] cNameGuid = null;
-// Set set = spdTable.keySet();
-// Iterator iter = set.iterator();
-//
-// while (iter.hasNext()) {
-// Spd spd = (Spd) spdTable.get(iter.next());
-// cNameGuid = spd.getGuidNameArray(guidName);
-// if (cNameGuid != null) {
-// break;
-// }
-// }
-// return cNameGuid;
-// }
+ public synchronized static String[] getGuidInfoFromCname(String cName){
+ String cNameGuid[] = null;
+ String guid = null;
+ Set set = spdTable.keySet();
+ Iterator iter = set.iterator();
+
+ while (iter.hasNext()){
+ Spd spd = (Spd) spdTable.get(iter.next());
+ guid = spd.getGuidFromCname(cName);
+ if (guid != null){
+ cNameGuid[0] = new String(cName);
+ cNameGuid[1] = new String(guid);
+ break;
+ }
+ }
+ return cNameGuid;
+ }
//
// For PCD
//
-// public synchronized static Map<FpdModuleIdentification, XmlObject> getFpdModuleSaXmlObject(
-// String xmlObjectName) {
-// Set<FpdModuleIdentification> fpdModuleSASet = fpdModuleSA.keySet();
-// Iterator item = fpdModuleSASet.iterator();
-//
-// Map<FpdModuleIdentification, XmlObject> SAPcdBuildDef = new HashMap<FpdModuleIdentification, XmlObject>();
-// Map<String, XmlObject> SANode = new HashMap<String, XmlObject>();
-// FpdModuleIdentification moduleId;
-// while (item.hasNext()) {
-// moduleId = (FpdModuleIdentification) item.next();
-// SANode = fpdModuleSA.get(item.next());
-// SAPcdBuildDef.put(moduleId,
-// (PcdBuildDefinitionDocument.PcdBuildDefinition) SANode
-// .get(xmlObjectName));
-// }
-// return SAPcdBuildDef;
-// }
+ public synchronized static Map<FpdModuleIdentification, XmlObject> getFpdModuleSaXmlObject(
+ String xmlObjectName) {
+ Set<FpdModuleIdentification> fpdModuleSASet = fpdModuleSA.keySet();
+ Iterator item = fpdModuleSASet.iterator();
+
+
+ Map<FpdModuleIdentification, XmlObject> SAPcdBuildDef = new HashMap<FpdModuleIdentification, XmlObject>();
+ Map<String, XmlObject> SANode = new HashMap<String, XmlObject>();
+ FpdModuleIdentification moduleId;
+ while (item.hasNext()) {
+
+ moduleId = (FpdModuleIdentification) item.next();
+ SANode = fpdModuleSA.get(moduleId);
+ try{
+ if (SANode.get(xmlObjectName)!= null){
+ SAPcdBuildDef.put(moduleId,
+ (XmlObject) SANode
+ .get(xmlObjectName));
+
+ }
+
+
+ } catch (Exception e){
+ EdkLog.log(EdkLog.EDK_INFO, e.getMessage());
+ }
+ }
+ return SAPcdBuildDef;
+ }
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/Spd.java b/Tools/Source/GenBuild/org/tianocore/build/global/Spd.java
index ddc851d..3e09f58 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/global/Spd.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/Spd.java
@@ -66,6 +66,12 @@ public class Spd {
Map<String, String[]> guidInfo = new HashMap<String, String[]>();
///
+ /// Map of Guid info
+ /// Key: GuidCName
+ /// value: String Guid's GUID
+ ///
+ Map<String, String> guidCnameInfo = new HashMap<String, String>();
+
/// Map of library class and its exposed header file.
/// Key : library class name
/// value : library class corresponding header file
@@ -140,7 +146,7 @@ public class Spd {
// Change path seperator to system-dependent path separator
//
File file = new File (header);
- header = file.getParent();
+ header = file.getPath();
packageHeaderInfo.put(moduleType, header);
}
@@ -150,6 +156,17 @@ public class Spd {
guidInfo.putAll(SurfaceAreaQuery.getSpdGuid());
//
+ // For Pcd get TokenSpaceGuid
+ //
+ Set<String> key = guidInfo.keySet();
+ Iterator item = key.iterator();
+ String [] nameValue = new String[2];
+ while(item.hasNext()){
+ nameValue = guidInfo.get(item.next());
+ guidCnameInfo.put(nameValue[0], nameValue[1]);
+ }
+
+ //
// initialize PPI info
//
ppiInfo.putAll(SurfaceAreaQuery.getSpdPpi());
@@ -221,6 +238,13 @@ public class Spd {
}
/**
+ * return Guid Value.
+ */
+ public String getGuidFromCname(String cName){
+ return guidCnameInfo.get(cName);
+ }
+
+ /**
getLibClassInclude
This function is to get the library exposed header file name according
@@ -246,17 +270,5 @@ public class Spd {
return packageHeaderInfo.get(moduleType);
}
- /**
- getGuidNameArray
-
- This function is to get the GUID's CName and it's GUID according to
- GUID's name
-
- @param guidName Name of GUID
- @return CName and GUID.
- **/
- public String[] getGuidNameArray(String guidName) {
- return this.guidInfo.get(guidName);
- }
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
index 5eb14d4..9560339 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
@@ -27,6 +27,7 @@ import org.apache.xmlbeans.XmlNormalizedString;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlString;
import org.tianocore.BuildOptionsDocument;
+import org.tianocore.CNameType;
import org.tianocore.DataIdDocument;
import org.tianocore.ExternsDocument;
import org.tianocore.FileNameConvention;
@@ -48,9 +49,11 @@ import org.tianocore.OptionDocument;
import org.tianocore.PPIsDocument;
import org.tianocore.PackageDependenciesDocument;
import org.tianocore.PackageHeadersDocument;
+import org.tianocore.PcdCodedDocument;
import org.tianocore.PlatformDefinitionsDocument;
import org.tianocore.PpiDeclarationsDocument;
import org.tianocore.ProtocolDeclarationsDocument;
+import org.tianocore.Sentence;
import org.tianocore.SpdHeaderDocument;
import org.tianocore.SupportedArchitectures;
import org.tianocore.FilenameDocument.Filename;
@@ -63,6 +66,7 @@ import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification;
import org.tianocore.build.id.PlatformIdentification;
import org.tianocore.build.toolchain.ToolChainInfo;
+import org.tianocore.logger.EdkLog;
/**
* SurfaceAreaQuery class is used to query Surface Area information from msa,
@@ -624,8 +628,7 @@ public class SurfaceAreaQuery {
String[] entryPoints = new String[returns.length];
for (int i = 0; i < returns.length; ++i) {
- entryPoints[i] = ((XmlNormalizedString) returns[i])
- .getStringValue();
+ entryPoints[i] = ((CNameType) returns[i]).getStringValue();
}
return entryPoints;
@@ -689,7 +692,7 @@ public class SurfaceAreaQuery {
if (arch == null || arch.equals("")) {
return new String[0];
} else {
- xPath = new String[] { "/Protocol[@SupArchList='" + arch + "']" };
+ xPath = new String[] { "/Protocol" };
}
Object[] returns = get("Protocols", xPath);
@@ -700,7 +703,10 @@ public class SurfaceAreaQuery {
String[] protocolArray = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
- protocolArray[i] = protocolList[i].getProtocolCName();
+ List<String> archList = protocolList[i].getSupArchList();
+ if (archList == null || archList.contains(arch)){
+ protocolArray[i] = protocolList[i].getProtocolCName();
+ }
}
return protocolArray;
}
@@ -720,8 +726,7 @@ public class SurfaceAreaQuery {
if (arch == null || arch.equals("")) {
return new String[0];
} else {
- xPath = new String[] { "/ProtocolNotify[@SupArchList='" + arch
- + "']" };
+ xPath = new String[] { "/ProtocolNotify" };
}
Object[] returns = get("Protocols", xPath);
@@ -731,7 +736,11 @@ public class SurfaceAreaQuery {
String[] protocolNotifyList = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
- protocolNotifyList[i] = ((ProtocolNotify) returns[i]).getProtocolNotifyCName();
+ List<String> archList = ((ProtocolNotify) returns[i]).getSupArchList();
+ if (archList == null || archList.contains(arch)){
+ protocolNotifyList[i] = ((ProtocolNotify) returns[i]).getProtocolNotifyCName();
+ }
+
}
return protocolNotifyList;
@@ -790,7 +799,7 @@ public class SurfaceAreaQuery {
Object[] returns = get("Externs", xPath);
if (returns != null && returns.length > 0) {
String[] stringArray = new String[returns.length];
- XmlNormalizedString[] doc = (XmlNormalizedString[]) returns;
+ CNameType[] doc = (CNameType[]) returns;
for (int i = 0; i < returns.length; ++i) {
stringArray[i] = doc[i].getStringValue();
@@ -834,7 +843,7 @@ public class SurfaceAreaQuery {
if (arch == null || arch.equals("")) {
return new String[0];
} else {
- xPath = new String[] { "/PpiNotify[@SupArchList='" + arch + "']" };
+ xPath = new String[] { "/PpiNotify" };
}
Object[] returns = get("PPIs", xPath);
@@ -844,7 +853,11 @@ public class SurfaceAreaQuery {
String[] ppiNotifyList = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
- ppiNotifyList[i] = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName();
+ List<String> archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList();
+ if (archList == null || archList.contains(arch)){
+ ppiNotifyList[i] = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName();
+ }
+
}
return ppiNotifyList;
@@ -869,7 +882,7 @@ public class SurfaceAreaQuery {
if (arch == null || arch.equals("")) {
return new String[0];
} else {
- archXpath = "/PpiNotify[@SupArchList='" + arch + "']";
+ archXpath = "/PpiNotify";
if (usage != null && !usage.equals("")) {
usageXpath = "/PpiNotify[@Usage='" + arch + "']";
xPath = new String[] { archXpath, usageXpath };
@@ -906,7 +919,7 @@ public class SurfaceAreaQuery {
if (arch == null || arch.equals("")) {
return new String[0];
} else {
- xPath = new String[] { "/Ppi[@SupArchList='" + arch + "']" };
+ xPath = new String[] { "/Ppi" };
}
Object[] returns = get("PPIs", xPath);
@@ -916,7 +929,11 @@ public class SurfaceAreaQuery {
String[] ppiList = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
- ppiList[i] = ((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName();
+ List<String> archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList();
+ if (archList == null || archList.contains(arch)){
+ ppiList[i] = ((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName();
+ }
+
}
return ppiList;
}
@@ -940,7 +957,7 @@ public class SurfaceAreaQuery {
if (arch == null || arch.equals("")) {
return new String[0];
} else {
- archXpath = "/Ppi[@SupArchList='" + arch + "']";
+ archXpath = "/Ppi";
if (usage != null && !usage.equals("")) {
usageXpath = "/Ppi[@Usage='" + arch + "']";
xPath = new String[] { archXpath, usageXpath };
@@ -975,9 +992,9 @@ public class SurfaceAreaQuery {
String[] xPath;
if (arch == null || arch.equals("")) {
- xPath = new String[] { "/GuidName" };
+ xPath = new String[] { "/GuidCNames" };
} else {
- xPath = new String[] { "/GuidName[@SupArchList='" + arch + "']" };
+ xPath = new String[] { "/GuidCNames" };
}
Object[] returns = get("Guids", xPath);
@@ -986,7 +1003,11 @@ public class SurfaceAreaQuery {
}
String[] guidList = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
- guidList[i] = ((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName();
+ List<String> archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList();
+ if (archList == null || archList.contains(arch)){
+ guidList[i] = ((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName();
+ }
+
}
return guidList;
@@ -1009,7 +1030,7 @@ public class SurfaceAreaQuery {
if (arch == null || arch.equals("")) {
return new String[0];
} else {
- archXpath = "/GuidEntry[@SupArchList='" + arch + "']";
+ archXpath = "/GuidEntry";
if (usage != null && !usage.equals("")) {
usageXpath = "/GuidEntry[@Usage='" + arch + "']";
xPath = new String[] { archXpath, usageXpath };
@@ -1096,7 +1117,7 @@ public class SurfaceAreaQuery {
String[] strings = new String[returns.length];
for (int i = 0; i < returns.length; ++i) {
// TBD
- // strings[i] = ((CName) returns[i]).getStringValue();
+ strings[i] = ((CNameType) returns[i]).getStringValue();
}
return strings;
@@ -1113,8 +1134,8 @@ public class SurfaceAreaQuery {
Object[] returns = get("Externs", xPath);
if (returns != null && returns.length > 0) {
- // CName constructor = (CName) returns[0];
- // return constructor.getStringValue();
+ CNameType constructor = ((CNameType) returns[0]);
+ return constructor.getStringValue();
}
return null;
@@ -1131,8 +1152,11 @@ public class SurfaceAreaQuery {
Object[] returns = get("Externs", xPath);
if (returns != null && returns.length > 0) {
- // CName destructor = (CName) returns[0];
- // return destructor.getStringValue();
+ //
+ // Only support one Destructor function.
+ //
+ CNameType destructor = (CNameType) returns[0];
+ return destructor.getStringValue();
}
return null;
@@ -1646,9 +1670,8 @@ public class SurfaceAreaQuery {
String[] specificationList = new String[queryResult.length];
for (int i = 0; i < queryResult.length; i++) {
- // specificationList[i] = ((SpecificationDocument.Specification)
- // queryResult[i])
- // .getStringValue();
+ specificationList[i] = ((Sentence)queryResult[i])
+ .getStringValue();
}
return specificationList;
}
@@ -1765,6 +1788,9 @@ public class SurfaceAreaQuery {
guidPair[0] = entry.getCName();
guidPair[1] = entry.getGuidValue();
guidDeclMap.put(entry.getName(), guidPair);
+ EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());
+ EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[0]);
+ EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[1]);
}
return guidDeclMap;
}
@@ -1793,6 +1819,9 @@ public class SurfaceAreaQuery {
protocolPair[0] = entry.getCName();
protocolPair[1] = entry.getGuidValue();
protoclMap.put(entry.getName(), protocolPair);
+ EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());
+ EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[0]);
+ EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[1]);
}
return protoclMap;
}
@@ -1885,4 +1914,29 @@ public class SurfaceAreaQuery {
return new ModuleSADocument.ModuleSA[0];
}
+ /**
+ Get name array of PCD in a module. In one module, token space
+ is same, and token name should not be conflicted.
+
+ @return String[]
+ **/
+ public static String[] getModulePcdEntryNameArray() {
+ PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null;
+ String[] results;
+ int index;
+ String[] xPath = new String[] {"/PcdEntry"};
+ Object[] returns = get ("PcdCoded", xPath);
+
+ if (returns == null) {
+ return new String[0];
+ }
+
+ pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns;
+ results = new String[pcdEntries.length];
+
+ for (index = 0; index < pcdEntries.length; index ++) {
+ results[index] = pcdEntries[index].getCName();
+ }
+ return results;
+ }
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
index 2579946..8c91b2f 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
@@ -23,20 +23,36 @@ import java.io.FileReader;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
+import org.tianocore.DynamicPcdBuildDefinitionsDocument;
import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions;
+import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData;
+import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo;
import org.tianocore.FrameworkModulesDocument;
-import org.tianocore.FrameworkPlatformDescriptionDocument;
+import org.tianocore.PcdDeclarationsDocument;
+import org.tianocore.PlatformSurfaceAreaDocument;
+import org.tianocore.PcdBuildDefinitionDocument;
+import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
import org.tianocore.ModuleSADocument;
+import org.tianocore.ModuleSADocument.ModuleSA;
+import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.PcdBuildDefinitionDocument.PcdBuildDefinition;
+import org.tianocore.build.autogen.CommonDefinition;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.SurfaceAreaQuery;
+import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.build.pcd.action.ActionMessage;
import org.tianocore.build.pcd.entity.DynamicTokenValue;
import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
@@ -44,6 +60,7 @@ import org.tianocore.build.pcd.entity.SkuInstance;
import org.tianocore.build.pcd.entity.Token;
import org.tianocore.build.pcd.entity.UsageInstance;
import org.tianocore.build.pcd.exception.EntityException;
+import org.tianocore.logger.EdkLog;
import org.tianocore.ModuleTypeDef;
class CStructTypeDeclaration {
@@ -407,6 +424,7 @@ class GuidTable {
Output.add("/* GuidTable */");
Output.add("{");
+
if (al.size() == 0) {
Output.add("\t" + getUuidCString(new UUID(0, 0)));
}
@@ -1824,12 +1842,25 @@ class PcdDatabase {
}
class ModuleInfo {
- public ModuleSADocument.ModuleSA module;
- public ModuleTypeDef.Enum type;
+ private String type;
+ private FpdModuleIdentification moduleId;
+ private PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef;
+
+
- public ModuleInfo (ModuleSADocument.ModuleSA module, ModuleTypeDef.Enum type) {
- this.module = module;
+ public ModuleInfo (FpdModuleIdentification moduleId, String type, XmlObject pcdDef) {
+ this.moduleId = moduleId;
this.type = type;
+ this.pcdBuildDef = ((PcdBuildDefinitionDocument)pcdDef).getPcdBuildDefinition();
+ }
+ public String getModuleType (){
+ return this.type;
+ }
+ public FpdModuleIdentification getModuleId (){
+ return this.moduleId;
+ }
+ public PcdBuildDefinitionDocument.PcdBuildDefinition getPcdBuildDef(){
+ return this.pcdBuildDef;
}
}
@@ -1851,8 +1882,11 @@ public class CollectPCDAction {
private int originalMessageLevel;
/// Cache the fpd docment instance for private usage.
- private FrameworkPlatformDescriptionDocument fpdDocInstance;
-
+ private PlatformSurfaceAreaDocument fpdDocInstance;
+
+ /// xmlObject name
+ private static String xmlObjectName = "PcdBuildDefinition";
+
/**
Set WorkspacePath parameter for this action class.
@@ -1919,7 +1953,7 @@ public class CollectPCDAction {
@throws EntityException Exception indicate failed to execute this action.
**/
- private void execute() throws EntityException {
+ public void execute() throws EntityException {
//
// Get memoryDatabaseManager instance from GlobalData.
// The memoryDatabaseManager should be initialized for whatever build
@@ -1988,14 +2022,13 @@ public class CollectPCDAction {
List<ModuleInfo> allModules = new ArrayList<ModuleInfo>();
ModuleInfo current = null;
int index = 0;
- org.tianocore.Components components = null;
FrameworkModulesDocument.FrameworkModules fModules = null;
ModuleSADocument.ModuleSA[] modules = null;
HashMap<String, XmlObject> map = new HashMap<String, XmlObject>();
if (fpdDocInstance == null) {
try {
- fpdDocInstance = (FrameworkPlatformDescriptionDocument)XmlObject.Factory.parse(new File(fpdFilePath));
+ fpdDocInstance = (PlatformSurfaceAreaDocument)XmlObject.Factory.parse(new File(fpdFilePath));
} catch(IOException ioE) {
throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage());
} catch(XmlException xmlE) {
@@ -2004,14 +2037,28 @@ public class CollectPCDAction {
}
- map.put("FrameworkPlatformDescription", fpdDocInstance);
- SurfaceAreaQuery.setDoc(map);
- modules = SurfaceAreaQuery.getFpdModuleSAs();
- for (index = 0; index < modules.length; index ++) {
- SurfaceAreaQuery.setDoc(GlobalData.getDoc(modules[index].getModuleName()));
- allModules.add(new ModuleInfo(modules[index],
- ModuleTypeDef.Enum.forString(SurfaceAreaQuery.getModuleType())));
- }
+ //map.put("FrameworkPlatformDescription", fpdDocInstance);
+ //SurfaceAreaQuery.setDoc(map);
+ Map<FpdModuleIdentification,XmlObject>pcdBuildDef = GlobalData.getFpdModuleSaXmlObject(CollectPCDAction.xmlObjectName);
+ Set<FpdModuleIdentification> pcdBuildKeySet = pcdBuildDef.keySet();
+ Iterator item = pcdBuildKeySet.iterator();
+ while (item.hasNext()){
+ FpdModuleIdentification id = (FpdModuleIdentification)item.next();
+ try {
+ allModules.add(new ModuleInfo(id, id.getModule().getModuleType(),pcdBuildDef.get(id)));
+ } catch (Exception e){
+ System.out.println(e.getMessage());
+ //EdkLog.log(EdkLog.EDK_INFO,e.getMessage());
+ }
+
+
+ }
+// //modules = SurfaceAreaQuery.getFpdModuleSAs();
+// for (index = 0; index < modules.length; index ++) {
+// //SurfaceAreaQuery.setDoc(GlobalData.getDoc(modules[index].getModuleName()));
+// allModules.add(new ModuleInfo(modules[index],
+// ModuleTypeDef.Enum.forString(SurfaceAreaQuery.getModuleType())));
+// }
return allModules;
}
@@ -2049,7 +2096,8 @@ public class CollectPCDAction {
String moduleName = null;
String datum = null;
int maxDatumSize = 0;
-
+ String tokenSpaceGuidString = null;
+
//
// ----------------------------------------------
// 1), Get all <ModuleSA> from FPD file.
@@ -2073,17 +2121,17 @@ public class CollectPCDAction {
// BUGBUG: For transition schema, we can *not* get module's version from
// <ModuleSAs>, It is work around code.
//
- primaryKey1 = UsageInstance.getPrimaryKey(modules.get(index).module.getModuleName(),
+ primaryKey1 = UsageInstance.getPrimaryKey(modules.get(index).getModuleId().getModule().getName(),
+ null,
null,
null,
- null,
- modules.get(index).module.getArch().toString(),
+ modules.get(index).getModuleId().getArch(),
null);
- primaryKey2 = UsageInstance.getPrimaryKey(modules.get(index2).module.getModuleName(),
+ primaryKey2 = UsageInstance.getPrimaryKey(modules.get(index2).getModuleId().getModule().getName(),
null,
null,
null,
- modules.get(index2).module.getArch().toString(),
+ modules.get(index2).getModuleId().getArch(),
null);
if (primaryKey1.equalsIgnoreCase(primaryKey2)) {
isDuplicate = true;
@@ -2098,13 +2146,13 @@ public class CollectPCDAction {
//
// It is legal for a module does not contains ANY pcd build definitions.
//
- if (modules.get(index).module.getPcdBuildDefinition() == null) {
+ if (modules.get(index).getPcdBuildDef() == null) {
continue;
}
- pcdBuildDataArray = modules.get(index).module.getPcdBuildDefinition().getPcdDataList();
+ pcdBuildDataArray = modules.get(index).getPcdBuildDef().getPcdDataList();
- moduleName = modules.get(index).module.getModuleName();
+ moduleName = modules.get(index).getModuleId().getModule().getName();
//
// ----------------------------------------------------------------------
@@ -2112,13 +2160,14 @@ public class CollectPCDAction {
// ----------------------------------------------------------------------
//
for (pcdIndex = 0; pcdIndex < pcdBuildDataArray.size(); pcdIndex ++) {
+ //tokenSpaceGuidString = GlobalData.getGuidInfoFromCname(pcdBuildData.getTokenSpaceGuidCName())[1];
+ tokenSpaceGuidString = null;
pcdBuildData = pcdBuildDataArray.get(pcdIndex);
primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(),
- translateSchemaStringToUUID(pcdBuildData.getTokenSpaceGuid()));
+ translateSchemaStringToUUID(tokenSpaceGuidString));
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 {
@@ -2136,17 +2185,6 @@ public class CollectPCDAction {
}
//
- // Check <TokenSpaceGuid> is exist? In future, because all schema verification will tools
- // will check that, following checking code could be removed.
- //
- if (pcdBuildData.getTokenSpaceGuid() == null) {
- exceptionString = String.format("[FPD file error] There is no <TokenSpaceGuid> for PCD %s in module %s! This is required!",
- pcdBuildData.getCName(),
- moduleName);
- throw new EntityException(exceptionString);
- }
-
- //
// -------------------------------------------------------------------------------------------
// 2.1.1), Do some necessary checking work for FixedAtBuild, FeatureFlag and PatchableInModule
// -------------------------------------------------------------------------------------------
@@ -2255,8 +2293,10 @@ public class CollectPCDAction {
// If the token is not in database, create a new token instance and add
// a usage instance into this token in database.
//
+ //String tokenSpaceString = GlobalData.getGuidInfoFromCname(pcdBuildData.getTokenSpaceGuidCName())[1];
+ String tokenSpaceString = null;
token = new Token(pcdBuildData.getCName(),
- translateSchemaStringToUUID(pcdBuildData.getTokenSpaceGuid()));
+ translateSchemaStringToUUID(tokenSpaceString));
token.datumType = datumType;
token.tokenNumber = tokenNumber;
@@ -2294,9 +2334,9 @@ public class CollectPCDAction {
null,
null,
null,
- modules.get(index).type,
+ CommonDefinition.getModuleType(modules.get(index).getModuleType()),
pcdType,
- modules.get(index).module.getArch().toString(),
+ modules.get(index).getModuleId().getArch(),
null,
datum,
maxDatumSize);
@@ -2655,15 +2695,15 @@ public class CollectPCDAction {
//
if (fpdDocInstance == null) {
try {
- fpdDocInstance = (FrameworkPlatformDescriptionDocument)XmlObject.Factory.parse(new File(fpdFilePath));
+ fpdDocInstance = (PlatformSurfaceAreaDocument)XmlObject.Factory.parse(new File(fpdFilePath));
} catch(IOException ioE) {
throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage());
} catch(XmlException xmlE) {
throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage());
}
}
-
- dynamicPcdBuildDefinitions = fpdDocInstance.getFrameworkPlatformDescription().getDynamicPcdBuildDefinitions();
+
+ dynamicPcdBuildDefinitions = fpdDocInstance.getPlatformSurfaceArea().getDynamicPcdBuildDefinitions();
if (dynamicPcdBuildDefinitions == null) {
exceptionString = String.format("[FPD file error] There are no <PcdDynamicBuildDescriptions> in FPD file but contains Dynamic type "+
"PCD entry %s in module %s!",
@@ -2674,18 +2714,10 @@ public class CollectPCDAction {
dynamicPcdBuildDataArray = dynamicPcdBuildDefinitions.getPcdBuildDataList();
for (index = 0; index < dynamicPcdBuildDataArray.size(); index ++) {
- //
- // Check <TokenSpaceGuid> is exist? In future, because all schema verification will tools
- // will check that, following checking code could be removed.
- //
- if (dynamicPcdBuildDataArray.get(index).getTokenSpaceGuid() == null) {
- exceptionString = String.format("[FPD file error] There is no <TokenSpaceGuid> for PCD %s in <DynamicPcdBuildDefinitions>! This is required!",
- dynamicPcdBuildDataArray.get(index).getCName());
- throw new EntityException(exceptionString);
- }
-
+ //String tokenSpaceGuidString = GlobalData.getGuidInfoFromCname(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuidCName())[1];
+ String tokenSpaceGuidString = null;
dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(),
- translateSchemaStringToUUID(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuid()));
+ translateSchemaStringToUUID(tokenSpaceGuidString));
if (dynamicPrimaryKey.equalsIgnoreCase(token.getPrimaryKeyString())) {
return dynamicPcdBuildDataArray.get(index);
}
@@ -2880,14 +2912,22 @@ public class CollectPCDAction {
//
// Get variable guid string according to the name of guid which will be mapped into a GUID in SPD file.
//
- variableGuidString = GlobalData.getGuidInfoGuid(skuInfoList.get(index).getVariableGuid().toString());
+ variableGuidString = GlobalData.getGuidInfoFromCname(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()));
}
-
- skuInstance.value.setHiiData(skuInfoList.get(index).getVariableName(),
+ 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());
@@ -3044,8 +3084,8 @@ public class CollectPCDAction {
ca.setWorkspacePath("m:/tianocore/edk2");
ca.setFPDFilePath("m:/tianocore/edk2/EdkNt32Pkg/Nt32.fpd");
ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);
- GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
- "m:/tianocore/edk2");
- ca.execute();
+// GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
+// "m:/tianocore/edk2");
+// ca.execute();
}
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java
index c363aab..7365345 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java
@@ -19,11 +19,15 @@ package org.tianocore.build.pcd.action;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.xmlbeans.XmlObject;
import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.global.SurfaceAreaQuery;
import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
import org.tianocore.build.pcd.entity.Token;
import org.tianocore.build.pcd.entity.UsageInstance;
@@ -167,36 +171,167 @@ public class PCDAutoGenAction extends BuildAction {
return cAutoGenString;
}
+// /**
+// Construct function
+//
+// This function mainly initialize some member variable.
+//
+// @param moduleName Parameter of this action class.
+// @param isEmulatedPCDDriver Parameter of this action class.
+// **/
+// public PCDAutoGenAction(String moduleName,
+// UUID moduleGuid,
+// String packageName,
+// UUID packageGuid,
+// String arch,
+// String version,
+// boolean isBuildUsedLibrary,
+// String[] pcdNameArray) {
+// dbManager = null;
+// hAutoGenString = "";
+// cAutoGenString = "";
+//
+// setModuleName(moduleName);
+// setModuleGuid(moduleGuid);
+// setPackageName(packageName);
+// setPackageGuid(packageGuid);
+// setPcdNameArray(pcdNameArray);
+// setArch(arch);
+// setVersion(version);
+// setIsBuildUsedLibrary(isBuildUsedLibrary);
+// }
+
+
/**
- Construct function
+ Construct function
+
+ This function mainly initialize some member variable.
+
+ @param moduleName Parameter of this action class.
+ @param isEmulatedPCDDriver Parameter of this action class.
+ **/
+ public PCDAutoGenAction(String moduleName,
+ String moduleGuidString,
+ String packageName,
+ String packageGuidString,
+ String arch,
+ String version,
+ boolean isBuildUsedLibrary,
+ String[] pcdNameArray)
+ throws BuildActionException {
+ dbManager = null;
+ hAutoGenString = "";
+ cAutoGenString = "";
+ try {
+ setModuleName(moduleName);
+ setModuleGuid(translateSchemaStringToUUID(moduleGuidString));
+ setPackageName(packageName);
+ setPackageGuid(translateSchemaStringToUUID(packageGuidString));
+ setPcdNameArray(pcdNameArray);
+ setArch(arch);
+ setVersion(version);
+ setIsBuildUsedLibrary(isBuildUsedLibrary);
+
+ if (isBuildUsedLibrary) {
+ System.out.println("Build for library");
+ for (int index = 0; index < pcdNameArray.length; index ++) {
+ System.out.println(pcdNameArray[index]);
+ }
+ }
+ } catch (EntityException e){
+ throw new BuildActionException(e.getMessage());
+ }
+ }
+
+ /**
+ 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);
+ }
- This function mainly initialize some member variable.
-
- @param moduleName Parameter of this action class.
- @param isEmulatedPCDDriver Parameter of this action class.
- **/
- public PCDAutoGenAction(String moduleName,
- UUID moduleGuid,
- String packageName,
- UUID packageGuid,
- String arch,
- String version,
- boolean isBuildUsedLibrary,
- String[] pcdNameArray) {
- dbManager = null;
- hAutoGenString = "";
- cAutoGenString = "";
-
- setModuleName(moduleName);
- setModuleGuid(moduleGuid);
- setPackageName(packageName);
- setPackageGuid(packageGuid);
- setPcdNameArray(pcdNameArray);
- setArch(arch);
- setVersion(version);
- setIsBuildUsedLibrary(isBuildUsedLibrary);
- }
-
/**
check the parameter for action class.
@@ -265,12 +400,14 @@ public class PCDAutoGenAction extends BuildAction {
dbManager.UsageInstanceContext = usageInstanceArray;
dbManager.CurrentModuleName = moduleName;
} else {
+ System.out.println(String.format("Generate %s 's library", dbManager.CurrentModuleName));
usageContext = dbManager.UsageInstanceContext;
//
// For building MDE package, although all module are library, but PCD entries of
// these library should be used to autogen.
//
if (usageContext == null) {
+ System.out.println("context is null");
usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleName,
moduleGuid,
packageName,
@@ -279,6 +416,7 @@ public class PCDAutoGenAction extends BuildAction {
version);
} else {
usageInstanceArray = new ArrayList<UsageInstance>();
+ System.out.println("context is not null!");
//
// Remove PCD entries which are not belong to this library.
//
@@ -289,6 +427,7 @@ public class PCDAutoGenAction extends BuildAction {
for (index2 = 0; index2 < pcdNameArray.length; index2 ++) {
if (pcdNameArray[index2].equalsIgnoreCase(usageContext.get(index).parentToken.cName)) {
+ System.out.println("Found! for PCD entry " + pcdNameArray[index2]);
usageInstanceArray.add(usageContext.get(index));
break;
}
@@ -404,7 +543,7 @@ public class PCDAutoGenAction extends BuildAction {
//
CollectPCDAction collectionAction = new CollectPCDAction();
GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
- WorkSpace);
+ WorkSpace,null);
try {
collectionAction.perform(WorkSpace,
@@ -417,18 +556,18 @@ public class PCDAutoGenAction extends BuildAction {
//
// Then execute the PCDAuotoGenAction to get generated Autogen.h and Autogen.c
//
- PCDAutoGenAction autogenAction = new PCDAutoGenAction("PcdPeim",
- null,
- null,
- null,
- "IA32",
- null,
- true,
- nameArray);
- autogenAction.execute();
-
- System.out.println(autogenAction.OutputH());
- System.out.println("WQWQWQWQWQ");
- System.out.println(autogenAction.OutputC());
+// PCDAutoGenAction autogenAction = new PCDAutoGenAction("MonoStatusCode",
+// null,
+// null,
+// null,
+// "IA32",
+// null,
+// false,
+// nameArray);
+// autogenAction.execute();
+//
+// System.out.println(autogenAction.OutputH());
+// System.out.println("WQWQWQWQWQ");
+// System.out.println(autogenAction.OutputC());
}
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ShowPCDDatabaseAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ShowPCDDatabaseAction.java
index 77e5020..af07e55 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ShowPCDDatabaseAction.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ShowPCDDatabaseAction.java
@@ -92,7 +92,7 @@ public class ShowPCDDatabaseAction extends UIAction {
// Initialize global data.
//
GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
- workspacePath);
+ workspacePath,null);
//
// Collect PCD information.
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java
index d146e9d..20a58ba 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java
@@ -20,6 +20,7 @@ package org.tianocore.build.pcd.entity;
import java.util.UUID;
import org.tianocore.ModuleTypeDef;
+import org.tianocore.build.autogen.CommonDefinition;
import org.tianocore.build.pcd.exception.EntityException;
/**
@@ -71,7 +72,7 @@ public class UsageInstance {
///
/// The module type for this usage instance.
///
- public ModuleTypeDef.Enum moduleType;
+ public int moduleType;
///
/// The value of the PCD in this usage instance.
@@ -115,7 +116,7 @@ public class UsageInstance {
UUID moduleGUID,
String packageName,
UUID packageGUID,
- ModuleTypeDef.Enum moduleType,
+ int moduleType,
Token.PCD_TYPE modulePcdType,
String arch,
String version,
@@ -178,8 +179,8 @@ public class UsageInstance {
@return boolean
*/
public boolean isPeiPhaseComponent() {
- if ((moduleType == ModuleTypeDef.PEI_CORE) ||
- (moduleType == ModuleTypeDef.PEIM)) {
+ if ((moduleType == CommonDefinition.ModuleTypePeiCore) ||
+ (moduleType == CommonDefinition.ModuleTypePeim)) {
return true;
}
return false;
@@ -190,12 +191,12 @@ public class UsageInstance {
// BugBug: May need confirmation on which type of module can
// make use of Dynamic(EX) PCD entry.
//
- if ((moduleType == ModuleTypeDef.DXE_DRIVER) ||
- (moduleType == ModuleTypeDef.DXE_RUNTIME_DRIVER) ||
- (moduleType == ModuleTypeDef.DXE_SAL_DRIVER) ||
- (moduleType == ModuleTypeDef.DXE_SMM_DRIVER) ||
- (moduleType == ModuleTypeDef.UEFI_DRIVER) ||
- (moduleType == ModuleTypeDef.UEFI_APPLICATION)
+ if ((moduleType == CommonDefinition.ModuleTypeDxeDriver) ||
+ (moduleType == CommonDefinition.ModuleTypeDxeRuntimeDriver) ||
+ (moduleType == CommonDefinition.ModuleTypeDxeSalDriver) ||
+ (moduleType == CommonDefinition.ModuleTypeDxeSmmDriver) ||
+ (moduleType == CommonDefinition.ModuleTypeUefiDriver) ||
+ (moduleType == CommonDefinition.ModuleTypeUefiApplication)
) {
return true;
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java
index 0472265..0097890 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java
@@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.build.toolchain;
-import org.tianocore.build.exception.EdkException;
+import org.tianocore.exception.EdkException;
import java.io.BufferedReader;
import java.io.File;
diff --git a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java
index 05d2124..232046c 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java
@@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
package org.tianocore.build.toolchain;
import org.apache.tools.ant.BuildException;
-import org.tianocore.build.exception.EdkException;
+import org.tianocore.exception.EdkException;
import org.tianocore.build.toolchain.ToolChainKey;
import org.tianocore.build.toolchain.ToolChainMap;
diff --git a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainKey.java b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainKey.java
index 4804f15..ae13190 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainKey.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainKey.java
@@ -24,7 +24,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
-import org.tianocore.build.exception.EdkException;
+import org.tianocore.exception.EdkException;
public class ToolChainKey implements java.io.Serializable, Comparable<ToolChainKey> {
diff --git a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java
index da34e7e..39034fd 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java
@@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import org.tianocore.build.exception.EdkException;
+import org.tianocore.exception.EdkException;
public class ToolChainMap {