]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/pcd/entity/MemoryDatabaseManager.java
Support putting unreference DYNAMIC_EX PCD into Pcd runtime database.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / entity / MemoryDatabaseManager.java
index b03cddeed4cd98e80cfe8b86e75007080f10a989..2e29106323e22d13798b59462021160ccb14029d 100644 (file)
@@ -15,20 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 package org.tianocore.build.pcd.entity;\r
 \r
-import java.io.BufferedWriter;\r
-import java.io.File;\r
-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
 import java.util.UUID;\r
 \r
-import org.tianocore.build.pcd.action.ActionMessage;\r
+import org.tianocore.build.pcd.exception.EntityException;\r
 \r
 /** Database hold all PCD information comes from SPD, MSA, FPD file in memory.\r
 **/\r
@@ -141,12 +134,10 @@ public class MemoryDatabaseManager {
     private ArrayList getDynamicRecordArray() {\r
         Token[]     tokenArray  =   getRecordArray();\r
         int         index       =   0;\r
-        int         count       =   0;\r
         ArrayList<Token>   al   =   new ArrayList<Token>();\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
+            if (tokenArray[index].isDynamicPCD) {\r
                 al.add(tokenArray[index]);\r
             }\r
         }\r
@@ -160,8 +151,10 @@ public class MemoryDatabaseManager {
           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
+     * @throws EntityException \r
     **/\r
-    public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe) {\r
+    public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe) \r
+        throws EntityException {\r
         int                     usageInstanceIndex  =   0;\r
         int                     index               =   0;\r
         ArrayList               tokenArrayList      =   getDynamicRecordArray();\r
@@ -186,10 +179,34 @@ public class MemoryDatabaseManager {
                 }\r
             }\r
 \r
-            // If no PEI components reference the PCD entry, we insert it to DXE list\r
+            //\r
+            // If no PEI components reference the PCD entry, \r
+            // we check if it is referenced in DXE driver. \r
             //\r
             if (!found) {\r
-                dxe.add(token);\r
+                if (token.consumers != null) {\r
+                    usageInstanceArray = token.consumers.entrySet().toArray();\r
+                    for (usageInstanceIndex = 0; usageInstanceIndex < token.consumers.size(); usageInstanceIndex ++) {\r
+                        usageInstance =(UsageInstance) (((Map.Entry)usageInstanceArray[usageInstanceIndex]).getValue());\r
+                        if (usageInstance.isDxePhaseComponent()) {\r
+                            dxe.add(token);\r
+                            found = true;\r
+                            break;\r
+                        }\r
+                    }\r
+                }\r
+                \r
+                if (!found) {\r
+                    if (token.isDynamicPCD && token.consumers.size() == 0) {\r
+                        dxe.add(token);\r
+                    } else {\r
+                        //\r
+                        // We only support Dynamice(EX) type for PEI and DXE phase.\r
+                        // If it is not referenced in either PEI or DXE, throw exception now.\r
+                        //\r
+                        throw new EntityException("Dynamic(EX) PCD Entries are referenced in module that is not in PEI phase nor in DXE phase.");\r
+                    }\r
+                }\r
             }\r
         }\r
 \r