]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Refine the code for PCD tools.
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 15 Aug 2006 18:33:53 +0000 (18:33 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 15 Aug 2006 18:33:53 +0000 (18:33 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1282 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java
Tools/Source/GenBuild/org/tianocore/build/pcd/action/PlatformPcdPreprocessActionForBuilding.java
Tools/Source/PcdTools/org/tianocore/pcd/action/BuildAction.java
Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java
Tools/Source/PcdTools/org/tianocore/pcd/entity/UsageInstance.java

index ad4a5c74829a1abf1f37e32c21c73d6198a402d6..f3b107712ea96a2f4e3ba8e6cd7ef7b621d04e8d 100644 (file)
@@ -362,7 +362,7 @@ public class AutoGen {
         //\r
         if (this.myPcdAutogen != null) {\r
             fileBuffer.append("\r\n");\r
-            fileBuffer.append(this.myPcdAutogen.OutputH());\r
+            fileBuffer.append(this.myPcdAutogen.getHAutoGenString());\r
         }\r
 \r
         //\r
@@ -496,7 +496,7 @@ public class AutoGen {
 \r
         if (this.myPcdAutogen != null) {\r
             fileBuffer.append("\r\n");\r
-            fileBuffer.append(this.myPcdAutogen.OutputC());\r
+            fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
         }\r
 \r
         if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
@@ -599,7 +599,7 @@ public class AutoGen {
         //\r
         if (this.myPcdAutogen != null) {\r
             fileBuffer.append("\r\n");\r
-            fileBuffer.append(this.myPcdAutogen.OutputH());\r
+            fileBuffer.append(this.myPcdAutogen.getHAutoGenString());\r
         }\r
 \r
         //\r
@@ -650,7 +650,7 @@ public class AutoGen {
 \r
         if (this.myPcdAutogen != null) {\r
             fileBuffer.append("\r\n");\r
-            fileBuffer.append(this.myPcdAutogen.OutputC());\r
+            fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
         }\r
 \r
         if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
index 6d71629b6161dbab070939e58edbe4e522b12506..28bb81853e4a8eb2426e5b7026499fd939e52adf 100644 (file)
@@ -34,8 +34,9 @@ import org.tianocore.pcd.entity.UsageIdentification;
 import org.tianocore.pcd.entity.UsageInstance;\r
 import org.tianocore.pcd.exception.BuildActionException;\r
 \r
-/** This class is to manage how to generate the PCD information into Autogen.c and\r
-    Autogen.h.\r
+/**\r
+    This class is to manage how to generate the PCD information into Autogen.c\r
+    and Autogen.h.\r
 **/\r
 public class PCDAutoGenAction extends BuildAction {\r
     ///\r
@@ -113,7 +114,7 @@ public class PCDAutoGenAction extends BuildAction {
 \r
       @return the string of header file for PCD\r
     **/\r
-    public String OutputH() {\r
+    public String getHAutoGenString() {\r
         return hAutoGenString;\r
     }\r
 \r
@@ -122,7 +123,7 @@ public class PCDAutoGenAction extends BuildAction {
 \r
       @return the string of C code file for PCD\r
     **/\r
-    public String OutputC() {\r
+    public String getCAutoGenString() {\r
         return cAutoGenString;\r
     }\r
 \r
@@ -317,10 +318,6 @@ public class PCDAutoGenAction extends BuildAction {
             cAutoGenString += usageInstance.getCAutogenStr();\r
         }\r
 \r
-        //\r
-        // Work around code, In furture following code should be modified that get\r
-        // these information from Uplevel Autogen tools.\r
-        //\r
         if (pcdDriverType == CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER) {\r
             hAutoGenString += MemoryDatabaseManager.PcdPeimHString;\r
             cAutoGenString += MemoryDatabaseManager.PcdPeimCString;\r
@@ -329,29 +326,4 @@ public class PCDAutoGenAction extends BuildAction {
             cAutoGenString += MemoryDatabaseManager.PcdDxeCString;\r
         }\r
     }\r
-\r
-    /**\r
-      Test case function\r
-\r
-      @param argv  paramter from command line\r
-    **/\r
-    public static void main(String argv[]) {\r
-\r
-        String WorkSpace = "X:/edk2";\r
-        String logFilePath = WorkSpace  + "/EdkNt32Pkg/Nt32.fpd";\r
-\r
-        //\r
-        // At first, CollectPCDAction should be invoked to collect\r
-        // all PCD information from SPD, MSA, FPD.\r
-        //\r
-        PlatformPcdPreprocessActionForBuilding collectionAction = new PlatformPcdPreprocessActionForBuilding();\r
-        GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",\r
-                            WorkSpace,null);\r
-\r
-        try {\r
-            collectionAction.perform(logFilePath, ActionMessage.MAX_MESSAGE_LEVEL);\r
-        } catch(Exception e) {\r
-            e.printStackTrace();\r
-        }\r
-    }\r
 }\r
index a0a40eb4d1b83673b6b4bb528b194bf2ba7e3cdd..4d2335dfd2525975e791e01d124b1bce262b858e 100644 (file)
@@ -19,7 +19,6 @@ package org.tianocore.build.pcd.action;
 \r
 import java.io.File;\r
 import java.io.IOException;\r
-import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.Iterator;\r
 import java.util.List;\r
@@ -50,7 +49,7 @@ import org.tianocore.pcd.exception.PlatformPcdPreprocessException;
 **/\r
 public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreprocessAction {\r
     ///\r
-    /// FPD file is the root file.\r
+    /// FPD file path.\r
     ///\r
     private String                      fpdFilePath;\r
 \r
@@ -88,7 +87,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
     /**\r
       Common function interface for outer.\r
 \r
-      @param fpdFilePath    The fpd file path of current build or analysis.\r
+      @param fpdFilePath    The fpd file path of current build or processing.\r
       @param messageLevel   The message level for this Action.\r
 \r
       @throws  PlatformPreprocessBuildException \r
@@ -98,7 +97,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
     **/\r
     public void perform(String fpdFilePath, int messageLevel) \r
         throws PlatformPcdPreprocessBuildException {\r
-        setFPDFilePath(fpdFilePath);\r
+        this.fpdFilePath = fpdFilePath;\r
         setActionMessageLevel(messageLevel);\r
         checkParameter();\r
         execute();\r
@@ -152,7 +151,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
         try {\r
             genPcdDatabaseSourceCode ();\r
         } catch (EntityException exp) {\r
-            throw new PlatformPcdPreprocessBuildException(errorMessageHeader + exp.getMessage());\r
+            throw new PlatformPcdPreprocessBuildException(errorMessageHeader + "\r\n" + exp.getMessage());\r
         }\r
     }\r
 \r
@@ -323,7 +322,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
 \r
             dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(),\r
                                                           tokenSpaceStrRet);\r
-            if (dynamicPrimaryKey.equalsIgnoreCase(token.getPrimaryKeyString())) {\r
+            if (dynamicPrimaryKey.equals(token.getPrimaryKeyString())) {\r
                 return dynamicPcdBuildDataArray.get(index);\r
             }\r
         }\r
@@ -374,11 +373,11 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
         File file = null;\r
 \r
         if (fpdFilePath == null) {\r
-            throw new PlatformPcdPreprocessBuildException("WorkspacePath and FPDFileName should be empty for CollectPCDAtion!");\r
+            throw new PlatformPcdPreprocessBuildException("FPDFileName should be empty for CollectPCDAtion!");\r
         }\r
 \r
         if (fpdFilePath.length() == 0) {\r
-            throw new PlatformPcdPreprocessBuildException("WorkspacePath and FPDFileName should be empty for CollectPCDAtion!");\r
+            throw new PlatformPcdPreprocessBuildException("FPDFileName should be empty for CollectPCDAtion!");\r
         }\r
 \r
         file = new File(fpdFilePath);\r
@@ -387,23 +386,4 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
             throw new PlatformPcdPreprocessBuildException("FPD File " + fpdFilePath + " does not exist!");\r
         }\r
     }\r
-\r
-    /**\r
-      Test case function\r
-\r
-      @param argv  parameter from command line\r
-    **/\r
-    public static void main(String argv[]) throws PlatformPcdPreprocessBuildException {\r
-        PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();\r
-        String projectDir = "x:/edk2";\r
-        ca.setFPDFilePath(projectDir + "/EdkNt32Pkg/Nt32.fpd");\r
-        ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);\r
-        GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",\r
-                            projectDir,\r
-                            "tools_def.txt");\r
-        System.out.println("After initInfo!");\r
-        FpdParserTask fpt = new FpdParserTask();\r
-        fpt.parseFpdFile(new File(projectDir + "/EdkNt32Pkg/Nt32.fpd"));\r
-        ca.execute();\r
-    }\r
 }\r
index 98068d97b9f9d7bdba33a9b0fb56ffc7713af6cc..e5288f364b3bb97f8601169271dd2c19a25487ea 100644 (file)
@@ -66,7 +66,10 @@ public abstract class BuildAction extends Task {
       @param logStr     The string contains log information.\r
     **/\r
     public static void logMsg(Object action, String logStr) {\r
-        ((Task) action).log(logStr, Project.MSG_INFO);\r
+        try {      \r
+            ((Task) action).log(logStr, Project.MSG_INFO);\r
+        } catch (Exception exp) {\r
+        }\r
     }\r
 \r
     /**\r
index 9343c1689d09365a4ab0205d48ecae4b17d056ee..ee91f2a8e8aaede47fcdc3207585f96ef2f2de54 100644 (file)
@@ -58,6 +58,7 @@ public abstract class PlatformPcdPreprocessAction {
     public PlatformPcdPreprocessAction() {\r
         pcdDbManager = null;\r
         errorString  = null;\r
+       errorCount   = 0;\r
     }\r
 \r
     /**\r
@@ -77,12 +78,13 @@ public abstract class PlatformPcdPreprocessAction {
     public MemoryDatabaseManager getPcdDbManager() {\r
         return pcdDbManager;\r
     }\r
+\r
     /**\r
        Abstract function: retrieve module information from FPD file.\r
 \r
        In building environement, this function will be implementated by FpdParserTask.\r
 \r
-       @return List<ModuleInfo>                  the component array.\r
+       @return List<ModulePcdInfoFromFpd>        the component array.\r
        @throws PlatformPcdPreprocessException    get all modules in <ModuleSA> in FPD file.\r
 \r
     **/\r
@@ -100,8 +102,7 @@ public abstract class PlatformPcdPreprocessAction {
        @throws PlatformPcdPreprocessException\r
                             Fail to get Guid information from SPD file.\r
     **/\r
-    public abstract String                  getGuidInfoFromSpd(String guidCName)\r
-                                            throws PlatformPcdPreprocessException;\r
+    public abstract String getGuidInfoFromSpd(String guidCName) throws PlatformPcdPreprocessException;\r
 \r
     /**\r
        Abstract function: Verification the PCD data.\r
@@ -118,11 +119,8 @@ public abstract class PlatformPcdPreprocessAction {
        @return String       exception strings.\r
 \r
     **/\r
-    public abstract String                  verifyDatum(String            cName,\r
-                                                        String            moduleName,\r
-                                                        String            datum,\r
-                                                        Token.DATUM_TYPE  datumType,\r
-                                                        int               maxDatumSize);\r
+    public abstract String verifyDatum(String cName, String moduleName, String datum,\r
+                                       Token.DATUM_TYPE  datumType, int maxDatumSize);\r
 \r
     /**\r
        Abstract function: Get dynamic information for a token\r
@@ -173,22 +171,23 @@ public abstract class PlatformPcdPreprocessAction {
     **/\r
     public void initPcdMemoryDbWithPlatformInfo()\r
         throws PlatformPcdPreprocessException {\r
-        int                                 index             = 0;\r
-        int                                 pcdIndex          = 0;\r
+        int                                 index;\r
+        int                                 pcdIndex;\r
         List<PcdBuildDefinition.PcdData>    pcdBuildDataArray = new ArrayList<PcdBuildDefinition.PcdData>();\r
-        PcdBuildDefinition.PcdData          pcdBuildData      = null;\r
+        PcdBuildDefinition.PcdData          pcdBuildData;\r
         Token                               token             = null;\r
-        List<ModulePcdInfoFromFpd>          modules           = null;\r
-        String                              primaryKey        = null;\r
-        String                              exceptionString   = null;\r
-        UsageInstance                       usageInstance     = null;\r
+        List<ModulePcdInfoFromFpd>          modules;\r
+        String                              primaryKey;\r
+        String                              exceptionString;\r
+        UsageInstance                       usageInstance;\r
         Token.PCD_TYPE                      pcdType           = Token.PCD_TYPE.UNKNOWN;\r
         Token.DATUM_TYPE                    datumType         = Token.DATUM_TYPE.UNKNOWN;\r
-        long                                tokenNumber       = 0;\r
-        String                              moduleName        = null;\r
-        String                              datum             = null;\r
-        int                                 maxDatumSize      = 0;\r
-        String                              tokenSpaceStrRet  = null;\r
+        long                                tokenNumber;\r
+        String                              moduleName;\r
+        String                              datum;\r
+        int                                 maxDatumSize;\r
+        String                              tokenSpaceStrRet;\r
+        ModulePcdInfoFromFpd                curModule;\r
 \r
         //\r
         // ----------------------------------------------\r
@@ -208,16 +207,17 @@ public abstract class PlatformPcdPreprocessAction {
         // -------------------------------------------------------------------\r
         //\r
         for (index = 0; index < modules.size(); index++) {\r
-           //\r
+            curModule = modules.get(index);\r
+\r
+            //\r
            // It is legal for a module does not contains ANY pcd build definitions.\r
            //\r
-           if (modules.get(index).pcdBuildDefinition == null) {\r
+           if (curModule.pcdBuildDefinition == null) {\r
                 continue;\r
            }\r
 \r
-            pcdBuildDataArray = modules.get(index).pcdBuildDefinition.getPcdDataList();\r
-\r
-            moduleName = modules.get(index).usageId.moduleName;\r
+            pcdBuildDataArray = curModule.pcdBuildDefinition.getPcdDataList();\r
+            moduleName        = curModule.usageId.moduleName;\r
 \r
             //\r
             // ----------------------------------------------------------------------\r
@@ -433,7 +433,7 @@ public abstract class PlatformPcdPreprocessAction {
                 // ------------------------------------------------\r
                 //\r
                 usageInstance = new UsageInstance(token,\r
-                                                  modules.get(index).usageId,\r
+                                                  curModule.usageId,\r
                                                   pcdType,\r
                                                   datum,\r
                                                   maxDatumSize);\r
@@ -441,7 +441,7 @@ public abstract class PlatformPcdPreprocessAction {
                     putError(String.format("PCD %s for module %s(%s) already exists in the database.\nPlease check all PCD build entries "+\r
                                            "in the %s module's <ModuleSA> section to make sure there are no duplicated definitions in the FPD file!",\r
                                            token.cName,\r
-                                           modules.get(index).usageId.moduleGuid,\r
+                                           curModule.usageId.moduleGuid,\r
                                            moduleName,\r
                                            moduleName));\r
                     continue;\r
index 47638bcea6defbe2a265fdb28c73f7bc36a5cc78..e38bc91aedb8eb4314a8b6ea2e37dfb5952985a8 100644 (file)
@@ -193,20 +193,40 @@ public class UsageInstance {
 \r
         switch (modulePcdType) {\r
         case FEATURE_FLAG:\r
+            //\r
+            // Example autogen string for following generation:\r
+            // "extern const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken";\r
+            // \r
             hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",\r
                                          parentToken.cName);\r
+            //\r
+            // Example autogen string for following generation:\r
+            // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_FixedAtBuild_PcdSampleToken";\r
+            // \r
             hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  _gPcd_FixedAtBuild_%s\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName,\r
                                          parentToken.cName);\r
+            //\r
+            // Example autogen string for following generation:\r
+            // "//#define _PCD_SET_MODE_8_PcdSampleToken ASSERT(FALSE) If is not allowed to set value...";\r
+            // \r
             hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) If is not allowed to set value for a FEATURE_FLAG PCD\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName);\r
 \r
             if (!isBuildUsedLibrary) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_VALUE_PcdSampleToken 0x1000"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
                                              parentToken.cName,\r
                                              printDatum);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken = _PCD_VALUE_PcdSampleToken;"\r
+                // \r
                 cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
@@ -214,47 +234,91 @@ public class UsageInstance {
             break;\r
         case FIXED_AT_BUILD:\r
             if (isByteArray) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "extern const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken";\r
+                // \r
                 hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",\r
                                              parentToken.cName);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_GET_MODE_8_PcdSampleToken (VOID*)_gPcd_FixedAtBuild_PcdSampleToken";\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
             } else {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "extern const UINT8 _gPcd_FixedAtBuild_PcdSampleToken";\r
+                // \r
                 hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
                                              Token.getAutogendatumTypeString(parentToken.datumType),\r
                                              parentToken.cName);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_FixedAtBuild_PcdSampleToken";\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  _gPcd_FixedAtBuild_%s\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
             }\r
 \r
+            //\r
+            // Example autogen string for following generation:\r
+            // "//#define _PCD_SET_MODE_8_PcdSampleToken ASSERT(FALSE) If is not allowed to set value...";\r
+            // \r
             hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName);\r
             if (!isBuildUsedLibrary) {\r
                 if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
                     if (isByteArray) {\r
+                        //\r
+                        // Example autogen string for following generation:\r
+                        // "#define _PCD_VALUE_PcdSampleToken (VOID*)_gPcd_FixedAtBuild_PcdSampleToken"\r
+                        // \r
                         hAutogenStr += String.format("#define _PCD_VALUE_%s   (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r
                                                      parentToken.cName,\r
                                                      parentToken.cName);\r
+                        //\r
+                        // Example autogen string for following generation:\r
+                        // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = 'dfdf';"\r
+                        // \r
                         cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",\r
                                                      parentToken.cName,\r
                                                      printDatum);\r
                     } else {\r
+                        //\r
+                        // Example autogen string for following generation:\r
+                        // "#define _PCD_VALUE_PcdSampleToken 0x222"\r
+                        // \r
                         hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
                                                      parentToken.cName,\r
                                                      printDatum);\r
+                        //\r
+                        // Example autogen string for following generation:\r
+                        // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+                        // \r
                         cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
                                                      Token.getAutogendatumTypeString(parentToken.datumType),\r
                                                      parentToken.cName,\r
                                                      parentToken.cName);\r
                     }\r
                 } else {\r
+                    //\r
+                    // Example autogen string for following generation:\r
+                    // "#define _PCD_VALUE_PcdSampleToken 0x222"\r
+                    // \r
                     hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
                                                  parentToken.cName,\r
                                                  printDatum);\r
+                    //\r
+                    // Example autogen string for following generation:\r
+                    // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+                    // \r
                     cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
                                                  Token.getAutogendatumTypeString(parentToken.datumType),\r
                                                  parentToken.cName,\r
@@ -264,16 +328,32 @@ public class UsageInstance {
             break;\r
         case PATCHABLE_IN_MODULE:\r
             if (isByteArray) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken[];"\r
+                // \r
                 hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",\r
                                              parentToken.cName);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_GET_MODE_8_PcdSampleToken  (VOID*)_gPcd_BinaryPatch_PcdSampleToken"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  (VOID*)_gPcd_BinaryPatch_%s\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
             } else {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken;"\r
+                // \r
                 hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
                                              Token.getAutogendatumTypeString(parentToken.datumType),\r
                                              parentToken.cName);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_GET_MODE_8_PcdSampleToken  _gPcd_BinaryPatch_PcdSampleToken"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  _gPcd_BinaryPatch_%s\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
@@ -284,11 +364,19 @@ public class UsageInstance {
             // Generate _PCD_SET_MODE_xx macro for using set BinaryPatch value via PcdSet macro\r
             //\r
             if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_PcdSampleToken, (Buffer), (SizeOfBuffer))"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_%s, (Buffer), (SizeOfBuffer))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
             } else {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) (_gPcd_BinaryPatch_PcdSampleToken = (Value))"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) (_gPcd_BinaryPatch_%s = (Value))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
@@ -296,14 +384,26 @@ public class UsageInstance {
             }\r
 \r
             if (!isBuildUsedLibrary) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_VALUE_PcdSampleToken   0x111"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
                                              parentToken.cName,\r
                                              printDatum);\r
                 if (isByteArray) {\r
+                    //\r
+                    // Example autogen string for following generation:\r
+                    // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+                    // \r
                     cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[] = _PCD_VALUE_%s;\r\n",\r
                                                  parentToken.cName,\r
                                                  parentToken.cName);\r
                 } else {\r
+                    //\r
+                    // Example autogen string for following generation:\r
+                    // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+                    // \r
                     cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",\r
                                                  Token.getAutogendatumTypeString(parentToken.datumType),\r
                                                  parentToken.cName,\r
@@ -313,18 +413,30 @@ public class UsageInstance {
 \r
             break;\r
         case DYNAMIC:\r
+            //\r
+            // Example autogen string for following generation:\r
+            // "#define _PCD_GET_MODE_8_PcdSampleToken  LibPcdGet%s(_PCD_TOKEN_PcdSampleToken)"\r
+            // \r
             hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  LibPcdGet%s(_PCD_TOKEN_%s)\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName,\r
                                          Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
                                          parentToken.cName);\r
             if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer)  LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer)  LibPcdSet%s(_PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
                                              parentToken.cName);\r
             } else {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(Value)  LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (Value))"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value)  LibPcdSet%s(_PCD_TOKEN_%s, (Value))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
@@ -336,6 +448,10 @@ public class UsageInstance {
             guidStringCName = "_gPcd_TokenSpaceGuid_" +\r
                               parentToken.tokenSpaceName.toString().replaceAll("-", "_");\r
 \r
+            //\r
+            // Example autogen string for following generation:\r
+            // "#define _PCD_GET_MODE_8_PcdSampleToken LibPcdGetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken)"\r
+            // \r
             hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName,\r
@@ -344,6 +460,10 @@ public class UsageInstance {
                                          parentToken.cName);\r
 \r
             if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
@@ -351,6 +471,10 @@ public class UsageInstance {
                                              guidStringCName,\r
                                              parentToken.cName);\r
             } else {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (Value))"\r
+                //\r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (Value))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r