diff options
15 files changed, 263 insertions, 57 deletions
diff --git a/EdkModulePkg/EdkModulePkg.fpd b/EdkModulePkg/EdkModulePkg.fpd index 7ed449c1af..4e1e99ef10 100644 --- a/EdkModulePkg/EdkModulePkg.fpd +++ b/EdkModulePkg/EdkModulePkg.fpd @@ -19886,15 +19886,9 @@ <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_PEIM"/>
<Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
<Attribute Name="FFS_ATTRIB_DATA_ALIGNMENT" Value="1"/>
- <!--FFS DATA should align 16 bytes.-->
+ <!--The PE32 should align on 16 bytes boundary.-->
<Sections>
- <Section SectionType="EFI_SECTION_RAW">
- <!--add 12 bytes blank.pad file-->
- <Filenames>
- <Filename>${PLATFORM_DIR}/Blank.pad</Filename>
- </Filenames>
- </Section>
- <Section SectionType="EFI_SECTION_PE32"/>
+ <Section SectionType="EFI_SECTION_PE32" Alignment="1"/>
<Section SectionType="EFI_SECTION_PEI_DEPEX"/>
<Section SectionType="EFI_SECTION_USER_INTERFACE"/>
<Section SectionType="EFI_SECTION_VERSION"/>
@@ -19904,15 +19898,9 @@ <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_PEI_CORE"/>
<Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
<Attribute Name="FFS_ATTRIB_DATA_ALIGNMENT" Value="1"/>
- <!--FFS DATA should align 16 bytes.-->
+ <!--The PE32 should align on 16 bytes boundary.-->
<Sections>
- <Section SectionType="EFI_SECTION_RAW">
- <!--add 12 bytes blank.pad file-->
- <Filenames>
- <Filename>${PLATFORM_DIR}/Blank.pad</Filename>
- </Filenames>
- </Section>
- <Section SectionType="EFI_SECTION_PE32"/>
+ <Section SectionType="EFI_SECTION_PE32" Alignment="1"/>
<Section SectionType="EFI_SECTION_USER_INTERFACE"/>
<Section SectionType="EFI_SECTION_VERSION"/>
</Sections>
diff --git a/EdkNt32Pkg/Nt32.fpd b/EdkNt32Pkg/Nt32.fpd index f4a6563191..5c81986e85 100644 --- a/EdkNt32Pkg/Nt32.fpd +++ b/EdkNt32Pkg/Nt32.fpd @@ -7916,26 +7916,29 @@ <concat destfile="${FV_DIR}/FV_RECOVERY.fd" binary="true" force="no">
<fileset dir="${FV_DIR}" includes="*.fv"/>
</concat>
- <!--Generate Run.cmd file. This file will call SecMain.exe to start shell.-->
<pathconvert property="SecMainPath" targetos="windows">
<path path="${TARGET_DIR}/IA32"/>
</pathconvert>
- <echo file="${BUILD_DIR}/run.cmd">@REM - @REM Copyright (c) 2006, Intel Corporation - @REM All rights reserved. This program and the accompanying materials - @REM are licensed and made available under the terms and conditions of the BSD License - @REM which accompanies this distribution. The full text of the license may be found at - @REM http://opensource.org/licenses/bsd-license.php - @REM - @REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - @REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - @REM - - @echo off - pushd . - cd ${SecMainPath} - SecMain.exe - popd + <echo file="${TARGET_DIR}/run.cmd">@REM
+ @REM Copyright (c) 2006, Intel Corporation
+ @REM All rights reserved. This program and the accompanying materials
+ @REM are licensed and made available under the terms and conditions of the BSD License
+ @REM which accompanies this distribution. The full text of the license may be found at
+ @REM http://opensource.org/licenses/bsd-license.php
+ @REM
+ @REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ @REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ @REM
+
+ @echo off
+ pushd .
+ cd ${SecMainPath}
+ SecMain.exe
+ popd
@echo on</echo>
</UserExtensions>
+ <UserExtensions UserID="TianoCore" Identifier="run">
+ <!-- execute the NT32 simulator -->
+ <exec executable="${TARGET_DIR}/IA32/SecMain.exe" dir="${TARGET_DIR}/IA32" spawn="false"/>
+ </UserExtensions>
</PlatformSurfaceArea>
\ No newline at end of file diff --git a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java index 5f35685fbe..3e2a98f695 100644 --- a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java +++ b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java @@ -33,6 +33,7 @@ import org.apache.tools.ant.BuildException; **/
public class CompressSection implements Section, FfsTypes {
+ private int alignment = 0;
//
// The attribute of compressName.
//
@@ -197,4 +198,16 @@ public class CompressSection implements Section, FfsTypes { public void addTool (Tool tool) {
sectList.add(tool);
}
+
+ public int getAlignment() {
+ return alignment;
+ }
+
+ public void setAlignment(int alignment) {
+ if (alignment > 7) {
+ this.alignment = 7;
+ } else {
+ this.alignment = alignment;
+ }
+ }
}
\ No newline at end of file diff --git a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFfsFileTask.java b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFfsFileTask.java index 3fdeb8d76a..ebc26b92a4 100644 --- a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFfsFileTask.java +++ b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFfsFileTask.java @@ -741,15 +741,53 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes { return value;
}
-
- /**
- genFfs
-
- This function is to generate FFS file.
-
- @param ffsFile Name of FFS file.
- @param isOrg Flag to indicate generate ORG ffs file or not.
- **/
+
+ private void alignSection(DataOutputStream dataBuffer, int dataSize, int alignment) throws BuildException {
+ if (alignment == 0) {
+ return;
+ }
+ dataSize += 4; // take the section header into account
+ int[] alignedBytes = {0, 16, 128, 512, 1024, 4096, 32768, 65536};
+ int padSize = (alignedBytes[alignment] - dataSize) & (alignedBytes[alignment] - 1);
+ if (padSize == 0) {
+ //
+ // already aligned
+ //
+ return;
+ }
+ //
+ // if the pad size is not times of 4, there must be something wrong in previous sections
+ //
+ if (((4 - padSize) & (4 - 1)) != 0) {
+ EdkLog.log(this, EdkLog.EDK_ERROR, "PAD section size must be 4-byte aligned (" + padSize + ")!");
+ throw new BuildException ("Alignment can't be satisfied!");
+ }
+ byte[] pad = new byte[padSize];
+ //
+ // first three byte stores the section size
+ //
+ pad[0] = (byte)(padSize & 0xff);
+ pad[1] = (byte)((padSize >> 8) & 0xff);
+ pad[2] = (byte)((padSize >> 16) & 0xff);
+ //
+ // the fourth byte are section type. use raw type (0x19)
+ //
+ pad[3] = 0x19;
+ try {
+ dataBuffer.write(pad);
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+ }
+
+ /**
+ genFfs
+
+ This function is to generate FFS file.
+
+ @param ffsFile Name of FFS file.
+ @param isOrg Flag to indicate generate ORG ffs file or not.
+ **/
private void genFfs(File ffsFile) throws BuildException {
Section sect;
int fileSize;
@@ -775,6 +813,11 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes { sect = (Section)sectionIter.next();
try {
+ int alignment = sect.getAlignment();
+ if (this.ffsAttribDataAlignment < alignment) {
+ this.ffsAttribDataAlignment = alignment;
+ }
+ alignSection(dataBuffer, dataBuffer.size(), alignment);
//
// The last section don't need 4 byte ffsAligment.
//
@@ -812,6 +855,12 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes { stringToGuid (this.ffsFileGuid, ffsHeader.name);
}
+ //
+ // because we may have changed the ffsAttribDataAlignment, we need to refresh attributes
+ //
+ this.attributes &= ~(((byte)7) << 3);
+ this.attributes |= (((byte)this.ffsAttribDataAlignment) << 3);
+
ffsHeader.ffsAttributes = this.attributes;
if ((ffsHeader.fileType = stringToType(this.ffsFileType))== -1) {
throw new BuildException ("FFS_FILE_TYPE unknow!\n");
diff --git a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java index e329c0e3eb..82844f080f 100644 --- a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java +++ b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java @@ -32,6 +32,7 @@ import org.apache.tools.ant.types.Commandline; import org.tianocore.common.logger.EdkLog;
public class GenSectionTask extends Task implements EfiDefine, Section, FfsTypes {
+ private int alignment = 0;
//
// Tool name
//
@@ -269,6 +270,18 @@ public class GenSectionTask extends Task implements EfiDefine, Section, FfsTypes this.sectFileList.add(task);
}
+ public int getAlignment() {
+ return alignment;
+ }
+
+ public void setAlignment(int alignment) {
+ if (alignment > 7) {
+ this.alignment = 7;
+ } else {
+ this.alignment = alignment;
+ }
+ }
+
public void toBuffer(DataOutputStream buffer){
//
// Search SectionList find earch section and call it's
diff --git a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/SectFile.java b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/SectFile.java index c110f3bc50..9d53a21999 100644 --- a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/SectFile.java +++ b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/SectFile.java @@ -25,6 +25,7 @@ import org.apache.tools.ant.BuildException; **/
public class SectFile implements Section {
private String fileName = ""; /// section file name
+ private int alignment = 0;
/**
Get method of ANT task/datatype for "FileName" attribute
@@ -44,6 +45,18 @@ public class SectFile implements Section { this.fileName = fileName;
}
+ public int getAlignment() {
+ return alignment;
+ }
+
+ public void setAlignment(int alignment) {
+ if (alignment > 7) {
+ this.alignment = 7;
+ } else {
+ this.alignment = alignment;
+ }
+ }
+
public SectFile (){
}
diff --git a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/Section.java b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/Section.java index 5fa8d7b1ee..ff4c6d6d11 100644 --- a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/Section.java +++ b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/Section.java @@ -19,5 +19,8 @@ import java.io.DataOutputStream; Section interface is for geting the contain buffer form compress, tool, and sectFile
**/
public interface Section {
+ int alignment = 0;
public void toBuffer (DataOutputStream buffer);
+ public void setAlignment(int alignment);
+ public int getAlignment();
}
\ No newline at end of file diff --git a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java index 761a0efab0..ea320366b1 100644 --- a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java +++ b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java @@ -32,6 +32,7 @@ import org.tianocore.common.logger.EdkLog; **/
public class Tool implements EfiDefine, Section {
+ private int alignment = 0;
private String toolName = "";
private ToolArg toolArgList = new ToolArg();
private Input inputFiles = new Input();
@@ -247,6 +248,19 @@ public class Tool implements EfiDefine, Section { public synchronized int getRand() {
return ran.nextInt();
}
+
+ public int getAlignment() {
+ return alignment;
+ }
+
+ public void setAlignment(int alignment) {
+ if (alignment > 7) {
+ this.alignment = 7;
+ } else {
+ this.alignment = alignment;
+ }
+ }
+
}
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/FfsProcess.java b/Tools/Java/Source/GenBuild/org/tianocore/build/FfsProcess.java index 884a0d7453..dd86346b7f 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/FfsProcess.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/FfsProcess.java @@ -347,6 +347,7 @@ public class FfsProcess { **/
private void dealSection(int mode, Document doc, Element root, XmlCursor cursor, Vector<String> list) {
String type = cursor.getAttributeText(new QName("SectionType"));
+ String alignment = cursor.getAttributeText(new QName("Alignment"));
//
// Judge if file is specified? Yes, just use the file, else call Build Macro
@@ -399,6 +400,9 @@ public class FfsProcess { } else {
ele.setAttribute("fileName", fileName);
}
+ if (alignment != null) {
+ ele.setAttribute("Alignment", alignment);
+ }
root.appendChild(ele);
}
}
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java b/Tools/Java/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java index e240150c29..ae1ac7ec93 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java @@ -323,11 +323,7 @@ public class FrameworkBuildTask extends Task{ }
public void setType(String type) {
- if (type.equalsIgnoreCase("clean") || type.equalsIgnoreCase("cleanall")) {
- this.type = type.toLowerCase();
- } else {
- this.type = "all";
- }
+ this.type = type.toLowerCase();
}
private void readTargetFile() throws EdkException{
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java index 2265d6ba05..5aa717fbdd 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java @@ -327,10 +327,8 @@ public class GenBuildTask extends Ant { if (type.equalsIgnoreCase("all") || type.equalsIgnoreCase("build")) {
applyBuild(targetList[i], toolchainList[j], fpdModuleId);
- } else if (type.equalsIgnoreCase("clean")) {
- applyClean(fpdModuleId);
- } else if (type.equalsIgnoreCase("cleanall")) {
- applyCleanall(fpdModuleId);
+ } else {
+ applyNonBuildTarget(fpdModuleId);
}
}
}
@@ -675,6 +673,24 @@ public class GenBuildTask extends Ant { antCall(antFilename, null);
}
+ private void applyNonBuildTarget(FpdModuleIdentification fpdModuleId){
+ //
+ // if it is CUSTOM_BUILD
+ // then call the exist BaseName_build.xml directly.
+ //
+ if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
+ EdkLog.log(this, "Calling user-defined " + moduleId.getName() + "_build.xml");
+
+ String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
+ antCall(antFilename, this.type);
+
+ return ;
+ }
+
+ String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
+ antCall(antFilename, this.type);
+ }
+
private void applyClean(FpdModuleIdentification fpdModuleId){
//
// if it is CUSTOM_BUILD
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java index 1e5c7744b5..ad2ee2cdd2 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java @@ -159,7 +159,8 @@ public class PlatformBuildFileGenerator { // User Extension Post build
//
applyUserExtensionsPostBuild(document, root);
-
+ applyUserExtensions(document, root);
+
document.appendChild(rootComment);
document.appendChild(root);
//
@@ -630,7 +631,59 @@ public class PlatformBuildFileGenerator { root.appendChild(ele);
}
-
+
+ private void applyUserExtensions(Document document, Node root) {
+ Node[] nodeList = saq.getFpdUserExtensions();
+ for (int nodeIndex = 0; nodeIndex < nodeList.length; ++nodeIndex) {
+ Node node = nodeList[nodeIndex];
+ //
+ // User Extensions
+ //
+ root.appendChild(document.createComment("User Defined Target"));
+ Element ele = document.createElement("target");
+ ele.setAttribute("name", node.getAttributes().getNamedItem("Identifier").getNodeValue());
+
+ if (node != null) {
+ //
+ // For every Target and ToolChain
+ //
+ String[] targetList = GlobalData.getToolChainInfo().getTargets();
+ for (int i = 0; i < targetList.length; i++){
+ String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();
+ for(int j = 0; j < toolchainList.length; j++){
+ //
+ // Prepare FV_DIR
+ //
+ String ffsCommonDir = project.getProperty("BUILD_DIR") + File.separatorChar
+ + targetList[i] + "_"
+ + toolchainList[j];
+ File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");
+ Element fvEle = document.createElement("var");
+ fvEle.setAttribute("name", "FV_DIR");
+ fvEle.setAttribute("value", fvDir.getPath().replaceAll("(\\\\)", "/"));
+ ele.appendChild(fvEle);
+
+ Element targetDirEle = document.createElement("var");
+ targetDirEle.setAttribute("name", "TARGET_DIR");
+ targetDirEle.setAttribute("value", ffsCommonDir.replaceAll("(\\\\)", "/"));
+ ele.appendChild(targetDirEle);
+
+ NodeList childNodes = node.getChildNodes();
+ for (int k = 0; k < childNodes.getLength(); k++) {
+ Node childItem = childNodes.item(k);
+ if (childItem.getNodeType() == Node.ELEMENT_NODE) {
+ ele.appendChild(recursiveNode(childItem, document));
+ }
+ }
+
+ }
+ }
+ }
+
+ root.appendChild(ele);
+ }
+ }
+
private Element recursiveNode(Node node, Document document) {
Element root = document.createElement(node.getNodeName());
NamedNodeMap attr = node.getAttributes();
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java index 36eda95c3f..b95c389592 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java @@ -1492,6 +1492,22 @@ public class SurfaceAreaQuery { return a.getDomNode();
}
+ public Node[] getFpdUserExtensions() {
+ String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and not(@Identifier='1') and not(@Identifier='0')]" };
+
+ Object[] queryResult = get("PlatformSurfaceArea", xPath);
+ if (queryResult == null || queryResult.length == 0) {
+ return new Node[0];
+ }
+
+ Node[] nodeList = new Node[queryResult.length];
+ for (int i = 0; i < queryResult.length; ++i) {
+ UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[i];
+ nodeList[i] = a.getDomNode();
+ }
+
+ return nodeList;
+ }
/**
* Retrieve FV image option information
*
diff --git a/Tools/bin/build.bat b/Tools/bin/build.bat index 3f15bb6775..590bed8182 100644 --- a/Tools/bin/build.bat +++ b/Tools/bin/build.bat @@ -8,5 +8,30 @@ @REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@REM
+@echo off
+
+set _ARGS=
+:check_arg
+if ""%1""=="""" goto arg_end
+if ""%1""==""-q"" goto ant_arg
+if ""%1""==""-v"" goto ant_arg
+if ""%1""==""-d"" goto ant_arg
+
+goto ant_target
+
+:ant_arg
+ set _ARGS=%_ARGS% %1
+ shift
+ goto check_arg
+
+:ant_target
+ set _ARGS=%_ARGS% -DBUILD_TARGET=%1
+ shift
+ goto check_arg
+
+:arg_end
+ant -logger org.tianocore.build.global.GenBuildLogger -f %WORKSPACE%/build.xml %_ARGS%
+
+set _ARGS=
+@echo on
-ant -logger org.tianocore.build.global.GenBuildLogger -f %WORKSPACE%/build.xml %*
@@ -17,8 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. <property environment="env" />
<property name="WORKSPACE_DIR" value="${env.WORKSPACE}" />
-
- <!--property name="COMMON_FILE" value="${WORKSPACE_DIR}/Tools/Conf/Common.xml" /-->
+ <property name="BUILD_TARGET" value="all"/>
<import file="${WORKSPACE_DIR}/Tools/Conf/BuildMacro.xml" />
@@ -36,7 +35,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. </target>
<target name="build">
- <FrameworkBuild />
+ <echo message="TARGET: ${BUILD_TARGET}" level="info"/>
+ <FrameworkBuild type="${BUILD_TARGET}"/>
</target>
<target name="clean" depends="init">
|