]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Moved the function prototype of SetVirtualAddress and ExitBootService to AutoGen...
authorjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 23 Jan 2007 05:14:48 +0000 (05:14 +0000)
committerjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 23 Jan 2007 05:14:48 +0000 (05:14 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2280 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java

index 8bb77af3d1cf28e50f5dee62d3e05a33bcfbd069..5925e504f63f9bb81a94fed2aeabaf1238643fe5 100644 (file)
@@ -119,6 +119,8 @@ public class AutoGen {
     private List<String> setVirtalAddList = new ArrayList<String>();\r
     private List<String> exitBootServiceList = new ArrayList<String>();\r
 \r
+    private StringBuffer functionDeclarations = new StringBuffer(10240);\r
+\r
     //\r
     // flag of PcdComponentNameDisable, PcdDriverDiagnosticDisable \r
     //\r
@@ -326,7 +328,7 @@ public class AutoGen {
         String[] specList = saq.getExternSpecificaiton();\r
         for (int i = 0; i < specList.length; i++) {\r
             fileBuffer.append(CommonDefinition.DEFINE + specList[i]\r
-                              + "\n");\r
+                              + "\r\n");\r
         }\r
         //\r
         // Write consumed package's mdouleInfo related .h file to autogen.h\r
@@ -362,7 +364,7 @@ public class AutoGen {
                 fileBuffer.append(item.next().toString());\r
             }\r
         }\r
-        fileBuffer.append("\n");\r
+        fileBuffer.append("\r\n");\r
 \r
         //\r
         //  If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to\r
@@ -371,21 +373,22 @@ public class AutoGen {
         if (saq.isHaveTianoR8FlashMap()) {\r
             fileBuffer.append(CommonDefinition.INCLUDE);\r
             fileBuffer.append("  <");\r
-            fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\n");\r
+            fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n");\r
             copyFlashMapHToDebugDir();\r
         }\r
 \r
         // Write PCD autogen information to AutoGen.h.\r
         //\r
         if (this.myPcdAutogen != null) {\r
-            fileBuffer.append("\n");\r
+            fileBuffer.append("\r\n");\r
             fileBuffer.append(this.myPcdAutogen.getHAutoGenString());\r
         }\r
 \r
+        fileBuffer.append(functionDeclarations);\r
         //\r
         // Append the #endif at AutoGen.h\r
         //\r
-        fileBuffer.append("#endif\n");\r
+        fileBuffer.append("#endif\r\n");\r
 \r
         //\r
         // Save string buffer content in AutoGen.h.\r
@@ -469,7 +472,7 @@ public class AutoGen {
         //\r
 \r
         fileBuffer.append(guid);\r
-        fileBuffer.append("};\n");\r
+        fileBuffer.append("};\r\n");\r
 \r
         //\r
         // Generate library instance consumed protocol, guid, ppi, pcd list.\r
@@ -509,7 +512,7 @@ public class AutoGen {
 \r
         this.myPcdAutogen.execute();\r
         if (this.myPcdAutogen != null) {\r
-            fileBuffer.append("\n");\r
+            fileBuffer.append("\r\n");\r
             fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
         }\r
 \r
@@ -563,8 +566,7 @@ public class AutoGen {
         fileBuffer.append(CommonDefinition.AUTOGENHBEGIN);\r
         String[] specList = saq.getExternSpecificaiton();\r
         for (int i = 0; i < specList.length; i++) {\r
-            fileBuffer.append(CommonDefinition.DEFINE + specList[i]\r
-                              + "\n");\r
+            fileBuffer.append(CommonDefinition.DEFINE + specList[i] + "\r\n");\r
         }\r
         // fileBuffer.append(CommonDefinition.autoGenHLine1);\r
         // fileBuffer.append(CommonDefinition.autoGenHLine2);\r
@@ -573,8 +575,7 @@ public class AutoGen {
         // Write consumed package's mdouleInfo related *.h file to autogen.h.\r
         //\r
         moduleType = saq.getModuleType();\r
-        PackageIdentification[] cosumedPkglist = saq\r
-                                                 .getDependencePkg(this.arch);\r
+        PackageIdentification[] cosumedPkglist = saq.getDependencePkg(this.arch);\r
         headerFileList = depPkgToAutogenH(cosumedPkglist, moduleType);\r
         item = headerFileList.iterator();\r
         while (item.hasNext()) {\r
@@ -609,7 +610,7 @@ public class AutoGen {
         if (saq.isHaveTianoR8FlashMap()) {\r
             fileBuffer.append(CommonDefinition.INCLUDE);\r
             fileBuffer.append("  <");\r
-            fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\n");\r
+            fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n");\r
             copyFlashMapHToDebugDir();\r
         }\r
 \r
@@ -617,18 +618,20 @@ public class AutoGen {
         // Write PCD information to library AutoGen.h.\r
         //\r
         if (this.myPcdAutogen != null) {\r
-            fileBuffer.append("\n");\r
+            fileBuffer.append("\r\n");\r
             fileBuffer.append(this.myPcdAutogen.getHAutoGenString());\r
         }\r
         //\r
         // generate function prototype for constructor and destructor\r
         // \r
-        LibConstructorToAutogenH(moduleType, fileBuffer);\r
-        LibDestructorToAutogenH(moduleType, fileBuffer);\r
+        LibConstructorToAutogenH(moduleType);\r
+        LibDestructorToAutogenH(moduleType);\r
+        ExternCallBackToAutoGenH(moduleType);\r
+        fileBuffer.append(functionDeclarations);\r
         //\r
         // Append the #endif at AutoGen.h\r
         //\r
-        fileBuffer.append("#endif\n");\r
+        fileBuffer.append("#endif\r\n");\r
         //\r
         // Save content of string buffer to AutoGen.h file.\r
         //\r
@@ -709,7 +712,7 @@ public class AutoGen {
                 String includeNameStr = includeName[j];\r
                 if (includeNameStr != null) {\r
                     str = CommonDefinition.INCLUDE + " " + "<";\r
-                    str = str + includeNameStr + ">\n";\r
+                    str = str + includeNameStr + ">\r\n";\r
                     includeStrList.add(str);\r
                     includeNameStr = null;\r
                 }\r
@@ -747,8 +750,7 @@ public class AutoGen {
                                            + packageNameList[i]\r
                                            + "] declaration in any SPD package. ");\r
             } else if (!pkgHeader.equalsIgnoreCase("")) {\r
-                includeStr = CommonDefinition.INCLUDE + " <" + pkgHeader\r
-                             + ">\n";\r
+                includeStr = CommonDefinition.INCLUDE + " <" + pkgHeader + ">\r\n";\r
                 includeStrList.add(includeStr);\r
             }\r
         }\r
@@ -772,7 +774,7 @@ public class AutoGen {
     throws EdkException {\r
 \r
         String typeStr = saq.getModuleType();\r
-        String debugStr = "DEBUG ((EFI_D_INFO | EFI_D_LOAD, \"Module Entry Point (%s) 0x%%p\\n\", (VOID *)(UINTN)%s));\n";\r
+        String debugStr = "DEBUG ((EFI_D_INFO | EFI_D_LOAD, \"Module Entry Point (%s) 0x%%p\\n\", (VOID *)(UINTN)%s));\r\n";\r
         int unloadImageCount = 0;\r
         int entryPointCount  = 0;\r
 \r
@@ -784,114 +786,113 @@ public class AutoGen {
         \r
         case CommonDefinition.ModuleTypePeiCore:\r
             if (entryPointList == null ||entryPointList.length != 1 ) {\r
-                throw new AutoGenException(\r
-                                          "Module type = 'PEI_CORE', can have only one module entry point!");\r
+                throw new AutoGenException("Module type = 'PEI_CORE', can have only one module entry point!");\r
             } else {\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
+                fileBuffer.append("EFI_STATUS\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
                 fileBuffer.append(entryPointList[0]);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\n");\r
-                fileBuffer.append("  IN VOID                        *OldCoreData\n");\r
-                fileBuffer.append("  );\n\n");\r
-\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append("ProcessModuleEntryPointList (\n");\r
-                fileBuffer.append("  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\n");\r
-                fileBuffer.append("  IN VOID                        *OldCoreData\n");\r
-                fileBuffer.append("  )\n\n");\r
-                fileBuffer.append("{\n");\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
+\r
+                fileBuffer.append("EFI_STATUS\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append("ProcessModuleEntryPointList (\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
+                fileBuffer.append("{\r\n");\r
                 fileBuffer.append("  return ");\r
                 fileBuffer.append(entryPointList[0]);\r
-                fileBuffer.append(" (PeiStartupDescriptor, OldCoreData);\n");\r
-                fileBuffer.append("}\n\n");\r
+                fileBuffer.append(" (PeiStartupDescriptor, OldCoreData);\r\n");\r
+                fileBuffer.append("}\r\n\r\n");\r
             }\r
             break;\r
 \r
         case CommonDefinition.ModuleTypeDxeCore:\r
-            fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\n");\r
+            fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\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\n");\r
-                fileBuffer.append("EFIAPI\n");\r
+                fileBuffer.append("VOID\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
                 fileBuffer.append(entryPointList[0]);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  IN VOID  *HobStart\n");\r
-                fileBuffer.append("  );\n\n");\r
-\r
-                fileBuffer.append("VOID\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append("ProcessModuleEntryPointList (\n");\r
-                fileBuffer.append("  IN VOID  *HobStart\n");\r
-                fileBuffer.append("  )\n\n");\r
-                fileBuffer.append("{\n");\r
+                fileBuffer.append(" (\r\n");\r
+                fileBuffer.append("  IN VOID  *HobStart\r\n");\r
+                fileBuffer.append("  );\r\n\r\n");\r
+\r
+                fileBuffer.append("VOID\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
+                fileBuffer.append("  IN VOID  *HobStart\r\n");\r
+                fileBuffer.append("  )\r\n\r\n");\r
+                fileBuffer.append("{\r\n");\r
                 fileBuffer.append("  ");\r
                 fileBuffer.append(entryPointList[0]);\r
-                fileBuffer.append(" (HobStart);\n");\r
-                fileBuffer.append("}\n\n");\r
+                fileBuffer.append(" (HobStart);\r\n");\r
+                fileBuffer.append("}\r\n\r\n");\r
             }\r
             break;\r
 \r
         case CommonDefinition.ModuleTypePeim:\r
             entryPointCount = 0;\r
-            fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\n");\r
+            fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");\r
             if (entryPointList == null || entryPointList.length == 0) {\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append("ProcessModuleEntryPointList (\n");\r
-                fileBuffer.append("  IN EFI_FFS_FILE_HEADER  *FfsHeader,\n");\r
-                fileBuffer.append("  IN EFI_PEI_SERVICES     **PeiServices\n");\r
-                fileBuffer.append("  )\n\n");\r
-                fileBuffer.append("{\n");\r
-                fileBuffer.append("  return EFI_SUCCESS;\n");\r
-                fileBuffer.append("}\n\n");\r
+                fileBuffer.append("EFI_STATUS\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append("ProcessModuleEntryPointList (\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\n");\r
+                fileBuffer.append("{\r\n");\r
+                fileBuffer.append("  return EFI_SUCCESS;\r\n");\r
+                fileBuffer.append("}\r\n\r\n");\r
                 break;\r
             }\r
             for (int i = 0; i < entryPointList.length; i++) {\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
+                fileBuffer.append("EFI_STATUS\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
                 fileBuffer.append(entryPointList[i]);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  IN EFI_FFS_FILE_HEADER  *FfsHeader,\n");\r
-                fileBuffer.append("  IN EFI_PEI_SERVICES     **PeiServices\n");\r
-                fileBuffer.append("  );\n");\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
                 entryPointCount++;\r
             }\r
 \r
-            fileBuffer.append("EFI_STATUS\n");\r
-            fileBuffer.append("EFIAPI\n");\r
-            fileBuffer.append("ProcessModuleEntryPointList (\n");\r
-            fileBuffer.append("  IN EFI_FFS_FILE_HEADER  *FfsHeader,\n");\r
-            fileBuffer.append("  IN EFI_PEI_SERVICES     **PeiServices\n");\r
-            fileBuffer.append("  )\n\n");\r
-            fileBuffer.append("{\n");\r
+            fileBuffer.append("EFI_STATUS\r\n");\r
+            fileBuffer.append("EFIAPI\r\n");\r
+            fileBuffer.append("ProcessModuleEntryPointList (\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\n");\r
+            fileBuffer.append("{\r\n");\r
             if (entryPointCount == 1) {\r
                 fileBuffer.append(String.format("  " + debugStr, entryPointList[0], entryPointList[0]));\r
                 fileBuffer.append("  return ");\r
                 fileBuffer.append(entryPointList[0]);\r
-                fileBuffer.append(" (FfsHeader, PeiServices);\n");\r
+                fileBuffer.append(" (FfsHeader, PeiServices);\r\n");\r
             } else {\r
-                fileBuffer.append("  EFI_STATUS  Status;\n");\r
-                fileBuffer.append("  EFI_STATUS  CombinedStatus;\n\n");\r
-                fileBuffer.append("  CombinedStatus = EFI_LOAD_ERROR;\n\n");\r
+                fileBuffer.append("  EFI_STATUS  Status;\r\n");\r
+                fileBuffer.append("  EFI_STATUS  CombinedStatus;\r\n\r\n");\r
+                fileBuffer.append("  CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");\r
                 for (int i = 0; i < entryPointList.length; i++) {\r
                     if (!entryPointList[i].equals("")) {\r
                         fileBuffer.append(String.format("  " + debugStr, entryPointList[i], entryPointList[i]));\r
                         fileBuffer.append("  Status = ");\r
                         fileBuffer.append(entryPointList[i]);\r
-                        fileBuffer.append(" (FfsHeader, PeiServices);\n");\r
-                        fileBuffer.append("  if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\n");\r
-                        fileBuffer.append("    CombinedStatus = Status;\n");\r
-                        fileBuffer.append("  }\n\n");\r
+                        fileBuffer.append(" (FfsHeader, PeiServices);\r\n");\r
+                        fileBuffer.append("  if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");\r
+                        fileBuffer.append("    CombinedStatus = Status;\r\n");\r
+                        fileBuffer.append("  }\r\n\r\n");\r
                     } else {\r
                         break;\r
                     }\r
                 }\r
-                fileBuffer.append("  return CombinedStatus;\n");\r
+                fileBuffer.append("  return CombinedStatus;\r\n");\r
             }\r
-            fileBuffer.append("}\n\n");\r
+            fileBuffer.append("}\r\n\r\n");\r
             break;\r
 \r
         case CommonDefinition.ModuleTypeDxeSmmDriver:\r
@@ -903,128 +904,125 @@ public class AutoGen {
             if (entryPointList == null || entryPointList.length == 0) {\r
                 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED  const UINT8  _gDriverEntryPointCount = ");\r
                 fileBuffer.append(Integer.toString(entryPointCount));\r
-                fileBuffer.append(";\n");\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append("ProcessModuleEntryPointList (\n");\r
-                fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-                fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-                fileBuffer.append("  )\n\n");\r
-                fileBuffer.append("{\n");\r
-                fileBuffer.append("  return EFI_SUCCESS;\n");\r
-                fileBuffer.append("}\n\n");\r
+                fileBuffer.append(";\r\n");\r
+                fileBuffer.append("EFI_STATUS\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append("ProcessModuleEntryPointList (\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\n");\r
+                fileBuffer.append("{\r\n");\r
+                fileBuffer.append("  return EFI_SUCCESS;\r\n");\r
+                fileBuffer.append("}\r\n\r\n");\r
 \r
             } else {\r
                 for (int i = 0; i < entryPointList.length; i++) {\r
-                    fileBuffer.append("EFI_STATUS\n");\r
-                    fileBuffer.append("EFIAPI\n");\r
+                    fileBuffer.append("EFI_STATUS\r\n");\r
+                    fileBuffer.append("EFIAPI\r\n");\r
                     fileBuffer.append(entryPointList[i]);\r
-                    fileBuffer.append(" (\n");\r
-                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-                    fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-                    fileBuffer.append("  );\n");\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
                     entryPointCount++;\r
                 }\r
                 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED  const UINT8  _gDriverEntryPointCount = ");\r
                 fileBuffer.append(Integer.toString(entryPointCount));\r
-                fileBuffer.append(";\n");\r
-                fileBuffer.append("static BASE_LIBRARY_JUMP_BUFFER  mJumpContext;\n");\r
-                fileBuffer.append("static EFI_STATUS  mDriverEntryPointStatus = EFI_LOAD_ERROR;\n\n");\r
-\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append("ProcessModuleEntryPointList (\n");\r
-                fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-                fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-                fileBuffer.append("  )\n\n");\r
-                fileBuffer.append("{\n");\r
+                fileBuffer.append(";\r\n");\r
+                fileBuffer.append("static BASE_LIBRARY_JUMP_BUFFER  mJumpContext;\r\n");\r
+                fileBuffer.append("static EFI_STATUS  mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");\r
+\r
+                fileBuffer.append("EFI_STATUS\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append("ProcessModuleEntryPointList (\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\n");\r
+                fileBuffer.append("{\r\n");\r
 \r
                 for (int i = 0; i < entryPointList.length; i++) {\r
-                    fileBuffer.append("  if (SetJump (&mJumpContext) == 0) {\n");\r
+                    fileBuffer.append("  if (SetJump (&mJumpContext) == 0) {\r\n");\r
                     fileBuffer.append(String.format("    " + debugStr, entryPointList[i], entryPointList[i]));\r
                     fileBuffer.append("    ExitDriver (");\r
                     fileBuffer.append(entryPointList[i]);\r
-                    fileBuffer.append(" (ImageHandle, SystemTable));\n");\r
-                    fileBuffer.append("    ASSERT (FALSE);\n");\r
-                    fileBuffer.append("  }\n");\r
+                    fileBuffer.append(" (ImageHandle, SystemTable));\r\n");\r
+                    fileBuffer.append("    ASSERT (FALSE);\r\n");\r
+                    fileBuffer.append("  }\r\n");\r
                 }\r
-                fileBuffer.append("  return mDriverEntryPointStatus;\n");\r
-                fileBuffer.append("}\n\n");\r
-\r
-                fileBuffer.append("VOID\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append("ExitDriver (\n");\r
-                fileBuffer.append("  IN EFI_STATUS  Status\n");\r
-                fileBuffer.append("  )\n\n");\r
-                fileBuffer.append("{\n");\r
-                fileBuffer.append("  if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\n");\r
-                fileBuffer.append("    mDriverEntryPointStatus = Status;\n");\r
-                fileBuffer.append("  }\n");\r
-                fileBuffer.append("  LongJump (&mJumpContext, (UINTN)-1);\n");\r
-                fileBuffer.append("  ASSERT (FALSE);\n");\r
-                fileBuffer.append("}\n\n");\r
+                fileBuffer.append("  return mDriverEntryPointStatus;\r\n");\r
+                fileBuffer.append("}\r\n\r\n");\r
+\r
+                fileBuffer.append("VOID\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append("ExitDriver (\r\n");\r
+                fileBuffer.append("  IN EFI_STATUS  Status\r\n");\r
+                fileBuffer.append("  )\r\n\r\n");\r
+                fileBuffer.append("{\r\n");\r
+                fileBuffer.append("  if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");\r
+                fileBuffer.append("    mDriverEntryPointStatus = Status;\r\n");\r
+                fileBuffer.append("  }\r\n");\r
+                fileBuffer.append("  LongJump (&mJumpContext, (UINTN)-1);\r\n");\r
+                fileBuffer.append("  ASSERT (FALSE);\r\n");\r
+                fileBuffer.append("}\r\n\r\n");\r
             }\r
 \r
 \r
             //\r
             // Add "ModuleUnloadImage" for DxeSmmDriver module type;\r
             //\r
-            //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();\r
-            //entryPointList = CommonDefinition.remDupString(entryPointList);\r
-            //entryPointCount = 0;\r
 \r
             unloadImageCount = 0;\r
             if (unloadImageList != null) {\r
                 for (int i = 0; i < unloadImageList.length; i++) {\r
-                    fileBuffer.append("EFI_STATUS\n");\r
+                    fileBuffer.append("EFI_STATUS\r\n");\r
                     fileBuffer.append(unloadImageList[i]);\r
-                    fileBuffer.append(" (\n");\r
-                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle\n");\r
-                    fileBuffer.append("  );\n");\r
+                    fileBuffer.append(" (\r\n");\r
+                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle\r\n");\r
+                    fileBuffer.append("  );\r\n");\r
                     unloadImageCount++;\r
                 }\r
             }\r
 \r
             fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverUnloadImageCount = ");\r
             fileBuffer.append(Integer.toString(unloadImageCount));\r
-            fileBuffer.append(";\n\n");\r
+            fileBuffer.append(";\r\n\r\n");\r
 \r
-            fileBuffer.append("EFI_STATUS\n");\r
-            fileBuffer.append("EFIAPI\n");\r
-            fileBuffer.append("ProcessModuleUnloadList (\n");\r
-            fileBuffer.append("  IN EFI_HANDLE  ImageHandle\n");\r
-            fileBuffer.append("  )\n");\r
-            fileBuffer.append("{\n");\r
+            fileBuffer.append("EFI_STATUS\r\n");\r
+            fileBuffer.append("EFIAPI\r\n");\r
+            fileBuffer.append("ProcessModuleUnloadList (\r\n");\r
+            fileBuffer.append("  IN EFI_HANDLE  ImageHandle\r\n");\r
+            fileBuffer.append("  )\r\n");\r
+            fileBuffer.append("{\r\n");\r
 \r
             if (unloadImageCount == 0) {\r
-                fileBuffer.append("  return EFI_SUCCESS;\n");\r
+                fileBuffer.append("  return EFI_SUCCESS;\r\n");\r
             } else if (unloadImageCount == 1) {\r
                 fileBuffer.append("  return ");\r
                 fileBuffer.append(unloadImageList[0]);\r
-                fileBuffer.append("(ImageHandle);\n");\r
+                fileBuffer.append("(ImageHandle);\r\n");\r
             } else {\r
-                fileBuffer.append("  EFI_STATUS  Status;\n\n");\r
-                fileBuffer.append("  Status = EFI_SUCCESS;\n\n");\r
+                fileBuffer.append("  EFI_STATUS  Status;\r\n\r\n");\r
+                fileBuffer.append("  Status = EFI_SUCCESS;\r\n\r\n");\r
                 for (int i = 0; i < unloadImageList.length; i++) {\r
                     if (i == 0) {\r
                         fileBuffer.append("     Status = ");\r
                         fileBuffer.append(unloadImageList[i]);\r
-                        fileBuffer.append("(ImageHandle);\n");\r
+                        fileBuffer.append("(ImageHandle);\r\n");\r
                     } else {\r
-                        fileBuffer.append("  if (EFI_ERROR (Status)) {\n");\r
+                        fileBuffer.append("  if (EFI_ERROR (Status)) {\r\n");\r
                         fileBuffer.append("    ");\r
                         fileBuffer.append(unloadImageList[i]);\r
-                        fileBuffer.append("(ImageHandle);\n");\r
-                        fileBuffer.append("  } else {\n");\r
+                        fileBuffer.append("(ImageHandle);\r\n");\r
+                        fileBuffer.append("  } else {\r\n");\r
                         fileBuffer.append("    Status = ");\r
                         fileBuffer.append(unloadImageList[i]);\r
-                        fileBuffer.append("(ImageHandle);\n");\r
-                        fileBuffer.append("  }\n");\r
+                        fileBuffer.append("(ImageHandle);\r\n");\r
+                        fileBuffer.append("  }\r\n");\r
                     }\r
                 }\r
-                fileBuffer.append("  return Status;\n");\r
+                fileBuffer.append("  return Status;\r\n");\r
             }\r
-            fileBuffer.append("}\n\n");\r
+            fileBuffer.append("}\r\n\r\n");\r
             break;\r
 \r
         case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
@@ -1033,95 +1031,94 @@ public class AutoGen {
         case CommonDefinition.ModuleTypeUefiDriver:\r
         case CommonDefinition.ModuleTypeUefiApplication:\r
             entryPointCount = 0;\r
-            fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\n");\r
+            fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");\r
             //\r
             // If entry point is null, create a empty ProcessModuleEntryPointList function.\r
             //\r
             if (entryPointList == null || entryPointList.length == 0) {\r
-                fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverEntryPointCount = 0;\n");\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append("ProcessModuleEntryPointList (\n");\r
-                fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-                fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-                fileBuffer.append("  )\n\n");\r
-                fileBuffer.append("{\n");\r
-                fileBuffer.append("  return EFI_SUCCESS;\n");\r
-                fileBuffer.append("}\n");\r
+                fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverEntryPointCount = 0;\r\n");\r
+                fileBuffer.append("EFI_STATUS\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append("ProcessModuleEntryPointList (\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\n");\r
+                fileBuffer.append("{\r\n");\r
+                fileBuffer.append("  return EFI_SUCCESS;\r\n");\r
+                fileBuffer.append("}\r\n");\r
 \r
             } else {\r
                 for (int i = 0; i < entryPointList.length; i++) {\r
-\r
-                    fileBuffer.append("EFI_STATUS\n");\r
-                    fileBuffer.append("EFIAPI\n");\r
+                    fileBuffer.append("EFI_STATUS\r\n");\r
+                    fileBuffer.append("EFIAPI\r\n");\r
                     fileBuffer.append(entryPointList[i]);\r
-                    fileBuffer.append(" (\n");\r
-                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-                    fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-                    fileBuffer.append("  );\n");\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
                     entryPointCount++;\r
                 }\r
 \r
                 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverEntryPointCount = ");\r
                 fileBuffer.append(Integer.toString(entryPointCount));\r
-                fileBuffer.append(";\n");\r
+                fileBuffer.append(";\r\n");\r
                 if (entryPointCount > 1) {\r
-                    fileBuffer.append("static BASE_LIBRARY_JUMP_BUFFER  mJumpContext;\n");\r
-                    fileBuffer.append("static EFI_STATUS  mDriverEntryPointStatus = EFI_LOAD_ERROR;\n");\r
+                    fileBuffer.append("static BASE_LIBRARY_JUMP_BUFFER  mJumpContext;\r\n");\r
+                    fileBuffer.append("static EFI_STATUS  mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");\r
                 }\r
-                fileBuffer.append("\n");\r
+                fileBuffer.append("\r\n");\r
 \r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append("ProcessModuleEntryPointList (\n");\r
-                fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-                fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-                fileBuffer.append("  )\n\n");\r
-                fileBuffer.append("{\n");\r
+                fileBuffer.append("EFI_STATUS\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append("ProcessModuleEntryPointList (\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\n");\r
+                fileBuffer.append("{\r\n");\r
 \r
                 if (entryPointCount == 1) {\r
                     fileBuffer.append(String.format("  " + debugStr, entryPointList[0], entryPointList[0]));\r
                     fileBuffer.append("  return ");\r
                     fileBuffer.append(entryPointList[0]);\r
-                    fileBuffer.append(" (ImageHandle, SystemTable);\n");\r
+                    fileBuffer.append(" (ImageHandle, SystemTable);\r\n");\r
                 } else {\r
                     for (int i = 0; i < entryPointList.length; i++) {\r
                         if (!entryPointList[i].equals("")) {\r
-                            fileBuffer.append("  if (SetJump (&mJumpContext) == 0) {\n");\r
+                            fileBuffer.append("  if (SetJump (&mJumpContext) == 0) {\r\n");\r
                             fileBuffer.append(String.format("    " + debugStr, entryPointList[i], entryPointList[i]));\r
                             fileBuffer.append("    ExitDriver (");\r
                             fileBuffer.append(entryPointList[i]);\r
-                            fileBuffer.append(" (ImageHandle, SystemTable));\n");\r
-                            fileBuffer.append("    ASSERT (FALSE);\n");\r
-                            fileBuffer.append("  }\n");\r
+                            fileBuffer.append(" (ImageHandle, SystemTable));\r\n");\r
+                            fileBuffer.append("    ASSERT (FALSE);\r\n");\r
+                            fileBuffer.append("  }\r\n");\r
                         } else {\r
                             break;\r
                         }\r
                     }\r
-                    fileBuffer.append("  return mDriverEntryPointStatus;\n");\r
+                    fileBuffer.append("  return mDriverEntryPointStatus;\r\n");\r
                 }\r
-                fileBuffer.append("}\n\n");\r
-\r
-                fileBuffer.append("VOID\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append("ExitDriver (\n");\r
-                fileBuffer.append("  IN EFI_STATUS  Status\n");\r
-                fileBuffer.append("  )\n\n");\r
-                fileBuffer.append("{\n");\r
+                fileBuffer.append("}\r\n\r\n");\r
+\r
+                fileBuffer.append("VOID\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append("ExitDriver (\r\n");\r
+                fileBuffer.append("  IN EFI_STATUS  Status\r\n");\r
+                fileBuffer.append("  )\r\n\r\n");\r
+                fileBuffer.append("{\r\n");\r
                 if (entryPointCount <= 1) {\r
-                    fileBuffer.append("  if (EFI_ERROR (Status)) {\n");\r
-                    fileBuffer.append("    ProcessLibraryDestructorList (gImageHandle, gST);\n");\r
-                    fileBuffer.append("  }\n");\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);\n");\r
+                    .append("  gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");\r
                 } else {\r
-                    fileBuffer.append("  if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\n");\r
-                    fileBuffer.append("    mDriverEntryPointStatus = Status;\n");\r
-                    fileBuffer.append("  }\n");\r
-                    fileBuffer.append("  LongJump (&mJumpContext, (UINTN)-1);\n");\r
-                    fileBuffer.append("  ASSERT (FALSE);\n");\r
+                    fileBuffer.append("  if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");\r
+                    fileBuffer.append("    mDriverEntryPointStatus = Status;\r\n");\r
+                    fileBuffer.append("  }\r\n");\r
+                    fileBuffer.append("  LongJump (&mJumpContext, (UINTN)-1);\r\n");\r
+                    fileBuffer.append("  ASSERT (FALSE);\r\n");\r
                 }\r
-                fileBuffer.append("}\n\n");\r
+                fileBuffer.append("}\r\n\r\n");\r
             }\r
 \r
             //\r
@@ -1136,56 +1133,56 @@ public class AutoGen {
             unloadImageCount = 0;\r
             if (unloadImageList != null) {\r
                 for (int i = 0; i < unloadImageList.length; i++) {\r
-                    fileBuffer.append("EFI_STATUS\n");\r
-                    fileBuffer.append("EFIAPI\n");\r
+                    fileBuffer.append("EFI_STATUS\r\n");\r
+                    fileBuffer.append("EFIAPI\r\n");\r
                     fileBuffer.append(unloadImageList[i]);\r
-                    fileBuffer.append(" (\n");\r
-                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle\n");\r
-                    fileBuffer.append("  );\n");\r
+                    fileBuffer.append(" (\r\n");\r
+                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle\r\n");\r
+                    fileBuffer.append("  );\r\n");\r
                     unloadImageCount++;\r
                 }\r
             }\r
 \r
             fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverUnloadImageCount = ");\r
             fileBuffer.append(Integer.toString(unloadImageCount));\r
-            fileBuffer.append(";\n\n");\r
+            fileBuffer.append(";\r\n\r\n");\r
 \r
-            fileBuffer.append("EFI_STATUS\n");\r
-            fileBuffer.append("EFIAPI\n");\r
-            fileBuffer.append("ProcessModuleUnloadList (\n");\r
-            fileBuffer.append("  IN EFI_HANDLE  ImageHandle\n");\r
-            fileBuffer.append("  )\n");\r
-            fileBuffer.append("{\n");\r
+            fileBuffer.append("EFI_STATUS\r\n");\r
+            fileBuffer.append("EFIAPI\r\n");\r
+            fileBuffer.append("ProcessModuleUnloadList (\r\n");\r
+            fileBuffer.append("  IN EFI_HANDLE  ImageHandle\r\n");\r
+            fileBuffer.append("  )\r\n");\r
+            fileBuffer.append("{\r\n");\r
 \r
             if (unloadImageCount == 0) {\r
-                fileBuffer.append("  return EFI_SUCCESS;\n");\r
+                fileBuffer.append("  return EFI_SUCCESS;\r\n");\r
             } else if (unloadImageCount == 1) {\r
                 fileBuffer.append("  return ");\r
                 fileBuffer.append(unloadImageList[0]);\r
-                fileBuffer.append("(ImageHandle);\n");\r
+                fileBuffer.append("(ImageHandle);\r\n");\r
             } else {\r
-                fileBuffer.append("  EFI_STATUS  Status;\n\n");\r
-                fileBuffer.append("  Status = EFI_SUCCESS;\n\n");\r
+                fileBuffer.append("  EFI_STATUS  Status;\r\n\r\n");\r
+                fileBuffer.append("  Status = EFI_SUCCESS;\r\n\r\n");\r
                 for (int i = 0; i < unloadImageList.length; i++) {\r
                     if (i == 0) {\r
                         fileBuffer.append("  Status = ");\r
                         fileBuffer.append(unloadImageList[i]);\r
-                        fileBuffer.append("(ImageHandle);\n");\r
+                        fileBuffer.append("(ImageHandle);\r\n");\r
                     } else {\r
-                        fileBuffer.append("  if (EFI_ERROR (Status)) {\n");\r
+                        fileBuffer.append("  if (EFI_ERROR (Status)) {\r\n");\r
                         fileBuffer.append("    ");\r
                         fileBuffer.append(unloadImageList[i]);\r
-                        fileBuffer.append("(ImageHandle);\n");\r
-                        fileBuffer.append("  } else {\n");\r
+                        fileBuffer.append("(ImageHandle);\r\n");\r
+                        fileBuffer.append("  } else {\r\n");\r
                         fileBuffer.append("    Status = ");\r
                         fileBuffer.append(unloadImageList[i]);\r
-                        fileBuffer.append("(ImageHandle);\n");\r
-                        fileBuffer.append("  }\n");\r
+                        fileBuffer.append("(ImageHandle);\r\n");\r
+                        fileBuffer.append("  }\r\n");\r
                     }\r
                 }\r
-                fileBuffer.append("  return Status;\n");\r
+                fileBuffer.append("  return Status;\r\n");\r
             }\r
-            fileBuffer.append("}\n\n");\r
+            fileBuffer.append("}\r\n\r\n");\r
             break;\r
         }\r
     }\r
@@ -1228,7 +1225,7 @@ public class AutoGen {
             ppiKeyWord = ppiIterator.next().toString();\r
             cNameGuid = GlobalData.getPpiGuid(this.mDepPkgList, ppiKeyWord);\r
             if (cNameGuid != null) {\r
-                fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");\r
+                fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");\r
                 fileBuffer.append(cNameGuid[0]);\r
                 fileBuffer.append(" =     { ");\r
                 fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));\r
@@ -1283,7 +1280,7 @@ public class AutoGen {
             protocolKeyWord = protocolIterator.next().toString();\r
             cNameGuid = GlobalData.getProtocolGuid(this.mDepPkgList, protocolKeyWord);\r
             if (cNameGuid != null) {\r
-                fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");\r
+                fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");\r
                 fileBuffer.append(cNameGuid[0]);\r
                 fileBuffer.append(" =     { ");\r
                 fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));\r
@@ -1325,7 +1322,7 @@ public class AutoGen {
             cNameGuid = GlobalData.getGuid(this.mDepPkgList, guidKeyWord);\r
 \r
             if (cNameGuid != null) {\r
-                fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");\r
+                fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");\r
                 fileBuffer.append(cNameGuid[0]);\r
                 fileBuffer.append(" =     { ");\r
                 fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));\r
@@ -1379,7 +1376,7 @@ public class AutoGen {
                  String buffer for AutoGen.c\r
       @throws Exception\r
     **/\r
-    void LibConstructorToAutogenH(String moduleType, StringBuffer fileBuffer) throws EdkException {\r
+    void LibConstructorToAutogenH(String moduleType) throws EdkException {\r
         boolean isFirst = true;\r
 \r
         //\r
@@ -1396,32 +1393,32 @@ public class AutoGen {
         // module type.\r
         //\r
         if (moduleType.equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
-            fileBuffer.append("RETURN_STATUS\n");\r
-            fileBuffer.append("EFIAPI\n");\r
-            fileBuffer.append(libConstructName);\r
-            fileBuffer.append(" (\n");\r
-            fileBuffer.append("  VOID\n");\r
-            fileBuffer.append("  );\n");\r
+            functionDeclarations.append("RETURN_STATUS\r\n");\r
+            functionDeclarations.append("EFIAPI\r\n");\r
+            functionDeclarations.append(libConstructName);\r
+            functionDeclarations.append(" (\r\n");\r
+            functionDeclarations.append("  VOID\r\n");\r
+            functionDeclarations.append("  );\r\n");\r
         } else {\r
             switch (CommonDefinition.getModuleType(moduleType)) {\r
             case CommonDefinition.ModuleTypeBase:\r
-                fileBuffer.append("RETURN_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append(libConstructName);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  VOID\n");\r
-                fileBuffer.append("  );\n");\r
+                functionDeclarations.append("RETURN_STATUS\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(libConstructName);\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  VOID\r\n");\r
+                functionDeclarations.append("  );\r\n");\r
                 break;\r
 \r
             case CommonDefinition.ModuleTypePeiCore:\r
             case CommonDefinition.ModuleTypePeim:\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append(libConstructName);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\n");\r
-                fileBuffer.append("  IN EFI_PEI_SERVICES          **PeiServices\n");\r
-                fileBuffer.append("  );\n");\r
+                functionDeclarations.append("EFI_STATUS\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(libConstructName);\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
                 break;\r
 \r
             case CommonDefinition.ModuleTypeDxeCore:\r
@@ -1431,13 +1428,13 @@ public class AutoGen {
             case CommonDefinition.ModuleTypeDxeSalDriver:\r
             case CommonDefinition.ModuleTypeUefiDriver:\r
             case CommonDefinition.ModuleTypeUefiApplication:\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append(libConstructName);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-                fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-                fileBuffer.append("  );\n");\r
+                functionDeclarations.append("EFI_STATUS\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(libConstructName);\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
                 break;\r
 \r
             }\r
@@ -1458,7 +1455,7 @@ public class AutoGen {
                  String buffer for AutoGen.c\r
       @throws Exception\r
     **/\r
-    void LibDestructorToAutogenH(String moduleType, StringBuffer fileBuffer) throws EdkException {\r
+    void LibDestructorToAutogenH(String moduleType) throws EdkException {\r
         boolean isFirst = true;\r
         String libDestructName = saq.getLibDestructorName();\r
         if (libDestructName == null) {\r
@@ -1466,31 +1463,31 @@ public class AutoGen {
         }\r
 \r
         if (moduleType.equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
-            fileBuffer.append("RETURN_STATUS\n");\r
-            fileBuffer.append("EFIAPI\n");\r
-            fileBuffer.append(libDestructName);\r
-            fileBuffer.append(" (\n");\r
-            fileBuffer.append("  VOID\n");\r
-            fileBuffer.append("  );\n");\r
+            functionDeclarations.append("RETURN_STATUS\r\n");\r
+            functionDeclarations.append("EFIAPI\r\n");\r
+            functionDeclarations.append(libDestructName);\r
+            functionDeclarations.append(" (\r\n");\r
+            functionDeclarations.append("  VOID\r\n");\r
+            functionDeclarations.append("  );\r\n");\r
         } else {\r
             switch (CommonDefinition.getModuleType(moduleType)) {\r
             case CommonDefinition.ModuleTypeBase:\r
-                fileBuffer.append("RETURN_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append(libDestructName);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  VOID\n");\r
-                fileBuffer.append("  );\n");\r
+                functionDeclarations.append("RETURN_STATUS\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(libDestructName);\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  VOID\r\n");\r
+                functionDeclarations.append("  );\r\n");\r
                 break;\r
             case CommonDefinition.ModuleTypePeiCore:\r
             case CommonDefinition.ModuleTypePeim:\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append(libDestructName);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\n");\r
-                fileBuffer.append("  IN EFI_PEI_SERVICES          **PeiServices\n");\r
-                fileBuffer.append("  );\n");\r
+                functionDeclarations.append("EFI_STATUS\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(libDestructName);\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
                 break;\r
             case CommonDefinition.ModuleTypeDxeCore:\r
             case CommonDefinition.ModuleTypeDxeDriver:\r
@@ -1499,13 +1496,13 @@ public class AutoGen {
             case CommonDefinition.ModuleTypeDxeSalDriver:\r
             case CommonDefinition.ModuleTypeUefiDriver:\r
             case CommonDefinition.ModuleTypeUefiApplication:\r
-                fileBuffer.append("EFI_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append(libDestructName);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-                fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-                fileBuffer.append("  );\n");\r
+                functionDeclarations.append("EFI_STATUS\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(libDestructName);\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
                 break;\r
             }\r
         }\r
@@ -1535,32 +1532,32 @@ public class AutoGen {
         //\r
         for (int i = 0; i < libInstanceList.size(); i++) {\r
             if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
-                fileBuffer.append("RETURN_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append(libInstanceList.get(i)[0]);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  VOID\n");\r
-                fileBuffer.append("  );\n");\r
+                functionDeclarations.append("RETURN_STATUS\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(libInstanceList.get(i)[0]);\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  VOID\r\n");\r
+                functionDeclarations.append("  );\r\n");\r
             } else {\r
                 switch (CommonDefinition.getModuleType(moduleType)) {\r
                 case CommonDefinition.ModuleTypeBase:\r
-                    fileBuffer.append("RETURN_STATUS\n");\r
-                    fileBuffer.append("EFIAPI\n");\r
-                    fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append(" (\n");\r
-                    fileBuffer.append("  VOID\n");\r
-                    fileBuffer.append("  );\n");\r
+                    functionDeclarations.append("RETURN_STATUS\r\n");\r
+                    functionDeclarations.append("EFIAPI\r\n");\r
+                    functionDeclarations.append(libInstanceList.get(i)[0]);\r
+                    functionDeclarations.append(" (\r\n");\r
+                    functionDeclarations.append("  VOID\r\n");\r
+                    functionDeclarations.append("  );\r\n");\r
                     break;\r
 \r
                 case CommonDefinition.ModuleTypePeiCore:\r
                 case CommonDefinition.ModuleTypePeim:\r
-                    fileBuffer.append("EFI_STATUS\n");\r
-                    fileBuffer.append("EFIAPI\n");\r
-                    fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append(" (\n");\r
-                    fileBuffer.append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\n");\r
-                    fileBuffer.append("  IN EFI_PEI_SERVICES          **PeiServices\n");\r
-                    fileBuffer.append("  );\n");\r
+                    functionDeclarations.append("EFI_STATUS\r\n");\r
+                    functionDeclarations.append("EFIAPI\r\n");\r
+                    functionDeclarations.append(libInstanceList.get(i)[0]);\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
                     break;\r
 \r
                 case CommonDefinition.ModuleTypeDxeCore:\r
@@ -1570,13 +1567,13 @@ public class AutoGen {
                 case CommonDefinition.ModuleTypeDxeSalDriver:\r
                 case CommonDefinition.ModuleTypeUefiDriver:\r
                 case CommonDefinition.ModuleTypeUefiApplication:\r
-                    fileBuffer.append("EFI_STATUS\n");\r
-                    fileBuffer.append("EFIAPI\n");\r
-                    fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append(" (\n");\r
-                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-                    fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-                    fileBuffer.append("  );\n");\r
+                    functionDeclarations.append("EFI_STATUS\r\n");\r
+                    functionDeclarations.append("EFIAPI\r\n");\r
+                    functionDeclarations.append(libInstanceList.get(i)[0]);\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
                     break;\r
 \r
                 }\r
@@ -1586,19 +1583,19 @@ public class AutoGen {
         //\r
         // Add ProcessLibraryConstructorList in AutoGen.c\r
         //\r
-        fileBuffer.append("VOID\n");\r
-        fileBuffer.append("EFIAPI\n");\r
-        fileBuffer.append("ProcessLibraryConstructorList (\n");\r
+        fileBuffer.append("VOID\r\n");\r
+        fileBuffer.append("EFIAPI\r\n");\r
+        fileBuffer.append("ProcessLibraryConstructorList (\r\n");\r
         switch (CommonDefinition.getModuleType(moduleType)) {\r
         case CommonDefinition.ModuleTypeBase:\r
-            fileBuffer.append("  VOID\n");\r
+            fileBuffer.append("  VOID\r\n");\r
             break;\r
 \r
         case CommonDefinition.ModuleTypePeiCore:\r
         case CommonDefinition.ModuleTypePeim:\r
-            fileBuffer.append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\n");\r
+            fileBuffer.append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r\n");\r
             fileBuffer\r
-            .append("  IN EFI_PEI_SERVICES          **PeiServices\n");\r
+            .append("  IN EFI_PEI_SERVICES          **PeiServices\r\n");\r
             break;\r
 \r
         case CommonDefinition.ModuleTypeDxeCore:\r
@@ -1608,42 +1605,39 @@ public class AutoGen {
         case CommonDefinition.ModuleTypeDxeSalDriver:\r
         case CommonDefinition.ModuleTypeUefiDriver:\r
         case CommonDefinition.ModuleTypeUefiApplication:\r
-            fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-            fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
+            fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\r\n");\r
+            fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\r\n");\r
             break;\r
         }\r
 \r
-        fileBuffer.append("  )\n");\r
-        fileBuffer.append("{\n");\r
+        fileBuffer.append("  )\r\n");\r
+        fileBuffer.append("{\r\n");\r
         //\r
         // If no constructor function, return EFI_SUCCESS.\r
         //\r
-        //if (libInstanceList.size() == 0){\r
-        //   fileBuffer.append("  return EFI_SUCCESS;\n");\r
-        //}\r
         for (int i = 0; i < libInstanceList.size(); i++) {\r
             if (isFirst) {\r
-                fileBuffer.append("  EFI_STATUS  Status;\n");\r
-                fileBuffer.append("  Status = EFI_SUCCESS;\n");\r
-                fileBuffer.append("\n");\r
+                fileBuffer.append("  EFI_STATUS  Status;\r\n");\r
+                fileBuffer.append("  Status = EFI_SUCCESS;\r\n");\r
+                fileBuffer.append("\r\n");\r
                 isFirst = false;\r
             }\r
             if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
                 fileBuffer.append("  Status = ");\r
                 fileBuffer.append(libInstanceList.get(i)[0]);\r
-                fileBuffer.append("();\n");\r
+                fileBuffer.append("();\r\n");\r
             } else {\r
                 switch (CommonDefinition.getModuleType(moduleType)) {\r
                 case CommonDefinition.ModuleTypeBase:\r
                     fileBuffer.append("  Status = ");\r
                     fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append("();\n");\r
+                    fileBuffer.append("();\r\n");\r
                     break;\r
                 case CommonDefinition.ModuleTypePeiCore:\r
                 case CommonDefinition.ModuleTypePeim:\r
                     fileBuffer.append("  Status = ");\r
                     fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append(" (FfsHeader, PeiServices);\n");\r
+                    fileBuffer.append(" (FfsHeader, PeiServices);\r\n");\r
                     break;\r
                 case CommonDefinition.ModuleTypeDxeCore:\r
                 case CommonDefinition.ModuleTypeDxeDriver:\r
@@ -1654,16 +1648,16 @@ public class AutoGen {
                 case CommonDefinition.ModuleTypeUefiApplication:\r
                     fileBuffer.append("  Status = ");\r
                     fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append(" (ImageHandle, SystemTable);\n");\r
+                    fileBuffer.append(" (ImageHandle, SystemTable);\r\n");\r
                     break;\r
                 default:\r
                     EdkLog.log(EdkLog.EDK_INFO,"Autogen doesn't know how to deal with module type - " + moduleType + "!");\r
                 }\r
 \r
             }\r
-            fileBuffer.append("  ASSERT_EFI_ERROR (Status);\n");\r
+            fileBuffer.append("  ASSERT_EFI_ERROR (Status);\r\n");\r
         }\r
-        fileBuffer.append("}\n");\r
+        fileBuffer.append("}\r\n");\r
     }\r
 \r
     /**\r
@@ -1685,31 +1679,31 @@ public class AutoGen {
         boolean isFirst = true;\r
         for (int i = 0; i < libInstanceList.size(); i++) {\r
             if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
-                fileBuffer.append("RETURN_STATUS\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append(libInstanceList.get(i)[0]);\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  VOID\n");\r
-                fileBuffer.append("  );\n");\r
+                functionDeclarations.append("RETURN_STATUS\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(libInstanceList.get(i)[0]);\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  VOID\r\n");\r
+                functionDeclarations.append("  );\r\n");\r
             } else {\r
                 switch (CommonDefinition.getModuleType(moduleType)) {\r
                 case CommonDefinition.ModuleTypeBase:\r
-                    fileBuffer.append("RETURN_STATUS\n");\r
-                    fileBuffer.append("EFIAPI\n");\r
-                    fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append(" (\n");\r
-                    fileBuffer.append("  VOID\n");\r
-                    fileBuffer.append("  );\n");\r
+                    functionDeclarations.append("RETURN_STATUS\r\n");\r
+                    functionDeclarations.append("EFIAPI\r\n");\r
+                    functionDeclarations.append(libInstanceList.get(i)[0]);\r
+                    functionDeclarations.append(" (\r\n");\r
+                    functionDeclarations.append("  VOID\r\n");\r
+                    functionDeclarations.append("  );\r\n");\r
                     break;\r
                 case CommonDefinition.ModuleTypePeiCore:\r
                 case CommonDefinition.ModuleTypePeim:\r
-                    fileBuffer.append("EFI_STATUS\n");\r
-                    fileBuffer.append("EFIAPI\n");\r
-                    fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append(" (\n");\r
-                    fileBuffer.append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\n");\r
-                    fileBuffer.append("  IN EFI_PEI_SERVICES          **PeiServices\n");\r
-                    fileBuffer.append("  );\n");\r
+                    functionDeclarations.append("EFI_STATUS\r\n");\r
+                    functionDeclarations.append("EFIAPI\r\n");\r
+                    functionDeclarations.append(libInstanceList.get(i)[0]);\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
                     break;\r
                 case CommonDefinition.ModuleTypeDxeCore:\r
                 case CommonDefinition.ModuleTypeDxeDriver:\r
@@ -1718,13 +1712,13 @@ public class AutoGen {
                 case CommonDefinition.ModuleTypeDxeSalDriver:\r
                 case CommonDefinition.ModuleTypeUefiDriver:\r
                 case CommonDefinition.ModuleTypeUefiApplication:\r
-                    fileBuffer.append("EFI_STATUS\n");\r
-                    fileBuffer.append("EFIAPI\n");\r
-                    fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append(" (\n");\r
-                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-                    fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-                    fileBuffer.append("  );\n");\r
+                    functionDeclarations.append("EFI_STATUS\r\n");\r
+                    functionDeclarations.append("EFIAPI\r\n");\r
+                    functionDeclarations.append(libInstanceList.get(i)[0]);\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
                     break;\r
                 }\r
             }\r
@@ -1745,37 +1739,37 @@ public class AutoGen {
         case CommonDefinition.ModuleTypeDxeSalDriver:\r
         case CommonDefinition.ModuleTypeUefiDriver:\r
         case CommonDefinition.ModuleTypeUefiApplication:\r
-            fileBuffer.append("VOID\n");\r
-            fileBuffer.append("EFIAPI\n");\r
-            fileBuffer.append("ProcessLibraryDestructorList (\n");\r
-            fileBuffer.append("  IN EFI_HANDLE        ImageHandle,\n");\r
-            fileBuffer.append("  IN EFI_SYSTEM_TABLE  *SystemTable\n");\r
-            fileBuffer.append("  )\n");\r
-            fileBuffer.append("{\n");\r
+            fileBuffer.append("VOID\r\n");\r
+            fileBuffer.append("EFIAPI\r\n");\r
+            fileBuffer.append("ProcessLibraryDestructorList (\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
+            fileBuffer.append("{\r\n");\r
             //\r
             // If no library destructor function, return EFI_SUCCESS.\r
             //\r
 \r
             for (int i = 0; i < libInstanceList.size(); i++) {\r
                 if (isFirst) {\r
-                    fileBuffer.append("  EFI_STATUS  Status;\n");\r
-                    fileBuffer.append("  Status = EFI_SUCCESS;\n");\r
-                    fileBuffer.append("\n");\r
+                    fileBuffer.append("  EFI_STATUS  Status;\r\n");\r
+                    fileBuffer.append("  Status = EFI_SUCCESS;\r\n");\r
+                    fileBuffer.append("\r\n");\r
                     isFirst = false;\r
                 }\r
                 if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
                     fileBuffer.append("  Status = ");\r
                     fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append("();\n");\r
-                    fileBuffer.append("  VOID\n");\r
+                    fileBuffer.append("();\r\n");\r
+                    fileBuffer.append("  VOID\r\n");\r
                 } else {\r
                     fileBuffer.append("  Status = ");\r
                     fileBuffer.append(libInstanceList.get(i)[0]);\r
-                    fileBuffer.append("(ImageHandle, SystemTable);\n");\r
-                    fileBuffer.append("  ASSERT_EFI_ERROR (Status);\n");\r
+                    fileBuffer.append("(ImageHandle, SystemTable);\r\n");\r
+                    fileBuffer.append("  ASSERT_EFI_ERROR (Status);\r\n");\r
                 }\r
             }\r
-            fileBuffer.append("}\n");\r
+            fileBuffer.append("}\r\n");\r
             break;\r
         }\r
     }\r
@@ -1811,7 +1805,7 @@ public class AutoGen {
             if (driverBindingGroup[i][0] != null) {\r
                 fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL ");\r
                 fileBuffer.append(driverBindingGroup[i][0]);\r
-                fileBuffer.append(";\n");\r
+                fileBuffer.append(";\r\n");\r
             }\r
         }\r
 \r
@@ -1825,7 +1819,7 @@ public class AutoGen {
                         BitMask |= 0x01;\r
                         fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL ");\r
                         fileBuffer.append(driverBindingGroup[i][1]);\r
-                        fileBuffer.append(";\n");\r
+                        fileBuffer.append(";\r\n");\r
                     } else {\r
                         throw new AutoGenException("DriverBinding can't be empty!!");\r
                     }\r
@@ -1842,7 +1836,7 @@ public class AutoGen {
                     BitMask |= 0x02;\r
                     fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");\r
                     fileBuffer.append(driverBindingGroup[i][2]);\r
-                    fileBuffer.append(";\n");\r
+                    fileBuffer.append(";\r\n");\r
                 } else {\r
                     throw new AutoGenException("DriverBinding can't be empty!!");\r
                 }\r
@@ -1859,7 +1853,7 @@ public class AutoGen {
                         BitMask |= 0x04;\r
                         fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");\r
                         fileBuffer.append(driverBindingGroup[i][3]);\r
-                        fileBuffer.append(";\n");\r
+                        fileBuffer.append(";\r\n");\r
                     } else {\r
                         throw new AutoGenException("DriverBinding can't be empty!!");\r
                     }\r
@@ -1873,7 +1867,7 @@ public class AutoGen {
         //\r
         fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverModelProtocolBitmask = ");\r
         fileBuffer.append(Integer.toString(BitMask));\r
-        fileBuffer.append(";\n");\r
+        fileBuffer.append(";\r\n");\r
 \r
         //\r
         // Write driver module protocol list entry\r
@@ -1881,7 +1875,7 @@ public class AutoGen {
         fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN  _gDriverModelProtocolListEntries = ");\r
 \r
         fileBuffer.append(Integer.toString(driverBindingGroup.length));\r
-        fileBuffer.append(";\n");\r
+        fileBuffer.append(";\r\n");\r
 \r
         //\r
         // Write drive module protocol list to autogen.c\r
@@ -1898,10 +1892,10 @@ public class AutoGen {
             //\r
             //  DriverBinding\r
             // \r
-            fileBuffer.append("\n {\n");\r
+            fileBuffer.append("\r\n {\r\n");\r
             fileBuffer.append("  &");\r
             fileBuffer.append(driverBindingGroup[i][0]);\r
-            fileBuffer.append(", \n");\r
+            fileBuffer.append(", \r\n");\r
 \r
             //\r
             //  ComponentName\r
@@ -1909,9 +1903,9 @@ public class AutoGen {
             if (driverBindingGroup[i][1] != null && componentNamePcd != true) {\r
                 fileBuffer.append("  &");\r
                 fileBuffer.append(driverBindingGroup[i][1]);\r
-                fileBuffer.append(", \n");\r
+                fileBuffer.append(", \r\n");\r
             } else {\r
-                fileBuffer.append("  NULL, \n");\r
+                fileBuffer.append("  NULL, \r\n");\r
             }\r
 \r
             //\r
@@ -1920,9 +1914,9 @@ public class AutoGen {
             if (driverBindingGroup[i][2] != null) {\r
                 fileBuffer.append("  &");\r
                 fileBuffer.append(driverBindingGroup[i][2]);\r
-                fileBuffer.append(", \n");\r
+                fileBuffer.append(", \r\n");\r
             } else {\r
-                fileBuffer.append("  NULL, \n");\r
+                fileBuffer.append("  NULL, \r\n");\r
             }\r
 \r
             //\r
@@ -1931,15 +1925,82 @@ public class AutoGen {
             if (driverBindingGroup[i][3] != null && driverDiagnostPcd != true) {\r
                 fileBuffer.append("  &");\r
                 fileBuffer.append(driverBindingGroup[i][3]);\r
-                fileBuffer.append(", \n");\r
+                fileBuffer.append(", \r\n");\r
             } else {\r
-                fileBuffer.append("  NULL, \n");\r
+                fileBuffer.append("  NULL, \r\n");\r
             }\r
             fileBuffer.append("  }");\r
         }\r
 \r
         if (driverBindingGroup.length > 0) {\r
-            fileBuffer.append("\n};\n");\r
+            fileBuffer.append("\r\n};\r\n");\r
+        }\r
+    }\r
+\r
+    /**\r
+      ExternCallBackToAutoGenC\r
+     \r
+      This function adds <SetVirtualAddressMapCallBack> and\r
+      <ExitBootServicesCallBack> infomation to AutoGen.c\r
+     \r
+      @param fileBuffer\r
+                 String buffer for AutoGen.c\r
+      @throws BuildException\r
+    **/\r
+    void ExternCallBackToAutoGenH(String moduleType)\r
+    throws EdkException {\r
+        //\r
+        // Collect module's <SetVirtualAddressMapCallBack> and\r
+        // <ExitBootServiceCallBack> and add to setVirtualAddList\r
+        //  exitBootServiceList.\r
+        //\r
+        String[] setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
+        String[] exitBoots = saq.getExitBootServicesCallBackArray();\r
+        //\r
+        //  Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>\r
+        //  and <ExitBootServicesCallBack>\r
+        //\r
+        switch (CommonDefinition.getModuleType(moduleType)) {\r
+        case CommonDefinition.ModuleTypeDxeDriver:\r
+        case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
+        case CommonDefinition.ModuleTypeDxeSalDriver:\r
+        case CommonDefinition.ModuleTypeUefiDriver:\r
+        case CommonDefinition.ModuleTypeUefiApplication:\r
+            //\r
+            // Write SetVirtualAddressMap function definition.\r
+            //\r
+            for (int i = 0; setVirtuals != null && i < setVirtuals.length; i++) {\r
+                if (setVirtuals[i].equalsIgnoreCase("")) {\r
+                    continue;\r
+                }\r
+                functionDeclarations.append("VOID\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(setVirtuals[i]);\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  IN EFI_EVENT  Event,\r\n");\r
+                functionDeclarations.append("  IN VOID       *Context\r\n");\r
+                functionDeclarations.append("  );\r\n\r\n");\r
+            }\r
+\r
+            //\r
+            // Write DriverExitBootServices function definition.\r
+            //\r
+            for (int i = 0; exitBoots != null && i < exitBoots.length; i++) {\r
+                if (exitBoots[i].equalsIgnoreCase("")) {\r
+                    continue;\r
+                }\r
+\r
+                functionDeclarations.append("VOID\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(exitBoots[i]);\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  IN EFI_EVENT  Event,\r\n");\r
+                functionDeclarations.append("  IN VOID       *Context\r\n");\r
+                functionDeclarations.append("  );\r\n\r\n");\r
+            }\r
+            break;\r
+        default:\r
+            break;\r
         }\r
     }\r
 \r
@@ -2160,12 +2221,13 @@ public class AutoGen {
             }\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.append("\nGLOBAL_REMOVE_IF_UNREFERENCED  const UINTN _gDriverSetVirtualAddressMapEventCount = ");\r
+        fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED  const UINTN _gDriverSetVirtualAddressMapEventCount = ");\r
 \r
         //\r
         // If the list is not valid or has no entries set count to zero else\r
@@ -2183,14 +2245,14 @@ public class AutoGen {
         }\r
 \r
         fileBuffer.append(Integer.toString(Count));\r
-        fileBuffer.append(";\n\n");\r
+        fileBuffer.append(";\r\n\r\n");\r
         if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) {\r
             //\r
             // No data so make a NULL list\r
             //\r
-            fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\n");\r
-            fileBuffer.append("  NULL\n");\r
-            fileBuffer.append("};\n\n");\r
+            fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");\r
+            fileBuffer.append("  NULL\r\n");\r
+            fileBuffer.append("};\r\n\r\n");\r
         } else {\r
             //\r
             // Write SetVirtualAddressMap function definition.\r
@@ -2199,28 +2261,28 @@ public class AutoGen {
                 if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
                     break;\r
                 }\r
-                fileBuffer.append("VOID\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append(this.setVirtalAddList.get(i));\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  IN EFI_EVENT  Event,\n");\r
-                fileBuffer.append("  IN VOID       *Context\n");\r
-                fileBuffer.append("  );\n\n");\r
+                functionDeclarations.append("VOID\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(this.setVirtalAddList.get(i));\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  IN EFI_EVENT  Event,\r\n");\r
+                functionDeclarations.append("  IN VOID       *Context\r\n");\r
+                functionDeclarations.append("  );\r\n\r\n");\r
             }\r
 \r
             //\r
             // Write SetVirtualAddressMap entry point array.\r
             //\r
-            fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");\r
+            fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");\r
             for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
                 if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
                     break;\r
                 }\r
 \r
                 if (i == 0) {\r
-                    fileBuffer.append("\n  ");\r
+                    fileBuffer.append("\r\n  ");\r
                 } else {\r
-                    fileBuffer.append(",\n  ");\r
+                    fileBuffer.append(",\r\n  ");\r
                 }\r
 \r
                 fileBuffer.append(this.setVirtalAddList.get(i));\r
@@ -2228,8 +2290,8 @@ public class AutoGen {
             //\r
             // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.\r
             //\r
-            fileBuffer.append(",\n  NULL");\r
-            fileBuffer.append("\n};\n\n");\r
+            fileBuffer.append(",\r\n  NULL");\r
+            fileBuffer.append("\r\n};\r\n\r\n");\r
         }\r
     }\r
 \r
@@ -2238,8 +2300,7 @@ public class AutoGen {
         //\r
         // Entry point lib for these module types needs to know the count.\r
         //\r
-        fileBuffer\r
-        .append("\nGLOBAL_REMOVE_IF_UNREFERENCED  const UINTN _gDriverExitBootServicesEventCount = ");\r
+        fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED  const UINTN _gDriverExitBootServicesEventCount = ");\r
 \r
         //\r
         // If the list is not valid or has no entries set count to zero else\r
@@ -2256,15 +2317,15 @@ public class AutoGen {
             Count = i;\r
         }\r
         fileBuffer.append(Integer.toString(Count));\r
-        fileBuffer.append(";\n\n");\r
+        fileBuffer.append(";\r\n\r\n");\r
 \r
         if (this.exitBootServiceList == null || this.exitBootServiceList.size() == 0) {\r
             //      \r
             // No data so make a NULL list.\r
             //\r
-            fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\n");\r
-            fileBuffer.append("  NULL\n");\r
-            fileBuffer.append("};\n\n");\r
+            fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");\r
+            fileBuffer.append("  NULL\r\n");\r
+            fileBuffer.append("};\r\n\r\n");\r
         } else {\r
             //\r
             // Write DriverExitBootServices function definition.\r
@@ -2274,34 +2335,34 @@ public class AutoGen {
                     break;\r
                 }\r
 \r
-                fileBuffer.append("VOID\n");\r
-                fileBuffer.append("EFIAPI\n");\r
-                fileBuffer.append(this.exitBootServiceList.get(i));\r
-                fileBuffer.append(" (\n");\r
-                fileBuffer.append("  IN EFI_EVENT  Event,\n");\r
-                fileBuffer.append("  IN VOID       *Context\n");\r
-                fileBuffer.append("  );\n\n");\r
+                functionDeclarations.append("VOID\r\n");\r
+                functionDeclarations.append("EFIAPI\r\n");\r
+                functionDeclarations.append(this.exitBootServiceList.get(i));\r
+                functionDeclarations.append(" (\r\n");\r
+                functionDeclarations.append("  IN EFI_EVENT  Event,\r\n");\r
+                functionDeclarations.append("  IN VOID       *Context\r\n");\r
+                functionDeclarations.append("  );\r\n\r\n");\r
             }\r
 \r
             //\r
             // Write DriverExitBootServices entry point array.\r
             //\r
-            fileBuffer.append("\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");\r
+            fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");\r
             for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
                 if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
                     break;\r
                 }\r
 \r
                 if (i == 0) {\r
-                    fileBuffer.append("\n  ");\r
+                    fileBuffer.append("\r\n  ");\r
                 } else {\r
-                    fileBuffer.append(",\n  ");\r
+                    fileBuffer.append(",\r\n  ");\r
                 }\r
                 fileBuffer.append(this.exitBootServiceList.get(i));\r
             }\r
 \r
-            fileBuffer.append(",\n  NULL");\r
-            fileBuffer.append("\n};\n\n");\r
+            fileBuffer.append(",\r\n  NULL");\r
+            fileBuffer.append("\r\n};\r\n\r\n");\r
         }   \r
     }\r
     /**\r