X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fautogen%2FAutoGen.java;h=8c92bef43ade581357877f6127a785fbb7152eda;hb=3e73f377a8b366c595c2790876e6409fea48191d;hp=e385dea64eb7bb8324e45400adc3bd6f48dc177b;hpb=c60019f637b21263c1e3063c41a5bc59cd26a8d8;p=mirror_edk2.git diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java index e385dea64e..8c92bef43a 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java +++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java @@ -34,14 +34,15 @@ import java.util.Set; import org.apache.tools.ant.BuildException; import org.apache.xmlbeans.XmlObject; -import org.tianocore.build.exception.*; +import org.tianocore.build.exception.AutoGenException; import org.tianocore.build.global.GlobalData; import org.tianocore.build.global.SurfaceAreaQuery; import org.tianocore.build.id.ModuleIdentification; import org.tianocore.build.id.PackageIdentification; import org.tianocore.build.pcd.action.PCDAutoGenAction; -import org.tianocore.common.logger.EdkLog; import org.tianocore.common.definitions.ToolDefinitions; +import org.tianocore.common.exception.EdkException; +import org.tianocore.common.logger.EdkLog; /** This class is to generate Autogen.h and Autogen.c according to module surface @@ -116,6 +117,9 @@ public class AutoGen { private List setVirtalAddList = new ArrayList(); private List exitBootServiceList = new ArrayList(); + private SurfaceAreaQuery saq = null; + + private ModuleIdentification parentId = null; /** Construct function @@ -131,12 +135,13 @@ public class AutoGen { @param arch Target architecture. **/ - public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch) { + public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch, SurfaceAreaQuery saq, ModuleIdentification parentId) { this.outputPath = outputPath; this.moduleId = moduleId; this.arch = arch; this.fvDir = fvDir; - + this.saq = saq; + this.parentId = parentId; } /** @@ -206,29 +211,28 @@ public class AutoGen { @throws BuildException Failed to creat AutoGen.c & AutoGen.h. **/ - public void genAutogen() throws BuildException { + public void genAutogen() throws EdkException { try { // // If outputPath do not exist, create it. // File path = new File(outputPath); path.mkdirs(); - - // - // Check current is library or not, then call the corresponding - // function. - // - if (this.moduleId.isLibrary()) { - libGenAutogen(); - } else { - moduleGenAutogen(); - } - - } catch (Exception e) { - throw new BuildException( - "Failed to create AutoGen.c & AutoGen.h!\n" - + e.getMessage()); + } catch (Exception e) { + throw new AutoGenException( + "Failed to create " + + outputPath + " directory"); } + + // + // Check current is library or not, then call the corresponding + // function. + // + if (this.moduleId.isLibrary()) { + libGenAutogen(); + } else { + moduleGenAutogen(); + } } /** @@ -239,17 +243,10 @@ public class AutoGen { @throws BuildException Faile to create module AutoGen.c & AutoGen.h. **/ - void moduleGenAutogen() throws BuildException { - - try { - collectLibInstanceInfo(); - moduleGenAutogenC(); - moduleGenAutogenH(); - } catch (Exception e) { - throw new BuildException( - "Faile to create module AutoGen.c & AutoGen.h!\n" - + e.getMessage()); - } + void moduleGenAutogen() throws EdkException { + collectLibInstanceInfo(); + moduleGenAutogenC(); + moduleGenAutogenH(); } /** @@ -260,15 +257,9 @@ public class AutoGen { @throws BuildException Faile to create library AutoGen.c & AutoGen.h **/ - void libGenAutogen() throws BuildException { - try { - libGenAutogenC(); - libGenAutogenH(); - } catch (Exception e) { - throw new BuildException( - "Failed to create library AutoGen.c & AutoGen.h!\n" - + e.getMessage()); - } + void libGenAutogen() throws EdkException { + libGenAutogenC(); + libGenAutogenH(); } /** @@ -279,7 +270,7 @@ public class AutoGen { @throws BuildException Failed to generate AutoGen.h. **/ - void moduleGenAutogenH() throws AutoGenException { + void moduleGenAutogenH() throws EdkException { Set libClassIncludeH; String moduleType; @@ -314,7 +305,7 @@ public class AutoGen { // be got from module surface area instead of hard code by it's // moduleType. // - moduleType = SurfaceAreaQuery.getModuleType(); + moduleType = saq.getModuleType(); // // Add "extern int __make_me_compile_correctly;" at begin of @@ -325,7 +316,7 @@ public class AutoGen { // // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION. // - String[] specList = SurfaceAreaQuery.getExternSpecificaiton(); + String[] specList = saq.getExternSpecificaiton(); for (int i = 0; i < specList.length; i++) { fileBuffer.append(CommonDefinition.DEFINE + specList[i] + "\r\n"); @@ -335,8 +326,7 @@ public class AutoGen { // // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery // .getDependencePkg(this.arch); - PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery - .getDependencePkg(this.arch); + PackageIdentification[] consumedPkgIdList = saq.getDependencePkg(this.arch); if (consumedPkgIdList != null) { headerFileList = depPkgToAutogenH(consumedPkgIdList, moduleType); item = headerFileList.iterator(); @@ -348,8 +338,7 @@ public class AutoGen { // // Write library class's related *.h file to autogen.h. // - String[] libClassList = SurfaceAreaQuery - .getLibraryClasses(CommonDefinition.ALWAYSCONSUMED,this.arch); + String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED,this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -358,8 +347,7 @@ public class AutoGen { } } - libClassList = SurfaceAreaQuery - .getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch); + libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -373,7 +361,7 @@ public class AutoGen { // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to // {DEST_DIR_DRBUG}/FlashMap.h // - if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) { + if (saq.isHaveTianoR8FlashMap()) { fileBuffer.append(CommonDefinition.INCLUDE); fileBuffer.append(" <"); fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n"); @@ -396,7 +384,7 @@ public class AutoGen { // Save string buffer content in AutoGen.h. // if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) { - throw new BuildException("Failed to generate AutoGen.h !!!"); + throw new AutoGenException("Failed to generate AutoGen.h !!!"); } } @@ -408,7 +396,7 @@ public class AutoGen { @throws BuildException Failed to generate AutoGen.c. **/ - void moduleGenAutogenC() throws AutoGenException { + void moduleGenAutogenC() throws EdkException { StringBuffer fileBuffer = new StringBuffer(8192); // @@ -427,7 +415,7 @@ public class AutoGen { // process it should be set the DOC as the Native MSA info. // Map doc = GlobalData.getNativeMsa(this.moduleId); - SurfaceAreaQuery.push(doc); + saq.push(doc); // // Write // DriverBinding/ComponentName/DriverConfiguration/DriverDialog @@ -445,24 +433,23 @@ public class AutoGen { // // Write EntryPoint to autgoGen.c // - String[] entryPointList = SurfaceAreaQuery.getModuleEntryPointArray(); - String[] unloadImageList = SurfaceAreaQuery.getModuleUnloadImageArray(); + String[] entryPointList = saq.getModuleEntryPointArray(); + String[] unloadImageList = saq.getModuleUnloadImageArray(); EntryPointToAutoGen(CommonDefinition.remDupString(entryPointList), CommonDefinition.remDupString(unloadImageList), fileBuffer); - pcdDriverType = SurfaceAreaQuery.getPcdDriverType(); + pcdDriverType = saq.getPcdDriverType(); // // Restore the DOC which include the FPD module info. // - SurfaceAreaQuery.pop(); + saq.pop(); // // Write Guid to autogen.c // - String guid = CommonDefinition.formatGuidName(SurfaceAreaQuery - .getModuleGuid()); + String guid = CommonDefinition.formatGuidName(saq.getModuleGuid()); fileBuffer .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {"); @@ -490,7 +477,7 @@ public class AutoGen { // // Get module dependent Package identification. // - PackageIdentification[] packages = SurfaceAreaQuery.getDependencePkg(this.arch); + PackageIdentification[] packages = saq.getDependencePkg(this.arch); for (int i = 0; i < packages.length; i++) { if (!this.mDepPkgList.contains(packages[i])) { this.mDepPkgList.add(packages[i]); @@ -512,20 +499,17 @@ public class AutoGen { arch, false, null, - pcdDriverType); - try { - this.myPcdAutogen.execute(); - } catch (Exception exp) { - throw new PcdAutogenException (exp.getMessage()); - } - + pcdDriverType, + parentId); + + this.myPcdAutogen.execute(); if (this.myPcdAutogen != null) { fileBuffer.append("\r\n"); fileBuffer.append(this.myPcdAutogen.getCAutoGenString()); } if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) { - throw new BuildException("Failed to generate AutoGen.c !!!"); + throw new AutoGenException("Failed to generate AutoGen.c !!!"); } } @@ -538,7 +522,7 @@ public class AutoGen { @throws BuildException Failed to generate AutoGen.c. **/ - void libGenAutogenH() throws AutoGenException { + void libGenAutogenH() throws EdkException { Set libClassIncludeH; String moduleType; @@ -572,7 +556,7 @@ public class AutoGen { // be get from module surface area instead of hard code. // fileBuffer.append(CommonDefinition.AUTOGENHBEGIN); - String[] specList = SurfaceAreaQuery.getExternSpecificaiton(); + String[] specList = saq.getExternSpecificaiton(); for (int i = 0; i < specList.length; i++) { fileBuffer.append(CommonDefinition.DEFINE + specList[i] + "\r\n"); @@ -583,8 +567,8 @@ public class AutoGen { // // Write consumed package's mdouleInfo related *.h file to autogen.h. // - moduleType = SurfaceAreaQuery.getModuleType(); - PackageIdentification[] cosumedPkglist = SurfaceAreaQuery + moduleType = saq.getModuleType(); + PackageIdentification[] cosumedPkglist = saq .getDependencePkg(this.arch); headerFileList = depPkgToAutogenH(cosumedPkglist, moduleType); item = headerFileList.iterator(); @@ -594,7 +578,7 @@ public class AutoGen { // // Write library class's related *.h file to autogen.h // - String[] libClassList = SurfaceAreaQuery + String[] libClassList = saq .getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); @@ -604,7 +588,7 @@ public class AutoGen { } } - libClassList = SurfaceAreaQuery + libClassList = saq .getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); @@ -619,7 +603,7 @@ public class AutoGen { // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to // {DEST_DIR_DRBUG}/FlashMap.h // - if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) { + if (saq.isHaveTianoR8FlashMap()) { fileBuffer.append(CommonDefinition.INCLUDE); fileBuffer.append(" <"); fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n"); @@ -643,7 +627,7 @@ public class AutoGen { // Save content of string buffer to AutoGen.h file. // if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) { - throw new BuildException("Failed to generate AutoGen.h !!!"); + throw new AutoGenException("Failed to generate AutoGen.h !!!"); } } @@ -655,7 +639,7 @@ public class AutoGen { @throws BuildException Failed to generate AutoGen.c. **/ - void libGenAutogenC() throws BuildException, PcdAutogenException { + void libGenAutogenC() throws EdkException { StringBuffer fileBuffer = new StringBuffer(10240); // @@ -672,21 +656,17 @@ public class AutoGen { this.myPcdAutogen = new PCDAutoGenAction(moduleId, arch, true, - SurfaceAreaQuery.getModulePcdEntryNameArray(), - pcdDriverType); - try { - this.myPcdAutogen.execute(); - } catch (Exception e) { - throw new PcdAutogenException(e.getMessage()); - } - + saq.getModulePcdEntryNameArray(), + pcdDriverType, + parentId); + this.myPcdAutogen.execute(); if (this.myPcdAutogen != null) { fileBuffer.append(ToolDefinitions.LINE_SEPARATOR); fileBuffer.append(this.myPcdAutogen.getCAutoGenString()); } if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) { - throw new BuildException("Failed to generate AutoGen.c !!!"); + throw new AutoGenException("Failed to generate AutoGen.c !!!"); } } @@ -702,7 +682,7 @@ public class AutoGen { @return includeStrList List of *.h file. **/ Set LibraryClassToAutogenH(String[] libClassList) - throws AutoGenException { + throws EdkException { Set includeStrList = new LinkedHashSet(); String includeName[]; String str = ""; @@ -713,7 +693,7 @@ public class AutoGen { // for (int i = 0; i < libClassList.length; i++) { includeName = GlobalData.getLibraryClassHeaderFiles( - SurfaceAreaQuery.getDependencePkg(this.arch), + saq.getDependencePkg(this.arch), libClassList[i]); if (includeName == null) { throw new AutoGenException("Can not find library class [" @@ -783,9 +763,9 @@ public class AutoGen { @throws Exception **/ void EntryPointToAutoGen(String[] entryPointList, String[] unloadImageList, StringBuffer fileBuffer) - throws BuildException { + throws EdkException { - String typeStr = SurfaceAreaQuery.getModuleType(); + String typeStr = saq.getModuleType(); int unloadImageCount = 0; int entryPointCount = 0; @@ -797,11 +777,11 @@ public class AutoGen { case CommonDefinition.ModuleTypePeiCore: if (entryPointList == null ||entryPointList.length != 1 ) { - throw new BuildException( + throw new AutoGenException( "Module type = 'PEI_CORE', can have only one module entry point!"); } else { fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); + //fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(entryPointList[0]); fileBuffer.append(" (\r\n"); fileBuffer @@ -829,12 +809,12 @@ public class AutoGen { case CommonDefinition.ModuleTypeDxeCore: fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n"); if (entryPointList == null || entryPointList.length != 1) { - throw new BuildException( + throw new AutoGenException( "Module type = 'DXE_CORE', can have only one module entry point!"); } else { fileBuffer.append("VOID\r\n"); - fileBuffer.append("EFIAPI\r\n"); + //fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(entryPointList[0]); fileBuffer.append(" (\n"); fileBuffer.append(" IN VOID *HobStart\r\n"); @@ -871,7 +851,7 @@ public class AutoGen { } for (int i = 0; i < entryPointList.length; i++) { fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); + //fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(entryPointList[i]); fileBuffer.append(" (\r\n"); fileBuffer @@ -940,7 +920,7 @@ public class AutoGen { } else { for (int i = 0; i < entryPointList.length; i++) { fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); + //fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(entryPointList[i]); fileBuffer.append(" (\r\n"); fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); @@ -1007,7 +987,7 @@ public class AutoGen { if (unloadImageList != null) { for (int i = 0; i < unloadImageList.length; i++) { fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); + //fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(unloadImageList[i]); fileBuffer.append(" (\r\n"); fileBuffer @@ -1087,7 +1067,7 @@ public class AutoGen { for (int i = 0; i < entryPointList.length; i++) { fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); + //fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(entryPointList[i]); fileBuffer.append(" (\r\n"); fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); @@ -1166,17 +1146,12 @@ public class AutoGen { // // Add ModuleUnloadImage for DxeDriver and UefiDriver module type. // - //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray(); - // - // Remover duplicate unload entry point. - // - //entryPointList = CommonDefinition.remDupString(entryPointList); - //entryPointCount = 0; + unloadImageCount = 0; if (unloadImageList != null) { for (int i = 0; i < unloadImageList.length; i++) { fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); + //fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(unloadImageList[i]); fileBuffer.append(" (\r\n"); fileBuffer @@ -1250,12 +1225,12 @@ public class AutoGen { // then add those PPI ,and PPI Notify name to list. // - String[] ppiList = SurfaceAreaQuery.getPpiArray(this.arch); + String[] ppiList = saq.getPpiArray(this.arch); for (int i = 0; i < ppiList.length; i++) { this.mPpiList.add(ppiList[i]); } - String[] ppiNotifyList = SurfaceAreaQuery.getPpiNotifyArray(this.arch); + String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch); for (int i = 0; i < ppiNotifyList.length; i++) { this.mPpiList.add(ppiNotifyList[i]); } @@ -1296,10 +1271,10 @@ public class AutoGen { @throws BuildException Protocol name must set. **/ - void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws BuildException { + void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws EdkException { String[] cNameGuid = null; - String[] protocolList = SurfaceAreaQuery.getProtocolArray(this.arch); + String[] protocolList = saq.getProtocolArray(this.arch); // // Add result to Autogen global list. @@ -1308,7 +1283,7 @@ public class AutoGen { this.mProtocolList.add(protocolList[i]); } - String[] protocolNotifyList = SurfaceAreaQuery + String[] protocolNotifyList = saq .getProtocolNotifyArray(this.arch); for (int i = 0; i < protocolNotifyList.length; i++) { @@ -1336,7 +1311,7 @@ public class AutoGen { // // If can't find protocol GUID declaration in every package // - throw new BuildException("Can not find protocol Guid [" + throw new AutoGenException("Can not find protocol Guid [" + protocolKeyWord + "] declaration in any SPD package!"); } } @@ -1356,7 +1331,7 @@ public class AutoGen { String[] cNameGuid = null; String guidKeyWord = null; - String[] guidList = SurfaceAreaQuery.getGuidEntryArray(this.arch); + String[] guidList = saq.getGuidEntryArray(this.arch); for (int i = 0; i < guidList.length; i++) { this.mGuidList.add(guidList[i]); @@ -1397,21 +1372,17 @@ public class AutoGen { String buffer for AutoGen.c @throws BuildException **/ - void LibInstanceToAutogenC(StringBuffer fileBuffer) throws BuildException { - try { - String moduleType = this.moduleId.getModuleType(); - // - // Add library constructor to AutoGen.c - // - LibConstructorToAutogenC(libConstructList, moduleType, - fileBuffer/* autogenC */); - // - // Add library destructor to AutoGen.c - // - LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */); - } catch (Exception e) { - throw new BuildException(e.getMessage()); - } + void LibInstanceToAutogenC(StringBuffer fileBuffer) throws EdkException { + String moduleType = this.moduleId.getModuleType(); + // + // Add library constructor to AutoGen.c + // + LibConstructorToAutogenC(libConstructList, moduleType, + fileBuffer/* autogenC */); + // + // Add library destructor to AutoGen.c + // + LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */); } /** @@ -1429,7 +1400,7 @@ public class AutoGen { @throws Exception **/ void LibConstructorToAutogenC(List libInstanceList, - String moduleType, StringBuffer fileBuffer) throws Exception { + String moduleType, StringBuffer fileBuffer) throws EdkException { boolean isFirst = true; // @@ -1570,7 +1541,7 @@ public class AutoGen { @throws Exception **/ void LibDestructorToAutogenC(List libInstanceList, - String moduleType, StringBuffer fileBuffer) throws Exception { + String moduleType, StringBuffer fileBuffer) throws EdkException { boolean isFirst = true; for (int i = 0; i < libInstanceList.size(); i++) { switch (CommonDefinition.getModuleType(moduleType)) { @@ -1665,7 +1636,7 @@ public class AutoGen { String buffer for AutoGen.c **/ void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer) - throws BuildException { + throws EdkException { // // Check what contains. And the number of following elements @@ -1673,7 +1644,7 @@ public class AutoGen { // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC // - String[] drvBindList = SurfaceAreaQuery.getDriverBindingArray(); + String[] drvBindList = saq.getDriverBindingArray(); // // If component name protocol,component configuration protocol, @@ -1684,9 +1655,9 @@ public class AutoGen { return; } - String[] compNamList = SurfaceAreaQuery.getComponentNameArray(); - String[] compConfList = SurfaceAreaQuery.getDriverConfigArray(); - String[] compDiagList = SurfaceAreaQuery.getDriverDiagArray(); + String[] compNamList = saq.getComponentNameArray(); + String[] compConfList = saq.getDriverConfigArray(); + String[] compDiagList = saq.getDriverDiagArray(); int BitMask = 0; @@ -1704,7 +1675,7 @@ public class AutoGen { // if (compNamList != null && compNamList.length != 0) { if (drvBindList.length != compNamList.length) { - throw new BuildException( + throw new AutoGenException( "Different number of Driver Binding and Component Name protocols!"); } @@ -1721,7 +1692,7 @@ public class AutoGen { // if (compConfList != null && compConfList.length != 0) { if (drvBindList.length != compConfList.length) { - throw new BuildException( + throw new AutoGenException( "Different number of Driver Binding and Driver Configuration protocols!"); } @@ -1738,7 +1709,7 @@ public class AutoGen { // if (compDiagList != null && compDiagList.length != 0) { if (drvBindList.length != compDiagList.length) { - throw new BuildException( + throw new AutoGenException( "Different number of Driver Binding and Driver Diagnosis protocols!"); } @@ -1820,14 +1791,14 @@ public class AutoGen { @throws BuildException **/ void ExternCallBackToAutoGenC(StringBuffer fileBuffer) - throws BuildException { + throws EdkException { // // Collect module's and // and add to setVirtualAddList // exitBootServiceList. // - String[] setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray(); - String[] exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray(); + String[] setVirtuals = saq.getSetVirtualAddressMapCallBackArray(); + String[] exitBoots = saq.getExitBootServicesCallBackArray(); if (setVirtuals != null) { for (int j = 0; j < setVirtuals.length; j++) { this.setVirtalAddList.add(setVirtuals[j]); @@ -1881,20 +1852,21 @@ public class AutoGen { // do nothing. // if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) { - try { - if (inFile.exists()) { - FileInputStream fis = new FileInputStream (inFile); - fis.read(buffer); - FileOutputStream fos = new FileOutputStream(outFile); - fos.write(buffer); - fis.close(); - fos.close(); - } else { - throw new AutoGenException("The file, flashMap.h doesn't exist!"); - } - } catch (Exception e) { - throw new AutoGenException(e.getMessage()); - } + if (inFile.exists()) { + try{ + FileInputStream fis = new FileInputStream (inFile); + fis.read(buffer); + FileOutputStream fos = new FileOutputStream(outFile); + fos.write(buffer); + fis.close(); + fos.close(); + } catch (IOException e){ + throw new AutoGenException("The file, flashMap.h can't be open!"); + } + + } else { + throw new AutoGenException("The file, flashMap.h doesn't exist!"); + } } } @@ -1907,7 +1879,7 @@ public class AutoGen { @param @return **/ - private void collectLibInstanceInfo(){ + private void collectLibInstanceInfo() throws EdkException{ int index; String libConstructName = null; @@ -1915,127 +1887,115 @@ public class AutoGen { String[] setVirtuals = null; String[] exitBoots = null; - ModuleIdentification[] libraryIdList = SurfaceAreaQuery - .getLibraryInstance(this.arch); - try { - if (libraryIdList != null) { - // - // Reorder library instance sequence. - // - AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList, - this.arch); - List orderList = libOrder - .orderLibInstance(); - - if (orderList != null) { - // - // Process library instance one by one. - // - for (int i = 0; i < orderList.size(); i++) { - - // - // Get library instance basename. - // - ModuleIdentification libInstanceId = orderList.get(i); - - // - // Get override map - // - - Map libDoc = GlobalData.getDoc(libInstanceId, this.arch); - SurfaceAreaQuery.push(libDoc); - // - // Get , , list of this library - // instance. - // - String[] ppiList = SurfaceAreaQuery.getPpiArray(this.arch); - String[] ppiNotifyList = SurfaceAreaQuery - .getPpiNotifyArray(this.arch); - String[] protocolList = SurfaceAreaQuery - .getProtocolArray(this.arch); - String[] protocolNotifyList = SurfaceAreaQuery - .getProtocolNotifyArray(this.arch); - String[] guidList = SurfaceAreaQuery - .getGuidEntryArray(this.arch); - PackageIdentification[] pkgList = SurfaceAreaQuery.getDependencePkg(this.arch); - - // - // Add those ppi, protocol, guid in global ppi, - // protocol, guid - // list. - // - for (index = 0; index < ppiList.length; index++) { - this.mPpiList.add(ppiList[index]); - } - - for (index = 0; index < ppiNotifyList.length; index++) { - this.mPpiList.add(ppiNotifyList[index]); - } + ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch); - for (index = 0; index < protocolList.length; index++) { - this.mProtocolList.add(protocolList[index]); - } - - for (index = 0; index < protocolNotifyList.length; index++) { - this.mProtocolList.add(protocolNotifyList[index]); - } - - for (index = 0; index < guidList.length; index++) { - this.mGuidList.add(guidList[index]); - } - for (index = 0; index < pkgList.length; index++) { - if (!this.mDepPkgList.contains(pkgList[index])) { - this.mDepPkgList.add(pkgList[index]); - } - } - - // - // If not yet parse this library instance's constructor - // element,parse it. - // - libConstructName = SurfaceAreaQuery - .getLibConstructorName(); - libDestructName = SurfaceAreaQuery - .getLibDestructorName(); - - // - // Collect SetVirtualAddressMapCallBack and - // ExitBootServiceCallBack. - // - setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray(); - exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray(); - if (setVirtuals != null) { - for (int j = 0; j < setVirtuals.length; j++) { - this.setVirtalAddList.add(setVirtuals[j]); - } - } - if (exitBoots != null) { - for (int k = 0; k < exitBoots.length; k++) { - this.exitBootServiceList.add(exitBoots[k]); - } - } - SurfaceAreaQuery.pop(); - // - // Add dependent library instance constructor function. - // - if (libConstructName != null) { - this.libConstructList.add(libConstructName); - } - // - // Add dependent library instance destructor fuction. - // - if (libDestructName != null) { - this.libDestructList.add(libDestructName); - } - } - } - - } + if (libraryIdList != null) { + // + // Reorder library instance sequence. + // + AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList, + this.arch); + List orderList = libOrder + .orderLibInstance(); + + if (orderList != null) { + // + // Process library instance one by one. + // + for (int i = 0; i < orderList.size(); i++) { + + // + // Get library instance basename. + // + ModuleIdentification libInstanceId = orderList.get(i); + + // + // Get override map + // + + Map libDoc = GlobalData.getDoc(libInstanceId, this.arch); + saq.push(libDoc); + // + // Get , , list of this library + // instance. + // + String[] ppiList = saq.getPpiArray(this.arch); + String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch); + String[] protocolList = saq.getProtocolArray(this.arch); + String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch); + String[] guidList = saq.getGuidEntryArray(this.arch); + PackageIdentification[] pkgList = saq.getDependencePkg(this.arch); + + // + // Add those ppi, protocol, guid in global ppi, + // protocol, guid + // list. + // + for (index = 0; index < ppiList.length; index++) { + this.mPpiList.add(ppiList[index]); + } + + for (index = 0; index < ppiNotifyList.length; index++) { + this.mPpiList.add(ppiNotifyList[index]); + } + + for (index = 0; index < protocolList.length; index++) { + this.mProtocolList.add(protocolList[index]); + } + + for (index = 0; index < protocolNotifyList.length; index++) { + this.mProtocolList.add(protocolNotifyList[index]); + } + + for (index = 0; index < guidList.length; index++) { + this.mGuidList.add(guidList[index]); + } + for (index = 0; index < pkgList.length; index++) { + if (!this.mDepPkgList.contains(pkgList[index])) { + this.mDepPkgList.add(pkgList[index]); + } + } + + // + // If not yet parse this library instance's constructor + // element,parse it. + // + libConstructName = saq.getLibConstructorName(); + libDestructName = saq.getLibDestructorName(); + + // + // Collect SetVirtualAddressMapCallBack and + // ExitBootServiceCallBack. + // + setVirtuals = saq.getSetVirtualAddressMapCallBackArray(); + exitBoots = saq.getExitBootServicesCallBackArray(); + if (setVirtuals != null) { + for (int j = 0; j < setVirtuals.length; j++) { + this.setVirtalAddList.add(setVirtuals[j]); + } + } + if (exitBoots != null) { + for (int k = 0; k < exitBoots.length; k++) { + this.exitBootServiceList.add(exitBoots[k]); + } + } + saq.pop(); + // + // Add dependent library instance constructor function. + // + if (libConstructName != null) { + this.libConstructList.add(libConstructName); + } + // + // Add dependent library instance destructor fuction. + // + if (libDestructName != null) { + this.libDestructList.add(libDestructName); + } + } + } - } catch (Exception e) { - System.out.println(e.getMessage()); - System.out.println("Collect library instance failed!"); - } + } } private void setVirtualAddressToAutogenC(StringBuffer fileBuffer){ //