4057c417e44783e1e10771b860ae36766d101673
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / action / CollectPCDAction.java
1 /** @file
2 CollectPCDAction class.
3
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.
7
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
13
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.
16
17 **/
18 package org.tianocore.build.pcd.action;
19
20 import java.io.BufferedReader;
21 import java.io.File;
22 import java.io.FileReader;
23 import java.io.IOException;
24 import java.util.ArrayList;
25 import java.util.Collections;
26 import java.util.Comparator;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.UUID;
31
32 import org.apache.xmlbeans.XmlException;
33 import org.apache.xmlbeans.XmlObject;
34 import org.tianocore.DynamicPcdBuildDefinitionsDocument;
35 import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions;
36 import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo;
37 import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData;
38 import org.tianocore.FrameworkModulesDocument;
39 import org.tianocore.FrameworkPlatformDescriptionDocument;
40 import org.tianocore.FrameworkPlatformDescriptionDocument.FrameworkPlatformDescription;
41 import org.tianocore.ModuleSADocument;
42 import org.tianocore.ModuleSADocument.ModuleSA;
43 import org.tianocore.PackageSurfaceAreaDocument;
44 import org.tianocore.PcdBuildDefinitionDocument.PcdBuildDefinition;
45 import org.tianocore.build.global.GlobalData;
46 import org.tianocore.build.global.SurfaceAreaQuery;
47 import org.tianocore.build.pcd.action.ActionMessage;
48 import org.tianocore.build.pcd.entity.DynamicTokenValue;
49 import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
50 import org.tianocore.build.pcd.entity.SkuInstance;
51 import org.tianocore.build.pcd.entity.Token;
52 import org.tianocore.build.pcd.entity.UsageInstance;
53 import org.tianocore.build.pcd.exception.EntityException;
54
55 class StringTable {
56 private ArrayList<String> al;
57 private ArrayList<String> alComments;
58 private String phase;
59 int len;
60 int bodyStart;
61 int bodyLineNum;
62
63 public StringTable (String phase) {
64 this.phase = phase;
65 al = new ArrayList<String>();
66 alComments = new ArrayList<String>();
67 len = 0;
68 bodyStart = 0;
69 bodyLineNum = 0;
70 }
71
72 public String getSizeMacro () {
73 return String.format(PcdDatabase.StringTableSizeMacro, phase, getSize());
74 }
75
76 private int getSize () {
77 //
78 // We have at least one Unicode Character in the table.
79 //
80 return len == 0 ? 1 : len;
81 }
82
83 public int getTableLen () {
84 return al.size() == 0 ? 1 : al.size();
85 }
86
87 public String getExistanceMacro () {
88 return String.format(PcdDatabase.StringTableExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE");
89 }
90
91 public String getTypeDeclaration () {
92
93 String output;
94
95 final String stringTable = "StringTable";
96 final String tab = "\t";
97 final String newLine = ";\r\n";
98
99 output = "/* StringTable */\r\n";
100
101 if (al.size() == 0) {
102 output += tab + String.format("UINT16 %s[1] /* StringTable is Empty */", stringTable) + newLine;
103 }
104
105 for (int i = 0; i < al.size(); i++) {
106 String str = al.get(i);
107
108 if (i == 0) {
109 //
110 // StringTable is a well-known name in the PCD DXE driver
111 //
112 output += tab + String.format("UINT16 %s[%d] /* %s */", stringTable, str.length() + 1, alComments.get(i)) + newLine;
113 } else {
114 output += tab + String.format("UINT16 %s_%d[%d] /* %s */", stringTable, i, str.length() + 1, alComments.get(i)) + newLine;
115 }
116 }
117
118 return output;
119
120 }
121
122 public ArrayList<String> getInstantiation () {
123 ArrayList<String> output = new ArrayList<String>();
124
125 output.add("/* StringTable */");
126
127 if (al.size() == 0) {
128 output.add("{ 0 }");
129 } else {
130 String str;
131
132 for (int i = 0; i < al.size(); i++) {
133 str = String.format("L\"%s\" /* %s */", al.get(i), alComments.get(i));
134 if (i != al.size() - 1) {
135 str += ",";
136 }
137 output.add(str);
138 }
139 }
140
141 return output;
142 }
143
144 public int add (String str, Token token) {
145 int i;
146
147 i = len;
148 //
149 // Include the NULL character at the end of String
150 //
151 len += str.length() + 1;
152 al.add(str);
153 alComments.add(token.getPrimaryKeyString());
154
155 return i;
156 }
157 }
158
159 class SizeTable {
160 private ArrayList<Integer> al;
161 private ArrayList<String> alComments;
162 private String phase;
163 private int len;
164 private int bodyStart;
165 private int bodyLineNum;
166
167 public SizeTable (String phase) {
168 this.phase = phase;
169 al = new ArrayList<Integer>();
170 alComments = new ArrayList<String>();
171 len = 0;
172 bodyStart = 0;
173 bodyLineNum = 0;
174 }
175
176 public String getTypeDeclaration () {
177 return String.format(PcdDatabase.SizeTableDeclaration, phase);
178 }
179
180 public ArrayList<String> getInstantiation () {
181 ArrayList<String> Output = new ArrayList<String>();
182
183 Output.add("/* SizeTable */");
184 Output.add("{");
185 bodyStart = 2;
186
187 if (al.size() == 0) {
188 Output.add("0");
189 } else {
190 for (int index = 0; index < al.size(); index++) {
191 Integer n = al.get(index);
192 String str = n.toString();
193
194 if (index != (al.size() - 1)) {
195 str += ",";
196 }
197
198 str += " /* " + alComments.get(index) + " */";
199 Output.add(str);
200 bodyLineNum++;
201
202 }
203 }
204 Output.add("}");
205
206 return Output;
207 }
208
209 public int getBodyStart() {
210 return bodyStart;
211 }
212
213 public int getBodyLineNum () {
214 return bodyLineNum;
215 }
216
217 public int add (Token token) {
218 int index = len;
219
220 len++;
221 al.add(token.datumSize);
222 alComments.add(token.getPrimaryKeyString());
223
224 return index;
225 }
226
227 private int getDatumSize(Token token) {
228 /*
229 switch (token.datumType) {
230 case Token.DATUM_TYPE.UINT8:
231 return 1;
232 default:
233 return 0;
234 }
235 */
236 return 0;
237 }
238
239 public int getTableLen () {
240 return al.size() == 0 ? 1 : al.size();
241 }
242
243 }
244
245 class GuidTable {
246 private ArrayList<UUID> al;
247 private ArrayList<String> alComments;
248 private String phase;
249 private int len;
250 private int bodyStart;
251 private int bodyLineNum;
252
253 public GuidTable (String phase) {
254 this.phase = phase;
255 al = new ArrayList<UUID>();
256 alComments = new ArrayList<String>();
257 len = 0;
258 bodyStart = 0;
259 bodyLineNum = 0;
260 }
261
262 public String getSizeMacro () {
263 return String.format(PcdDatabase.GuidTableSizeMacro, phase, getSize());
264 }
265
266 private int getSize () {
267 return (al.size() == 0)? 1 : al.size();
268 }
269
270 public String getExistanceMacro () {
271 return String.format(PcdDatabase.GuidTableExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE");
272 }
273
274 public String getTypeDeclaration () {
275 return String.format(PcdDatabase.GuidTableDeclaration, phase);
276 }
277
278 private String getUuidCString (UUID uuid) {
279 String[] guidStrArray;
280
281 guidStrArray =(uuid.toString()).split("-");
282
283 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 } }",
284 guidStrArray[0],
285 guidStrArray[1],
286 guidStrArray[2],
287 (guidStrArray[3].substring(0, 2)),
288 (guidStrArray[3].substring(2, 4)),
289 (guidStrArray[4].substring(0, 2)),
290 (guidStrArray[4].substring(2, 4)),
291 (guidStrArray[4].substring(4, 6)),
292 (guidStrArray[4].substring(6, 8)),
293 (guidStrArray[4].substring(8, 10)),
294 (guidStrArray[4].substring(10, 12))
295 );
296 }
297
298 public ArrayList<String> getInstantiation () {
299 ArrayList<String> Output = new ArrayList<String>();
300
301 Output.add("/* GuidTable */");
302 Output.add("{");
303 bodyStart = 2;
304
305 if (al.size() == 0) {
306 Output.add(getUuidCString(new UUID(0, 0)));
307 }
308
309 for (Object u : al) {
310 UUID uuid = (UUID)u;
311 String str = getUuidCString(uuid);
312
313 if (al.indexOf(u) != (al.size() - 1)) {
314 str += ",";
315 }
316 Output.add(str);
317 bodyLineNum++;
318
319 }
320 Output.add("}");
321
322 return Output;
323 }
324
325 public int getBodyStart() {
326 return bodyStart;
327 }
328
329 public int getBodyLineNum () {
330 return bodyLineNum;
331 }
332
333 public int add (UUID uuid, String name) {
334 int index = len;
335 //
336 // Include the NULL character at the end of String
337 //
338 len++;
339 al.add(uuid);
340
341 return index;
342 }
343
344 public int getTableLen () {
345 return al.size() == 0 ? 0 : al.size();
346 }
347
348 }
349
350 class SkuIdTable {
351 private ArrayList<Integer[]> al;
352 private ArrayList<String> alComment;
353 private String phase;
354 private int len;
355 private int bodyStart;
356 private int bodyLineNum;
357
358 public SkuIdTable (String phase) {
359 this.phase = phase;
360 al = new ArrayList<Integer[]>();
361 alComment = new ArrayList<String>();
362 bodyStart = 0;
363 bodyLineNum = 0;
364 len = 0;
365 }
366
367 public String getSizeMacro () {
368 return String.format(PcdDatabase.SkuIdTableSizeMacro, phase, getSize());
369 }
370
371 private int getSize () {
372 return (al.size() == 0)? 1 : al.size();
373 }
374
375 public String getExistanceMacro () {
376 return String.format(PcdDatabase.SkuTableExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE");
377 }
378
379 public String getTypeDeclaration () {
380 return String.format(PcdDatabase.SkuIdTableDeclaration, phase);
381 }
382
383 public ArrayList<String> getInstantiation () {
384 ArrayList<String> Output = new ArrayList<String> ();
385
386 Output.add("/* SkuIdTable */");
387 Output.add("{");
388 bodyStart = 2;
389
390 if (al.size() == 0) {
391 Output.add("0");
392 }
393
394 for (int index = 0; index < al.size(); index++) {
395 String str;
396
397 str = "/* " + alComment.get(index) + "*/ ";
398 str += "/* MaxSku */ ";
399
400
401 Integer[] ia = al.get(index);
402
403 str += ia[0].toString() + ", ";
404 for (int index2 = 1; index2 < ia.length; index2++) {
405 str += ia[index2].toString();
406 if (index != al.size() - 1) {
407 str += ", ";
408 }
409 }
410
411 Output.add(str);
412 bodyLineNum++;
413
414 }
415
416 Output.add("}");
417
418 return Output;
419 }
420
421 public int add (Token token) {
422
423 int index;
424
425 Integer [] skuIds = new Integer[token.skuData.size() + 1];
426 skuIds[0] = new Integer(token.skuData.size());
427 for (index = 1; index < skuIds.length; index++) {
428 skuIds[index] = new Integer(token.skuData.get(index - 1).id);
429 }
430
431 index = len;
432
433 len += skuIds.length;
434 al.add(skuIds);
435 alComment.add(token.getPrimaryKeyString());
436
437 return index;
438 }
439
440 public int getTableLen () {
441 return al.size() == 0 ? 1 : al.size();
442 }
443
444 }
445
446 class LocalTokenNumberTable {
447 private ArrayList<String> al;
448 private ArrayList<String> alComment;
449 private String phase;
450 private int len;
451
452 public LocalTokenNumberTable (String phase) {
453 this.phase = phase;
454 al = new ArrayList<String>();
455 alComment = new ArrayList<String>();
456
457 len = 0;
458 }
459
460 public String getSizeMacro () {
461 return String.format(PcdDatabase.LocalTokenNumberTableSizeMacro, phase, getSize())
462 + String.format(PcdDatabase.LocalTokenNumberSizeMacro, phase, al.size());
463 }
464
465 public int getSize () {
466 return (al.size() == 0)? 1 : al.size();
467 }
468
469 public String getExistanceMacro () {
470 return String.format(PcdDatabase.DatabaseExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE");
471 }
472
473 public String getTypeDeclaration () {
474 return String.format(PcdDatabase.LocalTokenNumberTableDeclaration, phase);
475 }
476
477 public ArrayList<String> getInstantiation () {
478 ArrayList<String> output = new ArrayList<String>();
479
480 output.add("/* LocalTokenNumberTable */");
481 output.add("{");
482
483 if (al.size() == 0) {
484 output.add("0");
485 }
486
487 for (int index = 0; index < al.size(); index++) {
488 String str;
489
490 str = (String)al.get(index);
491
492 str += " /* " + alComment.get(index) + " */ ";
493
494
495 if (index != (al.size() - 1)) {
496 str += ",";
497 }
498
499 output.add(str);
500
501 }
502
503 output.add("}");
504
505 return output;
506 }
507
508 public int add (Token token) {
509 int index = len;
510 String str;
511
512 len++;
513
514 str = String.format(PcdDatabase.offsetOfStrTemplate, phase, token.hasDefaultValue() ? "Init" : "Uninit", token.getPrimaryKeyString());
515
516 if (token.isStringType()) {
517 str += " | PCD_TYPE_STRING";
518 }
519
520 if (token.isSkuEnable()) {
521 str += " | PCD_TYPE_SKU_ENABLED";
522 }
523
524 if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {
525 str += " | PCD_TYPE_HII";
526 }
527
528 if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {
529 str += " | PCD_TYPE_VPD";
530 }
531
532 al.add(str);
533 alComment.add(token.getPrimaryKeyString());
534
535 return index;
536 }
537 }
538
539 class ExMapTable {
540
541 class ExTriplet {
542 public Integer guidTableIdx;
543 public Long exTokenNumber;
544 public Long localTokenIdx;
545
546 public ExTriplet (int guidTableIdx, long exTokenNumber, long localTokenIdx) {
547 this.guidTableIdx = new Integer(guidTableIdx);
548 this.exTokenNumber = new Long(exTokenNumber);
549 this.localTokenIdx = new Long(localTokenIdx);
550 }
551 }
552
553 private ArrayList<ExTriplet> al;
554 private ArrayList<String> alComment;
555 private String phase;
556 private int len;
557 private int bodyStart;
558 private int bodyLineNum;
559 private int base;
560
561 public ExMapTable (String phase) {
562 this.phase = phase;
563 al = new ArrayList<ExTriplet>();
564 alComment = new ArrayList<String>();
565 bodyStart = 0;
566 bodyLineNum = 0;
567 len = 0;
568 }
569
570 public String getSizeMacro () {
571 return String.format(PcdDatabase.ExMapTableSizeMacro, phase, getTableLen())
572 + String.format(PcdDatabase.ExTokenNumber, phase, al.size());
573 }
574
575 private int getSize () {
576 return (al.size() == 0)? 1 : al.size();
577 }
578
579 public String getExistanceMacro () {
580 return String.format(PcdDatabase.ExMapTableExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE");
581 }
582
583 public String getTypeDeclaration () {
584 return String.format(PcdDatabase.ExMapTableDeclaration, phase);
585 }
586
587 public ArrayList<String> getInstantiation () {
588 ArrayList<String> Output = new ArrayList<String>();
589
590 Output.add("/* ExMapTable */");
591 Output.add("{");
592 bodyStart = 2;
593
594 if (al.size() == 0) {
595 Output.add("{0, 0, 0}");
596 }
597
598 int index;
599 for (index = 0; index < al.size(); index++) {
600 String str;
601
602 ExTriplet e = (ExTriplet)al.get(index);
603
604 str = "{ " + e.exTokenNumber.toString() + ", ";
605 str += e.localTokenIdx.toString() + ", ";
606 str += e.guidTableIdx.toString();
607
608 str += " /* " + alComment.get(index) + " */";
609
610 if (index != al.size() - 1) {
611 str += ",";
612 }
613
614 Output.add(str);
615 bodyLineNum++;
616
617 }
618
619 Output.add("}");
620
621 return Output;
622 }
623
624 public int add (int localTokenIdx, long exTokenNum, int guidTableIdx, String name) {
625 int index = len;
626
627 len++;
628 al.add(new ExTriplet(guidTableIdx, exTokenNum, localTokenIdx));
629 alComment.add(name);
630
631 return index;
632 }
633
634 public int getTableLen () {
635 return al.size() == 0 ? 1 : al.size();
636 }
637
638 }
639
640 class PcdDatabase {
641
642 public final static String ExMapTableDeclaration = "DYNAMICEX_MAPPING ExMapTable[%s_EXMAPPING_TABLE_SIZE];\r\n";
643 public final static String GuidTableDeclaration = "EFI_GUID GuidTable[%s_GUID_TABLE_SIZE];\r\n";
644 public final static String LocalTokenNumberTableDeclaration = "UINT32 LocalTokenNumberTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";
645 public final static String StringTableDeclaration = "UINT16 StringTable[%s_STRING_TABLE_SIZE];\r\n";
646 public final static String SizeTableDeclaration = "UINT16 SizeTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";
647 public final static String SkuIdTableDeclaration = "UINT8 SkuIdTable[%s_SKUID_TABLE_SIZE];\r\n";
648
649
650 public final static String ExMapTableSizeMacro = "#define %s_EXMAPPING_TABLE_SIZE %d\r\n";
651 public final static String ExTokenNumber = "#define %s_EX_TOKEN_NUMBER %d\r\n";
652 public final static String GuidTableSizeMacro = "#define %s_GUID_TABLE_SIZE %d\r\n";
653 public final static String LocalTokenNumberTableSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER_TABLE_SIZE %d\r\n";
654 public final static String LocalTokenNumberSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER %d\r\n";
655 public final static String StringTableSizeMacro = "#define %s_STRING_TABLE_SIZE %d\r\n";
656 public final static String SkuIdTableSizeMacro = "#define %s_SKUID_TABLE_SIZE %d\r\n";
657
658
659 public final static String ExMapTableExistenceMacro = "#define %s_EXMAP_TABLE_EMPTY %s\r\n";
660 public final static String GuidTableExistenceMacro = "#define %s_GUID_TABLE_EMPTY %s\r\n";
661 public final static String DatabaseExistenceMacro = "#define %s_DATABASE_EMPTY %s\r\n";
662 public final static String StringTableExistenceMacro = "#define %s_STRING_TABLE_EMPTY %s\r\n";
663 public final static String SkuTableExistenceMacro = "#define %s_SKUID_TABLE_EMPTY %s\r\n";
664
665 public final static String offsetOfSkuHeadStrTemplate = "offsetof(%s_PCD_DATABASE, %s.%s_SkuDataTable)";
666 public final static String offsetOfStrTemplate = "offsetof(%s_PCD_DATABASE, %s.%s)";
667
668 private StringTable stringTable;
669 private GuidTable guidTable;
670 private LocalTokenNumberTable localTokenNumberTable;
671 private SkuIdTable skuIdTable;
672 private SizeTable sizeTable;
673 private ExMapTable exMapTable;
674
675 private ArrayList<Token> alTokens;
676 private String phase;
677 private int assignedTokenNumber;
678
679 //
680 // After Major changes done to the PCD
681 // database generation class PcdDatabase
682 // Please increment the version and please
683 // also update the version number in PCD
684 // service PEIM and DXE driver accordingly.
685 //
686 private final int version = 1;
687
688 private String hString;
689 private String cString;
690
691
692 class AlignmentSizeComp implements Comparator<Token> {
693 public int compare (Token a, Token b) {
694 return getAlignmentSize(b)
695 - getAlignmentSize(a);
696 }
697 }
698
699 public PcdDatabase (ArrayList<Token> alTokens, String exePhase, int startLen) {
700 phase = exePhase;
701
702 stringTable = new StringTable(phase);
703 guidTable = new GuidTable(phase);
704 localTokenNumberTable = new LocalTokenNumberTable(phase);
705 skuIdTable = new SkuIdTable(phase);
706 sizeTable = new SizeTable(phase);
707 exMapTable = new ExMapTable(phase);
708
709 assignedTokenNumber = startLen;
710 this.alTokens = alTokens;
711 }
712
713 private void getTwoGroupsOfTokens (ArrayList<Token> alTokens, List<Token> initTokens, List<Token> uninitTokens) {
714 for (int i = 0; i < alTokens.size(); i++) {
715 Token t = (Token)alTokens.get(i);
716 if (t.hasDefaultValue()) {
717 initTokens.add(t);
718 } else {
719 uninitTokens.add(t);
720 }
721 }
722
723 return;
724 }
725
726 private int getAlignmentSize (Token token) {
727 if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {
728 return 2;
729 }
730
731 if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {
732 return 4;
733 }
734
735 if (token.isStringType()) {
736 return 2;
737 }
738
739 switch (token.datumType) {
740 case UINT8:
741 return 1;
742 case UINT16:
743 return 2;
744 case UINT32:
745 return 4;
746 case UINT64:
747 return 8;
748 case POINTER:
749 return 1;
750 case BOOLEAN:
751 return 1;
752 }
753 return 1;
754 }
755
756 public String getCString () {
757 return cString;
758 }
759
760 public String getHString () {
761 return hString;
762 }
763
764 public void genCode ()
765 throws EntityException {
766
767 final String newLine = "\r\n";
768 final String declNewLine = ";\r\n";
769 final String tab = "\t";
770 final String commaNewLine = ", \r\n";
771
772 int i;
773 ArrayList<String> decla;
774 ArrayList<String> inst;
775
776 String macroStr = "";
777 String initDeclStr = "";
778 String initInstStr = "";
779 String uninitDeclStr = "";
780
781 List<Token> initTokens = new ArrayList<Token> ();
782 List<Token> uninitTokens = new ArrayList<Token> ();
783
784 HashMap <String, ArrayList<String>> initCode = new HashMap<String, ArrayList<String>> ();
785 HashMap <String, ArrayList<String>> uninitCode = new HashMap<String, ArrayList<String>> ();
786
787 getTwoGroupsOfTokens (alTokens, initTokens, uninitTokens);
788
789 //
790 // Generate Structure Declaration for PcdTokens without Default Value
791 // PEI_PCD_DATABASE_INIT
792 //
793 java.util.Comparator<Token> comparator = new AlignmentSizeComp();
794 java.util.Collections.sort(initTokens, comparator);
795 initCode = processTokens(initTokens);
796
797 //
798 // Generate Structure Declaration for PcdTokens without Default Value
799 // PEI_PCD_DATABASE_UNINIT
800 //
801 java.util.Collections.sort(uninitTokens, comparator);
802 uninitCode = processTokens(uninitTokens);
803
804 //
805 // Generate size info Macro for all Tables
806 //
807 macroStr += guidTable.getSizeMacro();
808 macroStr += stringTable.getSizeMacro();
809 macroStr += skuIdTable.getSizeMacro();
810 macroStr += localTokenNumberTable.getSizeMacro();
811 macroStr += exMapTable.getSizeMacro();
812
813 //
814 // Generate existance info Macro for all Tables
815 //
816 macroStr += guidTable.getExistanceMacro();
817 macroStr += stringTable.getExistanceMacro();
818 macroStr += skuIdTable.getExistanceMacro();
819 macroStr += localTokenNumberTable.getExistanceMacro();
820 macroStr += exMapTable.getExistanceMacro();
821
822 //
823 // Generate Structure Declaration for PcdTokens with Default Value
824 // for example PEI_PCD_DATABASE_INIT
825 //
826 initDeclStr += "typedef struct {" + newLine;
827 {
828 initDeclStr += tab + exMapTable.getTypeDeclaration();
829 initDeclStr += tab + guidTable.getTypeDeclaration();
830 initDeclStr += tab + localTokenNumberTable.getTypeDeclaration();
831 initDeclStr += tab + stringTable.getTypeDeclaration();
832 initDeclStr += tab + sizeTable.getTypeDeclaration();
833 initDeclStr += tab + skuIdTable.getTypeDeclaration();
834 if (phase.equalsIgnoreCase("PEI")) {
835 initDeclStr += tab + "SKU_ID SystemSkuId;" + newLine;
836 }
837
838 decla = initCode.get(new String("Declaration"));
839 for (i = 0; i < decla.size(); i++) {
840 initDeclStr += tab + decla.get(i) + declNewLine;
841 }
842
843 //
844 // Generate Structure Declaration for PcdToken with SkuEnabled
845 //
846 decla = initCode.get("DeclarationForSku");
847
848 for (i = 0; i < decla.size(); i++) {
849 initDeclStr += tab + decla.get(i) + declNewLine;
850 }
851 }
852 initDeclStr += String.format("} %s_PCD_DATABASE_INIT;\r\n\r\n", phase);
853
854 //
855 // Generate MACRO for structure intialization of PCDTokens with Default Value
856 // The sequence must match the sequence of declaration of the memembers in the structure
857 String tmp = String.format("%s_PCD_DATABASE_INIT g%sPcdDbInit = { ", phase.toUpperCase(), phase.toUpperCase());
858 initInstStr += tmp + newLine;
859 initInstStr += tab + genInstantiationStr(exMapTable.getInstantiation()) + commaNewLine;
860 initInstStr += tab + genInstantiationStr(guidTable.getInstantiation()) + commaNewLine;
861 initInstStr += tab + genInstantiationStr(localTokenNumberTable.getInstantiation()) + commaNewLine;
862 initInstStr += tab + genInstantiationStr(stringTable.getInstantiation()) + commaNewLine;
863 initInstStr += tab + genInstantiationStr(sizeTable.getInstantiation()) + commaNewLine;
864 initInstStr += tab + genInstantiationStr(skuIdTable.getInstantiation()) + commaNewLine;
865 //
866 // For SystemSkuId
867 //
868 if (phase.equalsIgnoreCase("PEI")) {
869 initInstStr += tab + "0" + tab + "/* SystemSkuId */" + commaNewLine;
870 }
871
872 inst = initCode.get("Instantiation");
873 for (i = 0; i < inst.size(); i++) {
874 initInstStr += tab + inst.get(i) + commaNewLine;
875 }
876
877 inst = initCode.get("InstantiationForSku");
878 for (i = 0; i < inst.size(); i++) {
879 initInstStr += tab + inst.get(i);
880 if (i != inst.size() - 1) {
881 initInstStr += commaNewLine;
882 }
883 }
884
885 initInstStr += "};";
886
887 uninitDeclStr += "typedef struct {" + newLine;
888 {
889 decla = uninitCode.get("Declaration");
890 if (decla.size() == 0) {
891 uninitDeclStr += "UINT8 dummy /* The UINT struct is empty */" + declNewLine;
892 } else {
893
894 for (i = 0; i < decla.size(); i++) {
895 uninitDeclStr += tab + decla.get(i) + declNewLine;
896 }
897
898 decla = uninitCode.get("DeclarationForSku");
899
900 for (i = 0; i < decla.size(); i++) {
901 uninitDeclStr += tab + decla.get(i) + declNewLine;
902 }
903 }
904 }
905 uninitDeclStr += String.format("} %s_PCD_DATABASE_UNINIT;\r\n\r\n", phase);
906
907 cString = initInstStr + newLine;
908 hString = macroStr + newLine
909 + initDeclStr + newLine
910 + uninitDeclStr + newLine
911 + newLine;
912
913 hString += String.format("#define PCD_%s_SERVICE_DRIVER_VERSION %d", phase, version);
914
915 }
916
917 private String genInstantiationStr (ArrayList<String> alStr) {
918 String str = "";
919 for (int i = 0; i< alStr.size(); i++) {
920 str += "\t" + alStr.get(i);
921 if (i != alStr.size() - 1) {
922 str += "\r\n";
923 }
924 }
925
926 return str;
927 }
928
929 private HashMap<String, ArrayList<String>> processTokens (List<Token> alToken)
930 throws EntityException {
931
932 HashMap <String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
933
934 ArrayList<String> decl = new ArrayList<String>();
935 ArrayList<String> declForSkuEnableType = new ArrayList<String>();
936 ArrayList<String> inst = new ArrayList<String>();
937 ArrayList<String> instForSkuEnableType = new ArrayList<String>();
938
939 for (int index = 0; index < alToken.size(); index++) {
940 Token token = alToken.get(index);
941
942 if (token.isSkuEnable()) {
943 //
944 // BugBug: Schema only support Data type now
945 //
946 int tableIdx;
947
948 tableIdx = skuIdTable.add(token);
949
950 decl.add(getSkuEnabledTypeDeclaration(token));
951 if (token.hasDefaultValue()) {
952 inst.add(getSkuEnabledTypeInstantiaion(token, tableIdx));
953 }
954
955 declForSkuEnableType.add(getDataTypeDeclarationForSkuEnabled(token));
956 if (token.hasDefaultValue()) {
957 instForSkuEnableType.add(getDataTypeInstantiationForSkuEnabled(token));
958 }
959
960 } else {
961 if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {
962 decl.add(getVariableEnableTypeDeclaration(token));
963 inst.add(getVariableEnableInstantiation(token));
964 } else if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {
965 decl.add(getVpdEnableTypeDeclaration(token));
966 inst.add(getVpdEnableTypeInstantiation(token));
967 } else if (token.isStringType()) {
968 decl.add(getStringTypeDeclaration(token));
969 inst.add(getStringTypeInstantiation(stringTable.add(token.getStringTypeString(), token), token));
970 }
971 else {
972 decl.add(getDataTypeDeclaration(token));
973 if (token.hasDefaultValue()) {
974 inst.add(getDataTypeInstantiation(token));
975 }
976 }
977 }
978
979 sizeTable.add(token);
980 localTokenNumberTable.add(token);
981 token.tokenNumber = assignedTokenNumber++;
982
983 }
984
985 map.put("Declaration", decl);
986 map.put("DeclarationForSku", declForSkuEnableType);
987 map.put("Instantiation", inst);
988 map.put("InstantiationForSku", instForSkuEnableType);
989
990 return map;
991 }
992
993 private String getSkuEnabledTypeDeclaration (Token token) {
994 return String.format("SKU_HEAD %s;\r\n", token.getPrimaryKeyString());
995 }
996
997 private String getSkuEnabledTypeInstantiaion (Token token, int SkuTableIdx) {
998
999 String offsetof = String.format(PcdDatabase.offsetOfSkuHeadStrTemplate, phase, token.hasDefaultValue()? "Init" : "Uninit", token.getPrimaryKeyString());
1000 return String.format("{ %s, %d }", offsetof, SkuTableIdx);
1001 }
1002
1003 private String getDataTypeDeclarationForSkuEnabled (Token token) {
1004 String typeStr = "";
1005
1006 if (token.datumType == Token.DATUM_TYPE.UINT8) {
1007 typeStr = "UINT8 %s_%s[%d];\r\n";
1008 } else if (token.datumType == Token.DATUM_TYPE.UINT16) {
1009 typeStr = "UINT16 %s_%s[%d];\r\n";
1010 } else if (token.datumType == Token.DATUM_TYPE.UINT32) {
1011 typeStr = "UINT32 %s_%s[%d];\r\n";
1012 } else if (token.datumType == Token.DATUM_TYPE.UINT64) {
1013 typeStr = "UINT64 %s_%s[%d];\r\n";
1014 } else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) {
1015 typeStr = "BOOLEAN %s_%s[%d];\r\n";
1016 } else if (token.datumType == Token.DATUM_TYPE.POINTER) {
1017 return String.format("UINT8 %s_%s[%d];\r\n", token.getPrimaryKeyString(), "SkuDataTable", token.datumSize * token.skuData.size());
1018 }
1019
1020 return String.format(typeStr, token.getPrimaryKeyString(), "SkuDataTable", token.skuData.size());
1021
1022 }
1023
1024 private String getDataTypeInstantiationForSkuEnabled (Token token) {
1025 String str = "";
1026
1027 if (token.datumType == Token.DATUM_TYPE.POINTER) {
1028 return String.format("UINT8 %s_%s[%d]", token.getPrimaryKeyString(), "SkuDataTable", token.datumSize * token.skuData.size());
1029 } else {
1030 str = "{ ";
1031 for (int idx = 0; idx < token.skuData.size(); idx++) {
1032 str += token.skuData.get(idx).toString();
1033 if (idx != token.skuData.size() - 1) {
1034 str += ", ";
1035 }
1036 }
1037 str += "}";
1038
1039 return str;
1040 }
1041
1042 }
1043
1044 private String getDataTypeInstantiation (Token token) {
1045
1046 if (token.datumType == Token.DATUM_TYPE.POINTER) {
1047 return String.format("%s /* %s */", token.getDefaultSku().value, token.getPrimaryKeyString());
1048 } else {
1049 return String.format("%s /* %s */", token.getDefaultSku().value, token.getPrimaryKeyString());
1050 }
1051 }
1052
1053
1054 private String getDataTypeDeclaration (Token token) {
1055
1056 String typeStr = "";
1057
1058 if (token.datumType == Token.DATUM_TYPE.UINT8) {
1059 typeStr = "UINT8";
1060 } else if (token.datumType == Token.DATUM_TYPE.UINT16) {
1061 typeStr = "UINT16";
1062 } else if (token.datumType == Token.DATUM_TYPE.UINT32) {
1063 typeStr = "UINT32";
1064 } else if (token.datumType == Token.DATUM_TYPE.UINT64) {
1065 typeStr = "UINT64";
1066 } else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) {
1067 typeStr = "BOOLEAN";
1068 } else if (token.datumType == Token.DATUM_TYPE.POINTER) {
1069 return String.format("UINT8 %s[%d]", token.getPrimaryKeyString(), token.datumSize);
1070 } else {
1071 }
1072
1073 return String.format("%s %s", typeStr, token.getPrimaryKeyString());
1074 }
1075
1076 private String getVpdEnableTypeDeclaration (Token token) {
1077 return String.format("VPD_HEAD %s", token.getPrimaryKeyString());
1078 }
1079
1080 private String getVpdEnableTypeInstantiation (Token token) {
1081 return String.format("{ %s } /* %s */", token.getDefaultSku().vpdOffset,
1082 token.getPrimaryKeyString());
1083 }
1084
1085 private String getStringTypeDeclaration (Token token) {
1086 return String.format("UINT16 %s", token.getPrimaryKeyString());
1087 }
1088
1089 private String getStringTypeInstantiation (int StringTableIdx, Token token) {
1090 return String.format ("%d /* %s */", StringTableIdx,
1091 token.getPrimaryKeyString());
1092 }
1093
1094
1095 private String getVariableEnableTypeDeclaration (Token token) {
1096 return String.format("VARIABLE_HEAD %s", token.getPrimaryKeyString());
1097 }
1098
1099 private String getVariableEnableInstantiation (Token token)
1100 throws EntityException {
1101 //
1102 // Need scott fix
1103 //
1104 return String.format("{ %d, %d, %s } /* %s */", guidTable.add(token.getDefaultSku().variableGuid, token.getPrimaryKeyString()),
1105 stringTable.add(token.getDefaultSku().getStringOfVariableName(), token),
1106 token.getDefaultSku().variableOffset,
1107 token.getPrimaryKeyString());
1108 }
1109
1110 public int getTotalTokenNumber () {
1111 return sizeTable.getTableLen();
1112 }
1113
1114 public static String getPcdDatabaseCommonDefinitions ()
1115 throws EntityException {
1116
1117 String retStr = "";
1118 try {
1119 File file = new File(GlobalData.getWorkspacePath() + File.separator +
1120 "Tools" + File.separator +
1121 "Conf" + File.separator +
1122 "Pcd" + File.separator +
1123 "PcdDatabaseCommonDefinitions.sample");
1124 FileReader reader = new FileReader(file);
1125 BufferedReader in = new BufferedReader(reader);
1126 String str;
1127 while ((str = in.readLine()) != null) {
1128 retStr = retStr +"\r\n" + str;
1129 }
1130 } catch (Exception ex) {
1131 throw new EntityException("Fatal error when generating PcdDatabase Common Definitions");
1132 }
1133
1134 return retStr;
1135 }
1136
1137 public static String getPcdDxeDatabaseDefinitions ()
1138 throws EntityException {
1139
1140 String retStr = "";
1141 try {
1142 File file = new File(GlobalData.getWorkspacePath() + File.separator +
1143 "Tools" + File.separator +
1144 "Conf" + File.separator +
1145 "Pcd" + File.separator +
1146 "PcdDatabaseDxeDefinitions.sample");
1147 FileReader reader = new FileReader(file);
1148 BufferedReader in = new BufferedReader(reader);
1149 String str;
1150 while ((str = in.readLine()) != null) {
1151 retStr = retStr +"\r\n" + str;
1152 }
1153 } catch (Exception ex) {
1154 throw new EntityException("Fatal error when generating PcdDatabase Dxe Definitions");
1155 }
1156
1157 return retStr;
1158 }
1159
1160 public static String getPcdPeiDatabaseDefinitions ()
1161 throws EntityException {
1162
1163 String retStr = "";
1164 try {
1165 File file = new File(GlobalData.getWorkspacePath() + File.separator +
1166 "Tools" + File.separator +
1167 "Conf" + File.separator +
1168 "Pcd" + File.separator +
1169 "PcdDatabasePeiDefinitions.sample");
1170 FileReader reader = new FileReader(file);
1171 BufferedReader in = new BufferedReader(reader);
1172 String str;
1173 while ((str = in.readLine()) != null) {
1174 retStr = retStr +"\r\n" + str;
1175 }
1176 } catch (Exception ex) {
1177 throw new EntityException("Fatal error when generating PcdDatabase Pei Definitions");
1178 }
1179
1180 return retStr;
1181 }
1182
1183 }
1184
1185 class ModuleInfo {
1186 public ModuleSADocument.ModuleSA module;
1187 public UsageInstance.MODULE_TYPE type;
1188
1189 public ModuleInfo (ModuleSADocument.ModuleSA module, UsageInstance.MODULE_TYPE type) {
1190 this.module = module;
1191 this.type = type;
1192 }
1193 }
1194
1195 /** This action class is to collect PCD information from MSA, SPD, FPD xml file.
1196 This class will be used for wizard and build tools, So it can *not* inherit
1197 from buildAction or UIAction.
1198 **/
1199 public class CollectPCDAction {
1200 /// memoryDatabase hold all PCD information collected from SPD, MSA, FPD.
1201 private MemoryDatabaseManager dbManager;
1202
1203 /// Workspacepath hold the workspace information.
1204 private String workspacePath;
1205
1206 /// FPD file is the root file.
1207 private String fpdFilePath;
1208
1209 /// Message level for CollectPCDAction.
1210 private int originalMessageLevel;
1211
1212 /// Cache the fpd docment instance for private usage.
1213 private FrameworkPlatformDescriptionDocument fpdDocInstance;
1214
1215 /**
1216 Set WorkspacePath parameter for this action class.
1217
1218 @param workspacePath parameter for this action
1219 **/
1220 public void setWorkspacePath(String workspacePath) {
1221 this.workspacePath = workspacePath;
1222 }
1223
1224 /**
1225 Set action message level for CollectPcdAction tool.
1226
1227 The message should be restored when this action exit.
1228
1229 @param actionMessageLevel parameter for this action
1230 **/
1231 public void setActionMessageLevel(int actionMessageLevel) {
1232 originalMessageLevel = ActionMessage.messageLevel;
1233 ActionMessage.messageLevel = actionMessageLevel;
1234 }
1235
1236 /**
1237 Set FPDFileName parameter for this action class.
1238
1239 @param fpdFilePath fpd file path
1240 **/
1241 public void setFPDFilePath(String fpdFilePath) {
1242 this.fpdFilePath = fpdFilePath;
1243 }
1244
1245 /**
1246 Common function interface for outer.
1247
1248 @param workspacePath The path of workspace of current build or analysis.
1249 @param fpdFilePath The fpd file path of current build or analysis.
1250 @param messageLevel The message level for this Action.
1251
1252 @throws Exception The exception of this function. Because it can *not* be predict
1253 where the action class will be used. So only Exception can be throw.
1254
1255 **/
1256 public void perform(String workspacePath, String fpdFilePath,
1257 int messageLevel) throws Exception {
1258 setWorkspacePath(workspacePath);
1259 setFPDFilePath(fpdFilePath);
1260 setActionMessageLevel(messageLevel);
1261 checkParameter();
1262 execute();
1263 ActionMessage.messageLevel = originalMessageLevel;
1264 }
1265
1266 /**
1267 Core execution function for this action class.
1268
1269 This function work flows will be:
1270 1) Collect and prepocess PCD information from FPD file, all PCD
1271 information will be stored into memory database.
1272 2) Generate 3 strings for
1273 a) All modules using Dynamic(Ex) PCD entry.(Token Number)
1274 b) PEI PCDDatabase (C Structure) for PCD Service PEIM.
1275 c) DXE PCD Database (C structure) for PCD Service DXE.
1276
1277
1278 @throws EntityException Exception indicate failed to execute this action.
1279
1280 **/
1281 private void execute() throws EntityException {
1282 //
1283 // Get memoryDatabaseManager instance from GlobalData.
1284 // The memoryDatabaseManager should be initialized for whatever build
1285 // tools or wizard tools
1286 //
1287 if((dbManager = GlobalData.getPCDMemoryDBManager()) == null) {
1288 throw new EntityException("The instance of PCD memory database manager is null");
1289 }
1290
1291 //
1292 // Collect all PCD information defined in FPD file.
1293 // Evenry token defind in FPD will be created as an token into
1294 // memory database.
1295 //
1296 createTokenInDBFromFPD();
1297
1298 //
1299 // Call Private function genPcdDatabaseSourceCode (void); ComponentTypeBsDriver
1300 // 1) Generate for PEI, DXE PCD DATABASE's definition and initialization.
1301 //
1302 genPcdDatabaseSourceCode ();
1303
1304 }
1305
1306 /**
1307 This function generates source code for PCD Database.
1308
1309 @param void
1310 @throws EntityException If the token does *not* exist in memory database.
1311
1312 **/
1313 private void genPcdDatabaseSourceCode()
1314 throws EntityException {
1315 String PcdCommonHeaderString = PcdDatabase.getPcdDatabaseCommonDefinitions ();
1316
1317 ArrayList<Token> alPei = new ArrayList<Token> ();
1318 ArrayList<Token> alDxe = new ArrayList<Token> ();
1319
1320 dbManager.getTwoPhaseDynamicRecordArray(alPei, alDxe);
1321 PcdDatabase pcdPeiDatabase = new PcdDatabase (alPei, "PEI", 0);
1322 pcdPeiDatabase.genCode();
1323 dbManager.PcdPeimHString = PcdCommonHeaderString + pcdPeiDatabase.getHString()
1324 + PcdDatabase.getPcdPeiDatabaseDefinitions();
1325 dbManager.PcdPeimCString = pcdPeiDatabase.getCString();
1326
1327 PcdDatabase pcdDxeDatabase = new PcdDatabase (alDxe,
1328 "DXE",
1329 alPei.size()
1330 );
1331 pcdDxeDatabase.genCode();
1332 dbManager.PcdDxeHString = dbManager.PcdPeimHString + pcdDxeDatabase.getHString()
1333 + PcdDatabase.getPcdDxeDatabaseDefinitions();
1334 dbManager.PcdDxeCString = pcdDxeDatabase.getCString();
1335 }
1336
1337 /**
1338 Get component array from FPD.
1339
1340 This function maybe provided by some Global class.
1341
1342 @return List<ModuleInfo> the component array.
1343
1344 */
1345 private List<ModuleInfo> getComponentsFromFPD()
1346 throws EntityException {
1347 HashMap<String, XmlObject> map = new HashMap<String, XmlObject>();
1348 List<ModuleInfo> allModules = new ArrayList<ModuleInfo>();
1349 ModuleInfo current = null;
1350 int index = 0;
1351 org.tianocore.Components components = null;
1352 FrameworkModulesDocument.FrameworkModules fModules = null;
1353 java.util.List<ModuleSADocument.ModuleSA> modules = null;
1354
1355
1356 if (fpdDocInstance == null) {
1357 try {
1358 fpdDocInstance = (FrameworkPlatformDescriptionDocument)XmlObject.Factory.parse(new File(fpdFilePath));
1359 } catch(IOException ioE) {
1360 throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage());
1361 } catch(XmlException xmlE) {
1362 throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage());
1363 }
1364
1365 }
1366
1367 //
1368 // Check whether FPD contians <FramworkModules>
1369 //
1370 fModules = fpdDocInstance.getFrameworkPlatformDescription().getFrameworkModules();
1371 if (fModules == null) {
1372 return null;
1373 }
1374
1375 //
1376 // BUGBUG: The following is work around code, the final component type should be get from
1377 // GlobalData class.
1378 //
1379 components = fModules.getSEC();
1380 if (components != null) {
1381 modules = components.getModuleSAList();
1382 for (index = 0; index < modules.size(); index ++) {
1383 allModules.add(new ModuleInfo(modules.get(index), UsageInstance.MODULE_TYPE.SEC));
1384 }
1385 }
1386
1387 components = fModules.getPEICORE();
1388 if (components != null) {
1389 modules = components.getModuleSAList();
1390 for (index = 0; index < modules.size(); index ++) {
1391 allModules.add(new ModuleInfo(modules.get(index), UsageInstance.MODULE_TYPE.PEI_CORE));
1392 }
1393 }
1394
1395 components = fModules.getPEIM();
1396 if (components != null) {
1397 modules = components.getModuleSAList();
1398 for (index = 0; index < modules.size(); index ++) {
1399 allModules.add(new ModuleInfo(modules.get(index), UsageInstance.MODULE_TYPE.PEIM));
1400 }
1401 }
1402
1403 components = fModules.getDXECORE();
1404 if (components != null) {
1405 modules = components.getModuleSAList();
1406 for (index = 0; index < modules.size(); index ++) {
1407 allModules.add(new ModuleInfo(modules.get(index), UsageInstance.MODULE_TYPE.DXE_CORE));
1408 }
1409 }
1410
1411 components = fModules.getDXEDRIVERS();
1412 if (components != null) {
1413 modules = components.getModuleSAList();
1414 for (index = 0; index < modules.size(); index ++) {
1415 allModules.add(new ModuleInfo(modules.get(index), UsageInstance.MODULE_TYPE.DXE_DRIVERS));
1416 }
1417 }
1418
1419 components = fModules.getOTHERCOMPONENTS();
1420 if (components != null) {
1421 modules = components.getModuleSAList();
1422 for (index = 0; index < modules.size(); index ++) {
1423 allModules.add(new ModuleInfo(modules.get(index), UsageInstance.MODULE_TYPE.OTHER_COMPONENTS));
1424 }
1425 }
1426
1427 return allModules;
1428 }
1429
1430 /**
1431 Create token instance object into memory database, the token information
1432 comes for FPD file. Normally, FPD file will contain all token platform
1433 informations.
1434
1435 @return FrameworkPlatformDescriptionDocument The FPD document instance for furture usage.
1436
1437 @throws EntityException Failed to parse FPD xml file.
1438
1439 **/
1440 private void createTokenInDBFromFPD()
1441 throws EntityException {
1442 int index = 0;
1443 int index2 = 0;
1444 int pcdIndex = 0;
1445 List<PcdBuildDefinition.PcdData> pcdBuildDataArray = new ArrayList<PcdBuildDefinition.PcdData>();
1446 PcdBuildDefinition.PcdData pcdBuildData = null;
1447 Token token = null;
1448 SkuInstance skuInstance = null;
1449 int skuIndex = 0;
1450 List<ModuleInfo> modules = null;
1451 String primaryKey = null;
1452 String exceptionString = null;
1453 UsageInstance usageInstance = null;
1454 String primaryKey1 = null;
1455 String primaryKey2 = null;
1456 boolean isDuplicate = false;
1457 Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN;
1458 Token.DATUM_TYPE datumType = Token.DATUM_TYPE.UNKNOWN;
1459 int tokenNumber = 0;
1460 String moduleName = null;
1461 String datum = null;
1462 int maxDatumSize = 0;
1463
1464 //
1465 // ----------------------------------------------
1466 // 1), Get all <ModuleSA> from FPD file.
1467 // ----------------------------------------------
1468 //
1469 modules = getComponentsFromFPD();
1470
1471 if (modules == null) {
1472 throw new EntityException("No modules in FPD file, Please check whether there are elements in <FrameworkModules> in FPD file!");
1473 }
1474
1475 //
1476 // -------------------------------------------------------------------
1477 // 2), Loop all modules to process <PcdBuildDeclarations> for each module.
1478 // -------------------------------------------------------------------
1479 //
1480 for (index = 0; index < modules.size(); index ++) {
1481 isDuplicate = false;
1482 for (index2 = 0; index2 < index; index2 ++) {
1483 //
1484 // BUGBUG: For transition schema, we can *not* get module's version from
1485 // <ModuleSAs>, It is work around code.
1486 //
1487 primaryKey1 = UsageInstance.getPrimaryKey(modules.get(index).module.getModuleName(),
1488 translateSchemaStringToUUID(modules.get(index).module.getModuleGuid()),
1489 modules.get(index).module.getPackageName(),
1490 translateSchemaStringToUUID(modules.get(index).module.getPackageGuid()),
1491 modules.get(index).module.getArch().toString(),
1492 null);
1493 primaryKey2 = UsageInstance.getPrimaryKey(modules.get(index2).module.getModuleName(),
1494 translateSchemaStringToUUID(modules.get(index2).module.getModuleGuid()),
1495 modules.get(index2).module.getPackageName(),
1496 translateSchemaStringToUUID(modules.get(index2).module.getPackageGuid()),
1497 modules.get(index2).module.getArch().toString(),
1498 null);
1499 if (primaryKey1.equalsIgnoreCase(primaryKey2)) {
1500 isDuplicate = true;
1501 break;
1502 }
1503 }
1504
1505 if (isDuplicate) {
1506 continue;
1507 }
1508
1509 //
1510 // It is legal for a module does not contains ANY pcd build definitions.
1511 //
1512 if (modules.get(index).module.getPcdBuildDefinition() == null) {
1513 continue;
1514 }
1515
1516 pcdBuildDataArray = modules.get(index).module.getPcdBuildDefinition().getPcdDataList();
1517
1518 moduleName = modules.get(index).module.getModuleName();
1519
1520 //
1521 // ----------------------------------------------------------------------
1522 // 2.1), Loop all Pcd entry for a module and add it into memory database.
1523 // ----------------------------------------------------------------------
1524 //
1525 for (pcdIndex = 0; pcdIndex < pcdBuildDataArray.size(); pcdIndex ++) {
1526 pcdBuildData = pcdBuildDataArray.get(pcdIndex);
1527 primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(),
1528 translateSchemaStringToUUID(pcdBuildData.getTokenSpaceGuid()));
1529 pcdType = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString());
1530 datumType = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString());
1531 tokenNumber = Integer.decode(pcdBuildData.getToken().toString());
1532 datum = pcdBuildData.getValue();
1533 maxDatumSize = pcdBuildData.getMaxDatumSize();
1534
1535 //
1536 // -------------------------------------------------------------------------------------------
1537 // 2.1.1), Do some necessary checking work for FixedAtBuild, FeatureFlag and PatchableInModule
1538 // -------------------------------------------------------------------------------------------
1539 //
1540 if (!Token.isDynamic(pcdType)) {
1541 //
1542 // Value is required.
1543 //
1544 if (datum == null) {
1545 exceptionString = String.format("There is no value for PCD entry %s in module %s!",
1546 pcdBuildData.getCName(),
1547 moduleName);
1548 throw new EntityException(exceptionString);
1549 }
1550
1551 //
1552 // Check whether the datum size is matched datum type.
1553 //
1554 if ((exceptionString = verifyDatumSize(pcdBuildData.getCName(),
1555 moduleName,
1556 maxDatumSize,
1557 datumType)) != null) {
1558 throw new EntityException(exceptionString);
1559 }
1560 }
1561
1562 //
1563 // ---------------------------------------------------------------------------------
1564 // 2.1.2), Create token or update token information for current anaylized PCD data.
1565 // ---------------------------------------------------------------------------------
1566 //
1567 if (dbManager.isTokenInDatabase(primaryKey)) {
1568 //
1569 // If the token is already exist in database, do some necessary checking
1570 // and add a usage instance into this token in database
1571 //
1572 token = dbManager.getTokenByKey(primaryKey);
1573
1574 //
1575 // checking for DatumType, DatumType should be unique for one PCD used in different
1576 // modules.
1577 //
1578 if (token.datumType != datumType) {
1579 exceptionString = String.format("The datum type of PCD entry %s is %s, which is different with %s defined in before!",
1580 pcdBuildData.getCName(),
1581 pcdBuildData.getDatumType().toString(),
1582 Token.getStringOfdatumType(token.datumType));
1583 throw new EntityException(exceptionString);
1584 }
1585
1586 //
1587 // Check token number is valid
1588 //
1589 if (tokenNumber != token.tokenNumber) {
1590 exceptionString = String.format("The token number of PCD entry %s in module %s is different with same PCD entry in other modules!",
1591 pcdBuildData.getCName(),
1592 moduleName);
1593 throw new EntityException(exceptionString);
1594 }
1595
1596 //
1597 // For same PCD used in different modules, the PCD type should all be dynamic or non-dynamic.
1598 //
1599 if (token.isDynamicPCD != Token.isDynamic(pcdType)) {
1600 exceptionString = String.format("For PCD entry %s in module %s, you define dynamic or non-dynamic PCD type which"+
1601 "is different with others module's",
1602 token.cName,
1603 moduleName);
1604 throw new EntityException(exceptionString);
1605 }
1606
1607 if (token.isDynamicPCD) {
1608 //
1609 // Check datum is equal the datum in dynamic information.
1610 // For dynamic PCD, you can do not write <Value> in sperated every <PcdBuildDefinition> in different <ModuleSA>,
1611 // But if you write, the <Value> must be same as the value in <DynamicPcdBuildDefinitions>.
1612 //
1613 if (!token.isSkuEnable() &&
1614 (token.skuData.get(0).value.type == DynamicTokenValue.VALUE_TYPE.DEFAULT_TYPE)) {
1615 if (!datum.equalsIgnoreCase(token.skuData.get(0).value.value)) {
1616 exceptionString = String.format("For dynamic PCD %s in module %s, the datum in <ModuleSA> is "+
1617 "not equal to the datum in <DynamicPcdBuildDefinitions>, it is "+
1618 "illega! You can choose no <Value> in <ModuleSA>!",
1619 token.cName,
1620 moduleName);
1621 }
1622 }
1623 }
1624
1625 } else {
1626 //
1627 // If the token is not in database, create a new token instance and add
1628 // a usage instance into this token in database.
1629 //
1630 token = new Token(pcdBuildData.getCName(),
1631 translateSchemaStringToUUID(pcdBuildData.getTokenSpaceGuid()));
1632
1633 token.datumType = datumType;
1634 token.tokenNumber = tokenNumber;
1635 token.isDynamicPCD = Token.isDynamic(pcdType);
1636 token.datumSize = maxDatumSize;
1637
1638 if (token.isDynamicPCD) {
1639 //
1640 // For Dynamic and Dynamic Ex type, need find the dynamic information
1641 // in <DynamicPcdBuildDefinition> section in FPD file.
1642 //
1643 updateDynamicInformation(moduleName,
1644 token,
1645 datum,
1646 maxDatumSize);
1647 }
1648
1649 dbManager.addTokenToDatabase(primaryKey, token);
1650 }
1651
1652 //
1653 // -----------------------------------------------------------------------------------
1654 // 2.1.3), Add the PcdType in current module into this Pcd token's supported PCD type.
1655 // -----------------------------------------------------------------------------------
1656 //
1657 token.updateSupportPcdType(pcdType);
1658
1659 //
1660 // ------------------------------------------------
1661 // 2.1.4), Create an usage instance for this token.
1662 // ------------------------------------------------
1663 //
1664 usageInstance = new UsageInstance(token,
1665 moduleName,
1666 translateSchemaStringToUUID(modules.get(index).module.getModuleGuid()),
1667 modules.get(index).module.getPackageName(),
1668 translateSchemaStringToUUID(modules.get(index).module.getPackageGuid()),
1669 modules.get(index).type,
1670 pcdType,
1671 modules.get(index).module.getArch().toString(),
1672 null,
1673 datum,
1674 maxDatumSize);
1675 token.addUsageInstance(usageInstance);
1676 }
1677 }
1678 }
1679
1680 /**
1681 Get dynamic information for a dynamic PCD from <DynamicPcdBuildDefinition> seciton in FPD file.
1682
1683 This function should be implemented in GlobalData in future.
1684
1685 @param token The token instance which has hold module's PCD information
1686 @param moduleName The name of module who will use this Dynamic PCD.
1687
1688 @return DynamicPcdBuildDefinitions.PcdBuildData
1689 */
1690 /***/
1691 private DynamicPcdBuildDefinitions.PcdBuildData getDynamicInfoFromFPD(Token token,
1692 String moduleName)
1693 throws EntityException {
1694 int index = 0;
1695 String exceptionString = null;
1696 String dynamicPrimaryKey = null;
1697 DynamicPcdBuildDefinitions dynamicPcdBuildDefinitions = null;
1698 List<DynamicPcdBuildDefinitions.PcdBuildData> dynamicPcdBuildDataArray = null;
1699
1700 //
1701 // If FPD document is not be opened, open and initialize it.
1702 //
1703 if (fpdDocInstance == null) {
1704 try {
1705 fpdDocInstance = (FrameworkPlatformDescriptionDocument)XmlObject.Factory.parse(new File(fpdFilePath));
1706 } catch(IOException ioE) {
1707 throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage());
1708 } catch(XmlException xmlE) {
1709 throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage());
1710 }
1711 }
1712
1713 dynamicPcdBuildDefinitions = fpdDocInstance.getFrameworkPlatformDescription().getDynamicPcdBuildDefinitions();
1714 if (dynamicPcdBuildDefinitions == null) {
1715 exceptionString = String.format("There are no <PcdDynamicBuildDescriptions> in FPD file but contains Dynamic type "+
1716 "PCD entry %s in module %s!",
1717 token.cName,
1718 moduleName);
1719 throw new EntityException(exceptionString);
1720 }
1721
1722 dynamicPcdBuildDataArray = dynamicPcdBuildDefinitions.getPcdBuildDataList();
1723 for (index = 0; index < dynamicPcdBuildDataArray.size(); index ++) {
1724 dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(),
1725 translateSchemaStringToUUID(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuid()));
1726 if (dynamicPrimaryKey.equalsIgnoreCase(token.getPrimaryKeyString())) {
1727 return dynamicPcdBuildDataArray.get(index);
1728 }
1729 }
1730
1731 return null;
1732 }
1733
1734 /**
1735 Verify the maxDatumSize for a PCD data is matched to Datum type.
1736
1737 @param token The token instance
1738 @param moduleName The module name who use this PCD data.
1739 @param maxDatumSize The value of max datum size in FPD file
1740 @param datumType The datum type
1741
1742 @return String if is unmatched, set the exception information
1743 as return value, otherwice is null.
1744 **/
1745 private String verifyDatumSize(String cName,
1746 String moduleName,
1747 int maxDatumSize,
1748 Token.DATUM_TYPE datumType) {
1749 String exceptionString = null;
1750 switch (datumType) {
1751 case UINT8:
1752 if (maxDatumSize != 1) {
1753 exceptionString = String.format("In FPD file, the datum type of PCD data %s in module %s "+
1754 "is UINT8, but datum size is %d, they are not matched!",
1755 cName,
1756 moduleName,
1757 maxDatumSize);
1758 }
1759 break;
1760 case UINT16:
1761 if (maxDatumSize != 2) {
1762 exceptionString = String.format("In FPD file, the datum type of PCD data %s in module %s "+
1763 "is UINT16, but datum size is %d, they are not matched!",
1764 cName,
1765 moduleName,
1766 maxDatumSize);
1767 }
1768 break;
1769 case UINT32:
1770 if (maxDatumSize != 4) {
1771 exceptionString = String.format("In FPD file, the datum type of PCD data %s in module %s "+
1772 "is UINT32, but datum size is %d, they are not matched!",
1773 cName,
1774 moduleName,
1775 maxDatumSize);
1776 }
1777 break;
1778 case UINT64:
1779 if (maxDatumSize != 8) {
1780 exceptionString = String.format("In FPD file, the datum type of PCD data %s in module %s "+
1781 "is UINT64, but datum size is %d, they are not matched!",
1782 cName,
1783 moduleName,
1784 maxDatumSize);
1785 }
1786 break;
1787 case BOOLEAN:
1788 if (maxDatumSize != 1) {
1789 exceptionString = String.format("In FPD file, the datum type of PCD data %s in module %s "+
1790 "is BOOLEAN, but datum size is %d, they are not matched!",
1791 cName,
1792 moduleName,
1793 maxDatumSize);
1794 }
1795 break;
1796 }
1797
1798 return exceptionString;
1799 }
1800
1801 /**
1802 Update dynamic information for PCD entry.
1803
1804 Dynamic information is retrieved from <PcdDynamicBuildDeclarations> in
1805 FPD file.
1806
1807 @param moduleName The name of the module who use this PCD
1808 @param token The token instance
1809 @param datum The <datum> in module's PCD information
1810 @param maxDatumSize The <maxDatumSize> in module's PCD information
1811
1812 @return Token
1813 */
1814 private Token updateDynamicInformation(String moduleName,
1815 Token token,
1816 String datum,
1817 int maxDatumSize)
1818 throws EntityException {
1819 int index = 0;
1820 int offset;
1821 String exceptionString = null;
1822 DynamicTokenValue dynamicValue;
1823 SkuInstance skuInstance = null;
1824 String temp;
1825 boolean hasSkuId0 = false;
1826
1827 List<DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> skuInfoList = null;
1828 DynamicPcdBuildDefinitions.PcdBuildData dynamicInfo = null;
1829
1830 dynamicInfo = getDynamicInfoFromFPD(token, moduleName);
1831 if (dynamicInfo == null) {
1832 exceptionString = String.format("For Dynamic PCD %s used by module %s, "+
1833 "there is no dynamic information in <DynamicPcdBuildDefinitions> "+
1834 "in FPD file, but it is required!",
1835 token.cName,
1836 moduleName);
1837 throw new EntityException(exceptionString);
1838 }
1839
1840 skuInfoList = dynamicInfo.getSkuInfoList();
1841
1842 //
1843 // Loop all sku data
1844 //
1845 for (index = 0; index < skuInfoList.size(); index ++) {
1846 skuInstance = new SkuInstance();
1847 //
1848 // Although SkuId in schema is BigInteger, but in fact, sku id is 32 bit value.
1849 //
1850 temp = skuInfoList.get(index).getSkuId().toString();
1851 skuInstance.id = Integer.decode(temp);
1852
1853 if (skuInstance.id == 0) {
1854 hasSkuId0 = true;
1855 }
1856 //
1857 // Judge whether is DefaultGroup at first, because most case is DefautlGroup.
1858 //
1859 if (skuInfoList.get(index).getValue() != null) {
1860 skuInstance.value.setValue(skuInfoList.get(index).getValue());
1861 token.skuData.add(skuInstance);
1862
1863 //
1864 // Judege wether is same of datum between module's information
1865 // and dynamic information.
1866 //
1867 if (datum != null) {
1868 if ((skuInstance.id == 0) &&
1869 !datum.equalsIgnoreCase(skuInfoList.get(index).getValue())) {
1870 exceptionString = String.format("For dynamic PCD %s, module %s give <datum> as %s which is different with "+
1871 "Sku 0's <datum> %s defined in <DynamicPcdBuildDefinitions>! Please sync them at first!",
1872 token.cName,
1873 datum,
1874 skuInfoList.get(index).getValue());
1875 throw new EntityException(exceptionString);
1876 }
1877 }
1878 continue;
1879 }
1880
1881 //
1882 // Judge whether is HII group case.
1883 //
1884 if (skuInfoList.get(index).getVariableName() != null) {
1885 exceptionString = null;
1886 if (skuInfoList.get(index).getVariableGuid() == null) {
1887 exceptionString = String.format("For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+
1888 "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",
1889 token.cName,
1890 index);
1891
1892 }
1893
1894 if (skuInfoList.get(index).getVariableOffset() == null) {
1895 exceptionString = String.format("For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+
1896 "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",
1897 token.cName,
1898 index);
1899 }
1900
1901 if (skuInfoList.get(index).getHiiDefaultValue() == null) {
1902 exceptionString = String.format("For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+
1903 "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",
1904 token.cName,
1905 index);
1906 }
1907
1908 if (exceptionString != null) {
1909 throw new EntityException(exceptionString);
1910 }
1911 offset = Integer.decode(skuInfoList.get(index).getVariableOffset());
1912 if (offset > 0xFFFF) {
1913 throw new EntityException(String.format("For dynamic PCD %s , the variable offset defined in sku %d data "+
1914 "exceed 64K, it is not allowed!",
1915 token.cName,
1916 index));
1917 }
1918
1919 skuInstance.value.setHiiData(skuInfoList.get(index).getVariableName(),
1920 translateSchemaStringToUUID(skuInfoList.get(index).getVariableGuid().toString()),
1921 skuInfoList.get(index).getVariableOffset(),
1922 skuInfoList.get(index).getHiiDefaultValue());
1923 token.skuData.add(skuInstance);
1924 continue;
1925 }
1926
1927 if (skuInfoList.get(index).getVpdOffset() != null) {
1928 skuInstance.value.setVpdData(skuInfoList.get(index).getVpdOffset());
1929 token.skuData.add(skuInstance);
1930 continue;
1931 }
1932
1933 exceptionString = String.format("For dynamic PCD %s, the dynamic info must "+
1934 "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.",
1935 token.cName);
1936 throw new EntityException(exceptionString);
1937 }
1938
1939 if (!hasSkuId0) {
1940 exceptionString = String.format("For dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+
1941 "no sku id = 0 data, which is required for every dynamic PCD",
1942 token.cName);
1943 }
1944
1945 return token;
1946 }
1947
1948 /**
1949 Translate the schema string to UUID instance.
1950
1951 In schema, the string of UUID is defined as following two types string:
1952 1) GuidArrayType: pattern = 0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},(
1953 )*0x[a-fA-F0-9]{1,4}(,( )*\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\})?
1954
1955 2) GuidNamingConvention: pattern =
1956 [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}
1957
1958 This function will convert string and create uuid instance.
1959
1960 @param uuidString UUID string in XML file
1961
1962 @return UUID UUID instance
1963 **/
1964 private UUID translateSchemaStringToUUID(String uuidString)
1965 throws EntityException {
1966 String temp;
1967 String[] splitStringArray;
1968 int index;
1969 int chIndex;
1970 int chLen;
1971
1972 if (uuidString == null) {
1973 return null;
1974 }
1975
1976 if (uuidString.length() == 0) {
1977 return null;
1978 }
1979
1980 if (uuidString.equals("0") ||
1981 uuidString.equalsIgnoreCase("0x0")) {
1982 return new UUID(0, 0);
1983 }
1984
1985 //
1986 // If the UUID schema string is GuidArrayType type then need translate
1987 // to GuidNamingConvention type at first.
1988 //
1989 if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) {
1990 splitStringArray = uuidString.split("," );
1991 if (splitStringArray.length != 11) {
1992 throw new EntityException ("Wrong format for UUID string: " + uuidString);
1993 }
1994
1995 //
1996 // Remove blank space from these string and remove header string "0x"
1997 //
1998 for (index = 0; index < 11; index ++) {
1999 splitStringArray[index] = splitStringArray[index].trim();
2000 splitStringArray[index] = splitStringArray[index].substring(2, splitStringArray[index].length());
2001 }
2002
2003 //
2004 // Add heading '0' to normalize the string length
2005 //
2006 for (index = 3; index < 11; index ++) {
2007 chLen = splitStringArray[index].length();
2008 for (chIndex = 0; chIndex < 2 - chLen; chIndex ++) {
2009 splitStringArray[index] = "0" + splitStringArray[index];
2010 }
2011 }
2012
2013 //
2014 // construct the final GuidNamingConvention string
2015 //
2016 temp = String.format("%s-%s-%s-%s%s-%s%s%s%s%s%s",
2017 splitStringArray[0],
2018 splitStringArray[1],
2019 splitStringArray[2],
2020 splitStringArray[3],
2021 splitStringArray[4],
2022 splitStringArray[5],
2023 splitStringArray[6],
2024 splitStringArray[7],
2025 splitStringArray[8],
2026 splitStringArray[9],
2027 splitStringArray[10]);
2028 uuidString = temp;
2029 }
2030
2031 return UUID.fromString(uuidString);
2032 }
2033
2034 /**
2035 check parameter for this action.
2036
2037 @throws EntityException Bad parameter.
2038 **/
2039 private void checkParameter() throws EntityException {
2040 File file = null;
2041
2042 if((fpdFilePath == null) ||(workspacePath == null)) {
2043 throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
2044 }
2045
2046 if(fpdFilePath.length() == 0 || workspacePath.length() == 0) {
2047 throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
2048 }
2049
2050 file = new File(workspacePath);
2051 if(!file.exists()) {
2052 throw new EntityException("WorkpacePath " + workspacePath + " does not exist!");
2053 }
2054
2055 file = new File(fpdFilePath);
2056
2057 if(!file.exists()) {
2058 throw new EntityException("FPD File " + fpdFilePath + " does not exist!");
2059 }
2060 }
2061
2062 /**
2063 Test case function
2064
2065 @param argv parameter from command line
2066 **/
2067 public static void main(String argv[]) throws EntityException {
2068 CollectPCDAction ca = new CollectPCDAction();
2069 ca.setWorkspacePath("m:/tianocore/edk2");
2070 ca.setFPDFilePath("m:/tianocore/edk2/EdkNt32Pkg/Nt32.fpd");
2071 ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);
2072 GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
2073 "m:/tianocore/edk2");
2074 ca.execute();
2075 }
2076 }