X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fautogen%2FAutoGen.java;h=0704bf44119b1bec734773634e8d9b1f923f1037;hp=300433081dd212e3ae056197f661a98ba596435b;hb=391dbbb1c00daefe78e7e44499d048943ca866ae;hpb=a84091c4be5c230e662d0ee5960720287cd7dae6 diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java index 300433081d..0704bf4411 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java +++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java @@ -17,32 +17,35 @@ package org.tianocore.build.autogen; -import org.tianocore.build.global.GlobalData; -import org.tianocore.build.global.Spd; -import org.tianocore.build.global.SurfaceAreaQuery; -import org.tianocore.build.id.ModuleIdentification; -import org.tianocore.build.id.PackageIdentification; -import org.tianocore.GuidsDocument; -import org.tianocore.LibraryClassDocument.LibraryClass; -import org.tianocore.PPIsDocument; -import org.tianocore.ProtocolsDocument; -import org.tianocore.build.pcd.action.PCDAutoGenAction; -import org.tianocore.build.exception.*; -import org.tianocore.logger.EdkLog; -import org.apache.tools.ant.BuildException; -import org.apache.xmlbeans.XmlObject; - import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.tools.ant.BuildException; +import org.apache.xmlbeans.XmlObject; +import org.tianocore.GuidsDocument; +import org.tianocore.LibraryClassDocument.LibraryClass; +import org.tianocore.PPIsDocument; +import org.tianocore.ProtocolsDocument; +import org.tianocore.build.exception.*; +import org.tianocore.build.global.GlobalData; +import org.tianocore.build.global.Spd; +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.logger.EdkLog; + /** * This class is to generate Autogen.h and Autogen.c according to module surface * area or library surface area. @@ -52,7 +55,10 @@ public class AutoGen { // / The output path of Autogen.h and Autogen.c // / private String outputPath; - + /// + /// The name of FV directory + /// + private String fvDir; // / // / The base name of module or library. // / @@ -92,6 +98,21 @@ public class AutoGen { // area and it's dependence on library instance surface are. // private List mDepPkgList = new LinkedList(); + + // + // For non library module, add its library instance's construct and destructor to + // list. + // + private List libConstructList = new ArrayList(); + private List libDestructList = new ArrayList(); + + // + // List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack + // + private List setVirtalAddList = new ArrayList(); + private List exitBootServiceList = new ArrayList(); + + /** * Construct function * @@ -104,10 +125,11 @@ public class AutoGen { * @param arch * Target architecture. */ - public AutoGen(String outputPath, ModuleIdentification moduleId, String arch) { + public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch) { this.outputPath = outputPath; this.moduleId = moduleId; this.arch = arch; + this.fvDir = fvDir; } @@ -197,6 +219,7 @@ public class AutoGen { void moduleGenAutogen() throws BuildException { try { + collectLibInstanceInfo(); moduleGenAutogenC(); moduleGenAutogenH(); } catch (Exception e) { @@ -220,7 +243,7 @@ public class AutoGen { libGenAutogenH(); } catch (Exception e) { throw new BuildException( - "Faile to create library AutoGen.c & AutoGen.h!\n" + "Failed to create library AutoGen.c & AutoGen.h!\n" + e.getMessage()); } } @@ -251,10 +274,8 @@ public class AutoGen { // Add #ifndef ${BaseName}_AUTOGENH // #def ${BseeName}_AUTOGENH // - fileBuffer.append("#ifndef " + this.moduleId.getName().toUpperCase() - + "_AUTOGENH\r\n"); - fileBuffer.append("#define " + this.moduleId.getName().toUpperCase() - + "_AUTOGENH\r\n\r\n"); + fileBuffer.append("#ifndef " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") +"\r\n"); + fileBuffer.append("#define " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") +"\r\n\r\n"); // // Write the specification version and release version at the begine @@ -298,7 +319,7 @@ public class AutoGen { // Write library class's related *.h file to autogen.h. // String[] libClassList = SurfaceAreaQuery - .getLibraryClasses(CommonDefinition.AlwaysConsumed); + .getLibraryClasses(CommonDefinition.AlwaysConsumed,this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -308,7 +329,7 @@ public class AutoGen { } libClassList = SurfaceAreaQuery - .getLibraryClasses(CommonDefinition.AlwaysProduced); + .getLibraryClasses(CommonDefinition.AlwaysProduced, this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -318,7 +339,17 @@ public class AutoGen { } fileBuffer.append("\r\n"); - // + // + // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to + // {DEST_DIR_DRBUG}/FlashMap.h + // + if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) { + fileBuffer.append(CommonDefinition.include); + fileBuffer.append(" <"); + fileBuffer.append(CommonDefinition.tianoR8FlashMapH + ">\r\n"); + copyFlashMapHToDebugDir(); + } + // Write PCD autogen information to AutoGen.h. // if (this.myPcdAutogen != null) { @@ -441,25 +472,18 @@ public class AutoGen { GuidGuidToAutogenC(fileBuffer); // - // Call pcd autogen. PCDAutoGenAction tool only need module name and - // isPcdEmulatedDriver as parameter. Library inherits PCD and module's - // PCD information has been collected in FPDParser task by - // CollectPCDAction. - // Note : when PCD image tool ready, - // isPCDEmulatedDriver parameter will be removed. - // - try { -// this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(), -// moduleId.getGuid(), moduleId.getPackage().getName(), moduleId.getPackage().getGuid(),this.arch,moduleId.getVersion(),false, null); - this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),null,null,null, this.arch,null,false, null); - this.myPcdAutogen.execute(); - } catch (Exception e) { - throw new BuildException("PCD Autogen failed:" + e.getMessage()); - } + // Call pcd autogen. + // + this.myPcdAutogen = new PCDAutoGenAction(moduleId, this.arch, false, null); + try { + this.myPcdAutogen.execute(); + } catch (Exception exp) { + throw new PcdAutogenException (exp.getMessage()); + } if (this.myPcdAutogen != null) { - fileBuffer.append("\r\n"); - fileBuffer.append(this.myPcdAutogen.OutputC()); + fileBuffer.append("\r\n"); + fileBuffer.append(this.myPcdAutogen.OutputC()); } if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) { @@ -493,10 +517,8 @@ public class AutoGen { // Add #ifndef ${BaseName}_AUTOGENH // #def ${BseeName}_AUTOGENH // - fileBuffer.append("#ifndef " + this.moduleId.getName().toUpperCase() - + "_AUTOGENH\r\n"); - fileBuffer.append("#define " + this.moduleId.getName().toUpperCase() - + "_AUTOGENH\r\n\r\n"); + fileBuffer.append("#ifndef " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") + "\r\n"); + fileBuffer.append("#define " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") + "\r\n\r\n"); // // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION @@ -528,7 +550,7 @@ public class AutoGen { // Write library class's related *.h file to autogen.h // String[] libClassList = SurfaceAreaQuery - .getLibraryClasses(CommonDefinition.AlwaysConsumed); + .getLibraryClasses(CommonDefinition.AlwaysConsumed, this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -538,7 +560,7 @@ public class AutoGen { } libClassList = SurfaceAreaQuery - .getLibraryClasses(CommonDefinition.AlwaysProduced); + .getLibraryClasses(CommonDefinition.AlwaysProduced, this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -548,6 +570,17 @@ public class AutoGen { } fileBuffer.append("\r\n"); + // + // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to + // {DEST_DIR_DRBUG}/FlashMap.h + // + if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) { + fileBuffer.append(CommonDefinition.include); + fileBuffer.append(" <"); + fileBuffer.append(CommonDefinition.tianoR8FlashMapH + ">\r\n"); + copyFlashMapHToDebugDir(); + } + // // Write PCD information to library AutoGen.h. // @@ -577,7 +610,7 @@ public class AutoGen { * @throws BuildException * Failed to generate AutoGen.c. */ - void libGenAutogenC() throws BuildException { + void libGenAutogenC() throws BuildException, PcdAutogenException { StringBuffer fileBuffer = new StringBuffer(10240); // @@ -589,33 +622,21 @@ public class AutoGen { fileBuffer.append("\r\n"); // - // Call pcd autogen. PCDAutoGenAction tool only need module name and - // isPcdEmulatedDriver as parameter. Library inherit PCD and module's - // PCD information has been collected in FPDParser task by - // CollectPCDAction. - // Note : when PCD image tool ready, - // isPCDEmulatedDriver parameter will be removed. + // Call pcd autogen. // + this.myPcdAutogen = new PCDAutoGenAction(this.moduleId, + this.arch, + true, + SurfaceAreaQuery.getModulePcdEntryNameArray()); try { -// this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(), -// this.moduleId.getGuid(),moduleId.getPackage().getName(),moduleId.getPackage().getGuid(), this.arch, moduleId.getVersion(),true, SurfaceAreaQuery.getModulePcdEntryNameArray()); - this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(), - null, - null, - null, - this.arch, - null, - true, - SurfaceAreaQuery.getModulePcdEntryNameArray()); - - this.myPcdAutogen.execute(); + this.myPcdAutogen.execute(); } catch (Exception e) { - throw new BuildException(e.getMessage()); + throw new PcdAutogenException(e.getMessage()); } if (this.myPcdAutogen != null) { - fileBuffer.append("\r\n"); - fileBuffer.append(this.myPcdAutogen.OutputC()); + fileBuffer.append("\r\n"); + fileBuffer.append(this.myPcdAutogen.OutputC()); } if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) { @@ -636,7 +657,7 @@ public class AutoGen { */ Set LibraryClassToAutogenH(String[] libClassList) throws AutoGenException { - Set includStrList = new HashSet(); + Set includStrList = new LinkedHashSet(); String includerName[]; String str = ""; @@ -651,7 +672,7 @@ public class AutoGen { libClassList[i]); if (includerName == null) { throw new AutoGenException("Can not find library class [" - + libClassList[i] + "] declaration in every packages. "); + + libClassList[i] + "] declaration in any SPD package. "); } for (int j = 0; j < includerName.length; j++) { String includeNameStr = includerName[j]; @@ -693,7 +714,7 @@ public class AutoGen { if (pkgHeader == null) { throw new AutoGenException("Can not find package [" + packageNameList[i] - + "] declaration in every packages. "); + + "] declaration in any SPD package. "); } else if (!pkgHeader.equalsIgnoreCase("")) { includeStr = CommonDefinition.include + " <" + pkgHeader + ">\r\n"; @@ -730,7 +751,7 @@ public class AutoGen { case CommonDefinition.ModuleTypePeiCore: if (entryPointList == null ||entryPointList.length != 1 ) { throw new BuildException( - "Module type = 'PEI_CORE', only have one module entry point!"); + "Module type = 'PEI_CORE', can have only one module entry point!"); } else { fileBuffer.append("EFI_STATUS\r\n"); fileBuffer.append("EFIAPI\r\n"); @@ -762,7 +783,7 @@ public class AutoGen { fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n"); if (entryPointList == null || entryPointList.length != 1) { throw new BuildException( - "Module type = 'DXE_CORE', only have one module entry point!"); + "Module type = 'DXE_CORE', can have only one module entry point!"); } else { fileBuffer.append("VOID\r\n"); @@ -1069,10 +1090,10 @@ public class AutoGen { } fileBuffer.append("}\r\n\r\n"); - fileBuffer.append("VOID\n"); - fileBuffer.append("EFIAPI\n"); + fileBuffer.append("VOID\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append("ExitDriver (\r\n"); - fileBuffer.append(" IN EFI_STATUS Status\n"); + fileBuffer.append(" IN EFI_STATUS Status\r\n"); fileBuffer.append(" )\r\n\r\n"); fileBuffer.append("{\r\n"); if (entryPointCount <= 1) { @@ -1210,7 +1231,7 @@ public class AutoGen { // If can't find Ppi GUID declaration in every package // throw new AutoGenException("Can not find Ppi GUID [" - + ppiKeyWord + "] declaration in every packages. "); + + ppiKeyWord + "] declaration in any SPD package!"); } } } @@ -1267,7 +1288,7 @@ public class AutoGen { // If can't find protocol GUID declaration in every package // throw new BuildException("Can not find protocol Guid [" - + protocolKeyWord + "] declaration in every packages. "); + + protocolKeyWord + "] declaration in any SPD package!"); } } } @@ -1310,7 +1331,7 @@ public class AutoGen { // If can't find GUID declaration in every package // throw new AutoGenException("Can not find Guid [" + guidKeyWord - + "] declaration in every packages. "); + + "] declaration in any SPD package. "); } } @@ -1328,128 +1349,17 @@ public class AutoGen { * @throws BuildException */ void LibInstanceToAutogenC(StringBuffer fileBuffer) throws BuildException { - int index; - - String moduleType = SurfaceAreaQuery.getModuleType(); - List libConstructList = new ArrayList(); - List libDestructList = new ArrayList(); - - String libConstructName = null; - String libDestructName = 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]); - } - - 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(); - - SurfaceAreaQuery.pop(); - // - // Add dependent library instance constructor function. - // - if (libConstructName != null) { - libConstructList.add(libConstructName); - } - // - // Add dependent library instance destructor fuction. - // - if (libDestructName != null) { - libDestructList.add(libDestructName); - } - } - - } - - // - // Add library constructor to AutoGen.c - // - LibConstructorToAutogenC(libConstructList, moduleType, - fileBuffer/* autogenC */); - // - // Add library destructor to AutoGen.c - // - LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */); - } - + 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()); } @@ -1481,6 +1391,7 @@ public class AutoGen { switch (CommonDefinition.getModuleType(moduleType)) { case CommonDefinition.ModuleTypeBase: fileBuffer.append("RETURN_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(libInstanceList.get(i)); fileBuffer.append(" (\r\n"); fileBuffer.append(" VOID\r\n"); @@ -1490,6 +1401,7 @@ public class AutoGen { case CommonDefinition.ModuleTypePeiCore: case CommonDefinition.ModuleTypePeim: fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(libInstanceList.get(i)); fileBuffer.append(" (\r\n"); fileBuffer @@ -1507,6 +1419,7 @@ public class AutoGen { case CommonDefinition.ModuleTypeUefiDriver: case CommonDefinition.ModuleTypeUefiApplication: fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(libInstanceList.get(i)); fileBuffer.append(" (\r\n"); fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); @@ -1520,6 +1433,7 @@ public class AutoGen { // Add ProcessLibraryConstructorList in AutoGen.c // fileBuffer.append("VOID\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append("ProcessLibraryConstructorList (\r\n"); switch (CommonDefinition.getModuleType(moduleType)) { case CommonDefinition.ModuleTypeBase: @@ -1585,7 +1499,7 @@ public class AutoGen { fileBuffer.append(" (ImageHandle, SystemTable);\r\n"); break; default: - EdkLog.log(EdkLog.EDK_INFO,"Autogen don't know how to deal with module type -"+ moduleType + " !"); + EdkLog.log(EdkLog.EDK_INFO,"Autogen doesn't know how to deal with module type - " + moduleType + "!"); } fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n"); } @@ -1612,7 +1526,8 @@ public class AutoGen { for (int i = 0; i < libInstanceList.size(); i++) { switch (CommonDefinition.getModuleType(moduleType)) { case CommonDefinition.ModuleTypeBase: - fileBuffer.append("RETURN_STATUS\n"); + fileBuffer.append("RETURN_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(libInstanceList.get(i)); fileBuffer.append(" (\r\n"); fileBuffer.append(" VOID\r\n"); @@ -1621,6 +1536,7 @@ public class AutoGen { case CommonDefinition.ModuleTypePeiCore: case CommonDefinition.ModuleTypePeim: fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(libInstanceList.get(i)); fileBuffer.append(" (\r\n"); fileBuffer @@ -1637,6 +1553,7 @@ public class AutoGen { case CommonDefinition.ModuleTypeUefiDriver: case CommonDefinition.ModuleTypeUefiApplication: fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(libInstanceList.get(i)); fileBuffer.append(" (\r\n"); fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); @@ -1662,6 +1579,7 @@ public class AutoGen { case CommonDefinition.ModuleTypeUefiDriver: case CommonDefinition.ModuleTypeUefiApplication: fileBuffer.append("VOID\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append("ProcessLibraryDestructorList (\r\n"); fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n"); @@ -1772,7 +1690,7 @@ public class AutoGen { if (compDiagList != null && compDiagList.length != 0) { if (drvBindList.length != compDiagList.length) { throw new BuildException( - "Different number of Driver Binding and Driver Configuration protocols!"); + "Different number of Driver Binding and Driver Diagnosis protocols!"); } BitMask |= 0x04; @@ -1854,15 +1772,31 @@ public class AutoGen { */ void ExternCallBackToAutoGenC(StringBuffer fileBuffer) throws BuildException { - String[] setVirtualList = SurfaceAreaQuery - .getSetVirtualAddressMapCallBackArray(); - String[] exitBootList = SurfaceAreaQuery - .getExitBootServicesCallBackArray(); - String moduleType = SurfaceAreaQuery.getModuleType(); + // + // Collect module's and + // and add to setVirtualAddList + // exitBootServiceList. + // + String[] setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray(); + String[] 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]); + } + } + // + // Add c code in autogen.c which relate to + // and + // + String moduleType = this.moduleId.getModuleType(); boolean UefiOrDxeModule = false; int Count = 0; int i; - switch (CommonDefinition.getModuleType(moduleType)) { case CommonDefinition.ModuleTypeDxeDriver: case CommonDefinition.ModuleTypeDxeRuntimeDriver: @@ -1882,9 +1816,9 @@ public class AutoGen { // set count to the number of valid entries // Count = 0; - if (setVirtualList != null) { - for (i = 0; i < setVirtualList.length; i++) { - if (setVirtualList[i].equalsIgnoreCase("")) { + if (this.setVirtalAddList != null) { + for (i = 0; i < this.setVirtalAddList.size(); i++) { + if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) { break; } } @@ -1898,7 +1832,7 @@ public class AutoGen { break; } - if (setVirtualList == null) { + if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) { if (UefiOrDxeModule) { // // No data so make a NULL list @@ -1912,13 +1846,13 @@ public class AutoGen { // // Write SetVirtualAddressMap function definition. // - for (i = 0; i < setVirtualList.length; i++) { - if (setVirtualList[i].equalsIgnoreCase("")) { + for (i = 0; i < this.setVirtalAddList.size(); i++) { + if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) { break; } fileBuffer.append("VOID\r\n"); fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(setVirtualList[i]); + fileBuffer.append(this.setVirtalAddList.get(i)); fileBuffer.append(" (\r\n"); fileBuffer.append(" IN EFI_EVENT Event,\r\n"); fileBuffer.append(" IN VOID *Context\r\n"); @@ -1930,8 +1864,8 @@ public class AutoGen { // fileBuffer .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {"); - for (i = 0; i < setVirtualList.length; i++) { - if (setVirtualList[i].equalsIgnoreCase("")) { + for (i = 0; i < this.setVirtalAddList.size(); i++) { + if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) { break; } @@ -1941,7 +1875,7 @@ public class AutoGen { fileBuffer.append(",\r\n "); } - fileBuffer.append(setVirtualList[i]); + fileBuffer.append(this.setVirtalAddList.get(i)); } // // If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER @@ -1966,21 +1900,19 @@ public class AutoGen { // set count to the number of valid entries. // Count = 0; - if (exitBootList != null) { - if (setVirtualList != null) { - for (i = 0; i < exitBootList.length; i++) { - if (exitBootList[i].equalsIgnoreCase("")) { - break; - } + if (this.exitBootServiceList != null) { + for (i = 0; i < this.exitBootServiceList.size(); i++) { + if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) { + break; } - Count = i; } + Count = i; } fileBuffer.append(Integer.toString(Count)); fileBuffer.append(";\r\n\r\n"); } - if (exitBootList == null) { + if (this.exitBootServiceList == null || this.exitBootServiceList.size() == 0) { if (UefiOrDxeModule) { // // No data so make a NULL list. @@ -1994,14 +1926,14 @@ public class AutoGen { // // Write DriverExitBootServices function definition. // - for (i = 0; i < exitBootList.length; i++) { - if (exitBootList[i].equalsIgnoreCase("")) { + for (i = 0; i < this.exitBootServiceList.size(); i++) { + if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) { break; } fileBuffer.append("VOID\r\n"); fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(exitBootList[i]); + fileBuffer.append(this.exitBootServiceList.get(i)); fileBuffer.append(" (\r\n"); fileBuffer.append(" IN EFI_EVENT Event,\r\n"); fileBuffer.append(" IN VOID *Context\r\n"); @@ -2013,8 +1945,8 @@ public class AutoGen { // fileBuffer .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {"); - for (i = 0; i < exitBootList.length; i++) { - if (exitBootList[i].equalsIgnoreCase("")) { + for (i = 0; i < this.exitBootServiceList.size(); i++) { + if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) { break; } @@ -2023,7 +1955,7 @@ public class AutoGen { } else { fileBuffer.append(",\r\n "); } - fileBuffer.append(exitBootList[i]); + fileBuffer.append(this.exitBootServiceList.get(i)); } if (!UefiOrDxeModule) { fileBuffer.append(",\r\n NULL"); @@ -2033,4 +1965,171 @@ public class AutoGen { } -} \ No newline at end of file + private void copyFlashMapHToDebugDir() throws AutoGenException{ + + File inFile = new File(fvDir + File.separatorChar + CommonDefinition.flashMapH); + int size = (int)inFile.length(); + byte[] buffer = new byte[size]; + File outFile = new File (this.outputPath + File.separatorChar + CommonDefinition.tianoR8FlashMapH); + // + // If TianoR8FlashMap.h existed and the flashMap.h don't change, + // 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()); + } + } + } + + /** + *This function first order the library instances, then collect + *library instance 's PPI, Protocol, GUID, + *SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and + *Destructor, Constructor. + * + **/ + private void collectLibInstanceInfo(){ + int index; + + String moduleType = SurfaceAreaQuery.getModuleType(); + String libConstructName = null; + String libDestructName = null; + 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]); + } + + 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); + } + } + } + + } + + }catch (Exception e){ + System.out.println(e.getMessage()); + System.out.println("Collect library instance failed!"); +} +} +}