mirror of https://github.com/acidanthera/audk.git
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:
parent
a28984d905
commit
2da8968bb5
|
@ -54,7 +54,7 @@ public class CompressSection implements Section, FfsTypes{
|
||||||
@param Buffer The point of output buffer
|
@param Buffer The point of output buffer
|
||||||
|
|
||||||
**/
|
**/
|
||||||
public void toBuffer (DataOutputStream Buffer){
|
public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer){
|
||||||
|
|
||||||
Section sect;
|
Section sect;
|
||||||
File compressOut;
|
File compressOut;
|
||||||
|
@ -79,7 +79,7 @@ public class CompressSection implements Section, FfsTypes{
|
||||||
// Call each section class's toBuffer function.
|
// Call each section class's toBuffer function.
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
sect.toBuffer(Do);
|
sect.toBuffer(Do, orgBuffer);
|
||||||
}
|
}
|
||||||
catch (BuildException e) {
|
catch (BuildException e) {
|
||||||
System.out.print(e.getMessage());
|
System.out.print(e.getMessage());
|
||||||
|
@ -121,7 +121,7 @@ public class CompressSection implements Section, FfsTypes{
|
||||||
Ch.SectionHeader.type = (byte) EFI_SECTION_COMPRESSION;
|
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 .
|
// EFI_STANDARD_COMPRSSION for compressType .
|
||||||
// That is follow old Genffsfile tools. Some code will be added for
|
// That is follow old Genffsfile tools. Some code will be added for
|
||||||
// the different compressName;
|
// the different compressName;
|
||||||
|
@ -138,19 +138,26 @@ public class CompressSection implements Section, FfsTypes{
|
||||||
//
|
//
|
||||||
// First add CompressHeader to Buffer, then add Compress data.
|
// First add CompressHeader to Buffer, then add Compress data.
|
||||||
//
|
//
|
||||||
Buffer.write (headerBuffer);
|
buffer.write (headerBuffer);
|
||||||
Buffer.write(myCompress.outputBuffer);
|
buffer.write(myCompress.outputBuffer);
|
||||||
|
|
||||||
//
|
//
|
||||||
// 4 Byte aligment
|
// Buffer 4 Byte aligment
|
||||||
//
|
//
|
||||||
int size = Ch.GetSize() + myCompress.outputBuffer.length;
|
int size = Ch.GetSize() + myCompress.outputBuffer.length;
|
||||||
|
|
||||||
while ((size & 0x03) != 0){
|
while ((size & 0x03) != 0){
|
||||||
size ++;
|
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
|
// Delete temp file
|
||||||
//
|
//
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.taskdefs.Execute;
|
import org.apache.tools.ant.taskdefs.Execute;
|
||||||
import org.apache.tools.ant.taskdefs.LogStreamHandler;
|
import org.apache.tools.ant.taskdefs.LogStreamHandler;
|
||||||
import org.apache.tools.ant.types.Commandline;
|
import org.apache.tools.ant.types.Commandline;
|
||||||
|
import org.tianocore.build.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
FwImageTask class.
|
FwImageTask class.
|
||||||
|
@ -65,12 +66,12 @@ public class FwImageTask extends Task implements EfiDefine{
|
||||||
//
|
//
|
||||||
// absolute path of efi tools
|
// absolute path of efi tools
|
||||||
//
|
//
|
||||||
String path = project.getProperty("env.Framework_Tools_Path");
|
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
||||||
String command;
|
String command;
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
command = "FwImage";
|
command = "fwimage";
|
||||||
} else {
|
} else {
|
||||||
command = path + "/" + "FwImage";
|
command = path + "/" + "fwimage";
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// argument of tools
|
// argument of tools
|
||||||
|
@ -92,14 +93,15 @@ public class FwImageTask extends Task implements EfiDefine{
|
||||||
|
|
||||||
runner.setAntRun(project);
|
runner.setAntRun(project);
|
||||||
runner.setCommandline(cmdline.getCommandline());
|
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();
|
revl = runner.execute();
|
||||||
if (EFI_SUCCESS == revl) {
|
if (EFI_SUCCESS == revl) {
|
||||||
//
|
//
|
||||||
// command execution success
|
// command execution success
|
||||||
//
|
//
|
||||||
System.out.println("fwimage succeeded!");
|
System.out.println("fwimage successed!");
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// command execution fail
|
// command execution fail
|
||||||
|
|
|
@ -59,12 +59,12 @@ public class GenCRC32SectionTask extends Task implements EfiDefine{
|
||||||
///
|
///
|
||||||
/// absolute path of efi tools
|
/// absolute path of efi tools
|
||||||
///
|
///
|
||||||
String path = project.getProperty("env.Framework_Tools_Path");
|
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
||||||
String command;
|
String command;
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
command = "GenCRC32Section";
|
command = "gencrc32section";
|
||||||
} else {
|
} else {
|
||||||
command = path + "/" + "GenCRC32Section" ;
|
command = path + "/" + "gencrc32section" ;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// string line of input files
|
// string line of input files
|
||||||
|
|
|
@ -51,12 +51,12 @@ public class GenDepexTask extends Task implements EfiDefine {
|
||||||
//
|
//
|
||||||
// absolute path of edk tools
|
// absolute path of edk tools
|
||||||
//
|
//
|
||||||
String path = project.getProperty("env.Framework_Tools_Path");
|
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
||||||
String command;
|
String command;
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
command = "GenDepex";
|
command = "gendepex";
|
||||||
} else {
|
} else {
|
||||||
command = path + "/" + "GenDepex";
|
command = path + "/" + "gendepex";
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// argument of GenDepex tool
|
// argument of GenDepex tool
|
||||||
|
@ -87,7 +87,7 @@ public class GenDepexTask extends Task implements EfiDefine {
|
||||||
//
|
//
|
||||||
// command execution success
|
// command execution success
|
||||||
//
|
//
|
||||||
System.out.println("GenDepex execute succeeded!");
|
System.out.println("GenDepex execute successed!");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
|
|
|
@ -114,13 +114,17 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
|
|
||||||
GenFfsFileTask execute is to generate ffs file according to input section
|
GenFfsFileTask execute is to generate ffs file according to input section
|
||||||
dscriptive information.
|
dscriptive information.
|
||||||
*/
|
**/
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
Section sect;
|
Section sect;
|
||||||
int fileSize;
|
int fileSize;
|
||||||
|
int orgFileSize;
|
||||||
int fileDataSize;
|
int fileDataSize;
|
||||||
|
int orgFileDataSize;
|
||||||
File ffsFile;
|
File ffsFile;
|
||||||
|
File ffsOrgFile;
|
||||||
FfsHeader ffsHeader = new FfsHeader();
|
FfsHeader ffsHeader = new FfsHeader();
|
||||||
|
FfsHeader orgFfsHeader = new FfsHeader();
|
||||||
String ffsSuffix = "";
|
String ffsSuffix = "";
|
||||||
String outputPath = "";
|
String outputPath = "";
|
||||||
|
|
||||||
|
@ -128,7 +132,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
// Get Fraemwork_Tools_Path
|
// Get Fraemwork_Tools_Path
|
||||||
//
|
//
|
||||||
Project pj = this.getOwningTarget().getProject();
|
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.
|
// Check does the BaseName, Guid, FileType set value.
|
||||||
|
@ -166,13 +170,25 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
System.out.print(outputPath + this.ffsFileGuid + '-' + this.baseName + ffsSuffix);
|
System.out.print(outputPath + this.ffsFileGuid + '-' + this.baseName + ffsSuffix);
|
||||||
System.out.print("\n");
|
System.out.print("\n");
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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.
|
// Create file output stream -- dataBuffer.
|
||||||
//
|
//
|
||||||
try {
|
|
||||||
FileOutputStream dataFs = new FileOutputStream (ffsFile.getAbsolutePath());
|
FileOutputStream dataFs = new FileOutputStream (ffsFile.getAbsolutePath());
|
||||||
DataOutputStream dataBuffer = new DataOutputStream (dataFs);
|
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
|
// Search SectionList find earch section and call it's
|
||||||
// ToBuffer function.
|
// ToBuffer function.
|
||||||
|
@ -185,7 +201,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
//
|
//
|
||||||
// The last section don't need 4 byte ffsAligment.
|
// The last section don't need 4 byte ffsAligment.
|
||||||
//
|
//
|
||||||
sect.toBuffer((DataOutputStream)dataBuffer);
|
sect.toBuffer((DataOutputStream)dataBuffer, (DataOutputStream) orgDataBuffer);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BuildException (e.getMessage());
|
throw new BuildException (e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -209,12 +225,24 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
di.read(fileBuffer);
|
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
|
// Add GUID to header struct
|
||||||
//
|
//
|
||||||
if (this.ffsFileGuid != null) {
|
if (this.ffsFileGuid != null) {
|
||||||
stringToGuid (this.ffsFileGuid, ffsHeader.name);
|
stringToGuid (this.ffsFileGuid, ffsHeader.name);
|
||||||
|
//
|
||||||
|
// Add Guid to org header struct
|
||||||
|
//
|
||||||
|
stringToGuid (this.ffsFileGuid, orgFfsHeader.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ffsHeader.ffsAttributes = this.attributes;
|
ffsHeader.ffsAttributes = this.attributes;
|
||||||
|
@ -222,6 +250,12 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
throw new BuildException ("FFS_FILE_TYPE unknow!\n");
|
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
|
// Adjust file size. The function is used to tripe the last
|
||||||
|
@ -231,15 +265,21 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
if (ffsHeader.fileType != EFI_FV_FILETYPE_RAW) {
|
if (ffsHeader.fileType != EFI_FV_FILETYPE_RAW) {
|
||||||
|
|
||||||
fileDataSize = adjustFileSize (fileBuffer);
|
fileDataSize = adjustFileSize (fileBuffer);
|
||||||
|
orgFileDataSize = adjustFileSize (orgFileBuffer);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fileDataSize = fileBuffer.length;
|
fileDataSize = fileBuffer.length;
|
||||||
|
orgFileDataSize = orgFileBuffer.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// 1. add header size to file size
|
// 1. add header size to file size
|
||||||
//
|
//
|
||||||
fileSize = fileDataSize + ffsHeader.getSize();
|
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.ffsAttributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {
|
||||||
if (ffsHeader.fileType == EFI_FV_FILETYPE_FFS_PAD) {
|
if (ffsHeader.fileType == EFI_FV_FILETYPE_FFS_PAD) {
|
||||||
|
@ -256,6 +296,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fileSize = fileSize + 2;
|
fileSize = fileSize + 2;
|
||||||
|
orgFileSize = orgFileSize + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -265,6 +306,13 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
ffsHeader.ffsFileSize[1] = (byte)((fileSize & 0x00FF00)>>8);
|
ffsHeader.ffsFileSize[1] = (byte)((fileSize & 0x00FF00)>>8);
|
||||||
ffsHeader.ffsFileSize[2] = (byte)(((int)fileSize & 0xFF0000)>>16);
|
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
|
// Fill in checksums and state, these must be zero for checksumming
|
||||||
//
|
//
|
||||||
|
@ -272,6 +320,13 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
ffsHeader.structToBuffer(),
|
ffsHeader.structToBuffer(),
|
||||||
ffsHeader.getSize()
|
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_CHECKSUM) != 0) {
|
||||||
if ((this.attributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {
|
if ((this.attributes & FFS_ATTRIB_TAIL_PRESENT) != 0) {
|
||||||
|
@ -279,14 +334,29 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
fileBuffer,
|
fileBuffer,
|
||||||
fileDataSize
|
fileDataSize
|
||||||
);
|
);
|
||||||
|
//
|
||||||
|
// Add org file header
|
||||||
|
//
|
||||||
|
orgFfsHeader.integrityCheck.file = calculateChecksum8 (
|
||||||
|
orgFileBuffer,
|
||||||
|
orgFileDataSize
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
ffsHeader.integrityCheck.file = calculateChecksum8 (
|
ffsHeader.integrityCheck.file = calculateChecksum8 (
|
||||||
fileBuffer,
|
fileBuffer,
|
||||||
fileDataSize
|
fileDataSize
|
||||||
);
|
);
|
||||||
|
//
|
||||||
|
// Add org file header
|
||||||
|
//
|
||||||
|
orgFfsHeader.integrityCheck.file = calculateChecksum8 (
|
||||||
|
orgFileBuffer,
|
||||||
|
orgFileDataSize
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ffsHeader.integrityCheck.file = FFS_FIXED_CHECKSUM;
|
ffsHeader.integrityCheck.file = FFS_FIXED_CHECKSUM;
|
||||||
|
orgFfsHeader.integrityCheck.file = FFS_FIXED_CHECKSUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -295,7 +365,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
ffsHeader.ffsState = EFI_FILE_HEADER_CONSTRUCTION |
|
ffsHeader.ffsState = EFI_FILE_HEADER_CONSTRUCTION |
|
||||||
EFI_FILE_HEADER_VALID |
|
EFI_FILE_HEADER_VALID |
|
||||||
EFI_FILE_DATA_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.
|
// create output stream to first write header data in file, then write sect data in file.
|
||||||
|
@ -303,14 +373,23 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
FileOutputStream headerFfs = new FileOutputStream (ffsFile.getAbsolutePath());
|
FileOutputStream headerFfs = new FileOutputStream (ffsFile.getAbsolutePath());
|
||||||
DataOutputStream ffsBuffer = new DataOutputStream (headerFfs);
|
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
|
// Add header struct and file data to FFS file
|
||||||
//
|
//
|
||||||
ffsBuffer.write(ffsHeader.structToBuffer());
|
ffsBuffer.write(ffsHeader.structToBuffer());
|
||||||
|
orgFfsBuffer.write(orgFfsHeader.structToBuffer());
|
||||||
|
|
||||||
for (int i = 0; i< fileDataSize; i++) {
|
for (int i = 0; i< fileDataSize; i++) {
|
||||||
ffsBuffer.write(fileBuffer[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 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);
|
tailByte[1] = (byte)((tailValue & 0xff00)>>8);
|
||||||
ffsBuffer.write(tailByte[0]);
|
ffsBuffer.write(tailByte[0]);
|
||||||
ffsBuffer.write(tailByte[1]);
|
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.
|
// the buffer can't be rewritten to file.
|
||||||
//
|
//
|
||||||
ffsBuffer.close();
|
ffsBuffer.close();
|
||||||
|
orgFfsBuffer.close();
|
||||||
System.out.print ("Successful create ffs file!\n");
|
System.out.print ("Successful create ffs file!\n");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BuildException (e.getMessage());
|
throw new BuildException (e.getMessage());
|
||||||
|
@ -672,7 +755,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ffsFileType.equals("EFI_FV_FILETYPE_FREEFORM")) {
|
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")) {
|
if (ffsFileType.equals("EFI_FV_FILETYPE_SECURITY_CORE")) {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
**/
|
**/
|
||||||
package org.tianocore.framework.tasks;
|
package org.tianocore.framework.tasks;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.Project;
|
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.taskdefs.LogStreamHandler;
|
||||||
import org.apache.tools.ant.types.Commandline;
|
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
|
GenFvImageTask
|
||||||
|
|
||||||
|
@ -39,10 +30,6 @@ import java.util.Map;
|
||||||
|
|
||||||
**/
|
**/
|
||||||
public class GenFvImageTask extends Task implements EfiDefine{
|
public class GenFvImageTask extends Task implements EfiDefine{
|
||||||
///
|
|
||||||
/// tool name
|
|
||||||
///
|
|
||||||
static final private String toolName = "GenFvImage";
|
|
||||||
///
|
///
|
||||||
/// The name of input inf file
|
/// The name of input inf file
|
||||||
///
|
///
|
||||||
|
@ -51,14 +38,6 @@ public class GenFvImageTask extends Task implements EfiDefine{
|
||||||
/// The target architecture.
|
/// The target architecture.
|
||||||
///
|
///
|
||||||
private String arch="";
|
private String arch="";
|
||||||
///
|
|
||||||
/// Output directory
|
|
||||||
///
|
|
||||||
private String outputDir = ".";
|
|
||||||
///
|
|
||||||
/// argument list
|
|
||||||
///
|
|
||||||
LinkedList<String> argList = new LinkedList<String>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
execute
|
execute
|
||||||
|
@ -68,45 +47,68 @@ public class GenFvImageTask extends Task implements EfiDefine{
|
||||||
**/
|
**/
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
Project project = this.getOwningTarget().getProject();
|
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){
|
if (path == null){
|
||||||
path = "";
|
path = "";
|
||||||
}else {
|
}else {
|
||||||
path += File.separatorChar;
|
path = path + File.separatorChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arch != null && arch.length() > 0) {
|
if (arch.equalsIgnoreCase("")){
|
||||||
argList.addFirst(path + toolName + "_" + arch);
|
command = path + "GenFvImage";
|
||||||
} else {
|
|
||||||
argList.addFirst(path + toolName);
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
|
||||||
///
|
|
||||||
/// lauch the program
|
|
||||||
///
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(argList);
|
|
||||||
pb.directory(new File(outputDir));
|
|
||||||
int exitCode = 0;
|
|
||||||
try {
|
try {
|
||||||
Process cmdProc = pb.start();
|
|
||||||
InputStreamReader cmdOut = new InputStreamReader(cmdProc.getInputStream());
|
|
||||||
char[] buf = new char[1024];
|
|
||||||
|
|
||||||
exitCode = cmdProc.waitFor();
|
Commandline commandLine = new Commandline();
|
||||||
if (exitCode != 0) {
|
commandLine.setExecutable(command);
|
||||||
int len = cmdOut.read(buf, 0, 1024);
|
commandLine.createArgument().setLine(argument);
|
||||||
log(new String(buf, 0, len), Project.MSG_ERR);
|
|
||||||
|
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 {
|
} else {
|
||||||
log("GenFvImage - DONE!", Project.MSG_VERBOSE);
|
|
||||||
}
|
//
|
||||||
} catch (Exception e) {
|
// execute command line failed!
|
||||||
throw new BuildException(e.getMessage());
|
//
|
||||||
} finally {
|
throw new BuildException("GenFvImage failed !(error =" +
|
||||||
if (exitCode != 0) {
|
Integer.toHexString(revl) + ")");
|
||||||
throw new BuildException("GenFvImage: failed to generate FV file!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
getInfFile
|
getInfFile
|
||||||
|
@ -126,9 +128,7 @@ public class GenFvImageTask extends Task implements EfiDefine{
|
||||||
@param infFile name of infFile
|
@param infFile name of infFile
|
||||||
**/
|
**/
|
||||||
public void setInfFile(String infFile) {
|
public void setInfFile(String infFile) {
|
||||||
this.infFile = infFile;
|
this.infFile = "-I " + infFile;
|
||||||
argList.add("-I");
|
|
||||||
argList.add(infFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,26 +151,4 @@ public class GenFvImageTask extends Task implements EfiDefine{
|
||||||
public void setArch(String arch) {
|
public void setArch(String arch) {
|
||||||
this.arch = 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -59,11 +59,11 @@ public class GenSectionTask extends Task implements EfiDefine {
|
||||||
//
|
//
|
||||||
// absolute path of efi tools
|
// absolute path of efi tools
|
||||||
//
|
//
|
||||||
String path = project.getProperty("env.Framework_Tools_Path");
|
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
command = "GenSection";
|
command = "gensection";
|
||||||
} else {
|
} else {
|
||||||
command = path + "/" + "GenSection";
|
command = path + "/" + "gensection";
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// argument of tools
|
// argument of tools
|
||||||
|
@ -93,7 +93,7 @@ public class GenSectionTask extends Task implements EfiDefine {
|
||||||
//
|
//
|
||||||
// command execution success
|
// command execution success
|
||||||
//
|
//
|
||||||
System.out.println("gensection succeeded!");
|
System.out.println("gensection successed!");
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// command execution fail
|
// command execution fail
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class GuidChkTask extends Task implements EfiDefine{
|
||||||
//
|
//
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
Project project = this.getOwningTarget().getProject();
|
Project project = this.getOwningTarget().getProject();
|
||||||
String path = project.getProperty("env.Framework_Tools_Path");
|
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
||||||
String command;
|
String command;
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
command = "GuidChk";
|
command = "GuidChk";
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class MakeDeps extends Task {
|
||||||
}
|
}
|
||||||
|
|
||||||
Project prj = this.getOwningTarget().getProject();
|
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
|
/// compose full tool path
|
||||||
///
|
///
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class SectFile implements Section {
|
||||||
|
|
||||||
@param Buffer buffer to contain the section file content with alignment
|
@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;
|
File sectFile;
|
||||||
byte data;
|
byte data;
|
||||||
long fileLen;
|
long fileLen;
|
||||||
|
@ -83,7 +83,11 @@ public class SectFile implements Section {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < fileLen) {
|
while (i < fileLen) {
|
||||||
data = In.readByte();
|
data = In.readByte();
|
||||||
Buffer.writeByte(data);
|
buffer.writeByte(data);
|
||||||
|
//
|
||||||
|
// Add data to org file
|
||||||
|
//
|
||||||
|
orgBuffer.writeByte(data);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +96,11 @@ public class SectFile implements Section {
|
||||||
///
|
///
|
||||||
while ((fileLen & 0x03)!= 0) {
|
while ((fileLen & 0x03)!= 0) {
|
||||||
fileLen ++;
|
fileLen ++;
|
||||||
Buffer.writeByte(0);
|
buffer.writeByte(0);
|
||||||
|
//
|
||||||
|
// Add data to org file
|
||||||
|
//
|
||||||
|
orgBuffer.writeByte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
|
@ -19,5 +19,5 @@ import java.io.DataOutputStream;
|
||||||
Section interface is for geting the contain buffer form compress, tool, and sectFile
|
Section interface is for geting the contain buffer form compress, tool, and sectFile
|
||||||
**/
|
**/
|
||||||
public interface Section {
|
public interface Section {
|
||||||
public void toBuffer (DataOutputStream Buffer);
|
public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer);
|
||||||
}
|
}
|
|
@ -46,7 +46,7 @@ public class SetStampTask extends Task implements EfiDefine {
|
||||||
///
|
///
|
||||||
/// absolute path of edk tools
|
/// absolute path of edk tools
|
||||||
///
|
///
|
||||||
String path = project.getProperty("env.Framework_Tools_Path");
|
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
||||||
String command;
|
String command;
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
command = "setstamp";
|
command = "setstamp";
|
||||||
|
@ -82,7 +82,7 @@ public class SetStampTask extends Task implements EfiDefine {
|
||||||
///
|
///
|
||||||
/// command execution success
|
/// command execution success
|
||||||
///
|
///
|
||||||
System.out.println("SetStamp execute succeeded!");
|
System.out.println("SetStamp execute successed!");
|
||||||
} else {
|
} else {
|
||||||
///
|
///
|
||||||
/// command execution fail
|
/// command execution fail
|
||||||
|
|
|
@ -108,12 +108,12 @@ public class StrGatherTask extends Task implements EfiDefine {
|
||||||
///
|
///
|
||||||
/// absolute path of efi tools
|
/// absolute path of efi tools
|
||||||
///
|
///
|
||||||
String path = project.getProperty("env.Framework_Tools_Path");
|
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
||||||
String command;
|
String command;
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
command = "StrGather";
|
command = "strgather";
|
||||||
} else {
|
} else {
|
||||||
command = path + "/" + "StrGather";
|
command = path + "/" + "strgather";
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class Tool implements EfiDefine, Section {
|
||||||
|
|
||||||
@param buffer The buffer to put the result with alignment
|
@param buffer The buffer to put the result with alignment
|
||||||
**/
|
**/
|
||||||
public void toBuffer (DataOutputStream buffer){
|
public void toBuffer (DataOutputStream buffer, DataOutputStream orgBuffer){
|
||||||
File OutputFile;
|
File OutputFile;
|
||||||
byte data;
|
byte data;
|
||||||
|
|
||||||
|
@ -72,6 +72,10 @@ public class Tool implements EfiDefine, Section {
|
||||||
while (i < fileLen) {
|
while (i < fileLen) {
|
||||||
data = In.readByte();
|
data = In.readByte();
|
||||||
buffer.writeByte(data);
|
buffer.writeByte(data);
|
||||||
|
//
|
||||||
|
// Add data to org file
|
||||||
|
//
|
||||||
|
orgBuffer.writeByte(data);
|
||||||
i ++;
|
i ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +85,7 @@ public class Tool implements EfiDefine, Section {
|
||||||
while ((fileLen & 0x03) != 0) {
|
while ((fileLen & 0x03) != 0) {
|
||||||
fileLen++;
|
fileLen++;
|
||||||
buffer.writeByte(0);
|
buffer.writeByte(0);
|
||||||
|
orgBuffer.writeByte(0);
|
||||||
}
|
}
|
||||||
In.close();
|
In.close();
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ public class VfrCompilerTask extends Task implements EfiDefine {
|
||||||
**/
|
**/
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
Project project = this.getProject();
|
Project project = this.getProject();
|
||||||
String toolPath= project.getProperty("env.Framework_Tools_Path");
|
String toolPath= project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
||||||
String command;
|
String command;
|
||||||
if (toolPath == null) {
|
if (toolPath == null) {
|
||||||
command = "VfrCompile";
|
command = "VfrCompile";
|
||||||
|
|
|
@ -62,7 +62,7 @@ if not exist %XMLBEANS_HOME%\lib\saxon8.jar goto no_saxon8
|
||||||
@REM
|
@REM
|
||||||
set WORKSPACE=%CD%
|
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%
|
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%XMLBEANS_HOME%\bin;%Framework_Tools_Path%;%PATH%
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
Loading…
Reference in New Issue