]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Remove DEBUG output statement for PEI&DXE core to fix boot failure issue
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / autogen / AutoGen.java
index 0d757b923b1c4b769096326b074db54482fdbf83..5b917b9ab499c7dc7f2893d827d1e3bdb375ac95 100644 (file)
@@ -108,7 +108,7 @@ public class AutoGen {
     ///\r
     ///  For non library module, add its library instance's construct and destructor to\r
     ///  list. String[0] recode LibConstructor name, String[1] recode Lib instance \r
-       ///  module type.\r
+    ///  module type.\r
     ///\r
     private List<String[]> libConstructList = new ArrayList<String[]>();\r
     private List<String[]> libDestructList = new ArrayList<String[]>();\r
@@ -119,8 +119,17 @@ public class AutoGen {
     private List<String> setVirtalAddList = new ArrayList<String>();\r
     private List<String> exitBootServiceList = new ArrayList<String>();\r
 \r
+    //\r
+    // flag of PcdComponentNameDisable, PcdDriverDiagnosticDisable \r
+    //\r
+    private boolean componentNamePcd = false;\r
+    private boolean driverDiagnostPcd = false;\r
+\r
+    //\r
+    // Instance of SurfaceAreaQuery\r
+    //\r
     private SurfaceAreaQuery saq = null;\r
-    \r
+\r
     private ModuleIdentification parentId = null;\r
 \r
     /**\r
@@ -160,25 +169,25 @@ public class AutoGen {
                  "false" failed\r
     **/\r
     private boolean saveFile(String fileName, StringBuffer fileBuffer) {\r
-        \r
+\r
         File autoGenH = new File(fileName);\r
 \r
-            //\r
-            // if the file exists, compare their content\r
-            //\r
+        //\r
+        // if the file exists, compare their content\r
+        //\r
         if (autoGenH.exists()) {\r
             char[] oldFileBuffer = new char[(int) autoGenH.length()];\r
-                       try {\r
-                               FileReader fIn = new FileReader(autoGenH);\r
-                               fIn.read(oldFileBuffer, 0, (int) autoGenH.length());\r
+            try {\r
+                FileReader fIn = new FileReader(autoGenH);\r
+                fIn.read(oldFileBuffer, 0, (int) autoGenH.length());\r
                 fIn.close();\r
-                       } catch (IOException e) {\r
-                               EdkLog.log(EdkLog.EDK_INFO, this.moduleId.getName() \r
-                                                               + "'s " \r
-                                                               + fileName \r
-                                                               + " is exist, but can't be open!!");\r
-                               return false;\r
-                       }\r
+            } catch (IOException e) {\r
+                EdkLog.log(EdkLog.EDK_INFO, this.moduleId.getName() \r
+                           + "'s " \r
+                           + fileName \r
+                           + " is exist, but can't be open!!");\r
+                return false;\r
+            }\r
 \r
             //\r
             // if we got the same file, don't re-generate it to prevent\r
@@ -188,19 +197,19 @@ public class AutoGen {
                 return true;\r
             }\r
         }\r
-        \r
-               try {\r
-                       FileWriter fOut = new FileWriter(autoGenH);\r
+\r
+        try {\r
+            FileWriter fOut = new FileWriter(autoGenH);\r
             fOut.write(fileBuffer.toString());\r
-                       fOut.flush();\r
+            fOut.flush();\r
             fOut.close();\r
-               } catch (IOException e) {\r
-                       EdkLog.log(EdkLog.EDK_INFO, this.moduleId.getName() \r
-                                                               + "'s " \r
-                                                               + fileName \r
-                                                               + " can't be create!!");\r
-                       return false;\r
-               } \r
+        } catch (IOException e) {\r
+            EdkLog.log(EdkLog.EDK_INFO, this.moduleId.getName() \r
+                       + "'s " \r
+                       + fileName \r
+                       + " can't be create!!");\r
+            return false;\r
+        }\r
         return true;\r
     }\r
 \r
@@ -214,27 +223,21 @@ public class AutoGen {
                   Failed to creat AutoGen.c & AutoGen.h.\r
     **/\r
     public void genAutogen() throws EdkException {\r
-        try {\r
-            //\r
-            // If outputPath do not exist, create it.\r
-            //\r
-            File path = new File(outputPath);\r
-            path.mkdirs();\r
-               } catch (Exception e) {\r
-            throw new AutoGenException(\r
-                                    "Failed to create "\r
-                                    + outputPath + " directory");\r
+        //\r
+        // If outputPath do not exist, create it.\r
+        //\r
+        File path = new File(outputPath);\r
+        path.mkdirs();\r
+\r
+        //\r
+        // Check current is library or not, then call the corresponding\r
+        // function.\r
+        //\r
+        if (this.moduleId.isLibrary()) {\r
+            libGenAutogen();\r
+        } else {\r
+            moduleGenAutogen();\r
         }\r
-            \r
-               //\r
-               // Check current is library or not, then call the corresponding\r
-               // function.\r
-               //\r
-               if (this.moduleId.isLibrary()) {\r
-                       libGenAutogen();\r
-               } else {\r
-                       moduleGenAutogen();\r
-               }\r
     }\r
 \r
     /**\r
@@ -246,9 +249,11 @@ public class AutoGen {
                   Faile to create module AutoGen.c & AutoGen.h.\r
     **/\r
     void moduleGenAutogen() throws EdkException {\r
-               collectLibInstanceInfo();\r
-               moduleGenAutogenC();\r
-               moduleGenAutogenH();\r
+        setPcdComponentName();\r
+        setPcdDriverDiagnostic();\r
+        collectLibInstanceInfo();\r
+        moduleGenAutogenC();\r
+        moduleGenAutogenH();\r
     }\r
 \r
     /**\r
@@ -260,8 +265,8 @@ public class AutoGen {
                   Faile to create library AutoGen.c & AutoGen.h\r
     **/\r
     void libGenAutogen() throws EdkException {\r
-               libGenAutogenC();\r
-               libGenAutogenH();\r
+        libGenAutogenC();\r
+        libGenAutogenH();\r
     }\r
 \r
     /**\r
@@ -291,14 +296,14 @@ public class AutoGen {
         // #def ${BseeName}_AUTOGENH\r
         //\r
         fileBuffer.append(CommonDefinition.IFNDEF \r
-                                     + CommonDefinition.AUTOGENH\r
-                                     + this.moduleId.getGuid().replaceAll("-", "_") \r
-                                     + ToolDefinitions.LINE_SEPARATOR);\r
+                          + CommonDefinition.AUTOGENH\r
+                          + this.moduleId.getGuid().replaceAll("-", "_") \r
+                          + ToolDefinitions.LINE_SEPARATOR);\r
         fileBuffer.append(CommonDefinition.DEFINE \r
-                                     + CommonDefinition.AUTOGENH\r
-                                     + this.moduleId.getGuid().replaceAll("-", "_") \r
-                                     + ToolDefinitions.LINE_SEPARATOR \r
-                                     + ToolDefinitions.LINE_SEPARATOR);\r
+                          + CommonDefinition.AUTOGENH\r
+                          + this.moduleId.getGuid().replaceAll("-", "_") \r
+                          + ToolDefinitions.LINE_SEPARATOR \r
+                          + ToolDefinitions.LINE_SEPARATOR);\r
 \r
         //\r
         // Write the specification version and release version at the begine\r
@@ -436,10 +441,10 @@ public class AutoGen {
         // Write EntryPoint to autgoGen.c\r
         //\r
         String[] entryPointList = saq.getModuleEntryPointArray();\r
-               String[] unloadImageList = saq.getModuleUnloadImageArray();\r
+        String[] unloadImageList = saq.getModuleUnloadImageArray();\r
         EntryPointToAutoGen(CommonDefinition.remDupString(entryPointList), \r
-                                       CommonDefinition.remDupString(unloadImageList),\r
-                                       fileBuffer);\r
+                            CommonDefinition.remDupString(unloadImageList),\r
+                            fileBuffer);\r
 \r
         pcdDriverType = saq.getPcdDriverType();\r
 \r
@@ -453,13 +458,11 @@ public class AutoGen {
         //\r
         String guid = CommonDefinition.formatGuidName(saq.getModuleGuid());\r
         if (this.moduleId.getModuleType().equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
-                       fileBuffer\r
-            .append("GLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = {");\r
-               } else {\r
-                       fileBuffer\r
-            .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");\r
-               }\r
-        \r
+            fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = {");\r
+        } else {\r
+            fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");\r
+        }\r
+\r
         if (guid == null) {\r
             throw new AutoGenException("Guid value must set!\n");\r
         }\r
@@ -508,7 +511,7 @@ public class AutoGen {
                                                  null,\r
                                                  pcdDriverType, \r
                                                  parentId);\r
-        \r
+\r
         this.myPcdAutogen.execute();\r
         if (this.myPcdAutogen != null) {\r
             fileBuffer.append("\r\n");\r
@@ -547,14 +550,14 @@ public class AutoGen {
         // #def ${BseeName}_AUTOGENH\r
         //\r
         fileBuffer.append(CommonDefinition.IFNDEF \r
-                                     + CommonDefinition.AUTOGENH\r
-                                     + this.moduleId.getGuid().replaceAll("-", "_") \r
-                                     + ToolDefinitions.LINE_SEPARATOR);\r
+                          + CommonDefinition.AUTOGENH\r
+                          + this.moduleId.getGuid().replaceAll("-", "_") \r
+                          + ToolDefinitions.LINE_SEPARATOR);\r
         fileBuffer.append(CommonDefinition.DEFINE \r
-                                     + CommonDefinition.AUTOGENH\r
-                                     + this.moduleId.getGuid().replaceAll("-", "_") \r
-                                     + ToolDefinitions.LINE_SEPARATOR \r
-                                     + ToolDefinitions.LINE_SEPARATOR);\r
+                          + CommonDefinition.AUTOGENH\r
+                          + this.moduleId.getGuid().replaceAll("-", "_") \r
+                          + ToolDefinitions.LINE_SEPARATOR \r
+                          + ToolDefinitions.LINE_SEPARATOR);\r
 \r
         //\r
         // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION\r
@@ -585,8 +588,7 @@ public class AutoGen {
         //\r
         // Write library class's related *.h file to autogen.h\r
         //\r
-        String[] libClassList = saq\r
-                                .getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch);\r
+        String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch);\r
         if (libClassList != null) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
             item = libClassIncludeH.iterator();\r
@@ -595,8 +597,7 @@ public class AutoGen {
             }\r
         }\r
 \r
-        libClassList = saq\r
-                       .getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
+        libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
         if (libClassList != null) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
             item = libClassIncludeH.iterator();\r
@@ -663,7 +664,7 @@ public class AutoGen {
         this.myPcdAutogen = new PCDAutoGenAction(moduleId,\r
                                                  arch,\r
                                                  true,\r
-                                                 saq.getModulePcdEntryNameArray(),\r
+                                                 saq.getModulePcdEntryNameArray(this.arch),\r
                                                  pcdDriverType, \r
                                                  parentId);\r
         this.myPcdAutogen.execute();\r
@@ -700,8 +701,8 @@ public class AutoGen {
         //\r
         for (int i = 0; i < libClassList.length; i++) {\r
             includeName = GlobalData.getLibraryClassHeaderFiles(\r
-                            saq.getDependencePkg(this.arch),\r
-                                                                libClassList[i]);\r
+                                                               saq.getDependencePkg(this.arch),\r
+                                                               libClassList[i]);\r
             if (includeName == null) {\r
                 throw new AutoGenException("Can not find library class ["\r
                                            + libClassList[i] + "] declaration in any SPD package. ");\r
@@ -773,7 +774,8 @@ public class AutoGen {
     throws EdkException {\r
 \r
         String typeStr = saq.getModuleType();\r
-               int unloadImageCount = 0;\r
+        String debugStr = "DEBUG ((EFI_D_INFO | EFI_D_LOAD, \"Module Entry Point (%s) 0x%%p\\n\", (VOID *)(UINTN)%s));\n";\r
+        int unloadImageCount = 0;\r
         int entryPointCount  = 0;\r
 \r
         //\r
@@ -785,24 +787,20 @@ public class AutoGen {
         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
+                                          "Module type = 'PEI_CORE', can have only one module entry point!");\r
             } else {\r
                 fileBuffer.append("EFI_STATUS\r\n");\r
                 fileBuffer.append(entryPointList[0]);\r
                 fileBuffer.append(" (\r\n");\r
-                fileBuffer\r
-                .append("  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r\n");\r
-                fileBuffer\r
-                .append("  IN VOID                        *OldCoreData\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\r
-                .append("  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r\n");\r
-                fileBuffer\r
-                .append("  IN VOID                        *OldCoreData\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
@@ -815,10 +813,8 @@ public class AutoGen {
         case CommonDefinition.ModuleTypeDxeCore:\r
             fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");\r
             if (entryPointList == null || entryPointList.length != 1) {\r
-                throw new AutoGenException(\r
-                                        "Module type = 'DXE_CORE', can have only one module entry point!");\r
+                throw new AutoGenException("Module type = 'DXE_CORE', can have only one module entry point!");\r
             } else {\r
-\r
                 fileBuffer.append("VOID\r\n");\r
                 fileBuffer.append(entryPointList[0]);\r
                 fileBuffer.append(" (\n");\r
@@ -840,8 +836,7 @@ public class AutoGen {
 \r
         case CommonDefinition.ModuleTypePeim:\r
             entryPointCount = 0;\r
-            fileBuffer\r
-            .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\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\r\n");\r
                 fileBuffer.append("EFIAPI\r\n");\r
@@ -858,13 +853,10 @@ public class AutoGen {
                 fileBuffer.append("EFI_STATUS\r\n");\r
                 fileBuffer.append(entryPointList[i]);\r
                 fileBuffer.append(" (\r\n");\r
-                fileBuffer\r
-                .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_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
 \r
             fileBuffer.append("EFI_STATUS\r\n");\r
@@ -875,6 +867,7 @@ public class AutoGen {
             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);\r\n");\r
@@ -884,11 +877,11 @@ public class AutoGen {
                 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);\r\n");\r
-                        fileBuffer\r
-                        .append("  if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\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
@@ -907,8 +900,7 @@ public class AutoGen {
             // function.\r
             //\r
             if (entryPointList == null || entryPointList.length == 0) {\r
-                fileBuffer\r
-                .append("GLOBAL_REMOVE_IF_UNREFERENCED  const UINT8  _gDriverEntryPointCount = ");\r
+                fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED  const UINT8  _gDriverEntryPointCount = ");\r
                 fileBuffer.append(Integer.toString(entryPointCount));\r
                 fileBuffer.append(";\r\n");\r
                 fileBuffer.append("EFI_STATUS\r\n");\r
@@ -931,14 +923,11 @@ public class AutoGen {
                     fileBuffer.append("  );\r\n");\r
                     entryPointCount++;\r
                 }\r
-                fileBuffer\r
-                .append("GLOBAL_REMOVE_IF_UNREFERENCED  const UINT8  _gDriverEntryPointCount = ");\r
+                fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED  const UINT8  _gDriverEntryPointCount = ");\r
                 fileBuffer.append(Integer.toString(entryPointCount));\r
                 fileBuffer.append(";\r\n");\r
-                fileBuffer\r
-                .append("static BASE_LIBRARY_JUMP_BUFFER  mJumpContext;\r\n");\r
-                fileBuffer\r
-                .append("static EFI_STATUS  mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\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
@@ -948,16 +937,14 @@ public class AutoGen {
                 fileBuffer.append("  )\r\n\r\n");\r
                 fileBuffer.append("{\r\n");\r
 \r
-\r
                 for (int i = 0; i < entryPointList.length; i++) {\r
-                    fileBuffer\r
-                    .append("  if (SetJump (&mJumpContext) == 0) {\r\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));\r\n");\r
                     fileBuffer.append("    ASSERT (FALSE);\r\n");\r
                     fileBuffer.append("  }\r\n");\r
-\r
                 }\r
                 fileBuffer.append("  return mDriverEntryPointStatus;\r\n");\r
                 fileBuffer.append("}\r\n\r\n");\r
@@ -968,14 +955,12 @@ public class AutoGen {
                 fileBuffer.append("  IN EFI_STATUS  Status\n");\r
                 fileBuffer.append("  )\r\n\r\n");\r
                 fileBuffer.append("{\r\n");\r
-                fileBuffer\r
-                .append("  if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\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
@@ -986,21 +971,19 @@ public class AutoGen {
             //entryPointList = CommonDefinition.remDupString(entryPointList);\r
             //entryPointCount = 0;\r
 \r
-                       unloadImageCount = 0;\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\r
-                    .append("  IN EFI_HANDLE        ImageHandle\r\n");\r
+                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle\r\n");\r
                     fileBuffer.append("  );\r\n");\r
                     unloadImageCount++;\r
                 }\r
             }\r
 \r
-            fileBuffer\r
-            .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverUnloadImageCount = ");\r
+            fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverUnloadImageCount = ");\r
             fileBuffer.append(Integer.toString(unloadImageCount));\r
             fileBuffer.append(";\r\n\r\n");\r
 \r
@@ -1053,8 +1036,7 @@ public class AutoGen {
             // If entry point is null, create a empty ProcessModuleEntryPointList function.\r
             //\r
             if (entryPointList == null || entryPointList.length == 0) {\r
-                fileBuffer\r
-                .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverEntryPointCount = 0;\r\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
@@ -1077,15 +1059,12 @@ public class AutoGen {
                     entryPointCount++;\r
                 }\r
 \r
-                fileBuffer\r
-                .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverEntryPointCount = ");\r
+                fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverEntryPointCount = ");\r
                 fileBuffer.append(Integer.toString(entryPointCount));\r
                 fileBuffer.append(";\r\n");\r
                 if (entryPointCount > 1) {\r
-                    fileBuffer\r
-                    .append("static BASE_LIBRARY_JUMP_BUFFER  mJumpContext;\r\n");\r
-                    fileBuffer\r
-                    .append("static EFI_STATUS  mDriverEntryPointStatus = EFI_LOAD_ERROR;\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
                 }\r
                 fileBuffer.append("\n");\r
 \r
@@ -1098,14 +1077,15 @@ public class AutoGen {
                 fileBuffer.append("{\r\n");\r
 \r
                 if (entryPointCount == 1) {\r
-                    fileBuffer.append("  return (");\r
+                    fileBuffer.append(String.format("  " + debugStr, entryPointList[0], entryPointList[0]));\r
+                    fileBuffer.append("  return ");\r
                     fileBuffer.append(entryPointList[0]);\r
-                    fileBuffer.append(" (ImageHandle, SystemTable));\r\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\r
-                            .append("  if (SetJump (&mJumpContext) == 0) {\r\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));\r\n");\r
@@ -1127,21 +1107,18 @@ public class AutoGen {
                 fileBuffer.append("{\r\n");\r
                 if (entryPointCount <= 1) {\r
                     fileBuffer.append("  if (EFI_ERROR (Status)) {\r\n");\r
-                    fileBuffer\r
-                    .append("    ProcessLibraryDestructorList (gImageHandle, gST);\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
                 } else {\r
-                    fileBuffer\r
-                    .append("  if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\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
                 }\r
                 fileBuffer.append("}\r\n\r\n");\r
-\r
             }\r
 \r
             //\r
@@ -1153,22 +1130,20 @@ public class AutoGen {
             //\r
             //entryPointList = CommonDefinition.remDupString(entryPointList);\r
             //entryPointCount = 0;\r
-                       unloadImageCount = 0;\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\r
-                    .append("  IN EFI_HANDLE        ImageHandle\r\n");\r
+                    fileBuffer.append("  IN EFI_HANDLE        ImageHandle\r\n");\r
                     fileBuffer.append("  );\r\n");\r
                     unloadImageCount++;\r
                 }\r
             }\r
 \r
-            fileBuffer\r
-            .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverUnloadImageCount = ");\r
+            fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverUnloadImageCount = ");\r
             fileBuffer.append(Integer.toString(unloadImageCount));\r
             fileBuffer.append(";\r\n\r\n");\r
 \r
@@ -1250,8 +1225,7 @@ public class AutoGen {
             ppiKeyWord = ppiIterator.next().toString();\r
             cNameGuid = GlobalData.getPpiGuid(this.mDepPkgList, ppiKeyWord);\r
             if (cNameGuid != null) {\r
-                fileBuffer\r
-                .append("\r\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
@@ -1289,8 +1263,7 @@ public class AutoGen {
             this.mProtocolList.add(protocolList[i]);\r
         }\r
 \r
-        String[] protocolNotifyList = saq\r
-                                      .getProtocolNotifyArray(this.arch);\r
+        String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);\r
 \r
         for (int i = 0; i < protocolNotifyList.length; i++) {\r
             this.mProtocolList.add(protocolNotifyList[i]);\r
@@ -1307,8 +1280,7 @@ public class AutoGen {
             protocolKeyWord = protocolIterator.next().toString();\r
             cNameGuid = GlobalData.getProtocolGuid(this.mDepPkgList, protocolKeyWord);\r
             if (cNameGuid != null) {\r
-                fileBuffer\r
-                .append("\r\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
@@ -1318,7 +1290,7 @@ public class AutoGen {
                 // If can't find protocol GUID declaration in every package\r
                 //\r
                 throw new AutoGenException("Can not find protocol Guid ["\r
-                                         + protocolKeyWord + "] declaration in any SPD package!");\r
+                                           + protocolKeyWord + "] declaration in any SPD package!");\r
             }\r
         }\r
     }\r
@@ -1350,8 +1322,7 @@ public class AutoGen {
             cNameGuid = GlobalData.getGuid(this.mDepPkgList, guidKeyWord);\r
 \r
             if (cNameGuid != null) {\r
-                fileBuffer\r
-                .append("\r\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,16 +1350,16 @@ public class AutoGen {
       @throws BuildException\r
     **/\r
     void LibInstanceToAutogenC(StringBuffer fileBuffer) throws EdkException {\r
-               String moduleType = this.moduleId.getModuleType();\r
-               //\r
-               // Add library constructor to AutoGen.c\r
-               //\r
-               LibConstructorToAutogenC(libConstructList, moduleType,\r
-                                                                fileBuffer/* autogenC */);\r
-               //\r
-               // Add library destructor to AutoGen.c\r
-               //\r
-               LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);\r
+        String moduleType = this.moduleId.getModuleType();\r
+        //\r
+        // Add library constructor to AutoGen.c\r
+        //\r
+        LibConstructorToAutogenC(libConstructList, moduleType,\r
+                                 fileBuffer/* autogenC */);\r
+        //\r
+        // Add library destructor to AutoGen.c\r
+        //\r
+        LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);\r
     }\r
 \r
     /**\r
@@ -1414,15 +1385,15 @@ public class AutoGen {
         // module type.\r
         //\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\r\n");\r
+            if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
+                fileBuffer.append("RETURN_STATUS\r\n");\r
                 fileBuffer.append("EFIAPI\r\n");\r
                 fileBuffer.append(libInstanceList.get(i)[0]);\r
                 fileBuffer.append(" (\r\n");\r
                 fileBuffer.append("  VOID\r\n");\r
                 fileBuffer.append("  );\r\n");\r
-                       } else {\r
-                               switch (CommonDefinition.getModuleType(moduleType)) {\r
+            } else {\r
+                switch (CommonDefinition.getModuleType(moduleType)) {\r
                 case CommonDefinition.ModuleTypeBase:\r
                     fileBuffer.append("RETURN_STATUS\r\n");\r
                     fileBuffer.append("EFIAPI\r\n");\r
@@ -1434,34 +1405,32 @@ public class AutoGen {
 \r
                 case CommonDefinition.ModuleTypePeiCore:\r
                 case CommonDefinition.ModuleTypePeim:\r
-                                       fileBuffer.append("EFI_STATUS\r\n");\r
-                                       fileBuffer.append("EFIAPI\r\n");\r
-                                       fileBuffer.append(libInstanceList.get(i)[0]);\r
-                                       fileBuffer.append(" (\r\n");\r
-                                       fileBuffer\r
-                                       .append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r\n");\r
-                                       fileBuffer\r
-                                       .append("  IN EFI_PEI_SERVICES          **PeiServices\r\n");\r
-                                       fileBuffer.append("  );\r\n");\r
-                                       break;\r
-       \r
-                               case CommonDefinition.ModuleTypeDxeCore:\r
-                               case CommonDefinition.ModuleTypeDxeDriver:\r
-                               case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
-                               case CommonDefinition.ModuleTypeDxeSmmDriver:\r
-                               case CommonDefinition.ModuleTypeDxeSalDriver:\r
-                               case CommonDefinition.ModuleTypeUefiDriver:\r
-                               case CommonDefinition.ModuleTypeUefiApplication:\r
-                                       fileBuffer.append("EFI_STATUS\r\n");\r
-                                       fileBuffer.append("EFIAPI\r\n");\r
-                                       fileBuffer.append(libInstanceList.get(i)[0]);\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
-                                       break;\r
-\r
-                           }\r
+                    fileBuffer.append("EFI_STATUS\r\n");\r
+                    fileBuffer.append("EFIAPI\r\n");\r
+                    fileBuffer.append(libInstanceList.get(i)[0]);\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
+                    break;\r
+\r
+                case CommonDefinition.ModuleTypeDxeCore:\r
+                case CommonDefinition.ModuleTypeDxeDriver:\r
+                case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
+                case CommonDefinition.ModuleTypeDxeSmmDriver:\r
+                case CommonDefinition.ModuleTypeDxeSalDriver:\r
+                case CommonDefinition.ModuleTypeUefiDriver:\r
+                case CommonDefinition.ModuleTypeUefiApplication:\r
+                    fileBuffer.append("EFI_STATUS\r\n");\r
+                    fileBuffer.append("EFIAPI\r\n");\r
+                    fileBuffer.append(libInstanceList.get(i)[0]);\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
+                    break;\r
+\r
+                }\r
             }\r
         }\r
 \r
@@ -1510,38 +1479,38 @@ public class AutoGen {
                 fileBuffer.append("\r\n");\r
                 isFirst = false;\r
             }\r
-                       if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\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("();\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("();\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);\r\n");\r
-                                               break;\r
-                                       case CommonDefinition.ModuleTypeDxeCore:\r
-                                       case CommonDefinition.ModuleTypeDxeDriver:\r
-                                       case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
-                                       case CommonDefinition.ModuleTypeDxeSmmDriver:\r
-                                       case CommonDefinition.ModuleTypeDxeSalDriver:\r
-                                       case CommonDefinition.ModuleTypeUefiDriver:\r
-                                       case CommonDefinition.ModuleTypeUefiApplication:\r
-                                               fileBuffer.append("  Status = ");\r
-                                               fileBuffer.append(libInstanceList.get(i)[0]);\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
+            } else {\r
+                switch (CommonDefinition.getModuleType(moduleType)) {\r
+                case CommonDefinition.ModuleTypeBase:\r
+                    fileBuffer.append("  Status = ");\r
+                    fileBuffer.append(libInstanceList.get(i)[0]);\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);\r\n");\r
+                    break;\r
+                case CommonDefinition.ModuleTypeDxeCore:\r
+                case CommonDefinition.ModuleTypeDxeDriver:\r
+                case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
+                case CommonDefinition.ModuleTypeDxeSmmDriver:\r
+                case CommonDefinition.ModuleTypeDxeSalDriver:\r
+                case CommonDefinition.ModuleTypeUefiDriver:\r
+                case CommonDefinition.ModuleTypeUefiApplication:\r
+                    fileBuffer.append("  Status = ");\r
+                    fileBuffer.append(libInstanceList.get(i)[0]);\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);\r\n");\r
         }\r
@@ -1566,51 +1535,49 @@ public class AutoGen {
                                  String moduleType, StringBuffer fileBuffer) throws EdkException {\r
         boolean isFirst = true;\r
         for (int i = 0; i < libInstanceList.size(); i++) {\r
-                       if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
+            if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
                 fileBuffer.append("RETURN_STATUS\r\n");\r
                 fileBuffer.append("EFIAPI\r\n");\r
                 fileBuffer.append(libInstanceList.get(i)[0]);\r
                 fileBuffer.append(" (\r\n");\r
                 fileBuffer.append("  VOID\r\n");\r
                 fileBuffer.append("  );\r\n");\r
-                       } else {\r
-                               switch (CommonDefinition.getModuleType(moduleType)) {\r
-                                       case CommonDefinition.ModuleTypeBase:\r
-                                               fileBuffer.append("RETURN_STATUS\r\n");\r
-                                               fileBuffer.append("EFIAPI\r\n");\r
-                                               fileBuffer.append(libInstanceList.get(i)[0]);\r
-                                               fileBuffer.append(" (\r\n");\r
-                                               fileBuffer.append("  VOID\r\n");\r
-                                               fileBuffer.append("  );\r\n");\r
-                                               break;\r
-                                       case CommonDefinition.ModuleTypePeiCore:\r
-                                       case CommonDefinition.ModuleTypePeim:\r
-                                               fileBuffer.append("EFI_STATUS\r\n");\r
-                                               fileBuffer.append("EFIAPI\r\n");\r
-                                               fileBuffer.append(libInstanceList.get(i)[0]);\r
-                                               fileBuffer.append(" (\r\n");\r
-                                               fileBuffer\r
-                                               .append("  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r\n");\r
-                                               fileBuffer\r
-                                               .append("  IN EFI_PEI_SERVICES          **PeiServices\r\n");\r
-                                               fileBuffer.append("  );\r\n");\r
-                                               break;\r
-                                       case CommonDefinition.ModuleTypeDxeCore:\r
-                                       case CommonDefinition.ModuleTypeDxeDriver:\r
-                                       case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
-                                       case CommonDefinition.ModuleTypeDxeSmmDriver:\r
-                                       case CommonDefinition.ModuleTypeDxeSalDriver:\r
-                                       case CommonDefinition.ModuleTypeUefiDriver:\r
-                                       case CommonDefinition.ModuleTypeUefiApplication:\r
-                                               fileBuffer.append("EFI_STATUS\r\n");\r
-                                               fileBuffer.append("EFIAPI\r\n");\r
-                                               fileBuffer.append(libInstanceList.get(i)[0]);\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
-                                               break;\r
-                           }\r
+            } else {\r
+                switch (CommonDefinition.getModuleType(moduleType)) {\r
+                case CommonDefinition.ModuleTypeBase:\r
+                    fileBuffer.append("RETURN_STATUS\r\n");\r
+                    fileBuffer.append("EFIAPI\r\n");\r
+                    fileBuffer.append(libInstanceList.get(i)[0]);\r
+                    fileBuffer.append(" (\r\n");\r
+                    fileBuffer.append("  VOID\r\n");\r
+                    fileBuffer.append("  );\r\n");\r
+                    break;\r
+                case CommonDefinition.ModuleTypePeiCore:\r
+                case CommonDefinition.ModuleTypePeim:\r
+                    fileBuffer.append("EFI_STATUS\r\n");\r
+                    fileBuffer.append("EFIAPI\r\n");\r
+                    fileBuffer.append(libInstanceList.get(i)[0]);\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
+                    break;\r
+                case CommonDefinition.ModuleTypeDxeCore:\r
+                case CommonDefinition.ModuleTypeDxeDriver:\r
+                case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
+                case CommonDefinition.ModuleTypeDxeSmmDriver:\r
+                case CommonDefinition.ModuleTypeDxeSalDriver:\r
+                case CommonDefinition.ModuleTypeUefiDriver:\r
+                case CommonDefinition.ModuleTypeUefiApplication:\r
+                    fileBuffer.append("EFI_STATUS\r\n");\r
+                    fileBuffer.append("EFIAPI\r\n");\r
+                    fileBuffer.append(libInstanceList.get(i)[0]);\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
+                    break;\r
+                }\r
             }\r
         }\r
 \r
@@ -1647,17 +1614,17 @@ public class AutoGen {
                     fileBuffer.append("\r\n");\r
                     isFirst = false;\r
                 }\r
-                               if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\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("();\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);\r\n");\r
-                                       fileBuffer.append("  ASSERT_EFI_ERROR (Status);\r\n");\r
-                               }\r
+                } else {\r
+                    fileBuffer.append("  Status = ");\r
+                    fileBuffer.append(libInstanceList.get(i)[0]);\r
+                    fileBuffer.append("(ImageHandle, SystemTable);\r\n");\r
+                    fileBuffer.append("  ASSERT_EFI_ERROR (Status);\r\n");\r
+                }\r
             }\r
             fileBuffer.append("}\r\n");\r
             break;\r
@@ -1675,91 +1642,94 @@ public class AutoGen {
     **/\r
     void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer)\r
     throws EdkException {\r
-\r
         //\r
         // Get the arry of extern. The driverBindingGroup is a 2 dimension array.\r
-               // The second dimension is include following element: DriverBinding, \r
-               // ComponentName, DriverConfiguration, DriverDiag;\r
-               // \r
+        // The second dimension is include following element: DriverBinding, \r
+        // ComponentName, DriverConfiguration, DriverDiag;\r
+        // \r
         String[][] driverBindingGroup = this.saq.getExternProtocolGroup();\r
 \r
+\r
         //\r
         // inital BitMask;\r
-               // \r
+        // \r
         int BitMask = 0;\r
 \r
         //\r
         // Write driver binding protocol extern to autogen.c\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
+            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
-                       } \r
+            }\r
         }\r
 \r
         //\r
         // Write component name protocol extern to autogen.c\r
         //\r
-               for (int i = 0; i < driverBindingGroup.length; i++) {\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
-                               } else {\r
-                    throw new AutoGenException("DriverBinding can't be empty!!");\r
-                               }\r
-                       }\r
-               }\r
+        if (!componentNamePcd) {\r
+            for (int i = 0; i < driverBindingGroup.length; i++) {\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
+                    } else {\r
+                        throw new AutoGenException("DriverBinding can't be empty!!");\r
+                    }\r
+                }\r
+            }\r
+        }\r
 \r
         //\r
         // Write driver configration protocol extern to autogen.c\r
         //\r
-               for (int i = 0; i < driverBindingGroup.length; i++) {\r
-                       if (driverBindingGroup[i][2] != null) {\r
-                               if (driverBindingGroup[i][0] != null) {\r
+        for (int i = 0; i < driverBindingGroup.length; i++) {\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("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");\r
                     fileBuffer.append(driverBindingGroup[i][2]);\r
                     fileBuffer.append(";\r\n");\r
-                               } else {\r
+                } else {\r
                     throw new AutoGenException("DriverBinding can't be empty!!");\r
-                               }\r
-                       }\r
-               }\r
-        \r
+                }\r
+            }\r
+        }\r
+\r
         //\r
         // Write driver dignastic protocol extern to autogen.c\r
         //\r
-               for (int i = 0; i < driverBindingGroup.length; i++) {\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
-                               } else {\r
-                    throw new AutoGenException("DriverBinding can't be empty!!");\r
-                               }\r
-                       }\r
-               }\r
-      \r
+        if (!driverDiagnostPcd) {\r
+            for (int i = 0; i < driverBindingGroup.length; i++) {\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
+                    } else {\r
+                        throw new AutoGenException("DriverBinding can't be empty!!");\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+\r
         //\r
         // Write driver module protocol bitmask.\r
         //\r
-        fileBuffer\r
-        .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverModelProtocolBitmask = ");\r
+        fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gDriverModelProtocolBitmask = ");\r
         fileBuffer.append(Integer.toString(BitMask));\r
         fileBuffer.append(";\r\n");\r
 \r
         //\r
         // Write driver module protocol list entry\r
         //\r
-        fileBuffer\r
-        .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN  _gDriverModelProtocolListEntries = ");\r
+        fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN  _gDriverModelProtocolListEntries = ");\r
 \r
         fileBuffer.append(Integer.toString(driverBindingGroup.length));\r
         fileBuffer.append(";\r\n");\r
@@ -1767,24 +1737,27 @@ public class AutoGen {
         //\r
         // Write drive module protocol list to autogen.c\r
         //\r
-               if (driverBindingGroup.length > 0) {\r
-                       fileBuffer\r
-        .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST  _gDriverModelProtocolList[] = {");\r
-               }\r
-        \r
-               \r
+        if (driverBindingGroup.length > 0) {\r
+            fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST  _gDriverModelProtocolList[] = {");\r
+        }\r
+\r
+\r
         for (int i = 0; i < driverBindingGroup.length; i++) {\r
             if (i != 0) {\r
                 fileBuffer.append(",");\r
             }\r
-                       \r
-                       fileBuffer.append("\r\n {\r\n");\r
+            //\r
+            //  DriverBinding\r
+            // \r
+            fileBuffer.append("\r\n {\r\n");\r
             fileBuffer.append("  &");\r
             fileBuffer.append(driverBindingGroup[i][0]);\r
             fileBuffer.append(", \r\n");\r
-                       \r
 \r
-            if (driverBindingGroup[i][1] != null) {\r
+            //\r
+            //  ComponentName\r
+            // \r
+            if (driverBindingGroup[i][1] != null && componentNamePcd != true) {\r
                 fileBuffer.append("  &");\r
                 fileBuffer.append(driverBindingGroup[i][1]);\r
                 fileBuffer.append(", \r\n");\r
@@ -1792,6 +1765,9 @@ public class AutoGen {
                 fileBuffer.append("  NULL, \r\n");\r
             }\r
 \r
+            //\r
+            // DriverConfiguration\r
+            // \r
             if (driverBindingGroup[i][2] != null) {\r
                 fileBuffer.append("  &");\r
                 fileBuffer.append(driverBindingGroup[i][2]);\r
@@ -1800,7 +1776,10 @@ public class AutoGen {
                 fileBuffer.append("  NULL, \r\n");\r
             }\r
 \r
-            if (driverBindingGroup[i][3] != null) {\r
+            //\r
+            // DriverDiagnostic\r
+            // \r
+            if (driverBindingGroup[i][3] != null && driverDiagnostPcd != true) {\r
                 fileBuffer.append("  &");\r
                 fileBuffer.append(driverBindingGroup[i][3]);\r
                 fileBuffer.append(", \r\n");\r
@@ -1810,9 +1789,9 @@ public class AutoGen {
             fileBuffer.append("  }");\r
         }\r
 \r
-               if (driverBindingGroup.length > 0) {\r
-                       fileBuffer.append("\r\n};\r\n");\r
-               }\r
+        if (driverBindingGroup.length > 0) {\r
+            fileBuffer.append("\r\n};\r\n");\r
+        }\r
     }\r
 \r
     /**\r
@@ -1854,13 +1833,13 @@ public class AutoGen {
         case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
         case CommonDefinition.ModuleTypeDxeSalDriver:\r
         case CommonDefinition.ModuleTypeUefiDriver:\r
-               case CommonDefinition.ModuleTypeUefiApplication:\r
-                       //\r
-                       //  If moduleType is one of above, call setVirtualAddressToAutogenC,\r
-                       //  and setExitBootServiceToAutogenC.\r
-                       // \r
+        case CommonDefinition.ModuleTypeUefiApplication:\r
+            //\r
+            //  If moduleType is one of above, call setVirtualAddressToAutogenC,\r
+            //  and setExitBootServiceToAutogenC.\r
+            // \r
             setVirtualAddressToAutogenC(fileBuffer);\r
-                       setExitBootServiceToAutogenC(fileBuffer);\r
+            setExitBootServiceToAutogenC(fileBuffer);\r
             break;\r
         default:\r
             break;\r
@@ -1887,21 +1866,21 @@ public class AutoGen {
         //  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
+            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
+            } else {\r
+                throw new AutoGenException("The file, flashMap.h doesn't exist!");\r
+            }\r
         }\r
     }\r
 \r
@@ -1919,200 +1898,195 @@ public class AutoGen {
 \r
         String libConstructName = null;\r
         String libDestructName = null;\r
-               String libModuleType   = 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
+        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
+                    // 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
-       private void setVirtualAddressToAutogenC(StringBuffer fileBuffer){\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
+        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
+        // set count to the number of valid entries\r
+        //\r
+        int Count = 0;\r
+        int i = 0;\r
+        if (this.setVirtalAddList != null) {\r
+            for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
+                if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
+                    break;\r
+                }\r
+            }\r
+            Count = i;\r
+        }\r
 \r
+        fileBuffer.append(Integer.toString(Count));\r
+        fileBuffer.append(";\r\n\r\n");\r
+        if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) {\r
             //\r
-            // If the list is not valid or has no entries set count to zero else\r
-            // set count to the number of valid entries\r
+            // No data so make a NULL list\r
             //\r
-            int Count = 0;\r
-                       int i = 0;\r
-            if (this.setVirtalAddList != null) {\r
-                for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
-                    if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
-                        break;\r
-                    }\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
+            //\r
+            for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
+                if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
+                    break;\r
                 }\r
-                Count = i;\r
+                fileBuffer.append("VOID\r\n");\r
+                fileBuffer.append("EFIAPI\r\n");\r
+                fileBuffer.append(this.setVirtalAddList.get(i));\r
+                fileBuffer.append(" (\r\n");\r
+                fileBuffer.append("  IN EFI_EVENT  Event,\r\n");\r
+                fileBuffer.append("  IN VOID       *Context\r\n");\r
+                fileBuffer.append("  );\r\n\r\n");\r
             }\r
 \r
-            fileBuffer.append(Integer.toString(Count));\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\r
-                .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
-                //\r
-                for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
-                    if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
-                        break;\r
-                    }\r
-                    fileBuffer.append("VOID\r\n");\r
-                    fileBuffer.append("EFIAPI\r\n");\r
-                    fileBuffer.append(this.setVirtalAddList.get(i));\r
-                    fileBuffer.append(" (\r\n");\r
-                    fileBuffer.append("  IN EFI_EVENT  Event,\r\n");\r
-                    fileBuffer.append("  IN VOID       *Context\r\n");\r
-                    fileBuffer.append("  );\r\n\r\n");\r
-                 }\r
-\r
-                //\r
-                // Write SetVirtualAddressMap entry point array.\r
-                //\r
-                fileBuffer\r
-                .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("\r\n  ");\r
-                    } else {\r
-                        fileBuffer.append(",\r\n  ");\r
-                    }\r
+            //\r
+            // Write SetVirtualAddressMap entry point array.\r
+            //\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
-                    fileBuffer.append(this.setVirtalAddList.get(i));\r
+                if (i == 0) {\r
+                    fileBuffer.append("\r\n  ");\r
+                } else {\r
+                    fileBuffer.append(",\r\n  ");\r
                 }\r
-                //\r
-                // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.\r
-                //\r
-                fileBuffer.append(",\r\n  NULL");\r
-                fileBuffer.append("\r\n};\r\n\r\n");\r
-                       }\r
-       }\r
 \r
+                fileBuffer.append(this.setVirtalAddList.get(i));\r
+            }\r
+            //\r
+            // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.\r
+            //\r
+            fileBuffer.append(",\r\n  NULL");\r
+            fileBuffer.append("\r\n};\r\n\r\n");\r
+        }\r
+    }\r
 \r
-       private void setExitBootServiceToAutogenC(StringBuffer fileBuffer){\r
-               //\r
+\r
+    private void setExitBootServiceToAutogenC(StringBuffer fileBuffer){\r
+        //\r
         // Entry point lib for these module types needs to know the count.\r
         //\r
         fileBuffer\r
@@ -2123,7 +2097,7 @@ public class AutoGen {
         // set count to the number of valid entries.\r
         //\r
         int Count = 0;\r
-               int i = 0; \r
+        int i = 0; \r
         if (this.exitBootServiceList != null) {\r
             for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
                 if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
@@ -2135,12 +2109,11 @@ public class AutoGen {
         fileBuffer.append(Integer.toString(Count));\r
         fileBuffer.append(";\r\n\r\n");\r
 \r
-               if (this.exitBootServiceList == null || this.exitBootServiceList.size() == 0) {\r
+        if (this.exitBootServiceList == null || this.exitBootServiceList.size() == 0) {\r
             //      \r
             // No data so make a NULL list.\r
             //\r
-            fileBuffer\r
-            .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\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
@@ -2164,8 +2137,7 @@ public class AutoGen {
             //\r
             // Write DriverExitBootServices entry point array.\r
             //\r
-            fileBuffer\r
-            .append("\r\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
@@ -2178,11 +2150,39 @@ public class AutoGen {
                 }\r
                 fileBuffer.append(this.exitBootServiceList.get(i));\r
             }\r
-            \r
+\r
             fileBuffer.append(",\r\n  NULL");\r
             fileBuffer.append("\r\n};\r\n\r\n");\r
+        }   \r
+    }\r
+    /**\r
+      setPcdComponentName\r
+      \r
+         Get the Pcd Value of ComponentName to \r
+         decide whether need to disable the componentName.         \r
+         \r
+    **/\r
+    public void setPcdComponentName (){\r
+        String pcdValue = null;\r
+        pcdValue = saq.getPcdValueBycName("PcdComponentNameDisable");\r
+        if (pcdValue != null && pcdValue.equalsIgnoreCase("true")) {\r
+            this.componentNamePcd = true;\r
         }\r
+    }\r
 \r
-       }\r
+    /**\r
+      setPcdDriverDiagnostic \r
+      \r
+        Get the Pcd Value of DriverDiagnostic to \r
+        decide whether need to disable DriverDiagnostic.\r
+         \r
+    **/\r
+    public void setPcdDriverDiagnostic (){\r
+        String pcdValue = null;\r
+        pcdValue  = saq.getPcdValueBycName("PcdDriverDiagnosticsDisable");\r
+        if (pcdValue != null && pcdValue.equalsIgnoreCase("true")) {\r
+            this.driverDiagnostPcd = true;\r
+        }\r
+    }  \r
 \r
 }\r