summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqouyang <qouyang@6f19259b-4bc3-4df7-8a09-765794883524>2006-08-15 08:05:34 +0000
committerqouyang <qouyang@6f19259b-4bc3-4df7-8a09-765794883524>2006-08-15 08:05:34 +0000
commit87379bbecf036195249649680b958e501dc952a5 (patch)
tree9eabf298502358aa3598a59f689435b9f1deef32
parent9c7790d2cb87584ac2a844f0757142edebd35f71 (diff)
downloadedk2-87379bbecf036195249649680b958e501dc952a5.zip
edk2-87379bbecf036195249649680b958e501dc952a5.tar.gz
edk2-87379bbecf036195249649680b958e501dc952a5.tar.bz2
Modify GenFfsTask to make it don't create ORG file.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1271 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java37
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFfsFileTask.java552
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java8
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SectFile.java29
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Section.java2
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java7
6 files changed, 274 insertions, 361 deletions
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java
index 674c6c8..84f9176 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java
@@ -17,11 +17,8 @@
package org.tianocore.framework.tasks;
-import java.io.DataInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -54,18 +51,17 @@ public class CompressSection implements Section, FfsTypes{
@param Buffer The point of output buffer
**/
- public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer){
+ public void toBuffer (DataOutputStream buffer){
Section sect;
- File compressOut;
//
// Get section file in compress node.
//
try{
- compressOut = new File ("Compress.temp");
- FileOutputStream fo = new FileOutputStream (compressOut.getName());
- DataOutputStream Do = new DataOutputStream (fo);
+
+ ByteArrayOutputStream bo = new ByteArrayOutputStream ();
+ DataOutputStream Do = new DataOutputStream (bo);
//
// Get each section which under the compress {};
@@ -79,7 +75,7 @@ public class CompressSection implements Section, FfsTypes{
// Call each section class's toBuffer function.
//
try {
- sect.toBuffer(Do, orgBuffer);
+ sect.toBuffer(Do);
}
catch (BuildException e) {
System.out.print(e.getMessage());
@@ -90,16 +86,9 @@ public class CompressSection implements Section, FfsTypes{
Do.close();
//
- // Get contain to Buffer
- //
- FileInputStream fi = new FileInputStream (compressOut.getName());
- DataInputStream di = new DataInputStream (fi);
- byte[] fileBuffer = new byte[(int)compressOut.length()];
- di.read(fileBuffer);
-
- //
// Call compress
//
+ byte[] fileBuffer = bo.toByteArray();
Compress myCompress = new Compress(fileBuffer, fileBuffer.length);
//
@@ -151,18 +140,10 @@ public class CompressSection implements Section, FfsTypes{
buffer.writeByte(0);
}
//
- // orgBuffer 4 Byte aligment
- //
- size = (int)compressOut.length();
- while ((size & 0x03) != 0){
- size ++;
- orgBuffer.writeByte(0);
- }
- //
// Delete temp file
//
- di.close();
- compressOut.delete();
+ //di.close();
+ //compressOut.delete();
}
catch (Exception e){
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFfsFileTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFfsFileTask.java
index 117ef39..b41e7f8 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFfsFileTask.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFfsFileTask.java
@@ -27,6 +27,7 @@ import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.tianocore.common.logger.EdkLog;
/**
GenFfsFileTask
@@ -112,7 +113,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
/// The path of Framewor_Tools_Paht.
///
static String path = "";
-
+
/**
execute
@@ -120,18 +121,17 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
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 = "";
-
+ Project project = this.getOwningTarget().getProject();
+ //
+ // set Logger
+ //
+ FrameworkLogger logger = new FrameworkLogger(project, "genFfs");
+ EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
+ EdkLog.setLogger(logger);
+
//
// Get Fraemwork_Tools_Path
//
@@ -170,267 +170,8 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
}
String ffsFilePath = outputPath + this.ffsFileGuid + '-' + this.baseName + ffsSuffix;
- ffsFile = new File (ffsFilePath);
- //
- // Create ffs ORG file. fileName = FfsFileGuid + BaseName + ffsSuffix +
- // ".org".
- //
- ffsOrgFile = new File(ffsFilePath + ".org");
-
- log(ffsFile.getName());
- log(ffsOrgFile.getName());
- 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.
- //
- Iterator sectionIter = this.sectionList.iterator();
- while (sectionIter.hasNext()) {
- sect = (Section)sectionIter.next();
-
- try {
- //
- // The last section don't need 4 byte ffsAligment.
- //
- sect.toBuffer((DataOutputStream)dataBuffer, (DataOutputStream) orgDataBuffer);
- } catch (Exception e) {
- throw new BuildException (e.getMessage());
- }
- }
- dataBuffer.close();
- orgDataBuffer.close();
- } catch (Exception e) {
- throw new BuildException (e.getMessage());
- }
-
- //
- // Creat Ffs file header
- //
- try {
-
- //
- // create input stream to read file data
- //
- byte[] fileBuffer = new byte[(int)ffsFile.length()];
- FileInputStream fi = new FileInputStream (ffsFile.getAbsolutePath());
- DataInputStream di = new DataInputStream (fi);
- di.read(fileBuffer);
- 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.
- //
- //
- 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) {
-
- throw new BuildException (
- "FFS_ATTRIB_TAIL_PRESENT=TRUE is " +
- "invalid for PAD files"
- );
- }
- if (fileSize == ffsHeader.getSize()) {
- throw new BuildException (
- "FFS_ATTRIB_TAIL_PRESENT=TRUE is " +
- "invalid for zero length files"
- );
- }
- fileSize = fileSize + 2;
- orgFileSize = orgFileSize + 2;
- }
-
- //
- // 2. set file size to header struct
- //
- 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
- //
- ffsHeader.integrityCheck.header = calculateChecksum8 (
- 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;
- }
-
- //
- // Set the state now. Spec says the checksum assumes the state is 0.
- //
- ffsHeader.ffsState = EFI_FILE_HEADER_CONSTRUCTION |
- EFI_FILE_HEADER_VALID |
- EFI_FILE_DATA_VALID;
- orgFfsHeader.ffsState = 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
- //
- if ((this.attributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {
- short tailValue ;
- byte [] tailByte = new byte[2];
-
- //
- // reverse tailvalue , integritycheck.file as hight byte, and
- // integritycheck.header as low byte.
- //
- tailValue = (short)(ffsHeader.integrityCheck.header & 0xff);
- tailValue = (short)((tailValue) | ((ffsHeader.integrityCheck.file << 8) & 0xff00));
- tailValue = (short)~tailValue;
-
- //
- // Change short to byte[2]
- //
- tailByte[0] = (byte)(tailValue & 0xff);
- tailByte[1] = (byte)((tailValue & 0xff00)>>8);
- ffsBuffer.write(tailByte[0]);
- ffsBuffer.write(tailByte[1]);
-
- orgFfsBuffer.write(tailByte[0]);
- orgFfsBuffer.write(tailByte[1]);
- }
-
- //
- // close output stream. Note if don't close output stream
- // the buffer can't be rewritten to file.
- //
- ffsBuffer.close();
- orgFfsBuffer.close();
- } catch (Exception e) {
- log("genffsfile failed!");
- throw new BuildException (e.getMessage());
- }
+ File ffsFile = new File (ffsFilePath);
+ genFfs(ffsFile);
}
/**
@@ -941,43 +682,260 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
this.outputDir = outputDir;
}
+ /**
+ getModuleTyp
+
+ This function is to get string of module type.
+
+ @return moduleType The string of module type.
+ **/
public String getModuleType() {
return this.moduleType;
}
+ /**
+ setModuleType
+
+ This function is to set moduleType.
+
+ @param moduleType The string of module type.
+ **/
public void setModuleType(String moduleType) {
this.moduleType = moduleType;
}
-
+
/**
- Convert a string to a integer.
-
- @param intString The string representing a integer
-
- @retval int The value of integer represented by the
- given string; -1 is returned if the format
- of the string is wrong.
- **/
- private int stringToInt(String intString) {
- int value;
- int hexPrefixPos = intString.indexOf("0x");
- int radix = 10;
- String intStringNoPrefix;
-
- if (hexPrefixPos >= 0) {
- radix = 16;
- intStringNoPrefix = intString.substring(hexPrefixPos + 2, intString.length());
- } else {
- intStringNoPrefix = intString;
+ Convert a string to a integer.
+
+ @param intString The string representing a integer
+
+ @retval int The value of integer represented by the
+ given string; -1 is returned if the format
+ of the string is wrong.
+ **/
+ private int stringToInt(String intString) {
+ int value;
+ int hexPrefixPos = intString.indexOf("0x");
+ int radix = 10;
+ String intStringNoPrefix;
+
+ if (hexPrefixPos >= 0) {
+ radix = 16;
+ intStringNoPrefix = intString.substring(hexPrefixPos + 2, intString.length());
+ } else {
+ intStringNoPrefix = intString;
+ }
+
+ try {
+ value = Integer.parseInt(intStringNoPrefix, radix);
+ } catch (NumberFormatException e) {
+ log("Incorrect format of int [" + intString + "]. -1 is assumed");
+ return -1;
+ }
+
+ 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 genFfs(File ffsFile) {
+ Section sect;
+ int fileSize;
+ int fileDataSize;
+ FfsHeader ffsHeader = new FfsHeader();
+ FfsHeader orgFfsHeader = new FfsHeader();
+
+ EdkLog.log(EdkLog.EDK_INFO, ffsFile.getName());
+
+ try {
+ //
+ // Create file output stream -- dataBuffer.
+ //
+ FileOutputStream dataFs = new FileOutputStream (ffsFile.getAbsolutePath());
+ DataOutputStream dataBuffer = new DataOutputStream (dataFs);
+
+ //
+ // Search SectionList find earch section and call it's
+ // ToBuffer function.
+ //
+ Iterator sectionIter = this.sectionList.iterator();
+ while (sectionIter.hasNext()) {
+ sect = (Section)sectionIter.next();
+
+ try {
+ //
+ // The last section don't need 4 byte ffsAligment.
+ //
+ sect.toBuffer((DataOutputStream)dataBuffer);
+ } catch (Exception e) {
+ throw new BuildException (e.getMessage());
+ }
+ }
+ dataBuffer.close();
+ } catch (Exception e) {
+ throw new BuildException (e.getMessage());
}
+ //
+ // Creat Ffs file header
+ //
try {
- value = Integer.parseInt(intStringNoPrefix, radix);
- } catch (NumberFormatException e) {
- log("Incorrect format of int [" + intString + "]. -1 is assumed");
- return -1;
+
+ //
+ // create input stream to read file data
+ //
+ byte[] fileBuffer = new byte[(int)ffsFile.length()];
+ FileInputStream fi = new FileInputStream (ffsFile.getAbsolutePath());
+ DataInputStream di = new DataInputStream (fi);
+ di.read(fileBuffer);
+ di.close();
+
+ //
+ // Add GUID to header struct
+ //
+ if (this.ffsFileGuid != null) {
+ stringToGuid (this.ffsFileGuid, ffsHeader.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.
+ //
+ //
+ if (ffsHeader.fileType != EFI_FV_FILETYPE_RAW) {
+
+ fileDataSize = adjustFileSize (fileBuffer);
+ } else {
+ fileDataSize = fileBuffer.length;
+ }
+
+ //
+ // 1. add header size to file size
+ //
+ fileSize = fileDataSize + ffsHeader.getSize();
+
+ if ((ffsHeader.ffsAttributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {
+ if (ffsHeader.fileType == EFI_FV_FILETYPE_FFS_PAD) {
+
+ throw new BuildException (
+ "FFS_ATTRIB_TAIL_PRESENT=TRUE is " +
+ "invalid for PAD files"
+ );
+ }
+ if (fileSize == ffsHeader.getSize()) {
+ throw new BuildException (
+ "FFS_ATTRIB_TAIL_PRESENT=TRUE is " +
+ "invalid for 0-length files"
+ );
+ }
+ fileSize = fileSize + 2;
+ }
+
+ //
+ // 2. set file size to header struct
+ //
+ ffsHeader.ffsFileSize[0] = (byte)(fileSize & 0x00FF);
+ ffsHeader.ffsFileSize[1] = (byte)((fileSize & 0x00FF00)>>8);
+ ffsHeader.ffsFileSize[2] = (byte)(((int)fileSize & 0xFF0000)>>16);
+
+ //
+ // Fill in checksums and state, these must be zero for checksumming
+ //
+ ffsHeader.integrityCheck.header = calculateChecksum8 (
+ ffsHeader.structToBuffer(),
+ ffsHeader.getSize()
+ );
+
+ if ((this.attributes & FFS_ATTRIB_CHECKSUM) != 0) {
+ if ((this.attributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {
+ ffsHeader.integrityCheck.file = calculateChecksum8 (
+ fileBuffer,
+ fileDataSize
+ );
+ } else {
+ ffsHeader.integrityCheck.file = calculateChecksum8 (
+ fileBuffer,
+ fileDataSize
+ );
+ }
+ } else {
+ ffsHeader.integrityCheck.file = FFS_FIXED_CHECKSUM;
+ orgFfsHeader.integrityCheck.file = FFS_FIXED_CHECKSUM;
+ }
+
+ //
+ // Set the state now. Spec says the checksum assumes the state is 0.
+ //
+ ffsHeader.ffsState = EFI_FILE_HEADER_CONSTRUCTION |
+ EFI_FILE_HEADER_VALID |
+ EFI_FILE_DATA_VALID;
+
+ //
+ // 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);
+
+ //
+ // Add header struct and file data to FFS file
+ //
+ ffsBuffer.write(ffsHeader.structToBuffer());
+ ffsBuffer.write(fileBuffer, 0, fileDataSize);
+
+
+
+ //
+ // If there is a tail, then set it
+ //
+ if ((this.attributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {
+ short tailValue ;
+ byte [] tailByte = new byte[2];
+
+ //
+ // reverse tailvalue , integritycheck.file as hight byte, and
+ // integritycheck.header as low byte.
+ //
+ tailValue = (short)(ffsHeader.integrityCheck.header & 0xff);
+ tailValue = (short)((tailValue) | ((ffsHeader.integrityCheck.file << 8) & 0xff00));
+ tailValue = (short)~tailValue;
+
+ //
+ // Change short to byte[2]
+ //
+ tailByte[0] = (byte)(tailValue & 0xff);
+ tailByte[1] = (byte)((tailValue & 0xff00)>>8);
+ ffsBuffer.write(tailByte[0]);
+ ffsBuffer.write(tailByte[1]);
+
+ }
+
+ //
+ // close output stream. Note if don't close output stream
+ // the buffer can't be rewritten to file.
+ //
+ ffsBuffer.close();
+ } catch (Exception e) {
+ log("genffsfile failed!");
+ throw new BuildException (e.getMessage());
}
- return value;
}
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java
index 90a613f..78eabf9 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java
@@ -18,19 +18,11 @@ package org.tianocore.framework.tasks;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
-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
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SectFile.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SectFile.java
index b603a3e..c110f3b 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SectFile.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SectFile.java
@@ -53,10 +53,9 @@ public class SectFile implements Section {
@param Buffer buffer to contain the section file content with alignment
**/
- public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer){
+ public void toBuffer (DataOutputStream buffer){
File sectFile;
- byte data;
- long fileLen;
+ int fileLen;
///
/// open file
@@ -67,7 +66,7 @@ public class SectFile implements Section {
/// check if file exist.
///
if (! sectFile.exists()) {
- throw new BuildException("The file " + this.fileName + " does not exist!\n");
+ throw new BuildException("The file " + this.fileName + " is not exist!\n");
}
@@ -78,18 +77,10 @@ public class SectFile implements Section {
FileInputStream fs = new FileInputStream (sectFile.getAbsoluteFile());
DataInputStream In = new DataInputStream (fs);
- fileLen = sectFile.length();
-
- int i = 0;
- while (i < fileLen) {
- data = In.readByte();
- buffer.writeByte(data);
- //
- // Add data to org file
- //
- orgBuffer.writeByte(data);
- i++;
- }
+ fileLen = (int)sectFile.length();
+ byte[] sectBuffer = new byte[fileLen];
+ In.read(sectBuffer);
+ buffer.write(sectBuffer);
///
/// 4 byte alignment
@@ -97,10 +88,6 @@ public class SectFile implements Section {
while ((fileLen & 0x03)!= 0) {
fileLen ++;
buffer.writeByte(0);
- //
- // Add data to org file
- //
- orgBuffer.writeByte(0);
}
///
@@ -113,4 +100,4 @@ public class SectFile implements Section {
throw new BuildException("SectFile, toBuffer failed!\n");
}
}
-}
+} \ No newline at end of file
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Section.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Section.java
index 6abee52..5fa8d7b 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Section.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Section.java
@@ -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, DataOutputStream orgBuffer);
+ public void toBuffer (DataOutputStream buffer);
} \ No newline at end of file
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java
index 67e0a86..4cc4d37 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java
@@ -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, DataOutputStream orgBuffer){
+ public void toBuffer (DataOutputStream buffer){
File OutputFile;
byte data;
@@ -72,10 +72,6 @@ public class Tool implements EfiDefine, Section {
while (i < fileLen) {
data = In.readByte();
buffer.writeByte(data);
- //
- // Add data to org file
- //
- orgBuffer.writeByte(data);
i ++;
}
@@ -85,7 +81,6 @@ public class Tool implements EfiDefine, Section {
while ((fileLen & 0x03) != 0) {
fileLen++;
buffer.writeByte(0);
- orgBuffer.writeByte(0);
}
In.close();