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