\r
package org.tianocore.build.autogen;\r
\r
-import org.tianocore.build.global.GlobalData;\r
-import org.tianocore.build.global.Spd;\r
-import org.tianocore.build.global.SurfaceAreaQuery;\r
-import org.tianocore.build.id.ModuleIdentification;\r
-import org.tianocore.build.id.PackageIdentification;\r
-import org.tianocore.GuidsDocument;\r
-import org.tianocore.LibraryClassDocument.LibraryClass;\r
-import org.tianocore.PPIsDocument;\r
-import org.tianocore.ProtocolsDocument;\r
-import org.tianocore.build.pcd.action.PCDAutoGenAction;\r
-import org.tianocore.build.exception.*;\r
-import org.tianocore.logger.EdkLog;\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.xmlbeans.XmlObject;\r
-\r
import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileOutputStream;\r
import java.io.FileReader;\r
import java.io.FileWriter;\r
import java.util.ArrayList;\r
import java.util.Map;\r
import java.util.Set;\r
\r
+import org.apache.tools.ant.BuildException;\r
+import org.apache.xmlbeans.XmlObject;\r
+import org.tianocore.GuidsDocument;\r
+import org.tianocore.LibraryClassDocument.LibraryClass;\r
+import org.tianocore.PPIsDocument;\r
+import org.tianocore.ProtocolsDocument;\r
+import org.tianocore.build.exception.*;\r
+import org.tianocore.build.global.GlobalData;\r
+import org.tianocore.build.global.Spd;\r
+import org.tianocore.build.global.SurfaceAreaQuery;\r
+import org.tianocore.build.id.ModuleIdentification;\r
+import org.tianocore.build.id.PackageIdentification;\r
+import org.tianocore.build.pcd.action.PCDAutoGenAction;\r
+import org.tianocore.logger.EdkLog;\r
+\r
/**\r
* This class is to generate Autogen.h and Autogen.c according to module surface\r
* area or library surface area.\r
// / The output path of Autogen.h and Autogen.c\r
// /\r
private String outputPath;\r
-\r
+ /// \r
+ /// The name of FV directory \r
+ /// \r
+ private String fvDir;\r
// /\r
// / The base name of module or library.\r
// /\r
* @param arch\r
* Target architecture.\r
*/\r
- public AutoGen(String outputPath, ModuleIdentification moduleId, String arch) {\r
+ public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch) {\r
this.outputPath = outputPath;\r
this.moduleId = moduleId;\r
this.arch = arch;\r
+ this.fvDir = fvDir;\r
\r
}\r
\r
// Add #ifndef ${BaseName}_AUTOGENH\r
// #def ${BseeName}_AUTOGENH\r
//\r
- fileBuffer.append("#ifndef " + this.moduleId.getName().toUpperCase()\r
- + "_AUTOGENH\r\n");\r
- fileBuffer.append("#define " + this.moduleId.getName().toUpperCase()\r
- + "_AUTOGENH\r\n\r\n");\r
+ fileBuffer.append("#ifndef " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") +"\r\n");\r
+ fileBuffer.append("#define " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") +"\r\n\r\n");\r
\r
//\r
// Write the specification version and release version at the begine\r
// moduleType.\r
//\r
moduleType = SurfaceAreaQuery.getModuleType();\r
-// switch (CommonDefinition.getModuleType(moduleType)) {\r
-// case CommonDefinition.ModuleTypeDxeCore:\r
-// case CommonDefinition.ModuleTypeDxeDriver:\r
-// case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
-// case CommonDefinition.ModuleTypeDxeSmmDriver:\r
-// case CommonDefinition.ModuleTypeDxeSalDriver:\r
-// case CommonDefinition.ModuleTypeUefiDriver:\r
-// case CommonDefinition.ModuleTypeUefiApplication:\r
-// fileBuffer.append(CommonDefinition.autoGenHLine1);\r
-// break;\r
-// default:\r
-// fileBuffer.append(CommonDefinition.autoGenHVersionDefault);\r
-// break;\r
-// }\r
-// switch (CommonDefinition.getModuleType(moduleType)) {\r
-// case CommonDefinition.ModuleTypeUefiDriver:\r
-// case CommonDefinition.ModuleTypeUefiApplication:\r
-// fileBuffer.append(CommonDefinition.autoGenHReleaseDefault);\r
-// break;\r
-// default:\r
-// fileBuffer.append(CommonDefinition.autoGenHLine2);\r
-// break;\r
-// }\r
\r
//\r
// Add "extern int __make_me_compile_correctly;" at begin of\r
// PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery\r
// .getDependencePkg(this.arch);\r
PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery\r
- .getDependencePkg(null);\r
+ .getDependencePkg(this.arch);\r
if (consumedPkgIdList != null) {\r
headerFileList = depPkgToAutogenH(consumedPkgIdList, moduleType);\r
item = headerFileList.iterator();\r
// Write library class's related *.h file to autogen.h.\r
//\r
String[] libClassList = SurfaceAreaQuery\r
- .getLibraryClasses(CommonDefinition.AlwaysConsumed);\r
+ .getLibraryClasses(CommonDefinition.AlwaysConsumed,this.arch);\r
if (libClassList != null) {\r
libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
item = libClassIncludeH.iterator();\r
}\r
\r
libClassList = SurfaceAreaQuery\r
- .getLibraryClasses(CommonDefinition.AlwaysProduced);\r
+ .getLibraryClasses(CommonDefinition.AlwaysProduced, this.arch);\r
if (libClassList != null) {\r
libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
item = libClassIncludeH.iterator();\r
}\r
fileBuffer.append("\r\n");\r
\r
- //\r
+ //\r
+ // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to \r
+ // {DEST_DIR_DRBUG}/FlashMap.h\r
+ // \r
+ if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) {\r
+ fileBuffer.append(CommonDefinition.include);\r
+ fileBuffer.append(" <");\r
+ fileBuffer.append(CommonDefinition.tianoR8FlashMapH + ">\r\n");\r
+ copyFlashMapHToDebugDir();\r
+ }\r
+\r
// Write PCD autogen information to AutoGen.h.\r
//\r
if (this.myPcdAutogen != null) {\r
// Add #ifndef ${BaseName}_AUTOGENH\r
// #def ${BseeName}_AUTOGENH\r
//\r
- fileBuffer.append("#ifndef " + this.moduleId.getName().toUpperCase()\r
- + "_AUTOGENH\r\n");\r
- fileBuffer.append("#define " + this.moduleId.getName().toUpperCase()\r
- + "_AUTOGENH\r\n\r\n");\r
+ fileBuffer.append("#ifndef " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") + "\r\n");\r
+ fileBuffer.append("#define " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") + "\r\n\r\n");\r
\r
//\r
// Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION\r
// Write library class's related *.h file to autogen.h\r
//\r
String[] libClassList = SurfaceAreaQuery\r
- .getLibraryClasses(CommonDefinition.AlwaysConsumed);\r
+ .getLibraryClasses(CommonDefinition.AlwaysConsumed, this.arch);\r
if (libClassList != null) {\r
libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
item = libClassIncludeH.iterator();\r
}\r
\r
libClassList = SurfaceAreaQuery\r
- .getLibraryClasses(CommonDefinition.AlwaysProduced);\r
+ .getLibraryClasses(CommonDefinition.AlwaysProduced, this.arch);\r
if (libClassList != null) {\r
libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
item = libClassIncludeH.iterator();\r
}\r
fileBuffer.append("\r\n");\r
\r
+ //\r
+ // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to \r
+ // {DEST_DIR_DRBUG}/FlashMap.h\r
+ // \r
+ if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) {\r
+ fileBuffer.append(CommonDefinition.include);\r
+ fileBuffer.append(" <");\r
+ fileBuffer.append(CommonDefinition.tianoR8FlashMapH + ">\r\n");\r
+ copyFlashMapHToDebugDir();\r
+ }\r
+\r
//\r
// Write PCD information to library AutoGen.h.\r
//\r
fileBuffer.append("{\r\n");\r
fileBuffer.append(" return EFI_SUCCESS;\r\n");\r
fileBuffer.append("}\r\n\r\n");\r
- break;\r
+\r
} else {\r
for (int i = 0; i < entryPointList.length; i++) {\r
- if (!entryPointList[i].equals("")) {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(entryPointList[i]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
- fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
- fileBuffer.append(" );\r\n");\r
- entryPointCount++;\r
- } else {\r
- break;\r
- }\r
+ fileBuffer.append("EFI_STATUS\r\n");\r
+ fileBuffer.append("EFIAPI\r\n");\r
+ fileBuffer.append(entryPointList[i]);\r
+ fileBuffer.append(" (\r\n");\r
+ fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
+ fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
+ fileBuffer.append(" );\r\n");\r
+ entryPointCount++;\r
}\r
fileBuffer\r
.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");\r
entryPointList = CommonDefinition.remDupString(entryPointList);\r
entryPointCount = 0;\r
\r
- fileBuffer\r
- .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");\r
- fileBuffer.append(Integer.toString(entryPointCount));\r
- fileBuffer.append(";\r\n\r\n");\r
-\r
if (entryPointList != null) {\r
for (int i = 0; i < entryPointList.length; i++) {\r
- if (!entryPointList[i].equals("")) {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(entryPointList[i]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer\r
- .append(" IN EFI_HANDLE ImageHandle\r\n");\r
- fileBuffer.append(" );\r\n");\r
- } else {\r
- break;\r
- }\r
- }\r
+ fileBuffer.append("EFI_STATUS\r\n");\r
+ fileBuffer.append("EFIAPI\r\n");\r
+ fileBuffer.append(entryPointList[i]);\r
+ fileBuffer.append(" (\r\n");\r
+ fileBuffer\r
+ .append(" IN EFI_HANDLE ImageHandle\r\n");\r
+ fileBuffer.append(" );\r\n");\r
+ entryPointCount++;\r
+ }\r
}\r
\r
+ fileBuffer\r
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");\r
+ fileBuffer.append(Integer.toString(entryPointCount));\r
+ fileBuffer.append(";\r\n\r\n");\r
+\r
fileBuffer.append("EFI_STATUS\r\n");\r
fileBuffer.append("EFIAPI\r\n");\r
fileBuffer.append("ProcessModuleUnloadList (\r\n");\r
entryPointCount = 0;\r
if (entryPointList != null) {\r
for (int i = 0; i < entryPointList.length; i++) {\r
- if (!entryPointList[i].equals("")) {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(entryPointList[i]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer\r
- .append(" IN EFI_HANDLE ImageHandle\r\n");\r
- fileBuffer.append(" );\r\n");\r
- entryPointCount++;\r
- } else {\r
- break;\r
- }\r
+ fileBuffer.append("EFI_STATUS\r\n");\r
+ fileBuffer.append("EFIAPI\r\n");\r
+ fileBuffer.append(entryPointList[i]);\r
+ fileBuffer.append(" (\r\n");\r
+ fileBuffer\r
+ .append(" IN EFI_HANDLE ImageHandle\r\n");\r
+ fileBuffer.append(" );\r\n");\r
+ entryPointCount++;\r
}\r
}\r
\r
fileBuffer.append(Integer.toString(entryPointCount));\r
fileBuffer.append(";\r\n\r\n");\r
\r
- if (entryPointList != null) {\r
- for (int i = 0; i < entryPointList.length; i++) {\r
- if (!entryPointList[i].equals("")) {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(entryPointList[i]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer\r
- .append(" IN EFI_HANDLE ImageHandle\r\n");\r
- fileBuffer.append(" );\r\n");\r
- } else {\r
- break;\r
- }\r
- }\r
- }\r
-\r
fileBuffer.append("EFI_STATUS\n");\r
fileBuffer.append("EFIAPI\r\n");\r
fileBuffer.append("ProcessModuleUnloadList (\r\n");\r
if (compDiagList != null && compDiagList.length != 0) {\r
if (drvBindList.length != compDiagList.length) {\r
throw new BuildException(\r
- "Different number of Driver Binding and Driver Configuration protocols!");\r
+ "Different number of Driver Binding and Driver Diagnosis protocols!");\r
}\r
\r
BitMask |= 0x04;\r
\r
}\r
\r
+ private void copyFlashMapHToDebugDir() throws AutoGenException{\r
+ \r
+ File inFile = new File(fvDir + File.separatorChar + CommonDefinition.flashMapH);\r
+ int size = (int)inFile.length();\r
+ byte[] buffer = new byte[size];\r
+ File outFile = new File (this.outputPath + File.separatorChar + CommonDefinition.tianoR8FlashMapH);\r
+ try{\r
+ if (inFile.exists()) {\r
+ FileInputStream fis = new FileInputStream (inFile);\r
+ fis.read(buffer);\r
+ FileOutputStream fos = new FileOutputStream(outFile);\r
+ fos.write(buffer);\r
+ fis.close();\r
+ fos.close();\r
+ }else {\r
+ throw new AutoGenException("The flashMap.h file don't exist!!");\r
+ }\r
+ } catch (Exception e){\r
+ throw new AutoGenException(e.getMessage());\r
+ }\r
+ \r
+ }\r
+\r
}
\ No newline at end of file