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=b7d6ec4e395511997acd6692d79cbeee8dbbcab5;hp=c6d0d342cde2f962f8a22584bf1fc0c0e186b630;hb=66a9a6f8e99c1bf744e012448afcbd62bda7034d;hpb=daa7a3eb47288bdc8d60571d14d27fd2e830c3e5 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 c6d0d342cd..b7d6ec4e39 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 // @@ -326,7 +328,7 @@ public class AutoGen { String[] specList = saq.getExternSpecificaiton(); for (int i = 0; i < specList.length; i++) { fileBuffer.append(CommonDefinition.DEFINE + specList[i] - + "\n"); + + "\r\n"); } // // Write consumed package's mdouleInfo related .h file to autogen.h @@ -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,15 +356,15 @@ 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()) { fileBuffer.append(item.next().toString()); } } - fileBuffer.append("\n"); + fileBuffer.append("\r\n"); // // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to @@ -371,21 +373,22 @@ public class AutoGen { if (saq.isHaveTianoR8FlashMap()) { fileBuffer.append(CommonDefinition.INCLUDE); fileBuffer.append(" <"); - fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\n"); + fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n"); copyFlashMapHToDebugDir(); } // Write PCD autogen information to AutoGen.h. // if (this.myPcdAutogen != null) { - fileBuffer.append("\n"); + fileBuffer.append("\r\n"); fileBuffer.append(this.myPcdAutogen.getHAutoGenString()); } + fileBuffer.append(functionDeclarations); // // Append the #endif at AutoGen.h // - fileBuffer.append("#endif\n"); + fileBuffer.append("#endif\r\n"); // // Save string buffer content in AutoGen.h. @@ -469,7 +472,7 @@ public class AutoGen { // fileBuffer.append(guid); - fileBuffer.append("};\n"); + fileBuffer.append("};\r\n"); // // Generate library instance consumed protocol, guid, ppi, pcd list. @@ -509,7 +512,7 @@ public class AutoGen { this.myPcdAutogen.execute(); if (this.myPcdAutogen != null) { - fileBuffer.append("\n"); + fileBuffer.append("\r\n"); fileBuffer.append(this.myPcdAutogen.getCAutoGenString()); } @@ -563,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] - + "\n"); + fileBuffer.append(CommonDefinition.DEFINE + specList[i] + "\r\n"); } // fileBuffer.append(CommonDefinition.autoGenHLine1); // fileBuffer.append(CommonDefinition.autoGenHLine2); @@ -573,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()) { @@ -583,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(); @@ -592,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(); @@ -609,7 +610,7 @@ public class AutoGen { if (saq.isHaveTianoR8FlashMap()) { fileBuffer.append(CommonDefinition.INCLUDE); fileBuffer.append(" <"); - fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\n"); + fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n"); copyFlashMapHToDebugDir(); } @@ -617,15 +618,20 @@ public class AutoGen { // Write PCD information to library AutoGen.h. // if (this.myPcdAutogen != null) { - fileBuffer.append("\n"); + 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\n"); - + fileBuffer.append("#endif\r\n"); // // Save content of string buffer to AutoGen.h file. // @@ -667,10 +673,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 !!!"); - } } /** @@ -706,7 +708,7 @@ public class AutoGen { String includeNameStr = includeName[j]; if (includeNameStr != null) { str = CommonDefinition.INCLUDE + " " + "<"; - str = str + includeNameStr + ">\n"; + str = str + includeNameStr + ">\r\n"; includeStrList.add(str); includeNameStr = null; } @@ -744,8 +746,7 @@ public class AutoGen { + packageNameList[i] + "] declaration in any SPD package. "); } else if (!pkgHeader.equalsIgnoreCase("")) { - includeStr = CommonDefinition.INCLUDE + " <" + pkgHeader - + ">\n"; + includeStr = CommonDefinition.INCLUDE + " <" + pkgHeader + ">\r\n"; includeStrList.add(includeStr); } } @@ -769,7 +770,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; @@ -781,114 +782,113 @@ 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\n"); - fileBuffer.append("EFIAPI\n"); + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(entryPointList[0]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\n"); - fileBuffer.append(" IN VOID *OldCoreData\n"); - fileBuffer.append(" );\n\n"); - - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessModuleEntryPointList (\n"); - fileBuffer.append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\n"); - fileBuffer.append(" IN VOID *OldCoreData\n"); - fileBuffer.append(" )\n\n"); - fileBuffer.append("{\n"); + 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"); + + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ProcessModuleEntryPointList (\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"); + fileBuffer.append("{\r\n"); fileBuffer.append(" return "); fileBuffer.append(entryPointList[0]); - fileBuffer.append(" (PeiStartupDescriptor, OldCoreData);\n"); - fileBuffer.append("}\n\n"); + fileBuffer.append(" (PeiStartupDescriptor, OldCoreData);\r\n"); + fileBuffer.append("}\r\n\r\n"); } break; case CommonDefinition.ModuleTypeDxeCore: - fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\n"); + fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n"); if (entryPointList == null || entryPointList.length != 1) { throw new AutoGenException("Module type = 'DXE_CORE', can have only one module entry point!"); } else { - fileBuffer.append("VOID\n"); - fileBuffer.append("EFIAPI\n"); + fileBuffer.append("VOID\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(entryPointList[0]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN VOID *HobStart\n"); - fileBuffer.append(" );\n\n"); - - fileBuffer.append("VOID\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessModuleEntryPointList (\n"); - fileBuffer.append(" IN VOID *HobStart\n"); - fileBuffer.append(" )\n\n"); - fileBuffer.append("{\n"); + fileBuffer.append(" (\r\n"); + fileBuffer.append(" IN VOID *HobStart\r\n"); + fileBuffer.append(" );\r\n\r\n"); + + fileBuffer.append("VOID\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ProcessModuleEntryPointList (\r\n"); + fileBuffer.append(" IN VOID *HobStart\r\n"); + fileBuffer.append(" )\r\n\r\n"); + fileBuffer.append("{\r\n"); fileBuffer.append(" "); fileBuffer.append(entryPointList[0]); - fileBuffer.append(" (HobStart);\n"); - fileBuffer.append("}\n\n"); + fileBuffer.append(" (HobStart);\r\n"); + fileBuffer.append("}\r\n\r\n"); } break; case CommonDefinition.ModuleTypePeim: entryPointCount = 0; - fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\n"); + fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n"); if (entryPointList == null || entryPointList.length == 0) { - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessModuleEntryPointList (\n"); - fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\n"); - fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\n"); - fileBuffer.append(" )\n\n"); - fileBuffer.append("{\n"); - fileBuffer.append(" return EFI_SUCCESS;\n"); - fileBuffer.append("}\n\n"); + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ProcessModuleEntryPointList (\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\r\n"); + fileBuffer.append("{\r\n"); + fileBuffer.append(" return EFI_SUCCESS;\r\n"); + fileBuffer.append("}\r\n\r\n"); break; } for (int i = 0; i < entryPointList.length; i++) { - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(entryPointList[i]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\n"); - fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\n"); - fileBuffer.append(" );\n"); + 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"); entryPointCount++; } - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessModuleEntryPointList (\n"); - fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\n"); - fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\n"); - fileBuffer.append(" )\n\n"); - fileBuffer.append("{\n"); + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ProcessModuleEntryPointList (\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\r\n"); + fileBuffer.append("{\r\n"); if (entryPointCount == 1) { fileBuffer.append(String.format(" " + debugStr, entryPointList[0], entryPointList[0])); fileBuffer.append(" return "); fileBuffer.append(entryPointList[0]); - fileBuffer.append(" (FfsHeader, PeiServices);\n"); + fileBuffer.append(" (FfsHeader, PeiServices);\r\n"); } else { - fileBuffer.append(" EFI_STATUS Status;\n"); - fileBuffer.append(" EFI_STATUS CombinedStatus;\n\n"); - fileBuffer.append(" CombinedStatus = EFI_LOAD_ERROR;\n\n"); + fileBuffer.append(" EFI_STATUS Status;\r\n"); + fileBuffer.append(" EFI_STATUS CombinedStatus;\r\n\r\n"); + fileBuffer.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n"); for (int i = 0; i < entryPointList.length; i++) { if (!entryPointList[i].equals("")) { fileBuffer.append(String.format(" " + debugStr, entryPointList[i], entryPointList[i])); fileBuffer.append(" Status = "); fileBuffer.append(entryPointList[i]); - fileBuffer.append(" (FfsHeader, PeiServices);\n"); - fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\n"); - fileBuffer.append(" CombinedStatus = Status;\n"); - fileBuffer.append(" }\n\n"); + fileBuffer.append(" (FfsHeader, PeiServices);\r\n"); + fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n"); + fileBuffer.append(" CombinedStatus = Status;\r\n"); + fileBuffer.append(" }\r\n\r\n"); } else { break; } } - fileBuffer.append(" return CombinedStatus;\n"); + fileBuffer.append(" return CombinedStatus;\r\n"); } - fileBuffer.append("}\n\n"); + fileBuffer.append("}\r\n\r\n"); break; case CommonDefinition.ModuleTypeDxeSmmDriver: @@ -900,128 +900,125 @@ public class AutoGen { if (entryPointList == null || entryPointList.length == 0) { fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = "); fileBuffer.append(Integer.toString(entryPointCount)); - fileBuffer.append(";\n"); - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessModuleEntryPointList (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\n"); - fileBuffer.append(" )\n\n"); - fileBuffer.append("{\n"); - fileBuffer.append(" return EFI_SUCCESS;\n"); - fileBuffer.append("}\n\n"); + fileBuffer.append(";\r\n"); + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ProcessModuleEntryPointList (\r\n"); + fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); + fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n"); + fileBuffer.append(" )\r\n\r\n"); + fileBuffer.append("{\r\n"); + fileBuffer.append(" return EFI_SUCCESS;\r\n"); + fileBuffer.append("}\r\n\r\n"); } else { for (int i = 0; i < entryPointList.length; i++) { - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(entryPointList[i]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\n"); - fileBuffer.append(" );\n"); + 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"); entryPointCount++; } fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = "); fileBuffer.append(Integer.toString(entryPointCount)); - fileBuffer.append(";\n"); - fileBuffer.append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\n"); - fileBuffer.append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\n\n"); - - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessModuleEntryPointList (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\n"); - fileBuffer.append(" )\n\n"); - fileBuffer.append("{\n"); + fileBuffer.append(";\r\n"); + fileBuffer.append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n"); + fileBuffer.append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n"); + + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ProcessModuleEntryPointList (\r\n"); + fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); + fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n"); + fileBuffer.append(" )\r\n\r\n"); + fileBuffer.append("{\r\n"); for (int i = 0; i < entryPointList.length; i++) { - fileBuffer.append(" if (SetJump (&mJumpContext) == 0) {\n"); + fileBuffer.append(" if (SetJump (&mJumpContext) == 0) {\r\n"); fileBuffer.append(String.format(" " + debugStr, entryPointList[i], entryPointList[i])); fileBuffer.append(" ExitDriver ("); fileBuffer.append(entryPointList[i]); - fileBuffer.append(" (ImageHandle, SystemTable));\n"); - fileBuffer.append(" ASSERT (FALSE);\n"); - fileBuffer.append(" }\n"); + fileBuffer.append(" (ImageHandle, SystemTable));\r\n"); + fileBuffer.append(" ASSERT (FALSE);\r\n"); + fileBuffer.append(" }\r\n"); } - fileBuffer.append(" return mDriverEntryPointStatus;\n"); - fileBuffer.append("}\n\n"); - - fileBuffer.append("VOID\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ExitDriver (\n"); - fileBuffer.append(" IN EFI_STATUS Status\n"); - fileBuffer.append(" )\n\n"); - fileBuffer.append("{\n"); - fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\n"); - fileBuffer.append(" mDriverEntryPointStatus = Status;\n"); - fileBuffer.append(" }\n"); - fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\n"); - fileBuffer.append(" ASSERT (FALSE);\n"); - fileBuffer.append("}\n\n"); + fileBuffer.append(" return mDriverEntryPointStatus;\r\n"); + fileBuffer.append("}\r\n\r\n"); + + fileBuffer.append("VOID\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ExitDriver (\r\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"); + fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n"); + fileBuffer.append(" }\r\n"); + fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n"); + fileBuffer.append(" ASSERT (FALSE);\r\n"); + fileBuffer.append("}\r\n\r\n"); } // // Add "ModuleUnloadImage" for DxeSmmDriver module type; // - //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray(); - //entryPointList = CommonDefinition.remDupString(entryPointList); - //entryPointCount = 0; unloadImageCount = 0; if (unloadImageList != null) { for (int i = 0; i < unloadImageList.length; i++) { - fileBuffer.append("EFI_STATUS\n"); + fileBuffer.append("EFI_STATUS\r\n"); fileBuffer.append(unloadImageList[i]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle\n"); - fileBuffer.append(" );\n"); + fileBuffer.append(" (\r\n"); + fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n"); + fileBuffer.append(" );\r\n"); unloadImageCount++; } } fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = "); fileBuffer.append(Integer.toString(unloadImageCount)); - fileBuffer.append(";\n\n"); + fileBuffer.append(";\r\n\r\n"); - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessModuleUnloadList (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle\n"); - fileBuffer.append(" )\n"); - fileBuffer.append("{\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"); + fileBuffer.append(" )\r\n"); + fileBuffer.append("{\r\n"); if (unloadImageCount == 0) { - fileBuffer.append(" return EFI_SUCCESS;\n"); + fileBuffer.append(" return EFI_SUCCESS;\r\n"); } else if (unloadImageCount == 1) { fileBuffer.append(" return "); fileBuffer.append(unloadImageList[0]); - fileBuffer.append("(ImageHandle);\n"); + fileBuffer.append("(ImageHandle);\r\n"); } else { - fileBuffer.append(" EFI_STATUS Status;\n\n"); - fileBuffer.append(" Status = EFI_SUCCESS;\n\n"); + fileBuffer.append(" EFI_STATUS Status;\r\n\r\n"); + fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n"); for (int i = 0; i < unloadImageList.length; i++) { if (i == 0) { fileBuffer.append(" Status = "); fileBuffer.append(unloadImageList[i]); - fileBuffer.append("(ImageHandle);\n"); + fileBuffer.append("(ImageHandle);\r\n"); } else { - fileBuffer.append(" if (EFI_ERROR (Status)) {\n"); + fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n"); fileBuffer.append(" "); fileBuffer.append(unloadImageList[i]); - fileBuffer.append("(ImageHandle);\n"); - fileBuffer.append(" } else {\n"); + fileBuffer.append("(ImageHandle);\r\n"); + fileBuffer.append(" } else {\r\n"); fileBuffer.append(" Status = "); fileBuffer.append(unloadImageList[i]); - fileBuffer.append("(ImageHandle);\n"); - fileBuffer.append(" }\n"); + fileBuffer.append("(ImageHandle);\r\n"); + fileBuffer.append(" }\r\n"); } } - fileBuffer.append(" return Status;\n"); + fileBuffer.append(" return Status;\r\n"); } - fileBuffer.append("}\n\n"); + fileBuffer.append("}\r\n\r\n"); break; case CommonDefinition.ModuleTypeDxeRuntimeDriver: @@ -1030,95 +1027,94 @@ public class AutoGen { case CommonDefinition.ModuleTypeUefiDriver: case CommonDefinition.ModuleTypeUefiApplication: entryPointCount = 0; - fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\n"); + fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n"); // // If entry point is null, create a empty ProcessModuleEntryPointList function. // if (entryPointList == null || entryPointList.length == 0) { - fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\n"); - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessModuleEntryPointList (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\n"); - fileBuffer.append(" )\n\n"); - fileBuffer.append("{\n"); - fileBuffer.append(" return EFI_SUCCESS;\n"); - fileBuffer.append("}\n"); + fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n"); + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ProcessModuleEntryPointList (\r\n"); + fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); + fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n"); + fileBuffer.append(" )\r\n\r\n"); + fileBuffer.append("{\r\n"); + fileBuffer.append(" return EFI_SUCCESS;\r\n"); + fileBuffer.append("}\r\n"); } else { for (int i = 0; i < entryPointList.length; i++) { - - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(entryPointList[i]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\n"); - fileBuffer.append(" );\n"); + 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"); entryPointCount++; } fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = "); fileBuffer.append(Integer.toString(entryPointCount)); - fileBuffer.append(";\n"); + fileBuffer.append(";\r\n"); if (entryPointCount > 1) { - fileBuffer.append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\n"); - fileBuffer.append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\n"); + 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\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessModuleEntryPointList (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\n"); - fileBuffer.append(" )\n\n"); - fileBuffer.append("{\n"); + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ProcessModuleEntryPointList (\r\n"); + fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); + fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n"); + fileBuffer.append(" )\r\n\r\n"); + fileBuffer.append("{\r\n"); if (entryPointCount == 1) { fileBuffer.append(String.format(" " + debugStr, entryPointList[0], entryPointList[0])); fileBuffer.append(" return "); fileBuffer.append(entryPointList[0]); - fileBuffer.append(" (ImageHandle, SystemTable);\n"); + fileBuffer.append(" (ImageHandle, SystemTable);\r\n"); } else { for (int i = 0; i < entryPointList.length; i++) { if (!entryPointList[i].equals("")) { - fileBuffer.append(" if (SetJump (&mJumpContext) == 0) {\n"); + fileBuffer.append(" if (SetJump (&mJumpContext) == 0) {\r\n"); fileBuffer.append(String.format(" " + debugStr, entryPointList[i], entryPointList[i])); fileBuffer.append(" ExitDriver ("); fileBuffer.append(entryPointList[i]); - fileBuffer.append(" (ImageHandle, SystemTable));\n"); - fileBuffer.append(" ASSERT (FALSE);\n"); - fileBuffer.append(" }\n"); + fileBuffer.append(" (ImageHandle, SystemTable));\r\n"); + fileBuffer.append(" ASSERT (FALSE);\r\n"); + fileBuffer.append(" }\r\n"); } else { break; } } - fileBuffer.append(" return mDriverEntryPointStatus;\n"); + fileBuffer.append(" return mDriverEntryPointStatus;\r\n"); } - fileBuffer.append("}\n\n"); - - fileBuffer.append("VOID\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ExitDriver (\n"); - fileBuffer.append(" IN EFI_STATUS Status\n"); - fileBuffer.append(" )\n\n"); - fileBuffer.append("{\n"); + fileBuffer.append("}\r\n\r\n"); + + fileBuffer.append("VOID\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ExitDriver (\r\n"); + fileBuffer.append(" IN EFI_STATUS Status\r\n"); + fileBuffer.append(" )\r\n\r\n"); + fileBuffer.append("{\r\n"); if (entryPointCount <= 1) { - fileBuffer.append(" if (EFI_ERROR (Status)) {\n"); - fileBuffer.append(" ProcessLibraryDestructorList (gImageHandle, gST);\n"); - fileBuffer.append(" }\n"); + 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);\n"); + .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n"); } else { - fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\n"); - fileBuffer.append(" mDriverEntryPointStatus = Status;\n"); - fileBuffer.append(" }\n"); - fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\n"); - fileBuffer.append(" ASSERT (FALSE);\n"); + fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n"); + fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n"); + fileBuffer.append(" }\r\n"); + fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n"); + fileBuffer.append(" ASSERT (FALSE);\r\n"); } - fileBuffer.append("}\n\n"); + fileBuffer.append("}\r\n\r\n"); } // @@ -1133,56 +1129,56 @@ public class AutoGen { unloadImageCount = 0; if (unloadImageList != null) { for (int i = 0; i < unloadImageList.length; i++) { - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); + fileBuffer.append("EFI_STATUS\r\n"); + fileBuffer.append("EFIAPI\r\n"); fileBuffer.append(unloadImageList[i]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle\n"); - fileBuffer.append(" );\n"); + fileBuffer.append(" (\r\n"); + fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n"); + fileBuffer.append(" );\r\n"); unloadImageCount++; } } fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = "); fileBuffer.append(Integer.toString(unloadImageCount)); - fileBuffer.append(";\n\n"); + fileBuffer.append(";\r\n\r\n"); - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessModuleUnloadList (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle\n"); - fileBuffer.append(" )\n"); - fileBuffer.append("{\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"); + fileBuffer.append(" )\r\n"); + fileBuffer.append("{\r\n"); if (unloadImageCount == 0) { - fileBuffer.append(" return EFI_SUCCESS;\n"); + fileBuffer.append(" return EFI_SUCCESS;\r\n"); } else if (unloadImageCount == 1) { fileBuffer.append(" return "); fileBuffer.append(unloadImageList[0]); - fileBuffer.append("(ImageHandle);\n"); + fileBuffer.append("(ImageHandle);\r\n"); } else { - fileBuffer.append(" EFI_STATUS Status;\n\n"); - fileBuffer.append(" Status = EFI_SUCCESS;\n\n"); + fileBuffer.append(" EFI_STATUS Status;\r\n\r\n"); + fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n"); for (int i = 0; i < unloadImageList.length; i++) { if (i == 0) { fileBuffer.append(" Status = "); fileBuffer.append(unloadImageList[i]); - fileBuffer.append("(ImageHandle);\n"); + fileBuffer.append("(ImageHandle);\r\n"); } else { - fileBuffer.append(" if (EFI_ERROR (Status)) {\n"); + fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n"); fileBuffer.append(" "); fileBuffer.append(unloadImageList[i]); - fileBuffer.append("(ImageHandle);\n"); - fileBuffer.append(" } else {\n"); + fileBuffer.append("(ImageHandle);\r\n"); + fileBuffer.append(" } else {\r\n"); fileBuffer.append(" Status = "); fileBuffer.append(unloadImageList[i]); - fileBuffer.append("(ImageHandle);\n"); - fileBuffer.append(" }\n"); + fileBuffer.append("(ImageHandle);\r\n"); + fileBuffer.append(" }\r\n"); } } - fileBuffer.append(" return Status;\n"); + fileBuffer.append(" return Status;\r\n"); } - fileBuffer.append("}\n\n"); + fileBuffer.append("}\r\n\r\n"); break; } } @@ -1225,7 +1221,7 @@ public class AutoGen { ppiKeyWord = ppiIterator.next().toString(); cNameGuid = GlobalData.getPpiGuid(this.mDepPkgList, ppiKeyWord); if (cNameGuid != null) { - fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID "); + fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID "); fileBuffer.append(cNameGuid[0]); fileBuffer.append(" = { "); fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1])); @@ -1280,7 +1276,7 @@ public class AutoGen { protocolKeyWord = protocolIterator.next().toString(); cNameGuid = GlobalData.getProtocolGuid(this.mDepPkgList, protocolKeyWord); if (cNameGuid != null) { - fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID "); + fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID "); fileBuffer.append(cNameGuid[0]); fileBuffer.append(" = { "); fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1])); @@ -1322,7 +1318,7 @@ public class AutoGen { cNameGuid = GlobalData.getGuid(this.mDepPkgList, guidKeyWord); if (cNameGuid != null) { - fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID "); + fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID "); fileBuffer.append(cNameGuid[0]); fileBuffer.append(" = { "); fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1])); @@ -1354,12 +1350,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 +1527,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\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\n"); - fileBuffer.append(" VOID\n"); - fileBuffer.append(" );\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\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\n"); - fileBuffer.append(" VOID\n"); - fileBuffer.append(" );\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\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\n"); - fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\n"); - fileBuffer.append(" );\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 +1562,13 @@ public class AutoGen { case CommonDefinition.ModuleTypeDxeSalDriver: case CommonDefinition.ModuleTypeUefiDriver: case CommonDefinition.ModuleTypeUefiApplication: - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\n"); - fileBuffer.append(" );\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; } @@ -1437,19 +1578,19 @@ public class AutoGen { // // Add ProcessLibraryConstructorList in AutoGen.c // - fileBuffer.append("VOID\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessLibraryConstructorList (\n"); + fileBuffer.append("VOID\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append("ProcessLibraryConstructorList (\r\n"); switch (CommonDefinition.getModuleType(moduleType)) { case CommonDefinition.ModuleTypeBase: - fileBuffer.append(" VOID\n"); + fileBuffer.append(" VOID\r\n"); break; case CommonDefinition.ModuleTypePeiCore: case CommonDefinition.ModuleTypePeim: - fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\n"); + fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n"); fileBuffer - .append(" IN EFI_PEI_SERVICES **PeiServices\n"); + .append(" IN EFI_PEI_SERVICES **PeiServices\r\n"); break; case CommonDefinition.ModuleTypeDxeCore: @@ -1459,42 +1600,39 @@ public class AutoGen { case CommonDefinition.ModuleTypeDxeSalDriver: case CommonDefinition.ModuleTypeUefiDriver: case CommonDefinition.ModuleTypeUefiApplication: - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\n"); + fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n"); + fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n"); break; } - fileBuffer.append(" )\n"); - fileBuffer.append("{\n"); + fileBuffer.append(" )\r\n"); + fileBuffer.append("{\r\n"); // // If no constructor function, return EFI_SUCCESS. // - //if (libInstanceList.size() == 0){ - // fileBuffer.append(" return EFI_SUCCESS;\n"); - //} for (int i = 0; i < libInstanceList.size(); i++) { if (isFirst) { - fileBuffer.append(" EFI_STATUS Status;\n"); - fileBuffer.append(" Status = EFI_SUCCESS;\n"); - fileBuffer.append("\n"); + fileBuffer.append(" EFI_STATUS Status;\r\n"); + fileBuffer.append(" Status = EFI_SUCCESS;\r\n"); + fileBuffer.append("\r\n"); isFirst = false; } if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) { fileBuffer.append(" Status = "); fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append("();\n"); + fileBuffer.append("();\r\n"); } else { switch (CommonDefinition.getModuleType(moduleType)) { case CommonDefinition.ModuleTypeBase: fileBuffer.append(" Status = "); fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append("();\n"); + fileBuffer.append("();\r\n"); break; case CommonDefinition.ModuleTypePeiCore: case CommonDefinition.ModuleTypePeim: fileBuffer.append(" Status = "); fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (FfsHeader, PeiServices);\n"); + fileBuffer.append(" (FfsHeader, PeiServices);\r\n"); break; case CommonDefinition.ModuleTypeDxeCore: case CommonDefinition.ModuleTypeDxeDriver: @@ -1505,16 +1643,16 @@ public class AutoGen { case CommonDefinition.ModuleTypeUefiApplication: fileBuffer.append(" Status = "); fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (ImageHandle, SystemTable);\n"); + fileBuffer.append(" (ImageHandle, SystemTable);\r\n"); break; default: EdkLog.log(EdkLog.EDK_INFO,"Autogen doesn't know how to deal with module type - " + moduleType + "!"); } } - fileBuffer.append(" ASSERT_EFI_ERROR (Status);\n"); + fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n"); } - fileBuffer.append("}\n"); + fileBuffer.append("}\r\n"); } /** @@ -1536,31 +1674,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\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\n"); - fileBuffer.append(" VOID\n"); - fileBuffer.append(" );\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\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\n"); - fileBuffer.append(" VOID\n"); - fileBuffer.append(" );\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\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\n"); - fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\n"); - fileBuffer.append(" );\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 +1707,13 @@ public class AutoGen { case CommonDefinition.ModuleTypeDxeSalDriver: case CommonDefinition.ModuleTypeUefiDriver: case CommonDefinition.ModuleTypeUefiApplication: - fileBuffer.append("EFI_STATUS\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\n"); - fileBuffer.append(" );\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; } } @@ -1596,37 +1734,37 @@ public class AutoGen { case CommonDefinition.ModuleTypeDxeSalDriver: case CommonDefinition.ModuleTypeUefiDriver: case CommonDefinition.ModuleTypeUefiApplication: - fileBuffer.append("VOID\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append("ProcessLibraryDestructorList (\n"); - fileBuffer.append(" IN EFI_HANDLE ImageHandle,\n"); - fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\n"); - fileBuffer.append(" )\n"); - fileBuffer.append("{\n"); + 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"); + fileBuffer.append(" )\r\n"); + fileBuffer.append("{\r\n"); // // If no library destructor function, return EFI_SUCCESS. // for (int i = 0; i < libInstanceList.size(); i++) { if (isFirst) { - fileBuffer.append(" EFI_STATUS Status;\n"); - fileBuffer.append(" Status = EFI_SUCCESS;\n"); - fileBuffer.append("\n"); + fileBuffer.append(" EFI_STATUS Status;\r\n"); + fileBuffer.append(" Status = EFI_SUCCESS;\r\n"); + fileBuffer.append("\r\n"); isFirst = false; } if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) { fileBuffer.append(" Status = "); fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append("();\n"); - fileBuffer.append(" VOID\n"); + fileBuffer.append("();\r\n"); + fileBuffer.append(" VOID\r\n"); } else { fileBuffer.append(" Status = "); fileBuffer.append(libInstanceList.get(i)[0]); - fileBuffer.append("(ImageHandle, SystemTable);\n"); - fileBuffer.append(" ASSERT_EFI_ERROR (Status);\n"); + fileBuffer.append("(ImageHandle, SystemTable);\r\n"); + fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n"); } } - fileBuffer.append("}\n"); + fileBuffer.append("}\r\n"); break; } } @@ -1662,7 +1800,7 @@ public class AutoGen { if (driverBindingGroup[i][0] != null) { fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL "); fileBuffer.append(driverBindingGroup[i][0]); - fileBuffer.append(";\n"); + fileBuffer.append(";\r\n"); } } @@ -1676,7 +1814,7 @@ public class AutoGen { BitMask |= 0x01; fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL "); fileBuffer.append(driverBindingGroup[i][1]); - fileBuffer.append(";\n"); + fileBuffer.append(";\r\n"); } else { throw new AutoGenException("DriverBinding can't be empty!!"); } @@ -1693,7 +1831,7 @@ public class AutoGen { BitMask |= 0x02; fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL "); fileBuffer.append(driverBindingGroup[i][2]); - fileBuffer.append(";\n"); + fileBuffer.append(";\r\n"); } else { throw new AutoGenException("DriverBinding can't be empty!!"); } @@ -1710,7 +1848,7 @@ public class AutoGen { BitMask |= 0x04; fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL "); fileBuffer.append(driverBindingGroup[i][3]); - fileBuffer.append(";\n"); + fileBuffer.append(";\r\n"); } else { throw new AutoGenException("DriverBinding can't be empty!!"); } @@ -1724,7 +1862,7 @@ public class AutoGen { // fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = "); fileBuffer.append(Integer.toString(BitMask)); - fileBuffer.append(";\n"); + fileBuffer.append(";\r\n"); // // Write driver module protocol list entry @@ -1732,7 +1870,7 @@ public class AutoGen { fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = "); fileBuffer.append(Integer.toString(driverBindingGroup.length)); - fileBuffer.append(";\n"); + fileBuffer.append(";\r\n"); // // Write drive module protocol list to autogen.c @@ -1749,10 +1887,10 @@ public class AutoGen { // // DriverBinding // - fileBuffer.append("\n {\n"); + fileBuffer.append("\r\n {\r\n"); fileBuffer.append(" &"); fileBuffer.append(driverBindingGroup[i][0]); - fileBuffer.append(", \n"); + fileBuffer.append(", \r\n"); // // ComponentName @@ -1760,9 +1898,9 @@ public class AutoGen { if (driverBindingGroup[i][1] != null && componentNamePcd != true) { fileBuffer.append(" &"); fileBuffer.append(driverBindingGroup[i][1]); - fileBuffer.append(", \n"); + fileBuffer.append(", \r\n"); } else { - fileBuffer.append(" NULL, \n"); + fileBuffer.append(" NULL, \r\n"); } // @@ -1771,9 +1909,9 @@ public class AutoGen { if (driverBindingGroup[i][2] != null) { fileBuffer.append(" &"); fileBuffer.append(driverBindingGroup[i][2]); - fileBuffer.append(", \n"); + fileBuffer.append(", \r\n"); } else { - fileBuffer.append(" NULL, \n"); + fileBuffer.append(" NULL, \r\n"); } // @@ -1782,15 +1920,82 @@ public class AutoGen { if (driverBindingGroup[i][3] != null && driverDiagnostPcd != true) { fileBuffer.append(" &"); fileBuffer.append(driverBindingGroup[i][3]); - fileBuffer.append(", \n"); + fileBuffer.append(", \r\n"); } else { - fileBuffer.append(" NULL, \n"); + fileBuffer.append(" NULL, \r\n"); } fileBuffer.append(" }"); } if (driverBindingGroup.length > 0) { - fileBuffer.append("\n};\n"); + fileBuffer.append("\r\n};\r\n"); + } + } + + /** + 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; } } @@ -1896,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; @@ -1903,120 +2109,127 @@ 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 // of entryPoint. // - fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = "); + fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = "); // // If the list is not valid or has no entries set count to zero else @@ -2034,14 +2247,14 @@ public class AutoGen { } fileBuffer.append(Integer.toString(Count)); - fileBuffer.append(";\n\n"); + fileBuffer.append(";\r\n\r\n"); if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) { // // No data so make a NULL list // - fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\n"); - fileBuffer.append(" NULL\n"); - fileBuffer.append("};\n\n"); + fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n"); + fileBuffer.append(" NULL\r\n"); + fileBuffer.append("};\r\n\r\n"); } else { // // Write SetVirtualAddressMap function definition. @@ -2050,28 +2263,28 @@ public class AutoGen { if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) { break; } - fileBuffer.append("VOID\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append(this.setVirtalAddList.get(i)); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_EVENT Event,\n"); - fileBuffer.append(" IN VOID *Context\n"); - fileBuffer.append(" );\n\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"); } // // Write SetVirtualAddressMap entry point array. // - fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {"); + fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {"); for (i = 0; i < this.setVirtalAddList.size(); i++) { if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) { break; } if (i == 0) { - fileBuffer.append("\n "); + fileBuffer.append("\r\n "); } else { - fileBuffer.append(",\n "); + fileBuffer.append(",\r\n "); } fileBuffer.append(this.setVirtalAddList.get(i)); @@ -2079,8 +2292,8 @@ public class AutoGen { // // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list. // - fileBuffer.append(",\n NULL"); - fileBuffer.append("\n};\n\n"); + fileBuffer.append(",\r\n NULL"); + fileBuffer.append("\r\n};\r\n\r\n"); } } @@ -2089,8 +2302,7 @@ public class AutoGen { // // Entry point lib for these module types needs to know the count. // - fileBuffer - .append("\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 @@ -2107,15 +2319,15 @@ public class AutoGen { Count = i; } fileBuffer.append(Integer.toString(Count)); - fileBuffer.append(";\n\n"); + fileBuffer.append(";\r\n\r\n"); if (this.exitBootServiceList == null || this.exitBootServiceList.size() == 0) { // // No data so make a NULL list. // - fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\n"); - fileBuffer.append(" NULL\n"); - fileBuffer.append("};\n\n"); + fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n"); + fileBuffer.append(" NULL\r\n"); + fileBuffer.append("};\r\n\r\n"); } else { // // Write DriverExitBootServices function definition. @@ -2125,34 +2337,34 @@ public class AutoGen { break; } - fileBuffer.append("VOID\n"); - fileBuffer.append("EFIAPI\n"); - fileBuffer.append(this.exitBootServiceList.get(i)); - fileBuffer.append(" (\n"); - fileBuffer.append(" IN EFI_EVENT Event,\n"); - fileBuffer.append(" IN VOID *Context\n"); - fileBuffer.append(" );\n\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"); } // // Write DriverExitBootServices entry point array. // - fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {"); + fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {"); for (i = 0; i < this.exitBootServiceList.size(); i++) { if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) { break; } if (i == 0) { - fileBuffer.append("\n "); + fileBuffer.append("\r\n "); } else { - fileBuffer.append(",\n "); + fileBuffer.append(",\r\n "); } fileBuffer.append(this.exitBootServiceList.get(i)); } - fileBuffer.append(",\n NULL"); - fileBuffer.append("\n};\n\n"); + fileBuffer.append(",\r\n NULL"); + fileBuffer.append("\r\n};\r\n\r\n"); } } /**