X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fpcd%2Faction%2FCollectPCDAction.java;h=8242a4c87c363dca42b14fbc237c6a635f683b38;hp=cf94885847058374f4a0fb5fa4a099795c76f5ae;hb=eece174ad00f11db8688a36f7c7ef57c9ced98db;hpb=10d8dee566d0d882f97b8b89950702c1237a1b55 diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java index cf94885847..8242a4c87c 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java @@ -25,18 +25,26 @@ import java.math.BigInteger; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions; import org.tianocore.FrameworkModulesDocument; -import org.tianocore.FrameworkPlatformDescriptionDocument; import org.tianocore.ModuleSADocument; +import org.tianocore.PcdBuildDefinitionDocument; import org.tianocore.PcdBuildDefinitionDocument.PcdBuildDefinition; +import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.build.autogen.CommonDefinition; +import org.tianocore.build.fpd.FpdParserTask; import org.tianocore.build.global.GlobalData; -import org.tianocore.build.global.SurfaceAreaQuery; +import org.tianocore.build.id.FpdModuleIdentification; import org.tianocore.build.pcd.action.ActionMessage; import org.tianocore.build.pcd.entity.DynamicTokenValue; import org.tianocore.build.pcd.entity.MemoryDatabaseManager; @@ -44,7 +52,16 @@ import org.tianocore.build.pcd.entity.SkuInstance; import org.tianocore.build.pcd.entity.Token; import org.tianocore.build.pcd.entity.UsageInstance; import org.tianocore.build.pcd.exception.EntityException; -import org.tianocore.ModuleTypeDef; + +/** + CStructTypeDeclaration + + This class is used to store the declaration string, such as + "UINT32 PcdPlatformFlashBaseAddress", of + each memember in the C structure, which is a standard C language + feature used to implement a simple and efficient database for + dynamic(ex) type PCD entry. +**/ class CStructTypeDeclaration { String key; @@ -60,6 +77,12 @@ class CStructTypeDeclaration { } } +/** + StringTable + + This class is used to store the String in a PCD database. + +**/ class StringTable { private ArrayList al; private ArrayList alComments; @@ -84,15 +107,11 @@ class StringTable { return len == 0 ? 1 : len; } - public int getTableLen () { - return al.size() == 0 ? 1 : al.size(); - } - public String getExistanceMacro () { return String.format(PcdDatabase.StringTableExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE"); } - public void genCodeNew (ArrayList declaList, HashMap instTable) { + public void genCode (ArrayList declaList, HashMap instTable) { final String stringTable = "StringTable"; final String tab = "\t"; final String newLine = "\r\n"; @@ -107,7 +126,7 @@ class StringTable { // If we have a empty StringTable // if (al.size() == 0) { - cDeclCode += tab + String.format("UINT16 %s[1]; /* StringTable is Empty */", stringTable) + newLine; + cDeclCode += String.format("%-20s%s[1]; /* StringTable is empty */", "UINT16", stringTable) + newLine; decl = new CStructTypeDeclaration ( stringTable, 2, @@ -116,7 +135,7 @@ class StringTable { ); declaList.add(decl); - cInstCode = " { 0 } " + String.format("/* %s */", stringTable); + cInstCode = String.format("/* %s */", stringTable) + newLine + tab + "{ 0 }"; instTable.put(stringTable, cInstCode); } else { @@ -137,11 +156,15 @@ class StringTable { stringTableName = String.format("%s_%d", stringTable, i); cDeclCode += tab; } - cDeclCode += String.format("UINT16 %s[%d]; /* %s */", stringTableName, str.length() + 1, alComments.get(i)) + newLine; + cDeclCode += String.format("%-20s%s[%d]; /* %s */", "UINT16", + stringTableName, str.length() + 1, + alComments.get(i)) + + newLine; if (i == 0) { cInstCode = "/* StringTable */" + newLine; } + cInstCode += tab + String.format("L\"%s\" /* %s */", al.get(i), alComments.get(i)); if (i != al.size() - 1) { cInstCode += commaNewLine; @@ -160,59 +183,6 @@ class StringTable { } } - public String getTypeDeclaration () { - - String output; - - final String stringTable = "StringTable"; - final String tab = "\t"; - final String newLine = ";\r\n"; - - output = "/* StringTable */\r\n"; - - if (al.size() == 0) { - output += tab + String.format("UINT16 %s[1] /* StringTable is Empty */", stringTable) + newLine; - } - - for (int i = 0; i < al.size(); i++) { - String str = al.get(i); - - if (i == 0) { - // - // StringTable is a well-known name in the PCD DXE driver - // - output += tab + String.format("UINT16 %s[%d] /* %s */", stringTable, str.length() + 1, alComments.get(i)) + newLine; - } else { - output += tab + String.format("UINT16 %s_%d[%d] /* %s */", stringTable, i, str.length() + 1, alComments.get(i)) + newLine; - } - } - - return output; - - } - - public ArrayList getInstantiation () { - ArrayList output = new ArrayList(); - - output.add("/* StringTable */"); - - if (al.size() == 0) { - output.add("{ 0 }"); - } else { - String str; - - for (int i = 0; i < al.size(); i++) { - str = String.format("L\"%s\" /* %s */", al.get(i), alComments.get(i)); - if (i != al.size() - 1) { - str += ","; - } - output.add(str); - } - } - - return output; - } - public int add (String inputStr, Token token) { int i; int pos; @@ -237,7 +207,6 @@ class StringTable { return pos; } pos = s.length() + 1; - } i = len; @@ -252,20 +221,35 @@ class StringTable { } } +/** + SizeTable + + This class is used to store the Size information for + POINTER TYPE PCD entry in a PCD database. + +**/ class SizeTable { - private ArrayList al; + private ArrayList> al; private ArrayList alComments; - private String phase; private int len; + private String phase; public SizeTable (String phase) { - this.phase = phase; - al = new ArrayList(); + al = new ArrayList>(); alComments = new ArrayList(); len = 0; + this.phase = phase; + } + + public String getSizeMacro () { + return String.format(PcdDatabase.SizeTableSizeMacro, phase, getSize()); + } + + private int getSize() { + return len == 0 ? 1 : len; } - public void genCodeNew (ArrayList declaList, HashMap instTable, String phase) { + public void genCode (ArrayList declaList, HashMap instTable, String phase) { final String name = "SizeTable"; CStructTypeDeclaration decl; @@ -285,27 +269,33 @@ class SizeTable { instTable.put(name, cCode); } - public String getTypeDeclaration () { - return String.format(PcdDatabase.SizeTableDeclaration, phase); - } - - public ArrayList getInstantiation () { + private ArrayList getInstantiation () { + final String comma = ","; ArrayList Output = new ArrayList(); Output.add("/* SizeTable */"); Output.add("{"); if (al.size() == 0) { - Output.add("0"); + Output.add("\t0"); } else { for (int index = 0; index < al.size(); index++) { - Integer n = al.get(index); - String str = "\t" + n.toString(); + ArrayList ial = al.get(index); + + String str = "\t"; + + for (int index2 = 0; index2 < ial.size(); index2++) { + str += " " + ial.get(index2).toString(); + if (index2 != ial.size() - 1) { + str += comma; + } + } + str += " /* " + alComments.get(index) + " */"; + if (index != (al.size() - 1)) { - str += ","; + str += comma; } - str += " /* " + alComments.get(index) + " */"; Output.add(str); } @@ -315,22 +305,32 @@ class SizeTable { return Output; } - public int add (Token token) { - int index = len; + public void add (Token token) { - len++; - al.add(token.datumSize); + // + // We only have size information for POINTER type PCD entry. + // + if (token.datumType != Token.DATUM_TYPE.POINTER) { + return; + } + + ArrayList ial = token.getPointerTypeSize(); + + len+= ial.size(); + + al.add(ial); alComments.add(token.getPrimaryKeyString()); - return index; + return; } - public int getTableLen () { - return al.size() == 0 ? 1 : al.size(); - } - } +/** + GuidTable + + This class is used to store the GUIDs in a PCD database. +**/ class GuidTable { private ArrayList al; private ArrayList alComments; @@ -358,7 +358,7 @@ class GuidTable { return String.format(PcdDatabase.GuidTableExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE"); } - public void genCodeNew (ArrayList declaList, HashMap instTable, String phase) { + public void genCode (ArrayList declaList, HashMap instTable, String phase) { final String name = "GuidTable"; CStructTypeDeclaration decl; @@ -367,7 +367,7 @@ class GuidTable { cCode += String.format(PcdDatabase.GuidTableDeclaration, phase); decl = new CStructTypeDeclaration ( name, - 8, + 4, cCode, true ); @@ -378,16 +378,12 @@ class GuidTable { instTable.put(name, cCode); } - public String getTypeDeclaration () { - return String.format(PcdDatabase.GuidTableDeclaration, phase); - } - private String getUuidCString (UUID uuid) { String[] guidStrArray; guidStrArray =(uuid.toString()).split("-"); - return String.format("{ 0x%s, 0x%s, 0x%s, { 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s } }", + return String.format("{0x%s, 0x%s, 0x%s, {0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s}}", guidStrArray[0], guidStrArray[1], guidStrArray[2], @@ -402,13 +398,14 @@ class GuidTable { ); } - public ArrayList getInstantiation () { + private ArrayList getInstantiation () { ArrayList Output = new ArrayList(); Output.add("/* GuidTable */"); Output.add("{"); + if (al.size() == 0) { - Output.add(getUuidCString(new UUID(0, 0))); + Output.add("\t" + getUuidCString(new UUID(0, 0))); } for (int i = 0; i < al.size(); i++) { @@ -433,7 +430,7 @@ class GuidTable { // If so, return the GuidTable index. // for (int i = 0; i < al.size(); i++) { - if (al.get(i).equals(uuid)) { + if (al.get(i).compareTo(uuid) == 0) { return i; } } @@ -448,12 +445,14 @@ class GuidTable { return len - 1; } - public int getTableLen () { - return al.size() == 0 ? 0 : al.size(); - } - } +/** + SkuIdTable + + This class is used to store the SKU IDs in a PCD database. + +**/ class SkuIdTable { private ArrayList al; private ArrayList alComment; @@ -479,7 +478,7 @@ class SkuIdTable { return String.format(PcdDatabase.SkuTableExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE"); } - public void genCodeNew (ArrayList declaList, HashMap instTable, String phase) { + public void genCode (ArrayList declaList, HashMap instTable, String phase) { final String name = "SkuIdTable"; CStructTypeDeclaration decl; @@ -505,7 +504,7 @@ class SkuIdTable { decl = new CStructTypeDeclaration ( "SystemSkuId", 1, - "SKU_ID SystemSkuId;\r\n", + String.format("%-20sSystemSkuId;\r\n", "SKU_ID"), true ); declaList.add(decl); @@ -515,11 +514,7 @@ class SkuIdTable { } - public String getTypeDeclaration () { - return String.format(PcdDatabase.SkuIdTableDeclaration, phase); - } - - public ArrayList getInstantiation () { + private ArrayList getInstantiation () { ArrayList Output = new ArrayList (); Output.add("/* SkuIdTable */"); @@ -599,10 +594,6 @@ class SkuIdTable { return index; } - public int getTableLen () { - return al.size() == 0 ? 1 : al.size(); - } - } class LocalTokenNumberTable { @@ -632,7 +623,7 @@ class LocalTokenNumberTable { return String.format(PcdDatabase.DatabaseExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE"); } - public void genCodeNew (ArrayList declaList, HashMap instTable, String phase) { + public void genCode (ArrayList declaList, HashMap instTable, String phase) { final String name = "LocalTokenNumberTable"; CStructTypeDeclaration decl; @@ -651,18 +642,14 @@ class LocalTokenNumberTable { instTable.put(name, cCode); } - public String getTypeDeclaration () { - return String.format(PcdDatabase.LocalTokenNumberTableDeclaration, phase); - } - - public ArrayList getInstantiation () { + private ArrayList getInstantiation () { ArrayList output = new ArrayList(); output.add("/* LocalTokenNumberTable */"); output.add("{"); if (al.size() == 0) { - output.add("0"); + output.add("\t0"); } for (int index = 0; index < al.size(); index++) { @@ -710,6 +697,25 @@ class LocalTokenNumberTable { str += " | PCD_TYPE_VPD"; } + switch (token.datumType) { + case UINT8: + case BOOLEAN: + str += " | PCD_DATUM_TYPE_UINT8"; + break; + case UINT16: + str += " | PCD_DATUM_TYPE_UINT16"; + break; + case UINT32: + str += " | PCD_DATUM_TYPE_UINT32"; + break; + case UINT64: + str += " | PCD_DATUM_TYPE_UINT64"; + break; + case POINTER: + str += " | PCD_DATUM_TYPE_POINTER"; + break; + } + al.add(str); alComment.add(token.getPrimaryKeyString()); @@ -717,8 +723,22 @@ class LocalTokenNumberTable { } } +/** + ExMapTable + + This class is used to store the table of mapping information + between DynamicEX ID pair(Guid, TokenNumber) and + the local token number assigned by PcdDatabase class. +**/ class ExMapTable { + /** + ExTriplet + + This class is used to store the mapping information + between DynamicEX ID pair(Guid, TokenNumber) and + the local token number assigned by PcdDatabase class. + **/ class ExTriplet { public Integer guidTableIdx; public Long exTokenNumber; @@ -732,7 +752,7 @@ class ExMapTable { } private ArrayList al; - private ArrayList alComment; + private Map alComment; private String phase; private int len; private int bodyLineNum; @@ -740,7 +760,7 @@ class ExMapTable { public ExMapTable (String phase) { this.phase = phase; al = new ArrayList(); - alComment = new ArrayList(); + alComment = new HashMap(); bodyLineNum = 0; len = 0; } @@ -754,7 +774,7 @@ class ExMapTable { return String.format(PcdDatabase.ExMapTableExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE"); } - public void genCodeNew (ArrayList declaList, HashMap instTable, String phase) { + public void genCode (ArrayList declaList, HashMap instTable, String phase) { final String exMapTableName = "ExMapTable"; sortTable(); @@ -776,11 +796,7 @@ class ExMapTable { instTable.put(exMapTableName, cCode); } - public String getTypeDeclaration () { - return String.format(PcdDatabase.ExMapTableDeclaration, phase); - } - - public ArrayList getInstantiation () { + private ArrayList getInstantiation () { ArrayList Output = new ArrayList(); Output.add("/* ExMapTable */"); @@ -799,7 +815,7 @@ class ExMapTable { str += e.localTokenIdx.toString() + ", "; str += e.guidTableIdx.toString(); - str += "}" + " /* " + alComment.get(index) + " */" ; + str += "}" + " /* " + alComment.get(e) + " */" ; if (index != al.size() - 1) { str += ","; @@ -818,14 +834,16 @@ class ExMapTable { public int add (int localTokenIdx, long exTokenNum, int guidTableIdx, String name) { int index = len; - len++; - al.add(new ExTriplet(guidTableIdx, exTokenNum, localTokenIdx)); - alComment.add(name); + len++; + ExTriplet et = new ExTriplet(guidTableIdx, exTokenNum, localTokenIdx); + + al.add(et); + alComment.put(et, name); return index; } - public int getTableLen () { + private int getTableLen () { return al.size() == 0 ? 1 : al.size(); } @@ -839,12 +857,15 @@ class ExMapTable { class ExTripletComp implements Comparator { public int compare (ExTriplet a, ExTriplet b) { if (a.guidTableIdx == b.guidTableIdx ) { + // + // exTokenNumber is long, we can't use simple substraction. + // if (a.exTokenNumber > b.exTokenNumber) { return 1; - } else if (a.exTokenNumber > b.exTokenNumber) { - return 1; - } else { + } else if (a.exTokenNumber == b.exTokenNumber) { return 0; + } else { + return -1; } } @@ -858,18 +879,24 @@ class ExMapTable { } } +/** + PcdDatabase + + This class is used to generate C code for Autogen.h and Autogen.c of + a PCD service DXE driver and PCD service PEIM. +**/ class PcdDatabase { private final static int SkuHeadAlignmentSize = 4; private final String newLine = "\r\n"; private final String commaNewLine = ",\r\n"; private final String tab = "\t"; - public final static String ExMapTableDeclaration = "DYNAMICEX_MAPPING ExMapTable[%s_EXMAPPING_TABLE_SIZE];\r\n"; - public final static String GuidTableDeclaration = "EFI_GUID GuidTable[%s_GUID_TABLE_SIZE];\r\n"; - public final static String LocalTokenNumberTableDeclaration = "UINT32 LocalTokenNumberTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n"; - public final static String StringTableDeclaration = "UINT16 StringTable[%s_STRING_TABLE_SIZE];\r\n"; - public final static String SizeTableDeclaration = "UINT16 SizeTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n"; - public final static String SkuIdTableDeclaration = "UINT8 SkuIdTable[%s_SKUID_TABLE_SIZE];\r\n"; + public final static String ExMapTableDeclaration = "DYNAMICEX_MAPPING ExMapTable[%s_EXMAPPING_TABLE_SIZE];\r\n"; + public final static String GuidTableDeclaration = "EFI_GUID GuidTable[%s_GUID_TABLE_SIZE];\r\n"; + public final static String LocalTokenNumberTableDeclaration = "UINT32 LocalTokenNumberTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n"; + public final static String StringTableDeclaration = "UINT16 StringTable[%s_STRING_TABLE_SIZE];\r\n"; + public final static String SizeTableDeclaration = "SIZE_INFO SizeTable[%s_SIZE_TABLE_SIZE];\r\n"; + public final static String SkuIdTableDeclaration = "UINT8 SkuIdTable[%s_SKUID_TABLE_SIZE];\r\n"; public final static String ExMapTableSizeMacro = "#define %s_EXMAPPING_TABLE_SIZE %d\r\n"; @@ -877,6 +904,7 @@ class PcdDatabase { public final static String GuidTableSizeMacro = "#define %s_GUID_TABLE_SIZE %d\r\n"; public final static String LocalTokenNumberTableSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER_TABLE_SIZE %d\r\n"; public final static String LocalTokenNumberSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER %d\r\n"; + public final static String SizeTableSizeMacro = "#define %s_SIZE_TABLE_SIZE %d\r\n"; public final static String StringTableSizeMacro = "#define %s_STRING_TABLE_SIZE %d\r\n"; public final static String SkuIdTableSizeMacro = "#define %s_SKUID_TABLE_SIZE %d\r\n"; @@ -923,14 +951,21 @@ class PcdDatabase { private String hString; private String cString; - - class AlignmentSizeComp implements Comparator { - public int compare (Token a, Token b) { - return getAlignmentSize(b) - - getAlignmentSize(a); - } - } - + /** + Constructor for PcdDatabase class. + +

We have two PCD dynamic(ex) database for the Framework implementation. One + for PEI phase and the other for DXE phase.

+ + @param alTokens A ArrayList of Dynamic(EX) PCD entry. + @param exePhase The phase to generate PCD database for: valid input + is "PEI" or "DXE". + @param startLen The starting Local Token Number for the PCD database. For + PEI phase, the starting Local Token Number starts from 0. + For DXE phase, the starting Local Token Number starts + from the total number of PCD entry of PEI phase. + @return void + **/ public PcdDatabase (ArrayList alTokens, String exePhase, int startLen) { phase = exePhase; @@ -941,6 +976,11 @@ class PcdDatabase { sizeTable = new SizeTable(phase); exMapTable = new ExMapTable(phase); + // + // Local token number 0 is reserved for INVALID_TOKEN_NUMBER. + // So we will increment 1 for the startLen passed from the + // constructor. + // assignedTokenNumber = startLen + 1; this.alTokens = alTokens; } @@ -958,20 +998,26 @@ class PcdDatabase { return; } - private void getTwoGroupsOfTokens (ArrayList alTokens, List initTokens, List uninitTokens) { - for (int i = 0; i < alTokens.size(); i++) { - Token t = (Token)alTokens.get(i); - if (t.hasDefaultValue()) { - initTokens.add(t); - } else { - uninitTokens.add(t); - } + private int getDataTypeAlignmentSize (Token token) { + switch (token.datumType) { + case UINT8: + return 1; + case UINT16: + return 2; + case UINT32: + return 4; + case UINT64: + return 8; + case POINTER: + return 1; + case BOOLEAN: + return 1; + default: + return 1; } - - return; } - - private int getDataTypeAlignmentSize (Token token) { + + private int getHiiPtrTypeAlignmentSize(Token token) { switch (token.datumType) { case UINT8: return 1; @@ -982,6 +1028,11 @@ class PcdDatabase { case UINT64: return 8; case POINTER: + if (token.isHiiEnable()) { + if (token.isHiiDefaultValueUnicodeStringType()) { + return 2; + } + } return 1; case BOOLEAN: return 1; @@ -1051,7 +1102,7 @@ class PcdDatabase { } - private void ProcessTokensNew (List tokens, + private void ProcessTokens (List tokens, ArrayList cStructDeclList, HashMap cStructInstTable, String phase @@ -1071,9 +1122,9 @@ class PcdDatabase { // Add a mapping if this dynamic PCD entry is a EX type // if (t.isDynamicEx()) { - exMapTable.add(t.tokenNumber, + exMapTable.add((int)t.tokenNumber, t.dynamicExTokenNumber, - guidTable.add(t.tokenSpaceName, t.getPrimaryKeyString()), + guidTable.add(translateSchemaStringToUUID(t.tokenSpaceName), t.getPrimaryKeyString()), t.getPrimaryKeyString() ); } @@ -1081,7 +1132,7 @@ class PcdDatabase { } - public void genCodeNew () throws EntityException { + public void genCode () throws EntityException { ArrayList cStructDeclList = new ArrayList(); HashMap cStructInstTable = new HashMap(); @@ -1099,15 +1150,15 @@ class PcdDatabase { // EX type token number starts from the last Non-EX PCD entry and // grows continously upwards. // - ProcessTokensNew (nexTokens, cStructDeclList, cStructInstTable, phase); - ProcessTokensNew (exTokens, cStructDeclList, cStructInstTable, phase); + ProcessTokens (nexTokens, cStructDeclList, cStructInstTable, phase); + ProcessTokens (exTokens, cStructDeclList, cStructInstTable, phase); - stringTable.genCodeNew(cStructDeclList, cStructInstTable); - skuIdTable.genCodeNew(cStructDeclList, cStructInstTable, phase); - exMapTable.genCodeNew(cStructDeclList, cStructInstTable, phase); - localTokenNumberTable.genCodeNew(cStructDeclList, cStructInstTable, phase); - sizeTable.genCodeNew(cStructDeclList, cStructInstTable, phase); - guidTable.genCodeNew(cStructDeclList, cStructInstTable, phase); + stringTable.genCode(cStructDeclList, cStructInstTable); + skuIdTable.genCode(cStructDeclList, cStructInstTable, phase); + exMapTable.genCode(cStructDeclList, cStructInstTable, phase); + localTokenNumberTable.genCode(cStructDeclList, cStructInstTable, phase); + sizeTable.genCode(cStructDeclList, cStructInstTable, phase); + guidTable.genCode(cStructDeclList, cStructInstTable, phase); hString = genCMacroCode (); @@ -1138,6 +1189,7 @@ class PcdDatabase { macroStr += skuIdTable.getSizeMacro(); macroStr += localTokenNumberTable.getSizeMacro(); macroStr += exMapTable.getSizeMacro(); + macroStr += sizeTable.getSizeMacro(); // // Generate existance info Macro for all Tables @@ -1206,7 +1258,8 @@ class PcdDatabase { // // We made a assumption that both PEI_PCD_DATABASE and DXE_PCD_DATABASE // has a least one data memember with alignment size of 1. So we can - // remove the last "," in the C structure instantiation string. + // remove the last "," in the C structure instantiation string. Luckily, + // this is true as both data structure has SKUID_TABLE anyway. // if ((align == 1) && (i == declaListBasedOnAlignment.size() - 1)) { initInstStr += newLine; @@ -1228,7 +1281,7 @@ class PcdDatabase { } if (uinitDatabaseEmpty) { - uninitDeclStr += tab + " UINT8 dummy; /* PCD_DATABASE_UNINIT is emptry */\r\n"; + uninitDeclStr += tab + String.format("%-20sdummy; /* PCD_DATABASE_UNINIT is emptry */\r\n", "UINT8"); } initDeclStr += String.format("} %s_PCD_DATABASE_INIT;", phase) + newLine + newLine; @@ -1242,159 +1295,6 @@ class PcdDatabase { return result; } - public void genCode () - throws EntityException { - - final String newLine = "\r\n"; - final String declNewLine = ";\r\n"; - final String tab = "\t"; - final String commaNewLine = ", \r\n"; - - int i; - ArrayList decla; - ArrayList inst; - - String macroStr = ""; - String initDeclStr = ""; - String initInstStr = ""; - String uninitDeclStr = ""; - - List initTokens = new ArrayList (); - List uninitTokens = new ArrayList (); - - HashMap > initCode = new HashMap> (); - HashMap > uninitCode = new HashMap> (); - - getTwoGroupsOfTokens (alTokens, initTokens, uninitTokens); - - // - // Generate Structure Declaration for PcdTokens without Default Value - // PEI_PCD_DATABASE_INIT - // - java.util.Comparator comparator = new AlignmentSizeComp(); - java.util.Collections.sort(initTokens, comparator); - initCode = processTokens(initTokens); - - // - // Generate Structure Declaration for PcdTokens without Default Value - // PEI_PCD_DATABASE_UNINIT - // - java.util.Collections.sort(uninitTokens, comparator); - uninitCode = processTokens(uninitTokens); - - // - // Generate size info Macro for all Tables - // - macroStr += guidTable.getSizeMacro(); - macroStr += stringTable.getSizeMacro(); - macroStr += skuIdTable.getSizeMacro(); - macroStr += localTokenNumberTable.getSizeMacro(); - macroStr += exMapTable.getSizeMacro(); - - // - // Generate existance info Macro for all Tables - // - macroStr += guidTable.getExistanceMacro(); - macroStr += stringTable.getExistanceMacro(); - macroStr += skuIdTable.getExistanceMacro(); - macroStr += localTokenNumberTable.getExistanceMacro(); - macroStr += exMapTable.getExistanceMacro(); - - // - // Generate Structure Declaration for PcdTokens with Default Value - // for example PEI_PCD_DATABASE_INIT - // - initDeclStr += "typedef struct {" + newLine; - { - initDeclStr += tab + exMapTable.getTypeDeclaration(); - initDeclStr += tab + guidTable.getTypeDeclaration(); - initDeclStr += tab + localTokenNumberTable.getTypeDeclaration(); - initDeclStr += tab + stringTable.getTypeDeclaration(); - initDeclStr += tab + sizeTable.getTypeDeclaration(); - initDeclStr += tab + skuIdTable.getTypeDeclaration(); - if (phase.equalsIgnoreCase("PEI")) { - initDeclStr += tab + "SKU_ID SystemSkuId;" + newLine; - } - - decla = initCode.get(new String("Declaration")); - for (i = 0; i < decla.size(); i++) { - initDeclStr += tab + decla.get(i) + declNewLine; - } - - // - // Generate Structure Declaration for PcdToken with SkuEnabled - // - decla = initCode.get("DeclarationForSku"); - - for (i = 0; i < decla.size(); i++) { - initDeclStr += tab + decla.get(i) + declNewLine; - } - } - initDeclStr += String.format("} %s_PCD_DATABASE_INIT;\r\n\r\n", phase); - - // - // Generate MACRO for structure intialization of PCDTokens with Default Value - // The sequence must match the sequence of declaration of the memembers in the structure - String tmp = String.format("%s_PCD_DATABASE_INIT g%sPcdDbInit = { ", phase.toUpperCase(), phase.toUpperCase()); - initInstStr += tmp + newLine; - initInstStr += tab + genInstantiationStr(exMapTable.getInstantiation()) + commaNewLine; - initInstStr += tab + genInstantiationStr(guidTable.getInstantiation()) + commaNewLine; - initInstStr += tab + genInstantiationStr(localTokenNumberTable.getInstantiation()) + commaNewLine; - initInstStr += tab + genInstantiationStr(stringTable.getInstantiation()) + commaNewLine; - initInstStr += tab + genInstantiationStr(sizeTable.getInstantiation()) + commaNewLine; - initInstStr += tab + genInstantiationStr(skuIdTable.getInstantiation()) + commaNewLine; - // - // For SystemSkuId - // - if (phase.equalsIgnoreCase("PEI")) { - initInstStr += tab + "0" + tab + "/* SystemSkuId */" + commaNewLine; - } - - inst = initCode.get("Instantiation"); - for (i = 0; i < inst.size(); i++) { - initInstStr += tab + inst.get(i) + commaNewLine; - } - - inst = initCode.get("InstantiationForSku"); - for (i = 0; i < inst.size(); i++) { - initInstStr += tab + inst.get(i); - if (i != inst.size() - 1) { - initInstStr += commaNewLine; - } - } - - initInstStr += "};"; - - uninitDeclStr += "typedef struct {" + newLine; - { - decla = uninitCode.get("Declaration"); - if (decla.size() == 0) { - uninitDeclStr += "UINT8 dummy /* The UINT struct is empty */" + declNewLine; - } else { - - for (i = 0; i < decla.size(); i++) { - uninitDeclStr += tab + decla.get(i) + declNewLine; - } - - decla = uninitCode.get("DeclarationForSku"); - - for (i = 0; i < decla.size(); i++) { - uninitDeclStr += tab + decla.get(i) + declNewLine; - } - } - } - uninitDeclStr += String.format("} %s_PCD_DATABASE_UNINIT;\r\n\r\n", phase); - - cString = initInstStr + newLine; - hString = macroStr + newLine - + initDeclStr + newLine - + uninitDeclStr + newLine - + newLine; - - hString += String.format("#define PCD_%s_SERVICE_DRIVER_VERSION %d", phase, version); - - } - public static String genInstantiationStr (ArrayList alStr) { String str = ""; for (int i = 0; i< alStr.size(); i++) { @@ -1410,133 +1310,19 @@ class PcdDatabase { return str; } - private HashMap> processTokens (List alToken) - throws EntityException { - - HashMap > map = new HashMap>(); - - ArrayList decl = new ArrayList(); - ArrayList declForSkuEnableType = new ArrayList(); - ArrayList inst = new ArrayList(); - ArrayList instForSkuEnableType = new ArrayList(); - - for (int index = 0; index < alToken.size(); index++) { - Token token = alToken.get(index); + private String getSkuEnabledTypeDeclaration (Token token) { + return String.format("%-20s%s;\r\n", "SKU_HEAD", token.getPrimaryKeyString()); + } - if (token.isSkuEnable()) { - // - // BugBug: Schema only support Data type now - // - int tableIdx; + private String getSkuEnabledTypeInstantiaion (Token token, int SkuTableIdx) { - tableIdx = skuIdTable.add(token); + String offsetof = String.format(PcdDatabase.offsetOfSkuHeadStrTemplate, phase, token.hasDefaultValue()? "Init" : "Uninit", token.getPrimaryKeyString()); + return String.format("{ %s, %d } /* SKU_ENABLED: %s */", offsetof, SkuTableIdx, token.getPrimaryKeyString()); + } - decl.add(getSkuEnabledTypeDeclaration(token)); - if (token.hasDefaultValue()) { - inst.add(getSkuEnabledTypeInstantiaion(token, tableIdx)); - } - - declForSkuEnableType.add(getDataTypeDeclarationForSkuEnabled(token)); - if (token.hasDefaultValue()) { - instForSkuEnableType.add(getDataTypeInstantiationForSkuEnabled(token)); - } - - } else { - if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) { - decl.add(getVariableEnableTypeDeclaration(token)); - inst.add(getVariableEnableInstantiation(token)); - } else if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) { - decl.add(getVpdEnableTypeDeclaration(token)); - inst.add(getVpdEnableTypeInstantiation(token)); - } else if (token.isUnicodeStringType()) { - decl.add(getStringTypeDeclaration(token)); - inst.add(getStringTypeInstantiation(stringTable.add(token.getStringTypeString(), token), token)); - } - else { - decl.add(getDataTypeDeclaration(token)); - if (token.hasDefaultValue()) { - inst.add(getDataTypeInstantiation(token)); - } - } - } - - sizeTable.add(token); - localTokenNumberTable.add(token); - token.tokenNumber = assignedTokenNumber++; - - } - - map.put("Declaration", decl); - map.put("DeclarationForSku", declForSkuEnableType); - map.put("Instantiation", inst); - map.put("InstantiationForSku", instForSkuEnableType); - - return map; - } - - private String getSkuEnabledTypeDeclaration (Token token) { - return String.format("SKU_HEAD %s;\r\n", token.getPrimaryKeyString()); - } - - private String getSkuEnabledTypeInstantiaion (Token token, int SkuTableIdx) { - - String offsetof = String.format(PcdDatabase.offsetOfSkuHeadStrTemplate, phase, token.hasDefaultValue()? "Init" : "Uninit", token.getPrimaryKeyString()); - return String.format("{ %s, %d } /* SKU_ENABLED: %s */", offsetof, SkuTableIdx, token.getPrimaryKeyString()); - } - - private String getDataTypeDeclarationForSkuEnabled (Token token) { - String typeStr = ""; - - if (token.datumType == Token.DATUM_TYPE.UINT8) { - typeStr = "UINT8 %s_%s[%d];\r\n"; - } else if (token.datumType == Token.DATUM_TYPE.UINT16) { - typeStr = "UINT16 %s_%s[%d];\r\n"; - } else if (token.datumType == Token.DATUM_TYPE.UINT32) { - typeStr = "UINT32 %s_%s[%d];\r\n"; - } else if (token.datumType == Token.DATUM_TYPE.UINT64) { - typeStr = "UINT64 %s_%s[%d];\r\n"; - } else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) { - typeStr = "BOOLEAN %s_%s[%d];\r\n"; - } else if (token.datumType == Token.DATUM_TYPE.POINTER) { - return String.format("UINT8 %s_%s[%d];\r\n", token.getPrimaryKeyString(), "SkuDataTable", token.datumSize * token.skuData.size()); - } - - return String.format(typeStr, token.getPrimaryKeyString(), "SkuDataTable", token.skuData.size()); - - } - - private String getDataTypeInstantiationForSkuEnabled (Token token) { - String str = ""; - - if (token.datumType == Token.DATUM_TYPE.POINTER) { - return String.format("UINT8 %s_%s[%d]", token.getPrimaryKeyString(), "SkuDataTable", token.datumSize * token.skuData.size()); - } else { - str = "{ "; - for (int idx = 0; idx < token.skuData.size(); idx++) { - str += token.skuData.get(idx).toString(); - if (idx != token.skuData.size() - 1) { - str += ", "; - } - } - str += "}"; - - return str; - } - - } - - private String getDataTypeInstantiationForVariableDefault_new (Token token, String cName, int skuId) { - return String.format("%s /* %s */", token.skuData.get(skuId).value.hiiDefaultValue, cName); - } - - private String getDataTypeInstantiation (Token token) { - - if (token.datumType == Token.DATUM_TYPE.POINTER) { - return String.format("%s /* %s */", token.getDefaultSku().value, token.getPrimaryKeyString()); - } else { - return String.format("%s /* %s */", token.getDefaultSku().value, token.getPrimaryKeyString()); - } - } + private String getDataTypeInstantiationForVariableDefault (Token token, String cName, int skuId) { + return String.format("%s /* %s */", token.skuData.get(skuId).value.hiiDefaultValue, cName); + } private String getCType (Token t) throws EntityException { @@ -1571,6 +1357,9 @@ class PcdDatabase { } } + // + // privateGlobalName and privateGlobalCCode is used to pass output to caller of getCDeclarationString + // private void getCDeclarationString(Token t) throws EntityException { @@ -1580,43 +1369,27 @@ class PcdDatabase { privateGlobalName = t.getPrimaryKeyString(); } - if (t.isUnicodeStringType()) { - privateGlobalCCode = String.format("STRING_HEAD %s[%d];\r\n", t.getPrimaryKeyString(), t.getSkuIdCount()); - } else { - String type = getCType(t); - if (t.datumType == Token.DATUM_TYPE.POINTER) { - privateGlobalCCode = String.format("%s %s[%d][%d];\r\n", type, privateGlobalName, t.getSkuIdCount(), t.datumSize); + String type = getCType(t); + if ((t.datumType == Token.DATUM_TYPE.POINTER) && (!t.isHiiEnable()) && (!t.isUnicodeStringType())) { + int bufferSize; + if (t.isASCIIStringType()) { + // + // Build tool will add a NULL string at the end of the ASCII string + // + bufferSize = t.datumSize + 1; } else { - privateGlobalCCode = String.format("%s %s[%d];\r\n", type, privateGlobalName, t.getSkuIdCount()); + bufferSize = t.datumSize; } - } - } - - private String getDataTypeDeclarationForVariableDefault_new (Token token, String cName, int skuId) { - - String typeStr = ""; - - if (token.datumType == Token.DATUM_TYPE.UINT8) { - typeStr = "UINT8"; - } else if (token.datumType == Token.DATUM_TYPE.UINT16) { - typeStr = "UINT16"; - } else if (token.datumType == Token.DATUM_TYPE.UINT32) { - typeStr = "UINT32"; - } else if (token.datumType == Token.DATUM_TYPE.UINT64) { - typeStr = "UINT64"; - } else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) { - typeStr = "BOOLEAN"; - } else if (token.datumType == Token.DATUM_TYPE.POINTER) { - return String.format("UINT8 %s[%d]", cName, token.datumSize); + privateGlobalCCode = String.format("%-20s%s[%d][%d];\r\n", type, privateGlobalName, t.getSkuIdCount(), bufferSize); } else { + privateGlobalCCode = String.format("%-20s%s[%d];\r\n", type, privateGlobalName, t.getSkuIdCount()); } - - return String.format("%s %s;\r\n", typeStr, cName); } - private String getDataTypeDeclaration (Token token) { + private String getDataTypeDeclarationForVariableDefault (Token token, String cName, int skuId) + throws EntityException { - String typeStr = ""; + String typeStr; if (token.datumType == Token.DATUM_TYPE.UINT8) { typeStr = "UINT8"; @@ -1629,15 +1402,30 @@ class PcdDatabase { } else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) { typeStr = "BOOLEAN"; } else if (token.datumType == Token.DATUM_TYPE.POINTER) { - return String.format("UINT8 %s[%d]", token.getPrimaryKeyString(), token.datumSize); + int size; + if (token.isHiiDefaultValueUnicodeStringType()) { + typeStr = "UINT16"; + // + // Include the NULL charactor + // + size = token.datumSize / 2 + 1; + } else { + typeStr = "UINT8"; + if (token.isHiiDefaultValueASCIIStringType()) { + // + // Include the NULL charactor + // + size = token.datumSize + 1; + } else { + size = token.datumSize; + } + } + return String.format("%-20s%s[%d];\r\n", typeStr, cName, size); } else { + throw new EntityException("Unknown DATUM_TYPE type in when generating code for VARIABLE_ENABLED PCD entry"); } - return String.format("%s %s", typeStr, token.getPrimaryKeyString()); - } - - private String getVpdEnableTypeDeclaration (Token token) { - return String.format("VPD_HEAD %s", token.getPrimaryKeyString()); + return String.format("%-20s%s;\r\n", typeStr, cName); } private String getTypeInstantiation (Token t, ArrayList declaList, HashMap instTable, String phase) throws EntityException { @@ -1649,7 +1437,7 @@ class PcdDatabase { s += tab + "{" + newLine; for (i = 0; i < t.skuData.size(); i++) { - if (t.isUnicodeStringType() && !t.isHiiEnable()) { + if (t.isUnicodeStringType()) { s += tab + tab + String.format("{ %d }", stringTable.add(t.skuData.get(i).value.value, t)); } else if (t.isHiiEnable()) { /* VPD_HEAD definition @@ -1657,6 +1445,7 @@ class PcdDatabase { UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID. UINT16 StringIndex; // Offset in String Table in units of UINT16. UINT16 Offset; // Offset in Variable + UINT16 DefaultValueOffset; // Offset of the Default Value } VARIABLE_HEAD ; */ String variableDefaultName = String.format("%s_VariableDefault_%d", t.getPrimaryKeyString(), i); @@ -1671,12 +1460,12 @@ class PcdDatabase { // the instantiation for the default value. // CStructTypeDeclaration decl = new CStructTypeDeclaration (variableDefaultName, - getDataTypeAlignmentSize(t), - getDataTypeDeclarationForVariableDefault_new(t, variableDefaultName, i), + getHiiPtrTypeAlignmentSize(t), + getDataTypeDeclarationForVariableDefault(t, variableDefaultName, i), true ); declaList.add(decl); - instTable.put(variableDefaultName, getDataTypeInstantiationForVariableDefault_new (t, variableDefaultName, i)); + instTable.put(variableDefaultName, getDataTypeInstantiationForVariableDefault (t, variableDefaultName, i)); } else if (t.isVpdEnable()) { /* typedef struct { UINT32 Offset; @@ -1684,7 +1473,14 @@ class PcdDatabase { */ s += tab + tab + String.format("{ %s }", t.skuData.get(i).value.vpdOffset); } else { - s += tab + tab + String.format("{ %s }", t.skuData.get(i).value.value); + if (t.isByteStreamType()) { + // + // Byte stream type input has their own "{" "}", so we won't help to insert. + // + s += tab + tab + String.format(" %s ", t.skuData.get(i).value.value); + } else { + s += tab + tab + String.format("{ %s }", t.skuData.get(i).value.value); + } } if (i != t.skuData.size() - 1) { @@ -1700,40 +1496,6 @@ class PcdDatabase { return s; } - private String getVpdEnableTypeInstantiation (Token token) { - return String.format("{ %s } /* %s */", token.getDefaultSku().vpdOffset, - token.getPrimaryKeyString()); - } - - private String getStringTypeDeclaration (Token token) { - return String.format("UINT16 %s", token.getPrimaryKeyString()); - } - - private String getStringTypeInstantiation (int StringTableIdx, Token token) { - return String.format ("%d /* %s */", StringTableIdx, - token.getPrimaryKeyString()); - } - - - private String getVariableEnableTypeDeclaration (Token token) { - return String.format("VARIABLE_HEAD %s", token.getPrimaryKeyString()); - } - - private String getVariableEnableInstantiation (Token token) - throws EntityException { - // - // Need scott fix - // - return String.format("{ %d, %d, %s } /* %s */", guidTable.add(token.getDefaultSku().variableGuid, token.getPrimaryKeyString()), - stringTable.add(token.getDefaultSku().getStringOfVariableName(), token), - token.getDefaultSku().variableOffset, - token.getPrimaryKeyString()); - } - - public int getTotalTokenNumber () { - return sizeTable.getTableLen(); - } - public static String getPcdDatabaseCommonDefinitions () throws EntityException { @@ -1803,15 +1565,119 @@ class PcdDatabase { return retStr; } + /** + Translate the schema string to UUID instance. + + In schema, the string of UUID is defined as following two types string: + 1) GuidArrayType: pattern = 0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},( + )*0x[a-fA-F0-9]{1,4}(,( )*\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\})? + + 2) GuidNamingConvention: pattern = + [a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12} + + This function will convert string and create uuid instance. + + @param uuidString UUID string in XML file + + @return UUID UUID instance + **/ + private UUID translateSchemaStringToUUID(String uuidString) + throws EntityException { + String temp; + String[] splitStringArray; + int index; + int chIndex; + int chLen; + + if (uuidString == null) { + return null; + } + + if (uuidString.length() == 0) { + return null; + } + + if (uuidString.equals("0") || + uuidString.equalsIgnoreCase("0x0")) { + return new UUID(0, 0); + } + + uuidString = uuidString.replaceAll("\\{", ""); + uuidString = uuidString.replaceAll("\\}", ""); + + // + // If the UUID schema string is GuidArrayType type then need translate + // to GuidNamingConvention type at first. + // + if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) { + splitStringArray = uuidString.split("," ); + if (splitStringArray.length != 11) { + throw new EntityException ("[FPD file error] Wrong format for UUID string: " + uuidString); + } + + // + // Remove blank space from these string and remove header string "0x" + // + for (index = 0; index < 11; index ++) { + splitStringArray[index] = splitStringArray[index].trim(); + splitStringArray[index] = splitStringArray[index].substring(2, splitStringArray[index].length()); + } + + // + // Add heading '0' to normalize the string length + // + for (index = 3; index < 11; index ++) { + chLen = splitStringArray[index].length(); + for (chIndex = 0; chIndex < 2 - chLen; chIndex ++) { + splitStringArray[index] = "0" + splitStringArray[index]; + } + } + + // + // construct the final GuidNamingConvention string + // + temp = String.format("%s-%s-%s-%s%s-%s%s%s%s%s%s", + splitStringArray[0], + splitStringArray[1], + splitStringArray[2], + splitStringArray[3], + splitStringArray[4], + splitStringArray[5], + splitStringArray[6], + splitStringArray[7], + splitStringArray[8], + splitStringArray[9], + splitStringArray[10]); + uuidString = temp; + } + + return UUID.fromString(uuidString); + } } +/** Module Info class is the data structure to hold information got from GlobalData. +*/ class ModuleInfo { - public ModuleSADocument.ModuleSA module; - public ModuleTypeDef.Enum type; + /// + /// Module's ID for a + /// + private FpdModuleIdentification moduleId; + /// + /// xmlobject in FPD file for a + /// + private PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef; + + public ModuleInfo (FpdModuleIdentification moduleId, XmlObject pcdDef) { + this.moduleId = moduleId; + this.pcdBuildDef = ((PcdBuildDefinitionDocument)pcdDef).getPcdBuildDefinition(); + } + + public FpdModuleIdentification getModuleId (){ + return moduleId; + } - public ModuleInfo (ModuleSADocument.ModuleSA module, ModuleTypeDef.Enum type) { - this.module = module; - this.type = type; + public PcdBuildDefinitionDocument.PcdBuildDefinition getPcdBuildDef(){ + return pcdBuildDef; } } @@ -1820,21 +1686,31 @@ class ModuleInfo { from buildAction or UIAction. **/ public class CollectPCDAction { + /// /// memoryDatabase hold all PCD information collected from SPD, MSA, FPD. + /// private MemoryDatabaseManager dbManager; - + /// /// Workspacepath hold the workspace information. + /// private String workspacePath; - + /// /// FPD file is the root file. + /// private String fpdFilePath; - + /// /// Message level for CollectPCDAction. + /// private int originalMessageLevel; - + /// /// Cache the fpd docment instance for private usage. - private FrameworkPlatformDescriptionDocument fpdDocInstance; - + /// + private PlatformSurfaceAreaDocument fpdDocInstance; + /// + /// xmlObject name + /// + private static String xmlObjectName = "PcdBuildDefinition"; + /** Set WorkspacePath parameter for this action class. @@ -1901,7 +1777,7 @@ public class CollectPCDAction { @throws EntityException Exception indicate failed to execute this action. **/ - private void execute() throws EntityException { + public void execute() throws EntityException { // // Get memoryDatabaseManager instance from GlobalData. // The memoryDatabaseManager should be initialized for whatever build @@ -1919,8 +1795,7 @@ public class CollectPCDAction { createTokenInDBFromFPD(); // - // Call Private function genPcdDatabaseSourceCode (void); ComponentTypeBsDriver - // 1) Generate for PEI, DXE PCD DATABASE's definition and initialization. + // Generate for PEI, DXE PCD DATABASE's definition and initialization. // genPcdDatabaseSourceCode (); @@ -1935,25 +1810,22 @@ public class CollectPCDAction { **/ private void genPcdDatabaseSourceCode() throws EntityException { - String PcdCommonHeaderString = PcdDatabase.getPcdDatabaseCommonDefinitions (); + String PcdCommonHeaderString = PcdDatabase.getPcdDatabaseCommonDefinitions(); ArrayList alPei = new ArrayList (); ArrayList alDxe = new ArrayList (); dbManager.getTwoPhaseDynamicRecordArray(alPei, alDxe); PcdDatabase pcdPeiDatabase = new PcdDatabase (alPei, "PEI", 0); - pcdPeiDatabase.genCodeNew(); - MemoryDatabaseManager.PcdPeimHString = PcdCommonHeaderString + pcdPeiDatabase.getHString() - + PcdDatabase.getPcdPeiDatabaseDefinitions(); + pcdPeiDatabase.genCode(); + MemoryDatabaseManager.PcdPeimHString = PcdCommonHeaderString + pcdPeiDatabase.getHString() + + PcdDatabase.getPcdPeiDatabaseDefinitions(); MemoryDatabaseManager.PcdPeimCString = pcdPeiDatabase.getCString(); - PcdDatabase pcdDxeDatabase = new PcdDatabase (alDxe, - "DXE", - alPei.size() - ); - pcdDxeDatabase.genCodeNew(); - MemoryDatabaseManager.PcdDxeHString = MemoryDatabaseManager.PcdPeimHString + pcdDxeDatabase.getHString() - + PcdDatabase.getPcdDxeDatabaseDefinitions(); + PcdDatabase pcdDxeDatabase = new PcdDatabase(alDxe, "DXE", alPei.size()); + pcdDxeDatabase.genCode(); + MemoryDatabaseManager.PcdDxeHString = MemoryDatabaseManager.PcdPeimHString + pcdDxeDatabase.getHString() + + PcdDatabase.getPcdDxeDatabaseDefinitions(); MemoryDatabaseManager.PcdDxeCString = pcdDxeDatabase.getCString(); } @@ -1967,32 +1839,23 @@ public class CollectPCDAction { */ private List getComponentsFromFPD() throws EntityException { - List allModules = new ArrayList(); - ModuleInfo current = null; - int index = 0; - org.tianocore.Components components = null; - FrameworkModulesDocument.FrameworkModules fModules = null; - ModuleSADocument.ModuleSA[] modules = null; - HashMap map = new HashMap(); - - if (fpdDocInstance == null) { - try { - fpdDocInstance = (FrameworkPlatformDescriptionDocument)XmlObject.Factory.parse(new File(fpdFilePath)); - } catch(IOException ioE) { - throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage()); - } catch(XmlException xmlE) { - throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage()); - } + List allModules = new ArrayList(); + FrameworkModulesDocument.FrameworkModules fModules = null; + ModuleSADocument.ModuleSA[] modules = null; + Map pcdBuildDefinitions = null; + pcdBuildDefinitions = GlobalData.getFpdPcdBuildDefinitions(); + if (pcdBuildDefinitions == null) { + return null; } - map.put("FrameworkPlatformDescription", fpdDocInstance); - SurfaceAreaQuery.setDoc(map); - modules = SurfaceAreaQuery.getFpdModuleSAs(); - for (index = 0; index < modules.length; index ++) { - SurfaceAreaQuery.setDoc(GlobalData.getDoc(modules[index].getModuleName())); - allModules.add(new ModuleInfo(modules[index], - ModuleTypeDef.Enum.forString(SurfaceAreaQuery.getModuleType()))); + // + // Loop map to retrieve all PCD build definition and Module id + // + Iterator item = pcdBuildDefinitions.keySet().iterator(); + while (item.hasNext()){ + FpdModuleIdentification id = (FpdModuleIdentification) item.next(); + allModules.add(new ModuleInfo(id, pcdBuildDefinitions.get(id))); } return allModules; @@ -2016,8 +1879,6 @@ public class CollectPCDAction { List pcdBuildDataArray = new ArrayList(); PcdBuildDefinition.PcdData pcdBuildData = null; Token token = null; - SkuInstance skuInstance = null; - int skuIndex = 0; List modules = null; String primaryKey = null; String exceptionString = null; @@ -2027,10 +1888,11 @@ public class CollectPCDAction { boolean isDuplicate = false; Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN; Token.DATUM_TYPE datumType = Token.DATUM_TYPE.UNKNOWN; - int tokenNumber = 0; + long tokenNumber = 0; String moduleName = null; String datum = null; int maxDatumSize = 0; + String[] tokenSpaceStrRet = null; // // ---------------------------------------------- @@ -2049,44 +1911,16 @@ public class CollectPCDAction { // ------------------------------------------------------------------- // for (index = 0; index < modules.size(); index ++) { - isDuplicate = false; - for (index2 = 0; index2 < index; index2 ++) { - // - // BUGBUG: For transition schema, we can *not* get module's version from - // , It is work around code. - // - primaryKey1 = UsageInstance.getPrimaryKey(modules.get(index).module.getModuleName(), - null, - null, - null, - modules.get(index).module.getArch().toString(), - null); - primaryKey2 = UsageInstance.getPrimaryKey(modules.get(index2).module.getModuleName(), - null, - null, - null, - modules.get(index2).module.getArch().toString(), - null); - if (primaryKey1.equalsIgnoreCase(primaryKey2)) { - isDuplicate = true; - break; - } - } - - if (isDuplicate) { - continue; - } - // // It is legal for a module does not contains ANY pcd build definitions. // - if (modules.get(index).module.getPcdBuildDefinition() == null) { + if (modules.get(index).getPcdBuildDef() == null) { continue; } - pcdBuildDataArray = modules.get(index).module.getPcdBuildDefinition().getPcdDataList(); + pcdBuildDataArray = modules.get(index).getPcdBuildDef().getPcdDataList(); - moduleName = modules.get(index).module.getModuleName(); + moduleName = modules.get(index).getModuleId().getModule().getName(); // // ---------------------------------------------------------------------- @@ -2095,11 +1929,21 @@ public class CollectPCDAction { // for (pcdIndex = 0; pcdIndex < pcdBuildDataArray.size(); pcdIndex ++) { pcdBuildData = pcdBuildDataArray.get(pcdIndex); - primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), - translateSchemaStringToUUID(pcdBuildData.getTokenSpaceGuid())); + + try { + tokenSpaceStrRet = GlobalData.getGuidInfoFromCname(pcdBuildData.getTokenSpaceGuidCName()); + } catch ( Exception e ) { + throw new EntityException ("Faile get Guid for token " + pcdBuildData.getCName() + ":" + e.getMessage()); + } + + if (tokenSpaceStrRet == null) { + throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName()); + } + + primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), tokenSpaceStrRet[1]); pcdType = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString()); datumType = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString()); - tokenNumber = Integer.decode(pcdBuildData.getToken().toString()); + tokenNumber = Long.decode(pcdBuildData.getToken().toString()); if (pcdBuildData.getValue() != null) { datum = pcdBuildData.getValue().toString(); } else { @@ -2116,17 +1960,6 @@ public class CollectPCDAction { throw new EntityException(exceptionString); } - // - // Check is exist? In future, because all schema verification will tools - // will check that, following checking code could be removed. - // - if (pcdBuildData.getTokenSpaceGuid() == null) { - exceptionString = String.format("[FPD file error] There is no for PCD %s in module %s! This is required!", - pcdBuildData.getCName(), - moduleName); - throw new EntityException(exceptionString); - } - // // ------------------------------------------------------------------------------------------- // 2.1.1), Do some necessary checking work for FixedAtBuild, FeatureFlag and PatchableInModule @@ -2236,8 +2069,17 @@ public class CollectPCDAction { // If the token is not in database, create a new token instance and add // a usage instance into this token in database. // - token = new Token(pcdBuildData.getCName(), - translateSchemaStringToUUID(pcdBuildData.getTokenSpaceGuid())); + try { + tokenSpaceStrRet = GlobalData.getGuidInfoFromCname(pcdBuildData.getTokenSpaceGuidCName()); + } catch (Exception e) { + throw new EntityException("Fail to get token space guid for token " + token.cName); + } + + if (tokenSpaceStrRet == null) { + throw new EntityException("Fail to get token space guid for token " + token.cName); + } + + token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]); token.datumType = datumType; token.tokenNumber = tokenNumber; @@ -2271,19 +2113,253 @@ public class CollectPCDAction { // ------------------------------------------------ // usageInstance = new UsageInstance(token, - moduleName, - null, - null, - null, - modules.get(index).type, + modules.get(index).getModuleId().getModule(), pcdType, - modules.get(index).module.getArch().toString(), - null, + modules.get(index).getModuleId().getArch(), datum, maxDatumSize); token.addUsageInstance(usageInstance); } } + + // + // ------------------------------------------------ + // 3), Add unreference dynamic_Ex pcd token into Pcd database. + // ------------------------------------------------ + // + List tokenArray = getUnreferencedDynamicPcd(); + if (tokenArray != null) { + for (index = 0; index < tokenArray.size(); index ++) { + dbManager.addTokenToDatabase(tokenArray.get(index).getPrimaryKeyString(), + tokenArray.get(index)); + } + } + } + + private List getUnreferencedDynamicPcd () throws EntityException { + List tokenArray = new ArrayList(); + Token token = null; + DynamicPcdBuildDefinitions dynamicPcdBuildDefinitions = null; + List dynamicPcdBuildDataArray = null; + DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = null; + List skuInfoList = null; + Token.PCD_TYPE pcdType; + SkuInstance skuInstance = null; + String primaryKey = null; + boolean hasSkuId0 = false; + int index, offset, index2; + String temp; + String exceptionString; + String hiiDefaultValue; + String tokenSpaceStrRet[]; + String variableGuidString[]; + + // + // Open fpd document to get Section. + // BUGBUG: the function should be move GlobalData in furture. + // + if (fpdDocInstance == null) { + try { + fpdDocInstance = (PlatformSurfaceAreaDocument)XmlObject.Factory.parse(new File(fpdFilePath)); + } catch(IOException ioE) { + throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage()); + } catch(XmlException xmlE) { + throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage()); + } + } + + dynamicPcdBuildDefinitions = fpdDocInstance.getPlatformSurfaceArea().getDynamicPcdBuildDefinitions(); + if (dynamicPcdBuildDefinitions == null) { + return null; + } + + dynamicPcdBuildDataArray = dynamicPcdBuildDefinitions.getPcdBuildDataList(); + for (index2 = 0; index2 < dynamicPcdBuildDataArray.size(); index2 ++) { + pcdBuildData = dynamicPcdBuildDataArray.get(index2); + try { + tokenSpaceStrRet = GlobalData.getGuidInfoFromCname(pcdBuildData.getTokenSpaceGuidCName()); + } catch ( Exception e ) { + throw new EntityException ("Faile get Guid for token " + pcdBuildData.getCName() + ":" + e.getMessage()); + } + + if (tokenSpaceStrRet == null) { + throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName()); + } + + primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), + tokenSpaceStrRet[1]); + + if (dbManager.isTokenInDatabase(primaryKey)) { + continue; + } + + pcdType = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString()); + if (pcdType != Token.PCD_TYPE.DYNAMIC_EX) { + throw new EntityException (String.format("[FPD file error] It not allowed for DYNAMIC PCD %s who is no used by any module", + pcdBuildData.getCName())); + } + + // + // Create new token for unreference dynamic PCD token + // + token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]); + token.datumSize = pcdBuildData.getMaxDatumSize(); + + + token.datumType = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString()); + token.tokenNumber = Long.decode(pcdBuildData.getToken().toString()); + token.dynamicExTokenNumber = token.tokenNumber; + token.isDynamicPCD = true; + token.updateSupportPcdType(pcdType); + + exceptionString = verifyDatum(token.cName, + null, + null, + token.datumType, + token.datumSize); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + + skuInfoList = pcdBuildData.getSkuInfoList(); + + // + // Loop all sku data + // + for (index = 0; index < skuInfoList.size(); index ++) { + skuInstance = new SkuInstance(); + // + // Although SkuId in schema is BigInteger, but in fact, sku id is 32 bit value. + // + temp = skuInfoList.get(index).getSkuId().toString(); + skuInstance.id = Integer.decode(temp); + if (skuInstance.id == 0) { + hasSkuId0 = true; + } + // + // Judge whether is DefaultGroup at first, because most case is DefautlGroup. + // + if (skuInfoList.get(index).getValue() != null) { + skuInstance.value.setValue(skuInfoList.get(index).getValue().toString()); + if ((exceptionString = verifyDatum(token.cName, + null, + skuInfoList.get(index).getValue().toString(), + token.datumType, + token.datumSize)) != null) { + throw new EntityException(exceptionString); + } + + token.skuData.add(skuInstance); + + continue; + } + + // + // Judge whether is HII group case. + // + if (skuInfoList.get(index).getVariableName() != null) { + exceptionString = null; + if (skuInfoList.get(index).getVariableGuid() == null) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + "file, who use HII, but there is no defined for Sku %d data!", + token.cName, + index); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + } + + if (skuInfoList.get(index).getVariableOffset() == null) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + "file, who use HII, but there is no defined for Sku %d data!", + token.cName, + index); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + } + + if (skuInfoList.get(index).getHiiDefaultValue() == null) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in section in FPD "+ + "file, who use HII, but there is no defined for Sku %d data!", + token.cName, + index); + if (exceptionString != null) { + throw new EntityException(exceptionString); + } + } + + if (skuInfoList.get(index).getHiiDefaultValue() != null) { + hiiDefaultValue = skuInfoList.get(index).getHiiDefaultValue().toString(); + } else { + hiiDefaultValue = null; + } + + if ((exceptionString = verifyDatum(token.cName, + null, + hiiDefaultValue, + token.datumType, + token.datumSize)) != null) { + throw new EntityException(exceptionString); + } + + offset = Integer.decode(skuInfoList.get(index).getVariableOffset()); + if (offset > 0xFFFF) { + throw new EntityException(String.format("[FPD file error] For dynamic PCD %s , the variable offset defined in sku %d data "+ + "exceed 64K, it is not allowed!", + token.cName, + index)); + } + + // + // Get variable guid string according to the name of guid which will be mapped into a GUID in SPD file. + // + variableGuidString = GlobalData.getGuidInfoFromCname(skuInfoList.get(index).getVariableGuid().toString()); + if (variableGuidString == null) { + throw new EntityException(String.format("[GUID Error] For dynamic PCD %s, the variable guid %s can be found in all SPD file!", + token.cName, + skuInfoList.get(index).getVariableGuid().toString())); + } + String variableStr = skuInfoList.get(index).getVariableName(); + Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}"); + Matcher matcher = pattern.matcher(variableStr); + List varNameList = new ArrayList(); + while (matcher.find()){ + String str = variableStr.substring(matcher.start(),matcher.end()); + varNameList.add(str); + } + + skuInstance.value.setHiiData(varNameList, + translateSchemaStringToUUID(variableGuidString[1]), + skuInfoList.get(index).getVariableOffset(), + skuInfoList.get(index).getHiiDefaultValue().toString()); + token.skuData.add(skuInstance); + continue; + } + + if (skuInfoList.get(index).getVpdOffset() != null) { + skuInstance.value.setVpdData(skuInfoList.get(index).getVpdOffset()); + token.skuData.add(skuInstance); + continue; + } + + exceptionString = String.format("[FPD file error] For dynamic PCD %s, the dynamic info must "+ + "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.", + token.cName); + throw new EntityException(exceptionString); + } + + if (!hasSkuId0) { + exceptionString = String.format("[FPD file error] For dynamic PCD %s in , there are "+ + "no sku id = 0 data, which is required for every dynamic PCD", + token.cName); + throw new EntityException(exceptionString); + } + + tokenArray.add(token); + } + + return tokenArray; } /** @@ -2556,7 +2632,12 @@ public class CollectPCDAction { strValue = datum.substring(start + 1, end); strValue = strValue.trim(); if (strValue.length() == 0) { - break; + exceptionString = String.format ("[FPD file error] The datum type of PCD %s in %s is VOID*, and "+ + "it is byte array in fact, but '{}' is not valid for NULL datam but"+ + " need use '{0}'", + cName, + moduleName); + return exceptionString; } strValueArray = strValue.split(","); for (index = 0; index < strValueArray.length; index ++) { @@ -2630,21 +2711,23 @@ public class CollectPCDAction { String dynamicPrimaryKey = null; DynamicPcdBuildDefinitions dynamicPcdBuildDefinitions = null; List dynamicPcdBuildDataArray = null; + String[] tokenSpaceStrRet = null; // // If FPD document is not be opened, open and initialize it. + // BUGBUG: The code should be moved into GlobalData in future. // if (fpdDocInstance == null) { try { - fpdDocInstance = (FrameworkPlatformDescriptionDocument)XmlObject.Factory.parse(new File(fpdFilePath)); + fpdDocInstance = (PlatformSurfaceAreaDocument)XmlObject.Factory.parse(new File(fpdFilePath)); } catch(IOException ioE) { throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage()); } catch(XmlException xmlE) { throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage()); } } - - dynamicPcdBuildDefinitions = fpdDocInstance.getFrameworkPlatformDescription().getDynamicPcdBuildDefinitions(); + + dynamicPcdBuildDefinitions = fpdDocInstance.getPlatformSurfaceArea().getDynamicPcdBuildDefinitions(); if (dynamicPcdBuildDefinitions == null) { exceptionString = String.format("[FPD file error] There are no in FPD file but contains Dynamic type "+ "PCD entry %s in module %s!", @@ -2655,18 +2738,20 @@ public class CollectPCDAction { dynamicPcdBuildDataArray = dynamicPcdBuildDefinitions.getPcdBuildDataList(); for (index = 0; index < dynamicPcdBuildDataArray.size(); index ++) { - // - // Check is exist? In future, because all schema verification will tools - // will check that, following checking code could be removed. - // - if (dynamicPcdBuildDataArray.get(index).getTokenSpaceGuid() == null) { - exceptionString = String.format("[FPD file error] There is no for PCD %s in ! This is required!", - dynamicPcdBuildDataArray.get(index).getCName()); - throw new EntityException(exceptionString); + //String tokenSpaceGuidString = GlobalData.getGuidInfoFromCname(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuidCName())[1]; + String tokenSpaceGuidString = null; + try { + tokenSpaceStrRet = GlobalData.getGuidInfoFromCname(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuidCName()); + } catch (Exception e) { + throw new EntityException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName()); + } + + if (tokenSpaceStrRet == null) { + throw new EntityException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName()); } dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(), - translateSchemaStringToUUID(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuid())); + tokenSpaceStrRet[1]); if (dynamicPrimaryKey.equalsIgnoreCase(token.getPrimaryKeyString())) { return dynamicPcdBuildDataArray.get(index); } @@ -2701,7 +2786,7 @@ public class CollectPCDAction { String temp; boolean hasSkuId0 = false; Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN; - int tokenNumber = 0; + long tokenNumber = 0; String hiiDefaultValue = null; String[] variableGuidString = null; @@ -2739,7 +2824,7 @@ public class CollectPCDAction { dynamicInfo.getMaxDatumSize()); throw new EntityException(exceptionString); } - tokenNumber = Integer.decode(dynamicInfo.getToken().toString()); + tokenNumber = Long.decode(dynamicInfo.getToken().toString()); if (tokenNumber != token.tokenNumber) { exceptionString = String.format("[FPD file error] For dynamic PCD %s, the token number in module %s is 0x%x, but"+ "in , the token number is 0x%x, they are not match!", @@ -2751,9 +2836,7 @@ public class CollectPCDAction { } pcdType = Token.getpcdTypeFromString(dynamicInfo.getItemType().toString()); - if (pcdType == Token.PCD_TYPE.DYNAMIC_EX) { - token.dynamicExTokenNumber = tokenNumber; - } + token.dynamicExTokenNumber = tokenNumber; skuInfoList = dynamicInfo.getSkuInfoList(); @@ -2861,14 +2944,22 @@ public class CollectPCDAction { // // Get variable guid string according to the name of guid which will be mapped into a GUID in SPD file. // - variableGuidString = GlobalData.getGuidInfoGuid(skuInfoList.get(index).getVariableGuid().toString()); + variableGuidString = GlobalData.getGuidInfoFromCname(skuInfoList.get(index).getVariableGuid().toString()); if (variableGuidString == null) { throw new EntityException(String.format("[GUID Error] For dynamic PCD %s, the variable guid %s can be found in all SPD file!", token.cName, skuInfoList.get(index).getVariableGuid().toString())); } - - skuInstance.value.setHiiData(skuInfoList.get(index).getVariableName(), + String variableStr = skuInfoList.get(index).getVariableName(); + Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}"); + Matcher matcher = pattern.matcher(variableStr); + List varNameList = new ArrayList(); + while (matcher.find()){ + String str = variableStr.substring(matcher.start(),matcher.end()); + varNameList.add(str); + } + + skuInstance.value.setHiiData(varNameList, translateSchemaStringToUUID(variableGuidString[1]), skuInfoList.get(index).getVariableOffset(), skuInfoList.get(index).getHiiDefaultValue().toString()); @@ -3022,11 +3113,16 @@ public class CollectPCDAction { **/ public static void main(String argv[]) throws EntityException { CollectPCDAction ca = new CollectPCDAction(); - ca.setWorkspacePath("m:/tianocore/edk2"); - ca.setFPDFilePath("m:/tianocore/edk2/EdkNt32Pkg/Nt32.fpd"); + String projectDir = "x:/edk2"; + ca.setWorkspacePath(projectDir); + ca.setFPDFilePath(projectDir + "/EdkNt32Pkg/Nt32.fpd"); ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL); GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", - "m:/tianocore/edk2"); + projectDir, + "tools_def.txt"); + System.out.println("After initInfo!"); + FpdParserTask fpt = new FpdParserTask(); + fpt.parseFpdFile(new File(projectDir + "/EdkNt32Pkg/Nt32.fpd")); ca.execute(); } }