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=ce6ff6184221a37cb793dd21b9eee2feb51234c0;hp=5b917b9ab499c7dc7f2893d827d1e3bdb375ac95;hb=700279a971c1f603a72a45455be4b4f842ce39d9;hpb=bf43f5eb3ef77a43fc192692acc51547663dd29d 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 5b917b9ab4..ce6ff61842 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java @@ -119,6 +119,8 @@ public class AutoGen { private List setVirtalAddList = new ArrayList(); private List exitBootServiceList = new ArrayList(); + private StringBuffer functionDeclarations = new StringBuffer(10240); + // // flag of PcdComponentNameDisable, PcdDriverDiagnosticDisable // @@ -345,8 +347,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()) { @@ -354,8 +356,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()) { @@ -382,6 +384,7 @@ public class AutoGen { fileBuffer.append(this.myPcdAutogen.getHAutoGenString()); } + fileBuffer.append(functionDeclarations); // // Append the #endif at AutoGen.h // @@ -411,11 +414,6 @@ public class AutoGen { // fileBuffer.append(CommonDefinition.AUTOGENCNOTATION); - // - // Write #include at beginning of AutoGen.c - // - fileBuffer.append(CommonDefinition.INCLUDEAUTOGENH); - // // Get the native MSA file infomation. Since before call autogen, // the MSA native information were overrided. So before @@ -568,8 +566,7 @@ public class AutoGen { fileBuffer.append(CommonDefinition.AUTOGENHBEGIN); String[] specList = saq.getExternSpecificaiton(); for (int i = 0; i < specList.length; i++) { - fileBuffer.append(CommonDefinition.DEFINE + specList[i] - + "\r\n"); + fileBuffer.append(CommonDefinition.DEFINE + specList[i] + "\r\n"); } // fileBuffer.append(CommonDefinition.autoGenHLine1); // fileBuffer.append(CommonDefinition.autoGenHLine2); @@ -578,8 +575,7 @@ public class AutoGen { // Write consumed package's mdouleInfo related *.h file to autogen.h. // moduleType = saq.getModuleType(); - PackageIdentification[] cosumedPkglist = saq - .getDependencePkg(this.arch); + PackageIdentification[] cosumedPkglist = saq.getDependencePkg(this.arch); headerFileList = depPkgToAutogenH(cosumedPkglist, moduleType); item = headerFileList.iterator(); while (item.hasNext()) { @@ -588,7 +584,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(); @@ -597,7 +593,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(); @@ -625,12 +621,17 @@ public class AutoGen { fileBuffer.append("\r\n"); fileBuffer.append(this.myPcdAutogen.getHAutoGenString()); } - + // + // generate function prototype for constructor and destructor + // + LibConstructorToAutogenH(moduleType); + LibDestructorToAutogenH(moduleType); + ExternCallBackToAutoGenH(moduleType); + fileBuffer.append(functionDeclarations); // // Append the #endif at AutoGen.h // fileBuffer.append("#endif\r\n"); - // // Save content of string buffer to AutoGen.h file. // @@ -749,8 +750,7 @@ public class AutoGen { + packageNameList[i] + "] declaration in any SPD package. "); } else if (!pkgHeader.equalsIgnoreCase("")) { - includeStr = CommonDefinition.INCLUDE + " <" + pkgHeader - + ">\r\n"; + includeStr = CommonDefinition.INCLUDE + " <" + pkgHeader + ">\r\n"; includeStrList.add(includeStr); } } @@ -774,7 +774,7 @@ public class AutoGen { throws EdkException { String typeStr = saq.getModuleType(); - String debugStr = "DEBUG ((EFI_D_INFO | EFI_D_LOAD, \"Module Entry Point (%s) 0x%%p\\n\", (VOID *)(UINTN)%s));\n"; + String debugStr = "DEBUG ((EFI_D_INFO | EFI_D_LOAD, \"Module Entry Point (%s) 0x%%p\\n\", (VOID *)(UINTN)%s));\r\n"; int unloadImageCount = 0; int entryPointCount = 0; @@ -786,10 +786,10 @@ public class AutoGen { case CommonDefinition.ModuleTypePeiCore: if (entryPointList == null ||entryPointList.length != 1 ) { - throw new AutoGenException( - "Module type = 'PEI_CORE', can have only one module entry point!"); + 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"); @@ -816,8 +816,9 @@ public class AutoGen { 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(" (\n"); + fileBuffer.append(" (\r\n"); fileBuffer.append(" IN VOID *HobStart\r\n"); fileBuffer.append(" );\r\n\r\n"); @@ -851,6 +852,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(entryPointList[i]); fileBuffer.append(" (\r\n"); fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n"); @@ -916,6 +918,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(entryPointList[i]); fileBuffer.append(" (\r\n"); fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); @@ -952,7 +955,7 @@ public class AutoGen { 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"); fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n"); @@ -967,9 +970,6 @@ public class AutoGen { // // Add "ModuleUnloadImage" for DxeSmmDriver module type; // - //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray(); - //entryPointList = CommonDefinition.remDupString(entryPointList); - //entryPointCount = 0; unloadImageCount = 0; if (unloadImageList != null) { @@ -1049,8 +1049,8 @@ 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"); @@ -1066,7 +1066,7 @@ public class AutoGen { fileBuffer.append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n"); fileBuffer.append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n"); } - fileBuffer.append("\n"); + fileBuffer.append("\r\n"); fileBuffer.append("EFI_STATUS\r\n"); fileBuffer.append("EFIAPI\r\n"); @@ -1147,7 +1147,7 @@ public class AutoGen { fileBuffer.append(Integer.toString(unloadImageCount)); fileBuffer.append(";\r\n\r\n"); - fileBuffer.append("EFI_STATUS\n"); + fileBuffer.append("EFI_STATUS\r\n"); fileBuffer.append("EFIAPI\r\n"); fileBuffer.append("ProcessModuleUnloadList (\r\n"); fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n"); @@ -1354,12 +1354,157 @@ 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); + } + + /** + LibConstructorToAutogenH + + This function writes library constructor declarations AutoGen.h. The library + constructor's parameter and return value depend on module type. + + @param libInstanceList + List of library construct name. + @param moduleType + Module type. + @param fileBuffer + String buffer for AutoGen.c + @throws Exception + **/ + void LibConstructorToAutogenH(String moduleType) throws EdkException { + boolean isFirst = true; + + // + // If not yet parse this library instance's constructor + // element,parse it. + // + String libConstructName = saq.getLibConstructorName(); + if (libConstructName == null) { + return; + } + + // + // The library constructor's parameter and return value depend on + // module type. + // + if (moduleType.equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) { + functionDeclarations.append("RETURN_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libConstructName); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" VOID\r\n"); + functionDeclarations.append(" );\r\n"); + } else { + switch (CommonDefinition.getModuleType(moduleType)) { + case CommonDefinition.ModuleTypeBase: + functionDeclarations.append("RETURN_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libConstructName); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" VOID\r\n"); + functionDeclarations.append(" );\r\n"); + break; + + case CommonDefinition.ModuleTypePeiCore: + case CommonDefinition.ModuleTypePeim: + functionDeclarations.append("EFI_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libConstructName); + 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"); + break; + + case CommonDefinition.ModuleTypeDxeCore: + case CommonDefinition.ModuleTypeDxeDriver: + case CommonDefinition.ModuleTypeDxeRuntimeDriver: + case CommonDefinition.ModuleTypeDxeSmmDriver: + case CommonDefinition.ModuleTypeDxeSalDriver: + case CommonDefinition.ModuleTypeUefiDriver: + case CommonDefinition.ModuleTypeUefiApplication: + functionDeclarations.append("EFI_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libConstructName); + 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"); + break; + + } + } + } + + /** + LibDestructorToAutogenH + + This function writes library destructor declarations AutoGen.h. The library + destructor's parameter and return value depend on module type. + + @param libInstanceList + List of library destructor name. + @param moduleType + Module type. + @param fileBuffer + String buffer for AutoGen.c + @throws Exception + **/ + void LibDestructorToAutogenH(String moduleType) throws EdkException { + boolean isFirst = true; + String libDestructName = saq.getLibDestructorName(); + if (libDestructName == null) { + return; + } + + if (moduleType.equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) { + functionDeclarations.append("RETURN_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libDestructName); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" VOID\r\n"); + functionDeclarations.append(" );\r\n"); + } else { + switch (CommonDefinition.getModuleType(moduleType)) { + case CommonDefinition.ModuleTypeBase: + functionDeclarations.append("RETURN_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libDestructName); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" VOID\r\n"); + functionDeclarations.append(" );\r\n"); + break; + case CommonDefinition.ModuleTypePeiCore: + case CommonDefinition.ModuleTypePeim: + functionDeclarations.append("EFI_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libDestructName); + 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"); + break; + case CommonDefinition.ModuleTypeDxeCore: + case CommonDefinition.ModuleTypeDxeDriver: + case CommonDefinition.ModuleTypeDxeRuntimeDriver: + case CommonDefinition.ModuleTypeDxeSmmDriver: + case CommonDefinition.ModuleTypeDxeSalDriver: + case CommonDefinition.ModuleTypeUefiDriver: + case CommonDefinition.ModuleTypeUefiApplication: + functionDeclarations.append("EFI_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libDestructName); + 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"); + break; + } + } } /** @@ -1386,32 +1531,32 @@ public class AutoGen { // for (int i = 0; i < libInstanceList.size(); i++) { if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) { - fileBuffer.append("RETURN_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" VOID\r\n"); - fileBuffer.append(" );\r\n"); + functionDeclarations.append("RETURN_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libInstanceList.get(i)[0]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" VOID\r\n"); + functionDeclarations.append(" );\r\n"); } else { switch (CommonDefinition.getModuleType(moduleType)) { case CommonDefinition.ModuleTypeBase: - fileBuffer.append("RETURN_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" VOID\r\n"); - fileBuffer.append(" );\r\n"); + functionDeclarations.append("RETURN_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libInstanceList.get(i)[0]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" VOID\r\n"); + functionDeclarations.append(" );\r\n"); break; case CommonDefinition.ModuleTypePeiCore: case CommonDefinition.ModuleTypePeim: - fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - 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(libInstanceList.get(i)[0]); + 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"); break; case CommonDefinition.ModuleTypeDxeCore: @@ -1421,13 +1566,13 @@ public class AutoGen { case CommonDefinition.ModuleTypeDxeSalDriver: case CommonDefinition.ModuleTypeUefiDriver: case CommonDefinition.ModuleTypeUefiApplication: - fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - 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(libInstanceList.get(i)[0]); + 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"); break; } @@ -1469,9 +1614,6 @@ public class AutoGen { // // If no constructor function, return EFI_SUCCESS. // - //if (libInstanceList.size() == 0){ - // fileBuffer.append(" return EFI_SUCCESS;\r\n"); - //} for (int i = 0; i < libInstanceList.size(); i++) { if (isFirst) { fileBuffer.append(" EFI_STATUS Status;\r\n"); @@ -1536,31 +1678,31 @@ public class AutoGen { boolean isFirst = true; for (int i = 0; i < libInstanceList.size(); i++) { if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) { - fileBuffer.append("RETURN_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" VOID\r\n"); - fileBuffer.append(" );\r\n"); + functionDeclarations.append("RETURN_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libInstanceList.get(i)[0]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" VOID\r\n"); + functionDeclarations.append(" );\r\n"); } else { switch (CommonDefinition.getModuleType(moduleType)) { case CommonDefinition.ModuleTypeBase: - fileBuffer.append("RETURN_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\r\n"); - fileBuffer.append(" VOID\r\n"); - fileBuffer.append(" );\r\n"); + functionDeclarations.append("RETURN_STATUS\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(libInstanceList.get(i)[0]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" VOID\r\n"); + functionDeclarations.append(" );\r\n"); break; case CommonDefinition.ModuleTypePeiCore: case CommonDefinition.ModuleTypePeim: - fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - 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(libInstanceList.get(i)[0]); + 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"); break; case CommonDefinition.ModuleTypeDxeCore: case CommonDefinition.ModuleTypeDxeDriver: @@ -1569,13 +1711,13 @@ public class AutoGen { case CommonDefinition.ModuleTypeDxeSalDriver: case CommonDefinition.ModuleTypeUefiDriver: case CommonDefinition.ModuleTypeUefiApplication: - fileBuffer.append("EFI_STATUS\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - 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(libInstanceList.get(i)[0]); + 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"); break; } } @@ -1794,6 +1936,73 @@ public class AutoGen { } } + /** + ExternCallBackToAutoGenC + + This function adds and + infomation to AutoGen.c + + @param fileBuffer + String buffer for AutoGen.c + @throws BuildException + **/ + void ExternCallBackToAutoGenH(String moduleType) + throws EdkException { + // + // Collect module's and + // and add to setVirtualAddList + // exitBootServiceList. + // + String[] setVirtuals = saq.getSetVirtualAddressMapCallBackArray(); + String[] exitBoots = saq.getExitBootServicesCallBackArray(); + // + // Add c code in autogen.c which relate to + // and + // + switch (CommonDefinition.getModuleType(moduleType)) { + case CommonDefinition.ModuleTypeDxeDriver: + case CommonDefinition.ModuleTypeDxeRuntimeDriver: + case CommonDefinition.ModuleTypeDxeSalDriver: + case CommonDefinition.ModuleTypeUefiDriver: + case CommonDefinition.ModuleTypeUefiApplication: + // + // Write SetVirtualAddressMap function definition. + // + for (int i = 0; setVirtuals != null && i < setVirtuals.length; i++) { + if (setVirtuals[i].equalsIgnoreCase("")) { + continue; + } + functionDeclarations.append("VOID\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(setVirtuals[i]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN EFI_EVENT Event,\r\n"); + functionDeclarations.append(" IN VOID *Context\r\n"); + functionDeclarations.append(" );\r\n\r\n"); + } + + // + // Write DriverExitBootServices function definition. + // + for (int i = 0; exitBoots != null && i < exitBoots.length; i++) { + if (exitBoots[i].equalsIgnoreCase("")) { + continue; + } + + functionDeclarations.append("VOID\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(exitBoots[i]); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN EFI_EVENT Event,\r\n"); + functionDeclarations.append(" IN VOID *Context\r\n"); + functionDeclarations.append(" );\r\n\r\n"); + } + break; + default: + break; + } + } + /** ExternCallBackToAutoGenC @@ -1896,6 +2105,7 @@ public class AutoGen { private void collectLibInstanceInfo() throws EdkException{ int index; + String moduleType = moduleId.getModuleType(); String libConstructName = null; String libDestructName = null; String libModuleType = null; @@ -1903,114 +2113,121 @@ 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}); + } } } + private void setVirtualAddressToAutogenC(StringBuffer fileBuffer){ // // Entry point lib for these module types needs to know the count @@ -2050,13 +2267,13 @@ public class AutoGen { if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) { break; } - fileBuffer.append("VOID\r\n"); - fileBuffer.append("EFIAPI\r\n"); - 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"); - fileBuffer.append(" );\r\n\r\n"); + functionDeclarations.append("VOID\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(this.setVirtalAddList.get(i)); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN EFI_EVENT Event,\r\n"); + functionDeclarations.append(" IN VOID *Context\r\n"); + functionDeclarations.append(" );\r\n\r\n"); } // @@ -2089,8 +2306,7 @@ public class AutoGen { // // Entry point lib for these module types needs to know the count. // - fileBuffer - .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = "); + fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = "); // // If the list is not valid or has no entries set count to zero else @@ -2125,13 +2341,13 @@ public class AutoGen { break; } - fileBuffer.append("VOID\r\n"); - fileBuffer.append("EFIAPI\r\n"); - 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"); - fileBuffer.append(" );\r\n\r\n"); + functionDeclarations.append("VOID\r\n"); + functionDeclarations.append("EFIAPI\r\n"); + functionDeclarations.append(this.exitBootServiceList.get(i)); + functionDeclarations.append(" (\r\n"); + functionDeclarations.append(" IN EFI_EVENT Event,\r\n"); + functionDeclarations.append(" IN VOID *Context\r\n"); + functionDeclarations.append(" );\r\n\r\n"); } //