]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Fixed EDKT318
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / autogen / AutoGen.java
index 80cdecf99277859a640427e7829fc2501d5043ba..5b6620b50dfc8d5f3672bcb012fe825a4fd482ed 100644 (file)
@@ -34,14 +34,16 @@ import java.util.Set;
 \r
 import org.apache.tools.ant.BuildException;\r
 import org.apache.xmlbeans.XmlObject;\r
-import org.tianocore.build.exception.*;\r
+import org.tianocore.build.exception.AutoGenException;\r
 import org.tianocore.build.global.GlobalData;\r
 import org.tianocore.build.global.SurfaceAreaQuery;\r
 import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.id.PackageIdentification;\r
 import org.tianocore.build.pcd.action.PCDAutoGenAction;\r
-import org.tianocore.common.logger.EdkLog;\r
 import org.tianocore.common.definitions.ToolDefinitions;\r
+import org.tianocore.common.definitions.EdkDefinitions;\r
+import org.tianocore.common.exception.EdkException;\r
+import org.tianocore.common.logger.EdkLog;\r
 \r
 /**\r
   This class is to generate Autogen.h and Autogen.c according to module surface\r
@@ -105,10 +107,11 @@ public class AutoGen {
 \r
     ///\r
     ///  For non library module, add its library instance's construct and destructor to\r
-    ///  list.\r
+    ///  list. String[0] recode LibConstructor name, String[1] recode Lib instance \r
+       ///  module type.\r
     ///\r
-    private List<String> libConstructList = new ArrayList<String>();\r
-    private List<String> libDestructList = new ArrayList<String>();\r
+    private List<String[]> libConstructList = new ArrayList<String[]>();\r
+    private List<String[]> libDestructList = new ArrayList<String[]>();\r
 \r
     ///\r
     /// List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack\r
@@ -116,6 +119,9 @@ 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
+    private ModuleIdentification parentId = null;\r
 \r
     /**\r
       Construct function\r
@@ -131,12 +137,13 @@ 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, ModuleIdentification parentId) {\r
         this.outputPath = outputPath;\r
         this.moduleId = moduleId;\r
         this.arch = arch;\r
         this.fvDir = fvDir;\r
-\r
+        this.saq = saq;\r
+        this.parentId = parentId;\r
     }\r
 \r
     /**\r
@@ -206,29 +213,28 @@ public class AutoGen {
       @throws BuildException\r
                   Failed to creat AutoGen.c & AutoGen.h.\r
     **/\r
-    public void genAutogen() throws BuildException {\r
+    public void genAutogen() throws EdkException {\r
         try {\r
             //\r
             // If outputPath do not exist, create it.\r
             //\r
             File path = new File(outputPath);\r
             path.mkdirs();\r
-\r
-            //\r
-            // Check current is library or not, then call the corresponding\r
-            // function.\r
-            //\r
-            if (this.moduleId.isLibrary()) {\r
-                libGenAutogen();\r
-            } else {\r
-                moduleGenAutogen();\r
-            }\r
-\r
-        } catch (Exception e) {\r
-            throw new BuildException(\r
-                                    "Failed to create AutoGen.c & AutoGen.h!\n"\r
-                                    + e.getMessage());\r
+               } catch (Exception e) {\r
+            throw new AutoGenException(\r
+                                    "Failed to create "\r
+                                    + outputPath + " directory");\r
         }\r
+            \r
+               //\r
+               // Check current is library or not, then call the corresponding\r
+               // function.\r
+               //\r
+               if (this.moduleId.isLibrary()) {\r
+                       libGenAutogen();\r
+               } else {\r
+                       moduleGenAutogen();\r
+               }\r
     }\r
 \r
     /**\r
@@ -239,17 +245,10 @@ public class AutoGen {
       @throws BuildException\r
                   Faile to create module AutoGen.c & AutoGen.h.\r
     **/\r
-    void moduleGenAutogen() throws BuildException {\r
-\r
-        try {\r
-            collectLibInstanceInfo();\r
-            moduleGenAutogenC();\r
-            moduleGenAutogenH();\r
-        } catch (Exception e) {\r
-            throw new BuildException(\r
-                                    "Faile to create module AutoGen.c & AutoGen.h!\n"\r
-                                    + e.getMessage());\r
-        }\r
+    void moduleGenAutogen() throws EdkException {\r
+               collectLibInstanceInfo();\r
+               moduleGenAutogenC();\r
+               moduleGenAutogenH();\r
     }\r
 \r
     /**\r
@@ -260,15 +259,9 @@ public class AutoGen {
       @throws BuildException\r
                   Faile to create library AutoGen.c & AutoGen.h\r
     **/\r
-    void libGenAutogen() throws BuildException {\r
-        try {\r
-            libGenAutogenC();\r
-            libGenAutogenH();\r
-        } catch (Exception e) {\r
-            throw new BuildException(\r
-                                    "Failed to create library AutoGen.c & AutoGen.h!\n"\r
-                                    + e.getMessage());\r
-        }\r
+    void libGenAutogen() throws EdkException {\r
+               libGenAutogenC();\r
+               libGenAutogenH();\r
     }\r
 \r
     /**\r
@@ -279,7 +272,7 @@ public class AutoGen {
       @throws BuildException\r
                   Failed to generate AutoGen.h.\r
     **/\r
-    void moduleGenAutogenH() throws AutoGenException {\r
+    void moduleGenAutogenH() throws EdkException {\r
 \r
         Set<String> libClassIncludeH;\r
         String moduleType;\r
@@ -314,7 +307,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 +318,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 +328,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 +340,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 +349,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 +363,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
@@ -396,7 +386,7 @@ public class AutoGen {
         // Save string buffer content in AutoGen.h.\r
         //\r
         if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {\r
-            throw new BuildException("Failed to generate AutoGen.h !!!");\r
+            throw new AutoGenException("Failed to generate AutoGen.h !!!");\r
         }\r
     }\r
 \r
@@ -408,7 +398,7 @@ public class AutoGen {
       @throws BuildException\r
                   Failed to generate AutoGen.c.\r
     **/\r
-    void moduleGenAutogenC() throws AutoGenException {\r
+    void moduleGenAutogenC() throws EdkException {\r
 \r
         StringBuffer fileBuffer = new StringBuffer(8192);\r
         //\r
@@ -427,7 +417,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 +435,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 +479,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
@@ -512,20 +501,17 @@ public class AutoGen {
                                                  arch, \r
                                                  false, \r
                                                  null,\r
-                                                 pcdDriverType);\r
-        try {\r
-            this.myPcdAutogen.execute();\r
-        } catch (Exception exp) {\r
-            throw new PcdAutogenException (exp.getMessage());\r
-        }\r
-\r
+                                                 pcdDriverType, \r
+                                                 parentId);\r
+        \r
+        this.myPcdAutogen.execute();\r
         if (this.myPcdAutogen != null) {\r
             fileBuffer.append("\r\n");\r
             fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
         }\r
 \r
         if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
-            throw new BuildException("Failed to generate AutoGen.c !!!");\r
+            throw new AutoGenException("Failed to generate AutoGen.c !!!");\r
         }\r
 \r
     }\r
@@ -538,7 +524,7 @@ public class AutoGen {
       @throws BuildException\r
                   Failed to generate AutoGen.c.\r
     **/\r
-    void libGenAutogenH() throws AutoGenException {\r
+    void libGenAutogenH() throws EdkException {\r
 \r
         Set<String> libClassIncludeH;\r
         String moduleType;\r
@@ -572,7 +558,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 +569,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 +580,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 +590,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 +605,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
@@ -643,7 +629,7 @@ public class AutoGen {
         // Save content of string buffer to AutoGen.h file.\r
         //\r
         if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {\r
-            throw new BuildException("Failed to generate AutoGen.h !!!");\r
+            throw new AutoGenException("Failed to generate AutoGen.h !!!");\r
         }\r
     }\r
 \r
@@ -655,7 +641,7 @@ public class AutoGen {
       @throws BuildException\r
                   Failed to generate AutoGen.c.\r
     **/\r
-    void libGenAutogenC() throws BuildException, PcdAutogenException {\r
+    void libGenAutogenC() throws EdkException {\r
         StringBuffer fileBuffer = new StringBuffer(10240);\r
 \r
         //\r
@@ -672,21 +658,17 @@ public class AutoGen {
         this.myPcdAutogen = new PCDAutoGenAction(moduleId,\r
                                                  arch,\r
                                                  true,\r
-                                                 SurfaceAreaQuery.getModulePcdEntryNameArray(),\r
-                                                 pcdDriverType);\r
-        try {\r
-            this.myPcdAutogen.execute();\r
-        } catch (Exception e) {\r
-            throw new PcdAutogenException(e.getMessage());\r
-        }\r
-\r
+                                                 saq.getModulePcdEntryNameArray(),\r
+                                                 pcdDriverType, \r
+                                                 parentId);\r
+        this.myPcdAutogen.execute();\r
         if (this.myPcdAutogen != null) {\r
             fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);\r
             fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
         }\r
 \r
         if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
-            throw new BuildException("Failed to generate AutoGen.c !!!");\r
+            throw new AutoGenException("Failed to generate AutoGen.c !!!");\r
         }\r
     }\r
 \r
@@ -702,7 +684,7 @@ public class AutoGen {
       @return includeStrList List of *.h file.\r
     **/\r
     Set<String> LibraryClassToAutogenH(String[] libClassList)\r
-    throws AutoGenException {\r
+    throws EdkException {\r
         Set<String> includeStrList = new LinkedHashSet<String>();\r
         String includeName[];\r
         String str = "";\r
@@ -713,7 +695,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
@@ -783,9 +765,9 @@ public class AutoGen {
       @throws Exception\r
     **/\r
     void EntryPointToAutoGen(String[] entryPointList, String[] unloadImageList, StringBuffer fileBuffer)\r
-    throws BuildException {\r
+    throws EdkException {\r
 \r
-        String typeStr = SurfaceAreaQuery.getModuleType();\r
+        String typeStr = saq.getModuleType();\r
                int unloadImageCount = 0;\r
         int entryPointCount  = 0;\r
 \r
@@ -797,11 +779,10 @@ public class AutoGen {
         \r
         case CommonDefinition.ModuleTypePeiCore:\r
             if (entryPointList == null ||entryPointList.length != 1 ) {\r
-                throw new BuildException(\r
+                throw new AutoGenException(\r
                                         "Module type = 'PEI_CORE', can have only one module entry point!");\r
             } else {\r
                 fileBuffer.append("EFI_STATUS\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
                 fileBuffer.append(entryPointList[0]);\r
                 fileBuffer.append(" (\r\n");\r
                 fileBuffer\r
@@ -829,12 +810,11 @@ public class AutoGen {
         case CommonDefinition.ModuleTypeDxeCore:\r
             fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");\r
             if (entryPointList == null || entryPointList.length != 1) {\r
-                throw new BuildException(\r
+                throw new AutoGenException(\r
                                         "Module type = 'DXE_CORE', can have only one module entry point!");\r
             } else {\r
 \r
                 fileBuffer.append("VOID\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
                 fileBuffer.append(entryPointList[0]);\r
                 fileBuffer.append(" (\n");\r
                 fileBuffer.append("  IN VOID  *HobStart\r\n");\r
@@ -871,7 +851,6 @@ public class AutoGen {
             }\r
             for (int i = 0; i < entryPointList.length; i++) {\r
                 fileBuffer.append("EFI_STATUS\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
                 fileBuffer.append(entryPointList[i]);\r
                 fileBuffer.append(" (\r\n");\r
                 fileBuffer\r
@@ -940,7 +919,6 @@ public class AutoGen {
             } else {\r
                 for (int i = 0; i < entryPointList.length; i++) {\r
                     fileBuffer.append("EFI_STATUS\r\n");\r
-                    fileBuffer.append("EFIAPI\r\n");\r
                     fileBuffer.append(entryPointList[i]);\r
                     fileBuffer.append(" (\r\n");\r
                     fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
@@ -1007,7 +985,6 @@ public class AutoGen {
             if (unloadImageList != null) {\r
                 for (int i = 0; i < unloadImageList.length; i++) {\r
                     fileBuffer.append("EFI_STATUS\r\n");\r
-                    fileBuffer.append("EFIAPI\r\n");\r
                     fileBuffer.append(unloadImageList[i]);\r
                     fileBuffer.append(" (\r\n");\r
                     fileBuffer\r
@@ -1087,7 +1064,6 @@ public class AutoGen {
                 for (int i = 0; i < entryPointList.length; i++) {\r
 \r
                     fileBuffer.append("EFI_STATUS\r\n");\r
-                    fileBuffer.append("EFIAPI\r\n");\r
                     fileBuffer.append(entryPointList[i]);\r
                     fileBuffer.append(" (\r\n");\r
                     fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
@@ -1250,12 +1226,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
@@ -1296,10 +1272,10 @@ public class AutoGen {
       @throws BuildException\r
                   Protocol name must set.\r
     **/\r
-    void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws BuildException {\r
+    void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws EdkException {\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 +1284,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
@@ -1336,7 +1312,7 @@ public class AutoGen {
                 //\r
                 // If can't find protocol GUID declaration in every package\r
                 //\r
-                throw new BuildException("Can not find protocol Guid ["\r
+                throw new AutoGenException("Can not find protocol Guid ["\r
                                          + protocolKeyWord + "] declaration in any SPD package!");\r
             }\r
         }\r
@@ -1356,7 +1332,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
@@ -1397,21 +1373,17 @@ public class AutoGen {
                  String buffer for AutoGen.c\r
       @throws BuildException\r
     **/\r
-    void LibInstanceToAutogenC(StringBuffer fileBuffer) throws BuildException {\r
-        try {\r
-            String moduleType = this.moduleId.getModuleType();\r
-            //\r
-            // Add library constructor to AutoGen.c\r
-            //\r
-            LibConstructorToAutogenC(libConstructList, moduleType,\r
-                                     fileBuffer/* autogenC */);\r
-            //\r
-            // Add library destructor to AutoGen.c\r
-            //\r
-            LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);\r
-        } catch (Exception e) {\r
-            throw new BuildException(e.getMessage());\r
-        }\r
+    void LibInstanceToAutogenC(StringBuffer fileBuffer) throws EdkException {\r
+               String moduleType = this.moduleId.getModuleType();\r
+               //\r
+               // Add library constructor to AutoGen.c\r
+               //\r
+               LibConstructorToAutogenC(libConstructList, moduleType,\r
+                                                                fileBuffer/* autogenC */);\r
+               //\r
+               // Add library destructor to AutoGen.c\r
+               //\r
+               LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);\r
     }\r
 \r
     /**\r
@@ -1428,8 +1400,8 @@ public class AutoGen {
                  String buffer for AutoGen.c\r
       @throws Exception\r
     **/\r
-    void LibConstructorToAutogenC(List<String> libInstanceList,\r
-                                  String moduleType, StringBuffer fileBuffer) throws Exception {\r
+    void LibConstructorToAutogenC(List<String[]> libInstanceList,\r
+                                  String moduleType, StringBuffer fileBuffer) throws EdkException {\r
         boolean isFirst = true;\r
 \r
         //\r
@@ -1437,44 +1409,54 @@ public class AutoGen {
         // module type.\r
         //\r
         for (int i = 0; i < libInstanceList.size(); i++) {\r
-            switch (CommonDefinition.getModuleType(moduleType)) {\r
-            case CommonDefinition.ModuleTypeBase:\r
-                fileBuffer.append("RETURN_STATUS\r\n");\r
+                       if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
+                               fileBuffer.append("RETURN_STATUS\r\n");\r
                 fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(libInstanceList.get(i));\r
+                fileBuffer.append(libInstanceList.get(i)[0]);\r
                 fileBuffer.append(" (\r\n");\r
                 fileBuffer.append("  VOID\r\n");\r
                 fileBuffer.append("  );\r\n");\r
-                break;\r
-\r
-            case CommonDefinition.ModuleTypePeiCore:\r
-            case CommonDefinition.ModuleTypePeim:\r
-                fileBuffer.append("EFI_STATUS\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(libInstanceList.get(i));\r
-                fileBuffer.append(" (\r\n");\r
-                fileBuffer\r
-                .append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r\n");\r
-                fileBuffer\r
-                .append("  IN EFI_PEI_SERVICES          **PeiServices\r\n");\r
-                fileBuffer.append("  );\r\n");\r
-                break;\r
+                       } else {\r
+                               switch (CommonDefinition.getModuleType(moduleType)) {\r
+                case CommonDefinition.ModuleTypeBase:\r
+                    fileBuffer.append("RETURN_STATUS\r\n");\r
+                    fileBuffer.append("EFIAPI\r\n");\r
+                    fileBuffer.append(libInstanceList.get(i)[0]);\r
+                    fileBuffer.append(" (\r\n");\r
+                    fileBuffer.append("  VOID\r\n");\r
+                    fileBuffer.append("  );\r\n");\r
+                    break;\r
 \r
-            case CommonDefinition.ModuleTypeDxeCore:\r
-            case CommonDefinition.ModuleTypeDxeDriver:\r
-            case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
-            case CommonDefinition.ModuleTypeDxeSmmDriver:\r
-            case CommonDefinition.ModuleTypeDxeSalDriver:\r
-            case CommonDefinition.ModuleTypeUefiDriver:\r
-            case CommonDefinition.ModuleTypeUefiApplication:\r
-                fileBuffer.append("EFI_STATUS\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(libInstanceList.get(i));\r
-                fileBuffer.append(" (\r\n");\r
-                fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
-                fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\r\n");\r
-                fileBuffer.append("  );\r\n");\r
-                break;\r
+                case CommonDefinition.ModuleTypePeiCore:\r
+                case CommonDefinition.ModuleTypePeim:\r
+                                       fileBuffer.append("EFI_STATUS\r\n");\r
+                                       fileBuffer.append("EFIAPI\r\n");\r
+                                       fileBuffer.append(libInstanceList.get(i)[0]);\r
+                                       fileBuffer.append(" (\r\n");\r
+                                       fileBuffer\r
+                                       .append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r\n");\r
+                                       fileBuffer\r
+                                       .append("  IN EFI_PEI_SERVICES          **PeiServices\r\n");\r
+                                       fileBuffer.append("  );\r\n");\r
+                                       break;\r
+       \r
+                               case CommonDefinition.ModuleTypeDxeCore:\r
+                               case CommonDefinition.ModuleTypeDxeDriver:\r
+                               case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
+                               case CommonDefinition.ModuleTypeDxeSmmDriver:\r
+                               case CommonDefinition.ModuleTypeDxeSalDriver:\r
+                               case CommonDefinition.ModuleTypeUefiDriver:\r
+                               case CommonDefinition.ModuleTypeUefiApplication:\r
+                                       fileBuffer.append("EFI_STATUS\r\n");\r
+                                       fileBuffer.append("EFIAPI\r\n");\r
+                                       fileBuffer.append(libInstanceList.get(i)[0]);\r
+                                       fileBuffer.append(" (\r\n");\r
+                                       fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
+                                       fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\r\n");\r
+                                       fileBuffer.append("  );\r\n");\r
+                                       break;\r
+\r
+                           }\r
             }\r
         }\r
 \r
@@ -1523,32 +1505,40 @@ public class AutoGen {
                 fileBuffer.append("\r\n");\r
                 isFirst = false;\r
             }\r
-            switch (CommonDefinition.getModuleType(moduleType)) {\r
-            case CommonDefinition.ModuleTypeBase:\r
+                       if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
                 fileBuffer.append("  Status = ");\r
-                fileBuffer.append(libInstanceList.get(i));\r
+                fileBuffer.append(libInstanceList.get(i)[0]);\r
                 fileBuffer.append("();\r\n");\r
                 fileBuffer.append("  VOID\r\n");\r
-                break;\r
-            case CommonDefinition.ModuleTypePeiCore:\r
-            case CommonDefinition.ModuleTypePeim:\r
-                fileBuffer.append("  Status = ");\r
-                fileBuffer.append(libInstanceList.get(i));\r
-                fileBuffer.append(" (FfsHeader, PeiServices);\r\n");\r
-                break;\r
-            case CommonDefinition.ModuleTypeDxeCore:\r
-            case CommonDefinition.ModuleTypeDxeDriver:\r
-            case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
-            case CommonDefinition.ModuleTypeDxeSmmDriver:\r
-            case CommonDefinition.ModuleTypeDxeSalDriver:\r
-            case CommonDefinition.ModuleTypeUefiDriver:\r
-            case CommonDefinition.ModuleTypeUefiApplication:\r
-                fileBuffer.append("  Status = ");\r
-                fileBuffer.append(libInstanceList.get(i));\r
-                fileBuffer.append(" (ImageHandle, SystemTable);\r\n");\r
-                break;\r
-            default:\r
-                EdkLog.log(EdkLog.EDK_INFO,"Autogen doesn't know how to deal with module type - " + moduleType + "!");\r
+                       } else {\r
+                               switch (CommonDefinition.getModuleType(moduleType)) {\r
+                                       case CommonDefinition.ModuleTypeBase:\r
+                                               fileBuffer.append("  Status = ");\r
+                                               fileBuffer.append(libInstanceList.get(i)[0]);\r
+                                               fileBuffer.append("();\r\n");\r
+                                               fileBuffer.append("  VOID\r\n");\r
+                                               break;\r
+                                       case CommonDefinition.ModuleTypePeiCore:\r
+                                       case CommonDefinition.ModuleTypePeim:\r
+                                               fileBuffer.append("  Status = ");\r
+                                               fileBuffer.append(libInstanceList.get(i)[0]);\r
+                                               fileBuffer.append(" (FfsHeader, PeiServices);\r\n");\r
+                                               break;\r
+                                       case CommonDefinition.ModuleTypeDxeCore:\r
+                                       case CommonDefinition.ModuleTypeDxeDriver:\r
+                                       case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
+                                       case CommonDefinition.ModuleTypeDxeSmmDriver:\r
+                                       case CommonDefinition.ModuleTypeDxeSalDriver:\r
+                                       case CommonDefinition.ModuleTypeUefiDriver:\r
+                                       case CommonDefinition.ModuleTypeUefiApplication:\r
+                                               fileBuffer.append("  Status = ");\r
+                                               fileBuffer.append(libInstanceList.get(i)[0]);\r
+                                               fileBuffer.append(" (ImageHandle, SystemTable);\r\n");\r
+                                               break;\r
+                                       default:\r
+                                               EdkLog.log(EdkLog.EDK_INFO,"Autogen doesn't know how to deal with module type - " + moduleType + "!");\r
+                          }\r
+            \r
             }\r
             fileBuffer.append("  ASSERT_EFI_ERROR (Status);\r\n");\r
         }\r
@@ -1569,46 +1559,55 @@ public class AutoGen {
                  String buffer for AutoGen.c\r
       @throws Exception\r
     **/\r
-    void LibDestructorToAutogenC(List<String> libInstanceList,\r
-                                 String moduleType, StringBuffer fileBuffer) throws Exception {\r
+    void LibDestructorToAutogenC(List<String[]> libInstanceList,\r
+                                 String moduleType, StringBuffer fileBuffer) throws EdkException {\r
         boolean isFirst = true;\r
         for (int i = 0; i < libInstanceList.size(); i++) {\r
-            switch (CommonDefinition.getModuleType(moduleType)) {\r
-            case CommonDefinition.ModuleTypeBase:\r
+                       if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
                 fileBuffer.append("RETURN_STATUS\r\n");\r
                 fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(libInstanceList.get(i));\r
+                fileBuffer.append(libInstanceList.get(i)[0]);\r
                 fileBuffer.append(" (\r\n");\r
                 fileBuffer.append("  VOID\r\n");\r
                 fileBuffer.append("  );\r\n");\r
-                break;\r
-            case CommonDefinition.ModuleTypePeiCore:\r
-            case CommonDefinition.ModuleTypePeim:\r
-                fileBuffer.append("EFI_STATUS\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(libInstanceList.get(i));\r
-                fileBuffer.append(" (\r\n");\r
-                fileBuffer\r
-                .append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r\n");\r
-                fileBuffer\r
-                .append("  IN EFI_PEI_SERVICES          **PeiServices\r\n");\r
-                fileBuffer.append("  );\r\n");\r
-                break;\r
-            case CommonDefinition.ModuleTypeDxeCore:\r
-            case CommonDefinition.ModuleTypeDxeDriver:\r
-            case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
-            case CommonDefinition.ModuleTypeDxeSmmDriver:\r
-            case CommonDefinition.ModuleTypeDxeSalDriver:\r
-            case CommonDefinition.ModuleTypeUefiDriver:\r
-            case CommonDefinition.ModuleTypeUefiApplication:\r
-                fileBuffer.append("EFI_STATUS\r\n");\r
-                fileBuffer.append("EFIAPI\r\n");\r
-                fileBuffer.append(libInstanceList.get(i));\r
-                fileBuffer.append(" (\r\n");\r
-                fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
-                fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\r\n");\r
-                fileBuffer.append("  );\r\n");\r
-                break;\r
+                       } else {\r
+                               switch (CommonDefinition.getModuleType(moduleType)) {\r
+                                       case CommonDefinition.ModuleTypeBase:\r
+                                               fileBuffer.append("RETURN_STATUS\r\n");\r
+                                               fileBuffer.append("EFIAPI\r\n");\r
+                                               fileBuffer.append(libInstanceList.get(i)[0]);\r
+                                               fileBuffer.append(" (\r\n");\r
+                                               fileBuffer.append("  VOID\r\n");\r
+                                               fileBuffer.append("  );\r\n");\r
+                                               break;\r
+                                       case CommonDefinition.ModuleTypePeiCore:\r
+                                       case CommonDefinition.ModuleTypePeim:\r
+                                               fileBuffer.append("EFI_STATUS\r\n");\r
+                                               fileBuffer.append("EFIAPI\r\n");\r
+                                               fileBuffer.append(libInstanceList.get(i)[0]);\r
+                                               fileBuffer.append(" (\r\n");\r
+                                               fileBuffer\r
+                                               .append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r\n");\r
+                                               fileBuffer\r
+                                               .append("  IN EFI_PEI_SERVICES          **PeiServices\r\n");\r
+                                               fileBuffer.append("  );\r\n");\r
+                                               break;\r
+                                       case CommonDefinition.ModuleTypeDxeCore:\r
+                                       case CommonDefinition.ModuleTypeDxeDriver:\r
+                                       case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
+                                       case CommonDefinition.ModuleTypeDxeSmmDriver:\r
+                                       case CommonDefinition.ModuleTypeDxeSalDriver:\r
+                                       case CommonDefinition.ModuleTypeUefiDriver:\r
+                                       case CommonDefinition.ModuleTypeUefiApplication:\r
+                                               fileBuffer.append("EFI_STATUS\r\n");\r
+                                               fileBuffer.append("EFIAPI\r\n");\r
+                                               fileBuffer.append(libInstanceList.get(i)[0]);\r
+                                               fileBuffer.append(" (\r\n");\r
+                                               fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
+                                               fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\r\n");\r
+                                               fileBuffer.append("  );\r\n");\r
+                                               break;\r
+                           }\r
             }\r
         }\r
 \r
@@ -1645,10 +1644,17 @@ public class AutoGen {
                     fileBuffer.append("\r\n");\r
                     isFirst = false;\r
                 }\r
-                fileBuffer.append("  Status = ");\r
-                fileBuffer.append(libInstanceList.get(i));\r
-                fileBuffer.append("(ImageHandle, SystemTable);\r\n");\r
-                fileBuffer.append("  ASSERT_EFI_ERROR (Status);\r\n");\r
+                               if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
+                    fileBuffer.append("  Status = ");\r
+                    fileBuffer.append(libInstanceList.get(i)[0]);\r
+                    fileBuffer.append("();\r\n");\r
+                    fileBuffer.append("  VOID\r\n");\r
+                               } else {\r
+                                       fileBuffer.append("  Status = ");\r
+                                       fileBuffer.append(libInstanceList.get(i)[0]);\r
+                                       fileBuffer.append("(ImageHandle, SystemTable);\r\n");\r
+                                       fileBuffer.append("  ASSERT_EFI_ERROR (Status);\r\n");\r
+                               }\r
             }\r
             fileBuffer.append("}\r\n");\r
             break;\r
@@ -1665,91 +1671,79 @@ public class AutoGen {
                  String buffer for AutoGen.c\r
     **/\r
     void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer)\r
-    throws BuildException {\r
+    throws EdkException {\r
 \r
         //\r
-        // Check what <extern> contains. And the number of following elements\r
-        // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME\r
-        // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC\r
-        //\r
+        // Get the arry of extern. The driverBindingGroup is a 2 dimension array.\r
+               // The second dimension is include following element: DriverBinding, \r
+               // ComponentName, DriverConfiguration, DriverDiag;\r
+               // \r
+        String[][] driverBindingGroup = this.saq.getExternProtocolGroup();\r
 \r
-        String[] drvBindList = SurfaceAreaQuery.getDriverBindingArray();\r
-\r
-        //\r
-        // If component name protocol,component configuration protocol,\r
-        // component diagnostic protocol is not null or empty, check\r
-        // if every one have the same number of the driver binding protocol.\r
         //\r
-        if (drvBindList == null || drvBindList.length == 0) {\r
-            return;\r
-        }\r
-\r
-        String[] compNamList = SurfaceAreaQuery.getComponentNameArray();\r
-        String[] compConfList = SurfaceAreaQuery.getDriverConfigArray();\r
-        String[] compDiagList = SurfaceAreaQuery.getDriverDiagArray();\r
-\r
+        // inital BitMask;\r
+               // \r
         int BitMask = 0;\r
 \r
         //\r
         // Write driver binding protocol extern to autogen.c\r
         //\r
-        for (int i = 0; i < drvBindList.length; i++) {\r
-            fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL ");\r
-            fileBuffer.append(drvBindList[i]);\r
-            fileBuffer.append(";\r\n");\r
+        for (int i = 0; i < driverBindingGroup.length; i++) {\r
+                       if (driverBindingGroup[i][0] != null) {\r
+                               fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL ");\r
+                fileBuffer.append(driverBindingGroup[i][0]);\r
+                fileBuffer.append(";\r\n");\r
+                       } \r
         }\r
 \r
         //\r
         // Write component name protocol extern to autogen.c\r
         //\r
-        if (compNamList != null && compNamList.length != 0) {\r
-            if (drvBindList.length != compNamList.length) {\r
-                throw new BuildException(\r
-                                        "Different number of Driver Binding and Component Name protocols!");\r
-            }\r
-\r
-            BitMask |= 0x01;\r
-            for (int i = 0; i < compNamList.length; i++) {\r
-                fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL ");\r
-                fileBuffer.append(compNamList[i]);\r
-                fileBuffer.append(";\r\n");\r
-            }\r
-        }\r
+               for (int i = 0; i < driverBindingGroup.length; i++) {\r
+                       if (driverBindingGroup[i][1]!= null) {\r
+                               if (driverBindingGroup[i][0] != null) {\r
+                                       BitMask |= 0x01;\r
+                                   fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL ");\r
+                    fileBuffer.append(driverBindingGroup[i][1]);\r
+                    fileBuffer.append(";\r\n");\r
+                               } else {\r
+                    throw new AutoGenException("DriverBinding can't be empty!!");\r
+                               }\r
+                       }\r
+               }\r
 \r
         //\r
         // Write driver configration protocol extern to autogen.c\r
         //\r
-        if (compConfList != null && compConfList.length != 0) {\r
-            if (drvBindList.length != compConfList.length) {\r
-                throw new BuildException(\r
-                                        "Different number of Driver Binding and Driver Configuration protocols!");\r
-            }\r
-\r
-            BitMask |= 0x02;\r
-            for (int i = 0; i < compConfList.length; i++) {\r
-                fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");\r
-                fileBuffer.append(compConfList[i]);\r
-                fileBuffer.append(";\r\n");\r
-            }\r
-        }\r
-\r
+               for (int i = 0; i < driverBindingGroup.length; i++) {\r
+                       if (driverBindingGroup[i][2] != null) {\r
+                               if (driverBindingGroup[i][0] != null) {\r
+                    BitMask |= 0x02;\r
+                                   fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");\r
+                    fileBuffer.append(driverBindingGroup[i][2]);\r
+                    fileBuffer.append(";\r\n");\r
+                               } else {\r
+                    throw new AutoGenException("DriverBinding can't be empty!!");\r
+                               }\r
+                       }\r
+               }\r
+        \r
         //\r
         // Write driver dignastic protocol extern to autogen.c\r
         //\r
-        if (compDiagList != null && compDiagList.length != 0) {\r
-            if (drvBindList.length != compDiagList.length) {\r
-                throw new BuildException(\r
-                                        "Different number of Driver Binding and Driver Diagnosis protocols!");\r
-            }\r
-\r
-            BitMask |= 0x04;\r
-            for (int i = 0; i < compDiagList.length; i++) {\r
-                fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");\r
-                fileBuffer.append(compDiagList[i]);\r
-                fileBuffer.append(";\r\n");\r
-            }\r
-        }\r
-\r
+               for (int i = 0; i < driverBindingGroup.length; i++) {\r
+                       if (driverBindingGroup[i][3] != null) {\r
+                               if (driverBindingGroup[i][0] != null) {\r
+                    BitMask |= 0x04;\r
+                    fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");\r
+                    fileBuffer.append(driverBindingGroup[i][3]);\r
+                    fileBuffer.append(";\r\n");\r
+                               } else {\r
+                    throw new AutoGenException("DriverBinding can't be empty!!");\r
+                               }\r
+                       }\r
+               }\r
+      \r
         //\r
         // Write driver module protocol bitmask.\r
         //\r
@@ -1764,49 +1758,58 @@ public class AutoGen {
         fileBuffer\r
         .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN  _gDriverModelProtocolListEntries = ");\r
 \r
-        fileBuffer.append(Integer.toString(drvBindList.length));\r
+        fileBuffer.append(Integer.toString(driverBindingGroup.length));\r
         fileBuffer.append(";\r\n");\r
 \r
         //\r
         // Write drive module protocol list to autogen.c\r
         //\r
-        fileBuffer\r
+               if (driverBindingGroup.length > 0) {\r
+                       fileBuffer\r
         .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST  _gDriverModelProtocolList[] = {");\r
-        for (int i = 0; i < drvBindList.length; i++) {\r
+               }\r
+        \r
+               \r
+        for (int i = 0; i < driverBindingGroup.length; i++) {\r
             if (i != 0) {\r
                 fileBuffer.append(",");\r
             }\r
-            fileBuffer.append("\r\n {\r\n");\r
+                       \r
+                       fileBuffer.append("\r\n {\r\n");\r
             fileBuffer.append("  &");\r
-            fileBuffer.append(drvBindList[i]);\r
+            fileBuffer.append(driverBindingGroup[i][0]);\r
             fileBuffer.append(", \r\n");\r
+                       \r
 \r
-            if (compNamList != null) {\r
+            if (driverBindingGroup[i][1] != null) {\r
                 fileBuffer.append("  &");\r
-                fileBuffer.append(compNamList[i]);\r
+                fileBuffer.append(driverBindingGroup[i][1]);\r
                 fileBuffer.append(", \r\n");\r
             } else {\r
                 fileBuffer.append("  NULL, \r\n");\r
             }\r
 \r
-            if (compConfList != null) {\r
+            if (driverBindingGroup[i][2] != null) {\r
                 fileBuffer.append("  &");\r
-                fileBuffer.append(compConfList[i]);\r
+                fileBuffer.append(driverBindingGroup[i][2]);\r
                 fileBuffer.append(", \r\n");\r
             } else {\r
                 fileBuffer.append("  NULL, \r\n");\r
             }\r
 \r
-            if (compDiagList != null) {\r
+            if (driverBindingGroup[i][3] != null) {\r
                 fileBuffer.append("  &");\r
-                fileBuffer.append(compDiagList[i]);\r
+                fileBuffer.append(driverBindingGroup[i][3]);\r
                 fileBuffer.append(", \r\n");\r
             } else {\r
                 fileBuffer.append("  NULL, \r\n");\r
             }\r
             fileBuffer.append("  }");\r
         }\r
-        fileBuffer.append("\r\n};\r\n");\r
+\r
+               if (driverBindingGroup.length > 0) {\r
+                       fileBuffer.append("\r\n};\r\n");\r
+               }\r
     }\r
 \r
     /**\r
@@ -1820,14 +1823,14 @@ public class AutoGen {
       @throws BuildException\r
     **/\r
     void ExternCallBackToAutoGenC(StringBuffer fileBuffer)\r
-    throws BuildException {\r
+    throws EdkException {\r
         //\r
         // Collect module's <SetVirtualAddressMapCallBack> and\r
         // <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,28 +1846,205 @@ 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
+               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
+\r
+    /**\r
+      copyFlashMapHToDebugDir\r
+      \r
+      This function is to copy the falshmap.h to debug directory and change \r
+      its name to TianoR8FlashMap.h\r
+      \r
+      @param \r
+      @return\r
+    **/\r
+    private void copyFlashMapHToDebugDir() throws  AutoGenException{\r
+\r
+        File inFile = new File(fvDir + File.separatorChar + CommonDefinition.FLASHMAPH);\r
+        int size = (int)inFile.length();\r
+        byte[] buffer = new byte[size];\r
+        File outFile = new File (this.outputPath + File.separatorChar + CommonDefinition.TIANOR8PLASHMAPH);\r
+        //\r
+        //  If TianoR8FlashMap.h existed and the flashMap.h don't change,\r
+        //  do nothing.\r
+        //\r
+        if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) {\r
+                       if (inFile.exists()) {\r
+                               try{\r
+                                       FileInputStream fis = new FileInputStream (inFile);\r
+                                   fis.read(buffer);\r
+                                   FileOutputStream fos = new FileOutputStream(outFile);\r
+                                   fos.write(buffer);\r
+                                   fis.close();\r
+                                   fos.close();\r
+                               } catch (IOException e){\r
+                    throw new AutoGenException("The file, flashMap.h can't be open!");\r
+                               }\r
+                               \r
+                       } else {\r
+                               throw new AutoGenException("The file, flashMap.h doesn't exist!");\r
+                       }\r
+        }\r
+    }\r
+\r
+    /**\r
+      This function first order the library instances, then collect\r
+      library instance 's PPI, Protocol, GUID,\r
+      SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and\r
+      Destructor, Constructor.\r
+      \r
+      @param\r
+      @return    \r
+    **/\r
+    private void collectLibInstanceInfo() throws EdkException{\r
+        int index;\r
+\r
+        String libConstructName = null;\r
+        String libDestructName = null;\r
+               String libModuleType   = null;\r
+        String[] setVirtuals = null;\r
+        String[] exitBoots = null;\r
+\r
+        ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch);\r
+\r
+               if (libraryIdList != null) {\r
+                       //\r
+                       // Reorder library instance sequence.\r
+                       //\r
+                       AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList,\r
+                                                                                                                  this.arch);\r
+                       List<ModuleIdentification> orderList = libOrder\r
+                                                                                                  .orderLibInstance();\r
+\r
+                       if (orderList != null) {\r
+                               //\r
+                               // Process library instance one by one.\r
+                               //\r
+                               for (int i = 0; i < orderList.size(); i++) {\r
+\r
+                                       //\r
+                                       // Get library instance basename.\r
+                                       //\r
+                                       ModuleIdentification libInstanceId = orderList.get(i);\r
+\r
+                                       //\r
+                                       // Get override map\r
+                                       //\r
+\r
+                                       Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
+                                       saq.push(libDoc);\r
+                                       //\r
+                                       // Get <PPis>, <Protocols>, <Guids> list of this library\r
+                                       // instance.\r
+                                       //\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
+                                       // protocol, guid\r
+                                       // list.\r
+                                       //\r
+                                       for (index = 0; index < ppiList.length; index++) {\r
+                                               this.mPpiList.add(ppiList[index]);\r
+                                       }\r
+\r
+                                       for (index = 0; index < ppiNotifyList.length; index++) {\r
+                                               this.mPpiList.add(ppiNotifyList[index]);\r
+                                       }\r
+\r
+                                       for (index = 0; index < protocolList.length; index++) {\r
+                                               this.mProtocolList.add(protocolList[index]);\r
+                                       }\r
+\r
+                                       for (index = 0; index < protocolNotifyList.length; index++) {\r
+                                               this.mProtocolList.add(protocolNotifyList[index]);\r
+                                       }\r
+\r
+                                       for (index = 0; index < guidList.length; index++) {\r
+                                               this.mGuidList.add(guidList[index]);\r
+                                       }\r
+                                       for (index = 0; index < pkgList.length; index++) {\r
+                                               if (!this.mDepPkgList.contains(pkgList[index])) {\r
+                                                       this.mDepPkgList.add(pkgList[index]);\r
+                                               }\r
+                                       }\r
+\r
+                                       //\r
+                                       // If not yet parse this library instance's constructor\r
+                                       // element,parse it.\r
+                                       //\r
+                                       libConstructName = saq.getLibConstructorName();\r
+                                       libDestructName = saq.getLibDestructorName();\r
+                                       libModuleType = saq.getModuleType();\r
+\r
+                                       //\r
+                                       // Collect SetVirtualAddressMapCallBack and\r
+                                       // ExitBootServiceCallBack.\r
+                                       //\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
+                                               }\r
+                                       }\r
+                                       if (exitBoots != null) {\r
+                                               for (int k = 0; k < exitBoots.length; k++) {\r
+                                                       this.exitBootServiceList.add(exitBoots[k]);\r
+                                               }\r
+                                       }\r
+                                       saq.pop();\r
+                                       //\r
+                                       // Add dependent library instance constructor function.\r
+                                       //\r
+                                       if (libConstructName != null) {\r
+                                               this.libConstructList.add(new String[] {libConstructName, libModuleType});\r
+                                       }\r
+                                       //\r
+                                       // Add dependent library instance destructor fuction.\r
+                                       //\r
+                                       if (libDestructName != null) {\r
+                                               this.libDestructList.add(new String[] {libDestructName, libModuleType});\r
+                                       }\r
+                               }\r
+                       }\r
+\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
-            Count = 0;\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
@@ -1876,13 +2056,7 @@ public class AutoGen {
 \r
             fileBuffer.append(Integer.toString(Count));\r
             fileBuffer.append(";\r\n\r\n");\r
-            break;\r
-        default:\r
-            break;\r
-        }\r
-\r
-        if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) {\r
-            if (UefiOrDxeModule) {\r
+            if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) {\r
                 //\r
                 // No data so make a NULL list\r
                 //\r
@@ -1890,87 +2064,82 @@ public class AutoGen {
                 .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
+            } 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
+                // 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
+                    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(this.setVirtalAddList.get(i));\r
+                }\r
+                //\r
+                // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.\r
+                //\r
                 fileBuffer.append(",\r\n  NULL");\r
-            }\r
-            fileBuffer.append("\r\n};\r\n\r\n");\r
-        }\r
+                fileBuffer.append("\r\n};\r\n\r\n");\r
+                       }\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
+       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
-                Count = i;\r
             }\r
-            fileBuffer.append(Integer.toString(Count));\r
-            fileBuffer.append(";\r\n\r\n");\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
-            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
+               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
@@ -2006,188 +2175,11 @@ public class AutoGen {
                 }\r
                 fileBuffer.append(this.exitBootServiceList.get(i));\r
             }\r
-            if (!UefiOrDxeModule) {\r
-                fileBuffer.append(",\r\n  NULL");\r
-            }\r
+            \r
+            fileBuffer.append(",\r\n  NULL");\r
             fileBuffer.append("\r\n};\r\n\r\n");\r
         }\r
 \r
-    }\r
-\r
-    /**\r
-      copyFlashMapHToDebugDir\r
-      \r
-      This function is to copy the falshmap.h to debug directory and change \r
-      its name to TianoR8FlashMap.h\r
-      \r
-      @param \r
-      @return\r
-    **/\r
-    private void copyFlashMapHToDebugDir() throws  AutoGenException{\r
-\r
-        File inFile = new File(fvDir + File.separatorChar + CommonDefinition.FLASHMAPH);\r
-        int size = (int)inFile.length();\r
-        byte[] buffer = new byte[size];\r
-        File outFile = new File (this.outputPath + File.separatorChar + CommonDefinition.TIANOR8PLASHMAPH);\r
-        //\r
-        //  If TianoR8FlashMap.h existed and the flashMap.h don't change,\r
-        //  do nothing.\r
-        //\r
-        if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) {\r
-            try {\r
-                if (inFile.exists()) {\r
-                    FileInputStream fis = new FileInputStream (inFile);\r
-                    fis.read(buffer);\r
-                    FileOutputStream fos = new FileOutputStream(outFile);\r
-                    fos.write(buffer);\r
-                    fis.close();\r
-                    fos.close();\r
-                } else {\r
-                    throw new AutoGenException("The file, flashMap.h doesn't exist!");\r
-                }\r
-            } catch (Exception e) {\r
-                throw new AutoGenException(e.getMessage());\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-      This function first order the library instances, then collect\r
-      library instance 's PPI, Protocol, GUID,\r
-      SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and\r
-      Destructor, Constructor.\r
-      \r
-      @param\r
-      @return    \r
-    **/\r
-    private void collectLibInstanceInfo(){\r
-        int index;\r
-\r
-        String libConstructName = null;\r
-        String libDestructName = null;\r
-        String[] setVirtuals = null;\r
-        String[] exitBoots = null;\r
-\r
-        ModuleIdentification[] libraryIdList = SurfaceAreaQuery\r
-                                               .getLibraryInstance(this.arch);\r
-        try {\r
-            if (libraryIdList != null) {\r
-                //\r
-                // Reorder library instance sequence.\r
-                //\r
-                AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList,\r
-                                                               this.arch);\r
-                List<ModuleIdentification> orderList = libOrder\r
-                                                       .orderLibInstance();\r
-\r
-                if (orderList != null) {\r
-                    //\r
-                    // Process library instance one by one.\r
-                    //\r
-                    for (int i = 0; i < orderList.size(); i++) {\r
-\r
-                        //\r
-                        // Get library instance basename.\r
-                        //\r
-                        ModuleIdentification libInstanceId = orderList.get(i);\r
-\r
-                        //\r
-                        // Get override map\r
-                        //\r
-\r
-                        Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
-                        SurfaceAreaQuery.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
-\r
-                        //\r
-                        // Add those ppi, protocol, guid in global ppi,\r
-                        // protocol, guid\r
-                        // list.\r
-                        //\r
-                        for (index = 0; index < ppiList.length; index++) {\r
-                            this.mPpiList.add(ppiList[index]);\r
-                        }\r
+       }\r
 \r
-                        for (index = 0; index < ppiNotifyList.length; index++) {\r
-                            this.mPpiList.add(ppiNotifyList[index]);\r
-                        }\r
-\r
-                        for (index = 0; index < protocolList.length; index++) {\r
-                            this.mProtocolList.add(protocolList[index]);\r
-                        }\r
-\r
-                        for (index = 0; index < protocolNotifyList.length; index++) {\r
-                            this.mProtocolList.add(protocolNotifyList[index]);\r
-                        }\r
-\r
-                        for (index = 0; index < guidList.length; index++) {\r
-                            this.mGuidList.add(guidList[index]);\r
-                        }\r
-                        for (index = 0; index < pkgList.length; index++) {\r
-                            if (!this.mDepPkgList.contains(pkgList[index])) {\r
-                                this.mDepPkgList.add(pkgList[index]);\r
-                            }\r
-                        }\r
-\r
-                        //\r
-                        // 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
-\r
-                        //\r
-                        // Collect SetVirtualAddressMapCallBack and\r
-                        // ExitBootServiceCallBack.\r
-                        //\r
-                        setVirtuals = SurfaceAreaQuery.getSetVirtualAddressMapCallBackArray();\r
-                        exitBoots = SurfaceAreaQuery.getExitBootServicesCallBackArray();\r
-                        if (setVirtuals != null) {\r
-                            for (int j = 0; j < setVirtuals.length; j++) {\r
-                                this.setVirtalAddList.add(setVirtuals[j]);\r
-                            }\r
-                        }\r
-                        if (exitBoots != null) {\r
-                            for (int k = 0; k < exitBoots.length; k++) {\r
-                                this.exitBootServiceList.add(exitBoots[k]);\r
-                            }\r
-                        }\r
-                        SurfaceAreaQuery.pop();\r
-                        //\r
-                        // Add dependent library instance constructor function.\r
-                        //\r
-                        if (libConstructName != null) {\r
-                            this.libConstructList.add(libConstructName);\r
-                        }\r
-                        //\r
-                        // Add dependent library instance destructor fuction.\r
-                        //\r
-                        if (libDestructName != null) {\r
-                            this.libDestructList.add(libDestructName);\r
-                        }\r
-                    }\r
-                }\r
-\r
-            }\r
-\r
-        } catch (Exception e) {\r
-            System.out.println(e.getMessage());\r
-            System.out.println("Collect library instance failed!");\r
-        }\r
-    }\r
 }\r