private List<String> exitBootServiceList = new ArrayList<String>();\r
\r
private StringBuffer functionDeclarations = new StringBuffer(10240);\r
+ private StringBuffer globalDeclarations = new StringBuffer(10240);\r
\r
//\r
// flag of PcdComponentNameDisable, PcdDriverDiagnosticDisable \r
//\r
// Write library class's related *.h file to autogen.h.\r
//\r
- String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED,this.arch);\r
- if (libClassList != null) {\r
+ String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch, null);\r
+ if (libClassList.length > 0) {\r
libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
item = libClassIncludeH.iterator();\r
while (item.hasNext()) {\r
}\r
}\r
\r
- libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
- if (libClassList != null) {\r
+ libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch, null);\r
+ if (libClassList.length > 0) {\r
libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
item = libClassIncludeH.iterator();\r
while (item.hasNext()) {\r
fileBuffer.append(this.myPcdAutogen.getHAutoGenString());\r
}\r
\r
+ fileBuffer.append(globalDeclarations);\r
fileBuffer.append(functionDeclarations);\r
//\r
// Append the #endif at AutoGen.h\r
//\r
// Write library class's related *.h file to autogen.h\r
//\r
- String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch);\r
+ String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch, null);\r
if (libClassList != null) {\r
libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
item = libClassIncludeH.iterator();\r
}\r
}\r
\r
- libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
+ libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch, null);\r
if (libClassList != null) {\r
libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
item = libClassIncludeH.iterator();\r
fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);\r
fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
}\r
-\r
- if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
- throw new AutoGenException("Failed to generate AutoGen.c !!!");\r
- }\r
}\r
\r
/**\r
if (entryPointList == null ||entryPointList.length != 1 ) {\r
throw new AutoGenException("Module type = 'PEI_CORE', can have only one module entry point!");\r
} else {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(entryPointList[0]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer.append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");\r
- fileBuffer.append(" IN VOID *OldCoreData\r\n");\r
- fileBuffer.append(" );\r\n\r\n");\r
+ functionDeclarations.append("EFI_STATUS\r\n");\r
+ functionDeclarations.append("EFIAPI\r\n");\r
+ functionDeclarations.append(entryPointList[0]);\r
+ functionDeclarations.append(" (\r\n");\r
+ functionDeclarations.append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");\r
+ functionDeclarations.append(" IN VOID *OldCoreData\r\n");\r
+ functionDeclarations.append(" );\r\n\r\n");\r
\r
fileBuffer.append("EFI_STATUS\r\n");\r
fileBuffer.append("EFIAPI\r\n");\r
if (entryPointList == null || entryPointList.length != 1) {\r
throw new AutoGenException("Module type = 'DXE_CORE', can have only one module entry point!");\r
} else {\r
- fileBuffer.append("VOID\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(entryPointList[0]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer.append(" IN VOID *HobStart\r\n");\r
- fileBuffer.append(" );\r\n\r\n");\r
+ functionDeclarations.append("VOID\r\n");\r
+ functionDeclarations.append("EFIAPI\r\n");\r
+ functionDeclarations.append(entryPointList[0]);\r
+ functionDeclarations.append(" (\r\n");\r
+ functionDeclarations.append(" IN VOID *HobStart\r\n");\r
+ functionDeclarations.append(" );\r\n\r\n");\r
\r
fileBuffer.append("VOID\r\n");\r
fileBuffer.append("EFIAPI\r\n");\r
break;\r
}\r
for (int i = 0; i < entryPointList.length; i++) {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(entryPointList[i]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");\r
- fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
- fileBuffer.append(" );\r\n");\r
+ functionDeclarations.append("EFI_STATUS\r\n");\r
+ functionDeclarations.append("EFIAPI\r\n");\r
+ functionDeclarations.append(entryPointList[i]);\r
+ functionDeclarations.append(" (\r\n");\r
+ functionDeclarations.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");\r
+ functionDeclarations.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
+ functionDeclarations.append(" );\r\n");\r
entryPointCount++;\r
}\r
\r
\r
} else {\r
for (int i = 0; i < entryPointList.length; i++) {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(entryPointList[i]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
- fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
- fileBuffer.append(" );\r\n");\r
+ functionDeclarations.append("EFI_STATUS\r\n");\r
+ functionDeclarations.append("EFIAPI\r\n");\r
+ functionDeclarations.append(entryPointList[i]);\r
+ functionDeclarations.append(" (\r\n");\r
+ functionDeclarations.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
+ functionDeclarations.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
+ functionDeclarations.append(" );\r\n");\r
entryPointCount++;\r
}\r
fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");\r
unloadImageCount = 0;\r
if (unloadImageList != null) {\r
for (int i = 0; i < unloadImageList.length; i++) {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append(unloadImageList[i]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n");\r
- fileBuffer.append(" );\r\n");\r
+ functionDeclarations.append("EFI_STATUS\r\n");\r
+ functionDeclarations.append(unloadImageList[i]);\r
+ functionDeclarations.append(" (\r\n");\r
+ functionDeclarations.append(" IN EFI_HANDLE ImageHandle\r\n");\r
+ functionDeclarations.append(" );\r\n");\r
unloadImageCount++;\r
}\r
}\r
\r
} else {\r
for (int i = 0; i < entryPointList.length; i++) {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(entryPointList[i]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
- fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
- fileBuffer.append(" );\r\n");\r
+ functionDeclarations.append("EFI_STATUS\r\n");\r
+ functionDeclarations.append("EFIAPI\r\n");\r
+ functionDeclarations.append(entryPointList[i]);\r
+ functionDeclarations.append(" (\r\n");\r
+ functionDeclarations.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
+ functionDeclarations.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
+ functionDeclarations.append(" );\r\n");\r
entryPointCount++;\r
}\r
\r
fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");\r
fileBuffer.append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");\r
fileBuffer.append(" }\r\n");\r
- fileBuffer\r
- .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");\r
+ fileBuffer.append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");\r
} else {\r
fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");\r
fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n");\r
unloadImageCount = 0;\r
if (unloadImageList != null) {\r
for (int i = 0; i < unloadImageList.length; i++) {\r
- fileBuffer.append("EFI_STATUS\r\n");\r
- fileBuffer.append("EFIAPI\r\n");\r
- fileBuffer.append(unloadImageList[i]);\r
- fileBuffer.append(" (\r\n");\r
- fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n");\r
- fileBuffer.append(" );\r\n");\r
+ functionDeclarations.append("EFI_STATUS\r\n");\r
+ functionDeclarations.append("EFIAPI\r\n");\r
+ functionDeclarations.append(unloadImageList[i]);\r
+ functionDeclarations.append(" (\r\n");\r
+ functionDeclarations.append(" IN EFI_HANDLE ImageHandle\r\n");\r
+ functionDeclarations.append(" );\r\n");\r
unloadImageCount++;\r
}\r
}\r
//\r
// Add library constructor to AutoGen.c\r
//\r
- LibConstructorToAutogenC(libConstructList, moduleType,\r
- fileBuffer/* autogenC */);\r
+ LibConstructorToAutogenC(libConstructList, moduleType, fileBuffer);\r
//\r
// Add library destructor to AutoGen.c\r
//\r
- LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);\r
+ LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer);\r
}\r
\r
/**\r
case CommonDefinition.ModuleTypePeiCore:\r
case CommonDefinition.ModuleTypePeim:\r
fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");\r
- fileBuffer\r
- .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
+ fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
break;\r
\r
case CommonDefinition.ModuleTypeDxeCore:\r
//\r
for (int i = 0; i < driverBindingGroup.length; i++) {\r
if (driverBindingGroup[i][0] != null) {\r
- fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL ");\r
- fileBuffer.append(driverBindingGroup[i][0]);\r
- fileBuffer.append(";\r\n");\r
+ globalDeclarations.append("extern EFI_DRIVER_BINDING_PROTOCOL ");\r
+ globalDeclarations.append(driverBindingGroup[i][0]);\r
+ globalDeclarations.append(";\r\n");\r
}\r
}\r
\r
if (driverBindingGroup[i][1]!= null) {\r
if (driverBindingGroup[i][0] != null) {\r
BitMask |= 0x01;\r
- fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL ");\r
- fileBuffer.append(driverBindingGroup[i][1]);\r
- fileBuffer.append(";\r\n");\r
+ globalDeclarations.append("extern EFI_COMPONENT_NAME_PROTOCOL ");\r
+ globalDeclarations.append(driverBindingGroup[i][1]);\r
+ globalDeclarations.append(";\r\n");\r
} else {\r
throw new AutoGenException("DriverBinding can't be empty!!");\r
}\r
if (driverBindingGroup[i][2] != null) {\r
if (driverBindingGroup[i][0] != null) {\r
BitMask |= 0x02;\r
- fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");\r
- fileBuffer.append(driverBindingGroup[i][2]);\r
- fileBuffer.append(";\r\n");\r
+ globalDeclarations.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");\r
+ globalDeclarations.append(driverBindingGroup[i][2]);\r
+ globalDeclarations.append(";\r\n");\r
} else {\r
throw new AutoGenException("DriverBinding can't be empty!!");\r
}\r
if (driverBindingGroup[i][3] != null) {\r
if (driverBindingGroup[i][0] != null) {\r
BitMask |= 0x04;\r
- fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");\r
- fileBuffer.append(driverBindingGroup[i][3]);\r
- fileBuffer.append(";\r\n");\r
+ globalDeclarations.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");\r
+ globalDeclarations.append(driverBindingGroup[i][3]);\r
+ globalDeclarations.append(";\r\n");\r
} else {\r
throw new AutoGenException("DriverBinding can't be empty!!");\r
}\r
private void collectLibInstanceInfo() throws EdkException{\r
int index;\r
\r
+ String moduleType = moduleId.getModuleType();\r
String libConstructName = null;\r
String libDestructName = null;\r
String libModuleType = null;\r
String[] exitBoots = null;\r
\r
ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch);\r
+ if (libraryIdList.length <= 0) {\r
+ return;\r
+ }\r
+ //\r
+ // Reorder library instance sequence.\r
+ //\r
+ AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList, this.arch);\r
+ List<ModuleIdentification> orderList = libOrder.orderLibInstance();\r
+ //\r
+ // Process library instance one by one.\r
+ //\r
+ for (int i = 0; i < orderList.size(); i++) {\r
+ //\r
+ // Get library instance basename.\r
+ //\r
+ ModuleIdentification libInstanceId = orderList.get(i);\r
\r
- if (libraryIdList != null) {\r
//\r
- // Reorder library instance sequence.\r
+ // Get override map\r
//\r
- AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList,\r
- this.arch);\r
- List<ModuleIdentification> orderList = libOrder\r
- .orderLibInstance();\r
\r
- if (orderList != null) {\r
- //\r
- // Process library instance one by one.\r
- //\r
- for (int i = 0; i < orderList.size(); i++) {\r
- //\r
- // Get library instance basename.\r
- //\r
- ModuleIdentification libInstanceId = orderList.get(i);\r
-\r
- //\r
- // Get override map\r
- //\r
-\r
- Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
- saq.push(libDoc);\r
- //\r
- // Get <PPis>, <Protocols>, <Guids> list of this library\r
- // instance.\r
- //\r
- String[] ppiList = saq.getPpiArray(this.arch);\r
- String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);\r
- String[] protocolList = saq.getProtocolArray(this.arch);\r
- String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);\r
- String[] guidList = saq.getGuidEntryArray(this.arch);\r
- PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);\r
-\r
- //\r
- // Add those ppi, protocol, guid in global ppi,\r
- // protocol, guid\r
- // list.\r
- //\r
- for (index = 0; index < ppiList.length; index++) {\r
- this.mPpiList.add(ppiList[index]);\r
- }\r
+ Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
+ saq.push(libDoc);\r
+ //\r
+ // check if the library instance support current module\r
+ // \r
+ String[] libraryClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED,\r
+ this.arch,\r
+ moduleType\r
+ );\r
+ if (libraryClassList.length <= 0) {\r
+ throw new EdkException("Library instance " + libInstanceId.getName() \r
+ + " doesn't support module type " + moduleType);\r
+ }\r
+ //\r
+ // Get <PPis>, <Protocols>, <Guids> list of this library\r
+ // instance.\r
+ //\r
+ String[] ppiList = saq.getPpiArray(this.arch);\r
+ String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);\r
+ String[] protocolList = saq.getProtocolArray(this.arch);\r
+ String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);\r
+ String[] guidList = saq.getGuidEntryArray(this.arch);\r
+ PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);\r
\r
- for (index = 0; index < ppiNotifyList.length; index++) {\r
- this.mPpiList.add(ppiNotifyList[index]);\r
- }\r
+ //\r
+ // Add those ppi, protocol, guid in global ppi,\r
+ // protocol, guid\r
+ // list.\r
+ //\r
+ for (index = 0; index < ppiList.length; index++) {\r
+ this.mPpiList.add(ppiList[index]);\r
+ }\r
\r
- for (index = 0; index < protocolList.length; index++) {\r
- this.mProtocolList.add(protocolList[index]);\r
- }\r
+ for (index = 0; index < ppiNotifyList.length; index++) {\r
+ this.mPpiList.add(ppiNotifyList[index]);\r
+ }\r
\r
- for (index = 0; index < protocolNotifyList.length; index++) {\r
- this.mProtocolList.add(protocolNotifyList[index]);\r
- }\r
+ for (index = 0; index < protocolList.length; index++) {\r
+ this.mProtocolList.add(protocolList[index]);\r
+ }\r
\r
- for (index = 0; index < guidList.length; index++) {\r
- this.mGuidList.add(guidList[index]);\r
- }\r
- for (index = 0; index < pkgList.length; index++) {\r
- if (!this.mDepPkgList.contains(pkgList[index])) {\r
- this.mDepPkgList.add(pkgList[index]);\r
- }\r
- }\r
+ for (index = 0; index < protocolNotifyList.length; index++) {\r
+ this.mProtocolList.add(protocolNotifyList[index]);\r
+ }\r
\r
- //\r
- // If not yet parse this library instance's constructor\r
- // element,parse it.\r
- //\r
- libConstructName = saq.getLibConstructorName();\r
- libDestructName = saq.getLibDestructorName();\r
- libModuleType = saq.getModuleType();\r
-\r
- //\r
- // Collect SetVirtualAddressMapCallBack and\r
- // ExitBootServiceCallBack.\r
- //\r
- setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
- exitBoots = saq.getExitBootServicesCallBackArray();\r
- if (setVirtuals != null) {\r
- for (int j = 0; j < setVirtuals.length; j++) {\r
- this.setVirtalAddList.add(setVirtuals[j]);\r
- }\r
- }\r
- if (exitBoots != null) {\r
- for (int k = 0; k < exitBoots.length; k++) {\r
- this.exitBootServiceList.add(exitBoots[k]);\r
- }\r
- }\r
- saq.pop();\r
- //\r
- // Add dependent library instance constructor function.\r
- //\r
- if (libConstructName != null) {\r
- this.libConstructList.add(new String[] {libConstructName, libModuleType});\r
- }\r
- //\r
- // Add dependent library instance destructor fuction.\r
- //\r
- if (libDestructName != null) {\r
- this.libDestructList.add(new String[] {libDestructName, libModuleType});\r
- }\r
+ for (index = 0; index < guidList.length; index++) {\r
+ this.mGuidList.add(guidList[index]);\r
+ }\r
+ for (index = 0; index < pkgList.length; index++) {\r
+ if (!this.mDepPkgList.contains(pkgList[index])) {\r
+ this.mDepPkgList.add(pkgList[index]);\r
+ }\r
+ }\r
+\r
+ //\r
+ // If not yet parse this library instance's constructor\r
+ // element,parse it.\r
+ //\r
+ libConstructName = saq.getLibConstructorName();\r
+ libDestructName = saq.getLibDestructorName();\r
+ libModuleType = saq.getModuleType();\r
+\r
+ //\r
+ // Collect SetVirtualAddressMapCallBack and\r
+ // ExitBootServiceCallBack.\r
+ //\r
+ setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
+ exitBoots = saq.getExitBootServicesCallBackArray();\r
+ if (setVirtuals != null) {\r
+ for (int j = 0; j < setVirtuals.length; j++) {\r
+ this.setVirtalAddList.add(setVirtuals[j]);\r
+ }\r
+ }\r
+ if (exitBoots != null) {\r
+ for (int k = 0; k < exitBoots.length; k++) {\r
+ this.exitBootServiceList.add(exitBoots[k]);\r
}\r
}\r
+ saq.pop();\r
+ //\r
+ // Add dependent library instance constructor function.\r
+ //\r
+ if (libConstructName != null) {\r
+ this.libConstructList.add(new String[] {libConstructName, libModuleType});\r
+ }\r
+ //\r
+ // Add dependent library instance destructor fuction.\r
+ //\r
+ if (libDestructName != null) {\r
+ this.libDestructList.add(new String[] {libDestructName, libModuleType});\r
+ }\r
}\r
}\r
\r