Fix the bug that using hardcode driver name to judge whether current driver is PCD driver.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1281 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -88,6 +88,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->
|
||||
</GuidCNames>
|
||||
</Guids>
|
||||
<Externs>
|
||||
<PcdIsDriver>DXE_PCD_DRIVER</PcdIsDriver>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
<Extern>
|
||||
|
@@ -85,6 +85,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->
|
||||
</GuidCNames>
|
||||
</Guids>
|
||||
<Externs>
|
||||
<PcdIsDriver>PEI_PCD_DRIVER</PcdIsDriver>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
<Extern>
|
||||
|
@@ -52,46 +52,53 @@ import org.tianocore.common.logger.EdkLog;
|
||||
* area or library surface area.
|
||||
*/
|
||||
public class AutoGen {
|
||||
// /
|
||||
// / The output path of Autogen.h and Autogen.c
|
||||
// /
|
||||
///
|
||||
/// The output path of Autogen.h and Autogen.c
|
||||
///
|
||||
private String outputPath;
|
||||
|
||||
///
|
||||
/// The name of FV directory
|
||||
///
|
||||
private String fvDir;
|
||||
// /
|
||||
// / The base name of module or library.
|
||||
// /
|
||||
|
||||
///
|
||||
/// The base name of module or library.
|
||||
///
|
||||
private ModuleIdentification moduleId;
|
||||
|
||||
// /
|
||||
// / The build architecture
|
||||
// /
|
||||
///
|
||||
/// The build architecture
|
||||
///
|
||||
private String arch;
|
||||
|
||||
// /
|
||||
// / PcdAutogen instance which is used to manage how to generate the PCD
|
||||
// / information.
|
||||
// /
|
||||
///
|
||||
/// PcdAutogen instance which is used to manage how to generate the PCD
|
||||
/// information.
|
||||
///
|
||||
private PCDAutoGenAction myPcdAutogen;
|
||||
|
||||
// /
|
||||
// / The protocl list which records in module or library surface area and
|
||||
// / it's dependence on library instance surface area.
|
||||
// /
|
||||
///
|
||||
/// the one of type : NOT_PCD_DRIVER, PEI_PCD_DRIVER, DXE_PCD_DRIVER
|
||||
///
|
||||
private CommonDefinition.PCD_DRIVER_TYPE pcdDriverType;
|
||||
|
||||
///
|
||||
/// The protocl list which records in module or library surface area and
|
||||
/// it's dependence on library instance surface area.
|
||||
///
|
||||
private Set<String> mProtocolList = new HashSet<String>();
|
||||
|
||||
// /
|
||||
// / The Ppi list which recorded in module or library surface area and its
|
||||
// / dependency on library instance surface area.
|
||||
// /
|
||||
///
|
||||
/// The Ppi list which recorded in module or library surface area and its
|
||||
/// dependency on library instance surface area.
|
||||
///
|
||||
private Set<String> mPpiList = new HashSet<String>();
|
||||
|
||||
// /
|
||||
// / The Guid list which recoreded in module or library surface area and it's
|
||||
// / dependence on library instance surface area.
|
||||
// /
|
||||
///
|
||||
/// The Guid list which recoreded in module or library surface area and it's
|
||||
/// dependence on library instance surface area.
|
||||
///
|
||||
private Set<String> mGuidList = new HashSet<String>();
|
||||
|
||||
//
|
||||
@@ -419,6 +426,7 @@ public class AutoGen {
|
||||
String[] entryPointList = SurfaceAreaQuery.getModuleEntryPointArray();
|
||||
EntryPointToAutoGen(CommonDefinition.remDupString(entryPointList), fileBuffer);
|
||||
|
||||
pcdDriverType = SurfaceAreaQuery.getPcdDriverType();
|
||||
|
||||
//
|
||||
// Restore the DOC which include the FPD module info.
|
||||
@@ -458,8 +466,8 @@ public class AutoGen {
|
||||
// Get module dependent Package identification.
|
||||
//
|
||||
PackageIdentification[] packages = SurfaceAreaQuery.getDependencePkg(this.arch);
|
||||
for (int i = 0; i < packages.length; i++){
|
||||
if (!this.mDepPkgList.contains(packages[i])){
|
||||
for (int i = 0; i < packages.length; i++) {
|
||||
if (!this.mDepPkgList.contains(packages[i])) {
|
||||
this.mDepPkgList.add(packages[i]);
|
||||
}
|
||||
|
||||
@@ -475,7 +483,11 @@ public class AutoGen {
|
||||
//
|
||||
// Call pcd autogen.
|
||||
//
|
||||
this.myPcdAutogen = new PCDAutoGenAction(moduleId, this.arch, false, null);
|
||||
this.myPcdAutogen = new PCDAutoGenAction(moduleId,
|
||||
arch,
|
||||
false,
|
||||
null,
|
||||
pcdDriverType);
|
||||
try {
|
||||
this.myPcdAutogen.execute();
|
||||
} catch (Exception exp) {
|
||||
@@ -625,10 +637,11 @@ public class AutoGen {
|
||||
//
|
||||
// Call pcd autogen.
|
||||
//
|
||||
this.myPcdAutogen = new PCDAutoGenAction(this.moduleId,
|
||||
this.arch,
|
||||
this.myPcdAutogen = new PCDAutoGenAction(moduleId,
|
||||
arch,
|
||||
true,
|
||||
SurfaceAreaQuery.getModulePcdEntryNameArray());
|
||||
SurfaceAreaQuery.getModulePcdEntryNameArray(),
|
||||
pcdDriverType);
|
||||
try {
|
||||
this.myPcdAutogen.execute();
|
||||
} catch (Exception e) {
|
||||
@@ -876,7 +889,7 @@ public class AutoGen {
|
||||
// If entryPoint is null, create an empty ProcessModuleEntryPointList
|
||||
// function.
|
||||
//
|
||||
if (entryPointList == null || entryPointList.length == 0){
|
||||
if (entryPointList == null || entryPointList.length == 0) {
|
||||
fileBuffer
|
||||
.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
|
||||
fileBuffer.append(Integer.toString(entryPointCount));
|
||||
@@ -992,11 +1005,11 @@ public class AutoGen {
|
||||
fileBuffer.append(" EFI_STATUS Status;\r\n\r\n");
|
||||
fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n");
|
||||
for (int i = 0; i < entryPointList.length; i++) {
|
||||
if (i == 0){
|
||||
if (i == 0) {
|
||||
fileBuffer.append(" Status = ");
|
||||
fileBuffer.append(entryPointList[i]);
|
||||
fileBuffer.append("(ImageHandle);\r\n");
|
||||
}else{
|
||||
} else {
|
||||
fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
|
||||
fileBuffer.append(" ");
|
||||
fileBuffer.append(entryPointList[i]);
|
||||
@@ -1023,7 +1036,7 @@ public class AutoGen {
|
||||
//
|
||||
// If entry point is null, create a empty ProcessModuleEntryPointList function.
|
||||
//
|
||||
if (entryPointList == null || entryPointList.length == 0){
|
||||
if (entryPointList == null || entryPointList.length == 0) {
|
||||
fileBuffer
|
||||
.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
|
||||
fileBuffer.append("EFI_STATUS\r\n");
|
||||
@@ -1036,7 +1049,7 @@ public class AutoGen {
|
||||
fileBuffer.append(" return EFI_SUCCESS;\r\n");
|
||||
fileBuffer.append("}\r\n");
|
||||
|
||||
}else {
|
||||
} else {
|
||||
for (int i = 0; i < entryPointList.length; i++) {
|
||||
|
||||
fileBuffer.append("EFI_STATUS\r\n");
|
||||
@@ -1164,7 +1177,7 @@ public class AutoGen {
|
||||
fileBuffer.append(" Status = ");
|
||||
fileBuffer.append(entryPointList[i]);
|
||||
fileBuffer.append("(ImageHandle);\r\n");
|
||||
}else{
|
||||
} else {
|
||||
fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
|
||||
fileBuffer.append(" ");
|
||||
fileBuffer.append(entryPointList[i]);
|
||||
@@ -1977,7 +1990,7 @@ public class AutoGen {
|
||||
// do nothing.
|
||||
//
|
||||
if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) {
|
||||
try{
|
||||
try {
|
||||
if (inFile.exists()) {
|
||||
FileInputStream fis = new FileInputStream (inFile);
|
||||
fis.read(buffer);
|
||||
@@ -1985,10 +1998,10 @@ public class AutoGen {
|
||||
fos.write(buffer);
|
||||
fis.close();
|
||||
fos.close();
|
||||
}else {
|
||||
} else {
|
||||
throw new AutoGenException("The file, flashMap.h doesn't exist!");
|
||||
}
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
throw new AutoGenException(e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -2079,8 +2092,8 @@ public class AutoGen {
|
||||
for (index = 0; index < guidList.length; index++) {
|
||||
this.mGuidList.add(guidList[index]);
|
||||
}
|
||||
for (index = 0; index < pkgList.length; index++){
|
||||
if (!this.mDepPkgList.contains(pkgList[index])){
|
||||
for (index = 0; index < pkgList.length; index++) {
|
||||
if (!this.mDepPkgList.contains(pkgList[index])) {
|
||||
this.mDepPkgList.add(pkgList[index]);
|
||||
}
|
||||
}
|
||||
@@ -2128,9 +2141,9 @@ public class AutoGen {
|
||||
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
System.out.println("Collect library instance failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -59,6 +59,15 @@ public class CommonDefinition {
|
||||
public final static String tianoR8FlashMapH = "TianoR8FlashMap.h";
|
||||
public final static String flashMapH = "FlashMap.h";
|
||||
|
||||
//
|
||||
// The defintions for identifying current module
|
||||
// is PEI Pcd driver or Dxe Pcd driver.
|
||||
//
|
||||
public static enum PCD_DRIVER_TYPE { NOT_PCD_DRIVER,
|
||||
PEI_PCD_DRIVER,
|
||||
DXE_PCD_DRIVER,
|
||||
UNKNOWN_PCD_DRIVER};
|
||||
|
||||
//
|
||||
// AutoGen.h and AutoGen.c file's header
|
||||
//
|
||||
@@ -162,7 +171,7 @@ public class CommonDefinition {
|
||||
new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver),
|
||||
new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),
|
||||
new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),
|
||||
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) };
|
||||
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication)};
|
||||
|
||||
//
|
||||
// Component type
|
||||
@@ -335,16 +344,16 @@ public class CommonDefinition {
|
||||
public static String[] remDupString (String[] orgList){
|
||||
Set<String> strList = new LinkedHashSet<String>();
|
||||
String[] desList ;
|
||||
if (orgList == null){
|
||||
if (orgList == null) {
|
||||
return new String[0];
|
||||
}
|
||||
for (int i = 0; i < orgList.length; i++){
|
||||
for (int i = 0; i < orgList.length; i++) {
|
||||
strList.add(orgList[i]);
|
||||
}
|
||||
desList = new String[strList.size()];
|
||||
Iterator item = strList.iterator();
|
||||
int index = 0;
|
||||
while (item.hasNext()){
|
||||
while (item.hasNext()) {
|
||||
desList[index] = (String)item.next();
|
||||
index++;
|
||||
}
|
||||
|
@@ -60,6 +60,7 @@ import org.tianocore.FilenameDocument.Filename;
|
||||
import org.tianocore.MsaHeaderDocument.MsaHeader;
|
||||
import org.tianocore.ProtocolsDocument.Protocols.Protocol;
|
||||
import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;
|
||||
import org.tianocore.PcdDriverTypes;
|
||||
|
||||
import org.tianocore.common.logger.EdkLog;
|
||||
import org.tianocore.build.id.FpdModuleIdentification;
|
||||
@@ -67,6 +68,7 @@ import org.tianocore.build.id.ModuleIdentification;
|
||||
import org.tianocore.build.id.PackageIdentification;
|
||||
import org.tianocore.build.id.PlatformIdentification;
|
||||
import org.tianocore.build.toolchain.ToolChainInfo;
|
||||
import org.tianocore.build.autogen.CommonDefinition;
|
||||
|
||||
/**
|
||||
* SurfaceAreaQuery class is used to query Surface Area information from msa,
|
||||
@@ -1275,6 +1277,30 @@ public class SurfaceAreaQuery {
|
||||
return getCNames("Externs", xPath);
|
||||
}
|
||||
|
||||
/**
|
||||
Judge whether current driver is PEI_PCD_DRIVER or DXE_PCD_DRIVER or
|
||||
NOT_PCD_DRIVER.
|
||||
|
||||
@return CommonDefinition.PCD_DRIVER_TYPE the type of current driver
|
||||
**/
|
||||
public static CommonDefinition.PCD_DRIVER_TYPE getPcdDriverType() {
|
||||
String[] xPath = new String[] {"/PcdIsDriver"};
|
||||
Object[] results = get ("Externs", xPath);
|
||||
|
||||
if (results != null && results.length != 0) {
|
||||
PcdDriverTypes type = (PcdDriverTypes) results[0];
|
||||
String typeStr = type.enumValue().toString();
|
||||
if (typeStr.equals(CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER.toString())) {
|
||||
return CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER;
|
||||
} else if (typeStr.equals(CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER.toString())) {
|
||||
return CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER;
|
||||
}
|
||||
return CommonDefinition.PCD_DRIVER_TYPE.UNKNOWN_PCD_DRIVER;
|
||||
}
|
||||
|
||||
return CommonDefinition.PCD_DRIVER_TYPE.NOT_PCD_DRIVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve module surface area file information
|
||||
*
|
||||
|
@@ -22,16 +22,17 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.tianocore.build.autogen.CommonDefinition;
|
||||
import org.tianocore.build.exception.PcdAutogenException;
|
||||
import org.tianocore.build.global.GlobalData;
|
||||
import org.tianocore.build.id.ModuleIdentification;
|
||||
import org.tianocore.pcd.action.ActionMessage;
|
||||
import org.tianocore.pcd.action.BuildAction;
|
||||
import org.tianocore.pcd.entity.MemoryDatabaseManager;
|
||||
import org.tianocore.pcd.entity.Token;
|
||||
import org.tianocore.pcd.entity.UsageIdentification;
|
||||
import org.tianocore.pcd.entity.UsageInstance;
|
||||
import org.tianocore.pcd.exception.BuildActionException;
|
||||
import org.tianocore.pcd.entity.UsageIdentification;
|
||||
import org.tianocore.pcd.action.BuildAction;
|
||||
import org.tianocore.pcd.action.ActionMessage;
|
||||
import org.tianocore.build.exception.PcdAutogenException;
|
||||
|
||||
/** This class is to manage how to generate the PCD information into Autogen.c and
|
||||
Autogen.h.
|
||||
@@ -52,6 +53,11 @@ public class PCDAutoGenAction extends BuildAction {
|
||||
///
|
||||
private boolean isBuildUsedLibrary;
|
||||
|
||||
///
|
||||
/// One of PEI_PCD_DRIVER, DXE_PCD_DRIVER, NOT_PCD_DRIVER
|
||||
///
|
||||
private CommonDefinition.PCD_DRIVER_TYPE pcdDriverType;
|
||||
|
||||
///
|
||||
/// The generated string for header file.
|
||||
///
|
||||
@@ -76,6 +82,14 @@ public class PCDAutoGenAction extends BuildAction {
|
||||
this.usageId = usageId;
|
||||
}
|
||||
|
||||
/**
|
||||
Set paramter pcdDriverType
|
||||
|
||||
@param pcdDriverType the driver type for PCD
|
||||
**/
|
||||
public void setPcdDriverType(CommonDefinition.PCD_DRIVER_TYPE pcdDriverType) {
|
||||
this.pcdDriverType = pcdDriverType;
|
||||
}
|
||||
/**
|
||||
set isBuildUsedLibrary parameter.
|
||||
|
||||
@@ -122,11 +136,14 @@ public class PCDAutoGenAction extends BuildAction {
|
||||
@param arch the architecture for module
|
||||
@param isBuildUsedLibary Is the current module library.
|
||||
@param pcdNameArrayInMsa the pcd name array got from MSA file.
|
||||
@param pcdDriverType one of PEI_PCD_DRIVER, DXE_PCD_DRIVER,
|
||||
NOT_PCD_DRIVER
|
||||
**/
|
||||
public PCDAutoGenAction(ModuleIdentification moduleId,
|
||||
String arch,
|
||||
boolean isBuildUsedLibrary,
|
||||
String[] pcdNameArrayInMsa) {
|
||||
String[] pcdNameArrayInMsa,
|
||||
CommonDefinition.PCD_DRIVER_TYPE pcdDriverType) {
|
||||
dbManager = null;
|
||||
hAutoGenString = "";
|
||||
cAutoGenString = "";
|
||||
@@ -140,6 +157,7 @@ public class PCDAutoGenAction extends BuildAction {
|
||||
moduleId.getModuleType()));
|
||||
setIsBuildUsedLibrary(isBuildUsedLibrary);
|
||||
setPcdNameArrayInMsa(pcdNameArrayInMsa);
|
||||
setPcdDriverType(pcdDriverType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,10 +321,10 @@ public class PCDAutoGenAction extends BuildAction {
|
||||
// Work around code, In furture following code should be modified that get
|
||||
// these information from Uplevel Autogen tools.
|
||||
//
|
||||
if (moduleName.equalsIgnoreCase("PcdPeim")) {
|
||||
if (pcdDriverType == CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER) {
|
||||
hAutoGenString += MemoryDatabaseManager.PcdPeimHString;
|
||||
cAutoGenString += MemoryDatabaseManager.PcdPeimCString;
|
||||
} else if (moduleName.equalsIgnoreCase("PcdDxe")) {
|
||||
} else if (pcdDriverType == CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER) {
|
||||
hAutoGenString += MemoryDatabaseManager.PcdDxeHString;
|
||||
cAutoGenString += MemoryDatabaseManager.PcdDxeCString;
|
||||
}
|
||||
|
Reference in New Issue
Block a user