]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix EDKT272.
authorqouyang <qouyang@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 21 Sep 2006 08:01:14 +0000 (08:01 +0000)
committerqouyang <qouyang@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 21 Sep 2006 08:01:14 +0000 (08:01 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1589 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java

index 8c92bef43ade581357877f6127a785fbb7152eda..b6e2800765ca009d35a5bb70c7ff6e522f7f244a 100644 (file)
@@ -781,7 +781,6 @@ public class AutoGen {
                                         "Module type = 'PEI_CORE', can have only one module entry point!");\r
             } else {\r
                 fileBuffer.append("EFI_STATUS\r\n");\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
                 fileBuffer.append(entryPointList[0]);\r
                 fileBuffer.append(" (\r\n");\r
                 fileBuffer\r
@@ -814,7 +813,6 @@ public class AutoGen {
             } else {\r
 \r
                 fileBuffer.append("VOID\r\n");\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
                 fileBuffer.append(entryPointList[0]);\r
                 fileBuffer.append(" (\n");\r
                 fileBuffer.append("  IN VOID  *HobStart\r\n");\r
@@ -851,7 +849,6 @@ public class AutoGen {
             }\r
             for (int i = 0; i < entryPointList.length; i++) {\r
                 fileBuffer.append("EFI_STATUS\r\n");\r
             }\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
                 fileBuffer.append(entryPointList[i]);\r
                 fileBuffer.append(" (\r\n");\r
                 fileBuffer\r
@@ -920,7 +917,6 @@ public class AutoGen {
             } else {\r
                 for (int i = 0; i < entryPointList.length; i++) {\r
                     fileBuffer.append("EFI_STATUS\r\n");\r
             } 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
                     fileBuffer.append(entryPointList[i]);\r
                     fileBuffer.append(" (\r\n");\r
                     fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
@@ -987,7 +983,6 @@ public class AutoGen {
             if (unloadImageList != null) {\r
                 for (int i = 0; i < unloadImageList.length; i++) {\r
                     fileBuffer.append("EFI_STATUS\r\n");\r
             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
                     fileBuffer.append(unloadImageList[i]);\r
                     fileBuffer.append(" (\r\n");\r
                     fileBuffer\r
@@ -1067,7 +1062,6 @@ public class AutoGen {
                 for (int i = 0; i < entryPointList.length; i++) {\r
 \r
                     fileBuffer.append("EFI_STATUS\r\n");\r
                 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
                     fileBuffer.append(entryPointList[i]);\r
                     fileBuffer.append(" (\r\n");\r
                     fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
@@ -1146,12 +1140,17 @@ public class AutoGen {
             //\r
             // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.\r
             //\r
             //\r
             // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.\r
             //\r
-            \r
+            //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();\r
+            //\r
+            // Remover duplicate unload entry point.\r
+            //\r
+            //entryPointList = CommonDefinition.remDupString(entryPointList);\r
+            //entryPointCount = 0;\r
                        unloadImageCount = 0;\r
             if (unloadImageList != null) {\r
                 for (int i = 0; i < unloadImageList.length; i++) {\r
                     fileBuffer.append("EFI_STATUS\r\n");\r
                        unloadImageCount = 0;\r
             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("EFIAPI\r\n");\r
                     fileBuffer.append(unloadImageList[i]);\r
                     fileBuffer.append(" (\r\n");\r
                     fileBuffer\r
                     fileBuffer.append(unloadImageList[i]);\r
                     fileBuffer.append(" (\r\n");\r
                     fileBuffer\r
@@ -1639,88 +1638,76 @@ public class AutoGen {
     throws EdkException {\r
 \r
         //\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
-\r
-        String[] drvBindList = saq.getDriverBindingArray();\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
         //\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 = saq.getComponentNameArray();\r
-        String[] compConfList = saq.getDriverConfigArray();\r
-        String[] compDiagList = saq.getDriverDiagArray();\r
-\r
+        // inital BitMask;\r
+               // \r
         int BitMask = 0;\r
 \r
         //\r
         // Write driver binding protocol extern to autogen.c\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
         }\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 AutoGenException(\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
 \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 AutoGenException(\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
         //\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 AutoGenException(\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
         //\r
         // Write driver module protocol bitmask.\r
         //\r
@@ -1735,49 +1722,58 @@ public class AutoGen {
         fileBuffer\r
         .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN  _gDriverModelProtocolListEntries = ");\r
 \r
         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.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
         .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
             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("  &");\r
-            fileBuffer.append(drvBindList[i]);\r
+            fileBuffer.append(driverBindingGroup[i][0]);\r
             fileBuffer.append(", \r\n");\r
             fileBuffer.append(", \r\n");\r
+                       \r
 \r
 \r
-            if (compNamList != null) {\r
+            if (driverBindingGroup[i][1] != null) {\r
                 fileBuffer.append("  &");\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
                 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("  &");\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
                 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("  &");\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
             } 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
     }\r
 \r
     /**\r
index 373633521e85b084418330b6342f4a1ccc3be23a..9a1ca98d189bc175e9d6d5e3f011f6e56aa71781 100644 (file)
@@ -23,53 +23,25 @@ import java.util.Stack;
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
 \r
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
 \r
-import org.w3c.dom.Node;\r
-\r
+import org.tianocore.ExternsDocument.Externs.Extern;\r
 import org.apache.xmlbeans.XmlObject;\r
 import org.apache.xmlbeans.XmlString;\r
 import org.apache.xmlbeans.XmlObject;\r
 import org.apache.xmlbeans.XmlString;\r
-\r
-import org.tianocore.BuildOptionsDocument;\r
-import org.tianocore.CNameType;\r
-import org.tianocore.ExternsDocument;\r
-import org.tianocore.FileNameConvention;\r
-import org.tianocore.FvImagesDocument;\r
-import org.tianocore.GuidDeclarationsDocument;\r
-import org.tianocore.GuidsDocument;\r
-import org.tianocore.LibrariesDocument;\r
-import org.tianocore.LibraryClassDeclarationsDocument;\r
-import org.tianocore.LibraryClassDocument;\r
-import org.tianocore.ModuleDefinitionsDocument;\r
-import org.tianocore.ModuleSADocument;\r
-import org.tianocore.ModuleSaBuildOptionsDocument;\r
-import org.tianocore.ModuleTypeDef;\r
-import org.tianocore.MsaFilesDocument;\r
-import org.tianocore.MsaHeaderDocument;\r
-import org.tianocore.OptionDocument;\r
-import org.tianocore.PPIsDocument;\r
-import org.tianocore.PackageDependenciesDocument;\r
-import org.tianocore.PackageHeadersDocument;\r
-import org.tianocore.PcdCodedDocument;\r
-import org.tianocore.PlatformDefinitionsDocument;\r
-import org.tianocore.PlatformHeaderDocument;\r
-import org.tianocore.PpiDeclarationsDocument;\r
-import org.tianocore.ProtocolDeclarationsDocument;\r
-import org.tianocore.Sentence;\r
-import org.tianocore.SpdHeaderDocument;\r
-import org.tianocore.UserExtensionsDocument;\r
+import org.tianocore.*;\r
+import org.tianocore.ExternsDocument.Externs;\r
 import org.tianocore.FilenameDocument.Filename;\r
 import org.tianocore.FilenameDocument.Filename;\r
+import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
 import org.tianocore.MsaHeaderDocument.MsaHeader;\r
 import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r
 import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
 import org.tianocore.MsaHeaderDocument.MsaHeader;\r
 import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r
 import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
-import org.tianocore.PcdDriverTypes;\r
-\r
-import org.tianocore.common.exception.EdkException;\r
-import org.tianocore.common.logger.EdkLog;\r
+import org.tianocore.build.autogen.CommonDefinition;\r
 import org.tianocore.build.id.FpdModuleIdentification;\r
 import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.id.PackageIdentification;\r
 import org.tianocore.build.id.PlatformIdentification;\r
 import org.tianocore.build.toolchain.ToolChainInfo;\r
 import org.tianocore.build.id.FpdModuleIdentification;\r
 import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.id.PackageIdentification;\r
 import org.tianocore.build.id.PlatformIdentification;\r
 import org.tianocore.build.toolchain.ToolChainInfo;\r
-import org.tianocore.build.autogen.CommonDefinition;\r
+import org.tianocore.common.exception.EdkException;\r
+import org.tianocore.common.logger.EdkLog;\r
+import org.w3c.dom.Node;\r
 \r
 /**\r
  * SurfaceAreaQuery class is used to query Surface Area information from msa,\r
 \r
 /**\r
  * SurfaceAreaQuery class is used to query Surface Area information from msa,\r
@@ -1251,6 +1223,62 @@ public class SurfaceAreaQuery {
         return getCNames("Externs", xPath);\r
     }\r
 \r
         return getCNames("Externs", xPath);\r
     }\r
 \r
+    /**\r
+     * Retrive DriverBinding, ComponentName, DriverConfig,\r
+     * DriverDiag group array\r
+     * \r
+     * @returns DriverBinding group name list if elements are found\r
+     *        at the known xpath\r
+     * @returns null if nothing is there\r
+     */\r
+       public String[][] getExternProtocolGroup() {\r
+               String[] xPath = new String[] {"/Extern"};\r
+               Object[] returns = get("Externs",xPath);\r
+\r
+        if (returns == null) {\r
+                       return new String[0][4];\r
+               }\r
+               List<Extern> externList = new ArrayList<Extern>();\r
+               for (int i = 0; i < returns.length; i++) {\r
+                       org.tianocore.ExternsDocument.Externs.Extern extern = (org.tianocore.ExternsDocument.Externs.Extern)returns[i];\r
+                       if (extern.getDriverBinding() != null) {\r
+                               externList.add(extern);\r
+                       }\r
+               }\r
+\r
+               String[][] externGroup = new String[externList.size()][4];\r
+               for (int i = 0; i < externList.size(); i++) {\r
+            String driverBindingStr = externList.get(i).getDriverBinding();\r
+                       if ( driverBindingStr != null){\r
+                               externGroup[i][0] = driverBindingStr;\r
+                       } else {\r
+                               externGroup[i][0] = null;\r
+                       }\r
+\r
+                       String componentNameStr = externList.get(i).getComponentName();\r
+                       if (componentNameStr != null) {\r
+                               externGroup[i][1] = componentNameStr;\r
+                       } else {\r
+                               externGroup[i][1] = null;\r
+                       }\r
+\r
+                       String driverConfigStr = externList.get(i).getDriverConfig();\r
+                       if (driverConfigStr != null) {\r
+                               externGroup[i][2] = driverConfigStr;\r
+                       } else {\r
+                               externGroup[i][2] = null;\r
+                       }\r
+\r
+                       String driverDiagStr = externList.get(i).getDriverDiag();\r
+                       if (driverDiagStr != null) {\r
+                           externGroup[i][3] = driverDiagStr;\r
+                       } else {\r
+                               externGroup[i][3] = null;\r
+                       }\r
+               }\r
+               return externGroup;\r
+       }\r
+    \r
     /**\r
      * Retrive SetVirtualAddressMapCallBack names\r
      *\r
     /**\r
      * Retrive SetVirtualAddressMapCallBack names\r
      *\r