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:
klu2 2006-08-15 17:11:06 +00:00
parent d208e1e260
commit 5f907e4a5b
6 changed files with 1791 additions and 1723 deletions

View File

@ -88,6 +88,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->
</GuidCNames> </GuidCNames>
</Guids> </Guids>
<Externs> <Externs>
<PcdIsDriver>DXE_PCD_DRIVER</PcdIsDriver>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification> <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification> <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern> <Extern>

View File

@ -85,6 +85,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->
</GuidCNames> </GuidCNames>
</Guids> </Guids>
<Externs> <Externs>
<PcdIsDriver>PEI_PCD_DRIVER</PcdIsDriver>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification> <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification> <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern> <Extern>

View File

@ -52,46 +52,53 @@ import org.tianocore.common.logger.EdkLog;
* area or library surface area. * area or library surface area.
*/ */
public class AutoGen { public class AutoGen {
// / ///
// / The output path of Autogen.h and Autogen.c /// The output path of Autogen.h and Autogen.c
// / ///
private String outputPath; private String outputPath;
/// ///
/// The name of FV directory /// The name of FV directory
/// ///
private String fvDir; private String fvDir;
// /
// / The base name of module or library. ///
// / /// The base name of module or library.
///
private ModuleIdentification moduleId; private ModuleIdentification moduleId;
// / ///
// / The build architecture /// The build architecture
// / ///
private String arch; private String arch;
// / ///
// / PcdAutogen instance which is used to manage how to generate the PCD /// PcdAutogen instance which is used to manage how to generate the PCD
// / information. /// information.
// / ///
private PCDAutoGenAction myPcdAutogen; private PCDAutoGenAction myPcdAutogen;
// / ///
// / The protocl list which records in module or library surface area and /// the one of type : NOT_PCD_DRIVER, PEI_PCD_DRIVER, DXE_PCD_DRIVER
// / it's dependence on library instance surface area. ///
// / 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>(); private Set<String> mProtocolList = new HashSet<String>();
// / ///
// / The Ppi list which recorded in module or library surface area and its /// The Ppi list which recorded in module or library surface area and its
// / dependency on library instance surface area. /// dependency on library instance surface area.
// / ///
private Set<String> mPpiList = new HashSet<String>(); private Set<String> mPpiList = new HashSet<String>();
// / ///
// / The Guid list which recoreded in module or library surface area and it's /// The Guid list which recoreded in module or library surface area and it's
// / dependence on library instance surface area. /// dependence on library instance surface area.
// / ///
private Set<String> mGuidList = new HashSet<String>(); private Set<String> mGuidList = new HashSet<String>();
// //
@ -419,6 +426,7 @@ public class AutoGen {
String[] entryPointList = SurfaceAreaQuery.getModuleEntryPointArray(); String[] entryPointList = SurfaceAreaQuery.getModuleEntryPointArray();
EntryPointToAutoGen(CommonDefinition.remDupString(entryPointList), fileBuffer); EntryPointToAutoGen(CommonDefinition.remDupString(entryPointList), fileBuffer);
pcdDriverType = SurfaceAreaQuery.getPcdDriverType();
// //
// Restore the DOC which include the FPD module info. // Restore the DOC which include the FPD module info.
@ -458,8 +466,8 @@ public class AutoGen {
// Get module dependent Package identification. // Get module dependent Package identification.
// //
PackageIdentification[] packages = SurfaceAreaQuery.getDependencePkg(this.arch); PackageIdentification[] packages = SurfaceAreaQuery.getDependencePkg(this.arch);
for (int i = 0; i < packages.length; i++){ for (int i = 0; i < packages.length; i++) {
if (!this.mDepPkgList.contains(packages[i])){ if (!this.mDepPkgList.contains(packages[i])) {
this.mDepPkgList.add(packages[i]); this.mDepPkgList.add(packages[i]);
} }
@ -475,7 +483,11 @@ public class AutoGen {
// //
// Call pcd autogen. // Call pcd autogen.
// //
this.myPcdAutogen = new PCDAutoGenAction(moduleId, this.arch, false, null); this.myPcdAutogen = new PCDAutoGenAction(moduleId,
arch,
false,
null,
pcdDriverType);
try { try {
this.myPcdAutogen.execute(); this.myPcdAutogen.execute();
} catch (Exception exp) { } catch (Exception exp) {
@ -625,10 +637,11 @@ public class AutoGen {
// //
// Call pcd autogen. // Call pcd autogen.
// //
this.myPcdAutogen = new PCDAutoGenAction(this.moduleId, this.myPcdAutogen = new PCDAutoGenAction(moduleId,
this.arch, arch,
true, true,
SurfaceAreaQuery.getModulePcdEntryNameArray()); SurfaceAreaQuery.getModulePcdEntryNameArray(),
pcdDriverType);
try { try {
this.myPcdAutogen.execute(); this.myPcdAutogen.execute();
} catch (Exception e) { } catch (Exception e) {
@ -876,7 +889,7 @@ public class AutoGen {
// If entryPoint is null, create an empty ProcessModuleEntryPointList // If entryPoint is null, create an empty ProcessModuleEntryPointList
// function. // function.
// //
if (entryPointList == null || entryPointList.length == 0){ if (entryPointList == null || entryPointList.length == 0) {
fileBuffer fileBuffer
.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = "); .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
fileBuffer.append(Integer.toString(entryPointCount)); fileBuffer.append(Integer.toString(entryPointCount));
@ -992,11 +1005,11 @@ public class AutoGen {
fileBuffer.append(" EFI_STATUS Status;\r\n\r\n"); fileBuffer.append(" EFI_STATUS Status;\r\n\r\n");
fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n"); fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n");
for (int i = 0; i < entryPointList.length; i++) { for (int i = 0; i < entryPointList.length; i++) {
if (i == 0){ if (i == 0) {
fileBuffer.append(" Status = "); fileBuffer.append(" Status = ");
fileBuffer.append(entryPointList[i]); fileBuffer.append(entryPointList[i]);
fileBuffer.append("(ImageHandle);\r\n"); fileBuffer.append("(ImageHandle);\r\n");
}else{ } else {
fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n"); fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
fileBuffer.append(" "); fileBuffer.append(" ");
fileBuffer.append(entryPointList[i]); fileBuffer.append(entryPointList[i]);
@ -1023,7 +1036,7 @@ public class AutoGen {
// //
// If entry point is null, create a empty ProcessModuleEntryPointList function. // If entry point is null, create a empty ProcessModuleEntryPointList function.
// //
if (entryPointList == null || entryPointList.length == 0){ if (entryPointList == null || entryPointList.length == 0) {
fileBuffer fileBuffer
.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n"); .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
fileBuffer.append("EFI_STATUS\r\n"); fileBuffer.append("EFI_STATUS\r\n");
@ -1036,7 +1049,7 @@ public class AutoGen {
fileBuffer.append(" return EFI_SUCCESS;\r\n"); fileBuffer.append(" return EFI_SUCCESS;\r\n");
fileBuffer.append("}\r\n"); fileBuffer.append("}\r\n");
}else { } else {
for (int i = 0; i < entryPointList.length; i++) { for (int i = 0; i < entryPointList.length; i++) {
fileBuffer.append("EFI_STATUS\r\n"); fileBuffer.append("EFI_STATUS\r\n");
@ -1164,7 +1177,7 @@ public class AutoGen {
fileBuffer.append(" Status = "); fileBuffer.append(" Status = ");
fileBuffer.append(entryPointList[i]); fileBuffer.append(entryPointList[i]);
fileBuffer.append("(ImageHandle);\r\n"); fileBuffer.append("(ImageHandle);\r\n");
}else{ } else {
fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n"); fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
fileBuffer.append(" "); fileBuffer.append(" ");
fileBuffer.append(entryPointList[i]); fileBuffer.append(entryPointList[i]);
@ -1977,7 +1990,7 @@ public class AutoGen {
// do nothing. // do nothing.
// //
if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) { if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) {
try{ try {
if (inFile.exists()) { if (inFile.exists()) {
FileInputStream fis = new FileInputStream (inFile); FileInputStream fis = new FileInputStream (inFile);
fis.read(buffer); fis.read(buffer);
@ -1985,10 +1998,10 @@ public class AutoGen {
fos.write(buffer); fos.write(buffer);
fis.close(); fis.close();
fos.close(); fos.close();
}else { } else {
throw new AutoGenException("The file, flashMap.h doesn't exist!"); throw new AutoGenException("The file, flashMap.h doesn't exist!");
} }
} catch (Exception e){ } catch (Exception e) {
throw new AutoGenException(e.getMessage()); throw new AutoGenException(e.getMessage());
} }
} }
@ -2079,8 +2092,8 @@ public class AutoGen {
for (index = 0; index < guidList.length; index++) { for (index = 0; index < guidList.length; index++) {
this.mGuidList.add(guidList[index]); this.mGuidList.add(guidList[index]);
} }
for (index = 0; index < pkgList.length; index++){ for (index = 0; index < pkgList.length; index++) {
if (!this.mDepPkgList.contains(pkgList[index])){ if (!this.mDepPkgList.contains(pkgList[index])) {
this.mDepPkgList.add(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(e.getMessage());
System.out.println("Collect library instance failed!"); System.out.println("Collect library instance failed!");
} }
} }
} }

View File

@ -59,6 +59,15 @@ public class CommonDefinition {
public final static String tianoR8FlashMapH = "TianoR8FlashMap.h"; public final static String tianoR8FlashMapH = "TianoR8FlashMap.h";
public final static String flashMapH = "FlashMap.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 // AutoGen.h and AutoGen.c file's header
// //
@ -162,7 +171,7 @@ public class CommonDefinition {
new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver), new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver),
new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver), new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),
new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver), new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) }; new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication)};
// //
// Component type // Component type
@ -335,16 +344,16 @@ public class CommonDefinition {
public static String[] remDupString (String[] orgList){ public static String[] remDupString (String[] orgList){
Set<String> strList = new LinkedHashSet<String>(); Set<String> strList = new LinkedHashSet<String>();
String[] desList ; String[] desList ;
if (orgList == null){ if (orgList == null) {
return new String[0]; return new String[0];
} }
for (int i = 0; i < orgList.length; i++){ for (int i = 0; i < orgList.length; i++) {
strList.add(orgList[i]); strList.add(orgList[i]);
} }
desList = new String[strList.size()]; desList = new String[strList.size()];
Iterator item = strList.iterator(); Iterator item = strList.iterator();
int index = 0; int index = 0;
while (item.hasNext()){ while (item.hasNext()) {
desList[index] = (String)item.next(); desList[index] = (String)item.next();
index++; index++;
} }

View File

@ -60,6 +60,7 @@ import org.tianocore.FilenameDocument.Filename;
import org.tianocore.MsaHeaderDocument.MsaHeader; import org.tianocore.MsaHeaderDocument.MsaHeader;
import org.tianocore.ProtocolsDocument.Protocols.Protocol; import org.tianocore.ProtocolsDocument.Protocols.Protocol;
import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify; import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;
import org.tianocore.PcdDriverTypes;
import org.tianocore.common.logger.EdkLog; import org.tianocore.common.logger.EdkLog;
import org.tianocore.build.id.FpdModuleIdentification; 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.PackageIdentification;
import org.tianocore.build.id.PlatformIdentification; import org.tianocore.build.id.PlatformIdentification;
import org.tianocore.build.toolchain.ToolChainInfo; import org.tianocore.build.toolchain.ToolChainInfo;
import org.tianocore.build.autogen.CommonDefinition;
/** /**
* SurfaceAreaQuery class is used to query Surface Area information from msa, * SurfaceAreaQuery class is used to query Surface Area information from msa,
@ -1275,6 +1277,30 @@ public class SurfaceAreaQuery {
return getCNames("Externs", xPath); 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 * Retrieve module surface area file information
* *

View File

@ -22,16 +22,17 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; 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.global.GlobalData;
import org.tianocore.build.id.ModuleIdentification; 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.MemoryDatabaseManager;
import org.tianocore.pcd.entity.Token; import org.tianocore.pcd.entity.Token;
import org.tianocore.pcd.entity.UsageIdentification;
import org.tianocore.pcd.entity.UsageInstance; import org.tianocore.pcd.entity.UsageInstance;
import org.tianocore.pcd.exception.BuildActionException; 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 /** This class is to manage how to generate the PCD information into Autogen.c and
Autogen.h. Autogen.h.
@ -52,6 +53,11 @@ public class PCDAutoGenAction extends BuildAction {
/// ///
private boolean isBuildUsedLibrary; 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. /// The generated string for header file.
/// ///
@ -76,6 +82,14 @@ public class PCDAutoGenAction extends BuildAction {
this.usageId = usageId; 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. set isBuildUsedLibrary parameter.
@ -122,11 +136,14 @@ public class PCDAutoGenAction extends BuildAction {
@param arch the architecture for module @param arch the architecture for module
@param isBuildUsedLibary Is the current module library. @param isBuildUsedLibary Is the current module library.
@param pcdNameArrayInMsa the pcd name array got from MSA file. @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, public PCDAutoGenAction(ModuleIdentification moduleId,
String arch, String arch,
boolean isBuildUsedLibrary, boolean isBuildUsedLibrary,
String[] pcdNameArrayInMsa) { String[] pcdNameArrayInMsa,
CommonDefinition.PCD_DRIVER_TYPE pcdDriverType) {
dbManager = null; dbManager = null;
hAutoGenString = ""; hAutoGenString = "";
cAutoGenString = ""; cAutoGenString = "";
@ -140,6 +157,7 @@ public class PCDAutoGenAction extends BuildAction {
moduleId.getModuleType())); moduleId.getModuleType()));
setIsBuildUsedLibrary(isBuildUsedLibrary); setIsBuildUsedLibrary(isBuildUsedLibrary);
setPcdNameArrayInMsa(pcdNameArrayInMsa); 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 // Work around code, In furture following code should be modified that get
// these information from Uplevel Autogen tools. // these information from Uplevel Autogen tools.
// //
if (moduleName.equalsIgnoreCase("PcdPeim")) { if (pcdDriverType == CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER) {
hAutoGenString += MemoryDatabaseManager.PcdPeimHString; hAutoGenString += MemoryDatabaseManager.PcdPeimHString;
cAutoGenString += MemoryDatabaseManager.PcdPeimCString; cAutoGenString += MemoryDatabaseManager.PcdPeimCString;
} else if (moduleName.equalsIgnoreCase("PcdDxe")) { } else if (pcdDriverType == CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER) {
hAutoGenString += MemoryDatabaseManager.PcdDxeHString; hAutoGenString += MemoryDatabaseManager.PcdDxeHString;
cAutoGenString += MemoryDatabaseManager.PcdDxeCString; cAutoGenString += MemoryDatabaseManager.PcdDxeCString;
} }