]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/pcd/entity/MemoryDatabaseManager.java
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@250 6f19259b...
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / entity / MemoryDatabaseManager.java
index 6f4f8949ef06a7bc3bb78b5b2057ac21c2ddc428..2c2433a95cac3e4801b041386eb4cf6444e243a8 100644 (file)
@@ -20,13 +20,26 @@ import java.io.File;
 import java.io.FileWriter;\r
 import java.io.IOException;\r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.Comparator;\r
 import java.util.HashMap;\r
+import java.util.Hashtable;\r
 import java.util.List;\r
 import java.util.Map;\r
 \r
 import org.tianocore.build.autogen.CommonDefinition;\r
 import org.tianocore.build.pcd.action.ActionMessage;\r
 \r
+class AlignmentSizeComp implements Comparator {\r
+    public int compare (Object a, Object b) {\r
+        Token tA = (Token) a;\r
+        Token tB = (Token) b;\r
+\r
+        return Token.getAutogendatumTypeAlignmentSize(tA.datumType) \r
+                - Token.getAutogendatumTypeAlignmentSize(tB.datumType);\r
+    }\r
+}\r
+\r
 /** Database hold all PCD information comes from SPD, MSA, FPD file in memory.\r
 **/\r
 public class MemoryDatabaseManager {\r
@@ -40,6 +53,11 @@ public class MemoryDatabaseManager {
     ///\r
     private static String              logFileName    = null;\r
 \r
+    public static String PcdPeimHString       = "";\r
+               public static String PcdPeimCString                             = "";\r
+    public static String PcdDxeHString                         = "";\r
+    public static String PcdDxeCString                         = "";\r
+\r
     /**\r
       Constructure function\r
     **/\r
@@ -135,7 +153,81 @@ public class MemoryDatabaseManager {
         return tokenArray;\r
     }\r
 \r
+\r
+    private ArrayList getDynamicRecordArray() {\r
+        Token[]     tokenArray  =   getRecordArray();\r
+        int         index       =   0;\r
+        int         count       =   0;\r
+        ArrayList   al          =   new ArrayList();\r
+\r
+        for (index = 0; index < tokenArray.length; index++) {\r
+            if (tokenArray[index].pcdType == Token.PCD_TYPE.DYNAMIC ||\r
+                tokenArray[index].pcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
+                al.add(tokenArray[index]);\r
+            }\r
+        }\r
+\r
+        return al;\r
+    }\r
+\r
+\r
     /**\r
+      Get the token record array contained all PCD token referenced by PEI phase.\r
+          The output array is sorted based on descending order of the size of alignment for each feilds.\r
+\r
+      @return the token record array contained all PCD token referenced in PEI phase.\r
+    **/\r
+    public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe) {\r
+        int                     usageInstanceIndex  =   0;\r
+        int                     index               =   0;\r
+        ArrayList               tokenArrayList      =   getDynamicRecordArray();\r
+        List<UsageInstance>     usageInstanceArray  =   null;\r
+        UsageInstance           usageInstance       =   null;\r
+\r
+                               //pei = new ArrayList<Token>();\r
+                               //dxe = new ArrayList<Token>();\r
+\r
+        for (index = 0; index < tokenArrayList.size(); index++) {\r
+            boolean found   =   false;\r
+            Token       token = (Token) tokenArrayList.get(index);\r
+            if (token.producers != null) {\r
+                usageInstanceArray = token.producers;\r
+                for (usageInstanceIndex = 0; usageInstanceIndex < usageInstanceArray.size(); usageInstanceIndex++) {\r
+                    usageInstance = (UsageInstance) usageInstanceArray.get(usageInstanceIndex);\r
+                    if (CommonDefinition.isPeiPhaseComponent(usageInstance.componentType)) {\r
+                        pei.add(token);\r
+                        found = true;\r
+                        break;\r
+                    }\r
+                }\r
+\r
+            }\r
+            if (!found) {\r
+                if (token.consumers != null) {\r
+                    usageInstanceArray = token.consumers;\r
+                    for (usageInstanceIndex = 0; usageInstanceIndex < usageInstanceArray.size(); usageInstanceIndex ++) {\r
+                        usageInstance =(UsageInstance) usageInstanceArray.get(usageInstanceIndex);\r
+                        if (CommonDefinition.isPeiPhaseComponent(usageInstance.componentType)) {\r
+                            pei.add(token);\r
+                                                                                                               found = true;\r
+                            break;\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+\r
+                                               //\r
+                                               // If no PEI components reference the PCD entry, we insert it to DXE list\r
+                                               //\r
+                                               if (!found) {\r
+                                                               dxe.add(token);\r
+                                               }\r
+        }\r
+\r
+                               return;\r
+    }\r
+\r
+               /**\r
       Get all PCD record for a module according to module's name.\r
      \r
       @param moduleName  the name of module.\r