1.Change environment variable from "Framework_Tools_Path" to "FRAMEWORK_TOOLS_PATH".

2.Add one OUTPUT - *.org file  for GenFfsFile tool.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@443 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qouyang 2006-06-08 09:11:56 +00:00
parent a28984d905
commit 2da8968bb5
16 changed files with 222 additions and 139 deletions

View File

@ -54,7 +54,7 @@ public class CompressSection implements Section, FfsTypes{
@param Buffer The point of output buffer
**/
public void toBuffer (DataOutputStream Buffer){
public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer){
Section sect;
File compressOut;
@ -79,7 +79,7 @@ public class CompressSection implements Section, FfsTypes{
// Call each section class's toBuffer function.
//
try {
sect.toBuffer(Do);
sect.toBuffer(Do, orgBuffer);
}
catch (BuildException e) {
System.out.print(e.getMessage());
@ -121,7 +121,7 @@ public class CompressSection implements Section, FfsTypes{
Ch.SectionHeader.type = (byte) EFI_SECTION_COMPRESSION;
//
// Note: The compressName was not effective now. Using the
// Note: The compressName was not efsfective now. Using the
// EFI_STANDARD_COMPRSSION for compressType .
// That is follow old Genffsfile tools. Some code will be added for
// the different compressName;
@ -138,19 +138,26 @@ public class CompressSection implements Section, FfsTypes{
//
// First add CompressHeader to Buffer, then add Compress data.
//
Buffer.write (headerBuffer);
Buffer.write(myCompress.outputBuffer);
buffer.write (headerBuffer);
buffer.write(myCompress.outputBuffer);
//
// 4 Byte aligment
// Buffer 4 Byte aligment
//
int size = Ch.GetSize() + myCompress.outputBuffer.length;
while ((size & 0x03) != 0){
size ++;
Buffer.writeByte(0);
buffer.writeByte(0);
}
//
// orgBuffer 4 Byte aligment
//
size = (int)compressOut.length();
while ((size & 0x03) != 0){
size ++;
orgBuffer.writeByte(0);
}
//
// Delete temp file
//

View File

@ -22,6 +22,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;
import org.tianocore.build.*;
/**
FwImageTask class.
@ -65,12 +66,12 @@ public class FwImageTask extends Task implements EfiDefine{
//
// absolute path of efi tools
//
String path = project.getProperty("env.Framework_Tools_Path");
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command;
if (path == null) {
command = "FwImage";
command = "fwimage";
} else {
command = path + "/" + "FwImage";
command = path + "/" + "fwimage";
}
//
// argument of tools
@ -92,14 +93,15 @@ public class FwImageTask extends Task implements EfiDefine{
runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline());
System.out.println(Commandline.toString(cmdline.getCommandline()));
//System.out.println(Commandline.toString(cmdline.getCommandline()));
//GenBuildTask.myLogger.log(Commandline.toString(cmdline.getCommandline()),0);
//getProject().log(Commandline.toString(cmdline.getCommandline()));
revl = runner.execute();
if (EFI_SUCCESS == revl) {
//
// command execution success
//
System.out.println("fwimage succeeded!");
System.out.println("fwimage successed!");
} else {
//
// command execution fail

View File

@ -59,12 +59,12 @@ public class GenCRC32SectionTask extends Task implements EfiDefine{
///
/// absolute path of efi tools
///
String path = project.getProperty("env.Framework_Tools_Path");
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command;
if (path == null) {
command = "GenCRC32Section";
command = "gencrc32section";
} else {
command = path + "/" + "GenCRC32Section" ;
command = path + "/" + "gencrc32section" ;
}
//
// string line of input files

View File

@ -51,12 +51,12 @@ public class GenDepexTask extends Task implements EfiDefine {
//
// absolute path of edk tools
//
String path = project.getProperty("env.Framework_Tools_Path");
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command;
if (path == null) {
command = "GenDepex";
command = "gendepex";
} else {
command = path + "/" + "GenDepex";
command = path + "/" + "gendepex";
}
//
// argument of GenDepex tool
@ -87,7 +87,7 @@ public class GenDepexTask extends Task implements EfiDefine {
//
// command execution success
//
System.out.println("GenDepex execute succeeded!");
System.out.println("GenDepex execute successed!");
} else {
//
@ -163,4 +163,4 @@ public class GenDepexTask extends Task implements EfiDefine {
public String getPadding() {
return this.padding;
}
}
}

View File

@ -114,13 +114,17 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
GenFfsFileTask execute is to generate ffs file according to input section
dscriptive information.
*/
**/
public void execute() throws BuildException {
Section sect;
int fileSize;
int orgFileSize;
int fileDataSize;
int orgFileDataSize;
File ffsFile;
File ffsOrgFile;
FfsHeader ffsHeader = new FfsHeader();
FfsHeader orgFfsHeader = new FfsHeader();
String ffsSuffix = "";
String outputPath = "";
@ -128,7 +132,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
// Get Fraemwork_Tools_Path
//
Project pj = this.getOwningTarget().getProject();
path = pj.getProperty("env.Framework_Tools_Path");
path = pj.getProperty("env.FRAMEWORK_TOOLS_PATH");
//
// Check does the BaseName, Guid, FileType set value.
@ -165,14 +169,26 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
System.out.print("General Ffs file: file name is:\n");
System.out.print(outputPath + this.ffsFileGuid + '-' + this.baseName + ffsSuffix);
System.out.print("\n");
//
// Create file output stream -- dataBuffer.
//
// Create ffs ORG file. fileName = FfsFileGuid + BaseName + ffsSuffix +
// ".org".
//
ffsOrgFile = new File(outputPath + this.ffsFileGuid + '-' + this.baseName + ffsSuffix + ".org");
try {
//
// Create file output stream -- dataBuffer.
//
FileOutputStream dataFs = new FileOutputStream (ffsFile.getAbsolutePath());
DataOutputStream dataBuffer = new DataOutputStream (dataFs);
//
// Create org file output stream -- orgDataBuffer
//
FileOutputStream orgDataFs = new FileOutputStream (ffsOrgFile.getAbsolutePath());
DataOutputStream orgDataBuffer = new DataOutputStream (orgDataFs);
//
// Search SectionList find earch section and call it's
// ToBuffer function.
@ -185,7 +201,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
//
// The last section don't need 4 byte ffsAligment.
//
sect.toBuffer((DataOutputStream)dataBuffer);
sect.toBuffer((DataOutputStream)dataBuffer, (DataOutputStream) orgDataBuffer);
} catch (Exception e) {
throw new BuildException (e.getMessage());
}
@ -207,22 +223,40 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
FileInputStream fi = new FileInputStream (ffsFile.getAbsolutePath());
DataInputStream di = new DataInputStream (fi);
di.read(fileBuffer);
di.close();
di.close();
//
// create input org stream to read file data
//
byte[] orgFileBuffer = new byte[(int)ffsOrgFile.length()];
FileInputStream ofi = new FileInputStream (ffsOrgFile.getAbsolutePath());
DataInputStream odi = new DataInputStream (ofi);
odi.read(orgFileBuffer);
odi.close();
//
// Add GUID to header struct
//
if (this.ffsFileGuid != null) {
stringToGuid (this.ffsFileGuid, ffsHeader.name);
//
// Add Guid to org header struct
//
stringToGuid (this.ffsFileGuid, orgFfsHeader.name);
}
ffsHeader.ffsAttributes = this.attributes;
if ((ffsHeader.fileType = stringToType(this.ffsFileType))== -1) {
throw new BuildException ("FFS_FILE_TYPE unknow!\n");
}
//
// Copy ffsHeader.ffsAttribute and fileType to orgFfsHeader.ffsAttribute
// and fileType
//
orgFfsHeader.ffsAttributes = ffsHeader.ffsAttributes;
orgFfsHeader.fileType = ffsHeader.fileType;
//
// Adjust file size. The function is used to tripe the last
// section padding of 4 binary boundary.
@ -231,15 +265,21 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
if (ffsHeader.fileType != EFI_FV_FILETYPE_RAW) {
fileDataSize = adjustFileSize (fileBuffer);
orgFileDataSize = adjustFileSize (orgFileBuffer);
} else {
fileDataSize = fileBuffer.length;
orgFileDataSize = orgFileBuffer.length;
}
//
// 1. add header size to file size
//
fileSize = fileDataSize + ffsHeader.getSize();
//
// add header size to org file size
//
orgFileSize = orgFileDataSize + ffsHeader.getSize();
if ((ffsHeader.ffsAttributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {
if (ffsHeader.fileType == EFI_FV_FILETYPE_FFS_PAD) {
@ -256,6 +296,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
);
}
fileSize = fileSize + 2;
orgFileSize = orgFileSize + 2;
}
//
@ -264,7 +305,14 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
ffsHeader.ffsFileSize[0] = (byte)(fileSize & 0x00FF);
ffsHeader.ffsFileSize[1] = (byte)((fileSize & 0x00FF00)>>8);
ffsHeader.ffsFileSize[2] = (byte)(((int)fileSize & 0xFF0000)>>16);
//
// set file size to org header struct
//
orgFfsHeader.ffsFileSize[0] = (byte)(orgFileSize & 0x00FF);
orgFfsHeader.ffsFileSize[1] = (byte)((orgFileSize & 0x00FF00)>>8);
orgFfsHeader.ffsFileSize[2] = (byte)(((int)orgFileSize & 0xFF0000)>>16);
//
// Fill in checksums and state, these must be zero for checksumming
//
@ -272,21 +320,43 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
ffsHeader.structToBuffer(),
ffsHeader.getSize()
);
//
// Fill in org file's header check sum and state
//
orgFfsHeader.integrityCheck.header = calculateChecksum8 (
orgFfsHeader.structToBuffer(),
orgFfsHeader.getSize()
);
if ((this.attributes & FFS_ATTRIB_CHECKSUM) != 0) {
if ((this.attributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {
ffsHeader.integrityCheck.file = calculateChecksum8 (
fileBuffer,
fileDataSize
);
//
// Add org file header
//
orgFfsHeader.integrityCheck.file = calculateChecksum8 (
orgFileBuffer,
orgFileDataSize
);
} else {
ffsHeader.integrityCheck.file = calculateChecksum8 (
fileBuffer,
fileDataSize
);
//
// Add org file header
//
orgFfsHeader.integrityCheck.file = calculateChecksum8 (
orgFileBuffer,
orgFileDataSize
);
}
} else {
ffsHeader.integrityCheck.file = FFS_FIXED_CHECKSUM;
orgFfsHeader.integrityCheck.file = FFS_FIXED_CHECKSUM;
}
//
@ -295,21 +365,30 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
ffsHeader.ffsState = EFI_FILE_HEADER_CONSTRUCTION |
EFI_FILE_HEADER_VALID |
EFI_FILE_DATA_VALID;
orgFfsHeader.integrityCheck.file = ffsHeader.ffsState;
//
// create output stream to first write header data in file, then write sect data in file.
//
FileOutputStream headerFfs = new FileOutputStream (ffsFile.getAbsolutePath());
DataOutputStream ffsBuffer = new DataOutputStream (headerFfs);
FileOutputStream orgHeaderFfs = new FileOutputStream (ffsOrgFile.getAbsolutePath());
DataOutputStream orgFfsBuffer = new DataOutputStream (orgHeaderFfs);
//
// Add header struct and file data to FFS file
//
ffsBuffer.write(ffsHeader.structToBuffer());
orgFfsBuffer.write(orgFfsHeader.structToBuffer());
for (int i = 0; i< fileDataSize; i++) {
ffsBuffer.write(fileBuffer[i]);
}
for (int i = 0; i < orgFileDataSize; i++){
orgFfsBuffer.write(orgFileBuffer[i]);
}
//
// If there is a tail, then set it
@ -333,6 +412,9 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
tailByte[1] = (byte)((tailValue & 0xff00)>>8);
ffsBuffer.write(tailByte[0]);
ffsBuffer.write(tailByte[1]);
orgFfsBuffer.write(tailByte[0]);
orgFfsBuffer.write(tailByte[1]);
}
//
@ -340,6 +422,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
// the buffer can't be rewritten to file.
//
ffsBuffer.close();
orgFfsBuffer.close();
System.out.print ("Successful create ffs file!\n");
} catch (Exception e) {
throw new BuildException (e.getMessage());
@ -672,7 +755,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
}
if (ffsFileType.equals("EFI_FV_FILETYPE_FREEFORM")) {
return(byte)EFI_FV_FILETYPE_SECURITY_CORE;
return(byte)EFI_FV_FILETYPE_FREEFORM;
}
if (ffsFileType.equals("EFI_FV_FILETYPE_SECURITY_CORE")) {

View File

@ -14,6 +14,7 @@
**/
package org.tianocore.framework.tasks;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@ -22,16 +23,6 @@ import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.ProcessBuilder;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
GenFvImageTask
@ -39,10 +30,6 @@ import java.util.Map;
**/
public class GenFvImageTask extends Task implements EfiDefine{
///
/// tool name
///
static final private String toolName = "GenFvImage";
///
/// The name of input inf file
///
@ -51,15 +38,7 @@ public class GenFvImageTask extends Task implements EfiDefine{
/// The target architecture.
///
private String arch="";
///
/// Output directory
///
private String outputDir = ".";
///
/// argument list
///
LinkedList<String> argList = new LinkedList<String>();
/**
execute
@ -68,45 +47,68 @@ public class GenFvImageTask extends Task implements EfiDefine{
**/
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
String path = project.getProperty("env.Framework_Tools_Path");
if (path == null) {
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command = "";
if (path == null){
path = "";
} else {
path += File.separatorChar;
}else {
path = path + File.separatorChar;
}
if (arch != null && arch.length() > 0) {
argList.addFirst(path + toolName + "_" + arch);
} else {
argList.addFirst(path + toolName);
if (arch.equalsIgnoreCase("")){
command = path + "GenFvImage";
}
///
/// lauch the program
///
ProcessBuilder pb = new ProcessBuilder(argList);
pb.directory(new File(outputDir));
int exitCode = 0;
if (arch.equalsIgnoreCase("ia32")){
command = path + "GenFvImage_IA32";
}
if (arch.equalsIgnoreCase("x64")){
command = path + "GenFvImage_X64";
}
if (arch.equalsIgnoreCase("ipf")){
command = path + "GenFvImage_IPF";
}
String argument = infFile;
try {
Process cmdProc = pb.start();
InputStreamReader cmdOut = new InputStreamReader(cmdProc.getInputStream());
char[] buf = new char[1024];
exitCode = cmdProc.waitFor();
if (exitCode != 0) {
int len = cmdOut.read(buf, 0, 1024);
log(new String(buf, 0, len), Project.MSG_ERR);
Commandline commandLine = new Commandline();
commandLine.setExecutable(command);
commandLine.createArgument().setLine(argument);
LogStreamHandler streamHandler = new LogStreamHandler(this,
Project.MSG_INFO,
Project.MSG_WARN);
//
// create a execute object and set it's commandline
//
Execute runner = new Execute(streamHandler,null);
runner.setAntRun(project);
runner.setCommandline(commandLine.getCommandline());
System.out.println(Commandline.toString(commandLine.getCommandline()));
int revl = -1;
//
// user execute class call external programs - GenFvImage
//
revl = runner.execute();
//
// execute command line success!
//
if (EFI_SUCCESS == revl){
System.out.println("GenFvImage succeeded!");
} else {
log("GenFvImage - DONE!", Project.MSG_VERBOSE);
//
// execute command line failed!
//
throw new BuildException("GenFvImage failed !(error =" +
Integer.toHexString(revl) + ")");
}
} catch (Exception e) {
throw new BuildException(e.getMessage());
} finally {
if (exitCode != 0) {
throw new BuildException("GenFvImage: failed to generate FV file!");
}
}
System.out.println(e.getMessage());
}
}
/**
getInfFile
@ -126,9 +128,7 @@ public class GenFvImageTask extends Task implements EfiDefine{
@param infFile name of infFile
**/
public void setInfFile(String infFile) {
this.infFile = infFile;
argList.add("-I");
argList.add(infFile);
this.infFile = "-I " + infFile;
}
/**
@ -150,27 +150,5 @@ public class GenFvImageTask extends Task implements EfiDefine{
**/
public void setArch(String arch) {
this.arch = arch;
}
/**
getOutputDir
This function is to get output directory.
@return Path of output directory.
**/
public String getOutputDir() {
return outputDir;
}
/**
setOutputDir
This function is to set output directory.
@param outputDir The output direcotry.
**/
public void setOutputDir(String outputDir) {
this.outputDir = outputDir;
}
}
}

View File

@ -59,11 +59,11 @@ public class GenSectionTask extends Task implements EfiDefine {
//
// absolute path of efi tools
//
String path = project.getProperty("env.Framework_Tools_Path");
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
if (path == null) {
command = "GenSection";
command = "gensection";
} else {
command = path + "/" + "GenSection";
command = path + "/" + "gensection";
}
//
// argument of tools
@ -93,7 +93,7 @@ public class GenSectionTask extends Task implements EfiDefine {
//
// command execution success
//
System.out.println("gensection succeeded!");
System.out.println("gensection successed!");
} else {
//
// command execution fail

View File

@ -96,7 +96,7 @@ public class GuidChkTask extends Task implements EfiDefine{
//
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
String path = project.getProperty("env.Framework_Tools_Path");
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command;
if (path == null) {
command = "GuidChk";

View File

@ -74,7 +74,7 @@ public class MakeDeps extends Task {
}
Project prj = this.getOwningTarget().getProject();
String toolPath = prj.getProperty("env.Framework_Tools_Path");
String toolPath = prj.getProperty("env.FRAMEWORK_TOOLS_PATH");
///
/// compose full tool path
///

View File

@ -53,7 +53,7 @@ public class SectFile implements Section {
@param Buffer buffer to contain the section file content with alignment
**/
public void toBuffer (DataOutputStream Buffer){
public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer){
File sectFile;
byte data;
long fileLen;
@ -83,7 +83,11 @@ public class SectFile implements Section {
int i = 0;
while (i < fileLen) {
data = In.readByte();
Buffer.writeByte(data);
buffer.writeByte(data);
//
// Add data to org file
//
orgBuffer.writeByte(data);
i++;
}
@ -92,7 +96,11 @@ public class SectFile implements Section {
///
while ((fileLen & 0x03)!= 0) {
fileLen ++;
Buffer.writeByte(0);
buffer.writeByte(0);
//
// Add data to org file
//
orgBuffer.writeByte(0);
}
///

View File

@ -19,5 +19,5 @@ import java.io.DataOutputStream;
Section interface is for geting the contain buffer form compress, tool, and sectFile
**/
public interface Section {
public void toBuffer (DataOutputStream Buffer);
public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer);
}

View File

@ -46,7 +46,7 @@ public class SetStampTask extends Task implements EfiDefine {
///
/// absolute path of edk tools
///
String path = project.getProperty("env.Framework_Tools_Path");
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command;
if (path == null) {
command = "setstamp";
@ -82,7 +82,7 @@ public class SetStampTask extends Task implements EfiDefine {
///
/// command execution success
///
System.out.println("SetStamp execute succeeded!");
System.out.println("SetStamp execute successed!");
} else {
///
/// command execution fail
@ -133,4 +133,4 @@ public class SetStampTask extends Task implements EfiDefine {
return this.timeFile;
}
}
}

View File

@ -108,12 +108,12 @@ public class StrGatherTask extends Task implements EfiDefine {
///
/// absolute path of efi tools
///
String path = project.getProperty("env.Framework_Tools_Path");
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command;
if (path == null) {
command = "StrGather";
command = "strgather";
} else {
command = path + "/" + "StrGather";
command = path + "/" + "strgather";
}
///

View File

@ -39,7 +39,7 @@ public class Tool implements EfiDefine, Section {
@param buffer The buffer to put the result with alignment
**/
public void toBuffer (DataOutputStream buffer){
public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer){
File OutputFile;
byte data;
@ -72,6 +72,10 @@ public class Tool implements EfiDefine, Section {
while (i < fileLen) {
data = In.readByte();
buffer.writeByte(data);
//
// Add data to org file
//
orgBuffer.writeByte(data);
i ++;
}
@ -81,6 +85,7 @@ public class Tool implements EfiDefine, Section {
while ((fileLen & 0x03) != 0) {
fileLen++;
buffer.writeByte(0);
orgBuffer.writeByte(0);
}
In.close();

View File

@ -153,7 +153,7 @@ public class VfrCompilerTask extends Task implements EfiDefine {
**/
public void execute() throws BuildException {
Project project = this.getProject();
String toolPath= project.getProperty("env.Framework_Tools_Path");
String toolPath= project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command;
if (toolPath == null) {
command = "VfrCompile";

View File

@ -62,7 +62,7 @@ if not exist %XMLBEANS_HOME%\lib\saxon8.jar goto no_saxon8
@REM
set WORKSPACE=%CD%
set Framework_Tools_Path=%WORKSPACE%\Tools\bin
set FRAMEWORK_TOOLS_PATH=%WORKSPACE%\Tools\bin
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%XMLBEANS_HOME%\bin;%Framework_Tools_Path%;%PATH%
echo.