]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Remove static from SurfaceAreaQuery.java for preparing parallel build.(1)
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / autogen / AutoGen.java
index 80cdecf99277859a640427e7829fc2501d5043ba..08b44f9eb47a871d398ef64e32972f805e06cc2a 100644 (file)
@@ -116,6 +116,7 @@ public class AutoGen {
     private List<String> setVirtalAddList = new ArrayList<String>();\r
     private List<String> exitBootServiceList = new ArrayList<String>();\r
 \r
+    private SurfaceAreaQuery saq = null;\r
 \r
     /**\r
       Construct function\r
@@ -131,12 +132,12 @@ public class AutoGen {
       @param arch\r
                  Target architecture.\r
     **/\r
-    public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch) {\r
+    public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch, SurfaceAreaQuery saq) {\r
         this.outputPath = outputPath;\r
         this.moduleId = moduleId;\r
         this.arch = arch;\r
         this.fvDir = fvDir;\r
-\r
+        this.saq = saq;\r
     }\r
 \r
     /**\r
@@ -314,7 +315,7 @@ public class AutoGen {
         // be got from module surface area instead of hard code by it's\r
         // moduleType.\r
         //\r
-        moduleType = SurfaceAreaQuery.getModuleType();\r
+        moduleType = saq.getModuleType();\r
 \r
         //\r
         // Add "extern int __make_me_compile_correctly;" at begin of\r
@@ -325,7 +326,7 @@ public class AutoGen {
         //\r
         // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.\r
         //\r
-        String[] specList = SurfaceAreaQuery.getExternSpecificaiton();\r
+        String[] specList = saq.getExternSpecificaiton();\r
         for (int i = 0; i < specList.length; i++) {\r
             fileBuffer.append(CommonDefinition.DEFINE + specList[i]\r
                               + "\r\n");\r
@@ -335,8 +336,7 @@ public class AutoGen {
         //\r
         // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery\r
         // .getDependencePkg(this.arch);\r
-        PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery\r
-                                                    .getDependencePkg(this.arch);\r
+        PackageIdentification[] consumedPkgIdList = saq.getDependencePkg(this.arch);\r
         if (consumedPkgIdList != null) {\r
             headerFileList = depPkgToAutogenH(consumedPkgIdList, moduleType);\r
             item = headerFileList.iterator();\r
@@ -348,8 +348,7 @@ public class AutoGen {
         //\r
         // Write library class's related *.h file to autogen.h.\r
         //\r
-        String[] libClassList = SurfaceAreaQuery\r
-                                .getLibraryClasses(CommonDefinition.ALWAYSCONSUMED,this.arch);\r
+        String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED,this.arch);\r
         if (libClassList != null) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
             item = libClassIncludeH.iterator();\r
@@ -358,8 +357,7 @@ public class AutoGen {
             }\r
         }\r
 \r
-        libClassList = SurfaceAreaQuery\r
-                       .getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
+        libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
         if (libClassList != null) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
             item = libClassIncludeH.iterator();\r
@@ -373,7 +371,7 @@ public class AutoGen {
         //  If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to\r
         // {DEST_DIR_DRBUG}/FlashMap.h\r
         //\r
-        if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) {\r
+        if (saq.isHaveTianoR8FlashMap()) {\r
             fileBuffer.append(CommonDefinition.INCLUDE);\r
             fileBuffer.append("  <");\r
             fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n");\r
@@ -427,7 +425,7 @@ public class AutoGen {
         // process <Externs> it should be set the DOC as the Native MSA info.\r
         //\r
         Map<String, XmlObject> doc = GlobalData.getNativeMsa(this.moduleId);\r
-        SurfaceAreaQuery.push(doc);\r
+        saq.push(doc);\r
         //\r
         // Write <Extern>\r
         // DriverBinding/ComponentName/DriverConfiguration/DriverDialog\r
@@ -445,24 +443,23 @@ public class AutoGen {
         //\r
         // Write EntryPoint to autgoGen.c\r
         //\r
-        String[] entryPointList = SurfaceAreaQuery.getModuleEntryPointArray();\r
-               String[] unloadImageList = SurfaceAreaQuery.getModuleUnloadImageArray();\r
+        String[] entryPointList = saq.getModuleEntryPointArray();\r
+               String[] unloadImageList = saq.getModuleUnloadImageArray();\r
         EntryPointToAutoGen(CommonDefinition.remDupString(entryPointList), \r
                                        CommonDefinition.remDupString(unloadImageList),\r
                                        fileBuffer);\r
 \r
-        pcdDriverType = SurfaceAreaQuery.getPcdDriverType();\r
+        pcdDriverType = saq.getPcdDriverType();\r
 \r
         //\r
         // Restore the DOC which include the FPD module info.\r
         //\r
-        SurfaceAreaQuery.pop();\r
+        saq.pop();\r
 \r
         //\r
         // Write Guid to autogen.c\r
         //\r
-        String guid = CommonDefinition.formatGuidName(SurfaceAreaQuery\r
-                                                      .getModuleGuid());\r
+        String guid = CommonDefinition.formatGuidName(saq.getModuleGuid());\r
 \r
         fileBuffer\r
         .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");\r
@@ -490,7 +487,7 @@ public class AutoGen {
         //\r
         // Get module dependent Package identification.\r
         //\r
-        PackageIdentification[] packages = SurfaceAreaQuery.getDependencePkg(this.arch);\r
+        PackageIdentification[] packages = saq.getDependencePkg(this.arch);\r
         for (int i = 0; i < packages.length; i++) {\r
             if (!this.mDepPkgList.contains(packages[i])) {\r
                 this.mDepPkgList.add(packages[i]);\r
@@ -572,7 +569,7 @@ public class AutoGen {
         // be get from module surface area instead of hard code.\r
         //\r
         fileBuffer.append(CommonDefinition.AUTOGENHBEGIN);\r
-        String[] specList = SurfaceAreaQuery.getExternSpecificaiton();\r
+        String[] specList = saq.getExternSpecificaiton();\r
         for (int i = 0; i < specList.length; i++) {\r
             fileBuffer.append(CommonDefinition.DEFINE + specList[i]\r
                               + "\r\n");\r
@@ -583,8 +580,8 @@ public class AutoGen {
         //\r
         // Write consumed package's mdouleInfo related *.h file to autogen.h.\r
         //\r
-        moduleType = SurfaceAreaQuery.getModuleType();\r
-        PackageIdentification[] cosumedPkglist = SurfaceAreaQuery\r
+        moduleType = saq.getModuleType();\r
+        PackageIdentification[] cosumedPkglist = saq\r
                                                  .getDependencePkg(this.arch);\r
         headerFileList = depPkgToAutogenH(cosumedPkglist, moduleType);\r
         item = headerFileList.iterator();\r
@@ -594,7 +591,7 @@ public class AutoGen {
         //\r
         // Write library class's related *.h file to autogen.h\r
         //\r
-        String[] libClassList = SurfaceAreaQuery\r
+        String[] libClassList = saq\r
                                 .getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch);\r
         if (libClassList != null) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
@@ -604,7 +601,7 @@ public class AutoGen {
             }\r
         }\r
 \r
-        libClassList = SurfaceAreaQuery\r
+        libClassList = saq\r
                        .getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
         if (libClassList != null) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
@@ -619,7 +616,7 @@ public class AutoGen {
         //  If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to\r
         // {DEST_DIR_DRBUG}/FlashMap.h\r
         //\r
-        if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) {\r
+        if (saq.isHaveTianoR8FlashMap()) {\r
             fileBuffer.append(CommonDefinition.INCLUDE);\r
             fileBuffer.append("  <");\r
             fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n");\r
@@ -672,7 +669,7 @@ public class AutoGen {
         this.myPcdAutogen = new PCDAutoGenAction(moduleId,\r
                                                  arch,\r
                                                  true,\r
-                                                 SurfaceAreaQuery.getModulePcdEntryNameArray(),\r
+                                                 saq.getModulePcdEntryNameArray(),\r
                                                  pcdDriverType);\r
         try {\r
             this.myPcdAutogen.execute();\r
@@ -713,7 +710,7 @@ public class AutoGen {
         //\r
         for (int i = 0; i < libClassList.length; i++) {\r
             includeName = GlobalData.getLibraryClassHeaderFiles(\r
-                                                                SurfaceAreaQuery.getDependencePkg(this.arch),\r
+                            saq.getDependencePkg(this.arch),\r
                                                                 libClassList[i]);\r
             if (includeName == null) {\r
                 throw new AutoGenException("Can not find library class ["\r
@@ -785,7 +782,7 @@ public class AutoGen {
     void EntryPointToAutoGen(String[] entryPointList, String[] unloadImageList, StringBuffer fileBuffer)\r
     throws BuildException {\r
 \r
-        String typeStr = SurfaceAreaQuery.getModuleType();\r
+        String typeStr = saq.getModuleType();\r
                int unloadImageCount = 0;\r
         int entryPointCount  = 0;\r
 \r
@@ -1250,12 +1247,12 @@ public class AutoGen {
         // then add those PPI ,and PPI Notify name to list.\r
         //\r
 \r
-        String[] ppiList = SurfaceAreaQuery.getPpiArray(this.arch);\r
+        String[] ppiList = saq.getPpiArray(this.arch);\r
         for (int i = 0; i < ppiList.length; i++) {\r
             this.mPpiList.add(ppiList[i]);\r
         }\r
 \r
-        String[] ppiNotifyList = SurfaceAreaQuery.getPpiNotifyArray(this.arch);\r
+        String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);\r
         for (int i = 0; i < ppiNotifyList.length; i++) {\r
             this.mPpiList.add(ppiNotifyList[i]);\r
         }\r
@@ -1299,7 +1296,7 @@ public class AutoGen {
     void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws BuildException {\r
         String[] cNameGuid = null;\r
 \r
-        String[] protocolList = SurfaceAreaQuery.getProtocolArray(this.arch);\r
+        String[] protocolList = saq.getProtocolArray(this.arch);\r
 \r
         //\r
         // Add result to Autogen global list.\r
@@ -1308,7 +1305,7 @@ public class AutoGen {
             this.mProtocolList.add(protocolList[i]);\r
         }\r
 \r
-        String[] protocolNotifyList = SurfaceAreaQuery\r
+        String[] protocolNotifyList = saq\r
                                       .getProtocolNotifyArray(this.arch);\r
 \r
         for (int i = 0; i < protocolNotifyList.length; i++) {\r
@@ -1356,7 +1353,7 @@ public class AutoGen {
         String[] cNameGuid = null;\r
         String guidKeyWord = null;\r
 \r
-        String[] guidList = SurfaceAreaQuery.getGuidEntryArray(this.arch);\r
+        String[] guidList = saq.getGuidEntryArray(this.arch);\r
 \r
         for (int i = 0; i < guidList.length; i++) {\r
             this.mGuidList.add(guidList[i]);\r
@@ -1673,7 +1670,7 @@ public class AutoGen {
         // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC\r
         //\r
 \r
-        String[] drvBindList = SurfaceAreaQuery.getDriverBindingArray();\r
+        String[] drvBindList = saq.getDriverBindingArray();\r
 \r
         //\r
         // If component name protocol,component configuration protocol,\r
@@ -1684,9 +1681,9 @@ public class AutoGen {
             return;\r
         }\r
 \r
-        String[] compNamList = SurfaceAreaQuery.getComponentNameArray();\r
-        String[] compConfList = SurfaceAreaQuery.getDriverConfigArray();\r
-        String[] compDiagList = SurfaceAreaQuery.getDriverDiagArray();\r
+        String[] compNamList = saq.getComponentNameArray();\r
+        String[] compConfList = saq.getDriverConfigArray();\r
+        String[] compDiagList = saq.getDriverDiagArray();\r
 \r
         int BitMask = 0;\r
 \r
@@ -1826,8 +1823,8 @@ public class AutoGen {
         // <ExitBootServiceCallBack> and add to setVirtualAddList\r
         //  exitBootServiceList.\r
         //\r
-        String[] setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray();\r
-        String[] exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray();\r
+        String[] setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
+        String[] exitBoots = saq.getExitBootServicesCallBackArray();\r
         if (setVirtuals != null) {\r
             for (int j = 0; j < setVirtuals.length; j++) {\r
                 this.setVirtalAddList.add(setVirtuals[j]);\r
@@ -1843,175 +1840,22 @@ public class AutoGen {
         //  and <ExitBootServicesCallBack>\r
         //\r
         String moduleType = this.moduleId.getModuleType();\r
-        boolean UefiOrDxeModule = false;\r
-        int Count = 0;\r
-        int i;\r
         switch (CommonDefinition.getModuleType(moduleType)) {\r
         case CommonDefinition.ModuleTypeDxeDriver:\r
         case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
         case CommonDefinition.ModuleTypeDxeSalDriver:\r
         case CommonDefinition.ModuleTypeUefiDriver:\r
-        case CommonDefinition.ModuleTypeUefiApplication:\r
-            //\r
-            // Entry point lib for these module types needs to know the count\r
-            // of entryPoint.\r
-            //\r
-            UefiOrDxeModule = true;\r
-            fileBuffer\r
-            .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED  const UINTN _gDriverSetVirtualAddressMapEventCount = ");\r
-\r
-            //\r
-            // If the list is not valid or has no entries set count to zero else\r
-            // set count to the number of valid entries\r
-            //\r
-            Count = 0;\r
-            if (this.setVirtalAddList != null) {\r
-                for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
-                    if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
-                        break;\r
-                    }\r
-                }\r
-                Count = i;\r
-            }\r
-\r
-            fileBuffer.append(Integer.toString(Count));\r
-            fileBuffer.append(";\r\n\r\n");\r
+               case CommonDefinition.ModuleTypeUefiApplication:\r
+                       //\r
+                       //  If moduleType is one of above, call setVirtualAddressToAutogenC,\r
+                       //  and setExitBootServiceToAutogenC.\r
+                       // \r
+            setVirtualAddressToAutogenC(fileBuffer);\r
+                       setExitBootServiceToAutogenC(fileBuffer);\r
             break;\r
         default:\r
             break;\r
         }\r
-\r
-        if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) {\r
-            if (UefiOrDxeModule) {\r
-                //\r
-                // No data so make a NULL list\r
-                //\r
-                fileBuffer\r
-                .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");\r
-                fileBuffer.append("  NULL\r\n");\r
-                fileBuffer.append("};\r\n\r\n");\r
-            }\r
-        } else {\r
-            //\r
-            // Write SetVirtualAddressMap function definition.\r
-            //\r
-            for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
-                if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
-                    break;\r
-                }\r
-                fileBuffer.append("VOID\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(this.setVirtalAddList.get(i));\r
-                fileBuffer.append(" (\r\n");\r
-                fileBuffer.append("  IN EFI_EVENT  Event,\r\n");\r
-                fileBuffer.append("  IN VOID       *Context\r\n");\r
-                fileBuffer.append("  );\r\n\r\n");\r
-            }\r
-\r
-            //\r
-            // Write SetVirtualAddressMap entry point array.\r
-            //\r
-            fileBuffer\r
-            .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");\r
-            for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
-                if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
-                    break;\r
-                }\r
-\r
-                if (i == 0) {\r
-                    fileBuffer.append("\r\n  ");\r
-                } else {\r
-                    fileBuffer.append(",\r\n  ");\r
-                }\r
-\r
-                fileBuffer.append(this.setVirtalAddList.get(i));\r
-            }\r
-            //\r
-            //  If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER\r
-            //  UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of\r
-            //  _gDriverSetVirtualAddressMapEvent list.\r
-            //\r
-            if (!UefiOrDxeModule) {\r
-                fileBuffer.append(",\r\n  NULL");\r
-            }\r
-            fileBuffer.append("\r\n};\r\n\r\n");\r
-        }\r
-\r
-        if (UefiOrDxeModule) {\r
-            //\r
-            // Entry point lib for these module types needs to know the count.\r
-            //\r
-            fileBuffer\r
-            .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED  const UINTN _gDriverExitBootServicesEventCount = ");\r
-\r
-            //\r
-            // If the list is not valid or has no entries set count to zero else\r
-            // set count to the number of valid entries.\r
-            //\r
-            Count = 0;\r
-            if (this.exitBootServiceList != null) {\r
-                for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
-                    if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
-                        break;\r
-                    }\r
-                }\r
-                Count = i;\r
-            }\r
-            fileBuffer.append(Integer.toString(Count));\r
-            fileBuffer.append(";\r\n\r\n");\r
-        }\r
-\r
-        if (this.exitBootServiceList == null || this.exitBootServiceList.size() == 0) {\r
-            if (UefiOrDxeModule) {\r
-                //\r
-                // No data so make a NULL list.\r
-                //\r
-                fileBuffer\r
-                .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");\r
-                fileBuffer.append("  NULL\r\n");\r
-                fileBuffer.append("};\r\n\r\n");\r
-            }\r
-        } else {\r
-            //\r
-            // Write DriverExitBootServices function definition.\r
-            //\r
-            for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
-                if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
-                    break;\r
-                }\r
-\r
-                fileBuffer.append("VOID\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(this.exitBootServiceList.get(i));\r
-                fileBuffer.append(" (\r\n");\r
-                fileBuffer.append("  IN EFI_EVENT  Event,\r\n");\r
-                fileBuffer.append("  IN VOID       *Context\r\n");\r
-                fileBuffer.append("  );\r\n\r\n");\r
-            }\r
-\r
-            //\r
-            // Write DriverExitBootServices entry point array.\r
-            //\r
-            fileBuffer\r
-            .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");\r
-            for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
-                if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
-                    break;\r
-                }\r
-\r
-                if (i == 0) {\r
-                    fileBuffer.append("\r\n  ");\r
-                } else {\r
-                    fileBuffer.append(",\r\n  ");\r
-                }\r
-                fileBuffer.append(this.exitBootServiceList.get(i));\r
-            }\r
-            if (!UefiOrDxeModule) {\r
-                fileBuffer.append(",\r\n  NULL");\r
-            }\r
-            fileBuffer.append("\r\n};\r\n\r\n");\r
-        }\r
-\r
     }\r
 \r
     /**\r
@@ -2068,8 +1912,7 @@ public class AutoGen {
         String[] setVirtuals = null;\r
         String[] exitBoots = null;\r
 \r
-        ModuleIdentification[] libraryIdList = SurfaceAreaQuery\r
-                                               .getLibraryInstance(this.arch);\r
+        ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch);\r
         try {\r
             if (libraryIdList != null) {\r
                 //\r
@@ -2096,21 +1939,17 @@ public class AutoGen {
                         //\r
 \r
                         Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
-                        SurfaceAreaQuery.push(libDoc);\r
+                        saq.push(libDoc);\r
                         //\r
                         // Get <PPis>, <Protocols>, <Guids> list of this library\r
                         // instance.\r
                         //\r
-                        String[] ppiList = SurfaceAreaQuery.getPpiArray(this.arch);\r
-                        String[] ppiNotifyList = SurfaceAreaQuery\r
-                                                 .getPpiNotifyArray(this.arch);\r
-                        String[] protocolList = SurfaceAreaQuery\r
-                                                .getProtocolArray(this.arch);\r
-                        String[] protocolNotifyList = SurfaceAreaQuery\r
-                                                      .getProtocolNotifyArray(this.arch);\r
-                        String[] guidList = SurfaceAreaQuery\r
-                                            .getGuidEntryArray(this.arch);\r
-                        PackageIdentification[] pkgList = SurfaceAreaQuery.getDependencePkg(this.arch);\r
+                        String[] ppiList = saq.getPpiArray(this.arch);\r
+                        String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);\r
+                        String[] protocolList = saq.getProtocolArray(this.arch);\r
+                        String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);\r
+                        String[] guidList = saq.getGuidEntryArray(this.arch);\r
+                        PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);\r
 \r
                         //\r
                         // Add those ppi, protocol, guid in global ppi,\r
@@ -2146,17 +1985,15 @@ public class AutoGen {
                         // If not yet parse this library instance's constructor\r
                         // element,parse it.\r
                         //\r
-                        libConstructName = SurfaceAreaQuery\r
-                                           .getLibConstructorName();\r
-                        libDestructName = SurfaceAreaQuery\r
-                                          .getLibDestructorName();\r
+                        libConstructName = saq.getLibConstructorName();\r
+                        libDestructName = saq.getLibDestructorName();\r
 \r
                         //\r
                         // Collect SetVirtualAddressMapCallBack and\r
                         // ExitBootServiceCallBack.\r
                         //\r
-                        setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray();\r
-                        exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray();\r
+                        setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
+                        exitBoots = saq.getExitBootServicesCallBackArray();\r
                         if (setVirtuals != null) {\r
                             for (int j = 0; j < setVirtuals.length; j++) {\r
                                 this.setVirtalAddList.add(setVirtuals[j]);\r
@@ -2167,7 +2004,7 @@ public class AutoGen {
                                 this.exitBootServiceList.add(exitBoots[k]);\r
                             }\r
                         }\r
-                        SurfaceAreaQuery.pop();\r
+                        saq.pop();\r
                         //\r
                         // Add dependent library instance constructor function.\r
                         //\r
@@ -2190,4 +2027,155 @@ public class AutoGen {
             System.out.println("Collect library instance failed!");\r
         }\r
     }\r
+       private void setVirtualAddressToAutogenC(StringBuffer fileBuffer){\r
+        //\r
+        // Entry point lib for these module types needs to know the count\r
+        // of entryPoint.\r
+        //\r
+               fileBuffer\r
+            .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED  const UINTN _gDriverSetVirtualAddressMapEventCount = ");\r
+\r
+            //\r
+            // If the list is not valid or has no entries set count to zero else\r
+            // set count to the number of valid entries\r
+            //\r
+            int Count = 0;\r
+                       int i = 0;\r
+            if (this.setVirtalAddList != null) {\r
+                for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
+                    if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
+                        break;\r
+                    }\r
+                }\r
+                Count = i;\r
+            }\r
+\r
+            fileBuffer.append(Integer.toString(Count));\r
+            fileBuffer.append(";\r\n\r\n");\r
+            if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) {\r
+                //\r
+                // No data so make a NULL list\r
+                //\r
+                fileBuffer\r
+                .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");\r
+                fileBuffer.append("  NULL\r\n");\r
+                fileBuffer.append("};\r\n\r\n");\r
+            } else {\r
+                //\r
+                // Write SetVirtualAddressMap function definition.\r
+                //\r
+                for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
+                    if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
+                        break;\r
+                    }\r
+                    fileBuffer.append("VOID\r\n");\r
+                    fileBuffer.append("EFIAPI\r\n");\r
+                    fileBuffer.append(this.setVirtalAddList.get(i));\r
+                    fileBuffer.append(" (\r\n");\r
+                    fileBuffer.append("  IN EFI_EVENT  Event,\r\n");\r
+                    fileBuffer.append("  IN VOID       *Context\r\n");\r
+                    fileBuffer.append("  );\r\n\r\n");\r
+                 }\r
+\r
+                //\r
+                // Write SetVirtualAddressMap entry point array.\r
+                //\r
+                fileBuffer\r
+                .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");\r
+                for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
+                    if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
+                        break;\r
+                    }\r
+\r
+                    if (i == 0) {\r
+                        fileBuffer.append("\r\n  ");\r
+                    } else {\r
+                        fileBuffer.append(",\r\n  ");\r
+                    }\r
+\r
+                    fileBuffer.append(this.setVirtalAddList.get(i));\r
+                }\r
+                //\r
+                // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.\r
+                //\r
+                fileBuffer.append(",\r\n  NULL");\r
+                fileBuffer.append("\r\n};\r\n\r\n");\r
+                       }\r
+       }\r
+\r
+\r
+       private void setExitBootServiceToAutogenC(StringBuffer fileBuffer){\r
+               //\r
+        // Entry point lib for these module types needs to know the count.\r
+        //\r
+        fileBuffer\r
+        .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED  const UINTN _gDriverExitBootServicesEventCount = ");\r
+\r
+        //\r
+        // If the list is not valid or has no entries set count to zero else\r
+        // set count to the number of valid entries.\r
+        //\r
+        int Count = 0;\r
+               int i = 0; \r
+        if (this.exitBootServiceList != null) {\r
+            for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
+                if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
+                    break;\r
+                }\r
+            }\r
+            Count = i;\r
+        }\r
+        fileBuffer.append(Integer.toString(Count));\r
+        fileBuffer.append(";\r\n\r\n");\r
+\r
+               if (this.exitBootServiceList == null || this.exitBootServiceList.size() == 0) {\r
+            //      \r
+            // No data so make a NULL list.\r
+            //\r
+            fileBuffer\r
+            .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");\r
+            fileBuffer.append("  NULL\r\n");\r
+            fileBuffer.append("};\r\n\r\n");\r
+        } else {\r
+            //\r
+            // Write DriverExitBootServices function definition.\r
+            //\r
+            for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
+                if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
+                    break;\r
+                }\r
+\r
+                fileBuffer.append("VOID\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append(this.exitBootServiceList.get(i));\r
+                fileBuffer.append(" (\r\n");\r
+                fileBuffer.append("  IN EFI_EVENT  Event,\r\n");\r
+                fileBuffer.append("  IN VOID       *Context\r\n");\r
+                fileBuffer.append("  );\r\n\r\n");\r
+            }\r
+\r
+            //\r
+            // Write DriverExitBootServices entry point array.\r
+            //\r
+            fileBuffer\r
+            .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");\r
+            for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
+                if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
+                    break;\r
+                }\r
+\r
+                if (i == 0) {\r
+                    fileBuffer.append("\r\n  ");\r
+                } else {\r
+                    fileBuffer.append(",\r\n  ");\r
+                }\r
+                fileBuffer.append(this.exitBootServiceList.get(i));\r
+            }\r
+            \r
+            fileBuffer.append(",\r\n  NULL");\r
+            fileBuffer.append("\r\n};\r\n\r\n");\r
+        }\r
+\r
+       }\r
+\r
 }\r