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
///\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
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