diff options
author | klu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-06-20 17:10:21 +0000 |
---|---|---|
committer | klu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-06-20 17:10:21 +0000 |
commit | 11e7b0f6dd28d03942494d3e18842d31421a9842 (patch) | |
tree | 25c8e73be0420e7151121eb372e3363679983250 /Tools | |
parent | b9546cc80d2ebe1a4754d98c35c5b7b15f94556d (diff) | |
download | edk2-platforms-11e7b0f6dd28d03942494d3e18842d31421a9842.tar.xz |
Modify autogen code for DynamicEx type PCD.
1) Roll back PcdSetEx/PcdGetEx macro, module developer must input the token space guid explicitly, because in a module maybe two PCD with same CName and token number but in different token space guid.
2) Modify the generated value for _PCD_MODE_xxx for DynamicEx PCD. This macro will be mapped to PcdLibSetEx/PcdLibGetEx directly, and the parameter of token space guid is auto generated.
3) For token space guid array variable autogened, only one copy will be exists in a module's autogen C file for different PCD which are in same token space guid.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@575 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java | 77 | ||||
-rw-r--r-- | Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java | 28 |
2 files changed, 69 insertions, 36 deletions
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java index 796aff62c3..dd33b540c1 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java @@ -17,11 +17,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. package org.tianocore.build.pcd.action;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.xmlbeans.XmlObject;
import org.tianocore.build.global.GlobalData;
@@ -252,6 +254,10 @@ public class PCDAutoGenAction extends BuildAction { {
int index, index2;
List<UsageInstance> usageInstanceArray, usageContext;
+ String[] guidStringArray = null;
+ String guidStringCName = null;
+ String guidString = null;
+ UsageInstance usageInstance = null;
if (!isBuildUsedLibrary) {
usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleName,
@@ -295,7 +301,6 @@ public class PCDAutoGenAction extends BuildAction { }
}
-
if(usageInstanceArray.size() != 0) {
//
// Add "#include 'PcdLib.h'" for Header file
@@ -303,16 +308,63 @@ public class PCDAutoGenAction extends BuildAction { hAutoGenString = "#include <MdePkg/Include/Library/PcdLib.h>\r\n";
}
+ //
+ // Generate all PCD entry for a module.
+ //
for(index = 0; index < usageInstanceArray.size(); index ++) {
ActionMessage.debug(this,
"Module " + moduleName + "'s PCD [" + Integer.toHexString(index) +
"]: " + usageInstanceArray.get(index).parentToken.cName);
try {
- usageInstanceArray.get(index).generateAutoGen(isBuildUsedLibrary);
- hAutoGenString += usageInstanceArray.get(index).getHAutogenStr() + "\r\n";
- cAutoGenString += usageInstanceArray.get(index).getCAutogenStr() + "\r\n";
+ usageInstance = usageInstanceArray.get(index);
+ //
+ // Before generate any PCD information into autogen.h/autogen.c for a module,
+ // generate TokenSpaceGuid array variable firstly. For every dynamicEx type
+ // PCD in this module the token, they are all reference to TokenSpaceGuid
+ // array.
+ //
+ if (usageInstanceArray.get(index).modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {
+ guidStringArray = usageInstance.parentToken.tokenSpaceName.toString().split("-");
+ guidStringCName = "_gPcd_TokenSpaceGuid_" +
+ usageInstance.parentToken.tokenSpaceName.toString().replaceAll("-", "_");
+ guidString = String.format("{ 0x%s, 0x%s, 0x%s, {0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s}}",
+ guidStringArray[0],
+ guidStringArray[1],
+ guidStringArray[2],
+ (guidStringArray[3].substring(0, 2)),
+ (guidStringArray[3].substring(2, 4)),
+ (guidStringArray[4].substring(0, 2)),
+ (guidStringArray[4].substring(2, 4)),
+ (guidStringArray[4].substring(4, 6)),
+ (guidStringArray[4].substring(6, 8)),
+ (guidStringArray[4].substring(8, 10)),
+ (guidStringArray[4].substring(10, 12)));
+ if (!isBuildUsedLibrary) {
+ Pattern pattern = Pattern.compile("(" + guidStringCName + ")+?");
+ Matcher matcher = pattern.matcher(cAutoGenString + " ");
+ //
+ // Find whether this guid array variable has been generated into autogen.c
+ // For different DyanmicEx pcd token who use same token space guid, the token space
+ // guid array should be only generated once.
+ //
+ if (!matcher.find()) {
+ cAutoGenString += String.format("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID %s = %s;\r\n",
+ guidStringCName,
+ guidString);
+ }
+ }
+ }
+
+ usageInstance.generateAutoGen(isBuildUsedLibrary);
+ //
+ // For every PCD entry for this module(usage instance), autogen string would
+ // be appand.
+ //
+ hAutoGenString += usageInstance.getHAutogenStr() + "\r\n";
+ cAutoGenString += usageInstance.getCAutogenStr();
+
} catch(EntityException exp) {
- throw new BuildActionException(exp.getMessage());
+ throw new BuildActionException("[PCD Autogen Error]: " + exp.getMessage());
}
}
@@ -343,8 +395,8 @@ public class PCDAutoGenAction extends BuildAction { **/
public static void main(String argv[]) {
- String WorkSpace = "M:/ForPcd/edk2";
- String logFilePath = WorkSpace + "/MdePkg/MdePkg.fpd";
+ String WorkSpace = "M:/tianocore/edk2";
+ String logFilePath = WorkSpace + "/EdkNt32Pkg/Nt32.fpd";
String[] nameArray = null;
//
@@ -366,11 +418,11 @@ public class PCDAutoGenAction extends BuildAction { //
// Then execute the PCDAuotoGenAction to get generated Autogen.h and Autogen.c
//
- PCDAutoGenAction autogenAction = new PCDAutoGenAction("BaseLib",
- null,
+ PCDAutoGenAction autogenAction = new PCDAutoGenAction("MonoStatusCode",
null,
null,
null,
+ "IA32",
null,
false,
nameArray);
@@ -379,10 +431,5 @@ public class PCDAutoGenAction extends BuildAction { System.out.println(autogenAction.OutputH());
System.out.println("WQWQWQWQWQ");
System.out.println(autogenAction.OutputC());
-
-
- System.out.println (autogenAction.hAutoGenString);
- System.out.println (autogenAction.cAutoGenString);
-
}
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java index 1a843968df..cfbdb1e149 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java @@ -201,8 +201,7 @@ public class UsageInstance { */
public void generateAutoGen(boolean isBuildUsedLibrary)
throws EntityException {
- String guidStringArray[] = null;
- String guidString = null;
+ String guidStringCName = null;
boolean isByteArray = false;
String printDatum = null;
@@ -210,8 +209,6 @@ public class UsageInstance { cAutogenStr = "";
if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {
- hAutogenStr += String.format("#define _PCD_LOCAL_TOKEN_%s 0x%016x\r\n",
- parentToken.cName, parentToken.tokenNumber);
hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%016x\r\n",
parentToken.cName, parentToken.dynamicExTokenNumber);
} else {
@@ -340,23 +337,12 @@ public class UsageInstance { parentToken.cName);
break;
case DYNAMIC_EX:
- guidStringArray = parentToken.tokenSpaceName.toString().split("-");
- guidString = String.format("{ 0x%s, 0x%s, 0x%s, {0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s}}",
- guidStringArray[0],
- guidStringArray[1],
- guidStringArray[2],
- (guidStringArray[3].substring(0, 2)),
- (guidStringArray[3].substring(2, 4)),
- (guidStringArray[4].substring(0, 2)),
- (guidStringArray[4].substring(2, 4)),
- (guidStringArray[4].substring(4, 6)),
- (guidStringArray[4].substring(6, 8)),
- (guidStringArray[4].substring(8, 10)),
- (guidStringArray[4].substring(10, 12)));
+ guidStringCName = "_gPcd_TokenSpaceGuid_" +
+ parentToken.tokenSpaceName.toString().replaceAll("-", "_");
- hAutogenStr += String.format("extern EFI_GUID _gPcd_DynamicEx_TokenSpaceGuid_%s;\r\n",
+ hAutogenStr += String.format("extern const EFI_GUID *_gPcd_DynamicEx_TokenSpaceGuid_%s;\r\n",
parentToken.cName);
- hAutogenStr += String.format("#define _PCD_MODE_%s_%s LibPcdGet%s(_PCD_LOCAL_TOKEN_%s)\r\n",
+ hAutogenStr += String.format("#define _PCD_MODE_%s_%s LibPcdGetEx%s(_gPcd_DynamicEx_TokenSpaceGuid_%s, _PCD_TOKEN_%s)\r\n",
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
parentToken.cName,
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),
@@ -364,9 +350,9 @@ public class UsageInstance { parentToken.cName);
if (!isBuildUsedLibrary) {
- cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID _gPcd_DynamicEx_TokenSpaceGuid_%s = %s;\r\n",
+ cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID *_gPcd_DynamicEx_TokenSpaceGuid_%s = &%s;\r\n",
parentToken.cName,
- guidString);
+ guidStringCName);
}
break;
}
|