///\r
String baseName = "";\r
///\r
+ /// \r
+ /// \r
+ String moduleType;\r
+ ///\r
/// module Guid\r
///\r
String ffsFileGuid = "";\r
///\r
boolean ffsAttribRecovery = false;\r
///\r
- /// ffsAligenment value is used to set the corresponding bit in the output \r
+ /// ffsAttribDataAlignment value is used to set the corresponding bit in the output \r
/// FFS file header.The specified FFS alignment must be a value between 0 \r
/// and 7 inclusive\r
///\r
- int ffsAlignment = 0;\r
+ int ffsAttribDataAlignment = 0;\r
///\r
/// ffsAttribChecksum value is used to set the corresponding bit in the \r
/// output FFS file header\r
// Create ffs file. File name = FfsFileGuid + BaseName + ffsSuffix.\r
// If outputDir's value was set, file will output to the outputDir.\r
//\r
- ffsSuffix = TypeToSuffix (this.ffsFileType);\r
+ ffsSuffix = TypeToSuffix (this.moduleType);\r
if (!this.outputDir.equals("")) {\r
String temp;\r
outputPath = this.outputDir;\r
\r
}\r
\r
- ffsFile = new File (outputPath + this.ffsFileGuid + '-' + this.baseName + ffsSuffix); \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
+ String ffsFilePath = outputPath + this.ffsFileGuid + '-' + this.baseName + ffsSuffix;\r
+ ffsFile = new File (ffsFilePath); \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
+ ffsOrgFile = new File(ffsFilePath + ".org");\r
\r
+ log(ffsFile.getName());\r
+ log(ffsOrgFile.getName());\r
try {\r
//\r
// Create file output stream -- dataBuffer.\r
ffsHeader.ffsState = EFI_FILE_HEADER_CONSTRUCTION | \r
EFI_FILE_HEADER_VALID | \r
EFI_FILE_DATA_VALID;\r
- orgFfsHeader.integrityCheck.file = ffsHeader.ffsState;\r
+ orgFfsHeader.ffsState = ffsHeader.ffsState;\r
\r
//\r
// create output stream to first write header data in file, then write sect data in file.\r
//\r
ffsBuffer.close();\r
orgFfsBuffer.close();\r
- System.out.print ("Successful create ffs file!\n");\r
} catch (Exception e) {\r
+ log("genffsfile failed!");\r
throw new BuildException (e.getMessage());\r
}\r
} \r
This function is to get the ffsAligment\r
@return The value of ffsAligment.\r
**/\r
- public int getFfsAligment() {\r
- return this.ffsAlignment;\r
+ public int getFfsAttribDataAlignment() {\r
+ return this.ffsAttribDataAlignment;\r
}\r
\r
/**\r
This function is to set ffsAligment \r
@param ffsAligment The value of ffsAligment.\r
**/\r
- public void setFfsAligment(int ffsAligment) {\r
- this.ffsAlignment = ffsAligment;\r
- if (this.ffsAlignment > 7) {\r
- throw new BuildException ("FFS_ALIGMENT Scope is 0-7");\r
+ public void setFfsAttribDataAlignment(String ffsAligment) {\r
+ this.ffsAttribDataAlignment = stringToInt(ffsAligment.replaceAll(" ", "").toLowerCase());\r
+ if (this.ffsAttribDataAlignment < 0 || this.ffsAttribDataAlignment > 7) {\r
+ throw new BuildException ("FFS_ATTRIB_DATA_ALIGMENT must be 0-7");\r
} else {\r
- attributes |= (((byte)this.ffsAlignment) << 3);\r
+ attributes |= (((byte)this.ffsAttribDataAlignment) << 3);\r
}\r
}\r
\r
@return The suffix of ffs file\r
**/\r
private String TypeToSuffix (String ffsFileType){\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_ALL")) {\r
- return "";\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_RAW")) {\r
- return EFI_FV_FFS_FILETYPE_STR;\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_FREEFORM")) {\r
- return EFI_FV_FFS_FILETYPE_STR;\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_SECURITY_CORE")) {\r
- return EFI_FV_SEC_FILETYPE_STR;\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_PEI_CORE")) {\r
- return EFI_FV_PEI_FILETYPE_STR;\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_DXE_CORE")) {\r
- return EFI_FV_DXE_FILETYPE_STR;\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_PEIM")) {\r
- return EFI_FV_PEI_FILETYPE_STR;\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_DRIVER")) {\r
- return EFI_FV_DXE_FILETYPE_STR;\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER")) {\r
- return EFI_FV_PEI_FILETYPE_STR;\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_APPLICATION")) {\r
- return EFI_FV_APP_FILETYPE_STR;\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE")) {\r
- return EFI_FV_FVI_FILETYPE_STR;\r
- }\r
- if (ffsFileType.equals("EFI_FV_FILETYPE_FFS_PAD")) {\r
- return EFI_FV_FFS_FILETYPE_STR;\r
+ String[][] suffix = { { "BASE", ".FFS"},\r
+ { "SEC", ".SEC" }, { "PEI_CORE", ".PEI" }, \r
+ { "PEIM", ".PEI" }, { "DXE_CORE", ".DXE" },\r
+ { "DXE_DRIVER", ".DXE" }, { "DXE_RUNTIME_DRIVER", ".DXE" }, \r
+ { "DXE_SAL_DRIVER", ".DXE" }, { "DXE_SMM_DRIVER", ".DXE" }, \r
+ { "TOOL", ".FFS" }, { "UEFI_DRIVER", ".DXE" },\r
+ { "UEFI_APPLICATION", ".APP" }, { "USER_DEFINED", ".FFS" } };\r
+\r
+ for (int i = 0; i < suffix.length; i++) {\r
+ if (suffix[i][0].equalsIgnoreCase(moduleType)) {\r
+ return suffix[i][1];\r
+ }\r
}\r
- return "";\r
+\r
+ return ".FFS";\r
}\r
\r
\r
public void setOutputDir(String outputDir) {\r
this.outputDir = outputDir;\r
}\r
+\r
+ public String getModuleType() {\r
+ return this.moduleType;\r
+ }\r
+\r
+ public void setModuleType(String moduleType) {\r
+ this.moduleType = moduleType;\r
+ }\r
+\r
+ /**\r
+ Convert a string to a integer.\r
+ \r
+ @param intString The string representing a integer\r
+ \r
+ @retval int The value of integer represented by the\r
+ given string; -1 is returned if the format\r
+ of the string is wrong.\r
+ **/\r
+ private int stringToInt(String intString) {\r
+ int value;\r
+ int hexPrefixPos = intString.indexOf("0x");\r
+ int radix = 10;\r
+ String intStringNoPrefix;\r
+\r
+ if (hexPrefixPos >= 0) {\r
+ radix = 16;\r
+ intStringNoPrefix = intString.substring(hexPrefixPos + 2, intString.length());\r
+ } else {\r
+ intStringNoPrefix = intString;\r
+ }\r
+\r
+ try {\r
+ value = Integer.parseInt(intStringNoPrefix, radix);\r
+ } catch (NumberFormatException e) {\r
+ log("Incorrect format of int (" + intString + "). -1 is assumed");\r
+ return -1;\r
+ }\r
+\r
+ return value;\r
+ }\r
}\r