@param Buffer The point of output buffer\r
\r
**/\r
- public void toBuffer (DataOutputStream Buffer){\r
+ public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer){\r
\r
Section sect;\r
File compressOut;\r
// Call each section class's toBuffer function.\r
//\r
try {\r
- sect.toBuffer(Do);\r
+ sect.toBuffer(Do, orgBuffer);\r
}\r
catch (BuildException e) {\r
System.out.print(e.getMessage());\r
Ch.SectionHeader.type = (byte) EFI_SECTION_COMPRESSION;\r
\r
//\r
- // Note: The compressName was not effective now. Using the\r
+ // Note: The compressName was not efsfective now. Using the\r
// EFI_STANDARD_COMPRSSION for compressType .\r
// That is follow old Genffsfile tools. Some code will be added for \r
// the different compressName;\r
//\r
// First add CompressHeader to Buffer, then add Compress data.\r
//\r
- Buffer.write (headerBuffer);\r
- Buffer.write(myCompress.outputBuffer); \r
+ buffer.write (headerBuffer);\r
+ buffer.write(myCompress.outputBuffer); \r
\r
//\r
- // 4 Byte aligment \r
+ // Buffer 4 Byte aligment \r
//\r
int size = Ch.GetSize() + myCompress.outputBuffer.length;\r
\r
while ((size & 0x03) != 0){\r
size ++;\r
- Buffer.writeByte(0);\r
+ buffer.writeByte(0);\r
+ }\r
+ //\r
+ // orgBuffer 4 Byte aligment\r
+ //\r
+ size = (int)compressOut.length();\r
+ while ((size & 0x03) != 0){\r
+ size ++;\r
+ orgBuffer.writeByte(0);\r
}\r
- \r
//\r
// Delete temp file\r
//\r
import org.apache.tools.ant.taskdefs.Execute;\r
import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
import org.apache.tools.ant.types.Commandline;\r
+import org.tianocore.build.*;\r
\r
/**\r
FwImageTask class.\r
//\r
// absolute path of efi tools\r
//\r
- String path = project.getProperty("env.Framework_Tools_Path");\r
+ String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
String command;\r
if (path == null) {\r
- command = "FwImage";\r
+ command = "fwimage";\r
} else {\r
- command = path + "/" + "FwImage";\r
+ command = path + "/" + "fwimage";\r
}\r
//\r
// argument of tools\r
\r
runner.setAntRun(project);\r
runner.setCommandline(cmdline.getCommandline());\r
- System.out.println(Commandline.toString(cmdline.getCommandline()));\r
-\r
+ //System.out.println(Commandline.toString(cmdline.getCommandline()));\r
+ //GenBuildTask.myLogger.log(Commandline.toString(cmdline.getCommandline()),0);\r
+ //getProject().log(Commandline.toString(cmdline.getCommandline()));\r
revl = runner.execute();\r
if (EFI_SUCCESS == revl) {\r
//\r
// command execution success\r
//\r
- System.out.println("fwimage succeeded!");\r
+ System.out.println("fwimage successed!");\r
} else {\r
//\r
// command execution fail\r
///\r
/// absolute path of efi tools\r
///\r
- String path = project.getProperty("env.Framework_Tools_Path"); \r
+ String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); \r
String command;\r
if (path == null) {\r
- command = "GenCRC32Section";\r
+ command = "gencrc32section";\r
} else {\r
- command = path + "/" + "GenCRC32Section" ;\r
+ command = path + "/" + "gencrc32section" ;\r
}\r
// \r
// string line of input files \r
//\r
// absolute path of edk tools\r
//\r
- String path = project.getProperty("env.Framework_Tools_Path");\r
+ String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
String command;\r
if (path == null) {\r
- command = "GenDepex";\r
+ command = "gendepex";\r
} else {\r
- command = path + "/" + "GenDepex";\r
+ command = path + "/" + "gendepex";\r
}\r
//\r
// argument of GenDepex tool\r
//\r
// command execution success\r
//\r
- System.out.println("GenDepex execute succeeded!");\r
+ System.out.println("GenDepex execute successed!");\r
\r
} else {\r
//\r
public String getPadding() {\r
return this.padding;\r
}\r
-}\r
+}
\ No newline at end of file
\r
GenFfsFileTask execute is to generate ffs file according to input section \r
dscriptive information.\r
- */\r
+ **/\r
public void execute() throws BuildException {\r
Section sect;\r
int fileSize;\r
+ int orgFileSize;\r
int fileDataSize;\r
+ int orgFileDataSize;\r
File ffsFile;\r
+ File ffsOrgFile;\r
FfsHeader ffsHeader = new FfsHeader(); \r
+ FfsHeader orgFfsHeader = new FfsHeader();\r
String ffsSuffix = "";\r
String outputPath = "";\r
\r
// Get Fraemwork_Tools_Path\r
//\r
Project pj = this.getOwningTarget().getProject();\r
- path = pj.getProperty("env.Framework_Tools_Path");\r
+ path = pj.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
\r
//\r
// Check does the BaseName, Guid, FileType set value.\r
System.out.print("General Ffs file: file name is:\n");\r
System.out.print(outputPath + this.ffsFileGuid + '-' + this.baseName + ffsSuffix);\r
System.out.print("\n");\r
-\r
+ \r
//\r
- // Create file output stream -- dataBuffer.\r
- // \r
+ // Create ffs ORG file. fileName = FfsFileGuid + BaseName + ffsSuffix +\r
+ // ".org".\r
+ //\r
+ ffsOrgFile = new File(outputPath + this.ffsFileGuid + '-' + this.baseName + ffsSuffix + ".org");\r
+ \r
try {\r
+ //\r
+ // Create file output stream -- dataBuffer.\r
+ //\r
FileOutputStream dataFs = new FileOutputStream (ffsFile.getAbsolutePath());\r
DataOutputStream dataBuffer = new DataOutputStream (dataFs);\r
-\r
+ \r
+ //\r
+ // Create org file output stream -- orgDataBuffer\r
+ //\r
+ FileOutputStream orgDataFs = new FileOutputStream (ffsOrgFile.getAbsolutePath());\r
+ DataOutputStream orgDataBuffer = new DataOutputStream (orgDataFs);\r
+ \r
//\r
// Search SectionList find earch section and call it's \r
// ToBuffer function.\r
//\r
// The last section don't need 4 byte ffsAligment.\r
//\r
- sect.toBuffer((DataOutputStream)dataBuffer);\r
+ sect.toBuffer((DataOutputStream)dataBuffer, (DataOutputStream) orgDataBuffer);\r
} catch (Exception e) {\r
throw new BuildException (e.getMessage());\r
}\r
FileInputStream fi = new FileInputStream (ffsFile.getAbsolutePath());\r
DataInputStream di = new DataInputStream (fi);\r
di.read(fileBuffer);\r
- di.close(); \r
-\r
+ di.close();\r
+ \r
+ //\r
+ // create input org stream to read file data\r
+ //\r
+ byte[] orgFileBuffer = new byte[(int)ffsOrgFile.length()];\r
+ FileInputStream ofi = new FileInputStream (ffsOrgFile.getAbsolutePath());\r
+ DataInputStream odi = new DataInputStream (ofi);\r
+ odi.read(orgFileBuffer);\r
+ odi.close();\r
\r
//\r
// Add GUID to header struct\r
//\r
if (this.ffsFileGuid != null) {\r
stringToGuid (this.ffsFileGuid, ffsHeader.name);\r
+ //\r
+ // Add Guid to org header struct\r
+ //\r
+ stringToGuid (this.ffsFileGuid, orgFfsHeader.name);\r
}\r
\r
ffsHeader.ffsAttributes = this.attributes;\r
if ((ffsHeader.fileType = stringToType(this.ffsFileType))== -1) {\r
throw new BuildException ("FFS_FILE_TYPE unknow!\n");\r
}\r
-\r
-\r
+ \r
+ //\r
+ // Copy ffsHeader.ffsAttribute and fileType to orgFfsHeader.ffsAttribute\r
+ // and fileType\r
+ // \r
+ orgFfsHeader.ffsAttributes = ffsHeader.ffsAttributes;\r
+ orgFfsHeader.fileType = ffsHeader.fileType;\r
+ \r
//\r
// Adjust file size. The function is used to tripe the last \r
// section padding of 4 binary boundary. \r
if (ffsHeader.fileType != EFI_FV_FILETYPE_RAW) {\r
\r
fileDataSize = adjustFileSize (fileBuffer);\r
+ orgFileDataSize = adjustFileSize (orgFileBuffer);\r
\r
} else {\r
fileDataSize = fileBuffer.length;\r
+ orgFileDataSize = orgFileBuffer.length;\r
}\r
\r
//\r
// 1. add header size to file size\r
//\r
fileSize = fileDataSize + ffsHeader.getSize();\r
+ //\r
+ // add header size to org file size\r
+ //\r
+ orgFileSize = orgFileDataSize + ffsHeader.getSize();\r
\r
if ((ffsHeader.ffsAttributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {\r
if (ffsHeader.fileType == EFI_FV_FILETYPE_FFS_PAD) {\r
); \r
}\r
fileSize = fileSize + 2;\r
+ orgFileSize = orgFileSize + 2;\r
}\r
\r
//\r
ffsHeader.ffsFileSize[0] = (byte)(fileSize & 0x00FF);\r
ffsHeader.ffsFileSize[1] = (byte)((fileSize & 0x00FF00)>>8);\r
ffsHeader.ffsFileSize[2] = (byte)(((int)fileSize & 0xFF0000)>>16);\r
-\r
+ \r
+ //\r
+ // set file size to org header struct\r
+ //\r
+ orgFfsHeader.ffsFileSize[0] = (byte)(orgFileSize & 0x00FF);\r
+ orgFfsHeader.ffsFileSize[1] = (byte)((orgFileSize & 0x00FF00)>>8);\r
+ orgFfsHeader.ffsFileSize[2] = (byte)(((int)orgFileSize & 0xFF0000)>>16);\r
+ \r
//\r
// Fill in checksums and state, these must be zero for checksumming\r
//\r
ffsHeader.structToBuffer(),\r
ffsHeader.getSize()\r
);\r
-\r
+ //\r
+ // Fill in org file's header check sum and state\r
+ //\r
+ orgFfsHeader.integrityCheck.header = calculateChecksum8 (\r
+ orgFfsHeader.structToBuffer(),\r
+ orgFfsHeader.getSize()\r
+ );\r
+ \r
if ((this.attributes & FFS_ATTRIB_CHECKSUM) != 0) {\r
if ((this.attributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {\r
ffsHeader.integrityCheck.file = calculateChecksum8 (\r
fileBuffer, \r
fileDataSize\r
);\r
+ //\r
+ // Add org file header\r
+ //\r
+ orgFfsHeader.integrityCheck.file = calculateChecksum8 (\r
+ orgFileBuffer,\r
+ orgFileDataSize\r
+ );\r
} else {\r
ffsHeader.integrityCheck.file = calculateChecksum8 (\r
fileBuffer,\r
fileDataSize\r
);\r
+ //\r
+ // Add org file header\r
+ //\r
+ orgFfsHeader.integrityCheck.file = calculateChecksum8 (\r
+ orgFileBuffer,\r
+ orgFileDataSize\r
+ );\r
}\r
} else {\r
ffsHeader.integrityCheck.file = FFS_FIXED_CHECKSUM;\r
+ orgFfsHeader.integrityCheck.file = FFS_FIXED_CHECKSUM;\r
}\r
\r
//\r
ffsHeader.ffsState = EFI_FILE_HEADER_CONSTRUCTION | \r
EFI_FILE_HEADER_VALID | \r
EFI_FILE_DATA_VALID;\r
-\r
-\r
+ orgFfsHeader.integrityCheck.file = ffsHeader.ffsState;\r
+ \r
//\r
// create output stream to first write header data in file, then write sect data in file.\r
//\r
FileOutputStream headerFfs = new FileOutputStream (ffsFile.getAbsolutePath());\r
DataOutputStream ffsBuffer = new DataOutputStream (headerFfs);\r
-\r
+ \r
+ FileOutputStream orgHeaderFfs = new FileOutputStream (ffsOrgFile.getAbsolutePath());\r
+ DataOutputStream orgFfsBuffer = new DataOutputStream (orgHeaderFfs);\r
+ \r
//\r
// Add header struct and file data to FFS file\r
//\r
ffsBuffer.write(ffsHeader.structToBuffer());\r
+ orgFfsBuffer.write(orgFfsHeader.structToBuffer());\r
+ \r
for (int i = 0; i< fileDataSize; i++) {\r
ffsBuffer.write(fileBuffer[i]);\r
}\r
+ \r
+ for (int i = 0; i < orgFileDataSize; i++){\r
+ orgFfsBuffer.write(orgFileBuffer[i]);\r
+ }\r
\r
//\r
// If there is a tail, then set it\r
tailByte[1] = (byte)((tailValue & 0xff00)>>8); \r
ffsBuffer.write(tailByte[0]);\r
ffsBuffer.write(tailByte[1]);\r
+ \r
+ orgFfsBuffer.write(tailByte[0]);\r
+ orgFfsBuffer.write(tailByte[1]);\r
}\r
\r
//\r
// the buffer can't be rewritten to file. \r
//\r
ffsBuffer.close();\r
+ orgFfsBuffer.close();\r
System.out.print ("Successful create ffs file!\n");\r
} catch (Exception e) {\r
throw new BuildException (e.getMessage());\r
}\r
\r
if (ffsFileType.equals("EFI_FV_FILETYPE_FREEFORM")) {\r
- return(byte)EFI_FV_FILETYPE_SECURITY_CORE;\r
+ return(byte)EFI_FV_FILETYPE_FREEFORM;\r
}\r
\r
if (ffsFileType.equals("EFI_FV_FILETYPE_SECURITY_CORE")) {\r
\r
**/\r
package org.tianocore.framework.tasks;\r
+import java.io.File;\r
\r
import org.apache.tools.ant.BuildException;\r
import org.apache.tools.ant.Project;\r
import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
import org.apache.tools.ant.types.Commandline;\r
\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.InputStreamReader;\r
-import java.lang.ProcessBuilder;\r
-import java.util.ArrayList;\r
-import java.util.LinkedList;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
/**\r
GenFvImageTask\r
\r
\r
**/\r
public class GenFvImageTask extends Task implements EfiDefine{\r
- ///\r
- /// tool name\r
- ///\r
- static final private String toolName = "GenFvImage";\r
///\r
/// The name of input inf file\r
///\r
/// The target architecture.\r
///\r
private String arch="";\r
- ///\r
- /// Output directory\r
- ///\r
- private String outputDir = ".";\r
- ///\r
- /// argument list\r
- ///\r
- LinkedList<String> argList = new LinkedList<String>();\r
-\r
+ \r
/**\r
execute\r
\r
**/\r
public void execute() throws BuildException {\r
Project project = this.getOwningTarget().getProject();\r
- String path = project.getProperty("env.Framework_Tools_Path");\r
- if (path == null) {\r
+ String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
+ String command = "";\r
+ \r
+ if (path == null){\r
path = "";\r
- } else {\r
- path += File.separatorChar;\r
+ }else {\r
+ path = path + File.separatorChar;\r
}\r
-\r
- if (arch != null && arch.length() > 0) {\r
- argList.addFirst(path + toolName + "_" + arch);\r
- } else {\r
- argList.addFirst(path + toolName);\r
+ \r
+ if (arch.equalsIgnoreCase("")){\r
+ command = path + "GenFvImage";\r
}\r
-\r
- ///\r
- /// lauch the program\r
- ///\r
- ProcessBuilder pb = new ProcessBuilder(argList);\r
- pb.directory(new File(outputDir));\r
- int exitCode = 0;\r
+ if (arch.equalsIgnoreCase("ia32")){\r
+ command = path + "GenFvImage_IA32";\r
+ } \r
+ if (arch.equalsIgnoreCase("x64")){\r
+ command = path + "GenFvImage_X64";\r
+ }\r
+ if (arch.equalsIgnoreCase("ipf")){\r
+ command = path + "GenFvImage_IPF";\r
+ }\r
+ String argument = infFile;\r
+ \r
try {\r
- Process cmdProc = pb.start();\r
- InputStreamReader cmdOut = new InputStreamReader(cmdProc.getInputStream());\r
- char[] buf = new char[1024];\r
-\r
- exitCode = cmdProc.waitFor();\r
- if (exitCode != 0) {\r
- int len = cmdOut.read(buf, 0, 1024);\r
- log(new String(buf, 0, len), Project.MSG_ERR);\r
+ \r
+ Commandline commandLine = new Commandline();\r
+ commandLine.setExecutable(command);\r
+ commandLine.createArgument().setLine(argument);\r
+ \r
+ LogStreamHandler streamHandler = new LogStreamHandler(this,\r
+ Project.MSG_INFO,\r
+ Project.MSG_WARN);\r
+ //\r
+ // create a execute object and set it's commandline\r
+ //\r
+ Execute runner = new Execute(streamHandler,null);\r
+ runner.setAntRun(project);\r
+ runner.setCommandline(commandLine.getCommandline()); \r
+ System.out.println(Commandline.toString(commandLine.getCommandline()));\r
+ \r
+ int revl = -1;\r
+ //\r
+ // user execute class call external programs - GenFvImage\r
+ //\r
+ revl = runner.execute();\r
+ // \r
+ // execute command line success!\r
+ //\r
+ if (EFI_SUCCESS == revl){\r
+ System.out.println("GenFvImage succeeded!");\r
} else {\r
- log("GenFvImage - DONE!", Project.MSG_VERBOSE);\r
+ \r
+ // \r
+ // execute command line failed! \r
+ //\r
+ throw new BuildException("GenFvImage failed !(error =" + \r
+ Integer.toHexString(revl) + ")");\r
}\r
+ \r
} catch (Exception e) {\r
- throw new BuildException(e.getMessage());\r
- } finally {\r
- if (exitCode != 0) {\r
- throw new BuildException("GenFvImage: failed to generate FV file!");\r
- }\r
- }\r
-\r
+ System.out.println(e.getMessage());\r
+ } \r
}\r
/**\r
getInfFile\r
@param infFile name of infFile\r
**/\r
public void setInfFile(String infFile) {\r
- this.infFile = infFile;\r
- argList.add("-I");\r
- argList.add(infFile);\r
+ this.infFile = "-I " + infFile;\r
}\r
\r
/**\r
**/\r
public void setArch(String arch) {\r
this.arch = arch;\r
- }\r
-\r
- /**\r
- getOutputDir\r
- \r
- This function is to get output directory.\r
- \r
- @return Path of output directory.\r
- **/\r
- public String getOutputDir() {\r
- return outputDir;\r
- }\r
-\r
- /**\r
- setOutputDir\r
- \r
- This function is to set output directory.\r
- \r
- @param outputDir The output direcotry.\r
- **/\r
- public void setOutputDir(String outputDir) {\r
- this.outputDir = outputDir;\r
- }\r
+ } \r
}
\ No newline at end of file
//\r
// absolute path of efi tools\r
//\r
- String path = project.getProperty("env.Framework_Tools_Path");\r
+ String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
if (path == null) {\r
- command = "GenSection";\r
+ command = "gensection";\r
} else {\r
- command = path + "/" + "GenSection";\r
+ command = path + "/" + "gensection";\r
}\r
//\r
// argument of tools\r
//\r
// command execution success\r
//\r
- System.out.println("gensection succeeded!");\r
+ System.out.println("gensection successed!");\r
} else {\r
//\r
// command execution fail\r
// \r
public void execute() throws BuildException {\r
Project project = this.getOwningTarget().getProject();\r
- String path = project.getProperty("env.Framework_Tools_Path");\r
+ String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
String command;\r
if (path == null) {\r
command = "GuidChk";\r
}\r
\r
Project prj = this.getOwningTarget().getProject();\r
- String toolPath = prj.getProperty("env.Framework_Tools_Path");\r
+ String toolPath = prj.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
///\r
/// compose full tool path\r
///\r
\r
@param Buffer buffer to contain the section file content with alignment\r
**/\r
- public void toBuffer (DataOutputStream Buffer){\r
+ public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer){\r
File sectFile;\r
byte data;\r
long fileLen;\r
int i = 0;\r
while (i < fileLen) {\r
data = In.readByte();\r
- Buffer.writeByte(data);\r
+ buffer.writeByte(data);\r
+ //\r
+ // Add data to org file \r
+ //\r
+ orgBuffer.writeByte(data);\r
i++;\r
}\r
\r
///\r
while ((fileLen & 0x03)!= 0) {\r
fileLen ++;\r
- Buffer.writeByte(0);\r
+ buffer.writeByte(0);\r
+ //\r
+ // Add data to org file \r
+ //\r
+ orgBuffer.writeByte(0);\r
} \r
\r
///\r
Section interface is for geting the contain buffer form compress, tool, and sectFile \r
**/\r
public interface Section {\r
- public void toBuffer (DataOutputStream Buffer);\r
+ public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer);\r
}
\ No newline at end of file
///\r
/// absolute path of edk tools\r
///\r
- String path = project.getProperty("env.Framework_Tools_Path");\r
+ String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
String command;\r
if (path == null) {\r
command = "setstamp";\r
///\r
/// command execution success\r
///\r
- System.out.println("SetStamp execute succeeded!");\r
+ System.out.println("SetStamp execute successed!");\r
} else {\r
///\r
/// command execution fail\r
return this.timeFile;\r
}\r
\r
-}\r
+}
\ No newline at end of file
///\r
/// absolute path of efi tools\r
///\r
- String path = project.getProperty("env.Framework_Tools_Path"); \r
+ String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); \r
String command;\r
if (path == null) {\r
- command = "StrGather";\r
+ command = "strgather";\r
} else {\r
- command = path + "/" + "StrGather";\r
+ command = path + "/" + "strgather";\r
}\r
\r
///\r
\r
@param buffer The buffer to put the result with alignment\r
**/\r
- public void toBuffer (DataOutputStream buffer){\r
+ public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer){\r
File OutputFile;\r
byte data;\r
\r
while (i < fileLen) {\r
data = In.readByte();\r
buffer.writeByte(data);\r
+ //\r
+ // Add data to org file\r
+ //\r
+ orgBuffer.writeByte(data);\r
i ++;\r
}\r
\r
while ((fileLen & 0x03) != 0) {\r
fileLen++;\r
buffer.writeByte(0);\r
+ orgBuffer.writeByte(0);\r
}\r
In.close();\r
\r
**/\r
public void execute() throws BuildException {\r
Project project = this.getProject();\r
- String toolPath= project.getProperty("env.Framework_Tools_Path");\r
+ String toolPath= project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
String command;\r
if (toolPath == null) {\r
command = "VfrCompile";\r
@REM\r
set WORKSPACE=%CD%\r
\r
-set Framework_Tools_Path=%WORKSPACE%\Tools\bin\r
+set FRAMEWORK_TOOLS_PATH=%WORKSPACE%\Tools\bin\r
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%XMLBEANS_HOME%\bin;%Framework_Tools_Path%;%PATH%\r
\r
echo.\r