\r
This class is to generate Autogen.h and Autogen.c according to module surface area\r
or library surface area.\r
- \r
+\r
Copyright (c) 2006, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
http://opensource.org/licenses/bsd-license.php\r
- \r
+\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\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
+import org.tianocore.common.logger.EdkLog;\r
\r
/**\r
* This class is to generate Autogen.h and Autogen.c according to module surface\r
// / The output path of Autogen.h and Autogen.c\r
// /\r
private String outputPath;\r
- /// \r
- /// The name of FV directory \r
- /// \r
+ ///\r
+ /// The name of FV directory\r
+ ///\r
private String fvDir;\r
// /\r
// / The base name of module or library.\r
// / dependence on library instance surface area.\r
// /\r
private Set<String> mGuidList = new HashSet<String>();\r
- \r
+\r
//\r
// The dependence package list which recoreded in module or library surface\r
// area and it's dependence on library instance surface are.\r
private List<PackageIdentification> mDepPkgList = new LinkedList<PackageIdentification>();\r
\r
//\r
- // For non library module, add its library instance's construct and destructor to \r
+ // For non library module, add its library instance's construct and destructor to\r
// list.\r
- // \r
+ //\r
private List<String> libConstructList = new ArrayList<String>();\r
private List<String> libDestructList = new ArrayList<String>();\r
\r
//\r
- // List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack \r
- // \r
+ // List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack\r
+ //\r
private List<String> setVirtalAddList = new ArrayList<String>();\r
private List<String> exitBootServiceList = new ArrayList<String>();\r
\r
- \r
+\r
/**\r
* Construct function\r
- * \r
+ *\r
* This function mainly initialize some member variable.\r
- * \r
+ *\r
* @param outputPath\r
* Output path of AutoGen file.\r
* @param baseName\r
\r
/**\r
* saveFile function\r
- * \r
+ *\r
* This function save the content in stringBuffer to file.\r
- * \r
+ *\r
* @param fileName\r
* The name of file.\r
* @param fileBuffer\r
\r
/**\r
* genAutogen function\r
- * \r
+ *\r
* This function call libGenAutoGen or moduleGenAutogen function, which\r
* dependence on generate library autogen or module autogen.\r
- * \r
+ *\r
* @throws BuildException\r
* Failed to creat AutoGen.c & AutoGen.h.\r
*/\r
\r
/**\r
* moduleGenAutogen function\r
- * \r
+ *\r
* This function generates AutoGen.c & AutoGen.h for module.\r
- * \r
+ *\r
* @throws BuildException\r
* Faile to create module AutoGen.c & AutoGen.h.\r
*/\r
\r
/**\r
* libGenAutogen function\r
- * \r
+ *\r
* This function generates AutoGen.c & AutoGen.h for library.\r
- * \r
+ *\r
* @throws BuildException\r
* Faile to create library AutoGen.c & AutoGen.h\r
*/\r
\r
/**\r
* moduleGenAutogenH\r
- * \r
+ *\r
* This function generates AutoGen.h for module.\r
- * \r
+ *\r
* @throws BuildException\r
* Failed to generate AutoGen.h.\r
*/\r
fileBuffer.append("\r\n");\r
\r
//\r
- // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to \r
+ // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to\r
// {DEST_DIR_DRBUG}/FlashMap.h\r
- // \r
+ //\r
if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) {\r
fileBuffer.append(CommonDefinition.include);\r
fileBuffer.append(" <");\r
\r
/**\r
* moduleGenAutogenC\r
- * \r
+ *\r
* This function generates AutoGen.c for module.\r
- * \r
+ *\r
* @throws BuildException\r
* Failed to generate AutoGen.c.\r
*/\r
// autogen.c\r
//\r
LibInstanceToAutogenC(fileBuffer);\r
- \r
+\r
//\r
// Get module dependent Package identification.\r
//\r
if (!this.mDepPkgList.contains(packages[i])){\r
this.mDepPkgList.add(packages[i]);\r
}\r
- \r
+\r
}\r
- \r
+\r
//\r
// Write consumed ppi, guid, protocol to autogen.c\r
//\r
GuidGuidToAutogenC(fileBuffer);\r
\r
//\r
- // Call pcd autogen. \r
+ // Call pcd autogen.\r
//\r
this.myPcdAutogen = new PCDAutoGenAction(moduleId, this.arch, false, null);\r
try {\r
} catch (Exception exp) {\r
throw new PcdAutogenException (exp.getMessage());\r
}\r
- \r
+\r
if (this.myPcdAutogen != null) {\r
fileBuffer.append("\r\n");\r
fileBuffer.append(this.myPcdAutogen.OutputC());\r
\r
/**\r
* libGenAutogenH\r
- * \r
+ *\r
* This function generates AutoGen.h for library.\r
- * \r
+ *\r
* @throws BuildException\r
* Failed to generate AutoGen.c.\r
*/\r
\r
//\r
// Write consumed package's mdouleInfo related *.h file to autogen.h.\r
- // \r
+ //\r
moduleType = SurfaceAreaQuery.getModuleType();\r
PackageIdentification[] cosumedPkglist = SurfaceAreaQuery\r
.getDependencePkg(this.arch);\r
fileBuffer.append("\r\n");\r
\r
//\r
- // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to \r
+ // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to\r
// {DEST_DIR_DRBUG}/FlashMap.h\r
- // \r
+ //\r
if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) {\r
fileBuffer.append(CommonDefinition.include);\r
fileBuffer.append(" <");\r
\r
/**\r
* libGenAutogenC\r
- * \r
+ *\r
* This function generates AutoGen.h for library.\r
- * \r
+ *\r
* @throws BuildException\r
* Failed to generate AutoGen.c.\r
*/\r
fileBuffer.append("\r\n");\r
\r
//\r
- // Call pcd autogen. \r
+ // Call pcd autogen.\r
//\r
this.myPcdAutogen = new PCDAutoGenAction(this.moduleId,\r
this.arch,\r
- true, \r
+ true,\r
SurfaceAreaQuery.getModulePcdEntryNameArray());\r
try {\r
this.myPcdAutogen.execute();\r
\r
/**\r
* LibraryClassToAutogenH\r
- * \r
+ *\r
* This function returns *.h files declared by library classes which are\r
* consumed or produced by current build module or library.\r
- * \r
+ *\r
* @param libClassList\r
* List of library class which consumed or produce by current\r
* build module or library.\r
\r
/**\r
* IncludesToAutogenH\r
- * \r
+ *\r
* This function add include file in AutoGen.h file.\r
- * \r
+ *\r
* @param packageNameList\r
* List of module depended package.\r
* @param moduleType\r
\r
/**\r
* EntryPointToAutoGen\r
- * \r
+ *\r
* This function convert <ModuleEntryPoint> & <ModuleUnloadImage>\r
* information in mas to AutoGen.c\r
- * \r
+ *\r
* @param entryPointList\r
* List of entry point.\r
* @param fileBuffer\r
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
fileBuffer.append(" );\r\n");\r
entryPointCount++;\r
- \r
+\r
}\r
\r
fileBuffer.append("EFI_STATUS\r\n");\r
fileBuffer.append(" )\r\n\r\n");\r
fileBuffer.append("{\r\n");\r
\r
- \r
+\r
for (int i = 0; i < entryPointList.length; i++) {\r
fileBuffer\r
.append(" if (SetJump (&mJumpContext) == 0) {\r\n");\r
fileBuffer.append(" (ImageHandle, SystemTable));\r\n");\r
fileBuffer.append(" ASSERT (FALSE);\r\n");\r
fileBuffer.append(" }\r\n");\r
- \r
+\r
}\r
fileBuffer.append(" return mDriverEntryPointStatus;\r\n");\r
fileBuffer.append("}\r\n\r\n");\r
fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");\r
fileBuffer.append(" ASSERT (FALSE);\r\n");\r
fileBuffer.append("}\r\n\r\n");\r
- \r
+\r
}\r
- \r
- \r
+\r
+\r
//\r
// Add "ModuleUnloadImage" for DxeSmmDriver module type;\r
//\r
fileBuffer.append("{\r\n");\r
fileBuffer.append(" return EFI_SUCCESS;\r\n");\r
fileBuffer.append("}\r\n");\r
- \r
+\r
}else {\r
for (int i = 0; i < entryPointList.length; i++) {\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\n");\r
\r
}\r
- \r
+\r
//\r
// Add ModuleUnloadImage for DxeDriver and UefiDriver module type.\r
//\r
\r
/**\r
* PpiGuidToAutogenc\r
- * \r
+ *\r
* This function gets GUIDs from SPD file accrodeing to <PPIs> information\r
* and write those GUIDs to AutoGen.c.\r
- * \r
+ *\r
* @param fileBuffer\r
* String Buffer for Autogen.c file.\r
* @throws BuildException\r
// Get the all PPI adn PPI Notify from MSA file,\r
// then add those PPI ,and PPI Notify name to list.\r
//\r
- \r
+\r
String[] ppiList = SurfaceAreaQuery.getPpiArray(this.arch);\r
for (int i = 0; i < ppiList.length; i++) {\r
this.mPpiList.add(ppiList[i]);\r
\r
/**\r
* ProtocolGuidToAutogenc\r
- * \r
+ *\r
* This function gets GUIDs from SPD file accrodeing to <Protocol>\r
* information and write those GUIDs to AutoGen.c.\r
- * \r
+ *\r
* @param fileBuffer\r
* String Buffer for Autogen.c file.\r
* @throws BuildException\r
//\r
Iterator protocolIterator = this.mProtocolList.iterator();\r
String protocolKeyWord = null;\r
- \r
- \r
+\r
+\r
while (protocolIterator.hasNext()) {\r
protocolKeyWord = protocolIterator.next().toString();\r
cNameGuid = GlobalData.getProtocolGuid(this.mDepPkgList, protocolKeyWord);\r
\r
/**\r
* GuidGuidToAutogenc\r
- * \r
+ *\r
* This function gets GUIDs from SPD file accrodeing to <Guids> information\r
* and write those GUIDs to AutoGen.c.\r
- * \r
+ *\r
* @param fileBuffer\r
* String Buffer for Autogen.c file.\r
- * \r
+ *\r
*/\r
void GuidGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {\r
String[] cNameGuid = null;\r
\r
/**\r
* LibInstanceToAutogenC\r
- * \r
+ *\r
* This function adds dependent library instance to autogen.c,which\r
* includeing library's constructor, destructor, and library dependent ppi,\r
* protocol, guid, pcd information.\r
- * \r
+ *\r
* @param fileBuffer\r
* String buffer for AutoGen.c\r
* @throws BuildException\r
\r
/**\r
* LibConstructorToAutogenc\r
- * \r
+ *\r
* This function writes library constructor list to AutoGen.c. The library\r
* constructor's parameter and return value depend on module type.\r
- * \r
+ *\r
* @param libInstanceList\r
* List of library construct name.\r
* @param moduleType\r
\r
/**\r
* LibDestructorToAutogenc\r
- * \r
+ *\r
* This function writes library destructor list to AutoGen.c. The library\r
* destructor's parameter and return value depend on module type.\r
- * \r
+ *\r
* @param libInstanceList\r
* List of library destructor name.\r
* @param moduleType\r
//\r
// If no library destructor function, return EFI_SUCCESS.\r
//\r
- \r
+\r
for (int i = 0; i < libInstanceList.size(); i++) {\r
if (isFirst) {\r
fileBuffer.append(" EFI_STATUS Status;\r\n");\r
\r
/**\r
* ExternsDriverBindingToAutoGenC\r
- * \r
+ *\r
* This function is to write DRIVER_BINDING, COMPONENT_NAME,\r
* DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.\r
- * \r
+ *\r
* @param fileBuffer\r
* String buffer for AutoGen.c\r
*/\r
\r
/**\r
* ExternCallBackToAutoGenC\r
- * \r
+ *\r
* This function adds <SetVirtualAddressMapCallBack> and\r
* <ExitBootServicesCallBack> infomation to AutoGen.c\r
- * \r
+ *\r
* @param fileBuffer\r
* String buffer for AutoGen.c\r
* @throws BuildException\r
void ExternCallBackToAutoGenC(StringBuffer fileBuffer)\r
throws BuildException {\r
//\r
- // Collect module's <SetVirtualAddressMapCallBack> and \r
- // <ExitBootServiceCallBack> and add to setVirtualAddList \r
+ // Collect module's <SetVirtualAddressMapCallBack> and\r
+ // <ExitBootServiceCallBack> and add to setVirtualAddList\r
// exitBootServiceList.\r
- // \r
+ //\r
String[] setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray();\r
String[] exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray();\r
if (setVirtuals != null) {\r
}\r
//\r
// Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>\r
- // and <ExitBootServicesCallBack> \r
- // \r
+ // and <ExitBootServicesCallBack>\r
+ //\r
String moduleType = this.moduleId.getModuleType();\r
boolean UefiOrDxeModule = false;\r
int Count = 0;\r
}\r
//\r
// If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER\r
- // UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of \r
- // _gDriverSetVirtualAddressMapEvent list. \r
+ // UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of\r
+ // _gDriverSetVirtualAddressMapEvent list.\r
//\r
if (!UefiOrDxeModule) {\r
fileBuffer.append(",\r\n NULL");\r
}\r
\r
private void copyFlashMapHToDebugDir() throws AutoGenException{\r
- \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
//\r
- // If TianoR8FlashMap.h existed and the flashMap.h don't change, \r
+ // If TianoR8FlashMap.h existed and the flashMap.h don't change,\r
// do nothing.\r
- // \r
+ //\r
if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) {\r
try{\r
if (inFile.exists()) {\r
}\r
}\r
}\r
- \r
+\r
/**\r
*This function first order the library instances, then collect\r
*library instance 's PPI, Protocol, GUID,\r
.getLibDestructorName();\r
\r
//\r
- // Collect SetVirtualAddressMapCallBack and \r
+ // Collect SetVirtualAddressMapCallBack and\r
// ExitBootServiceCallBack.\r
- // \r
+ //\r
setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray();\r
exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray();\r
if (setVirtuals != null) {\r