X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fautogen%2FAutoGen.java;h=08b44f9eb47a871d398ef64e32972f805e06cc2a;hb=83fba802560b3446de68ac1c280773cf1a4271be;hp=dea679b407856861bb2cf034fb30bc943f4a95ac;hpb=ca844f3623e795de548a5aaa8bda84aa0466b5dd;p=mirror_edk2.git diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java index dea679b407..08b44f9eb4 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java +++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java @@ -22,6 +22,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; +import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -39,13 +40,13 @@ import org.tianocore.build.global.SurfaceAreaQuery; import org.tianocore.build.id.ModuleIdentification; import org.tianocore.build.id.PackageIdentification; import org.tianocore.build.pcd.action.PCDAutoGenAction; - import org.tianocore.common.logger.EdkLog; +import org.tianocore.common.definitions.ToolDefinitions; /** - * This class is to generate Autogen.h and Autogen.c according to module surface - * area or library surface area. - */ + This class is to generate Autogen.h and Autogen.c according to module surface + area or library surface area. +**/ public class AutoGen { /// /// The output path of Autogen.h and Autogen.c @@ -96,96 +97,116 @@ public class AutoGen { /// private Set mGuidList = new HashSet(); - // - // The dependence package list which recoreded in module or library surface - // area and it's dependence on library instance surface are. - // + /// + /// The dependence package list which recoreded in module or library surface + /// area and it's dependence on library instance surface area. + /// private List mDepPkgList = new LinkedList(); - // - // For non library module, add its library instance's construct and destructor to - // list. - // + /// + /// For non library module, add its library instance's construct and destructor to + /// list. + /// private List libConstructList = new ArrayList(); private List libDestructList = new ArrayList(); - // - // List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack - // + /// + /// List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack + /// private List setVirtalAddList = new ArrayList(); private List exitBootServiceList = new ArrayList(); + private SurfaceAreaQuery saq = null; /** - * Construct function - * - * This function mainly initialize some member variable. - * - * @param outputPath - * Output path of AutoGen file. - * @param baseName - * Module base name. - * @param arch - * Target architecture. - */ - public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch) { + Construct function + + This function mainly initialize some member variable. + + @param fvDir + Absolute path of FV directory. + @param outputPath + Output path of AutoGen file. + @param moduleId + Module identification. + @param arch + Target architecture. + **/ + public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch, SurfaceAreaQuery saq) { this.outputPath = outputPath; this.moduleId = moduleId; this.arch = arch; this.fvDir = fvDir; - + this.saq = saq; } /** - * saveFile function - * - * This function save the content in stringBuffer to file. - * - * @param fileName - * The name of file. - * @param fileBuffer - * The content of AutoGen file in buffer. - * @return "true" successful, "false" failed. - */ + saveFile function + + This function save the content in stringBuffer to file. + + @param fileName + The name of file. + @param fileBuffer + The content of AutoGen file in buffer. + @return boolean + "true" successful + "false" failed + **/ private boolean saveFile(String fileName, StringBuffer fileBuffer) { - try { - File autoGenH = new File(fileName); + + File autoGenH = new File(fileName); // // if the file exists, compare their content // - if (autoGenH.exists()) { - FileReader fIn = new FileReader(autoGenH); - char[] oldFileBuffer = new char[(int) autoGenH.length()]; - fIn.read(oldFileBuffer, 0, (int) autoGenH.length()); + if (autoGenH.exists()) { + char[] oldFileBuffer = new char[(int) autoGenH.length()]; + try { + FileReader fIn = new FileReader(autoGenH); + fIn.read(oldFileBuffer, 0, (int) autoGenH.length()); fIn.close(); + } catch (IOException e) { + EdkLog.log(EdkLog.EDK_INFO, this.moduleId.getName() + + "'s " + + fileName + + " is exist, but can't be open!!"); + return false; + } - // - // if we got the same file, don't re-generate it to prevent - // sources depending on it from re-building - // - if (fileBuffer.toString().compareTo(new String(oldFileBuffer)) == 0) { - return true; - } + // + // if we got the same file, don't re-generate it to prevent + // sources depending on it from re-building + // + if (fileBuffer.toString().compareTo(new String(oldFileBuffer)) == 0) { + return true; } - FileWriter fOut = new FileWriter(autoGenH); + } + + try { + FileWriter fOut = new FileWriter(autoGenH); fOut.write(fileBuffer.toString()); + fOut.flush(); fOut.close(); - } catch (Exception e) { - return false; - } + } catch (IOException e) { + EdkLog.log(EdkLog.EDK_INFO, this.moduleId.getName() + + "'s " + + fileName + + " can't be create!!"); + return false; + } return true; } /** - * genAutogen function - * - * This function call libGenAutoGen or moduleGenAutogen function, which - * dependence on generate library autogen or module autogen. - * - * @throws BuildException - * Failed to creat AutoGen.c & AutoGen.h. - */ + genAutogen function + + This function call libGenAutoGen or moduleGenAutogen function, which + dependence on generate library autogen or module autogen. + + @throws BuildException + Failed to creat AutoGen.c & AutoGen.h. + **/ public void genAutogen() throws BuildException { try { // @@ -212,13 +233,13 @@ public class AutoGen { } /** - * moduleGenAutogen function - * - * This function generates AutoGen.c & AutoGen.h for module. - * - * @throws BuildException - * Faile to create module AutoGen.c & AutoGen.h. - */ + moduleGenAutogen function + + This function generates AutoGen.c & AutoGen.h for module. + + @throws BuildException + Faile to create module AutoGen.c & AutoGen.h. + **/ void moduleGenAutogen() throws BuildException { try { @@ -233,13 +254,13 @@ public class AutoGen { } /** - * libGenAutogen function - * - * This function generates AutoGen.c & AutoGen.h for library. - * - * @throws BuildException - * Faile to create library AutoGen.c & AutoGen.h - */ + libGenAutogen function + + This function generates AutoGen.c & AutoGen.h for library. + + @throws BuildException + Faile to create library AutoGen.c & AutoGen.h + **/ void libGenAutogen() throws BuildException { try { libGenAutogenC(); @@ -252,13 +273,13 @@ public class AutoGen { } /** - * moduleGenAutogenH - * - * This function generates AutoGen.h for module. - * - * @throws BuildException - * Failed to generate AutoGen.h. - */ + moduleGenAutogenH + + This function generates AutoGen.h for module. + + @throws BuildException + Failed to generate AutoGen.h. + **/ void moduleGenAutogenH() throws AutoGenException { Set libClassIncludeH; @@ -271,14 +292,21 @@ public class AutoGen { // // Write Autogen.h header notation // - fileBuffer.append(CommonDefinition.autogenHNotation); + fileBuffer.append(CommonDefinition.AUTOGENHNOTATION); // // Add #ifndef ${BaseName}_AUTOGENH // #def ${BseeName}_AUTOGENH // - fileBuffer.append("#ifndef " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") +"\r\n"); - fileBuffer.append("#define " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") +"\r\n\r\n"); + fileBuffer.append(CommonDefinition.IFNDEF + + CommonDefinition.AUTOGENH + + this.moduleId.getGuid().replaceAll("-", "_") + + ToolDefinitions.LINE_SEPARATOR); + fileBuffer.append(CommonDefinition.DEFINE + + CommonDefinition.AUTOGENH + + this.moduleId.getGuid().replaceAll("-", "_") + + ToolDefinitions.LINE_SEPARATOR + + ToolDefinitions.LINE_SEPARATOR); // // Write the specification version and release version at the begine @@ -287,20 +315,20 @@ public class AutoGen { // be got from module surface area instead of hard code by it's // moduleType. // - moduleType = SurfaceAreaQuery.getModuleType(); + moduleType = saq.getModuleType(); // // Add "extern int __make_me_compile_correctly;" at begin of // AutoGen.h. // - fileBuffer.append(CommonDefinition.autoGenHbegin); + fileBuffer.append(CommonDefinition.AUTOGENHBEGIN); // // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION. // - String[] specList = SurfaceAreaQuery.getExternSpecificaiton(); + String[] specList = saq.getExternSpecificaiton(); for (int i = 0; i < specList.length; i++) { - fileBuffer.append(CommonDefinition.marcDefineStr + specList[i] + fileBuffer.append(CommonDefinition.DEFINE + specList[i] + "\r\n"); } // @@ -308,8 +336,7 @@ public class AutoGen { // // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery // .getDependencePkg(this.arch); - PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery - .getDependencePkg(this.arch); + PackageIdentification[] consumedPkgIdList = saq.getDependencePkg(this.arch); if (consumedPkgIdList != null) { headerFileList = depPkgToAutogenH(consumedPkgIdList, moduleType); item = headerFileList.iterator(); @@ -321,8 +348,7 @@ public class AutoGen { // // Write library class's related *.h file to autogen.h. // - String[] libClassList = SurfaceAreaQuery - .getLibraryClasses(CommonDefinition.AlwaysConsumed,this.arch); + String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED,this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -331,8 +357,7 @@ public class AutoGen { } } - libClassList = SurfaceAreaQuery - .getLibraryClasses(CommonDefinition.AlwaysProduced, this.arch); + libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -346,10 +371,10 @@ public class AutoGen { // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to // {DEST_DIR_DRBUG}/FlashMap.h // - if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) { - fileBuffer.append(CommonDefinition.include); + if (saq.isHaveTianoR8FlashMap()) { + fileBuffer.append(CommonDefinition.INCLUDE); fileBuffer.append(" <"); - fileBuffer.append(CommonDefinition.tianoR8FlashMapH + ">\r\n"); + fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n"); copyFlashMapHToDebugDir(); } @@ -374,25 +399,25 @@ public class AutoGen { } /** - * moduleGenAutogenC - * - * This function generates AutoGen.c for module. - * - * @throws BuildException - * Failed to generate AutoGen.c. - */ + moduleGenAutogenC + + This function generates AutoGen.c for module. + + @throws BuildException + Failed to generate AutoGen.c. + **/ void moduleGenAutogenC() throws AutoGenException { StringBuffer fileBuffer = new StringBuffer(8192); // // Write Autogen.c header notation // - fileBuffer.append(CommonDefinition.autogenCNotation); + fileBuffer.append(CommonDefinition.AUTOGENCNOTATION); // // Write #include at beginning of AutoGen.c // - fileBuffer.append(CommonDefinition.includeAutogenH); + fileBuffer.append(CommonDefinition.INCLUDEAUTOGENH); // // Get the native MSA file infomation. Since before call autogen, @@ -400,7 +425,7 @@ public class AutoGen { // process it should be set the DOC as the Native MSA info. // Map doc = GlobalData.getNativeMsa(this.moduleId); - SurfaceAreaQuery.push(doc); + saq.push(doc); // // Write // DriverBinding/ComponentName/DriverConfiguration/DriverDialog @@ -418,21 +443,23 @@ public class AutoGen { // // Write EntryPoint to autgoGen.c // - String[] entryPointList = SurfaceAreaQuery.getModuleEntryPointArray(); - EntryPointToAutoGen(CommonDefinition.remDupString(entryPointList), fileBuffer); + String[] entryPointList = saq.getModuleEntryPointArray(); + String[] unloadImageList = saq.getModuleUnloadImageArray(); + EntryPointToAutoGen(CommonDefinition.remDupString(entryPointList), + CommonDefinition.remDupString(unloadImageList), + fileBuffer); - pcdDriverType = SurfaceAreaQuery.getPcdDriverType(); + pcdDriverType = saq.getPcdDriverType(); // // Restore the DOC which include the FPD module info. // - SurfaceAreaQuery.pop(); + saq.pop(); // // Write Guid to autogen.c // - String guid = CommonDefinition.formatGuidName(SurfaceAreaQuery - .getModuleGuid()); + String guid = CommonDefinition.formatGuidName(saq.getModuleGuid()); fileBuffer .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {"); @@ -460,7 +487,7 @@ public class AutoGen { // // Get module dependent Package identification. // - PackageIdentification[] packages = SurfaceAreaQuery.getDependencePkg(this.arch); + PackageIdentification[] packages = saq.getDependencePkg(this.arch); for (int i = 0; i < packages.length; i++) { if (!this.mDepPkgList.contains(packages[i])) { this.mDepPkgList.add(packages[i]); @@ -501,13 +528,13 @@ public class AutoGen { } /** - * libGenAutogenH - * - * This function generates AutoGen.h for library. - * - * @throws BuildException - * Failed to generate AutoGen.c. - */ + libGenAutogenH + + This function generates AutoGen.h for library. + + @throws BuildException + Failed to generate AutoGen.c. + **/ void libGenAutogenH() throws AutoGenException { Set libClassIncludeH; @@ -519,14 +546,21 @@ public class AutoGen { // // Write Autogen.h header notation // - fileBuffer.append(CommonDefinition.autogenHNotation); + fileBuffer.append(CommonDefinition.AUTOGENHNOTATION); // // Add #ifndef ${BaseName}_AUTOGENH // #def ${BseeName}_AUTOGENH // - fileBuffer.append("#ifndef " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") + "\r\n"); - fileBuffer.append("#define " + "_AUTOGENH_" + this.moduleId.getGuid().replaceAll("-", "_") + "\r\n\r\n"); + fileBuffer.append(CommonDefinition.IFNDEF + + CommonDefinition.AUTOGENH + + this.moduleId.getGuid().replaceAll("-", "_") + + ToolDefinitions.LINE_SEPARATOR); + fileBuffer.append(CommonDefinition.DEFINE + + CommonDefinition.AUTOGENH + + this.moduleId.getGuid().replaceAll("-", "_") + + ToolDefinitions.LINE_SEPARATOR + + ToolDefinitions.LINE_SEPARATOR); // // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION @@ -534,10 +568,10 @@ public class AutoGen { // Note: the specification version and release version should // be get from module surface area instead of hard code. // - fileBuffer.append(CommonDefinition.autoGenHbegin); - String[] specList = SurfaceAreaQuery.getExternSpecificaiton(); + fileBuffer.append(CommonDefinition.AUTOGENHBEGIN); + String[] specList = saq.getExternSpecificaiton(); for (int i = 0; i < specList.length; i++) { - fileBuffer.append(CommonDefinition.marcDefineStr + specList[i] + fileBuffer.append(CommonDefinition.DEFINE + specList[i] + "\r\n"); } // fileBuffer.append(CommonDefinition.autoGenHLine1); @@ -546,8 +580,8 @@ public class AutoGen { // // Write consumed package's mdouleInfo related *.h file to autogen.h. // - moduleType = SurfaceAreaQuery.getModuleType(); - PackageIdentification[] cosumedPkglist = SurfaceAreaQuery + moduleType = saq.getModuleType(); + PackageIdentification[] cosumedPkglist = saq .getDependencePkg(this.arch); headerFileList = depPkgToAutogenH(cosumedPkglist, moduleType); item = headerFileList.iterator(); @@ -557,8 +591,8 @@ public class AutoGen { // // Write library class's related *.h file to autogen.h // - String[] libClassList = SurfaceAreaQuery - .getLibraryClasses(CommonDefinition.AlwaysConsumed, this.arch); + String[] libClassList = saq + .getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -567,8 +601,8 @@ public class AutoGen { } } - libClassList = SurfaceAreaQuery - .getLibraryClasses(CommonDefinition.AlwaysProduced, this.arch); + libClassList = saq + .getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch); if (libClassList != null) { libClassIncludeH = LibraryClassToAutogenH(libClassList); item = libClassIncludeH.iterator(); @@ -576,16 +610,16 @@ public class AutoGen { fileBuffer.append(item.next().toString()); } } - fileBuffer.append("\r\n"); + fileBuffer.append(ToolDefinitions.LINE_SEPARATOR); // // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to // {DEST_DIR_DRBUG}/FlashMap.h // - if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) { - fileBuffer.append(CommonDefinition.include); + if (saq.isHaveTianoR8FlashMap()) { + fileBuffer.append(CommonDefinition.INCLUDE); fileBuffer.append(" <"); - fileBuffer.append(CommonDefinition.tianoR8FlashMapH + ">\r\n"); + fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n"); copyFlashMapHToDebugDir(); } @@ -611,23 +645,23 @@ public class AutoGen { } /** - * libGenAutogenC - * - * This function generates AutoGen.h for library. - * - * @throws BuildException - * Failed to generate AutoGen.c. - */ + libGenAutogenC + + This function generates AutoGen.h for library. + + @throws BuildException + Failed to generate AutoGen.c. + **/ void libGenAutogenC() throws BuildException, PcdAutogenException { StringBuffer fileBuffer = new StringBuffer(10240); // // Write Autogen.c header notation // - fileBuffer.append(CommonDefinition.autogenCNotation); + fileBuffer.append(CommonDefinition.AUTOGENCNOTATION); - fileBuffer.append(CommonDefinition.autoGenCLine1); - fileBuffer.append("\r\n"); + fileBuffer.append(ToolDefinitions.LINE_SEPARATOR); + fileBuffer.append(ToolDefinitions.LINE_SEPARATOR); // // Call pcd autogen. @@ -635,7 +669,7 @@ public class AutoGen { this.myPcdAutogen = new PCDAutoGenAction(moduleId, arch, true, - SurfaceAreaQuery.getModulePcdEntryNameArray(), + saq.getModulePcdEntryNameArray(), pcdDriverType); try { this.myPcdAutogen.execute(); @@ -644,7 +678,7 @@ public class AutoGen { } if (this.myPcdAutogen != null) { - fileBuffer.append("\r\n"); + fileBuffer.append(ToolDefinitions.LINE_SEPARATOR); fileBuffer.append(this.myPcdAutogen.getCAutoGenString()); } @@ -654,20 +688,20 @@ public class AutoGen { } /** - * LibraryClassToAutogenH - * - * This function returns *.h files declared by library classes which are - * consumed or produced by current build module or library. - * - * @param libClassList - * List of library class which consumed or produce by current - * build module or library. - * @return includeStrList List of *.h file. - */ + LibraryClassToAutogenH + + This function returns *.h files declared by library classes which are + consumed or produced by current build module or library. + + @param libClassList + List of library class which consumed or produce by current + build module or library. + @return includeStrList List of *.h file. + **/ Set LibraryClassToAutogenH(String[] libClassList) throws AutoGenException { - Set includStrList = new LinkedHashSet(); - String includerName[]; + Set includeStrList = new LinkedHashSet(); + String includeName[]; String str = ""; // @@ -675,37 +709,37 @@ public class AutoGen { // library class name. // for (int i = 0; i < libClassList.length; i++) { - includerName = GlobalData.getLibraryClassHeaderFiles( - SurfaceAreaQuery.getDependencePkg(this.arch), + includeName = GlobalData.getLibraryClassHeaderFiles( + saq.getDependencePkg(this.arch), libClassList[i]); - if (includerName == null) { + if (includeName == null) { throw new AutoGenException("Can not find library class [" + libClassList[i] + "] declaration in any SPD package. "); } - for (int j = 0; j < includerName.length; j++) { - String includeNameStr = includerName[j]; + for (int j = 0; j < includeName.length; j++) { + String includeNameStr = includeName[j]; if (includeNameStr != null) { - str = CommonDefinition.include + " " + "<"; + str = CommonDefinition.INCLUDE + " " + "<"; str = str + includeNameStr + ">\r\n"; - includStrList.add(str); + includeStrList.add(str); includeNameStr = null; } } } - return includStrList; + return includeStrList; } /** - * IncludesToAutogenH - * - * This function add include file in AutoGen.h file. - * - * @param packageNameList - * List of module depended package. - * @param moduleType - * Module type. - * @return - */ + IncludesToAutogenH + + This function add include file in AutoGen.h file. + + @param packageNameList + List of module depended package. + @param moduleType + Module type. + @return + **/ List depPkgToAutogenH(PackageIdentification[] packageNameList, String moduleType) throws AutoGenException { @@ -724,7 +758,7 @@ public class AutoGen { + packageNameList[i] + "] declaration in any SPD package. "); } else if (!pkgHeader.equalsIgnoreCase("")) { - includeStr = CommonDefinition.include + " <" + pkgHeader + includeStr = CommonDefinition.INCLUDE + " <" + pkgHeader + ">\r\n"; includeStrList.add(includeStr); } @@ -734,21 +768,23 @@ public class AutoGen { } /** - * EntryPointToAutoGen - * - * This function convert & - * information in mas to AutoGen.c - * - * @param entryPointList - * List of entry point. - * @param fileBuffer - * String buffer fo AutoGen.c. - * @throws Exception - */ - void EntryPointToAutoGen(String[] entryPointList, StringBuffer fileBuffer) + EntryPointToAutoGen + + This function convert & + information in mas to AutoGen.c + + @param entryPointList + List of entry point. + @param fileBuffer + String buffer fo AutoGen.c. + @throws Exception + **/ + void EntryPointToAutoGen(String[] entryPointList, String[] unloadImageList, StringBuffer fileBuffer) throws BuildException { - String typeStr = SurfaceAreaQuery.getModuleType(); + String typeStr = saq.getModuleType(); + int unloadImageCount = 0; + int entryPointCount = 0; // // The parameters and return value of entryPoint is difference @@ -815,7 +851,7 @@ public class AutoGen { break; case CommonDefinition.ModuleTypePeim: - int entryPointCount = 0; + entryPointCount = 0; fileBuffer .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n"); if (entryPointList == null || entryPointList.length == 0) { @@ -960,26 +996,27 @@ public class AutoGen { // // Add "ModuleUnloadImage" for DxeSmmDriver module type; // - entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray(); - entryPointList = CommonDefinition.remDupString(entryPointList); - entryPointCount = 0; + //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray(); + //entryPointList = CommonDefinition.remDupString(entryPointList); + //entryPointCount = 0; - if (entryPointList != null) { - for (int i = 0; i < entryPointList.length; i++) { + unloadImageCount = 0; + if (unloadImageList != null) { + for (int i = 0; i < unloadImageList.length; i++) { fileBuffer.append("EFI_STATUS\r\n"); fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(entryPointList[i]); + fileBuffer.append(unloadImageList[i]); fileBuffer.append(" (\r\n"); fileBuffer .append(" IN EFI_HANDLE ImageHandle\r\n"); fileBuffer.append(" );\r\n"); - entryPointCount++; + unloadImageCount++; } } fileBuffer .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = "); - fileBuffer.append(Integer.toString(entryPointCount)); + fileBuffer.append(Integer.toString(unloadImageCount)); fileBuffer.append(";\r\n\r\n"); fileBuffer.append("EFI_STATUS\r\n"); @@ -989,28 +1026,28 @@ public class AutoGen { fileBuffer.append(" )\r\n"); fileBuffer.append("{\r\n"); - if (entryPointCount == 0) { + if (unloadImageCount == 0) { fileBuffer.append(" return EFI_SUCCESS;\r\n"); - } else if (entryPointCount == 1) { + } else if (unloadImageCount == 1) { fileBuffer.append(" return "); - fileBuffer.append(entryPointList[0]); + fileBuffer.append(unloadImageList[0]); fileBuffer.append("(ImageHandle);\r\n"); } else { fileBuffer.append(" EFI_STATUS Status;\r\n\r\n"); fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n"); - for (int i = 0; i < entryPointList.length; i++) { + for (int i = 0; i < unloadImageList.length; i++) { if (i == 0) { fileBuffer.append(" Status = "); - fileBuffer.append(entryPointList[i]); + fileBuffer.append(unloadImageList[i]); fileBuffer.append("(ImageHandle);\r\n"); } else { fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n"); fileBuffer.append(" "); - fileBuffer.append(entryPointList[i]); + fileBuffer.append(unloadImageList[i]); fileBuffer.append("(ImageHandle);\r\n"); fileBuffer.append(" } else {\r\n"); fileBuffer.append(" Status = "); - fileBuffer.append(entryPointList[i]); + fileBuffer.append(unloadImageList[i]); fileBuffer.append("(ImageHandle);\r\n"); fileBuffer.append(" }\r\n"); } @@ -1126,28 +1163,29 @@ public class AutoGen { // // Add ModuleUnloadImage for DxeDriver and UefiDriver module type. // - entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray(); + //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray(); // // Remover duplicate unload entry point. // - entryPointList = CommonDefinition.remDupString(entryPointList); - entryPointCount = 0; - if (entryPointList != null) { - for (int i = 0; i < entryPointList.length; i++) { + //entryPointList = CommonDefinition.remDupString(entryPointList); + //entryPointCount = 0; + unloadImageCount = 0; + if (unloadImageList != null) { + for (int i = 0; i < unloadImageList.length; i++) { fileBuffer.append("EFI_STATUS\r\n"); fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(entryPointList[i]); + fileBuffer.append(unloadImageList[i]); fileBuffer.append(" (\r\n"); fileBuffer .append(" IN EFI_HANDLE ImageHandle\r\n"); fileBuffer.append(" );\r\n"); - entryPointCount++; + unloadImageCount++; } } fileBuffer .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = "); - fileBuffer.append(Integer.toString(entryPointCount)); + fileBuffer.append(Integer.toString(unloadImageCount)); fileBuffer.append(";\r\n\r\n"); fileBuffer.append("EFI_STATUS\n"); @@ -1157,28 +1195,28 @@ public class AutoGen { fileBuffer.append(" )\r\n"); fileBuffer.append("{\r\n"); - if (entryPointCount == 0) { + if (unloadImageCount == 0) { fileBuffer.append(" return EFI_SUCCESS;\r\n"); - } else if (entryPointCount == 1) { + } else if (unloadImageCount == 1) { fileBuffer.append(" return "); - fileBuffer.append(entryPointList[0]); + fileBuffer.append(unloadImageList[0]); fileBuffer.append("(ImageHandle);\r\n"); } else { fileBuffer.append(" EFI_STATUS Status;\r\n\r\n"); fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n"); - for (int i = 0; i < entryPointList.length; i++) { + for (int i = 0; i < unloadImageList.length; i++) { if (i == 0) { fileBuffer.append(" Status = "); - fileBuffer.append(entryPointList[i]); + fileBuffer.append(unloadImageList[i]); fileBuffer.append("(ImageHandle);\r\n"); } else { fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n"); fileBuffer.append(" "); - fileBuffer.append(entryPointList[i]); + fileBuffer.append(unloadImageList[i]); fileBuffer.append("(ImageHandle);\r\n"); fileBuffer.append(" } else {\r\n"); fileBuffer.append(" Status = "); - fileBuffer.append(entryPointList[i]); + fileBuffer.append(unloadImageList[i]); fileBuffer.append("(ImageHandle);\r\n"); fileBuffer.append(" }\r\n"); } @@ -1191,16 +1229,16 @@ public class AutoGen { } /** - * PpiGuidToAutogenc - * - * This function gets GUIDs from SPD file accrodeing to information - * and write those GUIDs to AutoGen.c. - * - * @param fileBuffer - * String Buffer for Autogen.c file. - * @throws BuildException - * Guid must set value! - */ + PpiGuidToAutogenc + + This function gets GUIDs from SPD file accrodeing to information + and write those GUIDs to AutoGen.c. + + @param fileBuffer + String Buffer for Autogen.c file. + @throws BuildException + Guid must set value! + **/ void PpiGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException { String[] cNameGuid = null; @@ -1209,12 +1247,12 @@ public class AutoGen { // then add those PPI ,and PPI Notify name to list. // - String[] ppiList = SurfaceAreaQuery.getPpiArray(this.arch); + String[] ppiList = saq.getPpiArray(this.arch); for (int i = 0; i < ppiList.length; i++) { this.mPpiList.add(ppiList[i]); } - String[] ppiNotifyList = SurfaceAreaQuery.getPpiNotifyArray(this.arch); + String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch); for (int i = 0; i < ppiNotifyList.length; i++) { this.mPpiList.add(ppiNotifyList[i]); } @@ -1245,20 +1283,20 @@ public class AutoGen { } /** - * ProtocolGuidToAutogenc - * - * This function gets GUIDs from SPD file accrodeing to - * information and write those GUIDs to AutoGen.c. - * - * @param fileBuffer - * String Buffer for Autogen.c file. - * @throws BuildException - * Protocol name must set. - */ + ProtocolGuidToAutogenc + + This function gets GUIDs from SPD file accrodeing to + information and write those GUIDs to AutoGen.c. + + @param fileBuffer + String Buffer for Autogen.c file. + @throws BuildException + Protocol name must set. + **/ void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws BuildException { String[] cNameGuid = null; - String[] protocolList = SurfaceAreaQuery.getProtocolArray(this.arch); + String[] protocolList = saq.getProtocolArray(this.arch); // // Add result to Autogen global list. @@ -1267,7 +1305,7 @@ public class AutoGen { this.mProtocolList.add(protocolList[i]); } - String[] protocolNotifyList = SurfaceAreaQuery + String[] protocolNotifyList = saq .getProtocolNotifyArray(this.arch); for (int i = 0; i < protocolNotifyList.length; i++) { @@ -1302,20 +1340,20 @@ public class AutoGen { } /** - * GuidGuidToAutogenc - * - * This function gets GUIDs from SPD file accrodeing to information - * and write those GUIDs to AutoGen.c. - * - * @param fileBuffer - * String Buffer for Autogen.c file. - * - */ + GuidGuidToAutogenc + + This function gets GUIDs from SPD file accrodeing to information + and write those GUIDs to AutoGen.c. + + @param fileBuffer + String Buffer for Autogen.c file. + + **/ void GuidGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException { String[] cNameGuid = null; String guidKeyWord = null; - String[] guidList = SurfaceAreaQuery.getGuidEntryArray(this.arch); + String[] guidList = saq.getGuidEntryArray(this.arch); for (int i = 0; i < guidList.length; i++) { this.mGuidList.add(guidList[i]); @@ -1346,16 +1384,16 @@ public class AutoGen { } /** - * LibInstanceToAutogenC - * - * This function adds dependent library instance to autogen.c,which - * includeing library's constructor, destructor, and library dependent ppi, - * protocol, guid, pcd information. - * - * @param fileBuffer - * String buffer for AutoGen.c - * @throws BuildException - */ + LibInstanceToAutogenC + + This function adds dependent library instance to autogen.c,which + includeing library's constructor, destructor, and library dependent ppi, + protocol, guid, pcd information. + + @param fileBuffer + String buffer for AutoGen.c + @throws BuildException + **/ void LibInstanceToAutogenC(StringBuffer fileBuffer) throws BuildException { try { String moduleType = this.moduleId.getModuleType(); @@ -1374,19 +1412,19 @@ public class AutoGen { } /** - * LibConstructorToAutogenc - * - * This function writes library constructor list to AutoGen.c. 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 - */ + LibConstructorToAutogenc + + This function writes library constructor list to AutoGen.c. 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 LibConstructorToAutogenC(List libInstanceList, String moduleType, StringBuffer fileBuffer) throws Exception { boolean isFirst = true; @@ -1515,19 +1553,19 @@ public class AutoGen { } /** - * LibDestructorToAutogenc - * - * This function writes library destructor list to AutoGen.c. 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 - */ + LibDestructorToAutogenc + + This function writes library destructor list to AutoGen.c. 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 LibDestructorToAutogenC(List libInstanceList, String moduleType, StringBuffer fileBuffer) throws Exception { boolean isFirst = true; @@ -1615,14 +1653,14 @@ public class AutoGen { } /** - * ExternsDriverBindingToAutoGenC - * - * This function is to write DRIVER_BINDING, COMPONENT_NAME, - * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c. - * - * @param fileBuffer - * String buffer for AutoGen.c - */ + ExternsDriverBindingToAutoGenC + + This function is to write DRIVER_BINDING, COMPONENT_NAME, + DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c. + + @param fileBuffer + String buffer for AutoGen.c + **/ void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer) throws BuildException { @@ -1632,7 +1670,7 @@ public class AutoGen { // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC // - String[] drvBindList = SurfaceAreaQuery.getDriverBindingArray(); + String[] drvBindList = saq.getDriverBindingArray(); // // If component name protocol,component configuration protocol, @@ -1643,9 +1681,9 @@ public class AutoGen { return; } - String[] compNamList = SurfaceAreaQuery.getComponentNameArray(); - String[] compConfList = SurfaceAreaQuery.getDriverConfigArray(); - String[] compDiagList = SurfaceAreaQuery.getDriverDiagArray(); + String[] compNamList = saq.getComponentNameArray(); + String[] compConfList = saq.getDriverConfigArray(); + String[] compDiagList = saq.getDriverDiagArray(); int BitMask = 0; @@ -1769,15 +1807,15 @@ public class AutoGen { } /** - * ExternCallBackToAutoGenC - * - * This function adds and - * infomation to AutoGen.c - * - * @param fileBuffer - * String buffer for AutoGen.c - * @throws BuildException - */ + ExternCallBackToAutoGenC + + This function adds and + infomation to AutoGen.c + + @param fileBuffer + String buffer for AutoGen.c + @throws BuildException + **/ void ExternCallBackToAutoGenC(StringBuffer fileBuffer) throws BuildException { // @@ -1785,8 +1823,8 @@ public class AutoGen { // and add to setVirtualAddList // exitBootServiceList. // - String[] setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray(); - String[] exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray(); + String[] setVirtuals = saq.getSetVirtualAddressMapCallBackArray(); + String[] exitBoots = saq.getExitBootServicesCallBackArray(); if (setVirtuals != null) { for (int j = 0; j < setVirtuals.length; j++) { this.setVirtalAddList.add(setVirtuals[j]); @@ -1802,183 +1840,39 @@ public class AutoGen { // and // String moduleType = this.moduleId.getModuleType(); - boolean UefiOrDxeModule = false; - int Count = 0; - int i; switch (CommonDefinition.getModuleType(moduleType)) { case CommonDefinition.ModuleTypeDxeDriver: case CommonDefinition.ModuleTypeDxeRuntimeDriver: case CommonDefinition.ModuleTypeDxeSalDriver: case CommonDefinition.ModuleTypeUefiDriver: - case CommonDefinition.ModuleTypeUefiApplication: - // - // Entry point lib for these module types needs to know the count - // of entryPoint. - // - UefiOrDxeModule = true; - 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 - // set count to the number of valid entries - // - Count = 0; - if (this.setVirtalAddList != null) { - for (i = 0; i < this.setVirtalAddList.size(); i++) { - if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) { - break; - } - } - Count = i; - } - - fileBuffer.append(Integer.toString(Count)); - fileBuffer.append(";\r\n\r\n"); + case CommonDefinition.ModuleTypeUefiApplication: + // + // If moduleType is one of above, call setVirtualAddressToAutogenC, + // and setExitBootServiceToAutogenC. + // + setVirtualAddressToAutogenC(fileBuffer); + setExitBootServiceToAutogenC(fileBuffer); break; default: break; } - - if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) { - if (UefiOrDxeModule) { - // - // No data so make a NULL list - // - 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. - // - for (i = 0; i < this.setVirtalAddList.size(); i++) { - if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) { - break; - } - fileBuffer.append("VOID\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(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"); - } - - // - // Write SetVirtualAddressMap entry point array. - // - 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("\r\n "); - } else { - fileBuffer.append(",\r\n "); - } - - fileBuffer.append(this.setVirtalAddList.get(i)); - } - // - // If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER - // UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of - // _gDriverSetVirtualAddressMapEvent list. - // - if (!UefiOrDxeModule) { - fileBuffer.append(",\r\n NULL"); - } - fileBuffer.append("\r\n};\r\n\r\n"); - } - - if (UefiOrDxeModule) { - // - // Entry point lib for these module types needs to know the count. - // - 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 - // set count to the number of valid entries. - // - Count = 0; - if (this.exitBootServiceList != null) { - for (i = 0; i < this.exitBootServiceList.size(); i++) { - if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) { - break; - } - } - Count = i; - } - fileBuffer.append(Integer.toString(Count)); - fileBuffer.append(";\r\n\r\n"); - } - - if (this.exitBootServiceList == null || this.exitBootServiceList.size() == 0) { - if (UefiOrDxeModule) { - // - // No data so make a NULL list. - // - 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. - // - for (i = 0; i < this.exitBootServiceList.size(); i++) { - if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) { - break; - } - - fileBuffer.append("VOID\r\n"); - fileBuffer.append("EFIAPI\r\n"); - fileBuffer.append(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"); - } - - // - // Write DriverExitBootServices entry point array. - // - 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("\r\n "); - } else { - fileBuffer.append(",\r\n "); - } - fileBuffer.append(this.exitBootServiceList.get(i)); - } - if (!UefiOrDxeModule) { - fileBuffer.append(",\r\n NULL"); - } - fileBuffer.append("\r\n};\r\n\r\n"); - } - } + /** + copyFlashMapHToDebugDir + + This function is to copy the falshmap.h to debug directory and change + its name to TianoR8FlashMap.h + + @param + @return + **/ private void copyFlashMapHToDebugDir() throws AutoGenException{ - File inFile = new File(fvDir + File.separatorChar + CommonDefinition.flashMapH); + File inFile = new File(fvDir + File.separatorChar + CommonDefinition.FLASHMAPH); int size = (int)inFile.length(); byte[] buffer = new byte[size]; - File outFile = new File (this.outputPath + File.separatorChar + CommonDefinition.tianoR8FlashMapH); + File outFile = new File (this.outputPath + File.separatorChar + CommonDefinition.TIANOR8PLASHMAPH); // // If TianoR8FlashMap.h existed and the flashMap.h don't change, // do nothing. @@ -2002,11 +1896,13 @@ public class AutoGen { } /** - *This function first order the library instances, then collect - *library instance 's PPI, Protocol, GUID, - *SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and - *Destructor, Constructor. - * + This function first order the library instances, then collect + library instance 's PPI, Protocol, GUID, + SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and + Destructor, Constructor. + + @param + @return **/ private void collectLibInstanceInfo(){ int index; @@ -2016,8 +1912,7 @@ public class AutoGen { String[] setVirtuals = null; String[] exitBoots = null; - ModuleIdentification[] libraryIdList = SurfaceAreaQuery - .getLibraryInstance(this.arch); + ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch); try { if (libraryIdList != null) { // @@ -2044,21 +1939,17 @@ public class AutoGen { // Map libDoc = GlobalData.getDoc(libInstanceId, this.arch); - SurfaceAreaQuery.push(libDoc); + saq.push(libDoc); // // Get , , list of this library // instance. // - String[] ppiList = SurfaceAreaQuery.getPpiArray(this.arch); - String[] ppiNotifyList = SurfaceAreaQuery - .getPpiNotifyArray(this.arch); - String[] protocolList = SurfaceAreaQuery - .getProtocolArray(this.arch); - String[] protocolNotifyList = SurfaceAreaQuery - .getProtocolNotifyArray(this.arch); - String[] guidList = SurfaceAreaQuery - .getGuidEntryArray(this.arch); - PackageIdentification[] pkgList = SurfaceAreaQuery.getDependencePkg(this.arch); + 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, @@ -2094,17 +1985,15 @@ public class AutoGen { // If not yet parse this library instance's constructor // element,parse it. // - libConstructName = SurfaceAreaQuery - .getLibConstructorName(); - libDestructName = SurfaceAreaQuery - .getLibDestructorName(); + libConstructName = saq.getLibConstructorName(); + libDestructName = saq.getLibDestructorName(); // // Collect SetVirtualAddressMapCallBack and // ExitBootServiceCallBack. // - setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray(); - exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray(); + setVirtuals = saq.getSetVirtualAddressMapCallBackArray(); + exitBoots = saq.getExitBootServicesCallBackArray(); if (setVirtuals != null) { for (int j = 0; j < setVirtuals.length; j++) { this.setVirtalAddList.add(setVirtuals[j]); @@ -2115,7 +2004,7 @@ public class AutoGen { this.exitBootServiceList.add(exitBoots[k]); } } - SurfaceAreaQuery.pop(); + saq.pop(); // // Add dependent library instance constructor function. // @@ -2138,4 +2027,155 @@ public class AutoGen { System.out.println("Collect library instance failed!"); } } + private void setVirtualAddressToAutogenC(StringBuffer fileBuffer){ + // + // Entry point lib for these module types needs to know the count + // of entryPoint. + // + 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 + // set count to the number of valid entries + // + int Count = 0; + int i = 0; + if (this.setVirtalAddList != null) { + for (i = 0; i < this.setVirtalAddList.size(); i++) { + if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) { + break; + } + } + Count = i; + } + + fileBuffer.append(Integer.toString(Count)); + fileBuffer.append(";\r\n\r\n"); + if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) { + // + // No data so make a NULL list + // + 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. + // + for (i = 0; i < this.setVirtalAddList.size(); i++) { + if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) { + break; + } + fileBuffer.append("VOID\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append(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"); + } + + // + // Write SetVirtualAddressMap entry point array. + // + 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("\r\n "); + } else { + fileBuffer.append(",\r\n "); + } + + fileBuffer.append(this.setVirtalAddList.get(i)); + } + // + // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list. + // + fileBuffer.append(",\r\n NULL"); + fileBuffer.append("\r\n};\r\n\r\n"); + } + } + + + private void setExitBootServiceToAutogenC(StringBuffer fileBuffer){ + // + // Entry point lib for these module types needs to know the count. + // + 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 + // set count to the number of valid entries. + // + int Count = 0; + int i = 0; + if (this.exitBootServiceList != null) { + for (i = 0; i < this.exitBootServiceList.size(); i++) { + if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) { + break; + } + } + Count = i; + } + fileBuffer.append(Integer.toString(Count)); + fileBuffer.append(";\r\n\r\n"); + + if (this.exitBootServiceList == null || this.exitBootServiceList.size() == 0) { + // + // No data so make a NULL list. + // + 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. + // + for (i = 0; i < this.exitBootServiceList.size(); i++) { + if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) { + break; + } + + fileBuffer.append("VOID\r\n"); + fileBuffer.append("EFIAPI\r\n"); + fileBuffer.append(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"); + } + + // + // Write DriverExitBootServices entry point array. + // + 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("\r\n "); + } else { + fileBuffer.append(",\r\n "); + } + fileBuffer.append(this.exitBootServiceList.get(i)); + } + + fileBuffer.append(",\r\n NULL"); + fileBuffer.append("\r\n};\r\n\r\n"); + } + + } + }