X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FJava%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fautogen%2FAutoGen.java;h=7953f5ce1218516fd9903b33dacc61c5ddca191d;hp=5925e504f63f9bb81a94fed2aeabaf1238643fe5;hb=a30ae9faeaafd760cc4a41a2abffcfd2b28742c1;hpb=aacce761007f07147d18376d65ca06f9e636e82d diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java b/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java index 5925e504f6..7953f5ce12 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java @@ -120,6 +120,7 @@ public class AutoGen { private List exitBootServiceList = new ArrayList(); private StringBuffer functionDeclarations = new StringBuffer(10240); + private StringBuffer globalDeclarations = new StringBuffer(10240); // // flag of PcdComponentNameDisable, PcdDriverDiagnosticDisable @@ -347,8 +348,8 @@ public class AutoGen { // // Write library class's related *.h file to autogen.h. // - String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED,this.arch); - if (libClassList != null) { + String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch, null); + if (libClassList.length > 0) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); while (item.hasNext()) { @@ -356,8 +357,8 @@ public class AutoGen { } } - libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch); - if (libClassList != null) { + libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch, null); + if (libClassList.length > 0) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); while (item.hasNext()) { @@ -384,6 +385,7 @@ public class AutoGen { fileBuffer.append(this.myPcdAutogen.getHAutoGenString()); } + fileBuffer.append(globalDeclarations); fileBuffer.append(functionDeclarations); // // Append the #endif at AutoGen.h @@ -584,7 +586,7 @@ public class AutoGen { // // Write library class's related *.h file to autogen.h // - String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch); + String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch, null); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -593,7 +595,7 @@ public class AutoGen { } } - libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch); + libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch, null); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -673,10 +675,6 @@ public class AutoGen { fileBuffer.append(ToolDefinitions.LINE_SEPARATOR); fileBuffer.append(this.myPcdAutogen.getCAutoGenString()); } - - if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) { - throw new AutoGenException("Failed to generate AutoGen.c !!!"); - } } /** @@ -788,13 +786,13 @@ public class AutoGen { if (entryPointList == null ||entryPointList.length != 1 ) { 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(entryPointList[0]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n"); - fileBuffer.append(" IN VOID *OldCoreData\r\n"); - fileBuffer.append(" );\r\n\r\n"); + functionDeclarations.append("EFI_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(entryPointList[0]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n"); + functionDeclarations.append(" IN VOID *OldCoreData\r\n"); + functionDeclarations.append(" );\r\n\r\n"); fileBuffer.append("EFI_STATUS\r\n"); fileBuffer.append("EFIAPI\r\n"); @@ -815,12 +813,12 @@ public class AutoGen { if (entryPointList == null || entryPointList.length != 1) { 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(entryPointList[0]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" IN VOID *HobStart\r\n"); - fileBuffer.append(" );\r\n\r\n"); + functionDeclarations.append("VOID\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(entryPointList[0]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN VOID *HobStart\r\n"); + functionDeclarations.append(" );\r\n\r\n"); fileBuffer.append("VOID\r\n"); fileBuffer.append("EFIAPI\r\n"); @@ -851,13 +849,13 @@ public class AutoGen { break; } for (int i = 0; i < entryPointList.length; i++) { - fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(entryPointList[i]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n"); - fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n"); - fileBuffer.append(" );\r\n"); + functionDeclarations.append("EFI_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(entryPointList[i]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n"); + functionDeclarations.append(" IN EFI_PEI_SERVICES **PeiServices\r\n"); + functionDeclarations.append(" );\r\n"); entryPointCount++; } @@ -917,13 +915,13 @@ 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(entryPointList[i]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n"); - fileBuffer.append(" );\r\n"); + functionDeclarations.append("EFI_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(entryPointList[i]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN EFI_HANDLE ImageHandle,\r\n"); + functionDeclarations.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n"); + functionDeclarations.append(" );\r\n"); entryPointCount++; } fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = "); @@ -974,11 +972,11 @@ public class AutoGen { unloadImageCount = 0; if (unloadImageList != null) { for (int i = 0; i < unloadImageList.length; i++) { - fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append(unloadImageList[i]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n"); - fileBuffer.append(" );\r\n"); + functionDeclarations.append("EFI_STATUS\r\n"); + functionDeclarations.append(unloadImageList[i]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN EFI_HANDLE ImageHandle\r\n"); + functionDeclarations.append(" );\r\n"); unloadImageCount++; } } @@ -1049,13 +1047,13 @@ 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(entryPointList[i]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n"); - fileBuffer.append(" );\r\n"); + functionDeclarations.append("EFI_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(entryPointList[i]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN EFI_HANDLE ImageHandle,\r\n"); + functionDeclarations.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n"); + functionDeclarations.append(" );\r\n"); entryPointCount++; } @@ -1109,8 +1107,7 @@ public class AutoGen { fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n"); fileBuffer.append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n"); fileBuffer.append(" }\r\n"); - fileBuffer - .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n"); + fileBuffer.append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n"); } else { fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n"); fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n"); @@ -1133,12 +1130,12 @@ public class AutoGen { 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(unloadImageList[i]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n"); - fileBuffer.append(" );\r\n"); + functionDeclarations.append("EFI_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(unloadImageList[i]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN EFI_HANDLE ImageHandle\r\n"); + functionDeclarations.append(" );\r\n"); unloadImageCount++; } } @@ -1354,12 +1351,11 @@ public class AutoGen { // // Add library constructor to AutoGen.c // - LibConstructorToAutogenC(libConstructList, moduleType, - fileBuffer/* autogenC */); + LibConstructorToAutogenC(libConstructList, moduleType, fileBuffer); // // Add library destructor to AutoGen.c // - LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */); + LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer); } /** @@ -1594,8 +1590,7 @@ public class AutoGen { case CommonDefinition.ModuleTypePeiCore: case CommonDefinition.ModuleTypePeim: fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n"); - fileBuffer - .append(" IN EFI_PEI_SERVICES **PeiServices\r\n"); + fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n"); break; case CommonDefinition.ModuleTypeDxeCore: @@ -1803,9 +1798,9 @@ public class AutoGen { // for (int i = 0; i < driverBindingGroup.length; i++) { if (driverBindingGroup[i][0] != null) { - fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL "); - fileBuffer.append(driverBindingGroup[i][0]); - fileBuffer.append(";\r\n"); + globalDeclarations.append("extern EFI_DRIVER_BINDING_PROTOCOL "); + globalDeclarations.append(driverBindingGroup[i][0]); + globalDeclarations.append(";\r\n"); } } @@ -1817,9 +1812,9 @@ public class AutoGen { if (driverBindingGroup[i][1]!= null) { if (driverBindingGroup[i][0] != null) { BitMask |= 0x01; - fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL "); - fileBuffer.append(driverBindingGroup[i][1]); - fileBuffer.append(";\r\n"); + globalDeclarations.append("extern EFI_COMPONENT_NAME_PROTOCOL "); + globalDeclarations.append(driverBindingGroup[i][1]); + globalDeclarations.append(";\r\n"); } else { throw new AutoGenException("DriverBinding can't be empty!!"); } @@ -1834,9 +1829,9 @@ public class AutoGen { if (driverBindingGroup[i][2] != null) { if (driverBindingGroup[i][0] != null) { BitMask |= 0x02; - fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL "); - fileBuffer.append(driverBindingGroup[i][2]); - fileBuffer.append(";\r\n"); + globalDeclarations.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL "); + globalDeclarations.append(driverBindingGroup[i][2]); + globalDeclarations.append(";\r\n"); } else { throw new AutoGenException("DriverBinding can't be empty!!"); } @@ -1851,9 +1846,9 @@ public class AutoGen { if (driverBindingGroup[i][3] != null) { if (driverBindingGroup[i][0] != null) { BitMask |= 0x04; - fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL "); - fileBuffer.append(driverBindingGroup[i][3]); - fileBuffer.append(";\r\n"); + globalDeclarations.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL "); + globalDeclarations.append(driverBindingGroup[i][3]); + globalDeclarations.append(";\r\n"); } else { throw new AutoGenException("DriverBinding can't be empty!!"); } @@ -2106,6 +2101,7 @@ public class AutoGen { private void collectLibInstanceInfo() throws EdkException{ int index; + String moduleType = moduleId.getModuleType(); String libConstructName = null; String libDestructName = null; String libModuleType = null; @@ -2113,112 +2109,118 @@ public class AutoGen { String[] exitBoots = null; ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch); + if (libraryIdList.length <= 0) { + return; + } + // + // Reorder library instance sequence. + // + AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList, this.arch); + List orderList = libOrder.orderLibInstance(); + // + // Process library instance one by one. + // + for (int i = 0; i < orderList.size(); i++) { + // + // Get library instance basename. + // + ModuleIdentification libInstanceId = orderList.get(i); - if (libraryIdList != null) { // - // Reorder library instance sequence. + // Get override map // - 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]); - } + Map libDoc = GlobalData.getDoc(libInstanceId, this.arch); + saq.push(libDoc); + // + // check if the library instance support current module + // + String[] libraryClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, + this.arch, + moduleType + ); + if (libraryClassList.length <= 0) { + throw new EdkException("Library instance " + libInstanceId.getName() + + " doesn't support module type " + moduleType); + } + // + // 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); - for (index = 0; index < ppiNotifyList.length; index++) { - this.mPpiList.add(ppiNotifyList[index]); - } + // + // 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 < protocolList.length; index++) { - this.mProtocolList.add(protocolList[index]); - } + for (index = 0; index < ppiNotifyList.length; index++) { + this.mPpiList.add(ppiNotifyList[index]); + } - for (index = 0; index < protocolNotifyList.length; index++) { - this.mProtocolList.add(protocolNotifyList[index]); - } + for (index = 0; index < protocolList.length; index++) { + this.mProtocolList.add(protocolList[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]); - } - } + for (index = 0; index < protocolNotifyList.length; index++) { + this.mProtocolList.add(protocolNotifyList[index]); + } - // - // If not yet parse this library instance's constructor - // element,parse it. - // - libConstructName = saq.getLibConstructorName(); - libDestructName = saq.getLibDestructorName(); - libModuleType = saq.getModuleType(); - - // - // 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(new String[] {libConstructName, libModuleType}); - } - // - // Add dependent library instance destructor fuction. - // - if (libDestructName != null) { - this.libDestructList.add(new String[] {libDestructName, libModuleType}); - } + 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(); + libModuleType = saq.getModuleType(); + + // + // 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(new String[] {libConstructName, libModuleType}); + } + // + // Add dependent library instance destructor fuction. + // + if (libDestructName != null) { + this.libDestructList.add(new String[] {libDestructName, libModuleType}); + } } }