2 CollectPCDAction class.
4 This action class is to collect PCD information from MSA, SPD, FPD xml file.
5 This class will be used for wizard and build tools, So it can *not* inherit
6 from buildAction or wizardAction.
8 Copyright (c) 2006, Intel Corporation
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 package org
.tianocore
.build
.pcd
.action
;
20 import java
.io
.BufferedReader
;
22 import java
.io
.FileReader
;
23 import java
.io
.IOException
;
24 import java
.math
.BigInteger
;
25 import java
.util
.ArrayList
;
26 import java
.util
.Comparator
;
27 import java
.util
.HashMap
;
28 import java
.util
.List
;
29 import java
.util
.UUID
;
31 import org
.apache
.xmlbeans
.XmlException
;
32 import org
.apache
.xmlbeans
.XmlObject
;
33 import org
.tianocore
.DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
;
34 import org
.tianocore
.FrameworkModulesDocument
;
35 import org
.tianocore
.FrameworkPlatformDescriptionDocument
;
36 import org
.tianocore
.ModuleSADocument
;
37 import org
.tianocore
.PcdBuildDefinitionDocument
.PcdBuildDefinition
;
38 import org
.tianocore
.build
.global
.GlobalData
;
39 import org
.tianocore
.build
.global
.SurfaceAreaQuery
;
40 import org
.tianocore
.build
.pcd
.action
.ActionMessage
;
41 import org
.tianocore
.build
.pcd
.entity
.DynamicTokenValue
;
42 import org
.tianocore
.build
.pcd
.entity
.MemoryDatabaseManager
;
43 import org
.tianocore
.build
.pcd
.entity
.SkuInstance
;
44 import org
.tianocore
.build
.pcd
.entity
.Token
;
45 import org
.tianocore
.build
.pcd
.entity
.UsageInstance
;
46 import org
.tianocore
.build
.pcd
.exception
.EntityException
;
47 import org
.tianocore
.ModuleTypeDef
;
49 class CStructTypeDeclaration
{
55 public CStructTypeDeclaration (String key
, int alignmentSize
, String cCode
, boolean initTable
) {
57 this.alignmentSize
= alignmentSize
;
59 this.initTable
= initTable
;
64 private ArrayList
<String
> al
;
65 private ArrayList
<String
> alComments
;
69 public StringTable (String phase
) {
71 al
= new ArrayList
<String
>();
72 alComments
= new ArrayList
<String
>();
76 public String
getSizeMacro () {
77 return String
.format(PcdDatabase
.StringTableSizeMacro
, phase
, getSize());
80 private int getSize () {
82 // We have at least one Unicode Character in the table.
84 return len
== 0 ?
1 : len
;
87 public int getTableLen () {
88 return al
.size() == 0 ?
1 : al
.size();
91 public String
getExistanceMacro () {
92 return String
.format(PcdDatabase
.StringTableExistenceMacro
, phase
, (al
.size() == 0)?
"TRUE":"FALSE");
95 public void genCodeNew (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
) {
96 final String stringTable
= "StringTable";
97 final String tab
= "\t";
98 final String newLine
= "\r\n";
99 final String commaNewLine
= ",\r\n";
101 CStructTypeDeclaration decl
;
103 String cDeclCode
= "";
104 String cInstCode
= "";
107 // If we have a empty StringTable
109 if (al
.size() == 0) {
110 cDeclCode
+= String
.format("%-20s%s[1]; /* StringTable is empty */", "UINT16", stringTable
) + newLine
;
111 decl
= new CStructTypeDeclaration (
119 cInstCode
= String
.format("/* %s */", stringTable
) + newLine
+ tab
+ "{ 0 }";
120 instTable
.put(stringTable
, cInstCode
);
124 // If there is any String in the StringTable
126 for (int i
= 0; i
< al
.size(); i
++) {
127 String str
= al
.get(i
);
128 String stringTableName
;
132 // StringTable is a well-known name in the PCD DXE driver
134 stringTableName
= stringTable
;
137 stringTableName
= String
.format("%s_%d", stringTable
, i
);
140 cDeclCode
+= String
.format("%-20s%s[%d]; /* %s */", "UINT16", stringTableName
, str
.length() + 1, alComments
.get(i
)) + newLine
;
143 cInstCode
= "/* StringTable */" + newLine
;
145 cInstCode
+= tab
+ String
.format("L\"%s\" /* %s */", al
.get(i
), alComments
.get(i
));
146 if (i
!= al
.size() - 1) {
147 cInstCode
+= commaNewLine
;
151 decl
= new CStructTypeDeclaration (
159 instTable
.put(stringTable
, cInstCode
);
163 public String
getTypeDeclaration () {
167 final String stringTable
= "StringTable";
168 final String tab
= "\t";
169 final String newLine
= ";\r\n";
171 output
= "/* StringTable */\r\n";
173 if (al
.size() == 0) {
174 output
+= tab
+ String
.format("UINT16 %s[1] /* StringTable is Empty */", stringTable
) + newLine
;
177 for (int i
= 0; i
< al
.size(); i
++) {
178 String str
= al
.get(i
);
182 // StringTable is a well-known name in the PCD DXE driver
184 output
+= tab
+ String
.format("UINT16 %s[%d] /* %s */", stringTable
, str
.length() + 1, alComments
.get(i
)) + newLine
;
186 output
+= tab
+ String
.format("UINT16 %s_%d[%d] /* %s */", stringTable
, i
, str
.length() + 1, alComments
.get(i
)) + newLine
;
194 public ArrayList
<String
> getInstantiation () {
195 ArrayList
<String
> output
= new ArrayList
<String
>();
197 output
.add("/* StringTable */");
199 if (al
.size() == 0) {
204 for (int i
= 0; i
< al
.size(); i
++) {
205 str
= String
.format("L\"%s\" /* %s */", al
.get(i
), alComments
.get(i
));
206 if (i
!= al
.size() - 1) {
216 public int add (String inputStr
, Token token
) {
220 String str
= inputStr
;
223 // The input can be two types:
224 // "L\"Bootmode\"" or "Bootmode".
225 // We drop the L\" and \" for the first type.
226 if (str
.startsWith("L\"") && str
.endsWith("\"")) {
227 str
= str
.substring(2, str
.length() - 1);
230 // Check if StringTable has this String already.
231 // If so, return the current pos.
233 for (i
= 0, pos
= 0; i
< al
.size(); i
++) {
234 String s
= al
.get(i
);;
239 pos
= s
.length() + 1;
245 // Include the NULL character at the end of String
247 len
+= str
.length() + 1;
249 alComments
.add(token
.getPrimaryKeyString());
256 private ArrayList
<Integer
> al
;
257 private ArrayList
<String
> alComments
;
258 private String phase
;
261 public SizeTable (String phase
) {
263 al
= new ArrayList
<Integer
>();
264 alComments
= new ArrayList
<String
>();
268 public void genCodeNew (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) {
269 final String name
= "SizeTable";
271 CStructTypeDeclaration decl
;
274 cCode
= String
.format(PcdDatabase
.SizeTableDeclaration
, phase
);
275 decl
= new CStructTypeDeclaration (
284 cCode
= PcdDatabase
.genInstantiationStr(getInstantiation());
285 instTable
.put(name
, cCode
);
288 public String
getTypeDeclaration () {
289 return String
.format(PcdDatabase
.SizeTableDeclaration
, phase
);
292 public ArrayList
<String
> getInstantiation () {
293 ArrayList
<String
> Output
= new ArrayList
<String
>();
295 Output
.add("/* SizeTable */");
297 if (al
.size() == 0) {
300 for (int index
= 0; index
< al
.size(); index
++) {
301 Integer n
= al
.get(index
);
302 String str
= "\t" + n
.toString();
304 if (index
!= (al
.size() - 1)) {
308 str
+= " /* " + alComments
.get(index
) + " */";
318 public int add (Token token
) {
322 al
.add(token
.datumSize
);
323 alComments
.add(token
.getPrimaryKeyString());
328 public int getTableLen () {
329 return al
.size() == 0 ?
1 : al
.size();
335 private ArrayList
<UUID
> al
;
336 private ArrayList
<String
> alComments
;
337 private String phase
;
339 private int bodyLineNum
;
341 public GuidTable (String phase
) {
343 al
= new ArrayList
<UUID
>();
344 alComments
= new ArrayList
<String
>();
349 public String
getSizeMacro () {
350 return String
.format(PcdDatabase
.GuidTableSizeMacro
, phase
, getSize());
353 private int getSize () {
354 return (al
.size() == 0)?
1 : al
.size();
357 public String
getExistanceMacro () {
358 return String
.format(PcdDatabase
.GuidTableExistenceMacro
, phase
, (al
.size() == 0)?
"TRUE":"FALSE");
361 public void genCodeNew (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) {
362 final String name
= "GuidTable";
364 CStructTypeDeclaration decl
;
367 cCode
+= String
.format(PcdDatabase
.GuidTableDeclaration
, phase
);
368 decl
= new CStructTypeDeclaration (
377 cCode
= PcdDatabase
.genInstantiationStr(getInstantiation());
378 instTable
.put(name
, cCode
);
381 public String
getTypeDeclaration () {
382 return String
.format(PcdDatabase
.GuidTableDeclaration
, phase
);
385 private String
getUuidCString (UUID uuid
) {
386 String
[] guidStrArray
;
388 guidStrArray
=(uuid
.toString()).split("-");
390 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}}",
394 (guidStrArray
[3].substring(0, 2)),
395 (guidStrArray
[3].substring(2, 4)),
396 (guidStrArray
[4].substring(0, 2)),
397 (guidStrArray
[4].substring(2, 4)),
398 (guidStrArray
[4].substring(4, 6)),
399 (guidStrArray
[4].substring(6, 8)),
400 (guidStrArray
[4].substring(8, 10)),
401 (guidStrArray
[4].substring(10, 12))
405 public ArrayList
<String
> getInstantiation () {
406 ArrayList
<String
> Output
= new ArrayList
<String
>();
408 Output
.add("/* GuidTable */");
410 if (al
.size() == 0) {
411 Output
.add("\t" + getUuidCString(new UUID(0, 0)));
414 for (int i
= 0; i
< al
.size(); i
++) {
415 String str
= "\t" + getUuidCString(al
.get(i
));
417 str
+= "/* " + alComments
.get(i
) + " */";
418 if (i
!= (al
.size() - 1)) {
430 public int add (UUID uuid
, String name
) {
432 // Check if GuidTable has this entry already.
433 // If so, return the GuidTable index.
435 for (int i
= 0; i
< al
.size(); i
++) {
436 if (al
.get(i
).equals(uuid
)) {
443 alComments
.add(name
);
446 // Return the previous Table Index
451 public int getTableLen () {
452 return al
.size() == 0 ?
0 : al
.size();
458 private ArrayList
<Integer
[]> al
;
459 private ArrayList
<String
> alComment
;
460 private String phase
;
463 public SkuIdTable (String phase
) {
465 al
= new ArrayList
<Integer
[]>();
466 alComment
= new ArrayList
<String
>();
470 public String
getSizeMacro () {
471 return String
.format(PcdDatabase
.SkuIdTableSizeMacro
, phase
, getSize());
474 private int getSize () {
475 return (len
== 0)?
1 : len
;
478 public String
getExistanceMacro () {
479 return String
.format(PcdDatabase
.SkuTableExistenceMacro
, phase
, (al
.size() == 0)?
"TRUE":"FALSE");
482 public void genCodeNew (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) {
483 final String name
= "SkuIdTable";
485 CStructTypeDeclaration decl
;
488 cCode
+= String
.format(PcdDatabase
.SkuIdTableDeclaration
, phase
);
489 decl
= new CStructTypeDeclaration (
498 cCode
= PcdDatabase
.genInstantiationStr(getInstantiation());
499 instTable
.put(name
, cCode
);
502 // SystemSkuId is in PEI phase PCD Database
504 if (phase
.equalsIgnoreCase("PEI")) {
505 decl
= new CStructTypeDeclaration (
508 String
.format("%-20sSystemSkuId;\r\n", "SKU_ID"),
513 instTable
.put("SystemSkuId", "0");
518 public String
getTypeDeclaration () {
519 return String
.format(PcdDatabase
.SkuIdTableDeclaration
, phase
);
522 public ArrayList
<String
> getInstantiation () {
523 ArrayList
<String
> Output
= new ArrayList
<String
> ();
525 Output
.add("/* SkuIdTable */");
528 if (al
.size() == 0) {
532 for (int index
= 0; index
< al
.size(); index
++) {
535 str
= "/* " + alComment
.get(index
) + "*/ ";
536 str
+= "/* MaxSku */ ";
539 Integer
[] ia
= al
.get(index
);
541 str
+= "\t" + ia
[0].toString() + ", ";
542 for (int index2
= 1; index2
< ia
.length
; index2
++) {
543 str
+= ia
[index2
].toString();
544 if (!((index2
== ia
.length
- 1) && (index
== al
.size() - 1))) {
558 public int add (Token token
) {
564 // Check if this SKU_ID Array is already in the table
568 Integer
[] s
= (Integer
[]) o
;
569 boolean different
= false;
570 if (s
[0] == token
.getSkuIdCount()) {
571 for (index
= 1; index
< s
.length
; index
++) {
572 if (s
[index
] != token
.skuData
.get(index
-1).id
) {
587 Integer
[] skuIds
= new Integer
[token
.skuData
.size() + 1];
588 skuIds
[0] = new Integer(token
.skuData
.size());
589 for (index
= 1; index
< skuIds
.length
; index
++) {
590 skuIds
[index
] = new Integer(token
.skuData
.get(index
- 1).id
);
595 len
+= skuIds
.length
;
597 alComment
.add(token
.getPrimaryKeyString());
602 public int getTableLen () {
603 return al
.size() == 0 ?
1 : al
.size();
608 class LocalTokenNumberTable
{
609 private ArrayList
<String
> al
;
610 private ArrayList
<String
> alComment
;
611 private String phase
;
614 public LocalTokenNumberTable (String phase
) {
616 al
= new ArrayList
<String
>();
617 alComment
= new ArrayList
<String
>();
622 public String
getSizeMacro () {
623 return String
.format(PcdDatabase
.LocalTokenNumberTableSizeMacro
, phase
, getSize())
624 + String
.format(PcdDatabase
.LocalTokenNumberSizeMacro
, phase
, al
.size());
627 public int getSize () {
628 return (al
.size() == 0)?
1 : al
.size();
631 public String
getExistanceMacro () {
632 return String
.format(PcdDatabase
.DatabaseExistenceMacro
, phase
, (al
.size() == 0)?
"TRUE":"FALSE");
635 public void genCodeNew (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) {
636 final String name
= "LocalTokenNumberTable";
638 CStructTypeDeclaration decl
;
641 cCode
+= String
.format(PcdDatabase
.LocalTokenNumberTableDeclaration
, phase
);
642 decl
= new CStructTypeDeclaration (
650 cCode
= PcdDatabase
.genInstantiationStr(getInstantiation());
651 instTable
.put(name
, cCode
);
654 public String
getTypeDeclaration () {
655 return String
.format(PcdDatabase
.LocalTokenNumberTableDeclaration
, phase
);
658 public ArrayList
<String
> getInstantiation () {
659 ArrayList
<String
> output
= new ArrayList
<String
>();
661 output
.add("/* LocalTokenNumberTable */");
664 if (al
.size() == 0) {
668 for (int index
= 0; index
< al
.size(); index
++) {
671 str
= "\t" + (String
)al
.get(index
);
673 str
+= " /* " + alComment
.get(index
) + " */ ";
676 if (index
!= (al
.size() - 1)) {
689 public int add (Token token
) {
695 str
= String
.format(PcdDatabase
.offsetOfStrTemplate
, phase
, token
.hasDefaultValue() ?
"Init" : "Uninit", token
.getPrimaryKeyString());
697 if (token
.isUnicodeStringType()) {
698 str
+= " | PCD_TYPE_STRING";
701 if (token
.isSkuEnable()) {
702 str
+= " | PCD_TYPE_SKU_ENABLED";
705 if (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.HII_TYPE
) {
706 str
+= " | PCD_TYPE_HII";
709 if (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.VPD_TYPE
) {
710 str
+= " | PCD_TYPE_VPD";
714 alComment
.add(token
.getPrimaryKeyString());
723 public Integer guidTableIdx
;
724 public Long exTokenNumber
;
725 public Long localTokenIdx
;
727 public ExTriplet (int guidTableIdx
, long exTokenNumber
, long localTokenIdx
) {
728 this.guidTableIdx
= new Integer(guidTableIdx
);
729 this.exTokenNumber
= new Long(exTokenNumber
);
730 this.localTokenIdx
= new Long(localTokenIdx
);
734 private ArrayList
<ExTriplet
> al
;
735 private ArrayList
<String
> alComment
;
736 private String phase
;
738 private int bodyLineNum
;
740 public ExMapTable (String phase
) {
742 al
= new ArrayList
<ExTriplet
>();
743 alComment
= new ArrayList
<String
>();
748 public String
getSizeMacro () {
749 return String
.format(PcdDatabase
.ExMapTableSizeMacro
, phase
, getTableLen())
750 + String
.format(PcdDatabase
.ExTokenNumber
, phase
, al
.size());
753 public String
getExistanceMacro () {
754 return String
.format(PcdDatabase
.ExMapTableExistenceMacro
, phase
, (al
.size() == 0)?
"TRUE":"FALSE");
757 public void genCodeNew (ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) {
758 final String exMapTableName
= "ExMapTable";
762 CStructTypeDeclaration decl
;
765 cCode
+= String
.format(PcdDatabase
.ExMapTableDeclaration
, phase
);
766 decl
= new CStructTypeDeclaration (
775 cCode
= PcdDatabase
.genInstantiationStr(getInstantiation());
776 instTable
.put(exMapTableName
, cCode
);
779 public String
getTypeDeclaration () {
780 return String
.format(PcdDatabase
.ExMapTableDeclaration
, phase
);
783 public ArrayList
<String
> getInstantiation () {
784 ArrayList
<String
> Output
= new ArrayList
<String
>();
786 Output
.add("/* ExMapTable */");
788 if (al
.size() == 0) {
789 Output
.add("\t{0, 0, 0}");
793 for (index
= 0; index
< al
.size(); index
++) {
796 ExTriplet e
= (ExTriplet
)al
.get(index
);
798 str
= "\t" + "{ " + String
.format("0x%08X", e
.exTokenNumber
) + ", ";
799 str
+= e
.localTokenIdx
.toString() + ", ";
800 str
+= e
.guidTableIdx
.toString();
802 str
+= "}" + " /* " + alComment
.get(index
) + " */" ;
804 if (index
!= al
.size() - 1) {
818 public int add (int localTokenIdx
, long exTokenNum
, int guidTableIdx
, String name
) {
822 al
.add(new ExTriplet(guidTableIdx
, exTokenNum
, localTokenIdx
));
828 public int getTableLen () {
829 return al
.size() == 0 ?
1 : al
.size();
833 // To simplify the algorithm for GetNextToken and GetNextTokenSpace in
834 // PCD PEIM/Driver, we need to sort the ExMapTable according to the
839 class ExTripletComp
implements Comparator
<ExTriplet
> {
840 public int compare (ExTriplet a
, ExTriplet b
) {
841 if (a
.guidTableIdx
== b
.guidTableIdx
) {
842 if (a
.exTokenNumber
> b
.exTokenNumber
) {
844 } else if (a
.exTokenNumber
> b
.exTokenNumber
) {
851 return a
.guidTableIdx
- b
.guidTableIdx
;
855 private void sortTable () {
856 java
.util
.Comparator
<ExTriplet
> comparator
= new ExTripletComp();
857 java
.util
.Collections
.sort(al
, comparator
);
863 private final static int SkuHeadAlignmentSize
= 4;
864 private final String newLine
= "\r\n";
865 private final String commaNewLine
= ",\r\n";
866 private final String tab
= "\t";
867 public final static String ExMapTableDeclaration
= "DYNAMICEX_MAPPING ExMapTable[%s_EXMAPPING_TABLE_SIZE];\r\n";
868 public final static String GuidTableDeclaration
= "EFI_GUID GuidTable[%s_GUID_TABLE_SIZE];\r\n";
869 public final static String LocalTokenNumberTableDeclaration
= "UINT32 LocalTokenNumberTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";
870 public final static String StringTableDeclaration
= "UINT16 StringTable[%s_STRING_TABLE_SIZE];\r\n";
871 public final static String SizeTableDeclaration
= "UINT16 SizeTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";
872 public final static String SkuIdTableDeclaration
= "UINT8 SkuIdTable[%s_SKUID_TABLE_SIZE];\r\n";
875 public final static String ExMapTableSizeMacro
= "#define %s_EXMAPPING_TABLE_SIZE %d\r\n";
876 public final static String ExTokenNumber
= "#define %s_EX_TOKEN_NUMBER %d\r\n";
877 public final static String GuidTableSizeMacro
= "#define %s_GUID_TABLE_SIZE %d\r\n";
878 public final static String LocalTokenNumberTableSizeMacro
= "#define %s_LOCAL_TOKEN_NUMBER_TABLE_SIZE %d\r\n";
879 public final static String LocalTokenNumberSizeMacro
= "#define %s_LOCAL_TOKEN_NUMBER %d\r\n";
880 public final static String StringTableSizeMacro
= "#define %s_STRING_TABLE_SIZE %d\r\n";
881 public final static String SkuIdTableSizeMacro
= "#define %s_SKUID_TABLE_SIZE %d\r\n";
884 public final static String ExMapTableExistenceMacro
= "#define %s_EXMAP_TABLE_EMPTY %s\r\n";
885 public final static String GuidTableExistenceMacro
= "#define %s_GUID_TABLE_EMPTY %s\r\n";
886 public final static String DatabaseExistenceMacro
= "#define %s_DATABASE_EMPTY %s\r\n";
887 public final static String StringTableExistenceMacro
= "#define %s_STRING_TABLE_EMPTY %s\r\n";
888 public final static String SkuTableExistenceMacro
= "#define %s_SKUID_TABLE_EMPTY %s\r\n";
890 public final static String offsetOfSkuHeadStrTemplate
= "offsetof(%s_PCD_DATABASE, %s.%s_SkuDataTable)";
891 public final static String offsetOfVariableEnabledDefault
= "offsetof(%s_PCD_DATABASE, %s.%s_VariableDefault_%d)";
892 public final static String offsetOfStrTemplate
= "offsetof(%s_PCD_DATABASE, %s.%s)";
894 private final static String skuDataTableTemplate
= "SkuDataTable";
897 private StringTable stringTable
;
898 private GuidTable guidTable
;
899 private LocalTokenNumberTable localTokenNumberTable
;
900 private SkuIdTable skuIdTable
;
901 private SizeTable sizeTable
;
902 private ExMapTable exMapTable
;
904 private ArrayList
<Token
> alTokens
;
905 private String phase
;
906 private int assignedTokenNumber
;
909 // Use two class global variable to store
912 private String privateGlobalName
;
913 private String privateGlobalCCode
;
915 // After Major changes done to the PCD
916 // database generation class PcdDatabase
917 // Please increment the version and please
918 // also update the version number in PCD
919 // service PEIM and DXE driver accordingly.
921 private final int version
= 2;
923 private String hString
;
924 private String cString
;
927 class AlignmentSizeComp
implements Comparator
<Token
> {
928 public int compare (Token a
, Token b
) {
929 return getAlignmentSize(b
)
930 - getAlignmentSize(a
);
934 public PcdDatabase (ArrayList
<Token
> alTokens
, String exePhase
, int startLen
) {
937 stringTable
= new StringTable(phase
);
938 guidTable
= new GuidTable(phase
);
939 localTokenNumberTable
= new LocalTokenNumberTable(phase
);
940 skuIdTable
= new SkuIdTable(phase
);
941 sizeTable
= new SizeTable(phase
);
942 exMapTable
= new ExMapTable(phase
);
944 assignedTokenNumber
= startLen
+ 1;
945 this.alTokens
= alTokens
;
948 private void getNonExAndExTokens (ArrayList
<Token
> alTokens
, List
<Token
> nexTokens
, List
<Token
> exTokens
) {
949 for (int i
= 0; i
< alTokens
.size(); i
++) {
950 Token t
= (Token
)alTokens
.get(i
);
951 if (t
.isDynamicEx()) {
961 private void getTwoGroupsOfTokens (ArrayList
<Token
> alTokens
, List
<Token
> initTokens
, List
<Token
> uninitTokens
) {
962 for (int i
= 0; i
< alTokens
.size(); i
++) {
963 Token t
= (Token
)alTokens
.get(i
);
964 if (t
.hasDefaultValue()) {
974 private int getDataTypeAlignmentSize (Token token
) {
975 switch (token
.datumType
) {
993 private int getAlignmentSize (Token token
) {
994 if (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.HII_TYPE
) {
998 if (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.VPD_TYPE
) {
1002 if (token
.isUnicodeStringType()) {
1006 return getDataTypeAlignmentSize(token
);
1009 public String
getCString () {
1013 public String
getHString () {
1017 private void genCodeWorker(Token t
,
1018 ArrayList
<CStructTypeDeclaration
> declaList
,
1019 HashMap
<String
, String
> instTable
, String phase
)
1020 throws EntityException
{
1022 CStructTypeDeclaration decl
;
1025 // Insert SKU_HEAD if isSkuEnable is true
1027 if (t
.isSkuEnable()) {
1029 tableIdx
= skuIdTable
.add(t
);
1030 decl
= new CStructTypeDeclaration(t
.getPrimaryKeyString(),
1031 SkuHeadAlignmentSize
, getSkuEnabledTypeDeclaration(t
), true);
1032 declaList
.add(decl
);
1033 instTable
.put(t
.getPrimaryKeyString(),
1034 getSkuEnabledTypeInstantiaion(t
, tableIdx
));
1038 // Insert PCD_ENTRY declaration and instantiation
1040 getCDeclarationString(t
);
1042 decl
= new CStructTypeDeclaration(privateGlobalName
,
1043 getAlignmentSize(t
), privateGlobalCCode
, t
.hasDefaultValue());
1044 declaList
.add(decl
);
1046 if (t
.hasDefaultValue()) {
1047 instTable
.put(privateGlobalName
,
1048 getTypeInstantiation(t
, declaList
, instTable
, phase
)
1054 private void ProcessTokensNew (List
<Token
> tokens
,
1055 ArrayList
<CStructTypeDeclaration
> cStructDeclList
,
1056 HashMap
<String
, String
> cStructInstTable
,
1059 throws EntityException
{
1061 for (int idx
= 0; idx
< tokens
.size(); idx
++) {
1062 Token t
= tokens
.get(idx
);
1064 genCodeWorker (t
, cStructDeclList
, cStructInstTable
, phase
);
1067 localTokenNumberTable
.add(t
);
1068 t
.tokenNumber
= assignedTokenNumber
++;
1071 // Add a mapping if this dynamic PCD entry is a EX type
1073 if (t
.isDynamicEx()) {
1074 exMapTable
.add((int)t
.tokenNumber
,
1075 t
.dynamicExTokenNumber
,
1076 guidTable
.add(t
.tokenSpaceName
, t
.getPrimaryKeyString()),
1077 t
.getPrimaryKeyString()
1084 public void genCodeNew () throws EntityException
{
1086 ArrayList
<CStructTypeDeclaration
> cStructDeclList
= new ArrayList
<CStructTypeDeclaration
>();
1087 HashMap
<String
, String
> cStructInstTable
= new HashMap
<String
, String
>();
1089 List
<Token
> nexTokens
= new ArrayList
<Token
> ();
1090 List
<Token
> exTokens
= new ArrayList
<Token
> ();
1092 getNonExAndExTokens (alTokens
, nexTokens
, exTokens
);
1095 // We have to process Non-Ex type PCD entry first. The reason is
1096 // that our optimization assumes that the Token Number of Non-Ex
1097 // PCD entry start from 1 (for PEI phase) and grows continously upwards.
1099 // EX type token number starts from the last Non-EX PCD entry and
1100 // grows continously upwards.
1102 ProcessTokensNew (nexTokens
, cStructDeclList
, cStructInstTable
, phase
);
1103 ProcessTokensNew (exTokens
, cStructDeclList
, cStructInstTable
, phase
);
1105 stringTable
.genCodeNew(cStructDeclList
, cStructInstTable
);
1106 skuIdTable
.genCodeNew(cStructDeclList
, cStructInstTable
, phase
);
1107 exMapTable
.genCodeNew(cStructDeclList
, cStructInstTable
, phase
);
1108 localTokenNumberTable
.genCodeNew(cStructDeclList
, cStructInstTable
, phase
);
1109 sizeTable
.genCodeNew(cStructDeclList
, cStructInstTable
, phase
);
1110 guidTable
.genCodeNew(cStructDeclList
, cStructInstTable
, phase
);
1112 hString
= genCMacroCode ();
1114 HashMap
<String
, String
> result
;
1116 result
= genCStructCode(cStructDeclList
,
1121 hString
+= result
.get("initDeclStr");
1122 hString
+= result
.get("uninitDeclStr");
1124 hString
+= String
.format("#define PCD_%s_SERVICE_DRIVER_VERSION %d", phase
, version
);
1126 cString
= newLine
+ newLine
+ result
.get("initInstStr");
1130 private String
genCMacroCode () {
1131 String macroStr
= "";
1134 // Generate size info Macro for all Tables
1136 macroStr
+= guidTable
.getSizeMacro();
1137 macroStr
+= stringTable
.getSizeMacro();
1138 macroStr
+= skuIdTable
.getSizeMacro();
1139 macroStr
+= localTokenNumberTable
.getSizeMacro();
1140 macroStr
+= exMapTable
.getSizeMacro();
1143 // Generate existance info Macro for all Tables
1145 macroStr
+= guidTable
.getExistanceMacro();
1146 macroStr
+= stringTable
.getExistanceMacro();
1147 macroStr
+= skuIdTable
.getExistanceMacro();
1148 macroStr
+= localTokenNumberTable
.getExistanceMacro();
1149 macroStr
+= exMapTable
.getExistanceMacro();
1151 macroStr
+= newLine
;
1156 private HashMap
<String
, String
> genCStructCode(
1157 ArrayList
<CStructTypeDeclaration
> declaList
,
1158 HashMap
<String
, String
> instTable
,
1163 HashMap
<String
, String
> result
= new HashMap
<String
, String
>();
1164 HashMap
<Integer
, ArrayList
<String
>> alignmentInitDecl
= new HashMap
<Integer
, ArrayList
<String
>>();
1165 HashMap
<Integer
, ArrayList
<String
>> alignmentUninitDecl
= new HashMap
<Integer
, ArrayList
<String
>>();
1166 HashMap
<Integer
, ArrayList
<String
>> alignmentInitInst
= new HashMap
<Integer
, ArrayList
<String
>>();
1169 // Initialize the storage for each alignment
1171 for (i
= 8; i
> 0; i
>>=1) {
1172 alignmentInitDecl
.put(new Integer(i
), new ArrayList
<String
>());
1173 alignmentInitInst
.put(new Integer(i
), new ArrayList
<String
>());
1174 alignmentUninitDecl
.put(new Integer(i
), new ArrayList
<String
>());
1177 String initDeclStr
= "typedef struct {" + newLine
;
1178 String initInstStr
= String
.format("%s_PCD_DATABASE_INIT g%sPcdDbInit = { ", phase
.toUpperCase(), phase
.toUpperCase()) + newLine
;
1179 String uninitDeclStr
= "typedef struct {" + newLine
;
1182 // Sort all C declaration and instantiation base on Alignment Size
1184 for (Object d
: declaList
) {
1185 CStructTypeDeclaration decl
= (CStructTypeDeclaration
) d
;
1187 if (decl
.initTable
) {
1188 alignmentInitDecl
.get(new Integer(decl
.alignmentSize
)).add(decl
.cCode
);
1189 alignmentInitInst
.get(new Integer(decl
.alignmentSize
)).add(instTable
.get(decl
.key
));
1191 alignmentUninitDecl
.get(new Integer(decl
.alignmentSize
)).add(decl
.cCode
);
1196 // Generate code for every alignment size
1198 boolean uinitDatabaseEmpty
= true;
1199 for (int align
= 8; align
> 0; align
>>= 1) {
1200 ArrayList
<String
> declaListBasedOnAlignment
= alignmentInitDecl
.get(new Integer(align
));
1201 ArrayList
<String
> instListBasedOnAlignment
= alignmentInitInst
.get(new Integer(align
));
1202 for (i
= 0; i
< declaListBasedOnAlignment
.size(); i
++) {
1203 initDeclStr
+= tab
+ declaListBasedOnAlignment
.get(i
);
1204 initInstStr
+= tab
+ instListBasedOnAlignment
.get(i
);
1207 // We made a assumption that both PEI_PCD_DATABASE and DXE_PCD_DATABASE
1208 // has a least one data memember with alignment size of 1. So we can
1209 // remove the last "," in the C structure instantiation string. Luckily,
1210 // this is true as both data structure has SKUID_TABLE anyway.
1212 if ((align
== 1) && (i
== declaListBasedOnAlignment
.size() - 1)) {
1213 initInstStr
+= newLine
;
1215 initInstStr
+= commaNewLine
;
1219 declaListBasedOnAlignment
= alignmentUninitDecl
.get(new Integer(align
));
1221 if (declaListBasedOnAlignment
.size() != 0) {
1222 uinitDatabaseEmpty
= false;
1225 for (Object d
: declaListBasedOnAlignment
) {
1226 String s
= (String
)d
;
1227 uninitDeclStr
+= tab
+ s
;
1231 if (uinitDatabaseEmpty
) {
1232 uninitDeclStr
+= tab
+ String
.format("%-20sdummy; /* PCD_DATABASE_UNINIT is emptry */\r\n", "UINT8");
1235 initDeclStr
+= String
.format("} %s_PCD_DATABASE_INIT;", phase
) + newLine
+ newLine
;
1236 initInstStr
+= "};" + newLine
;
1237 uninitDeclStr
+= String
.format("} %s_PCD_DATABASE_UNINIT;", phase
) + newLine
+ newLine
;
1239 result
.put("initDeclStr", initDeclStr
);
1240 result
.put("initInstStr", initInstStr
);
1241 result
.put("uninitDeclStr", uninitDeclStr
);
1246 public void genCode ()
1247 throws EntityException
{
1249 final String newLine
= "\r\n";
1250 final String declNewLine
= ";\r\n";
1251 final String tab
= "\t";
1252 final String commaNewLine
= ", \r\n";
1255 ArrayList
<String
> decla
;
1256 ArrayList
<String
> inst
;
1258 String macroStr
= "";
1259 String initDeclStr
= "";
1260 String initInstStr
= "";
1261 String uninitDeclStr
= "";
1263 List
<Token
> initTokens
= new ArrayList
<Token
> ();
1264 List
<Token
> uninitTokens
= new ArrayList
<Token
> ();
1266 HashMap
<String
, ArrayList
<String
>> initCode
= new HashMap
<String
, ArrayList
<String
>> ();
1267 HashMap
<String
, ArrayList
<String
>> uninitCode
= new HashMap
<String
, ArrayList
<String
>> ();
1269 getTwoGroupsOfTokens (alTokens
, initTokens
, uninitTokens
);
1272 // Generate Structure Declaration for PcdTokens without Default Value
1273 // PEI_PCD_DATABASE_INIT
1275 java
.util
.Comparator
<Token
> comparator
= new AlignmentSizeComp();
1276 java
.util
.Collections
.sort(initTokens
, comparator
);
1277 initCode
= processTokens(initTokens
);
1280 // Generate Structure Declaration for PcdTokens without Default Value
1281 // PEI_PCD_DATABASE_UNINIT
1283 java
.util
.Collections
.sort(uninitTokens
, comparator
);
1284 uninitCode
= processTokens(uninitTokens
);
1287 // Generate size info Macro for all Tables
1289 macroStr
+= guidTable
.getSizeMacro();
1290 macroStr
+= stringTable
.getSizeMacro();
1291 macroStr
+= skuIdTable
.getSizeMacro();
1292 macroStr
+= localTokenNumberTable
.getSizeMacro();
1293 macroStr
+= exMapTable
.getSizeMacro();
1296 // Generate existance info Macro for all Tables
1298 macroStr
+= guidTable
.getExistanceMacro();
1299 macroStr
+= stringTable
.getExistanceMacro();
1300 macroStr
+= skuIdTable
.getExistanceMacro();
1301 macroStr
+= localTokenNumberTable
.getExistanceMacro();
1302 macroStr
+= exMapTable
.getExistanceMacro();
1305 // Generate Structure Declaration for PcdTokens with Default Value
1306 // for example PEI_PCD_DATABASE_INIT
1308 initDeclStr
+= "typedef struct {" + newLine
;
1310 initDeclStr
+= tab
+ exMapTable
.getTypeDeclaration();
1311 initDeclStr
+= tab
+ guidTable
.getTypeDeclaration();
1312 initDeclStr
+= tab
+ localTokenNumberTable
.getTypeDeclaration();
1313 initDeclStr
+= tab
+ stringTable
.getTypeDeclaration();
1314 initDeclStr
+= tab
+ sizeTable
.getTypeDeclaration();
1315 initDeclStr
+= tab
+ skuIdTable
.getTypeDeclaration();
1316 if (phase
.equalsIgnoreCase("PEI")) {
1317 initDeclStr
+= tab
+ "SKU_ID SystemSkuId;" + newLine
;
1320 decla
= initCode
.get(new String("Declaration"));
1321 for (i
= 0; i
< decla
.size(); i
++) {
1322 initDeclStr
+= tab
+ decla
.get(i
) + declNewLine
;
1326 // Generate Structure Declaration for PcdToken with SkuEnabled
1328 decla
= initCode
.get("DeclarationForSku");
1330 for (i
= 0; i
< decla
.size(); i
++) {
1331 initDeclStr
+= tab
+ decla
.get(i
) + declNewLine
;
1334 initDeclStr
+= String
.format("} %s_PCD_DATABASE_INIT;\r\n\r\n", phase
);
1337 // Generate MACRO for structure intialization of PCDTokens with Default Value
1338 // The sequence must match the sequence of declaration of the memembers in the structure
1339 String tmp
= String
.format("%s_PCD_DATABASE_INIT g%sPcdDbInit = { ", phase
.toUpperCase(), phase
.toUpperCase());
1340 initInstStr
+= tmp
+ newLine
;
1341 initInstStr
+= tab
+ genInstantiationStr(exMapTable
.getInstantiation()) + commaNewLine
;
1342 initInstStr
+= tab
+ genInstantiationStr(guidTable
.getInstantiation()) + commaNewLine
;
1343 initInstStr
+= tab
+ genInstantiationStr(localTokenNumberTable
.getInstantiation()) + commaNewLine
;
1344 initInstStr
+= tab
+ genInstantiationStr(stringTable
.getInstantiation()) + commaNewLine
;
1345 initInstStr
+= tab
+ genInstantiationStr(sizeTable
.getInstantiation()) + commaNewLine
;
1346 initInstStr
+= tab
+ genInstantiationStr(skuIdTable
.getInstantiation()) + commaNewLine
;
1350 if (phase
.equalsIgnoreCase("PEI")) {
1351 initInstStr
+= tab
+ "0" + tab
+ "/* SystemSkuId */" + commaNewLine
;
1354 inst
= initCode
.get("Instantiation");
1355 for (i
= 0; i
< inst
.size(); i
++) {
1356 initInstStr
+= tab
+ inst
.get(i
) + commaNewLine
;
1359 inst
= initCode
.get("InstantiationForSku");
1360 for (i
= 0; i
< inst
.size(); i
++) {
1361 initInstStr
+= tab
+ inst
.get(i
);
1362 if (i
!= inst
.size() - 1) {
1363 initInstStr
+= commaNewLine
;
1367 initInstStr
+= "};";
1369 uninitDeclStr
+= "typedef struct {" + newLine
;
1371 decla
= uninitCode
.get("Declaration");
1372 if (decla
.size() == 0) {
1373 uninitDeclStr
+= "UINT8 dummy /* The UINT struct is empty */" + declNewLine
;
1376 for (i
= 0; i
< decla
.size(); i
++) {
1377 uninitDeclStr
+= tab
+ decla
.get(i
) + declNewLine
;
1380 decla
= uninitCode
.get("DeclarationForSku");
1382 for (i
= 0; i
< decla
.size(); i
++) {
1383 uninitDeclStr
+= tab
+ decla
.get(i
) + declNewLine
;
1387 uninitDeclStr
+= String
.format("} %s_PCD_DATABASE_UNINIT;\r\n\r\n", phase
);
1389 cString
= initInstStr
+ newLine
;
1390 hString
= macroStr
+ newLine
1391 + initDeclStr
+ newLine
1392 + uninitDeclStr
+ newLine
1395 hString
+= String
.format("#define PCD_%s_SERVICE_DRIVER_VERSION %d", phase
, version
);
1399 public static String
genInstantiationStr (ArrayList
<String
> alStr
) {
1401 for (int i
= 0; i
< alStr
.size(); i
++) {
1405 str
+= alStr
.get(i
);
1406 if (i
!= alStr
.size() - 1) {
1414 private HashMap
<String
, ArrayList
<String
>> processTokens (List
<Token
> alToken
)
1415 throws EntityException
{
1417 HashMap
<String
, ArrayList
<String
>> map
= new HashMap
<String
, ArrayList
<String
>>();
1419 ArrayList
<String
> decl
= new ArrayList
<String
>();
1420 ArrayList
<String
> declForSkuEnableType
= new ArrayList
<String
>();
1421 ArrayList
<String
> inst
= new ArrayList
<String
>();
1422 ArrayList
<String
> instForSkuEnableType
= new ArrayList
<String
>();
1424 for (int index
= 0; index
< alToken
.size(); index
++) {
1425 Token token
= alToken
.get(index
);
1427 if (token
.isSkuEnable()) {
1429 // BugBug: Schema only support Data type now
1433 tableIdx
= skuIdTable
.add(token
);
1435 decl
.add(getSkuEnabledTypeDeclaration(token
));
1436 if (token
.hasDefaultValue()) {
1437 inst
.add(getSkuEnabledTypeInstantiaion(token
, tableIdx
));
1440 declForSkuEnableType
.add(getDataTypeDeclarationForSkuEnabled(token
));
1441 if (token
.hasDefaultValue()) {
1442 instForSkuEnableType
.add(getDataTypeInstantiationForSkuEnabled(token
));
1446 if (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.HII_TYPE
) {
1447 decl
.add(getVariableEnableTypeDeclaration(token
));
1448 inst
.add(getVariableEnableInstantiation(token
));
1449 } else if (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.VPD_TYPE
) {
1450 decl
.add(getVpdEnableTypeDeclaration(token
));
1451 inst
.add(getVpdEnableTypeInstantiation(token
));
1452 } else if (token
.isUnicodeStringType()) {
1453 decl
.add(getStringTypeDeclaration(token
));
1454 inst
.add(getStringTypeInstantiation(stringTable
.add(token
.getStringTypeString(), token
), token
));
1457 decl
.add(getDataTypeDeclaration(token
));
1458 if (token
.hasDefaultValue()) {
1459 inst
.add(getDataTypeInstantiation(token
));
1464 sizeTable
.add(token
);
1465 localTokenNumberTable
.add(token
);
1466 token
.tokenNumber
= assignedTokenNumber
++;
1470 map
.put("Declaration", decl
);
1471 map
.put("DeclarationForSku", declForSkuEnableType
);
1472 map
.put("Instantiation", inst
);
1473 map
.put("InstantiationForSku", instForSkuEnableType
);
1478 private String
getSkuEnabledTypeDeclaration (Token token
) {
1479 return String
.format("%-20s%s;\r\n", "SKU_HEAD", token
.getPrimaryKeyString());
1482 private String
getSkuEnabledTypeInstantiaion (Token token
, int SkuTableIdx
) {
1484 String offsetof
= String
.format(PcdDatabase
.offsetOfSkuHeadStrTemplate
, phase
, token
.hasDefaultValue()?
"Init" : "Uninit", token
.getPrimaryKeyString());
1485 return String
.format("{ %s, %d } /* SKU_ENABLED: %s */", offsetof
, SkuTableIdx
, token
.getPrimaryKeyString());
1488 private String
getDataTypeDeclarationForSkuEnabled (Token token
) {
1489 String typeStr
= "";
1491 if (token
.datumType
== Token
.DATUM_TYPE
.UINT8
) {
1492 typeStr
= "UINT8 %s_%s[%d];\r\n";
1493 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT16
) {
1494 typeStr
= "UINT16 %s_%s[%d];\r\n";
1495 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT32
) {
1496 typeStr
= "UINT32 %s_%s[%d];\r\n";
1497 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT64
) {
1498 typeStr
= "UINT64 %s_%s[%d];\r\n";
1499 } else if (token
.datumType
== Token
.DATUM_TYPE
.BOOLEAN
) {
1500 typeStr
= "BOOLEAN %s_%s[%d];\r\n";
1501 } else if (token
.datumType
== Token
.DATUM_TYPE
.POINTER
) {
1502 return String
.format("UINT8 %s_%s[%d];\r\n", token
.getPrimaryKeyString(), "SkuDataTable", token
.datumSize
* token
.skuData
.size());
1505 return String
.format(typeStr
, token
.getPrimaryKeyString(), "SkuDataTable", token
.skuData
.size());
1509 private String
getDataTypeInstantiationForSkuEnabled (Token token
) {
1512 if (token
.datumType
== Token
.DATUM_TYPE
.POINTER
) {
1513 return String
.format("UINT8 %s_%s[%d]", token
.getPrimaryKeyString(), "SkuDataTable", token
.datumSize
* token
.skuData
.size());
1516 for (int idx
= 0; idx
< token
.skuData
.size(); idx
++) {
1517 str
+= token
.skuData
.get(idx
).toString();
1518 if (idx
!= token
.skuData
.size() - 1) {
1529 private String
getDataTypeInstantiationForVariableDefault_new (Token token
, String cName
, int skuId
) {
1530 return String
.format("%s /* %s */", token
.skuData
.get(skuId
).value
.hiiDefaultValue
, cName
);
1533 private String
getDataTypeInstantiation (Token token
) {
1535 if (token
.datumType
== Token
.DATUM_TYPE
.POINTER
) {
1536 return String
.format("%s /* %s */", token
.getDefaultSku().value
, token
.getPrimaryKeyString());
1538 return String
.format("%s /* %s */", token
.getDefaultSku().value
, token
.getPrimaryKeyString());
1542 private String
getCType (Token t
)
1543 throws EntityException
{
1545 if (t
.isHiiEnable()) {
1546 return "VARIABLE_HEAD";
1549 if (t
.isVpdEnable()) {
1553 if (t
.isUnicodeStringType()) {
1554 return "STRING_HEAD";
1557 switch (t
.datumType
) {
1571 throw new EntityException("Unknown type in getDataTypeCDeclaration");
1575 private void getCDeclarationString(Token t
)
1576 throws EntityException
{
1578 if (t
.isSkuEnable()) {
1579 privateGlobalName
= String
.format("%s_%s", t
.getPrimaryKeyString(), skuDataTableTemplate
);
1581 privateGlobalName
= t
.getPrimaryKeyString();
1584 if (t
.isUnicodeStringType()) {
1585 privateGlobalCCode
= String
.format("%-20s%s[%d];\r\n", "STRING_HEAD", t
.getPrimaryKeyString(), t
.getSkuIdCount());
1587 String type
= getCType(t
);
1588 if (t
.datumType
== Token
.DATUM_TYPE
.POINTER
) {
1590 if (t
.isASCIIStringType()) {
1592 // Build tool will add a NULL string at the end of the ASCII string
1594 bufferSize
= t
.datumSize
+ 1;
1596 bufferSize
= t
.datumSize
;
1598 privateGlobalCCode
= String
.format("%-20s%s[%d][%d];\r\n", type
, privateGlobalName
, t
.getSkuIdCount(), bufferSize
);
1600 privateGlobalCCode
= String
.format("%-20s%s[%d];\r\n", type
, privateGlobalName
, t
.getSkuIdCount());
1605 private String
getDataTypeDeclarationForVariableDefault_new (Token token
, String cName
, int skuId
) {
1609 if (token
.datumType
== Token
.DATUM_TYPE
.UINT8
) {
1611 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT16
) {
1613 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT32
) {
1615 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT64
) {
1617 } else if (token
.datumType
== Token
.DATUM_TYPE
.BOOLEAN
) {
1618 typeStr
= "BOOLEAN";
1619 } else if (token
.datumType
== Token
.DATUM_TYPE
.POINTER
) {
1620 return String
.format("%-20s%s[%d];\r\n", cName
, token
.datumSize
);
1625 return String
.format("%-20s%s;\r\n", typeStr
, cName
);
1628 private String
getDataTypeDeclaration (Token token
) {
1630 String typeStr
= "";
1632 if (token
.datumType
== Token
.DATUM_TYPE
.UINT8
) {
1634 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT16
) {
1636 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT32
) {
1638 } else if (token
.datumType
== Token
.DATUM_TYPE
.UINT64
) {
1640 } else if (token
.datumType
== Token
.DATUM_TYPE
.BOOLEAN
) {
1641 typeStr
= "BOOLEAN";
1642 } else if (token
.datumType
== Token
.DATUM_TYPE
.POINTER
) {
1643 return String
.format("UINT8 %s[%d]", token
.getPrimaryKeyString(), token
.datumSize
);
1647 return String
.format("%s %s", typeStr
, token
.getPrimaryKeyString());
1650 private String
getVpdEnableTypeDeclaration (Token token
) {
1651 return String
.format("VPD_HEAD %s", token
.getPrimaryKeyString());
1654 private String
getTypeInstantiation (Token t
, ArrayList
<CStructTypeDeclaration
> declaList
, HashMap
<String
, String
> instTable
, String phase
) throws EntityException
{
1659 s
= String
.format("/* %s */", t
.getPrimaryKeyString()) + newLine
;
1660 s
+= tab
+ "{" + newLine
;
1662 for (i
= 0; i
< t
.skuData
.size(); i
++) {
1663 if (t
.isUnicodeStringType() && !t
.isHiiEnable()) {
1664 s
+= tab
+ tab
+ String
.format("{ %d }", stringTable
.add(t
.skuData
.get(i
).value
.value
, t
));
1665 } else if (t
.isHiiEnable()) {
1666 /* VPD_HEAD definition
1668 UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
1669 UINT16 StringIndex; // Offset in String Table in units of UINT16.
1670 UINT16 Offset; // Offset in Variable
1673 String variableDefaultName
= String
.format("%s_VariableDefault_%d", t
.getPrimaryKeyString(), i
);
1675 s
+= tab
+ tab
+ String
.format("{ %d, %d, %s, %s }", guidTable
.add(t
.skuData
.get(i
).value
.variableGuid
, t
.getPrimaryKeyString()),
1676 stringTable
.add(t
.skuData
.get(i
).value
.getStringOfVariableName(), t
),
1677 t
.skuData
.get(i
).value
.variableOffset
,
1678 String
.format("offsetof(%s_PCD_DATABASE, Init.%s)", phase
, variableDefaultName
)
1681 // We need to support the default value, so we add the declaration and
1682 // the instantiation for the default value.
1684 CStructTypeDeclaration decl
= new CStructTypeDeclaration (variableDefaultName
,
1685 getDataTypeAlignmentSize(t
),
1686 getDataTypeDeclarationForVariableDefault_new(t
, variableDefaultName
, i
),
1689 declaList
.add(decl
);
1690 instTable
.put(variableDefaultName
, getDataTypeInstantiationForVariableDefault_new (t
, variableDefaultName
, i
));
1691 } else if (t
.isVpdEnable()) {
1696 s
+= tab
+ tab
+ String
.format("{ %s }", t
.skuData
.get(i
).value
.vpdOffset
);
1698 if (t
.isByteStreamType()) {
1700 // Byte stream type input has their own "{" "}", so we won't help to insert.
1702 s
+= tab
+ tab
+ String
.format(" %s ", t
.skuData
.get(i
).value
.value
);
1704 s
+= tab
+ tab
+ String
.format("{ %s }", t
.skuData
.get(i
).value
.value
);
1708 if (i
!= t
.skuData
.size() - 1) {
1721 private String
getVpdEnableTypeInstantiation (Token token
) {
1722 return String
.format("{ %s } /* %s */", token
.getDefaultSku().vpdOffset
,
1723 token
.getPrimaryKeyString());
1726 private String
getStringTypeDeclaration (Token token
) {
1727 return String
.format("UINT16 %s", token
.getPrimaryKeyString());
1730 private String
getStringTypeInstantiation (int StringTableIdx
, Token token
) {
1731 return String
.format ("%d /* %s */", StringTableIdx
,
1732 token
.getPrimaryKeyString());
1736 private String
getVariableEnableTypeDeclaration (Token token
) {
1737 return String
.format("VARIABLE_HEAD %s", token
.getPrimaryKeyString());
1740 private String
getVariableEnableInstantiation (Token token
)
1741 throws EntityException
{
1745 return String
.format("{ %d, %d, %s } /* %s */", guidTable
.add(token
.getDefaultSku().variableGuid
, token
.getPrimaryKeyString()),
1746 stringTable
.add(token
.getDefaultSku().getStringOfVariableName(), token
),
1747 token
.getDefaultSku().variableOffset
,
1748 token
.getPrimaryKeyString());
1751 public int getTotalTokenNumber () {
1752 return sizeTable
.getTableLen();
1755 public static String
getPcdDatabaseCommonDefinitions ()
1756 throws EntityException
{
1760 File file
= new File(GlobalData
.getWorkspacePath() + File
.separator
+
1761 "Tools" + File
.separator
+
1762 "Conf" + File
.separator
+
1763 "Pcd" + File
.separator
+
1764 "PcdDatabaseCommonDefinitions.sample");
1765 FileReader reader
= new FileReader(file
);
1766 BufferedReader in
= new BufferedReader(reader
);
1768 while ((str
= in
.readLine()) != null) {
1769 retStr
= retStr
+"\r\n" + str
;
1771 } catch (Exception ex
) {
1772 throw new EntityException("Fatal error when generating PcdDatabase Common Definitions");
1778 public static String
getPcdDxeDatabaseDefinitions ()
1779 throws EntityException
{
1783 File file
= new File(GlobalData
.getWorkspacePath() + File
.separator
+
1784 "Tools" + File
.separator
+
1785 "Conf" + File
.separator
+
1786 "Pcd" + File
.separator
+
1787 "PcdDatabaseDxeDefinitions.sample");
1788 FileReader reader
= new FileReader(file
);
1789 BufferedReader in
= new BufferedReader(reader
);
1791 while ((str
= in
.readLine()) != null) {
1792 retStr
= retStr
+"\r\n" + str
;
1794 } catch (Exception ex
) {
1795 throw new EntityException("Fatal error when generating PcdDatabase Dxe Definitions");
1801 public static String
getPcdPeiDatabaseDefinitions ()
1802 throws EntityException
{
1806 File file
= new File(GlobalData
.getWorkspacePath() + File
.separator
+
1807 "Tools" + File
.separator
+
1808 "Conf" + File
.separator
+
1809 "Pcd" + File
.separator
+
1810 "PcdDatabasePeiDefinitions.sample");
1811 FileReader reader
= new FileReader(file
);
1812 BufferedReader in
= new BufferedReader(reader
);
1814 while ((str
= in
.readLine()) != null) {
1815 retStr
= retStr
+"\r\n" + str
;
1817 } catch (Exception ex
) {
1818 throw new EntityException("Fatal error when generating PcdDatabase Pei Definitions");
1827 public ModuleSADocument
.ModuleSA module
;
1828 public ModuleTypeDef
.Enum type
;
1830 public ModuleInfo (ModuleSADocument
.ModuleSA module
, ModuleTypeDef
.Enum type
) {
1831 this.module
= module
;
1836 /** This action class is to collect PCD information from MSA, SPD, FPD xml file.
1837 This class will be used for wizard and build tools, So it can *not* inherit
1838 from buildAction or UIAction.
1840 public class CollectPCDAction
{
1841 /// memoryDatabase hold all PCD information collected from SPD, MSA, FPD.
1842 private MemoryDatabaseManager dbManager
;
1844 /// Workspacepath hold the workspace information.
1845 private String workspacePath
;
1847 /// FPD file is the root file.
1848 private String fpdFilePath
;
1850 /// Message level for CollectPCDAction.
1851 private int originalMessageLevel
;
1853 /// Cache the fpd docment instance for private usage.
1854 private FrameworkPlatformDescriptionDocument fpdDocInstance
;
1857 Set WorkspacePath parameter for this action class.
1859 @param workspacePath parameter for this action
1861 public void setWorkspacePath(String workspacePath
) {
1862 this.workspacePath
= workspacePath
;
1866 Set action message level for CollectPcdAction tool.
1868 The message should be restored when this action exit.
1870 @param actionMessageLevel parameter for this action
1872 public void setActionMessageLevel(int actionMessageLevel
) {
1873 originalMessageLevel
= ActionMessage
.messageLevel
;
1874 ActionMessage
.messageLevel
= actionMessageLevel
;
1878 Set FPDFileName parameter for this action class.
1880 @param fpdFilePath fpd file path
1882 public void setFPDFilePath(String fpdFilePath
) {
1883 this.fpdFilePath
= fpdFilePath
;
1887 Common function interface for outer.
1889 @param workspacePath The path of workspace of current build or analysis.
1890 @param fpdFilePath The fpd file path of current build or analysis.
1891 @param messageLevel The message level for this Action.
1893 @throws Exception The exception of this function. Because it can *not* be predict
1894 where the action class will be used. So only Exception can be throw.
1897 public void perform(String workspacePath
, String fpdFilePath
,
1898 int messageLevel
) throws Exception
{
1899 setWorkspacePath(workspacePath
);
1900 setFPDFilePath(fpdFilePath
);
1901 setActionMessageLevel(messageLevel
);
1904 ActionMessage
.messageLevel
= originalMessageLevel
;
1908 Core execution function for this action class.
1910 This function work flows will be:
1911 1) Collect and prepocess PCD information from FPD file, all PCD
1912 information will be stored into memory database.
1913 2) Generate 3 strings for
1914 a) All modules using Dynamic(Ex) PCD entry.(Token Number)
1915 b) PEI PCDDatabase (C Structure) for PCD Service PEIM.
1916 c) DXE PCD Database (C structure) for PCD Service DXE.
1919 @throws EntityException Exception indicate failed to execute this action.
1922 private void execute() throws EntityException
{
1924 // Get memoryDatabaseManager instance from GlobalData.
1925 // The memoryDatabaseManager should be initialized for whatever build
1926 // tools or wizard tools
1928 if((dbManager
= GlobalData
.getPCDMemoryDBManager()) == null) {
1929 throw new EntityException("The instance of PCD memory database manager is null");
1933 // Collect all PCD information defined in FPD file.
1934 // Evenry token defind in FPD will be created as an token into
1937 createTokenInDBFromFPD();
1940 // Call Private function genPcdDatabaseSourceCode (void); ComponentTypeBsDriver
1941 // 1) Generate for PEI, DXE PCD DATABASE's definition and initialization.
1943 genPcdDatabaseSourceCode ();
1948 This function generates source code for PCD Database.
1951 @throws EntityException If the token does *not* exist in memory database.
1954 private void genPcdDatabaseSourceCode()
1955 throws EntityException
{
1956 String PcdCommonHeaderString
= PcdDatabase
.getPcdDatabaseCommonDefinitions ();
1958 ArrayList
<Token
> alPei
= new ArrayList
<Token
> ();
1959 ArrayList
<Token
> alDxe
= new ArrayList
<Token
> ();
1961 dbManager
.getTwoPhaseDynamicRecordArray(alPei
, alDxe
);
1962 PcdDatabase pcdPeiDatabase
= new PcdDatabase (alPei
, "PEI", 0);
1963 pcdPeiDatabase
.genCodeNew();
1964 MemoryDatabaseManager
.PcdPeimHString
= PcdCommonHeaderString
+ pcdPeiDatabase
.getHString()
1965 + PcdDatabase
.getPcdPeiDatabaseDefinitions();
1966 MemoryDatabaseManager
.PcdPeimCString
= pcdPeiDatabase
.getCString();
1968 PcdDatabase pcdDxeDatabase
= new PcdDatabase (alDxe
,
1972 pcdDxeDatabase
.genCodeNew();
1973 MemoryDatabaseManager
.PcdDxeHString
= MemoryDatabaseManager
.PcdPeimHString
+ pcdDxeDatabase
.getHString()
1974 + PcdDatabase
.getPcdDxeDatabaseDefinitions();
1975 MemoryDatabaseManager
.PcdDxeCString
= pcdDxeDatabase
.getCString();
1979 Get component array from FPD.
1981 This function maybe provided by some Global class.
1983 @return List<ModuleInfo> the component array.
1986 private List
<ModuleInfo
> getComponentsFromFPD()
1987 throws EntityException
{
1988 List
<ModuleInfo
> allModules
= new ArrayList
<ModuleInfo
>();
1989 ModuleInfo current
= null;
1991 org
.tianocore
.Components components
= null;
1992 FrameworkModulesDocument
.FrameworkModules fModules
= null;
1993 ModuleSADocument
.ModuleSA
[] modules
= null;
1994 HashMap
<String
, XmlObject
> map
= new HashMap
<String
, XmlObject
>();
1996 if (fpdDocInstance
== null) {
1998 fpdDocInstance
= (FrameworkPlatformDescriptionDocument
)XmlObject
.Factory
.parse(new File(fpdFilePath
));
1999 } catch(IOException ioE
) {
2000 throw new EntityException("File IO error for xml file:" + fpdFilePath
+ "\n" + ioE
.getMessage());
2001 } catch(XmlException xmlE
) {
2002 throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath
+ "\n" + xmlE
.getMessage());
2007 map
.put("FrameworkPlatformDescription", fpdDocInstance
);
2008 SurfaceAreaQuery
.setDoc(map
);
2009 modules
= SurfaceAreaQuery
.getFpdModuleSAs();
2010 for (index
= 0; index
< modules
.length
; index
++) {
2011 SurfaceAreaQuery
.setDoc(GlobalData
.getDoc(modules
[index
].getModuleName()));
2012 allModules
.add(new ModuleInfo(modules
[index
],
2013 ModuleTypeDef
.Enum
.forString(SurfaceAreaQuery
.getModuleType())));
2020 Create token instance object into memory database, the token information
2021 comes for FPD file. Normally, FPD file will contain all token platform
2024 @return FrameworkPlatformDescriptionDocument The FPD document instance for furture usage.
2026 @throws EntityException Failed to parse FPD xml file.
2029 private void createTokenInDBFromFPD()
2030 throws EntityException
{
2034 List
<PcdBuildDefinition
.PcdData
> pcdBuildDataArray
= new ArrayList
<PcdBuildDefinition
.PcdData
>();
2035 PcdBuildDefinition
.PcdData pcdBuildData
= null;
2037 SkuInstance skuInstance
= null;
2039 List
<ModuleInfo
> modules
= null;
2040 String primaryKey
= null;
2041 String exceptionString
= null;
2042 UsageInstance usageInstance
= null;
2043 String primaryKey1
= null;
2044 String primaryKey2
= null;
2045 boolean isDuplicate
= false;
2046 Token
.PCD_TYPE pcdType
= Token
.PCD_TYPE
.UNKNOWN
;
2047 Token
.DATUM_TYPE datumType
= Token
.DATUM_TYPE
.UNKNOWN
;
2048 long tokenNumber
= 0;
2049 String moduleName
= null;
2050 String datum
= null;
2051 int maxDatumSize
= 0;
2054 // ----------------------------------------------
2055 // 1), Get all <ModuleSA> from FPD file.
2056 // ----------------------------------------------
2058 modules
= getComponentsFromFPD();
2060 if (modules
== null) {
2061 throw new EntityException("[FPD file error] No modules in FPD file, Please check whether there are elements in <FrameworkModules> in FPD file!");
2065 // -------------------------------------------------------------------
2066 // 2), Loop all modules to process <PcdBuildDeclarations> for each module.
2067 // -------------------------------------------------------------------
2069 for (index
= 0; index
< modules
.size(); index
++) {
2070 isDuplicate
= false;
2071 for (index2
= 0; index2
< index
; index2
++) {
2073 // BUGBUG: For transition schema, we can *not* get module's version from
2074 // <ModuleSAs>, It is work around code.
2076 primaryKey1
= UsageInstance
.getPrimaryKey(modules
.get(index
).module
.getModuleName(),
2080 modules
.get(index
).module
.getArch().toString(),
2082 primaryKey2
= UsageInstance
.getPrimaryKey(modules
.get(index2
).module
.getModuleName(),
2086 modules
.get(index2
).module
.getArch().toString(),
2088 if (primaryKey1
.equalsIgnoreCase(primaryKey2
)) {
2099 // It is legal for a module does not contains ANY pcd build definitions.
2101 if (modules
.get(index
).module
.getPcdBuildDefinition() == null) {
2105 pcdBuildDataArray
= modules
.get(index
).module
.getPcdBuildDefinition().getPcdDataList();
2107 moduleName
= modules
.get(index
).module
.getModuleName();
2110 // ----------------------------------------------------------------------
2111 // 2.1), Loop all Pcd entry for a module and add it into memory database.
2112 // ----------------------------------------------------------------------
2114 for (pcdIndex
= 0; pcdIndex
< pcdBuildDataArray
.size(); pcdIndex
++) {
2115 pcdBuildData
= pcdBuildDataArray
.get(pcdIndex
);
2116 primaryKey
= Token
.getPrimaryKeyString(pcdBuildData
.getCName(),
2117 translateSchemaStringToUUID(pcdBuildData
.getTokenSpaceGuid()));
2118 pcdType
= Token
.getpcdTypeFromString(pcdBuildData
.getItemType().toString());
2119 datumType
= Token
.getdatumTypeFromString(pcdBuildData
.getDatumType().toString());
2120 tokenNumber
= Long
.decode(pcdBuildData
.getToken().toString());
2122 if (pcdBuildData
.getValue() != null) {
2123 datum
= pcdBuildData
.getValue().toString();
2127 maxDatumSize
= pcdBuildData
.getMaxDatumSize();
2129 if ((pcdType
== Token
.PCD_TYPE
.FEATURE_FLAG
) &&
2130 (datumType
!= Token
.DATUM_TYPE
.BOOLEAN
)){
2131 exceptionString
= String
.format("[FPD file error] For PCD %s in module %s, the PCD type is FEATRUE_FLAG but "+
2132 "datum type of this PCD entry is not BOOLEAN!",
2133 pcdBuildData
.getCName(),
2135 throw new EntityException(exceptionString
);
2139 // Check <TokenSpaceGuid> is exist? In future, because all schema verification will tools
2140 // will check that, following checking code could be removed.
2142 if (pcdBuildData
.getTokenSpaceGuid() == null) {
2143 exceptionString
= String
.format("[FPD file error] There is no <TokenSpaceGuid> for PCD %s in module %s! This is required!",
2144 pcdBuildData
.getCName(),
2146 throw new EntityException(exceptionString
);
2150 // -------------------------------------------------------------------------------------------
2151 // 2.1.1), Do some necessary checking work for FixedAtBuild, FeatureFlag and PatchableInModule
2152 // -------------------------------------------------------------------------------------------
2154 if (!Token
.isDynamic(pcdType
)) {
2156 // Value is required.
2158 if (datum
== null) {
2159 exceptionString
= String
.format("[FPD file error] There is no value for PCD entry %s in module %s!",
2160 pcdBuildData
.getCName(),
2162 throw new EntityException(exceptionString
);
2166 // Check whether the datum size is matched datum type.
2168 if ((exceptionString
= verifyDatum(pcdBuildData
.getCName(),
2172 maxDatumSize
)) != null) {
2173 throw new EntityException(exceptionString
);
2178 // ---------------------------------------------------------------------------------
2179 // 2.1.2), Create token or update token information for current anaylized PCD data.
2180 // ---------------------------------------------------------------------------------
2182 if (dbManager
.isTokenInDatabase(primaryKey
)) {
2184 // If the token is already exist in database, do some necessary checking
2185 // and add a usage instance into this token in database
2187 token
= dbManager
.getTokenByKey(primaryKey
);
2190 // checking for DatumType, DatumType should be unique for one PCD used in different
2193 if (token
.datumType
!= datumType
) {
2194 exceptionString
= String
.format("[FPD file error] The datum type of PCD entry %s is %s, which is different with %s defined in before!",
2195 pcdBuildData
.getCName(),
2196 pcdBuildData
.getDatumType().toString(),
2197 Token
.getStringOfdatumType(token
.datumType
));
2198 throw new EntityException(exceptionString
);
2202 // Check token number is valid
2204 if (tokenNumber
!= token
.tokenNumber
) {
2205 exceptionString
= String
.format("[FPD file error] The token number of PCD entry %s in module %s is different with same PCD entry in other modules!",
2206 pcdBuildData
.getCName(),
2208 throw new EntityException(exceptionString
);
2212 // For same PCD used in different modules, the PCD type should all be dynamic or non-dynamic.
2214 if (token
.isDynamicPCD
!= Token
.isDynamic(pcdType
)) {
2215 exceptionString
= String
.format("[FPD file error] For PCD entry %s in module %s, you define dynamic or non-dynamic PCD type which"+
2216 "is different with others module's",
2219 throw new EntityException(exceptionString
);
2222 if (token
.isDynamicPCD
) {
2224 // Check datum is equal the datum in dynamic information.
2225 // For dynamic PCD, you can do not write <Value> in sperated every <PcdBuildDefinition> in different <ModuleSA>,
2226 // But if you write, the <Value> must be same as the value in <DynamicPcdBuildDefinitions>.
2228 if (!token
.isSkuEnable() &&
2229 (token
.getDefaultSku().type
== DynamicTokenValue
.VALUE_TYPE
.DEFAULT_TYPE
) &&
2231 if (!datum
.equalsIgnoreCase(token
.getDefaultSku().value
)) {
2232 exceptionString
= String
.format("[FPD file error] For dynamic PCD %s in module %s, the datum in <ModuleSA> is "+
2233 "not equal to the datum in <DynamicPcdBuildDefinitions>, it is "+
2234 "illega! You could no set <Value> in <ModuleSA> for a dynamic PCD!",
2237 throw new EntityException(exceptionString
);
2241 if ((maxDatumSize
!= 0) &&
2242 (maxDatumSize
!= token
.datumSize
)){
2243 exceptionString
= String
.format("[FPD file error] For dynamic PCD %s in module %s, the max datum size is %d which "+
2244 "is different with <MaxDatumSize> %d defined in <DynamicPcdBuildDefinitions>!",
2249 throw new EntityException(exceptionString
);
2255 // If the token is not in database, create a new token instance and add
2256 // a usage instance into this token in database.
2258 token
= new Token(pcdBuildData
.getCName(),
2259 translateSchemaStringToUUID(pcdBuildData
.getTokenSpaceGuid()));
2261 token
.datumType
= datumType
;
2262 token
.tokenNumber
= tokenNumber
;
2263 token
.isDynamicPCD
= Token
.isDynamic(pcdType
);
2264 token
.datumSize
= maxDatumSize
;
2266 if (token
.isDynamicPCD
) {
2268 // For Dynamic and Dynamic Ex type, need find the dynamic information
2269 // in <DynamicPcdBuildDefinition> section in FPD file.
2271 updateDynamicInformation(moduleName
,
2277 dbManager
.addTokenToDatabase(primaryKey
, token
);
2281 // -----------------------------------------------------------------------------------
2282 // 2.1.3), Add the PcdType in current module into this Pcd token's supported PCD type.
2283 // -----------------------------------------------------------------------------------
2285 token
.updateSupportPcdType(pcdType
);
2288 // ------------------------------------------------
2289 // 2.1.4), Create an usage instance for this token.
2290 // ------------------------------------------------
2292 usageInstance
= new UsageInstance(token
,
2297 modules
.get(index
).type
,
2299 modules
.get(index
).module
.getArch().toString(),
2303 token
.addUsageInstance(usageInstance
);
2309 Verify the datum value according its datum size and datum type, this
2310 function maybe moved to FPD verification tools in future.
2321 public String
verifyDatum(String cName
,
2324 Token
.DATUM_TYPE datumType
,
2326 String exceptionString
= null;
2332 if (moduleName
== null) {
2333 moduleName
= "section <DynamicPcdBuildDefinitions>";
2335 moduleName
= "module " + moduleName
;
2338 if (maxDatumSize
== 0) {
2339 exceptionString
= String
.format("[FPD file error] You maybe miss <MaxDatumSize> for PCD %s in %s",
2342 return exceptionString
;
2345 switch (datumType
) {
2347 if (maxDatumSize
!= 1) {
2348 exceptionString
= String
.format("[FPD file error] The datum type of PCD data %s in %s "+
2349 "is UINT8, but datum size is %d, they are not matched!",
2353 return exceptionString
;
2356 if (datum
!= null) {
2358 value
= Integer
.decode(datum
);
2359 } catch (NumberFormatException nfeExp
) {
2360 exceptionString
= String
.format("[FPD file error] The datum for PCD %s in %s is not valid "+
2361 "digital format of UINT8",
2364 return exceptionString
;
2367 exceptionString
= String
.format("[FPD file error] The datum for PCD %s in %s is %s exceed"+
2368 " the max size of UINT8 - 0xFF",
2372 return exceptionString
;
2377 if (maxDatumSize
!= 2) {
2378 exceptionString
= String
.format("[FPD file error] The datum type of PCD data %s in %s "+
2379 "is UINT16, but datum size is %d, they are not matched!",
2383 return exceptionString
;
2385 if (datum
!= null) {
2387 value
= Integer
.decode(datum
);
2388 } catch (NumberFormatException nfeExp
) {
2389 exceptionString
= String
.format("[FPD file error] The datum for PCD %s in %s is "+
2390 "not valid digital of UINT16",
2393 return exceptionString
;
2395 if (value
> 0xFFFF) {
2396 exceptionString
= String
.format("[FPD file error] The datum for PCD %s in %s is %s "+
2397 "which exceed the range of UINT16 - 0xFFFF",
2401 return exceptionString
;
2406 if (maxDatumSize
!= 4) {
2407 exceptionString
= String
.format("[FPD file error] The datum type of PCD data %s in %s "+
2408 "is UINT32, but datum size is %d, they are not matched!",
2412 return exceptionString
;
2415 if (datum
!= null) {
2417 if (datum
.length() > 2) {
2418 if ((datum
.charAt(0) == '0') &&
2419 ((datum
.charAt(1) == 'x') || (datum
.charAt(1) == 'X'))){
2420 subStr
= datum
.substring(2, datum
.length());
2421 value64
= new BigInteger(subStr
, 16);
2423 value64
= new BigInteger(datum
);
2426 value64
= new BigInteger(datum
);
2428 } catch (NumberFormatException nfeExp
) {
2429 exceptionString
= String
.format("[FPD file error] The datum for PCD %s in %s is not "+
2430 "valid digital of UINT32",
2433 return exceptionString
;
2436 if (value64
.bitLength() > 32) {
2437 exceptionString
= String
.format("[FPD file error] The datum for PCD %s in %s is %s which "+
2438 "exceed the range of UINT32 - 0xFFFFFFFF",
2442 return exceptionString
;
2447 if (maxDatumSize
!= 8) {
2448 exceptionString
= String
.format("[FPD file error] The datum type of PCD data %s in %s "+
2449 "is UINT64, but datum size is %d, they are not matched!",
2453 return exceptionString
;
2456 if (datum
!= null) {
2458 if (datum
.length() > 2) {
2459 if ((datum
.charAt(0) == '0') &&
2460 ((datum
.charAt(1) == 'x') || (datum
.charAt(1) == 'X'))){
2461 subStr
= datum
.substring(2, datum
.length());
2462 value64
= new BigInteger(subStr
, 16);
2464 value64
= new BigInteger(datum
);
2467 value64
= new BigInteger(datum
);
2469 } catch (NumberFormatException nfeExp
) {
2470 exceptionString
= String
.format("[FPD file error] The datum for PCD %s in %s is not valid"+
2471 " digital of UINT64",
2474 return exceptionString
;
2477 if (value64
.bitLength() > 64) {
2478 exceptionString
= String
.format("[FPD file error] The datum for PCD %s in %s is %s "+
2479 "exceed the range of UINT64 - 0xFFFFFFFFFFFFFFFF",
2483 return exceptionString
;
2488 if (maxDatumSize
!= 1) {
2489 exceptionString
= String
.format("[FPD file error] The datum type of PCD data %s in %s "+
2490 "is BOOLEAN, but datum size is %d, they are not matched!",
2494 return exceptionString
;
2497 if (datum
!= null) {
2498 if (!(datum
.equalsIgnoreCase("TRUE") ||
2499 datum
.equalsIgnoreCase("FALSE"))) {
2500 exceptionString
= String
.format("[FPD file error] The datum type of PCD data %s in %s "+
2501 "is BOOELAN, but value is not 'true'/'TRUE' or 'FALSE'/'false'",
2504 return exceptionString
;
2510 if (datum
== null) {
2514 char ch
= datum
.charAt(0);
2518 // For void* type PCD, only three datum is support:
2519 // 1) Unicode: string with start char is "L"
2520 // 2) Ansci: String start char is ""
2521 // 3) byte array: String start char "{"
2524 start
= datum
.indexOf('\"');
2525 end
= datum
.lastIndexOf('\"');
2526 if ((start
> end
) ||
2527 (end
> datum
.length())||
2528 ((start
== end
) && (datum
.length() > 0))) {
2529 exceptionString
= String
.format("[FPD file error] The datum type of PCD %s in %s is VOID* and datum is "+
2530 "a UNICODE string because start with L\", but format maybe"+
2531 "is not right, correct UNICODE string is L\"...\"!",
2534 return exceptionString
;
2537 strValue
= datum
.substring(start
+ 1, end
);
2538 if ((strValue
.length() * 2) > maxDatumSize
) {
2539 exceptionString
= String
.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is "+
2540 "a UNICODE string, but the datum size is %d exceed to <MaxDatumSize> : %d",
2543 strValue
.length() * 2,
2545 return exceptionString
;
2547 } else if (ch
== '\"'){
2548 start
= datum
.indexOf('\"');
2549 end
= datum
.lastIndexOf('\"');
2550 if ((start
> end
) ||
2551 (end
> datum
.length())||
2552 ((start
== end
) && (datum
.length() > 0))) {
2553 exceptionString
= String
.format("[FPD file error] The datum type of PCD %s in %s is VOID* and datum is "+
2554 "a ANSCII string because start with \", but format maybe"+
2555 "is not right, correct ANSIC string is \"...\"!",
2558 return exceptionString
;
2560 strValue
= datum
.substring(start
+ 1, end
);
2561 if ((strValue
.length()) > maxDatumSize
) {
2562 exceptionString
= String
.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is "+
2563 "a ANSCI string, but the datum size is %d which exceed to <MaxDatumSize> : %d",
2568 return exceptionString
;
2570 } else if (ch
=='{') {
2571 String
[] strValueArray
;
2573 start
= datum
.indexOf('{');
2574 end
= datum
.lastIndexOf('}');
2575 strValue
= datum
.substring(start
+ 1, end
);
2576 strValue
= strValue
.trim();
2577 if (strValue
.length() == 0) {
2580 strValueArray
= strValue
.split(",");
2581 for (index
= 0; index
< strValueArray
.length
; index
++) {
2583 value
= Integer
.decode(strValueArray
[index
].trim());
2584 } catch (NumberFormatException nfeEx
) {
2585 exceptionString
= String
.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and "+
2586 "it is byte array in fact. For every byte in array should be a valid"+
2587 "byte digital, but element %s is not a valid byte digital!",
2590 strValueArray
[index
]);
2591 return exceptionString
;
2594 exceptionString
= String
.format("[FPD file error] The datum type of PCD %s in %s is VOID*, "+
2595 "it is byte array in fact. But the element of %s exceed the byte range",
2598 strValueArray
[index
]);
2599 return exceptionString
;
2603 if (strValueArray
.length
> maxDatumSize
) {
2604 exceptionString
= String
.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is byte"+
2605 "array, but the number of bytes is %d which exceed to <MaxDatumSzie> : %d!",
2608 strValueArray
.length
,
2610 return exceptionString
;
2613 exceptionString
= String
.format("[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
2614 "1) UNICODE string: like L\"xxxx\";\r\n"+
2615 "2) ANSIC string: like \"xxx\";\r\n"+
2616 "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
2617 "But the datum in seems does not following above format!",
2620 return exceptionString
;
2624 exceptionString
= String
.format("[FPD file error] For PCD entry %s in %s, datum type is unknown, it should be one of "+
2625 "UINT8, UINT16, UINT32, UINT64, VOID*, BOOLEAN",
2628 return exceptionString
;
2634 Get dynamic information for a dynamic PCD from <DynamicPcdBuildDefinition> seciton in FPD file.
2636 This function should be implemented in GlobalData in future.
2638 @param token The token instance which has hold module's PCD information
2639 @param moduleName The name of module who will use this Dynamic PCD.
2641 @return DynamicPcdBuildDefinitions.PcdBuildData
2644 private DynamicPcdBuildDefinitions
.PcdBuildData
getDynamicInfoFromFPD(Token token
,
2646 throws EntityException
{
2648 String exceptionString
= null;
2649 String dynamicPrimaryKey
= null;
2650 DynamicPcdBuildDefinitions dynamicPcdBuildDefinitions
= null;
2651 List
<DynamicPcdBuildDefinitions
.PcdBuildData
> dynamicPcdBuildDataArray
= null;
2654 // If FPD document is not be opened, open and initialize it.
2656 if (fpdDocInstance
== null) {
2658 fpdDocInstance
= (FrameworkPlatformDescriptionDocument
)XmlObject
.Factory
.parse(new File(fpdFilePath
));
2659 } catch(IOException ioE
) {
2660 throw new EntityException("File IO error for xml file:" + fpdFilePath
+ "\n" + ioE
.getMessage());
2661 } catch(XmlException xmlE
) {
2662 throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath
+ "\n" + xmlE
.getMessage());
2666 dynamicPcdBuildDefinitions
= fpdDocInstance
.getFrameworkPlatformDescription().getDynamicPcdBuildDefinitions();
2667 if (dynamicPcdBuildDefinitions
== null) {
2668 exceptionString
= String
.format("[FPD file error] There are no <PcdDynamicBuildDescriptions> in FPD file but contains Dynamic type "+
2669 "PCD entry %s in module %s!",
2672 throw new EntityException(exceptionString
);
2675 dynamicPcdBuildDataArray
= dynamicPcdBuildDefinitions
.getPcdBuildDataList();
2676 for (index
= 0; index
< dynamicPcdBuildDataArray
.size(); index
++) {
2678 // Check <TokenSpaceGuid> is exist? In future, because all schema verification will tools
2679 // will check that, following checking code could be removed.
2681 if (dynamicPcdBuildDataArray
.get(index
).getTokenSpaceGuid() == null) {
2682 exceptionString
= String
.format("[FPD file error] There is no <TokenSpaceGuid> for PCD %s in <DynamicPcdBuildDefinitions>! This is required!",
2683 dynamicPcdBuildDataArray
.get(index
).getCName());
2684 throw new EntityException(exceptionString
);
2687 dynamicPrimaryKey
= Token
.getPrimaryKeyString(dynamicPcdBuildDataArray
.get(index
).getCName(),
2688 translateSchemaStringToUUID(dynamicPcdBuildDataArray
.get(index
).getTokenSpaceGuid()));
2689 if (dynamicPrimaryKey
.equalsIgnoreCase(token
.getPrimaryKeyString())) {
2690 return dynamicPcdBuildDataArray
.get(index
);
2698 Update dynamic information for PCD entry.
2700 Dynamic information is retrieved from <PcdDynamicBuildDeclarations> in
2703 @param moduleName The name of the module who use this PCD
2704 @param token The token instance
2705 @param datum The <datum> in module's PCD information
2706 @param maxDatumSize The <maxDatumSize> in module's PCD information
2710 private Token
updateDynamicInformation(String moduleName
,
2714 throws EntityException
{
2717 String exceptionString
= null;
2718 DynamicTokenValue dynamicValue
;
2719 SkuInstance skuInstance
= null;
2721 boolean hasSkuId0
= false;
2722 Token
.PCD_TYPE pcdType
= Token
.PCD_TYPE
.UNKNOWN
;
2723 long tokenNumber
= 0;
2724 String hiiDefaultValue
= null;
2725 String
[] variableGuidString
= null;
2727 List
<DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> skuInfoList
= null;
2728 DynamicPcdBuildDefinitions
.PcdBuildData dynamicInfo
= null;
2730 dynamicInfo
= getDynamicInfoFromFPD(token
, moduleName
);
2731 if (dynamicInfo
== null) {
2732 exceptionString
= String
.format("[FPD file error] For Dynamic PCD %s used by module %s, "+
2733 "there is no dynamic information in <DynamicPcdBuildDefinitions> "+
2734 "in FPD file, but it is required!",
2737 throw new EntityException(exceptionString
);
2740 token
.datumSize
= dynamicInfo
.getMaxDatumSize();
2742 exceptionString
= verifyDatum(token
.cName
,
2747 if (exceptionString
!= null) {
2748 throw new EntityException(exceptionString
);
2751 if ((maxDatumSize
!= 0) &&
2752 (maxDatumSize
!= token
.datumSize
)) {
2753 exceptionString
= String
.format("FPD file error] For dynamic PCD %s, the datum size in module %s is %d, but "+
2754 "the datum size in <DynamicPcdBuildDefinitions> is %d, they are not match!",
2758 dynamicInfo
.getMaxDatumSize());
2759 throw new EntityException(exceptionString
);
2761 tokenNumber
= Long
.decode(dynamicInfo
.getToken().toString());
2762 if (tokenNumber
!= token
.tokenNumber
) {
2763 exceptionString
= String
.format("[FPD file error] For dynamic PCD %s, the token number in module %s is 0x%x, but"+
2764 "in <DynamicPcdBuildDefinictions>, the token number is 0x%x, they are not match!",
2769 throw new EntityException(exceptionString
);
2772 pcdType
= Token
.getpcdTypeFromString(dynamicInfo
.getItemType().toString());
2773 if (pcdType
== Token
.PCD_TYPE
.DYNAMIC_EX
) {
2774 token
.dynamicExTokenNumber
= tokenNumber
;
2777 skuInfoList
= dynamicInfo
.getSkuInfoList();
2780 // Loop all sku data
2782 for (index
= 0; index
< skuInfoList
.size(); index
++) {
2783 skuInstance
= new SkuInstance();
2785 // Although SkuId in schema is BigInteger, but in fact, sku id is 32 bit value.
2787 temp
= skuInfoList
.get(index
).getSkuId().toString();
2788 skuInstance
.id
= Integer
.decode(temp
);
2789 if (skuInstance
.id
== 0) {
2793 // Judge whether is DefaultGroup at first, because most case is DefautlGroup.
2795 if (skuInfoList
.get(index
).getValue() != null) {
2796 skuInstance
.value
.setValue(skuInfoList
.get(index
).getValue().toString());
2797 if ((exceptionString
= verifyDatum(token
.cName
,
2799 skuInfoList
.get(index
).getValue().toString(),
2801 token
.datumSize
)) != null) {
2802 throw new EntityException(exceptionString
);
2805 token
.skuData
.add(skuInstance
);
2808 // Judege wether is same of datum between module's information
2809 // and dynamic information.
2811 if (datum
!= null) {
2812 if ((skuInstance
.id
== 0) &&
2813 !datum
.toString().equalsIgnoreCase(skuInfoList
.get(index
).getValue().toString())) {
2814 exceptionString
= "[FPD file error] For dynamic PCD " + token
.cName
+ ", the value in module " + moduleName
+ " is " + datum
.toString() + " but the "+
2815 "value of sku 0 data in <DynamicPcdBuildDefinition> is " + skuInstance
.value
.value
+ ". They are must be same!"+
2816 " or you could not define value for a dynamic PCD in every <ModuleSA>!";
2817 throw new EntityException(exceptionString
);
2824 // Judge whether is HII group case.
2826 if (skuInfoList
.get(index
).getVariableName() != null) {
2827 exceptionString
= null;
2828 if (skuInfoList
.get(index
).getVariableGuid() == null) {
2829 exceptionString
= String
.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+
2830 "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",
2833 if (exceptionString
!= null) {
2834 throw new EntityException(exceptionString
);
2838 if (skuInfoList
.get(index
).getVariableOffset() == null) {
2839 exceptionString
= String
.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+
2840 "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",
2843 if (exceptionString
!= null) {
2844 throw new EntityException(exceptionString
);
2848 if (skuInfoList
.get(index
).getHiiDefaultValue() == null) {
2849 exceptionString
= String
.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+
2850 "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",
2853 if (exceptionString
!= null) {
2854 throw new EntityException(exceptionString
);
2858 if (skuInfoList
.get(index
).getHiiDefaultValue() != null) {
2859 hiiDefaultValue
= skuInfoList
.get(index
).getHiiDefaultValue().toString();
2861 hiiDefaultValue
= null;
2864 if ((exceptionString
= verifyDatum(token
.cName
,
2868 token
.datumSize
)) != null) {
2869 throw new EntityException(exceptionString
);
2872 offset
= Integer
.decode(skuInfoList
.get(index
).getVariableOffset());
2873 if (offset
> 0xFFFF) {
2874 throw new EntityException(String
.format("[FPD file error] For dynamic PCD %s , the variable offset defined in sku %d data "+
2875 "exceed 64K, it is not allowed!",
2881 // Get variable guid string according to the name of guid which will be mapped into a GUID in SPD file.
2883 variableGuidString
= GlobalData
.getGuidInfoGuid(skuInfoList
.get(index
).getVariableGuid().toString());
2884 if (variableGuidString
== null) {
2885 throw new EntityException(String
.format("[GUID Error] For dynamic PCD %s, the variable guid %s can be found in all SPD file!",
2887 skuInfoList
.get(index
).getVariableGuid().toString()));
2890 skuInstance
.value
.setHiiData(skuInfoList
.get(index
).getVariableName(),
2891 translateSchemaStringToUUID(variableGuidString
[1]),
2892 skuInfoList
.get(index
).getVariableOffset(),
2893 skuInfoList
.get(index
).getHiiDefaultValue().toString());
2894 token
.skuData
.add(skuInstance
);
2898 if (skuInfoList
.get(index
).getVpdOffset() != null) {
2899 skuInstance
.value
.setVpdData(skuInfoList
.get(index
).getVpdOffset());
2900 token
.skuData
.add(skuInstance
);
2904 exceptionString
= String
.format("[FPD file error] For dynamic PCD %s, the dynamic info must "+
2905 "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.",
2907 throw new EntityException(exceptionString
);
2911 exceptionString
= String
.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+
2912 "no sku id = 0 data, which is required for every dynamic PCD",
2914 throw new EntityException(exceptionString
);
2921 Translate the schema string to UUID instance.
2923 In schema, the string of UUID is defined as following two types string:
2924 1) GuidArrayType: pattern = 0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},(
2925 )*0x[a-fA-F0-9]{1,4}(,( )*\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\})?
2927 2) GuidNamingConvention: pattern =
2928 [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}
2930 This function will convert string and create uuid instance.
2932 @param uuidString UUID string in XML file
2934 @return UUID UUID instance
2936 private UUID
translateSchemaStringToUUID(String uuidString
)
2937 throws EntityException
{
2939 String
[] splitStringArray
;
2944 if (uuidString
== null) {
2948 if (uuidString
.length() == 0) {
2952 if (uuidString
.equals("0") ||
2953 uuidString
.equalsIgnoreCase("0x0")) {
2954 return new UUID(0, 0);
2957 uuidString
= uuidString
.replaceAll("\\{", "");
2958 uuidString
= uuidString
.replaceAll("\\}", "");
2961 // If the UUID schema string is GuidArrayType type then need translate
2962 // to GuidNamingConvention type at first.
2964 if ((uuidString
.charAt(0) == '0') && ((uuidString
.charAt(1) == 'x') || (uuidString
.charAt(1) == 'X'))) {
2965 splitStringArray
= uuidString
.split("," );
2966 if (splitStringArray
.length
!= 11) {
2967 throw new EntityException ("[FPD file error] Wrong format for UUID string: " + uuidString
);
2971 // Remove blank space from these string and remove header string "0x"
2973 for (index
= 0; index
< 11; index
++) {
2974 splitStringArray
[index
] = splitStringArray
[index
].trim();
2975 splitStringArray
[index
] = splitStringArray
[index
].substring(2, splitStringArray
[index
].length());
2979 // Add heading '0' to normalize the string length
2981 for (index
= 3; index
< 11; index
++) {
2982 chLen
= splitStringArray
[index
].length();
2983 for (chIndex
= 0; chIndex
< 2 - chLen
; chIndex
++) {
2984 splitStringArray
[index
] = "0" + splitStringArray
[index
];
2989 // construct the final GuidNamingConvention string
2991 temp
= String
.format("%s-%s-%s-%s%s-%s%s%s%s%s%s",
2992 splitStringArray
[0],
2993 splitStringArray
[1],
2994 splitStringArray
[2],
2995 splitStringArray
[3],
2996 splitStringArray
[4],
2997 splitStringArray
[5],
2998 splitStringArray
[6],
2999 splitStringArray
[7],
3000 splitStringArray
[8],
3001 splitStringArray
[9],
3002 splitStringArray
[10]);
3006 return UUID
.fromString(uuidString
);
3010 check parameter for this action.
3012 @throws EntityException Bad parameter.
3014 private void checkParameter() throws EntityException
{
3017 if((fpdFilePath
== null) ||(workspacePath
== null)) {
3018 throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
3021 if(fpdFilePath
.length() == 0 || workspacePath
.length() == 0) {
3022 throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
3025 file
= new File(workspacePath
);
3026 if(!file
.exists()) {
3027 throw new EntityException("WorkpacePath " + workspacePath
+ " does not exist!");
3030 file
= new File(fpdFilePath
);
3032 if(!file
.exists()) {
3033 throw new EntityException("FPD File " + fpdFilePath
+ " does not exist!");
3040 @param argv parameter from command line
3042 public static void main(String argv
[]) throws EntityException
{
3043 CollectPCDAction ca
= new CollectPCDAction();
3044 ca
.setWorkspacePath("m:/tianocore/edk2");
3045 ca
.setFPDFilePath("m:/tianocore/edk2/EdkNt32Pkg/Nt32.fpd");
3046 ca
.setActionMessageLevel(ActionMessage
.MAX_MESSAGE_LEVEL
);
3047 GlobalData
.initInfo("Tools" + File
.separator
+ "Conf" + File
.separator
+ "FrameworkDatabase.db",
3048 "m:/tianocore/edk2");