+ case CommonDefinition.ModuleTypeUefiApplication:\r
+ //\r
+ // If moduleType is one of above, call setVirtualAddressToAutogenC,\r
+ // and setExitBootServiceToAutogenC.\r
+ // \r
+ setVirtualAddressToAutogenC(fileBuffer);\r
+ setExitBootServiceToAutogenC(fileBuffer);\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+\r
+ /**\r
+ copyFlashMapHToDebugDir\r
+ \r
+ This function is to copy the falshmap.h to debug directory and change \r
+ its name to TianoR8FlashMap.h\r
+ \r
+ @param \r
+ @return\r
+ **/\r
+ private void copyFlashMapHToDebugDir() throws AutoGenException{\r
+\r
+ File inFile = new File(fvDir + File.separatorChar + CommonDefinition.FLASHMAPH);\r
+ int size = (int)inFile.length();\r
+ byte[] buffer = new byte[size];\r
+ File outFile = new File (this.outputPath + File.separatorChar + CommonDefinition.TIANOR8PLASHMAPH);\r
+ //\r
+ // If TianoR8FlashMap.h existed and the flashMap.h don't change,\r
+ // do nothing.\r
+ //\r
+ if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) {\r
+ if (inFile.exists()) {\r
+ try{\r
+ FileInputStream fis = new FileInputStream (inFile);\r
+ fis.read(buffer);\r
+ FileOutputStream fos = new FileOutputStream(outFile);\r
+ fos.write(buffer);\r
+ fis.close();\r
+ fos.close();\r
+ } catch (IOException e){\r
+ throw new AutoGenException("The file, flashMap.h can't be open!");\r
+ }\r
+ \r
+ } else {\r
+ throw new AutoGenException("The file, flashMap.h doesn't exist!");\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ This function first order the library instances, then collect\r
+ library instance 's PPI, Protocol, GUID,\r
+ SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and\r
+ Destructor, Constructor.\r
+ \r
+ @param\r
+ @return \r
+ **/\r
+ private void collectLibInstanceInfo() throws EdkException{\r
+ int index;\r
+\r
+ String libConstructName = null;\r
+ String libDestructName = null;\r
+ String libModuleType = null;\r
+ String[] setVirtuals = null;\r
+ String[] exitBoots = null;\r
+\r
+ ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch);\r
+\r
+ if (libraryIdList != null) {\r
+ //\r
+ // Reorder library instance sequence.\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
+ //\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
+\r
+ for (index = 0; index < ppiNotifyList.length; index++) {\r
+ this.mPpiList.add(ppiNotifyList[index]);\r
+ }\r
+\r
+ for (index = 0; index < protocolList.length; index++) {\r
+ this.mProtocolList.add(protocolList[index]);\r
+ }\r
+\r
+ for (index = 0; index < protocolNotifyList.length; index++) {\r
+ this.mProtocolList.add(protocolNotifyList[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
+\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
+ }\r
+ }\r
+ private void setVirtualAddressToAutogenC(StringBuffer fileBuffer){\r
+ //\r
+ // Entry point lib for these module types needs to know the count\r
+ // of entryPoint.\r
+ //\r
+ fileBuffer\r
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");\r