mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-24 22:24:37 +02:00
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
This commit is contained in:
parent
b9546cc80d
commit
11e7b0f6dd
@ -77,12 +77,12 @@ Module Name: PcdLib.h
|
|||||||
//
|
//
|
||||||
// Dynamic Ex is to support binary distribution
|
// Dynamic Ex is to support binary distribution
|
||||||
//
|
//
|
||||||
#define PcdGetEx8(TokenName) LibPcdGetEx8 (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName)
|
#define PcdGetEx8(Guid, TokenName) LibPcdGetEx8 (Guid, _PCD_TOKEN_##TokenName)
|
||||||
#define PcdGetEx16(TokenName) LibPcdGetEx16 (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName)
|
#define PcdGetEx16(Guid, TokenName) LibPcdGetEx16 (Guid, _PCD_TOKEN_##TokenName)
|
||||||
#define PcdGetEx32(TokenName) LibPcdGetEx32 (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName)
|
#define PcdGetEx32(Guid, TokenName) LibPcdGetEx32 (Guid, _PCD_TOKEN_##TokenName)
|
||||||
#define PcdGetEx64(TokenName) LibPcdGetEx64 (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName)
|
#define PcdGetEx64(Guid, TokenName) LibPcdGetEx64 (Guid, _PCD_TOKEN_##TokenName)
|
||||||
#define PcdGetExPtr(TokenName) LibPcdGetExPtr (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName)
|
#define PcdGetExPtr(Guid, TokenName) LibPcdGetExPtr (Guid, _PCD_TOKEN_##TokenName)
|
||||||
#define PcdGetExBool(TokenName) LibPcdGetExBool (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName)
|
#define PcdGetExBool(Guid, TokenName) LibPcdGetExBool (Guid, _PCD_TOKEN_##TokenName)
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -99,12 +99,12 @@ Module Name: PcdLib.h
|
|||||||
//
|
//
|
||||||
// Dynamic Set Ex
|
// Dynamic Set Ex
|
||||||
//
|
//
|
||||||
#define PcdSetEx8(TokenName, Value) LibPcdSetEx8 (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName, Value)
|
#define PcdSetEx8(Guid, TokenName, Value) LibPcdSetEx8 (Guid, _PCD_TOKEN_##TokenName, Value)
|
||||||
#define PcdSetEx16(TokenName, Value) LibPcdSetEx16 (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName, Value)
|
#define PcdSetEx16(Guid, TokenName, Value) LibPcdSetEx16 (Guid, _PCD_TOKEN_##TokenName, Value)
|
||||||
#define PcdSetEx32(TokenName, Value) LibPcdSetEx32 (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName, Value)
|
#define PcdSetEx32(Guid, TokenName, Value) LibPcdSetEx32 (Guid, _PCD_TOKEN_##TokenName, Value)
|
||||||
#define PcdSetEx64(TokenName, Value) LibPcdSetEx64 (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName, Value)
|
#define PcdSetEx64(Guid, TokenName, Value) LibPcdSetEx64 (Guid, _PCD_TOKEN_##TokenName, Value)
|
||||||
#define PcdSetExPtr(TokenName, SizeOfBuffer, Buffer) LibPcdSetExPtr (&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName, SizeOfBuffer, Buffer)
|
#define PcdSetExPtr(Guid, TokenName, SizeOfBuffer, Buffer) LibPcdSetExPtr (Guid, _PCD_TOKEN_##TokenName, SizeOfBuffer, Buffer)
|
||||||
#define PcdSetExBool(TokenName, Value) LibPcdSetExBool(&_gPcd_DynamicEx_TokenSpaceGuid_##TokenName, _PCD_TOKEN_##TokenName, Value)
|
#define PcdSetExBool(Guid, TokenName, Value) LibPcdSetExBool(Guid, _PCD_TOKEN_##TokenName, Value)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,11 +17,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
package org.tianocore.build.pcd.action;
|
package org.tianocore.build.pcd.action;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
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.apache.xmlbeans.XmlObject;
|
||||||
import org.tianocore.build.global.GlobalData;
|
import org.tianocore.build.global.GlobalData;
|
||||||
@ -252,6 +254,10 @@ public class PCDAutoGenAction extends BuildAction {
|
|||||||
{
|
{
|
||||||
int index, index2;
|
int index, index2;
|
||||||
List<UsageInstance> usageInstanceArray, usageContext;
|
List<UsageInstance> usageInstanceArray, usageContext;
|
||||||
|
String[] guidStringArray = null;
|
||||||
|
String guidStringCName = null;
|
||||||
|
String guidString = null;
|
||||||
|
UsageInstance usageInstance = null;
|
||||||
|
|
||||||
if (!isBuildUsedLibrary) {
|
if (!isBuildUsedLibrary) {
|
||||||
usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleName,
|
usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleName,
|
||||||
@ -295,7 +301,6 @@ public class PCDAutoGenAction extends BuildAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(usageInstanceArray.size() != 0) {
|
if(usageInstanceArray.size() != 0) {
|
||||||
//
|
//
|
||||||
// Add "#include 'PcdLib.h'" for Header file
|
// 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";
|
hAutoGenString = "#include <MdePkg/Include/Library/PcdLib.h>\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Generate all PCD entry for a module.
|
||||||
|
//
|
||||||
for(index = 0; index < usageInstanceArray.size(); index ++) {
|
for(index = 0; index < usageInstanceArray.size(); index ++) {
|
||||||
ActionMessage.debug(this,
|
ActionMessage.debug(this,
|
||||||
"Module " + moduleName + "'s PCD [" + Integer.toHexString(index) +
|
"Module " + moduleName + "'s PCD [" + Integer.toHexString(index) +
|
||||||
"]: " + usageInstanceArray.get(index).parentToken.cName);
|
"]: " + usageInstanceArray.get(index).parentToken.cName);
|
||||||
try {
|
try {
|
||||||
usageInstanceArray.get(index).generateAutoGen(isBuildUsedLibrary);
|
usageInstance = usageInstanceArray.get(index);
|
||||||
hAutoGenString += usageInstanceArray.get(index).getHAutogenStr() + "\r\n";
|
//
|
||||||
cAutoGenString += usageInstanceArray.get(index).getCAutogenStr() + "\r\n";
|
// 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) {
|
} 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[]) {
|
public static void main(String argv[]) {
|
||||||
|
|
||||||
String WorkSpace = "M:/ForPcd/edk2";
|
String WorkSpace = "M:/tianocore/edk2";
|
||||||
String logFilePath = WorkSpace + "/MdePkg/MdePkg.fpd";
|
String logFilePath = WorkSpace + "/EdkNt32Pkg/Nt32.fpd";
|
||||||
String[] nameArray = null;
|
String[] nameArray = null;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -366,11 +418,11 @@ public class PCDAutoGenAction extends BuildAction {
|
|||||||
//
|
//
|
||||||
// Then execute the PCDAuotoGenAction to get generated Autogen.h and Autogen.c
|
// Then execute the PCDAuotoGenAction to get generated Autogen.h and Autogen.c
|
||||||
//
|
//
|
||||||
PCDAutoGenAction autogenAction = new PCDAutoGenAction("BaseLib",
|
PCDAutoGenAction autogenAction = new PCDAutoGenAction("MonoStatusCode",
|
||||||
null,
|
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
"IA32",
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
nameArray);
|
nameArray);
|
||||||
@ -379,10 +431,5 @@ public class PCDAutoGenAction extends BuildAction {
|
|||||||
System.out.println(autogenAction.OutputH());
|
System.out.println(autogenAction.OutputH());
|
||||||
System.out.println("WQWQWQWQWQ");
|
System.out.println("WQWQWQWQWQ");
|
||||||
System.out.println(autogenAction.OutputC());
|
System.out.println(autogenAction.OutputC());
|
||||||
|
|
||||||
|
|
||||||
System.out.println (autogenAction.hAutoGenString);
|
|
||||||
System.out.println (autogenAction.cAutoGenString);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,8 +201,7 @@ public class UsageInstance {
|
|||||||
*/
|
*/
|
||||||
public void generateAutoGen(boolean isBuildUsedLibrary)
|
public void generateAutoGen(boolean isBuildUsedLibrary)
|
||||||
throws EntityException {
|
throws EntityException {
|
||||||
String guidStringArray[] = null;
|
String guidStringCName = null;
|
||||||
String guidString = null;
|
|
||||||
boolean isByteArray = false;
|
boolean isByteArray = false;
|
||||||
String printDatum = null;
|
String printDatum = null;
|
||||||
|
|
||||||
@ -210,8 +209,6 @@ public class UsageInstance {
|
|||||||
cAutogenStr = "";
|
cAutogenStr = "";
|
||||||
|
|
||||||
if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {
|
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",
|
hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%016x\r\n",
|
||||||
parentToken.cName, parentToken.dynamicExTokenNumber);
|
parentToken.cName, parentToken.dynamicExTokenNumber);
|
||||||
} else {
|
} else {
|
||||||
@ -340,23 +337,12 @@ public class UsageInstance {
|
|||||||
parentToken.cName);
|
parentToken.cName);
|
||||||
break;
|
break;
|
||||||
case DYNAMIC_EX:
|
case DYNAMIC_EX:
|
||||||
guidStringArray = parentToken.tokenSpaceName.toString().split("-");
|
guidStringCName = "_gPcd_TokenSpaceGuid_" +
|
||||||
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}}",
|
parentToken.tokenSpaceName.toString().replaceAll("-", "_");
|
||||||
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)));
|
|
||||||
|
|
||||||
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);
|
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),
|
Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
|
||||||
parentToken.cName,
|
parentToken.cName,
|
||||||
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),
|
Token.getAutogenLibrarydatumTypeString(parentToken.datumType),
|
||||||
@ -364,9 +350,9 @@ public class UsageInstance {
|
|||||||
parentToken.cName);
|
parentToken.cName);
|
||||||
|
|
||||||
if (!isBuildUsedLibrary) {
|
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,
|
parentToken.cName,
|
||||||
guidString);
|
guidStringCName);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user