enhance MsaOwner.java

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1627 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
alfred 2006-09-26 07:19:30 +00:00
parent e8c0c170fa
commit fd16b4dddd
2 changed files with 121 additions and 11 deletions

View File

@ -1,6 +1,9 @@
package org.tianocore.migration;
import java.util.*;
import org.tianocore.*;
import org.tianocore.SupportedArchitectures.Enum;
public class MsaOwner {
public static final String COPYRIGHT = "Copyright (c) 2006, Intel Corporation";
@ -17,21 +20,126 @@ public class MsaOwner {
" Intel Corporation.";
public static final String SPECIFICATION = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
public static final Enum IA32 = SupportedArchitectures.IA_32;
public static final Enum X64 = SupportedArchitectures.X_64;
public static final Enum IPF = SupportedArchitectures.IPF;
public static final Enum EBC = SupportedArchitectures.EBC;
private ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.newInstance();
private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;
private MsaHeaderDocument.MsaHeader msaheader = null;
private LicenseDocument.License license = null;
private ModuleDefinitionsDocument.ModuleDefinitions md = null;
private ModuleDefinitionsDocument.ModuleDefinitions moduledefinitions = null;
private SourceFilesDocument.SourceFiles sourcefiles = null; //found local .h files are not written
private GuidsDocument.Guids guids = null;
private ProtocolsDocument.Protocols protocols = null;
private PPIsDocument.PPIs ppis = null;
private PackageDependenciesDocument.PackageDependencies pd = null;
private PackageDependenciesDocument.PackageDependencies packagedependencies = null;
private LibraryClassDefinitionsDocument.LibraryClassDefinitions libclassdefs = null;
private ExternsDocument.Externs externs = null;
private List<Enum> listarch = new ArrayList<Enum>();
private Map<String, Enum> mapfilenames = new HashMap<String, Enum>(); //this need to be installed manually when msa is to be written
private Map<String, UsageTypes.Enum> mapprotocols = new HashMap<String, UsageTypes.Enum>();
//-----------------------------msaheader-------------------------------------//
private final boolean installProtocols () {
if (mapprotocols.isEmpty()) {
return false;
}
Set<String> setprotocols = mapprotocols.keySet();
ProtocolsDocument.Protocols.Protocol protocol;
Iterator<String> it = setprotocols.iterator();
while (it.hasNext()) {
protocol = protocols.addNewProtocol();
protocol.setProtocolCName(it.next());
protocol.setUsage(mapprotocols.get(protocol.getProtocolCName()));
}
return true;
}
public final boolean addProtocols (String protocol, UsageTypes.Enum usage) {
if (mapprotocols.containsKey(protocol)) {
return false;
} else {
mapprotocols.put(protocol, usage);
return true;
}
}
private final boolean installHashFilename () {
if (mapfilenames.isEmpty()) {
return false;
}
Set<String> setfilename = mapfilenames.keySet();
FilenameDocument.Filename filename;
List<Enum> arch = new ArrayList<Enum>();
Iterator<String> it = setfilename.iterator();
while (it.hasNext()) {
filename = sourcefiles.addNewFilename();
filename.setStringValue(it.next());
arch.add(mapfilenames.get(filename.getStringValue()));
filename.setSupArchList(arch);
}
return true;
}
public final boolean addSourceFile (String filename, Enum arch) { // dummy & null how to imply?
if (mapfilenames.containsKey(filename)) {
return false;
} else {
mapfilenames.put(filename, arch);
return true;
}
}
// entry point todo
public final boolean setupExternSpecification () {
addExternSpecification("EFI_SPECIFICATION_VERSION 0x00020000");
addExternSpecification("EDK_RELEASE_VERSION 0x00020000");
return true;
}
public final boolean addExternSpecification (String specification) {
if (externs.getSpecificationList().contains(specification)) {
return false;
} else {
externs.addSpecification(specification);
return true;
}
}
public final boolean setupPackageDependencies() {
addPackage("5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec");
addPackage("68169ab0-d41b-4009-9060-292c253ac43d");
return true;
}
public final boolean addPackage (String guid) {
if (packagedependencies.getPackageList().contains(guid)) {
return false;
} else {
packagedependencies.addNewPackage().setPackageGuid(guid);
return true;
}
}
public final boolean setupModuleDefinitions () { //????????? give this job to moduleinfo
moduledefinitions.setBinaryModule(false);
moduledefinitions.setOutputFileBasename(msaheader.getModuleName());
return true;
}
public final boolean addSupportedArchitectures (Enum arch) {
if (listarch.contains(arch)) {
return false;
} else {
listarch.add(arch);
return true;
}
}
public final boolean addSpecification (String specification) {
if (msaheader.getSpecification() == null) {
if (specification == null) {
@ -155,9 +263,11 @@ public class MsaOwner {
private final MsaOwner init () {
msa = msadoc.addNewModuleSurfaceArea();
msaheader = msa.addNewMsaHeader();
md = msa.addNewModuleDefinitions();
moduledefinitions = msa.addNewModuleDefinitions();
moduledefinitions.setSupportedArchitectures(listarch);
sourcefiles = msa.addNewSourceFiles();
pd = msa.addNewPackageDependencies();
packagedependencies = msa.addNewPackageDependencies();
libclassdefs = msa.addNewLibraryClassDefinitions();
externs = msa.addNewExterns();
return this;

View File

@ -119,13 +119,13 @@ public class MsaWriter {
externs.addNewSpecification().setStringValue("EFI_SPECIFICATION_VERSION 0x00020000");
externs.addNewSpecification().setStringValue("EDK_RELEASE_VERSION 0x00020000");
if (mi.entrypoint != null) {
externs.addNewExtern().setModuleEntryPoint(mi.entrypoint);
org.tianocore.ModuleTypeDef.Enum moduleType = msaheader.getModuleType();
if (moduleType == ModuleTypeDef.PEIM) {
mi.hashrequiredr9libs.add("PeimEntryPoint");
} else {
mi.hashrequiredr9libs.add("UefiDriverEntryPoint");
}
externs.addNewExtern().setModuleEntryPoint(mi.entrypoint);
org.tianocore.ModuleTypeDef.Enum moduleType = msaheader.getModuleType();
if (moduleType == ModuleTypeDef.PEIM) {
mi.hashrequiredr9libs.add("PeimEntryPoint");
} else {
mi.hashrequiredr9libs.add("UefiDriverEntryPoint");
}
}
it = mi.localmodulesources.iterator();